clang 22.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 "clang/Sema/Template.h"
49#include "llvm/ADT/ArrayRef.h"
50#include "llvm/Support/ErrorHandling.h"
51#include <algorithm>
52#include <optional>
53
54using namespace llvm::omp;
55
56namespace clang {
57using namespace sema;
58
59// This helper class is used to facilitate pack expansion during tree transform.
69
70/// A semantic tree transformation that allows one to transform one
71/// abstract syntax tree into another.
72///
73/// A new tree transformation is defined by creating a new subclass \c X of
74/// \c TreeTransform<X> and then overriding certain operations to provide
75/// behavior specific to that transformation. For example, template
76/// instantiation is implemented as a tree transformation where the
77/// transformation of TemplateTypeParmType nodes involves substituting the
78/// template arguments for their corresponding template parameters; a similar
79/// transformation is performed for non-type template parameters and
80/// template template parameters.
81///
82/// This tree-transformation template uses static polymorphism to allow
83/// subclasses to customize any of its operations. Thus, a subclass can
84/// override any of the transformation or rebuild operators by providing an
85/// operation with the same signature as the default implementation. The
86/// overriding function should not be virtual.
87///
88/// Semantic tree transformations are split into two stages, either of which
89/// can be replaced by a subclass. The "transform" step transforms an AST node
90/// or the parts of an AST node using the various transformation functions,
91/// then passes the pieces on to the "rebuild" step, which constructs a new AST
92/// node of the appropriate kind from the pieces. The default transformation
93/// routines recursively transform the operands to composite AST nodes (e.g.,
94/// the pointee type of a PointerType node) and, if any of those operand nodes
95/// were changed by the transformation, invokes the rebuild operation to create
96/// a new AST node.
97///
98/// Subclasses can customize the transformation at various levels. The
99/// most coarse-grained transformations involve replacing TransformType(),
100/// TransformExpr(), TransformDecl(), TransformNestedNameSpecifierLoc(),
101/// TransformTemplateName(), or TransformTemplateArgument() with entirely
102/// new implementations.
103///
104/// For more fine-grained transformations, subclasses can replace any of the
105/// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
106/// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
107/// replacing TransformTemplateTypeParmType() allows template instantiation
108/// to substitute template arguments for their corresponding template
109/// parameters. Additionally, subclasses can override the \c RebuildXXX
110/// functions to control how AST nodes are rebuilt when their operands change.
111/// By default, \c TreeTransform will invoke semantic analysis to rebuild
112/// AST nodes. However, certain other tree transformations (e.g, cloning) may
113/// be able to use more efficient rebuild steps.
114///
115/// There are a handful of other functions that can be overridden, allowing one
116/// to avoid traversing nodes that don't need any transformation
117/// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
118/// operands have not changed (\c AlwaysRebuild()), and customize the
119/// default locations and entity names used for type-checking
120/// (\c getBaseLocation(), \c getBaseEntity()).
121template<typename Derived>
123 /// Private RAII object that helps us forget and then re-remember
124 /// the template argument corresponding to a partially-substituted parameter
125 /// pack.
126 class ForgetPartiallySubstitutedPackRAII {
127 Derived &Self;
129 // Set the pack expansion index to -1 to avoid pack substitution and
130 // indicate that parameter packs should be instantiated as themselves.
131 Sema::ArgPackSubstIndexRAII ResetPackSubstIndex;
132
133 public:
134 ForgetPartiallySubstitutedPackRAII(Derived &Self)
135 : Self(Self), ResetPackSubstIndex(Self.getSema(), std::nullopt) {
136 Old = Self.ForgetPartiallySubstitutedPack();
137 }
138
139 ~ForgetPartiallySubstitutedPackRAII() {
140 Self.RememberPartiallySubstitutedPack(Old);
141 }
142 ForgetPartiallySubstitutedPackRAII(
143 const ForgetPartiallySubstitutedPackRAII &) = delete;
144 ForgetPartiallySubstitutedPackRAII &
145 operator=(const ForgetPartiallySubstitutedPackRAII &) = delete;
146 };
147
148protected:
150
151 /// The set of local declarations that have been transformed, for
152 /// cases where we are forced to build new declarations within the transformer
153 /// rather than in the subclass (e.g., lambda closure types).
154 llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls;
155
156public:
157 /// Initializes a new tree transformer.
159
160 /// Retrieves a reference to the derived class.
161 Derived &getDerived() { return static_cast<Derived&>(*this); }
162
163 /// Retrieves a reference to the derived class.
164 const Derived &getDerived() const {
165 return static_cast<const Derived&>(*this);
166 }
167
168 static inline ExprResult Owned(Expr *E) { return E; }
169 static inline StmtResult Owned(Stmt *S) { return S; }
170
171 /// Retrieves a reference to the semantic analysis object used for
172 /// this tree transform.
173 Sema &getSema() const { return SemaRef; }
174
175 /// Whether the transformation should always rebuild AST nodes, even
176 /// if none of the children have changed.
177 ///
178 /// Subclasses may override this function to specify when the transformation
179 /// should rebuild all AST nodes.
180 ///
181 /// We must always rebuild all AST nodes when performing variadic template
182 /// pack expansion, in order to avoid violating the AST invariant that each
183 /// statement node appears at most once in its containing declaration.
184 bool AlwaysRebuild() { return static_cast<bool>(SemaRef.ArgPackSubstIndex); }
185
186 /// Whether the transformation is forming an expression or statement that
187 /// replaces the original. In this case, we'll reuse mangling numbers from
188 /// existing lambdas.
189 bool ReplacingOriginal() { return false; }
190
191 /// Wether CXXConstructExpr can be skipped when they are implicit.
192 /// They will be reconstructed when used if needed.
193 /// This is useful when the user that cause rebuilding of the
194 /// CXXConstructExpr is outside of the expression at which the TreeTransform
195 /// started.
196 bool AllowSkippingCXXConstructExpr() { return true; }
197
198 /// Returns the location of the entity being transformed, if that
199 /// information was not available elsewhere in the AST.
200 ///
201 /// By default, returns no source-location information. Subclasses can
202 /// provide an alternative implementation that provides better location
203 /// information.
205
206 /// Returns the name of the entity being transformed, if that
207 /// information was not available elsewhere in the AST.
208 ///
209 /// By default, returns an empty name. Subclasses can provide an alternative
210 /// implementation with a more precise name.
212
213 /// Sets the "base" location and entity when that
214 /// information is known based on another transformation.
215 ///
216 /// By default, the source location and entity are ignored. Subclasses can
217 /// override this function to provide a customized implementation.
219
220 /// RAII object that temporarily sets the base location and entity
221 /// used for reporting diagnostics in types.
223 TreeTransform &Self;
224 SourceLocation OldLocation;
225 DeclarationName OldEntity;
226
227 public:
229 DeclarationName Entity) : Self(Self) {
230 OldLocation = Self.getDerived().getBaseLocation();
231 OldEntity = Self.getDerived().getBaseEntity();
232
233 if (Location.isValid())
234 Self.getDerived().setBase(Location, Entity);
235 }
236
238 Self.getDerived().setBase(OldLocation, OldEntity);
239 }
240 TemporaryBase(const TemporaryBase &) = delete;
242 };
243
244 /// Determine whether the given type \p T has already been
245 /// transformed.
246 ///
247 /// Subclasses can provide an alternative implementation of this routine
248 /// to short-circuit evaluation when it is known that a given type will
249 /// not change. For example, template instantiation need not traverse
250 /// non-dependent types.
252 return T.isNull();
253 }
254
255 /// Transform a template parameter depth level.
256 ///
257 /// During a transformation that transforms template parameters, this maps
258 /// an old template parameter depth to a new depth.
259 unsigned TransformTemplateDepth(unsigned Depth) {
260 return Depth;
261 }
262
263 /// Determine whether the given call argument should be dropped, e.g.,
264 /// because it is a default argument.
265 ///
266 /// Subclasses can provide an alternative implementation of this routine to
267 /// determine which kinds of call arguments get dropped. By default,
268 /// CXXDefaultArgument nodes are dropped (prior to transformation).
270 return E->isDefaultArgument();
271 }
272
273 /// Determine whether we should expand a pack expansion with the
274 /// given set of parameter packs into separate arguments by repeatedly
275 /// transforming the pattern.
276 ///
277 /// By default, the transformer never tries to expand pack expansions.
278 /// Subclasses can override this routine to provide different behavior.
279 ///
280 /// \param EllipsisLoc The location of the ellipsis that identifies the
281 /// pack expansion.
282 ///
283 /// \param PatternRange The source range that covers the entire pattern of
284 /// the pack expansion.
285 ///
286 /// \param Unexpanded The set of unexpanded parameter packs within the
287 /// pattern.
288 ///
289 /// \param ShouldExpand Will be set to \c true if the transformer should
290 /// expand the corresponding pack expansions into separate arguments. When
291 /// set, \c NumExpansions must also be set.
292 ///
293 /// \param RetainExpansion Whether the caller should add an unexpanded
294 /// pack expansion after all of the expanded arguments. This is used
295 /// when extending explicitly-specified template argument packs per
296 /// C++0x [temp.arg.explicit]p9.
297 ///
298 /// \param NumExpansions The number of separate arguments that will be in
299 /// the expanded form of the corresponding pack expansion. This is both an
300 /// input and an output parameter, which can be set by the caller if the
301 /// number of expansions is known a priori (e.g., due to a prior substitution)
302 /// and will be set by the callee when the number of expansions is known.
303 /// The callee must set this value when \c ShouldExpand is \c true; it may
304 /// set this value in other cases.
305 ///
306 /// \returns true if an error occurred (e.g., because the parameter packs
307 /// are to be instantiated with arguments of different lengths), false
308 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
309 /// must be set.
311 SourceRange PatternRange,
313 bool FailOnPackProducingTemplates,
314 bool &ShouldExpand, bool &RetainExpansion,
315 UnsignedOrNone &NumExpansions) {
316 ShouldExpand = false;
317 return false;
318 }
319
320 /// "Forget" about the partially-substituted pack template argument,
321 /// when performing an instantiation that must preserve the parameter pack
322 /// use.
323 ///
324 /// This routine is meant to be overridden by the template instantiator.
328
329 /// "Remember" the partially-substituted pack template argument
330 /// after performing an instantiation that must preserve the parameter pack
331 /// use.
332 ///
333 /// This routine is meant to be overridden by the template instantiator.
335
336 /// "Forget" the template substitution to allow transforming the AST without
337 /// any template instantiations. This is used to expand template packs when
338 /// their size is not known in advance (e.g. for builtins that produce type
339 /// packs).
342
343private:
344 struct ForgetSubstitutionRAII {
345 Derived &Self;
347
348 public:
349 ForgetSubstitutionRAII(Derived &Self) : Self(Self) {
350 Old = Self.ForgetSubstitution();
351 }
352
353 ~ForgetSubstitutionRAII() { Self.RememberSubstitution(std::move(Old)); }
354 };
355
356public:
357 /// Note to the derived class when a function parameter pack is
358 /// being expanded.
360
361 /// Transforms the given type into another type.
362 ///
363 /// By default, this routine transforms a type by creating a
364 /// TypeSourceInfo for it and delegating to the appropriate
365 /// function. This is expensive, but we don't mind, because
366 /// this method is deprecated anyway; all users should be
367 /// switched to storing TypeSourceInfos.
368 ///
369 /// \returns the transformed type.
371
372 /// Transforms the given type-with-location into a new
373 /// type-with-location.
374 ///
375 /// By default, this routine transforms a type by delegating to the
376 /// appropriate TransformXXXType to build a new type. Subclasses
377 /// may override this function (to take over all type
378 /// transformations) or some set of the TransformXXXType functions
379 /// to alter the transformation.
381
382 /// Transform the given type-with-location into a new
383 /// type, collecting location information in the given builder
384 /// as necessary.
385 ///
387
388 /// Transform a type that is permitted to produce a
389 /// DeducedTemplateSpecializationType.
390 ///
391 /// This is used in the (relatively rare) contexts where it is acceptable
392 /// for transformation to produce a class template type with deduced
393 /// template arguments.
394 /// @{
397 /// @}
398
399 /// The reason why the value of a statement is not discarded, if any.
405
406 /// Transform the given statement.
407 ///
408 /// By default, this routine transforms a statement by delegating to the
409 /// appropriate TransformXXXStmt function to transform a specific kind of
410 /// statement or the TransformExpr() function to transform an expression.
411 /// Subclasses may override this function to transform statements using some
412 /// other mechanism.
413 ///
414 /// \returns the transformed statement.
417
418 /// Transform the given statement.
419 ///
420 /// By default, this routine transforms a statement by delegating to the
421 /// appropriate TransformOMPXXXClause function to transform a specific kind
422 /// of clause. Subclasses may override this function to transform statements
423 /// using some other mechanism.
424 ///
425 /// \returns the transformed OpenMP clause.
427
428 /// Transform the given attribute.
429 ///
430 /// By default, this routine transforms a statement by delegating to the
431 /// appropriate TransformXXXAttr function to transform a specific kind
432 /// of attribute. Subclasses may override this function to transform
433 /// attributed statements/types using some other mechanism.
434 ///
435 /// \returns the transformed attribute
436 const Attr *TransformAttr(const Attr *S);
437
438 // Transform the given statement attribute.
439 //
440 // Delegates to the appropriate TransformXXXAttr function to transform a
441 // specific kind of statement attribute. Unlike the non-statement taking
442 // version of this, this implements all attributes, not just pragmas.
443 const Attr *TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS,
444 const Attr *A);
445
446 // Transform the specified attribute.
447 //
448 // Subclasses should override the transformation of attributes with a pragma
449 // spelling to transform expressions stored within the attribute.
450 //
451 // \returns the transformed attribute.
452#define ATTR(X) \
453 const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; }
454#include "clang/Basic/AttrList.inc"
455
456 // Transform the specified attribute.
457 //
458 // Subclasses should override the transformation of attributes to do
459 // transformation and checking of statement attributes. By default, this
460 // delegates to the non-statement taking version.
461 //
462 // \returns the transformed attribute.
463#define ATTR(X) \
464 const X##Attr *TransformStmt##X##Attr(const Stmt *, const Stmt *, \
465 const X##Attr *A) { \
466 return getDerived().Transform##X##Attr(A); \
467 }
468#include "clang/Basic/AttrList.inc"
469
470 /// Transform the given expression.
471 ///
472 /// By default, this routine transforms an expression by delegating to the
473 /// appropriate TransformXXXExpr function to build a new expression.
474 /// Subclasses may override this function to transform expressions using some
475 /// other mechanism.
476 ///
477 /// \returns the transformed expression.
479
480 /// Transform the given initializer.
481 ///
482 /// By default, this routine transforms an initializer by stripping off the
483 /// semantic nodes added by initialization, then passing the result to
484 /// TransformExpr or TransformExprs.
485 ///
486 /// \returns the transformed initializer.
488
489 /// Transform the given list of expressions.
490 ///
491 /// This routine transforms a list of expressions by invoking
492 /// \c TransformExpr() for each subexpression. However, it also provides
493 /// support for variadic templates by expanding any pack expansions (if the
494 /// derived class permits such expansion) along the way. When pack expansions
495 /// are present, the number of outputs may not equal the number of inputs.
496 ///
497 /// \param Inputs The set of expressions to be transformed.
498 ///
499 /// \param NumInputs The number of expressions in \c Inputs.
500 ///
501 /// \param IsCall If \c true, then this transform is being performed on
502 /// function-call arguments, and any arguments that should be dropped, will
503 /// be.
504 ///
505 /// \param Outputs The transformed input expressions will be added to this
506 /// vector.
507 ///
508 /// \param ArgChanged If non-NULL, will be set \c true if any argument changed
509 /// due to transformation.
510 ///
511 /// \returns true if an error occurred, false otherwise.
512 bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall,
514 bool *ArgChanged = nullptr);
515
516 /// Transform the given declaration, which is referenced from a type
517 /// or expression.
518 ///
519 /// By default, acts as the identity function on declarations, unless the
520 /// transformer has had to transform the declaration itself. Subclasses
521 /// may override this function to provide alternate behavior.
523 llvm::DenseMap<Decl *, Decl *>::iterator Known
524 = TransformedLocalDecls.find(D);
525 if (Known != TransformedLocalDecls.end())
526 return Known->second;
527
528 return D;
529 }
530
531 /// Transform the specified condition.
532 ///
533 /// By default, this transforms the variable and expression and rebuilds
534 /// the condition.
536 Expr *Expr,
538
539 /// Transform the attributes associated with the given declaration and
540 /// place them on the new declaration.
541 ///
542 /// By default, this operation does nothing. Subclasses may override this
543 /// behavior to transform attributes.
544 void transformAttrs(Decl *Old, Decl *New) { }
545
546 /// Note that a local declaration has been transformed by this
547 /// transformer.
548 ///
549 /// Local declarations are typically transformed via a call to
550 /// TransformDefinition. However, in some cases (e.g., lambda expressions),
551 /// the transformer itself has to transform the declarations. This routine
552 /// can be overridden by a subclass that keeps track of such mappings.
554 assert(New.size() == 1 &&
555 "must override transformedLocalDecl if performing pack expansion");
556 TransformedLocalDecls[Old] = New.front();
557 }
558
559 /// Transform the definition of the given declaration.
560 ///
561 /// By default, invokes TransformDecl() to transform the declaration.
562 /// Subclasses may override this function to provide alternate behavior.
564 return getDerived().TransformDecl(Loc, D);
565 }
566
567 /// Transform the given declaration, which was the first part of a
568 /// nested-name-specifier in a member access expression.
569 ///
570 /// This specific declaration transformation only applies to the first
571 /// identifier in a nested-name-specifier of a member access expression, e.g.,
572 /// the \c T in \c x->T::member
573 ///
574 /// By default, invokes TransformDecl() to transform the declaration.
575 /// Subclasses may override this function to provide alternate behavior.
577 return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D));
578 }
579
580 /// Transform the set of declarations in an OverloadExpr.
581 bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL,
582 LookupResult &R);
583
584 /// Transform the given nested-name-specifier with source-location
585 /// information.
586 ///
587 /// By default, transforms all of the types and declarations within the
588 /// nested-name-specifier. Subclasses may override this function to provide
589 /// alternate behavior.
592 QualType ObjectType = QualType(),
593 NamedDecl *FirstQualifierInScope = nullptr);
594
595 /// Transform the given declaration name.
596 ///
597 /// By default, transforms the types of conversion function, constructor,
598 /// and destructor names and then (if needed) rebuilds the declaration name.
599 /// Identifiers and selectors are returned unmodified. Subclasses may
600 /// override this function to provide alternate behavior.
603
613
614 /// Transform the given template name.
615 ///
616 /// \param SS The nested-name-specifier that qualifies the template
617 /// name. This nested-name-specifier must already have been transformed.
618 ///
619 /// \param Name The template name to transform.
620 ///
621 /// \param NameLoc The source location of the template name.
622 ///
623 /// \param ObjectType If we're translating a template name within a member
624 /// access expression, this is the type of the object whose member template
625 /// is being referenced.
626 ///
627 /// \param FirstQualifierInScope If the first part of a nested-name-specifier
628 /// also refers to a name within the current (lexical) scope, this is the
629 /// declaration it refers to.
630 ///
631 /// By default, transforms the template name by transforming the declarations
632 /// and nested-name-specifiers that occur within the template name.
633 /// Subclasses may override this function to provide alternate behavior.
635 SourceLocation TemplateKWLoc,
636 TemplateName Name, SourceLocation NameLoc,
637 QualType ObjectType = QualType(),
638 NamedDecl *FirstQualifierInScope = nullptr,
639 bool AllowInjectedClassName = false);
640
641 /// Transform the given template argument.
642 ///
643 /// By default, this operation transforms the type, expression, or
644 /// declaration stored within the template argument and constructs a
645 /// new template argument from the transformed result. Subclasses may
646 /// override this function to provide alternate behavior.
647 ///
648 /// Returns true if there was an error.
650 TemplateArgumentLoc &Output,
651 bool Uneval = false);
652
654 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
655 TemplateName Name, SourceLocation NameLoc);
656
657 /// Transform the given set of template arguments.
658 ///
659 /// By default, this operation transforms all of the template arguments
660 /// in the input set using \c TransformTemplateArgument(), and appends
661 /// the transformed arguments to the output list.
662 ///
663 /// Note that this overload of \c TransformTemplateArguments() is merely
664 /// a convenience function. Subclasses that wish to override this behavior
665 /// should override the iterator-based member template version.
666 ///
667 /// \param Inputs The set of template arguments to be transformed.
668 ///
669 /// \param NumInputs The number of template arguments in \p Inputs.
670 ///
671 /// \param Outputs The set of transformed template arguments output by this
672 /// routine.
673 ///
674 /// Returns true if an error occurred.
676 unsigned NumInputs,
678 bool Uneval = false) {
679 return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs,
680 Uneval);
681 }
682
683 /// Transform the given set of template arguments.
684 ///
685 /// By default, this operation transforms all of the template arguments
686 /// in the input set using \c TransformTemplateArgument(), and appends
687 /// the transformed arguments to the output list.
688 ///
689 /// \param First An iterator to the first template argument.
690 ///
691 /// \param Last An iterator one step past the last template argument.
692 ///
693 /// \param Outputs The set of transformed template arguments output by this
694 /// routine.
695 ///
696 /// Returns true if an error occurred.
697 template<typename InputIterator>
699 InputIterator Last,
701 bool Uneval = false);
702
703 template <typename InputIterator>
705 InputIterator Last,
707 bool Uneval = false);
708
709 /// Checks if the argument pack from \p In will need to be expanded and does
710 /// the necessary prework.
711 /// Whether the expansion is needed is captured in Info.Expand.
712 ///
713 /// - When the expansion is required, \p Out will be a template pattern that
714 /// would need to be expanded.
715 /// - When the expansion must not happen, \p Out will be a pack that must be
716 /// returned to the outputs directly.
717 ///
718 /// \return true iff the error occurred
721
722 /// Fakes up a TemplateArgumentLoc for a given TemplateArgument.
724 TemplateArgumentLoc &ArgLoc);
725
726 /// Fakes up a TypeSourceInfo for a type.
728 return SemaRef.Context.getTrivialTypeSourceInfo(T,
730 }
731
732#define ABSTRACT_TYPELOC(CLASS, PARENT)
733#define TYPELOC(CLASS, PARENT) \
734 QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
735#include "clang/AST/TypeLocNodes.def"
736
739 bool SuppressObjCLifetime);
743 bool SuppressObjCLifetime);
744
745 template<typename Fn>
748 CXXRecordDecl *ThisContext,
749 Qualifiers ThisTypeQuals,
751
754 SmallVectorImpl<QualType> &Exceptions,
755 bool &Changed);
756
758
761 QualType ObjectType,
762 NamedDecl *FirstQualifierInScope,
763 bool AllowInjectedClassName);
764
766
767 /// Transforms the parameters of a function type into the
768 /// given vectors.
769 ///
770 /// The result vectors should be kept in sync; null entries in the
771 /// variables vector are acceptable.
772 ///
773 /// LastParamTransformed, if non-null, will be set to the index of the last
774 /// parameter on which transformation was started. In the event of an error,
775 /// this will contain the parameter which failed to instantiate.
776 ///
777 /// Return true on error.
780 const QualType *ParamTypes,
781 const FunctionProtoType::ExtParameterInfo *ParamInfos,
783 Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed);
784
787 const QualType *ParamTypes,
788 const FunctionProtoType::ExtParameterInfo *ParamInfos,
791 return getDerived().TransformFunctionTypeParams(
792 Loc, Params, ParamTypes, ParamInfos, PTypes, PVars, PInfos, nullptr);
793 }
794
795 /// Transforms the parameters of a requires expresison into the given vectors.
796 ///
797 /// The result vectors should be kept in sync; null entries in the
798 /// variables vector are acceptable.
799 ///
800 /// Returns an unset ExprResult on success. Returns an ExprResult the 'not
801 /// satisfied' RequiresExpr if subsitution failed, OR an ExprError, both of
802 /// which are cases where transformation shouldn't continue.
804 SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
810 KWLoc, Params, /*ParamTypes=*/nullptr,
811 /*ParamInfos=*/nullptr, PTypes, &TransParams, PInfos))
812 return ExprError();
813
814 return ExprResult{};
815 }
816
817 /// Transforms a single function-type parameter. Return null
818 /// on error.
819 ///
820 /// \param indexAdjustment - A number to add to the parameter's
821 /// scope index; can be negative
823 int indexAdjustment,
824 UnsignedOrNone NumExpansions,
825 bool ExpectParameterPack);
826
827 /// Transform the body of a lambda-expression.
829 /// Alternative implementation of TransformLambdaBody that skips transforming
830 /// the body.
832
838
840
843
848
850
852 bool IsAddressOfOperand,
853 TypeSourceInfo **RecoveryTSI);
854
856 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
857 TypeSourceInfo **RecoveryTSI);
858
860 bool IsAddressOfOperand);
861
863
865
866// FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
867// amount of stack usage with clang.
868#define STMT(Node, Parent) \
869 LLVM_ATTRIBUTE_NOINLINE \
870 StmtResult Transform##Node(Node *S);
871#define VALUESTMT(Node, Parent) \
872 LLVM_ATTRIBUTE_NOINLINE \
873 StmtResult Transform##Node(Node *S, StmtDiscardKind SDK);
874#define EXPR(Node, Parent) \
875 LLVM_ATTRIBUTE_NOINLINE \
876 ExprResult Transform##Node(Node *E);
877#define ABSTRACT_STMT(Stmt)
878#include "clang/AST/StmtNodes.inc"
879
880#define GEN_CLANG_CLAUSE_CLASS
881#define CLAUSE_CLASS(Enum, Str, Class) \
882 LLVM_ATTRIBUTE_NOINLINE \
883 OMPClause *Transform##Class(Class *S);
884#include "llvm/Frontend/OpenMP/OMP.inc"
885
886 /// Build a new qualified type given its unqualified type and type location.
887 ///
888 /// By default, this routine adds type qualifiers only to types that can
889 /// have qualifiers, and silently suppresses those qualifiers that are not
890 /// permitted. Subclasses may override this routine to provide different
891 /// behavior.
893
894 /// Build a new pointer type given its pointee type.
895 ///
896 /// By default, performs semantic analysis when building the pointer type.
897 /// Subclasses may override this routine to provide different behavior.
899
900 /// Build a new block pointer type given its pointee type.
901 ///
902 /// By default, performs semantic analysis when building the block pointer
903 /// type. Subclasses may override this routine to provide different behavior.
905
906 /// Build a new reference type given the type it references.
907 ///
908 /// By default, performs semantic analysis when building the
909 /// reference type. Subclasses may override this routine to provide
910 /// different behavior.
911 ///
912 /// \param LValue whether the type was written with an lvalue sigil
913 /// or an rvalue sigil.
915 bool LValue,
916 SourceLocation Sigil);
917
918 /// Build a new member pointer type given the pointee type and the
919 /// qualifier it refers into.
920 ///
921 /// By default, performs semantic analysis when building the member pointer
922 /// type. Subclasses may override this routine to provide different behavior.
924 const CXXScopeSpec &SS, CXXRecordDecl *Cls,
925 SourceLocation Sigil);
926
928 SourceLocation ProtocolLAngleLoc,
930 ArrayRef<SourceLocation> ProtocolLocs,
931 SourceLocation ProtocolRAngleLoc);
932
933 /// Build an Objective-C object type.
934 ///
935 /// By default, performs semantic analysis when building the object type.
936 /// Subclasses may override this routine to provide different behavior.
938 SourceLocation Loc,
939 SourceLocation TypeArgsLAngleLoc,
941 SourceLocation TypeArgsRAngleLoc,
942 SourceLocation ProtocolLAngleLoc,
944 ArrayRef<SourceLocation> ProtocolLocs,
945 SourceLocation ProtocolRAngleLoc);
946
947 /// Build a new Objective-C object pointer type given the pointee type.
948 ///
949 /// By default, directly builds the pointer type, with no additional semantic
950 /// analysis.
953
954 /// Build a new array type given the element type, size
955 /// modifier, size of the array (if known), size expression, and index type
956 /// qualifiers.
957 ///
958 /// By default, performs semantic analysis when building the array type.
959 /// Subclasses may override this routine to provide different behavior.
960 /// Also by default, all of the other Rebuild*Array
962 const llvm::APInt *Size, Expr *SizeExpr,
963 unsigned IndexTypeQuals, SourceRange BracketsRange);
964
965 /// Build a new constant array type given the element type, size
966 /// modifier, (known) size of the array, and index type qualifiers.
967 ///
968 /// By default, performs semantic analysis when building the array type.
969 /// Subclasses may override this routine to provide different behavior.
971 ArraySizeModifier SizeMod,
972 const llvm::APInt &Size, Expr *SizeExpr,
973 unsigned IndexTypeQuals,
974 SourceRange BracketsRange);
975
976 /// Build a new incomplete array type given the element type, size
977 /// modifier, and index type qualifiers.
978 ///
979 /// By default, performs semantic analysis when building the array type.
980 /// Subclasses may override this routine to provide different behavior.
982 ArraySizeModifier SizeMod,
983 unsigned IndexTypeQuals,
984 SourceRange BracketsRange);
985
986 /// Build a new variable-length array type given the element type,
987 /// size modifier, size expression, and index type qualifiers.
988 ///
989 /// By default, performs semantic analysis when building the array type.
990 /// Subclasses may override this routine to provide different behavior.
992 ArraySizeModifier SizeMod, Expr *SizeExpr,
993 unsigned IndexTypeQuals,
994 SourceRange BracketsRange);
995
996 /// Build a new dependent-sized array type given the element type,
997 /// size modifier, size expression, and index type qualifiers.
998 ///
999 /// By default, performs semantic analysis when building the array type.
1000 /// Subclasses may override this routine to provide different behavior.
1002 ArraySizeModifier SizeMod,
1003 Expr *SizeExpr,
1004 unsigned IndexTypeQuals,
1005 SourceRange BracketsRange);
1006
1007 /// Build a new vector type given the element type and
1008 /// number of elements.
1009 ///
1010 /// By default, performs semantic analysis when building the vector type.
1011 /// Subclasses may override this routine to provide different behavior.
1012 QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
1013 VectorKind VecKind);
1014
1015 /// Build a new potentially dependently-sized extended vector type
1016 /// given the element type and number of elements.
1017 ///
1018 /// By default, performs semantic analysis when building the vector type.
1019 /// Subclasses may override this routine to provide different behavior.
1021 SourceLocation AttributeLoc, VectorKind);
1022
1023 /// Build a new extended vector type given the element type and
1024 /// number of elements.
1025 ///
1026 /// By default, performs semantic analysis when building the vector type.
1027 /// Subclasses may override this routine to provide different behavior.
1028 QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
1029 SourceLocation AttributeLoc);
1030
1031 /// Build a new potentially dependently-sized extended vector type
1032 /// given the element type and number of elements.
1033 ///
1034 /// By default, performs semantic analysis when building the vector type.
1035 /// Subclasses may override this routine to provide different behavior.
1037 Expr *SizeExpr,
1038 SourceLocation AttributeLoc);
1039
1040 /// Build a new matrix type given the element type and dimensions.
1041 QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows,
1042 unsigned NumColumns);
1043
1044 /// Build a new matrix type given the type and dependently-defined
1045 /// dimensions.
1047 Expr *ColumnExpr,
1048 SourceLocation AttributeLoc);
1049
1050 /// Build a new DependentAddressSpaceType or return the pointee
1051 /// type variable with the correct address space (retrieved from
1052 /// AddrSpaceExpr) applied to it. The former will be returned in cases
1053 /// where the address space remains dependent.
1054 ///
1055 /// By default, performs semantic analysis when building the type with address
1056 /// space applied. Subclasses may override this routine to provide different
1057 /// behavior.
1059 Expr *AddrSpaceExpr,
1060 SourceLocation AttributeLoc);
1061
1062 /// Build a new function type.
1063 ///
1064 /// By default, performs semantic analysis when building the function type.
1065 /// Subclasses may override this routine to provide different behavior.
1067 MutableArrayRef<QualType> ParamTypes,
1069
1070 /// Build a new unprototyped function type.
1072
1073 /// Rebuild an unresolved typename type, given the decl that
1074 /// the UnresolvedUsingTypenameDecl was transformed to.
1076 NestedNameSpecifier Qualifier,
1077 SourceLocation NameLoc, Decl *D);
1078
1079 /// Build a new type found via an alias.
1082 QualType UnderlyingType) {
1083 return SemaRef.Context.getUsingType(Keyword, Qualifier, D, UnderlyingType);
1084 }
1085
1086 /// Build a new typedef type.
1088 NestedNameSpecifier Qualifier,
1090 return SemaRef.Context.getTypedefType(Keyword, Qualifier, Typedef);
1091 }
1092
1093 /// Build a new MacroDefined type.
1095 const IdentifierInfo *MacroII) {
1096 return SemaRef.Context.getMacroQualifiedType(T, MacroII);
1097 }
1098
1099 /// Build a new class/struct/union/enum type.
1101 NestedNameSpecifier Qualifier, TagDecl *Tag) {
1102 return SemaRef.Context.getTagType(Keyword, Qualifier, Tag,
1103 /*OwnsTag=*/false);
1104 }
1106 return SemaRef.Context.getCanonicalTagType(Tag);
1107 }
1108
1109 /// Build a new typeof(expr) type.
1110 ///
1111 /// By default, performs semantic analysis when building the typeof type.
1112 /// Subclasses may override this routine to provide different behavior.
1114 TypeOfKind Kind);
1115
1116 /// Build a new typeof(type) type.
1117 ///
1118 /// By default, builds a new TypeOfType with the given underlying type.
1120
1121 /// Build a new unary transform type.
1123 UnaryTransformType::UTTKind UKind,
1124 SourceLocation Loc);
1125
1126 /// Build a new C++11 decltype type.
1127 ///
1128 /// By default, performs semantic analysis when building the decltype type.
1129 /// Subclasses may override this routine to provide different behavior.
1131
1133 SourceLocation Loc,
1134 SourceLocation EllipsisLoc,
1135 bool FullySubstituted,
1136 ArrayRef<QualType> Expansions = {});
1137
1138 /// Build a new C++11 auto type.
1139 ///
1140 /// By default, builds a new AutoType with the given deduced type.
1142 ConceptDecl *TypeConstraintConcept,
1143 ArrayRef<TemplateArgument> TypeConstraintArgs) {
1144 // Note, IsDependent is always false here: we implicitly convert an 'auto'
1145 // which has been deduced to a dependent type into an undeduced 'auto', so
1146 // that we'll retry deduction after the transformation.
1147 return SemaRef.Context.getAutoType(Deduced, Keyword,
1148 /*IsDependent*/ false, /*IsPack=*/false,
1149 TypeConstraintConcept,
1150 TypeConstraintArgs);
1151 }
1152
1153 /// By default, builds a new DeducedTemplateSpecializationType with the given
1154 /// deduced type.
1157 return SemaRef.Context.getDeducedTemplateSpecializationType(
1158 Keyword, Template, Deduced, /*IsDependent*/ false);
1159 }
1160
1161 /// Build a new template specialization type.
1162 ///
1163 /// By default, performs semantic analysis when building the template
1164 /// specialization type. Subclasses may override this routine to provide
1165 /// different behavior.
1168 SourceLocation TemplateLoc,
1170
1171 /// Build a new parenthesized type.
1172 ///
1173 /// By default, builds a new ParenType type from the inner type.
1174 /// Subclasses may override this routine to provide different behavior.
1176 return SemaRef.BuildParenType(InnerType);
1177 }
1178
1179 /// Build a new typename type that refers to an identifier.
1180 ///
1181 /// By default, performs semantic analysis when building the typename type
1182 /// (or elaborated type). Subclasses may override this routine to provide
1183 /// different behavior.
1185 SourceLocation KeywordLoc,
1186 NestedNameSpecifierLoc QualifierLoc,
1187 const IdentifierInfo *Id,
1188 SourceLocation IdLoc,
1189 bool DeducedTSTContext) {
1190 CXXScopeSpec SS;
1191 SS.Adopt(QualifierLoc);
1192
1193 if (QualifierLoc.getNestedNameSpecifier().isDependent()) {
1194 // If the name is still dependent, just build a new dependent name type.
1195 if (!SemaRef.computeDeclContext(SS))
1196 return SemaRef.Context.getDependentNameType(Keyword,
1197 QualifierLoc.getNestedNameSpecifier(),
1198 Id);
1199 }
1200
1203 return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1204 *Id, IdLoc, DeducedTSTContext);
1205 }
1206
1208
1209 // We had a dependent elaborated-type-specifier that has been transformed
1210 // into a non-dependent elaborated-type-specifier. Find the tag we're
1211 // referring to.
1213 DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1214 if (!DC)
1215 return QualType();
1216
1217 if (SemaRef.RequireCompleteDeclContext(SS, DC))
1218 return QualType();
1219
1220 TagDecl *Tag = nullptr;
1221 SemaRef.LookupQualifiedName(Result, DC);
1222 switch (Result.getResultKind()) {
1225 break;
1226
1228 Tag = Result.getAsSingle<TagDecl>();
1229 break;
1230
1233 llvm_unreachable("Tag lookup cannot find non-tags");
1234
1236 // Let the LookupResult structure handle ambiguities.
1237 return QualType();
1238 }
1239
1240 if (!Tag) {
1241 // Check where the name exists but isn't a tag type and use that to emit
1242 // better diagnostics.
1244 SemaRef.LookupQualifiedName(Result, DC);
1245 switch (Result.getResultKind()) {
1249 NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1250 NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1251 SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag)
1252 << SomeDecl << NTK << Kind;
1253 SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1254 break;
1255 }
1256 default:
1257 SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1258 << Kind << Id << DC << QualifierLoc.getSourceRange();
1259 break;
1260 }
1261 return QualType();
1262 }
1263 if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1264 IdLoc, Id)) {
1265 SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1266 SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1267 return QualType();
1268 }
1269 return getDerived().RebuildTagType(
1270 Keyword, QualifierLoc.getNestedNameSpecifier(), Tag);
1271 }
1272
1273 /// Build a new pack expansion type.
1274 ///
1275 /// By default, builds a new PackExpansionType type from the given pattern.
1276 /// Subclasses may override this routine to provide different behavior.
1278 SourceLocation EllipsisLoc,
1279 UnsignedOrNone NumExpansions) {
1280 return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1281 NumExpansions);
1282 }
1283
1284 /// Build a new atomic type given its value type.
1285 ///
1286 /// By default, performs semantic analysis when building the atomic type.
1287 /// Subclasses may override this routine to provide different behavior.
1289
1290 /// Build a new pipe type given its value type.
1292 bool isReadPipe);
1293
1294 /// Build a bit-precise int given its value type.
1295 QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits,
1296 SourceLocation Loc);
1297
1298 /// Build a dependent bit-precise int given its value type.
1299 QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
1300 SourceLocation Loc);
1301
1302 /// Build a new template name given a nested name specifier, a flag
1303 /// indicating whether the "template" keyword was provided, and the template
1304 /// that the template name refers to.
1305 ///
1306 /// By default, builds the new template name directly. Subclasses may override
1307 /// this routine to provide different behavior.
1309 TemplateName Name);
1310
1311 /// Build a new template name given a nested name specifier and the
1312 /// name that is referred to as a template.
1313 ///
1314 /// By default, performs semantic analysis to determine whether the name can
1315 /// be resolved to a specific template, then builds the appropriate kind of
1316 /// template name. Subclasses may override this routine to provide different
1317 /// behavior.
1319 SourceLocation TemplateKWLoc,
1320 const IdentifierInfo &Name,
1321 SourceLocation NameLoc, QualType ObjectType,
1322 bool AllowInjectedClassName);
1323
1324 /// Build a new template name given a nested name specifier and the
1325 /// overloaded operator name that is referred to as a template.
1326 ///
1327 /// By default, performs semantic analysis to determine whether the name can
1328 /// be resolved to a specific template, then builds the appropriate kind of
1329 /// template name. Subclasses may override this routine to provide different
1330 /// behavior.
1332 SourceLocation TemplateKWLoc,
1333 OverloadedOperatorKind Operator,
1334 SourceLocation NameLoc, QualType ObjectType,
1335 bool AllowInjectedClassName);
1336
1338 SourceLocation TemplateKWLoc,
1340 SourceLocation NameLoc, QualType ObjectType,
1341 bool AllowInjectedClassName);
1342
1343 /// Build a new template name given a template template parameter pack
1344 /// and the
1345 ///
1346 /// By default, performs semantic analysis to determine whether the name can
1347 /// be resolved to a specific template, then builds the appropriate kind of
1348 /// template name. Subclasses may override this routine to provide different
1349 /// behavior.
1351 Decl *AssociatedDecl, unsigned Index,
1352 bool Final) {
1354 ArgPack, AssociatedDecl, Index, Final);
1355 }
1356
1357 /// Build a new compound statement.
1358 ///
1359 /// By default, performs semantic analysis to build the new statement.
1360 /// Subclasses may override this routine to provide different behavior.
1362 MultiStmtArg Statements,
1363 SourceLocation RBraceLoc,
1364 bool IsStmtExpr) {
1365 return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1366 IsStmtExpr);
1367 }
1368
1369 /// Build a new case statement.
1370 ///
1371 /// By default, performs semantic analysis to build the new statement.
1372 /// Subclasses may override this routine to provide different behavior.
1374 Expr *LHS,
1375 SourceLocation EllipsisLoc,
1376 Expr *RHS,
1377 SourceLocation ColonLoc) {
1378 return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1379 ColonLoc);
1380 }
1381
1382 /// Attach the body to a new case statement.
1383 ///
1384 /// By default, performs semantic analysis to build the new statement.
1385 /// Subclasses may override this routine to provide different behavior.
1387 getSema().ActOnCaseStmtBody(S, Body);
1388 return S;
1389 }
1390
1391 /// Build a new default statement.
1392 ///
1393 /// By default, performs semantic analysis to build the new statement.
1394 /// Subclasses may override this routine to provide different behavior.
1396 SourceLocation ColonLoc,
1397 Stmt *SubStmt) {
1398 return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1399 /*CurScope=*/nullptr);
1400 }
1401
1402 /// Build a new label statement.
1403 ///
1404 /// By default, performs semantic analysis to build the new statement.
1405 /// Subclasses may override this routine to provide different behavior.
1407 SourceLocation ColonLoc, Stmt *SubStmt) {
1408 return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1409 }
1410
1411 /// Build a new attributed statement.
1412 ///
1413 /// By default, performs semantic analysis to build the new statement.
1414 /// Subclasses may override this routine to provide different behavior.
1417 Stmt *SubStmt) {
1418 if (SemaRef.CheckRebuiltStmtAttributes(Attrs))
1419 return StmtError();
1420 return SemaRef.BuildAttributedStmt(AttrLoc, Attrs, SubStmt);
1421 }
1422
1423 /// Build a new "if" statement.
1424 ///
1425 /// By default, performs semantic analysis to build the new statement.
1426 /// Subclasses may override this routine to provide different behavior.
1429 SourceLocation RParenLoc, Stmt *Init, Stmt *Then,
1430 SourceLocation ElseLoc, Stmt *Else) {
1431 return getSema().ActOnIfStmt(IfLoc, Kind, LParenLoc, Init, Cond, RParenLoc,
1432 Then, ElseLoc, Else);
1433 }
1434
1435 /// Start building a new switch statement.
1436 ///
1437 /// By default, performs semantic analysis to build the new statement.
1438 /// Subclasses may override this routine to provide different behavior.
1440 SourceLocation LParenLoc, Stmt *Init,
1442 SourceLocation RParenLoc) {
1443 return getSema().ActOnStartOfSwitchStmt(SwitchLoc, LParenLoc, Init, Cond,
1444 RParenLoc);
1445 }
1446
1447 /// Attach the body to the switch statement.
1448 ///
1449 /// By default, performs semantic analysis to build the new statement.
1450 /// Subclasses may override this routine to provide different behavior.
1452 Stmt *Switch, Stmt *Body) {
1453 return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1454 }
1455
1456 /// Build a new while statement.
1457 ///
1458 /// By default, performs semantic analysis to build the new statement.
1459 /// Subclasses may override this routine to provide different behavior.
1462 SourceLocation RParenLoc, Stmt *Body) {
1463 return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body);
1464 }
1465
1466 /// Build a new do-while statement.
1467 ///
1468 /// By default, performs semantic analysis to build the new statement.
1469 /// Subclasses may override this routine to provide different behavior.
1471 SourceLocation WhileLoc, SourceLocation LParenLoc,
1472 Expr *Cond, SourceLocation RParenLoc) {
1473 return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1474 Cond, RParenLoc);
1475 }
1476
1477 /// Build a new for statement.
1478 ///
1479 /// By default, performs semantic analysis to build the new statement.
1480 /// Subclasses may override this routine to provide different behavior.
1483 Sema::FullExprArg Inc, SourceLocation RParenLoc,
1484 Stmt *Body) {
1485 return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1486 Inc, RParenLoc, Body);
1487 }
1488
1489 /// Build a new 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 LabelDecl *Label) {
1495 return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1496 }
1497
1498 /// Build a new indirect goto statement.
1499 ///
1500 /// By default, performs semantic analysis to build the new statement.
1501 /// Subclasses may override this routine to provide different behavior.
1503 SourceLocation StarLoc,
1504 Expr *Target) {
1505 return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1506 }
1507
1508 /// Build a new return statement.
1509 ///
1510 /// By default, performs semantic analysis to build the new statement.
1511 /// Subclasses may override this routine to provide different behavior.
1513 return getSema().BuildReturnStmt(ReturnLoc, Result);
1514 }
1515
1516 /// Build a new declaration statement.
1517 ///
1518 /// By default, performs semantic analysis to build the new statement.
1519 /// Subclasses may override this routine to provide different behavior.
1521 SourceLocation StartLoc, SourceLocation EndLoc) {
1523 return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1524 }
1525
1526 /// Build a new inline asm statement.
1527 ///
1528 /// By default, performs semantic analysis to build the new statement.
1529 /// Subclasses may override this routine to provide different behavior.
1531 bool IsVolatile, unsigned NumOutputs,
1532 unsigned NumInputs, IdentifierInfo **Names,
1533 MultiExprArg Constraints, MultiExprArg Exprs,
1534 Expr *AsmString, MultiExprArg Clobbers,
1535 unsigned NumLabels,
1536 SourceLocation RParenLoc) {
1537 return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1538 NumInputs, Names, Constraints, Exprs,
1539 AsmString, Clobbers, NumLabels, RParenLoc);
1540 }
1541
1542 /// Build a new MS style inline asm statement.
1543 ///
1544 /// By default, performs semantic analysis to build the new statement.
1545 /// Subclasses may override this routine to provide different behavior.
1547 ArrayRef<Token> AsmToks,
1548 StringRef AsmString,
1549 unsigned NumOutputs, unsigned NumInputs,
1550 ArrayRef<StringRef> Constraints,
1551 ArrayRef<StringRef> Clobbers,
1552 ArrayRef<Expr*> Exprs,
1553 SourceLocation EndLoc) {
1554 return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1555 NumOutputs, NumInputs,
1556 Constraints, Clobbers, Exprs, EndLoc);
1557 }
1558
1559 /// Build a new co_return statement.
1560 ///
1561 /// By default, performs semantic analysis to build the new statement.
1562 /// Subclasses may override this routine to provide different behavior.
1564 bool IsImplicit) {
1565 return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1566 }
1567
1568 /// Build a new co_await expression.
1569 ///
1570 /// By default, performs semantic analysis to build the new expression.
1571 /// Subclasses may override this routine to provide different behavior.
1573 UnresolvedLookupExpr *OpCoawaitLookup,
1574 bool IsImplicit) {
1575 // This function rebuilds a coawait-expr given its operator.
1576 // For an explicit coawait-expr, the rebuild involves the full set
1577 // of transformations performed by BuildUnresolvedCoawaitExpr(),
1578 // including calling await_transform().
1579 // For an implicit coawait-expr, we need to rebuild the "operator
1580 // coawait" but not await_transform(), so use BuildResolvedCoawaitExpr().
1581 // This mirrors how the implicit CoawaitExpr is originally created
1582 // in Sema::ActOnCoroutineBodyStart().
1583 if (IsImplicit) {
1585 CoawaitLoc, Operand, OpCoawaitLookup);
1586 if (Suspend.isInvalid())
1587 return ExprError();
1588 return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Operand,
1589 Suspend.get(), true);
1590 }
1591
1592 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Operand,
1593 OpCoawaitLookup);
1594 }
1595
1596 /// Build a new co_await expression.
1597 ///
1598 /// By default, performs semantic analysis to build the new expression.
1599 /// Subclasses may override this routine to provide different behavior.
1601 Expr *Result,
1602 UnresolvedLookupExpr *Lookup) {
1603 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1604 }
1605
1606 /// Build a new co_yield expression.
1607 ///
1608 /// By default, performs semantic analysis to build the new expression.
1609 /// Subclasses may override this routine to provide different behavior.
1611 return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1612 }
1613
1617
1618 /// Build a new Objective-C \@try statement.
1619 ///
1620 /// By default, performs semantic analysis to build the new statement.
1621 /// Subclasses may override this routine to provide different behavior.
1623 Stmt *TryBody,
1624 MultiStmtArg CatchStmts,
1625 Stmt *Finally) {
1626 return getSema().ObjC().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1627 Finally);
1628 }
1629
1630 /// Rebuild an Objective-C exception declaration.
1631 ///
1632 /// By default, performs semantic analysis to build the new declaration.
1633 /// Subclasses may override this routine to provide different behavior.
1635 TypeSourceInfo *TInfo, QualType T) {
1637 TInfo, T, ExceptionDecl->getInnerLocStart(),
1638 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
1639 }
1640
1641 /// Build a new Objective-C \@catch statement.
1642 ///
1643 /// By default, performs semantic analysis to build the new statement.
1644 /// Subclasses may override this routine to provide different behavior.
1646 SourceLocation RParenLoc,
1647 VarDecl *Var,
1648 Stmt *Body) {
1649 return getSema().ObjC().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, Var, Body);
1650 }
1651
1652 /// Build a new Objective-C \@finally statement.
1653 ///
1654 /// By default, performs semantic analysis to build the new statement.
1655 /// Subclasses may override this routine to provide different behavior.
1657 Stmt *Body) {
1658 return getSema().ObjC().ActOnObjCAtFinallyStmt(AtLoc, Body);
1659 }
1660
1661 /// Build a new Objective-C \@throw statement.
1662 ///
1663 /// By default, performs semantic analysis to build the new statement.
1664 /// Subclasses may override this routine to provide different behavior.
1666 Expr *Operand) {
1667 return getSema().ObjC().BuildObjCAtThrowStmt(AtLoc, Operand);
1668 }
1669
1670 /// Build a new OpenMP Canonical loop.
1671 ///
1672 /// Ensures that the outermost loop in @p LoopStmt is wrapped by a
1673 /// OMPCanonicalLoop.
1675 return getSema().OpenMP().ActOnOpenMPCanonicalLoop(LoopStmt);
1676 }
1677
1678 /// Build a new OpenMP executable directive.
1679 ///
1680 /// By default, performs semantic analysis to build the new statement.
1681 /// Subclasses may override this routine to provide different behavior.
1683 DeclarationNameInfo DirName,
1684 OpenMPDirectiveKind CancelRegion,
1685 ArrayRef<OMPClause *> Clauses,
1686 Stmt *AStmt, SourceLocation StartLoc,
1687 SourceLocation EndLoc) {
1688
1690 Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1691 }
1692
1693 /// Build a new OpenMP informational directive.
1695 DeclarationNameInfo DirName,
1696 ArrayRef<OMPClause *> Clauses,
1697 Stmt *AStmt,
1698 SourceLocation StartLoc,
1699 SourceLocation EndLoc) {
1700
1702 Kind, DirName, Clauses, AStmt, StartLoc, EndLoc);
1703 }
1704
1705 /// Build a new OpenMP 'if' clause.
1706 ///
1707 /// By default, performs semantic analysis to build the new OpenMP clause.
1708 /// Subclasses may override this routine to provide different behavior.
1710 Expr *Condition, SourceLocation StartLoc,
1711 SourceLocation LParenLoc,
1712 SourceLocation NameModifierLoc,
1713 SourceLocation ColonLoc,
1714 SourceLocation EndLoc) {
1716 NameModifier, Condition, StartLoc, LParenLoc, NameModifierLoc, ColonLoc,
1717 EndLoc);
1718 }
1719
1720 /// Build a new OpenMP 'final' clause.
1721 ///
1722 /// By default, performs semantic analysis to build the new OpenMP clause.
1723 /// Subclasses may override this routine to provide different behavior.
1725 SourceLocation LParenLoc,
1726 SourceLocation EndLoc) {
1727 return getSema().OpenMP().ActOnOpenMPFinalClause(Condition, StartLoc,
1728 LParenLoc, EndLoc);
1729 }
1730
1731 /// Build a new OpenMP 'num_threads' clause.
1732 ///
1733 /// By default, performs semantic analysis to build the new OpenMP clause.
1734 /// Subclasses may override this routine to provide different behavior.
1736 Expr *NumThreads,
1737 SourceLocation StartLoc,
1738 SourceLocation LParenLoc,
1739 SourceLocation ModifierLoc,
1740 SourceLocation EndLoc) {
1742 Modifier, NumThreads, StartLoc, LParenLoc, ModifierLoc, EndLoc);
1743 }
1744
1745 /// Build a new OpenMP 'safelen' 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().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc,
1753 EndLoc);
1754 }
1755
1756 /// Build a new OpenMP 'simdlen' clause.
1757 ///
1758 /// By default, performs semantic analysis to build the new OpenMP clause.
1759 /// Subclasses may override this routine to provide different behavior.
1761 SourceLocation LParenLoc,
1762 SourceLocation EndLoc) {
1763 return getSema().OpenMP().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc,
1764 EndLoc);
1765 }
1766
1768 SourceLocation StartLoc,
1769 SourceLocation LParenLoc,
1770 SourceLocation EndLoc) {
1771 return getSema().OpenMP().ActOnOpenMPSizesClause(Sizes, StartLoc, LParenLoc,
1772 EndLoc);
1773 }
1774
1775 /// Build a new OpenMP 'permutation' clause.
1777 SourceLocation StartLoc,
1778 SourceLocation LParenLoc,
1779 SourceLocation EndLoc) {
1780 return getSema().OpenMP().ActOnOpenMPPermutationClause(PermExprs, StartLoc,
1781 LParenLoc, EndLoc);
1782 }
1783
1784 /// Build a new OpenMP 'full' clause.
1786 SourceLocation EndLoc) {
1787 return getSema().OpenMP().ActOnOpenMPFullClause(StartLoc, EndLoc);
1788 }
1789
1790 /// Build a new OpenMP 'partial' clause.
1792 SourceLocation LParenLoc,
1793 SourceLocation EndLoc) {
1794 return getSema().OpenMP().ActOnOpenMPPartialClause(Factor, StartLoc,
1795 LParenLoc, EndLoc);
1796 }
1797
1798 OMPClause *
1800 SourceLocation LParenLoc, SourceLocation FirstLoc,
1801 SourceLocation CountLoc, SourceLocation EndLoc) {
1803 First, Count, StartLoc, LParenLoc, FirstLoc, CountLoc, EndLoc);
1804 }
1805
1806 /// Build a new OpenMP 'allocator' clause.
1807 ///
1808 /// By default, performs semantic analysis to build the new OpenMP clause.
1809 /// Subclasses may override this routine to provide different behavior.
1811 SourceLocation LParenLoc,
1812 SourceLocation EndLoc) {
1813 return getSema().OpenMP().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc,
1814 EndLoc);
1815 }
1816
1817 /// Build a new OpenMP 'collapse' clause.
1818 ///
1819 /// By default, performs semantic analysis to build the new OpenMP clause.
1820 /// Subclasses may override this routine to provide different behavior.
1822 SourceLocation LParenLoc,
1823 SourceLocation EndLoc) {
1824 return getSema().OpenMP().ActOnOpenMPCollapseClause(Num, StartLoc,
1825 LParenLoc, EndLoc);
1826 }
1827
1828 /// Build a new OpenMP 'default' clause.
1829 ///
1830 /// By default, performs semantic analysis to build the new OpenMP clause.
1831 /// Subclasses may override this routine to provide different behavior.
1834 SourceLocation VCLoc,
1835 SourceLocation StartLoc,
1836 SourceLocation LParenLoc,
1837 SourceLocation EndLoc) {
1839 Kind, KindKwLoc, VCKind, VCLoc, StartLoc, LParenLoc, EndLoc);
1840 }
1841
1842 /// Build a new OpenMP 'proc_bind' clause.
1843 ///
1844 /// By default, performs semantic analysis to build the new OpenMP clause.
1845 /// Subclasses may override this routine to provide different behavior.
1847 SourceLocation KindKwLoc,
1848 SourceLocation StartLoc,
1849 SourceLocation LParenLoc,
1850 SourceLocation EndLoc) {
1852 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1853 }
1854
1855 /// Build a new OpenMP 'schedule' clause.
1856 ///
1857 /// By default, performs semantic analysis to build the new OpenMP clause.
1858 /// Subclasses may override this routine to provide different behavior.
1861 OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1862 SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1863 SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1865 M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1866 CommaLoc, EndLoc);
1867 }
1868
1869 /// Build a new OpenMP 'ordered' clause.
1870 ///
1871 /// By default, performs semantic analysis to build the new OpenMP clause.
1872 /// Subclasses may override this routine to provide different behavior.
1874 SourceLocation EndLoc,
1875 SourceLocation LParenLoc, Expr *Num) {
1876 return getSema().OpenMP().ActOnOpenMPOrderedClause(StartLoc, EndLoc,
1877 LParenLoc, Num);
1878 }
1879
1880 /// Build a new OpenMP 'nowait' clause.
1881 ///
1882 /// By default, performs semantic analysis to build the new OpenMP clause.
1883 /// Subclasses may override this routine to provide different behavior.
1885 SourceLocation LParenLoc,
1886 SourceLocation EndLoc) {
1887 return getSema().OpenMP().ActOnOpenMPNowaitClause(StartLoc, EndLoc,
1888 LParenLoc, Condition);
1889 }
1890
1891 /// Build a new OpenMP 'private' clause.
1892 ///
1893 /// By default, performs semantic analysis to build the new OpenMP clause.
1894 /// Subclasses may override this routine to provide different behavior.
1896 SourceLocation StartLoc,
1897 SourceLocation LParenLoc,
1898 SourceLocation EndLoc) {
1899 return getSema().OpenMP().ActOnOpenMPPrivateClause(VarList, StartLoc,
1900 LParenLoc, EndLoc);
1901 }
1902
1903 /// Build a new OpenMP 'firstprivate' clause.
1904 ///
1905 /// By default, performs semantic analysis to build the new OpenMP clause.
1906 /// Subclasses may override this routine to provide different behavior.
1908 SourceLocation StartLoc,
1909 SourceLocation LParenLoc,
1910 SourceLocation EndLoc) {
1911 return getSema().OpenMP().ActOnOpenMPFirstprivateClause(VarList, StartLoc,
1912 LParenLoc, EndLoc);
1913 }
1914
1915 /// Build a new OpenMP 'lastprivate' clause.
1916 ///
1917 /// By default, performs semantic analysis to build the new OpenMP clause.
1918 /// Subclasses may override this routine to provide different behavior.
1921 SourceLocation LPKindLoc,
1922 SourceLocation ColonLoc,
1923 SourceLocation StartLoc,
1924 SourceLocation LParenLoc,
1925 SourceLocation EndLoc) {
1927 VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1928 }
1929
1930 /// Build a new OpenMP 'shared' clause.
1931 ///
1932 /// By default, performs semantic analysis to build the new OpenMP clause.
1933 /// Subclasses may override this routine to provide different behavior.
1935 SourceLocation StartLoc,
1936 SourceLocation LParenLoc,
1937 SourceLocation EndLoc) {
1938 return getSema().OpenMP().ActOnOpenMPSharedClause(VarList, StartLoc,
1939 LParenLoc, EndLoc);
1940 }
1941
1942 /// Build a new OpenMP 'reduction' clause.
1943 ///
1944 /// By default, performs semantic analysis to build the new statement.
1945 /// Subclasses may override this routine to provide different behavior.
1948 OpenMPOriginalSharingModifier OriginalSharingModifier,
1949 SourceLocation StartLoc, SourceLocation LParenLoc,
1950 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1951 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
1952 const DeclarationNameInfo &ReductionId,
1953 ArrayRef<Expr *> UnresolvedReductions) {
1955 VarList, {Modifier, OriginalSharingModifier}, StartLoc, LParenLoc,
1956 ModifierLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, ReductionId,
1957 UnresolvedReductions);
1958 }
1959
1960 /// Build a new OpenMP 'task_reduction' clause.
1961 ///
1962 /// By default, performs semantic analysis to build the new statement.
1963 /// Subclasses may override this routine to provide different behavior.
1965 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1966 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
1967 CXXScopeSpec &ReductionIdScopeSpec,
1968 const DeclarationNameInfo &ReductionId,
1969 ArrayRef<Expr *> UnresolvedReductions) {
1971 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1972 ReductionId, UnresolvedReductions);
1973 }
1974
1975 /// Build a new OpenMP 'in_reduction' clause.
1976 ///
1977 /// By default, performs semantic analysis to build the new statement.
1978 /// Subclasses may override this routine to provide different behavior.
1979 OMPClause *
1981 SourceLocation LParenLoc, SourceLocation ColonLoc,
1982 SourceLocation EndLoc,
1983 CXXScopeSpec &ReductionIdScopeSpec,
1984 const DeclarationNameInfo &ReductionId,
1985 ArrayRef<Expr *> UnresolvedReductions) {
1987 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1988 ReductionId, UnresolvedReductions);
1989 }
1990
1991 /// Build a new OpenMP 'linear' clause.
1992 ///
1993 /// By default, performs semantic analysis to build the new OpenMP clause.
1994 /// Subclasses may override this routine to provide different behavior.
1996 ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc,
1997 SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier,
1998 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1999 SourceLocation StepModifierLoc, SourceLocation EndLoc) {
2001 VarList, Step, StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc,
2002 StepModifierLoc, EndLoc);
2003 }
2004
2005 /// Build a new OpenMP 'aligned' clause.
2006 ///
2007 /// By default, performs semantic analysis to build the new OpenMP clause.
2008 /// Subclasses may override this routine to provide different behavior.
2010 SourceLocation StartLoc,
2011 SourceLocation LParenLoc,
2012 SourceLocation ColonLoc,
2013 SourceLocation EndLoc) {
2015 VarList, Alignment, StartLoc, LParenLoc, ColonLoc, EndLoc);
2016 }
2017
2018 /// Build a new OpenMP 'copyin' clause.
2019 ///
2020 /// By default, performs semantic analysis to build the new OpenMP clause.
2021 /// Subclasses may override this routine to provide different behavior.
2023 SourceLocation StartLoc,
2024 SourceLocation LParenLoc,
2025 SourceLocation EndLoc) {
2026 return getSema().OpenMP().ActOnOpenMPCopyinClause(VarList, StartLoc,
2027 LParenLoc, EndLoc);
2028 }
2029
2030 /// Build a new OpenMP 'copyprivate' clause.
2031 ///
2032 /// By default, performs semantic analysis to build the new OpenMP clause.
2033 /// Subclasses may override this routine to provide different behavior.
2035 SourceLocation StartLoc,
2036 SourceLocation LParenLoc,
2037 SourceLocation EndLoc) {
2038 return getSema().OpenMP().ActOnOpenMPCopyprivateClause(VarList, StartLoc,
2039 LParenLoc, EndLoc);
2040 }
2041
2042 /// Build a new OpenMP 'flush' pseudo clause.
2043 ///
2044 /// By default, performs semantic analysis to build the new OpenMP clause.
2045 /// Subclasses may override this routine to provide different behavior.
2047 SourceLocation StartLoc,
2048 SourceLocation LParenLoc,
2049 SourceLocation EndLoc) {
2050 return getSema().OpenMP().ActOnOpenMPFlushClause(VarList, StartLoc,
2051 LParenLoc, EndLoc);
2052 }
2053
2054 /// Build a new OpenMP 'depobj' pseudo clause.
2055 ///
2056 /// By default, performs semantic analysis to build the new OpenMP clause.
2057 /// Subclasses may override this routine to provide different behavior.
2059 SourceLocation LParenLoc,
2060 SourceLocation EndLoc) {
2061 return getSema().OpenMP().ActOnOpenMPDepobjClause(Depobj, StartLoc,
2062 LParenLoc, EndLoc);
2063 }
2064
2065 /// Build a new OpenMP 'depend' pseudo clause.
2066 ///
2067 /// By default, performs semantic analysis to build the new OpenMP clause.
2068 /// Subclasses may override this routine to provide different behavior.
2070 Expr *DepModifier, ArrayRef<Expr *> VarList,
2071 SourceLocation StartLoc,
2072 SourceLocation LParenLoc,
2073 SourceLocation EndLoc) {
2075 Data, DepModifier, VarList, StartLoc, LParenLoc, EndLoc);
2076 }
2077
2078 /// Build a new OpenMP 'device' clause.
2079 ///
2080 /// By default, performs semantic analysis to build the new statement.
2081 /// Subclasses may override this routine to provide different behavior.
2083 Expr *Device, SourceLocation StartLoc,
2084 SourceLocation LParenLoc,
2085 SourceLocation ModifierLoc,
2086 SourceLocation EndLoc) {
2088 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2089 }
2090
2091 /// Build a new OpenMP 'map' clause.
2092 ///
2093 /// By default, performs semantic analysis to build the new OpenMP clause.
2094 /// Subclasses may override this routine to provide different behavior.
2096 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
2097 ArrayRef<SourceLocation> MapTypeModifiersLoc,
2098 CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId,
2099 OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
2100 SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
2101 const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) {
2103 IteratorModifier, MapTypeModifiers, MapTypeModifiersLoc,
2104 MapperIdScopeSpec, MapperId, MapType, IsMapTypeImplicit, MapLoc,
2105 ColonLoc, VarList, Locs,
2106 /*NoDiagnose=*/false, UnresolvedMappers);
2107 }
2108
2109 /// Build a new OpenMP 'allocate' clause.
2110 ///
2111 /// By default, performs semantic analysis to build the new OpenMP clause.
2112 /// Subclasses may override this routine to provide different behavior.
2113 OMPClause *
2114 RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment,
2115 OpenMPAllocateClauseModifier FirstModifier,
2116 SourceLocation FirstModifierLoc,
2117 OpenMPAllocateClauseModifier SecondModifier,
2118 SourceLocation SecondModifierLoc,
2119 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2120 SourceLocation LParenLoc, SourceLocation ColonLoc,
2121 SourceLocation EndLoc) {
2123 Allocate, Alignment, FirstModifier, FirstModifierLoc, SecondModifier,
2124 SecondModifierLoc, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc);
2125 }
2126
2127 /// Build a new OpenMP 'num_teams' clause.
2128 ///
2129 /// By default, performs semantic analysis to build the new statement.
2130 /// Subclasses may override this routine to provide different behavior.
2132 SourceLocation StartLoc,
2133 SourceLocation LParenLoc,
2134 SourceLocation EndLoc) {
2135 return getSema().OpenMP().ActOnOpenMPNumTeamsClause(VarList, StartLoc,
2136 LParenLoc, EndLoc);
2137 }
2138
2139 /// Build a new OpenMP 'thread_limit' clause.
2140 ///
2141 /// By default, performs semantic analysis to build the new statement.
2142 /// Subclasses may override this routine to provide different behavior.
2144 SourceLocation StartLoc,
2145 SourceLocation LParenLoc,
2146 SourceLocation EndLoc) {
2147 return getSema().OpenMP().ActOnOpenMPThreadLimitClause(VarList, StartLoc,
2148 LParenLoc, EndLoc);
2149 }
2150
2151 /// Build a new OpenMP 'priority' clause.
2152 ///
2153 /// By default, performs semantic analysis to build the new statement.
2154 /// Subclasses may override this routine to provide different behavior.
2156 SourceLocation LParenLoc,
2157 SourceLocation EndLoc) {
2158 return getSema().OpenMP().ActOnOpenMPPriorityClause(Priority, StartLoc,
2159 LParenLoc, EndLoc);
2160 }
2161
2162 /// Build a new OpenMP 'grainsize' clause.
2163 ///
2164 /// By default, performs semantic analysis to build the new statement.
2165 /// Subclasses may override this routine to provide different behavior.
2167 Expr *Device, SourceLocation StartLoc,
2168 SourceLocation LParenLoc,
2169 SourceLocation ModifierLoc,
2170 SourceLocation EndLoc) {
2172 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2173 }
2174
2175 /// Build a new OpenMP 'num_tasks' clause.
2176 ///
2177 /// By default, performs semantic analysis to build the new statement.
2178 /// Subclasses may override this routine to provide different behavior.
2180 Expr *NumTasks, SourceLocation StartLoc,
2181 SourceLocation LParenLoc,
2182 SourceLocation ModifierLoc,
2183 SourceLocation EndLoc) {
2185 Modifier, NumTasks, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2186 }
2187
2188 /// Build a new OpenMP 'hint' clause.
2189 ///
2190 /// By default, performs semantic analysis to build the new statement.
2191 /// Subclasses may override this routine to provide different behavior.
2193 SourceLocation LParenLoc,
2194 SourceLocation EndLoc) {
2195 return getSema().OpenMP().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc,
2196 EndLoc);
2197 }
2198
2199 /// Build a new OpenMP 'detach' clause.
2200 ///
2201 /// By default, performs semantic analysis to build the new statement.
2202 /// Subclasses may override this routine to provide different behavior.
2204 SourceLocation LParenLoc,
2205 SourceLocation EndLoc) {
2206 return getSema().OpenMP().ActOnOpenMPDetachClause(Evt, StartLoc, LParenLoc,
2207 EndLoc);
2208 }
2209
2210 /// Build a new OpenMP 'dist_schedule' clause.
2211 ///
2212 /// By default, performs semantic analysis to build the new OpenMP clause.
2213 /// Subclasses may override this routine to provide different behavior.
2214 OMPClause *
2216 Expr *ChunkSize, SourceLocation StartLoc,
2217 SourceLocation LParenLoc, SourceLocation KindLoc,
2218 SourceLocation CommaLoc, SourceLocation EndLoc) {
2220 Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
2221 }
2222
2223 /// Build a new OpenMP 'to' clause.
2224 ///
2225 /// By default, performs semantic analysis to build the new statement.
2226 /// Subclasses may override this routine to provide different behavior.
2227 OMPClause *
2229 ArrayRef<SourceLocation> MotionModifiersLoc,
2230 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2231 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2232 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2233 ArrayRef<Expr *> UnresolvedMappers) {
2235 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2236 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2237 UnresolvedMappers);
2238 }
2239
2240 /// Build a new OpenMP 'from' clause.
2241 ///
2242 /// By default, performs semantic analysis to build the new statement.
2243 /// Subclasses may override this routine to provide different behavior.
2244 OMPClause *
2246 ArrayRef<SourceLocation> MotionModifiersLoc,
2247 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2248 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2249 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2250 ArrayRef<Expr *> UnresolvedMappers) {
2252 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2253 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2254 UnresolvedMappers);
2255 }
2256
2257 /// Build a new OpenMP 'use_device_ptr' clause.
2258 ///
2259 /// By default, performs semantic analysis to build the new OpenMP clause.
2260 /// Subclasses may override this routine to provide different behavior.
2262 const OMPVarListLocTy &Locs) {
2263 return getSema().OpenMP().ActOnOpenMPUseDevicePtrClause(VarList, Locs);
2264 }
2265
2266 /// Build a new OpenMP 'use_device_addr' clause.
2267 ///
2268 /// By default, performs semantic analysis to build the new OpenMP clause.
2269 /// Subclasses may override this routine to provide different behavior.
2274
2275 /// Build a new OpenMP 'is_device_ptr' clause.
2276 ///
2277 /// By default, performs semantic analysis to build the new OpenMP clause.
2278 /// Subclasses may override this routine to provide different behavior.
2280 const OMPVarListLocTy &Locs) {
2281 return getSema().OpenMP().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
2282 }
2283
2284 /// Build a new OpenMP 'has_device_addr' clause.
2285 ///
2286 /// By default, performs semantic analysis to build the new OpenMP clause.
2287 /// Subclasses may override this routine to provide different behavior.
2292
2293 /// Build a new OpenMP 'defaultmap' clause.
2294 ///
2295 /// By default, performs semantic analysis to build the new OpenMP clause.
2296 /// Subclasses may override this routine to provide different behavior.
2299 SourceLocation StartLoc,
2300 SourceLocation LParenLoc,
2301 SourceLocation MLoc,
2302 SourceLocation KindLoc,
2303 SourceLocation EndLoc) {
2305 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2306 }
2307
2308 /// Build a new OpenMP 'nontemporal' clause.
2309 ///
2310 /// By default, performs semantic analysis to build the new OpenMP clause.
2311 /// Subclasses may override this routine to provide different behavior.
2313 SourceLocation StartLoc,
2314 SourceLocation LParenLoc,
2315 SourceLocation EndLoc) {
2316 return getSema().OpenMP().ActOnOpenMPNontemporalClause(VarList, StartLoc,
2317 LParenLoc, EndLoc);
2318 }
2319
2320 /// Build a new OpenMP 'inclusive' clause.
2321 ///
2322 /// By default, performs semantic analysis to build the new OpenMP clause.
2323 /// Subclasses may override this routine to provide different behavior.
2325 SourceLocation StartLoc,
2326 SourceLocation LParenLoc,
2327 SourceLocation EndLoc) {
2328 return getSema().OpenMP().ActOnOpenMPInclusiveClause(VarList, StartLoc,
2329 LParenLoc, EndLoc);
2330 }
2331
2332 /// Build a new OpenMP 'exclusive' 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 SourceLocation StartLoc,
2338 SourceLocation LParenLoc,
2339 SourceLocation EndLoc) {
2340 return getSema().OpenMP().ActOnOpenMPExclusiveClause(VarList, StartLoc,
2341 LParenLoc, EndLoc);
2342 }
2343
2344 /// Build a new OpenMP 'uses_allocators' clause.
2345 ///
2346 /// By default, performs semantic analysis to build the new OpenMP clause.
2347 /// Subclasses may override this routine to provide different behavior.
2354
2355 /// Build a new OpenMP 'affinity' clause.
2356 ///
2357 /// By default, performs semantic analysis to build the new OpenMP clause.
2358 /// Subclasses may override this routine to provide different behavior.
2360 SourceLocation LParenLoc,
2361 SourceLocation ColonLoc,
2362 SourceLocation EndLoc, Expr *Modifier,
2363 ArrayRef<Expr *> Locators) {
2365 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2366 }
2367
2368 /// Build a new OpenMP 'order' 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 OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc,
2374 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
2375 OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc) {
2377 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2378 }
2379
2380 /// Build a new OpenMP 'init' 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 VarLoc,
2388 SourceLocation EndLoc) {
2390 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2391 }
2392
2393 /// Build a new OpenMP 'use' clause.
2394 ///
2395 /// By default, performs semantic analysis to build the new OpenMP clause.
2396 /// Subclasses may override this routine to provide different behavior.
2398 SourceLocation LParenLoc,
2399 SourceLocation VarLoc, SourceLocation EndLoc) {
2400 return getSema().OpenMP().ActOnOpenMPUseClause(InteropVar, StartLoc,
2401 LParenLoc, VarLoc, EndLoc);
2402 }
2403
2404 /// Build a new OpenMP 'destroy' clause.
2405 ///
2406 /// By default, performs semantic analysis to build the new OpenMP clause.
2407 /// Subclasses may override this routine to provide different behavior.
2409 SourceLocation LParenLoc,
2410 SourceLocation VarLoc,
2411 SourceLocation EndLoc) {
2413 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2414 }
2415
2416 /// Build a new OpenMP 'novariants' clause.
2417 ///
2418 /// By default, performs semantic analysis to build the new OpenMP clause.
2419 /// Subclasses may override this routine to provide different behavior.
2421 SourceLocation StartLoc,
2422 SourceLocation LParenLoc,
2423 SourceLocation EndLoc) {
2425 LParenLoc, EndLoc);
2426 }
2427
2428 /// Build a new OpenMP 'nocontext' clause.
2429 ///
2430 /// By default, performs semantic analysis to build the new OpenMP clause.
2431 /// Subclasses may override this routine to provide different behavior.
2433 SourceLocation LParenLoc,
2434 SourceLocation EndLoc) {
2436 LParenLoc, EndLoc);
2437 }
2438
2439 /// Build a new OpenMP 'filter' clause.
2440 ///
2441 /// By default, performs semantic analysis to build the new OpenMP clause.
2442 /// Subclasses may override this routine to provide different behavior.
2444 SourceLocation LParenLoc,
2445 SourceLocation EndLoc) {
2446 return getSema().OpenMP().ActOnOpenMPFilterClause(ThreadID, StartLoc,
2447 LParenLoc, EndLoc);
2448 }
2449
2450 /// Build a new OpenMP 'bind' 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 KindLoc,
2456 SourceLocation StartLoc,
2457 SourceLocation LParenLoc,
2458 SourceLocation EndLoc) {
2459 return getSema().OpenMP().ActOnOpenMPBindClause(Kind, KindLoc, StartLoc,
2460 LParenLoc, EndLoc);
2461 }
2462
2463 /// Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
2464 ///
2465 /// By default, performs semantic analysis to build the new OpenMP clause.
2466 /// Subclasses may override this routine to provide different behavior.
2468 SourceLocation LParenLoc,
2469 SourceLocation EndLoc) {
2470 return getSema().OpenMP().ActOnOpenMPXDynCGroupMemClause(Size, StartLoc,
2471 LParenLoc, EndLoc);
2472 }
2473
2474 /// Build a new OpenMP 'dyn_groupprivate' clause.
2475 ///
2476 /// By default, performs semantic analysis to build the new OpenMP clause.
2477 /// Subclasses may override this routine to provide different behavior.
2481 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc,
2482 SourceLocation M2Loc, SourceLocation EndLoc) {
2484 M1, M2, Size, StartLoc, LParenLoc, M1Loc, M2Loc, EndLoc);
2485 }
2486
2487 /// Build a new OpenMP 'ompx_attribute' clause.
2488 ///
2489 /// By default, performs semantic analysis to build the new OpenMP clause.
2490 /// Subclasses may override this routine to provide different behavior.
2492 SourceLocation StartLoc,
2493 SourceLocation LParenLoc,
2494 SourceLocation EndLoc) {
2495 return getSema().OpenMP().ActOnOpenMPXAttributeClause(Attrs, StartLoc,
2496 LParenLoc, EndLoc);
2497 }
2498
2499 /// Build a new OpenMP 'ompx_bare' clause.
2500 ///
2501 /// By default, performs semantic analysis to build the new OpenMP clause.
2502 /// Subclasses may override this routine to provide different behavior.
2504 SourceLocation EndLoc) {
2505 return getSema().OpenMP().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2506 }
2507
2508 /// Build a new OpenMP 'align' clause.
2509 ///
2510 /// By default, performs semantic analysis to build the new OpenMP clause.
2511 /// Subclasses may override this routine to provide different behavior.
2513 SourceLocation LParenLoc,
2514 SourceLocation EndLoc) {
2515 return getSema().OpenMP().ActOnOpenMPAlignClause(A, StartLoc, LParenLoc,
2516 EndLoc);
2517 }
2518
2519 /// Build a new OpenMP 'at' clause.
2520 ///
2521 /// By default, performs semantic analysis to build the new OpenMP clause.
2522 /// Subclasses may override this routine to provide different behavior.
2524 SourceLocation StartLoc,
2525 SourceLocation LParenLoc,
2526 SourceLocation EndLoc) {
2527 return getSema().OpenMP().ActOnOpenMPAtClause(Kind, KwLoc, StartLoc,
2528 LParenLoc, EndLoc);
2529 }
2530
2531 /// Build a new OpenMP 'severity' clause.
2532 ///
2533 /// By default, performs semantic analysis to build the new OpenMP clause.
2534 /// Subclasses may override this routine to provide different behavior.
2536 SourceLocation KwLoc,
2537 SourceLocation StartLoc,
2538 SourceLocation LParenLoc,
2539 SourceLocation EndLoc) {
2540 return getSema().OpenMP().ActOnOpenMPSeverityClause(Kind, KwLoc, StartLoc,
2541 LParenLoc, EndLoc);
2542 }
2543
2544 /// Build a new OpenMP 'message' clause.
2545 ///
2546 /// By default, performs semantic analysis to build the new OpenMP clause.
2547 /// Subclasses may override this routine to provide different behavior.
2549 SourceLocation LParenLoc,
2550 SourceLocation EndLoc) {
2551 return getSema().OpenMP().ActOnOpenMPMessageClause(MS, StartLoc, LParenLoc,
2552 EndLoc);
2553 }
2554
2555 /// Build a new OpenMP 'doacross' clause.
2556 ///
2557 /// By default, performs semantic analysis to build the new OpenMP clause.
2558 /// Subclasses may override this routine to provide different behavior.
2559 OMPClause *
2561 SourceLocation DepLoc, SourceLocation ColonLoc,
2562 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2563 SourceLocation LParenLoc, SourceLocation EndLoc) {
2565 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2566 }
2567
2568 /// Build a new OpenMP 'holds' clause.
2570 SourceLocation LParenLoc,
2571 SourceLocation EndLoc) {
2572 return getSema().OpenMP().ActOnOpenMPHoldsClause(A, StartLoc, LParenLoc,
2573 EndLoc);
2574 }
2575
2576 /// Rebuild the operand to an Objective-C \@synchronized statement.
2577 ///
2578 /// By default, performs semantic analysis to build the new statement.
2579 /// Subclasses may override this routine to provide different behavior.
2584
2585 /// Build a new Objective-C \@synchronized statement.
2586 ///
2587 /// By default, performs semantic analysis to build the new statement.
2588 /// Subclasses may override this routine to provide different behavior.
2590 Expr *Object, Stmt *Body) {
2591 return getSema().ObjC().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
2592 }
2593
2594 /// Build a new Objective-C \@autoreleasepool statement.
2595 ///
2596 /// By default, performs semantic analysis to build the new statement.
2597 /// Subclasses may override this routine to provide different behavior.
2602
2603 /// Build a new Objective-C fast enumeration statement.
2604 ///
2605 /// By default, performs semantic analysis to build the new statement.
2606 /// Subclasses may override this routine to provide different behavior.
2608 Stmt *Element,
2609 Expr *Collection,
2610 SourceLocation RParenLoc,
2611 Stmt *Body) {
2613 ForLoc, Element, Collection, RParenLoc);
2614 if (ForEachStmt.isInvalid())
2615 return StmtError();
2616
2617 return getSema().ObjC().FinishObjCForCollectionStmt(ForEachStmt.get(),
2618 Body);
2619 }
2620
2621 /// Build a new C++ exception declaration.
2622 ///
2623 /// By default, performs semantic analysis to build the new decaration.
2624 /// Subclasses may override this routine to provide different behavior.
2627 SourceLocation StartLoc,
2628 SourceLocation IdLoc,
2629 IdentifierInfo *Id) {
2631 StartLoc, IdLoc, Id);
2632 if (Var)
2633 getSema().CurContext->addDecl(Var);
2634 return Var;
2635 }
2636
2637 /// Build a new C++ catch statement.
2638 ///
2639 /// By default, performs semantic analysis to build the new statement.
2640 /// Subclasses may override this routine to provide different behavior.
2642 VarDecl *ExceptionDecl,
2643 Stmt *Handler) {
2644 return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2645 Handler));
2646 }
2647
2648 /// Build a new C++ try statement.
2649 ///
2650 /// By default, performs semantic analysis to build the new statement.
2651 /// Subclasses may override this routine to provide different behavior.
2653 ArrayRef<Stmt *> Handlers) {
2654 return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2655 }
2656
2657 /// Build a new C++0x range-based for statement.
2658 ///
2659 /// By default, performs semantic analysis to build the new statement.
2660 /// Subclasses may override this routine to provide different behavior.
2662 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init,
2663 SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond,
2664 Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc,
2665 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
2666 // If we've just learned that the range is actually an Objective-C
2667 // collection, treat this as an Objective-C fast enumeration loop.
2668 if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2669 if (RangeStmt->isSingleDecl()) {
2670 if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2671 if (RangeVar->isInvalidDecl())
2672 return StmtError();
2673
2674 Expr *RangeExpr = RangeVar->getInit();
2675 if (!RangeExpr->isTypeDependent() &&
2676 RangeExpr->getType()->isObjCObjectPointerType()) {
2677 // FIXME: Support init-statements in Objective-C++20 ranged for
2678 // statement.
2679 if (Init) {
2680 return SemaRef.Diag(Init->getBeginLoc(),
2681 diag::err_objc_for_range_init_stmt)
2682 << Init->getSourceRange();
2683 }
2685 ForLoc, LoopVar, RangeExpr, RParenLoc);
2686 }
2687 }
2688 }
2689 }
2690
2692 ForLoc, CoawaitLoc, Init, ColonLoc, Range, Begin, End, Cond, Inc,
2693 LoopVar, RParenLoc, Sema::BFRK_Rebuild, LifetimeExtendTemps);
2694 }
2695
2696 /// Build a new C++0x range-based for statement.
2697 ///
2698 /// By default, performs semantic analysis to build the new statement.
2699 /// Subclasses may override this routine to provide different behavior.
2701 bool IsIfExists,
2702 NestedNameSpecifierLoc QualifierLoc,
2703 DeclarationNameInfo NameInfo,
2704 Stmt *Nested) {
2705 return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2706 QualifierLoc, NameInfo, Nested);
2707 }
2708
2709 /// Attach body to a C++0x range-based for statement.
2710 ///
2711 /// By default, performs semantic analysis to finish the new statement.
2712 /// Subclasses may override this routine to provide different behavior.
2714 return getSema().FinishCXXForRangeStmt(ForRange, Body);
2715 }
2716
2718 Stmt *TryBlock, Stmt *Handler) {
2719 return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2720 }
2721
2723 Stmt *Block) {
2724 return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2725 }
2726
2728 return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2729 }
2730
2732 SourceLocation LParen,
2733 SourceLocation RParen,
2734 TypeSourceInfo *TSI) {
2735 return getSema().SYCL().BuildUniqueStableNameExpr(OpLoc, LParen, RParen,
2736 TSI);
2737 }
2738
2739 /// Build a new predefined expression.
2740 ///
2741 /// By default, performs semantic analysis to build the new expression.
2742 /// Subclasses may override this routine to provide different behavior.
2746
2747 /// Build a new expression that references a declaration.
2748 ///
2749 /// By default, performs semantic analysis to build the new expression.
2750 /// Subclasses may override this routine to provide different behavior.
2752 LookupResult &R,
2753 bool RequiresADL) {
2754 return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2755 }
2756
2757
2758 /// Build a new expression that references a declaration.
2759 ///
2760 /// By default, performs semantic analysis to build the new expression.
2761 /// Subclasses may override this routine to provide different behavior.
2763 ValueDecl *VD,
2764 const DeclarationNameInfo &NameInfo,
2766 TemplateArgumentListInfo *TemplateArgs) {
2767 CXXScopeSpec SS;
2768 SS.Adopt(QualifierLoc);
2769 return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2770 TemplateArgs);
2771 }
2772
2773 /// Build a new expression in parentheses.
2774 ///
2775 /// By default, performs semantic analysis to build the new expression.
2776 /// Subclasses may override this routine to provide different behavior.
2778 SourceLocation RParen) {
2779 return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2780 }
2781
2782 /// Build a new pseudo-destructor expression.
2783 ///
2784 /// By default, performs semantic analysis to build the new expression.
2785 /// Subclasses may override this routine to provide different behavior.
2787 SourceLocation OperatorLoc,
2788 bool isArrow,
2789 CXXScopeSpec &SS,
2790 TypeSourceInfo *ScopeType,
2791 SourceLocation CCLoc,
2792 SourceLocation TildeLoc,
2793 PseudoDestructorTypeStorage Destroyed);
2794
2795 /// Build a new unary operator expression.
2796 ///
2797 /// By default, performs semantic analysis to build the new expression.
2798 /// Subclasses may override this routine to provide different behavior.
2801 Expr *SubExpr) {
2802 return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2803 }
2804
2805 /// Build a new builtin offsetof expression.
2806 ///
2807 /// By default, performs semantic analysis to build the new expression.
2808 /// Subclasses may override this routine to provide different behavior.
2812 SourceLocation RParenLoc) {
2813 return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2814 RParenLoc);
2815 }
2816
2817 /// Build a new sizeof, alignof or vec_step expression with a
2818 /// type argument.
2819 ///
2820 /// By default, performs semantic analysis to build the new expression.
2821 /// Subclasses may override this routine to provide different behavior.
2823 SourceLocation OpLoc,
2824 UnaryExprOrTypeTrait ExprKind,
2825 SourceRange R) {
2826 return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2827 }
2828
2829 /// Build a new sizeof, alignof or vec step expression with an
2830 /// expression argument.
2831 ///
2832 /// By default, performs semantic analysis to build the new expression.
2833 /// Subclasses may override this routine to provide different behavior.
2835 UnaryExprOrTypeTrait ExprKind,
2836 SourceRange R) {
2838 = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2839 if (Result.isInvalid())
2840 return ExprError();
2841
2842 return Result;
2843 }
2844
2845 /// Build a new array subscript expression.
2846 ///
2847 /// By default, performs semantic analysis to build the new expression.
2848 /// Subclasses may override this routine to provide different behavior.
2850 SourceLocation LBracketLoc,
2851 Expr *RHS,
2852 SourceLocation RBracketLoc) {
2853 return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2854 LBracketLoc, RHS,
2855 RBracketLoc);
2856 }
2857
2858 /// Build a new matrix single subscript expression.
2859 ///
2860 /// By default, performs semantic analysis to build the new expression.
2861 /// Subclasses may override this routine to provide different behavior.
2863 SourceLocation RBracketLoc) {
2865 RBracketLoc);
2866 }
2867
2868 /// Build a new matrix subscript expression.
2869 ///
2870 /// By default, performs semantic analysis to build the new expression.
2871 /// Subclasses may override this routine to provide different behavior.
2873 Expr *ColumnIdx,
2874 SourceLocation RBracketLoc) {
2875 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2876 RBracketLoc);
2877 }
2878
2879 /// Build a new array section expression.
2880 ///
2881 /// By default, performs semantic analysis to build the new expression.
2882 /// Subclasses may override this routine to provide different behavior.
2884 SourceLocation LBracketLoc,
2885 Expr *LowerBound,
2886 SourceLocation ColonLocFirst,
2887 SourceLocation ColonLocSecond,
2888 Expr *Length, Expr *Stride,
2889 SourceLocation RBracketLoc) {
2890 if (IsOMPArraySection)
2892 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2893 Stride, RBracketLoc);
2894
2895 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2896 "Stride/second colon not allowed for OpenACC");
2897
2899 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2900 }
2901
2902 /// Build a new array shaping expression.
2903 ///
2904 /// By default, performs semantic analysis to build the new expression.
2905 /// Subclasses may override this routine to provide different behavior.
2907 SourceLocation RParenLoc,
2908 ArrayRef<Expr *> Dims,
2909 ArrayRef<SourceRange> BracketsRanges) {
2911 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2912 }
2913
2914 /// Build a new iterator expression.
2915 ///
2916 /// By default, performs semantic analysis to build the new expression.
2917 /// Subclasses may override this routine to provide different behavior.
2920 SourceLocation RLoc,
2923 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2924 }
2925
2926 /// Build a new call expression.
2927 ///
2928 /// By default, performs semantic analysis to build the new expression.
2929 /// Subclasses may override this routine to provide different behavior.
2931 MultiExprArg Args,
2932 SourceLocation RParenLoc,
2933 Expr *ExecConfig = nullptr) {
2934 return getSema().ActOnCallExpr(
2935 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2936 }
2937
2939 MultiExprArg Args,
2940 SourceLocation RParenLoc) {
2942 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2943 }
2944
2945 /// Build a new member access expression.
2946 ///
2947 /// By default, performs semantic analysis to build the new expression.
2948 /// Subclasses may override this routine to provide different behavior.
2950 bool isArrow,
2951 NestedNameSpecifierLoc QualifierLoc,
2952 SourceLocation TemplateKWLoc,
2953 const DeclarationNameInfo &MemberNameInfo,
2955 NamedDecl *FoundDecl,
2956 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2957 NamedDecl *FirstQualifierInScope) {
2959 isArrow);
2960 if (!Member->getDeclName()) {
2961 // We have a reference to an unnamed field. This is always the
2962 // base of an anonymous struct/union member access, i.e. the
2963 // field is always of record type.
2964 assert(Member->getType()->isRecordType() &&
2965 "unnamed member not of record type?");
2966
2967 BaseResult =
2969 QualifierLoc.getNestedNameSpecifier(),
2970 FoundDecl, Member);
2971 if (BaseResult.isInvalid())
2972 return ExprError();
2973 Base = BaseResult.get();
2974
2975 // `TranformMaterializeTemporaryExpr()` removes materialized temporaries
2976 // from the AST, so we need to re-insert them if needed (since
2977 // `BuildFieldRefereneExpr()` doesn't do this).
2978 if (!isArrow && Base->isPRValue()) {
2980 if (BaseResult.isInvalid())
2981 return ExprError();
2982 Base = BaseResult.get();
2983 }
2984
2985 CXXScopeSpec EmptySS;
2987 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
2988 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
2989 MemberNameInfo);
2990 }
2991
2992 CXXScopeSpec SS;
2993 SS.Adopt(QualifierLoc);
2994
2995 Base = BaseResult.get();
2996 if (Base->containsErrors())
2997 return ExprError();
2998
2999 QualType BaseType = Base->getType();
3000
3001 if (isArrow && !BaseType->isPointerType())
3002 return ExprError();
3003
3004 // FIXME: this involves duplicating earlier analysis in a lot of
3005 // cases; we should avoid this when possible.
3006 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
3007 R.addDecl(FoundDecl);
3008 R.resolveKind();
3009
3010 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
3012 if (auto *ThisClass = cast<CXXThisExpr>(Base)
3013 ->getType()
3014 ->getPointeeType()
3015 ->getAsCXXRecordDecl()) {
3016 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
3017 // In unevaluated contexts, an expression supposed to be a member access
3018 // might reference a member in an unrelated class.
3019 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
3020 return getSema().BuildDeclRefExpr(Member, Member->getType(),
3021 VK_LValue, Member->getLocation());
3022 }
3023 }
3024
3025 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
3026 SS, TemplateKWLoc,
3027 FirstQualifierInScope,
3028 R, ExplicitTemplateArgs,
3029 /*S*/nullptr);
3030 }
3031
3032 /// Build a new binary operator expression.
3033 ///
3034 /// By default, performs semantic analysis to build the new expression.
3035 /// Subclasses may override this routine to provide different behavior.
3037 Expr *LHS, Expr *RHS,
3038 bool ForFoldExpression = false) {
3039 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS,
3040 ForFoldExpression);
3041 }
3042
3043 /// Build a new rewritten operator expression.
3044 ///
3045 /// By default, performs semantic analysis to build the new expression.
3046 /// Subclasses may override this routine to provide different behavior.
3048 SourceLocation OpLoc, BinaryOperatorKind Opcode,
3049 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
3050 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
3051 RHS, /*RequiresADL*/false);
3052 }
3053
3054 /// Build a new conditional operator expression.
3055 ///
3056 /// By default, performs semantic analysis to build the new expression.
3057 /// Subclasses may override this routine to provide different behavior.
3059 SourceLocation QuestionLoc,
3060 Expr *LHS,
3061 SourceLocation ColonLoc,
3062 Expr *RHS) {
3063 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
3064 LHS, RHS);
3065 }
3066
3067 /// Build a new C-style cast expression.
3068 ///
3069 /// By default, performs semantic analysis to build the new expression.
3070 /// Subclasses may override this routine to provide different behavior.
3072 TypeSourceInfo *TInfo,
3073 SourceLocation RParenLoc,
3074 Expr *SubExpr) {
3075 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
3076 SubExpr);
3077 }
3078
3079 /// Build a new compound literal expression.
3080 ///
3081 /// By default, performs semantic analysis to build the new expression.
3082 /// Subclasses may override this routine to provide different behavior.
3084 TypeSourceInfo *TInfo,
3085 SourceLocation RParenLoc,
3086 Expr *Init) {
3087 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
3088 Init);
3089 }
3090
3091 /// Build a new extended vector element access expression.
3092 ///
3093 /// By default, performs semantic analysis to build the new expression.
3094 /// Subclasses may override this routine to provide different behavior.
3096 bool IsArrow,
3097 SourceLocation AccessorLoc,
3098 IdentifierInfo &Accessor) {
3099
3100 CXXScopeSpec SS;
3101 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3103 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3104 /*FirstQualifierInScope*/ nullptr, NameInfo,
3105 /* TemplateArgs */ nullptr,
3106 /*S*/ nullptr);
3107 }
3108
3109 /// Build a new initializer list expression.
3110 ///
3111 /// By default, performs semantic analysis to build the new expression.
3112 /// Subclasses may override this routine to provide different behavior.
3114 MultiExprArg Inits,
3115 SourceLocation RBraceLoc) {
3116 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
3117 }
3118
3119 /// Build a new designated initializer expression.
3120 ///
3121 /// By default, performs semantic analysis to build the new expression.
3122 /// Subclasses may override this routine to provide different behavior.
3124 MultiExprArg ArrayExprs,
3125 SourceLocation EqualOrColonLoc,
3126 bool GNUSyntax,
3127 Expr *Init) {
3129 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3130 Init);
3131 if (Result.isInvalid())
3132 return ExprError();
3133
3134 return Result;
3135 }
3136
3137 /// Build a new value-initialized expression.
3138 ///
3139 /// By default, builds the implicit value initialization without performing
3140 /// any semantic analysis. Subclasses may override this routine to provide
3141 /// different behavior.
3145
3146 /// Build a new \c va_arg expression.
3147 ///
3148 /// By default, performs semantic analysis to build the new expression.
3149 /// Subclasses may override this routine to provide different behavior.
3151 Expr *SubExpr, TypeSourceInfo *TInfo,
3152 SourceLocation RParenLoc) {
3153 return getSema().BuildVAArgExpr(BuiltinLoc,
3154 SubExpr, TInfo,
3155 RParenLoc);
3156 }
3157
3158 /// Build a new expression list in parentheses.
3159 ///
3160 /// By default, performs semantic analysis to build the new expression.
3161 /// Subclasses may override this routine to provide different behavior.
3163 MultiExprArg SubExprs,
3164 SourceLocation RParenLoc) {
3165 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3166 }
3167
3169 unsigned NumUserSpecifiedExprs,
3170 SourceLocation InitLoc,
3171 SourceLocation LParenLoc,
3172 SourceLocation RParenLoc) {
3173 return getSema().ActOnCXXParenListInitExpr(Args, T, NumUserSpecifiedExprs,
3174 InitLoc, LParenLoc, RParenLoc);
3175 }
3176
3177 /// Build a new address-of-label expression.
3178 ///
3179 /// By default, performs semantic analysis, using the name of the label
3180 /// rather than attempting to map the label statement itself.
3181 /// Subclasses may override this routine to provide different behavior.
3183 SourceLocation LabelLoc, LabelDecl *Label) {
3184 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3185 }
3186
3187 /// Build a new GNU statement expression.
3188 ///
3189 /// By default, performs semantic analysis to build the new expression.
3190 /// Subclasses may override this routine to provide different behavior.
3192 SourceLocation RParenLoc, unsigned TemplateDepth) {
3193 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3194 TemplateDepth);
3195 }
3196
3197 /// Build a new __builtin_choose_expr expression.
3198 ///
3199 /// By default, performs semantic analysis to build the new expression.
3200 /// Subclasses may override this routine to provide different behavior.
3202 Expr *Cond, Expr *LHS, Expr *RHS,
3203 SourceLocation RParenLoc) {
3204 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3205 Cond, LHS, RHS,
3206 RParenLoc);
3207 }
3208
3209 /// Build a new generic selection expression with an expression predicate.
3210 ///
3211 /// By default, performs semantic analysis to build the new expression.
3212 /// Subclasses may override this routine to provide different behavior.
3214 SourceLocation DefaultLoc,
3215 SourceLocation RParenLoc,
3216 Expr *ControllingExpr,
3218 ArrayRef<Expr *> Exprs) {
3219 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3220 /*PredicateIsExpr=*/true,
3221 ControllingExpr, Types, Exprs);
3222 }
3223
3224 /// Build a new generic selection expression with a type predicate.
3225 ///
3226 /// By default, performs semantic analysis to build the new expression.
3227 /// Subclasses may override this routine to provide different behavior.
3229 SourceLocation DefaultLoc,
3230 SourceLocation RParenLoc,
3231 TypeSourceInfo *ControllingType,
3233 ArrayRef<Expr *> Exprs) {
3234 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3235 /*PredicateIsExpr=*/false,
3236 ControllingType, Types, Exprs);
3237 }
3238
3239 /// Build a new overloaded operator call expression.
3240 ///
3241 /// By default, performs semantic analysis to build the new expression.
3242 /// The semantic analysis provides the behavior of template instantiation,
3243 /// copying with transformations that turn what looks like an overloaded
3244 /// operator call into a use of a builtin operator, performing
3245 /// argument-dependent lookup, etc. Subclasses may override this routine to
3246 /// provide different behavior.
3248 SourceLocation OpLoc,
3249 SourceLocation CalleeLoc,
3250 bool RequiresADL,
3251 const UnresolvedSetImpl &Functions,
3252 Expr *First, Expr *Second);
3253
3254 /// Build a new C++ "named" cast expression, such as static_cast or
3255 /// reinterpret_cast.
3256 ///
3257 /// By default, this routine dispatches to one of the more-specific routines
3258 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3259 /// Subclasses may override this routine to provide different behavior.
3262 SourceLocation LAngleLoc,
3263 TypeSourceInfo *TInfo,
3264 SourceLocation RAngleLoc,
3265 SourceLocation LParenLoc,
3266 Expr *SubExpr,
3267 SourceLocation RParenLoc) {
3268 switch (Class) {
3269 case Stmt::CXXStaticCastExprClass:
3270 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3271 RAngleLoc, LParenLoc,
3272 SubExpr, RParenLoc);
3273
3274 case Stmt::CXXDynamicCastExprClass:
3275 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3276 RAngleLoc, LParenLoc,
3277 SubExpr, RParenLoc);
3278
3279 case Stmt::CXXReinterpretCastExprClass:
3280 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3281 RAngleLoc, LParenLoc,
3282 SubExpr,
3283 RParenLoc);
3284
3285 case Stmt::CXXConstCastExprClass:
3286 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3287 RAngleLoc, LParenLoc,
3288 SubExpr, RParenLoc);
3289
3290 case Stmt::CXXAddrspaceCastExprClass:
3291 return getDerived().RebuildCXXAddrspaceCastExpr(
3292 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3293
3294 default:
3295 llvm_unreachable("Invalid C++ named cast");
3296 }
3297 }
3298
3299 /// Build a new C++ static_cast expression.
3300 ///
3301 /// By default, performs semantic analysis to build the new expression.
3302 /// Subclasses may override this routine to provide different behavior.
3304 SourceLocation LAngleLoc,
3305 TypeSourceInfo *TInfo,
3306 SourceLocation RAngleLoc,
3307 SourceLocation LParenLoc,
3308 Expr *SubExpr,
3309 SourceLocation RParenLoc) {
3310 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3311 TInfo, SubExpr,
3312 SourceRange(LAngleLoc, RAngleLoc),
3313 SourceRange(LParenLoc, RParenLoc));
3314 }
3315
3316 /// Build a new C++ dynamic_cast expression.
3317 ///
3318 /// By default, performs semantic analysis to build the new expression.
3319 /// Subclasses may override this routine to provide different behavior.
3321 SourceLocation LAngleLoc,
3322 TypeSourceInfo *TInfo,
3323 SourceLocation RAngleLoc,
3324 SourceLocation LParenLoc,
3325 Expr *SubExpr,
3326 SourceLocation RParenLoc) {
3327 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3328 TInfo, SubExpr,
3329 SourceRange(LAngleLoc, RAngleLoc),
3330 SourceRange(LParenLoc, RParenLoc));
3331 }
3332
3333 /// Build a new C++ reinterpret_cast expression.
3334 ///
3335 /// By default, performs semantic analysis to build the new expression.
3336 /// Subclasses may override this routine to provide different behavior.
3338 SourceLocation LAngleLoc,
3339 TypeSourceInfo *TInfo,
3340 SourceLocation RAngleLoc,
3341 SourceLocation LParenLoc,
3342 Expr *SubExpr,
3343 SourceLocation RParenLoc) {
3344 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3345 TInfo, SubExpr,
3346 SourceRange(LAngleLoc, RAngleLoc),
3347 SourceRange(LParenLoc, RParenLoc));
3348 }
3349
3350 /// Build a new C++ const_cast expression.
3351 ///
3352 /// By default, performs semantic analysis to build the new expression.
3353 /// Subclasses may override this routine to provide different behavior.
3355 SourceLocation LAngleLoc,
3356 TypeSourceInfo *TInfo,
3357 SourceLocation RAngleLoc,
3358 SourceLocation LParenLoc,
3359 Expr *SubExpr,
3360 SourceLocation RParenLoc) {
3361 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3362 TInfo, SubExpr,
3363 SourceRange(LAngleLoc, RAngleLoc),
3364 SourceRange(LParenLoc, RParenLoc));
3365 }
3366
3369 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3370 SourceLocation LParenLoc, Expr *SubExpr,
3371 SourceLocation RParenLoc) {
3372 return getSema().BuildCXXNamedCast(
3373 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3374 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3375 }
3376
3377 /// Build a new C++ functional-style cast expression.
3378 ///
3379 /// By default, performs semantic analysis to build the new expression.
3380 /// Subclasses may override this routine to provide different behavior.
3382 SourceLocation LParenLoc,
3383 Expr *Sub,
3384 SourceLocation RParenLoc,
3385 bool ListInitialization) {
3386 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3387 // CXXParenListInitExpr. Pass its expanded arguments so that the
3388 // CXXParenListInitExpr can be rebuilt.
3389 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3391 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3392 RParenLoc, ListInitialization);
3393
3394 if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub))
3396 TInfo, LParenLoc, PLE->getInitExprs(), RParenLoc, ListInitialization);
3397
3398 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3399 MultiExprArg(&Sub, 1), RParenLoc,
3400 ListInitialization);
3401 }
3402
3403 /// Build a new C++ __builtin_bit_cast expression.
3404 ///
3405 /// By default, performs semantic analysis to build the new expression.
3406 /// Subclasses may override this routine to provide different behavior.
3408 TypeSourceInfo *TSI, Expr *Sub,
3409 SourceLocation RParenLoc) {
3410 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3411 }
3412
3413 /// Build a new C++ typeid(type) expression.
3414 ///
3415 /// By default, performs semantic analysis to build the new expression.
3416 /// Subclasses may override this routine to provide different behavior.
3418 SourceLocation TypeidLoc,
3419 TypeSourceInfo *Operand,
3420 SourceLocation RParenLoc) {
3421 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3422 RParenLoc);
3423 }
3424
3425
3426 /// Build a new C++ typeid(expr) expression.
3427 ///
3428 /// By default, performs semantic analysis to build the new expression.
3429 /// Subclasses may override this routine to provide different behavior.
3431 SourceLocation TypeidLoc,
3432 Expr *Operand,
3433 SourceLocation RParenLoc) {
3434 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3435 RParenLoc);
3436 }
3437
3438 /// Build a new C++ __uuidof(type) expression.
3439 ///
3440 /// By default, performs semantic analysis to build the new expression.
3441 /// Subclasses may override this routine to provide different behavior.
3443 TypeSourceInfo *Operand,
3444 SourceLocation RParenLoc) {
3445 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3446 }
3447
3448 /// Build a new C++ __uuidof(expr) expression.
3449 ///
3450 /// By default, performs semantic analysis to build the new expression.
3451 /// Subclasses may override this routine to provide different behavior.
3453 Expr *Operand, SourceLocation RParenLoc) {
3454 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3455 }
3456
3457 /// Build a new C++ "this" expression.
3458 ///
3459 /// By default, performs semantic analysis to build a new "this" expression.
3460 /// Subclasses may override this routine to provide different behavior.
3462 QualType ThisType,
3463 bool isImplicit) {
3464 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3465 return ExprError();
3466 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3467 }
3468
3469 /// Build a new C++ throw expression.
3470 ///
3471 /// By default, performs semantic analysis to build the new expression.
3472 /// Subclasses may override this routine to provide different behavior.
3474 bool IsThrownVariableInScope) {
3475 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3476 }
3477
3478 /// Build a new C++ default-argument expression.
3479 ///
3480 /// By default, builds a new default-argument expression, which does not
3481 /// require any semantic analysis. Subclasses may override this routine to
3482 /// provide different behavior.
3484 Expr *RewrittenExpr) {
3485 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3486 RewrittenExpr, getSema().CurContext);
3487 }
3488
3489 /// Build a new C++11 default-initialization expression.
3490 ///
3491 /// By default, builds a new default field initialization expression, which
3492 /// does not require any semantic analysis. Subclasses may override this
3493 /// routine to provide different behavior.
3498
3499 /// Build a new C++ zero-initialization expression.
3500 ///
3501 /// By default, performs semantic analysis to build the new expression.
3502 /// Subclasses may override this routine to provide different behavior.
3504 SourceLocation LParenLoc,
3505 SourceLocation RParenLoc) {
3506 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3507 /*ListInitialization=*/false);
3508 }
3509
3510 /// Build a new C++ "new" expression.
3511 ///
3512 /// By default, performs semantic analysis to build the new expression.
3513 /// Subclasses may override this routine to provide different behavior.
3515 SourceLocation PlacementLParen,
3516 MultiExprArg PlacementArgs,
3517 SourceLocation PlacementRParen,
3518 SourceRange TypeIdParens, QualType AllocatedType,
3519 TypeSourceInfo *AllocatedTypeInfo,
3520 std::optional<Expr *> ArraySize,
3521 SourceRange DirectInitRange, Expr *Initializer) {
3522 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3523 PlacementLParen,
3524 PlacementArgs,
3525 PlacementRParen,
3526 TypeIdParens,
3527 AllocatedType,
3528 AllocatedTypeInfo,
3529 ArraySize,
3530 DirectInitRange,
3531 Initializer);
3532 }
3533
3534 /// Build a new C++ "delete" expression.
3535 ///
3536 /// By default, performs semantic analysis to build the new expression.
3537 /// Subclasses may override this routine to provide different behavior.
3539 bool IsGlobalDelete,
3540 bool IsArrayForm,
3541 Expr *Operand) {
3542 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3543 Operand);
3544 }
3545
3546 /// Build a new type trait expression.
3547 ///
3548 /// By default, performs semantic analysis to build the new expression.
3549 /// Subclasses may override this routine to provide different behavior.
3551 SourceLocation StartLoc,
3553 SourceLocation RParenLoc) {
3554 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3555 }
3556
3557 /// Build a new array type trait expression.
3558 ///
3559 /// By default, performs semantic analysis to build the new expression.
3560 /// Subclasses may override this routine to provide different behavior.
3562 SourceLocation StartLoc,
3563 TypeSourceInfo *TSInfo,
3564 Expr *DimExpr,
3565 SourceLocation RParenLoc) {
3566 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3567 }
3568
3569 /// Build a new expression trait expression.
3570 ///
3571 /// By default, performs semantic analysis to build the new expression.
3572 /// Subclasses may override this routine to provide different behavior.
3574 SourceLocation StartLoc,
3575 Expr *Queried,
3576 SourceLocation RParenLoc) {
3577 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3578 }
3579
3580 /// Build a new (previously unresolved) declaration reference
3581 /// expression.
3582 ///
3583 /// By default, performs semantic analysis to build the new expression.
3584 /// Subclasses may override this routine to provide different behavior.
3586 NestedNameSpecifierLoc QualifierLoc,
3587 SourceLocation TemplateKWLoc,
3588 const DeclarationNameInfo &NameInfo,
3589 const TemplateArgumentListInfo *TemplateArgs,
3590 bool IsAddressOfOperand,
3591 TypeSourceInfo **RecoveryTSI) {
3592 CXXScopeSpec SS;
3593 SS.Adopt(QualifierLoc);
3594
3595 if (TemplateArgs || TemplateKWLoc.isValid())
3597 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3598
3600 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3601 }
3602
3603 /// Build a new template-id expression.
3604 ///
3605 /// By default, performs semantic analysis to build the new expression.
3606 /// Subclasses may override this routine to provide different behavior.
3608 SourceLocation TemplateKWLoc,
3609 LookupResult &R,
3610 bool RequiresADL,
3611 const TemplateArgumentListInfo *TemplateArgs) {
3612 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3613 TemplateArgs);
3614 }
3615
3616 /// Build a new object-construction expression.
3617 ///
3618 /// By default, performs semantic analysis to build the new expression.
3619 /// Subclasses may override this routine to provide different behavior.
3622 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3623 bool ListInitialization, bool StdInitListInitialization,
3624 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3625 SourceRange ParenRange) {
3626 // Reconstruct the constructor we originally found, which might be
3627 // different if this is a call to an inherited constructor.
3628 CXXConstructorDecl *FoundCtor = Constructor;
3629 if (Constructor->isInheritingConstructor())
3630 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3631
3632 SmallVector<Expr *, 8> ConvertedArgs;
3633 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3634 ConvertedArgs))
3635 return ExprError();
3636
3638 IsElidable,
3639 ConvertedArgs,
3640 HadMultipleCandidates,
3641 ListInitialization,
3642 StdInitListInitialization,
3643 RequiresZeroInit, ConstructKind,
3644 ParenRange);
3645 }
3646
3647 /// Build a new implicit construction via inherited constructor
3648 /// expression.
3651 bool ConstructsVBase,
3652 bool InheritedFromVBase) {
3654 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3655 }
3656
3657 /// Build a new object-construction expression.
3658 ///
3659 /// By default, performs semantic analysis to build the new expression.
3660 /// Subclasses may override this routine to provide different behavior.
3662 SourceLocation LParenOrBraceLoc,
3663 MultiExprArg Args,
3664 SourceLocation RParenOrBraceLoc,
3665 bool ListInitialization) {
3667 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3668 }
3669
3670 /// Build a new object-construction expression.
3671 ///
3672 /// By default, performs semantic analysis to build the new expression.
3673 /// Subclasses may override this routine to provide different behavior.
3675 SourceLocation LParenLoc,
3676 MultiExprArg Args,
3677 SourceLocation RParenLoc,
3678 bool ListInitialization) {
3679 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3680 RParenLoc, ListInitialization);
3681 }
3682
3683 /// Build a new member reference expression.
3684 ///
3685 /// By default, performs semantic analysis to build the new expression.
3686 /// Subclasses may override this routine to provide different behavior.
3688 QualType BaseType,
3689 bool IsArrow,
3690 SourceLocation OperatorLoc,
3691 NestedNameSpecifierLoc QualifierLoc,
3692 SourceLocation TemplateKWLoc,
3693 NamedDecl *FirstQualifierInScope,
3694 const DeclarationNameInfo &MemberNameInfo,
3695 const TemplateArgumentListInfo *TemplateArgs) {
3696 CXXScopeSpec SS;
3697 SS.Adopt(QualifierLoc);
3698
3699 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3700 OperatorLoc, IsArrow,
3701 SS, TemplateKWLoc,
3702 FirstQualifierInScope,
3703 MemberNameInfo,
3704 TemplateArgs, /*S*/nullptr);
3705 }
3706
3707 /// Build a new member reference expression.
3708 ///
3709 /// By default, performs semantic analysis to build the new expression.
3710 /// Subclasses may override this routine to provide different behavior.
3712 SourceLocation OperatorLoc,
3713 bool IsArrow,
3714 NestedNameSpecifierLoc QualifierLoc,
3715 SourceLocation TemplateKWLoc,
3716 NamedDecl *FirstQualifierInScope,
3717 LookupResult &R,
3718 const TemplateArgumentListInfo *TemplateArgs) {
3719 CXXScopeSpec SS;
3720 SS.Adopt(QualifierLoc);
3721
3722 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3723 OperatorLoc, IsArrow,
3724 SS, TemplateKWLoc,
3725 FirstQualifierInScope,
3726 R, TemplateArgs, /*S*/nullptr);
3727 }
3728
3729 /// Build a new noexcept expression.
3730 ///
3731 /// By default, performs semantic analysis to build the new expression.
3732 /// Subclasses may override this routine to provide different behavior.
3734 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3735 }
3736
3739
3740 /// Build a new expression to compute the length of a parameter pack.
3742 SourceLocation PackLoc,
3743 SourceLocation RParenLoc,
3744 UnsignedOrNone Length,
3745 ArrayRef<TemplateArgument> PartialArgs) {
3746 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3747 RParenLoc, Length, PartialArgs);
3748 }
3749
3751 SourceLocation RSquareLoc,
3752 Expr *PackIdExpression, Expr *IndexExpr,
3753 ArrayRef<Expr *> ExpandedExprs,
3754 bool FullySubstituted = false) {
3755 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3756 IndexExpr, RSquareLoc, ExpandedExprs,
3757 FullySubstituted);
3758 }
3759
3760 /// Build a new expression representing a call to a source location
3761 /// builtin.
3762 ///
3763 /// By default, performs semantic analysis to build the new expression.
3764 /// Subclasses may override this routine to provide different behavior.
3766 SourceLocation BuiltinLoc,
3767 SourceLocation RPLoc,
3768 DeclContext *ParentContext) {
3769 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3770 ParentContext);
3771 }
3772
3774 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3775 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3777 CXXScopeSpec SS;
3778 SS.Adopt(NNS);
3779 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3780 ConceptNameInfo,
3781 FoundDecl,
3782 NamedConcept, TALI);
3783 if (Result.isInvalid())
3784 return ExprError();
3785 return Result;
3786 }
3787
3788 /// \brief Build a new requires expression.
3789 ///
3790 /// By default, performs semantic analysis to build the new expression.
3791 /// Subclasses may override this routine to provide different behavior.
3794 SourceLocation LParenLoc,
3795 ArrayRef<ParmVarDecl *> LocalParameters,
3796 SourceLocation RParenLoc,
3798 SourceLocation ClosingBraceLoc) {
3799 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3800 LocalParameters, RParenLoc, Requirements,
3801 ClosingBraceLoc);
3802 }
3803
3807 return SemaRef.BuildTypeRequirement(SubstDiag);
3808 }
3809
3811 return SemaRef.BuildTypeRequirement(T);
3812 }
3813
3816 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3817 SourceLocation NoexceptLoc,
3819 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3820 std::move(Ret));
3821 }
3822
3824 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3826 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3827 std::move(Ret));
3828 }
3829
3831 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3832 const ASTConstraintSatisfaction &Satisfaction) {
3833 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3834 Satisfaction);
3835 }
3836
3838 return SemaRef.BuildNestedRequirement(Constraint);
3839 }
3840
3841 /// \brief Build a new Objective-C boxed expression.
3842 ///
3843 /// By default, performs semantic analysis to build the new expression.
3844 /// Subclasses may override this routine to provide different behavior.
3846 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3847 }
3848
3849 /// Build a new Objective-C array literal.
3850 ///
3851 /// By default, performs semantic analysis to build the new expression.
3852 /// Subclasses may override this routine to provide different behavior.
3854 Expr **Elements, unsigned NumElements) {
3856 Range, MultiExprArg(Elements, NumElements));
3857 }
3858
3860 Expr *Base, Expr *Key,
3861 ObjCMethodDecl *getterMethod,
3862 ObjCMethodDecl *setterMethod) {
3864 RB, Base, Key, getterMethod, setterMethod);
3865 }
3866
3867 /// Build a new Objective-C dictionary literal.
3868 ///
3869 /// By default, performs semantic analysis to build the new expression.
3870 /// Subclasses may override this routine to provide different behavior.
3875
3876 /// Build a new Objective-C \@encode expression.
3877 ///
3878 /// By default, performs semantic analysis to build the new expression.
3879 /// Subclasses may override this routine to provide different behavior.
3881 TypeSourceInfo *EncodeTypeInfo,
3882 SourceLocation RParenLoc) {
3883 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3884 RParenLoc);
3885 }
3886
3887 /// Build a new Objective-C class message.
3889 Selector Sel,
3890 ArrayRef<SourceLocation> SelectorLocs,
3892 SourceLocation LBracLoc,
3893 MultiExprArg Args,
3894 SourceLocation RBracLoc) {
3895 return SemaRef.ObjC().BuildClassMessage(
3896 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3897 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3898 RBracLoc, Args);
3899 }
3900
3901 /// Build a new Objective-C instance message.
3903 Selector Sel,
3904 ArrayRef<SourceLocation> SelectorLocs,
3906 SourceLocation LBracLoc,
3907 MultiExprArg Args,
3908 SourceLocation RBracLoc) {
3909 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3910 /*SuperLoc=*/SourceLocation(),
3911 Sel, Method, LBracLoc,
3912 SelectorLocs, RBracLoc, Args);
3913 }
3914
3915 /// Build a new Objective-C instance/class message to 'super'.
3917 Selector Sel,
3918 ArrayRef<SourceLocation> SelectorLocs,
3919 QualType SuperType,
3921 SourceLocation LBracLoc,
3922 MultiExprArg Args,
3923 SourceLocation RBracLoc) {
3924 return Method->isInstanceMethod()
3925 ? SemaRef.ObjC().BuildInstanceMessage(
3926 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3927 SelectorLocs, RBracLoc, Args)
3928 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3929 Sel, Method, LBracLoc,
3930 SelectorLocs, RBracLoc, Args);
3931 }
3932
3933 /// Build a new Objective-C ivar reference expression.
3934 ///
3935 /// By default, performs semantic analysis to build the new expression.
3936 /// Subclasses may override this routine to provide different behavior.
3938 SourceLocation IvarLoc,
3939 bool IsArrow, bool IsFreeIvar) {
3940 CXXScopeSpec SS;
3941 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3943 BaseArg, BaseArg->getType(),
3944 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3945 /*FirstQualifierInScope=*/nullptr, NameInfo,
3946 /*TemplateArgs=*/nullptr,
3947 /*S=*/nullptr);
3948 if (IsFreeIvar && Result.isUsable())
3949 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3950 return Result;
3951 }
3952
3953 /// Build a new Objective-C property reference expression.
3954 ///
3955 /// By default, performs semantic analysis to build the new expression.
3956 /// Subclasses may override this routine to provide different behavior.
3959 SourceLocation PropertyLoc) {
3960 CXXScopeSpec SS;
3961 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3962 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3963 /*FIXME:*/PropertyLoc,
3964 /*IsArrow=*/false,
3965 SS, SourceLocation(),
3966 /*FirstQualifierInScope=*/nullptr,
3967 NameInfo,
3968 /*TemplateArgs=*/nullptr,
3969 /*S=*/nullptr);
3970 }
3971
3972 /// Build a new Objective-C property reference expression.
3973 ///
3974 /// By default, performs semantic analysis to build the new expression.
3975 /// Subclasses may override this routine to provide different behavior.
3977 ObjCMethodDecl *Getter,
3978 ObjCMethodDecl *Setter,
3979 SourceLocation PropertyLoc) {
3980 // Since these expressions can only be value-dependent, we do not
3981 // need to perform semantic analysis again.
3982 return Owned(
3983 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3985 PropertyLoc, Base));
3986 }
3987
3988 /// Build a new Objective-C "isa" expression.
3989 ///
3990 /// By default, performs semantic analysis to build the new expression.
3991 /// Subclasses may override this routine to provide different behavior.
3993 SourceLocation OpLoc, bool IsArrow) {
3994 CXXScopeSpec SS;
3995 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
3996 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3997 OpLoc, IsArrow,
3998 SS, SourceLocation(),
3999 /*FirstQualifierInScope=*/nullptr,
4000 NameInfo,
4001 /*TemplateArgs=*/nullptr,
4002 /*S=*/nullptr);
4003 }
4004
4005 /// Build a new shuffle vector expression.
4006 ///
4007 /// By default, performs semantic analysis to build the new expression.
4008 /// Subclasses may override this routine to provide different behavior.
4010 MultiExprArg SubExprs,
4011 SourceLocation RParenLoc) {
4012 // Find the declaration for __builtin_shufflevector
4013 const IdentifierInfo &Name
4014 = SemaRef.Context.Idents.get("__builtin_shufflevector");
4015 TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
4016 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
4017 assert(!Lookup.empty() && "No __builtin_shufflevector?");
4018
4019 // Build a reference to the __builtin_shufflevector builtin
4021 Expr *Callee = new (SemaRef.Context)
4022 DeclRefExpr(SemaRef.Context, Builtin, false,
4023 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
4024 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
4025 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
4026 CK_BuiltinFnToFnPtr).get();
4027
4028 // Build the CallExpr
4029 ExprResult TheCall = CallExpr::Create(
4030 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
4031 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
4033
4034 // Type-check the __builtin_shufflevector expression.
4035 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
4036 }
4037
4038 /// Build a new convert vector expression.
4040 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
4041 SourceLocation RParenLoc) {
4042 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
4043 }
4044
4045 /// Build a new template argument pack expansion.
4046 ///
4047 /// By default, performs semantic analysis to build a new pack expansion
4048 /// for a template argument. Subclasses may override this routine to provide
4049 /// different behavior.
4051 SourceLocation EllipsisLoc,
4052 UnsignedOrNone NumExpansions) {
4053 switch (Pattern.getArgument().getKind()) {
4057 EllipsisLoc, NumExpansions);
4058 if (Result.isInvalid())
4059 return TemplateArgumentLoc();
4060
4062 /*IsCanonical=*/false),
4063 Result.get());
4064 }
4065
4067 return TemplateArgumentLoc(
4068 SemaRef.Context,
4070 NumExpansions),
4071 Pattern.getTemplateKWLoc(), Pattern.getTemplateQualifierLoc(),
4072 Pattern.getTemplateNameLoc(), EllipsisLoc);
4073
4081 llvm_unreachable("Pack expansion pattern has no parameter packs");
4082
4084 if (TypeSourceInfo *Expansion
4085 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4086 EllipsisLoc,
4087 NumExpansions))
4088 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4089 Expansion);
4090 break;
4091 }
4092
4093 return TemplateArgumentLoc();
4094 }
4095
4096 /// Build a new expression pack expansion.
4097 ///
4098 /// By default, performs semantic analysis to build a new pack expansion
4099 /// for an expression. Subclasses may override this routine to provide
4100 /// different behavior.
4102 UnsignedOrNone NumExpansions) {
4103 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4104 }
4105
4106 /// Build a new C++1z fold-expression.
4107 ///
4108 /// By default, performs semantic analysis in order to build a new fold
4109 /// expression.
4111 SourceLocation LParenLoc, Expr *LHS,
4112 BinaryOperatorKind Operator,
4113 SourceLocation EllipsisLoc, Expr *RHS,
4114 SourceLocation RParenLoc,
4115 UnsignedOrNone NumExpansions) {
4116 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4117 EllipsisLoc, RHS, RParenLoc,
4118 NumExpansions);
4119 }
4120
4122 LambdaScopeInfo *LSI) {
4123 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4124 if (Expr *Init = PVD->getInit())
4126 Init->containsUnexpandedParameterPack();
4127 else if (PVD->hasUninstantiatedDefaultArg())
4129 PVD->getUninstantiatedDefaultArg()
4130 ->containsUnexpandedParameterPack();
4131 }
4132 return getSema().BuildLambdaExpr(StartLoc, EndLoc);
4133 }
4134
4135 /// Build an empty C++1z fold-expression with the given operator.
4136 ///
4137 /// By default, produces the fallback value for the fold-expression, or
4138 /// produce an error if there is no fallback value.
4140 BinaryOperatorKind Operator) {
4141 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4142 }
4143
4144 /// Build a new atomic operation expression.
4145 ///
4146 /// By default, performs semantic analysis to build the new expression.
4147 /// Subclasses may override this routine to provide different behavior.
4150 SourceLocation RParenLoc) {
4151 // Use this for all of the locations, since we don't know the difference
4152 // between the call and the expr at this point.
4153 SourceRange Range{BuiltinLoc, RParenLoc};
4154 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4156 }
4157
4159 ArrayRef<Expr *> SubExprs, QualType Type) {
4160 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4161 }
4162
4164 SourceLocation BeginLoc,
4165 SourceLocation DirLoc,
4166 SourceLocation EndLoc,
4168 StmtResult StrBlock) {
4170 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4171 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, StrBlock);
4172 }
4173
4184
4186 SourceLocation BeginLoc,
4187 SourceLocation DirLoc,
4188 SourceLocation EndLoc,
4190 StmtResult Loop) {
4192 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4193 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, Loop);
4194 }
4195
4197 SourceLocation DirLoc,
4198 SourceLocation EndLoc,
4200 StmtResult StrBlock) {
4202 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4204 Clauses, StrBlock);
4205 }
4206
4216
4226
4228 SourceLocation DirLoc,
4229 SourceLocation EndLoc,
4231 StmtResult StrBlock) {
4235 Clauses, StrBlock);
4236 }
4237
4239 SourceLocation DirLoc,
4240 SourceLocation EndLoc,
4241 ArrayRef<OpenACCClause *> Clauses) {
4243 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4245 Clauses, {});
4246 }
4247
4257
4259 SourceLocation DirLoc,
4260 SourceLocation EndLoc,
4261 ArrayRef<OpenACCClause *> Clauses) {
4263 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4265 Clauses, {});
4266 }
4267
4269 SourceLocation DirLoc,
4270 SourceLocation EndLoc,
4271 ArrayRef<OpenACCClause *> Clauses) {
4273 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4275 Clauses, {});
4276 }
4277
4279 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4280 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4281 SourceLocation RParenLoc, SourceLocation EndLoc,
4282 ArrayRef<OpenACCClause *> Clauses) {
4284 Exprs.push_back(DevNumExpr);
4285 llvm::append_range(Exprs, QueueIdExprs);
4287 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4288 Exprs, OpenACCAtomicKind::None, RParenLoc, EndLoc, Clauses, {});
4289 }
4290
4292 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4293 SourceLocation ReadOnlyLoc, ArrayRef<Expr *> VarList,
4294 SourceLocation RParenLoc, SourceLocation EndLoc) {
4296 OpenACCDirectiveKind::Cache, BeginLoc, DirLoc, LParenLoc, ReadOnlyLoc,
4297 VarList, OpenACCAtomicKind::None, RParenLoc, EndLoc, {}, {});
4298 }
4299
4301 SourceLocation DirLoc,
4302 OpenACCAtomicKind AtKind,
4303 SourceLocation EndLoc,
4305 StmtResult AssociatedStmt) {
4307 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4308 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, Clauses,
4309 AssociatedStmt);
4310 }
4311
4315
4318 const NonTypeTemplateParmDecl *NTTP,
4320 UnsignedOrNone PackIndex, bool Final) {
4322 AssociatedDecl, NTTP, Loc, Arg, PackIndex, Final);
4323 }
4324
4325private:
4326 QualType TransformTypeInObjectScope(TypeLocBuilder &TLB, TypeLoc TL,
4327 QualType ObjectType,
4328 NamedDecl *FirstQualifierInScope);
4329
4330 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4331 QualType ObjectType,
4332 NamedDecl *FirstQualifierInScope) {
4333 if (getDerived().AlreadyTransformed(TSInfo->getType()))
4334 return TSInfo;
4335
4336 TypeLocBuilder TLB;
4337 QualType T = TransformTypeInObjectScope(TLB, TSInfo->getTypeLoc(),
4338 ObjectType, FirstQualifierInScope);
4339 if (T.isNull())
4340 return nullptr;
4341 return TLB.getTypeSourceInfo(SemaRef.Context, T);
4342 }
4343
4344 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4345 DependentNameTypeLoc TL,
4346 bool DeducibleTSTContext,
4347 QualType ObjectType = QualType(),
4348 NamedDecl *UnqualLookup = nullptr);
4349
4351 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4353
4354 OpenACCClause *
4355 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4356 OpenACCDirectiveKind DirKind,
4357 const OpenACCClause *OldClause);
4358};
4359
4360template <typename Derived>
4362 if (!S)
4363 return S;
4364
4365 switch (S->getStmtClass()) {
4366 case Stmt::NoStmtClass: break;
4367
4368 // Transform individual statement nodes
4369 // Pass SDK into statements that can produce a value
4370#define STMT(Node, Parent) \
4371 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4372#define VALUESTMT(Node, Parent) \
4373 case Stmt::Node##Class: \
4374 return getDerived().Transform##Node(cast<Node>(S), SDK);
4375#define ABSTRACT_STMT(Node)
4376#define EXPR(Node, Parent)
4377#include "clang/AST/StmtNodes.inc"
4378
4379 // Transform expressions by calling TransformExpr.
4380#define STMT(Node, Parent)
4381#define ABSTRACT_STMT(Stmt)
4382#define EXPR(Node, Parent) case Stmt::Node##Class:
4383#include "clang/AST/StmtNodes.inc"
4384 {
4385 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4386
4388 E = getSema().ActOnStmtExprResult(E);
4389 return getSema().ActOnExprStmt(E, SDK == StmtDiscardKind::Discarded);
4390 }
4391 }
4392
4393 return S;
4394}
4395
4396template<typename Derived>
4398 if (!S)
4399 return S;
4400
4401 switch (S->getClauseKind()) {
4402 default: break;
4403 // Transform individual clause nodes
4404#define GEN_CLANG_CLAUSE_CLASS
4405#define CLAUSE_CLASS(Enum, Str, Class) \
4406 case Enum: \
4407 return getDerived().Transform##Class(cast<Class>(S));
4408#include "llvm/Frontend/OpenMP/OMP.inc"
4409 }
4410
4411 return S;
4412}
4413
4414
4415template<typename Derived>
4417 if (!E)
4418 return E;
4419
4420 switch (E->getStmtClass()) {
4421 case Stmt::NoStmtClass: break;
4422#define STMT(Node, Parent) case Stmt::Node##Class: break;
4423#define ABSTRACT_STMT(Stmt)
4424#define EXPR(Node, Parent) \
4425 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4426#include "clang/AST/StmtNodes.inc"
4427 }
4428
4429 return E;
4430}
4431
4432template<typename Derived>
4434 bool NotCopyInit) {
4435 // Initializers are instantiated like expressions, except that various outer
4436 // layers are stripped.
4437 if (!Init)
4438 return Init;
4439
4440 if (auto *FE = dyn_cast<FullExpr>(Init))
4441 Init = FE->getSubExpr();
4442
4443 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4444 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4445 Init = OVE->getSourceExpr();
4446 }
4447
4448 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4449 Init = MTE->getSubExpr();
4450
4451 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4452 Init = Binder->getSubExpr();
4453
4454 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4455 Init = ICE->getSubExprAsWritten();
4456
4457 if (CXXStdInitializerListExpr *ILE =
4458 dyn_cast<CXXStdInitializerListExpr>(Init))
4459 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4460
4461 // If this is copy-initialization, we only need to reconstruct
4462 // InitListExprs. Other forms of copy-initialization will be a no-op if
4463 // the initializer is already the right type.
4464 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4465 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4466 return getDerived().TransformExpr(Init);
4467
4468 // Revert value-initialization back to empty parens.
4469 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4470 SourceRange Parens = VIE->getSourceRange();
4471 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4472 Parens.getEnd());
4473 }
4474
4475 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4477 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4478 SourceLocation());
4479
4480 // Revert initialization by constructor back to a parenthesized or braced list
4481 // of expressions. Any other form of initializer can just be reused directly.
4482 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4483 return getDerived().TransformExpr(Init);
4484
4485 // If the initialization implicitly converted an initializer list to a
4486 // std::initializer_list object, unwrap the std::initializer_list too.
4487 if (Construct && Construct->isStdInitListInitialization())
4488 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4489
4490 // Enter a list-init context if this was list initialization.
4493 Construct->isListInitialization());
4494
4495 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4496 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4497 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4498 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4499 SmallVector<Expr*, 8> NewArgs;
4500 bool ArgChanged = false;
4501 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4502 /*IsCall*/true, NewArgs, &ArgChanged))
4503 return ExprError();
4504
4505 // If this was list initialization, revert to syntactic list form.
4506 if (Construct->isListInitialization())
4507 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4508 Construct->getEndLoc());
4509
4510 // Build a ParenListExpr to represent anything else.
4512 if (Parens.isInvalid()) {
4513 // This was a variable declaration's initialization for which no initializer
4514 // was specified.
4515 assert(NewArgs.empty() &&
4516 "no parens or braces but have direct init with arguments?");
4517 return ExprEmpty();
4518 }
4519 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4520 Parens.getEnd());
4521}
4522
4523template<typename Derived>
4525 unsigned NumInputs,
4526 bool IsCall,
4527 SmallVectorImpl<Expr *> &Outputs,
4528 bool *ArgChanged) {
4529 for (unsigned I = 0; I != NumInputs; ++I) {
4530 // If requested, drop call arguments that need to be dropped.
4531 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4532 if (ArgChanged)
4533 *ArgChanged = true;
4534
4535 break;
4536 }
4537
4538 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4539 Expr *Pattern = Expansion->getPattern();
4540
4542 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4543 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4544
4545 // Determine whether the set of unexpanded parameter packs can and should
4546 // be expanded.
4547 bool Expand = true;
4548 bool RetainExpansion = false;
4549 UnsignedOrNone OrigNumExpansions = Expansion->getNumExpansions();
4550 UnsignedOrNone NumExpansions = OrigNumExpansions;
4552 Expansion->getEllipsisLoc(), Pattern->getSourceRange(),
4553 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
4554 RetainExpansion, NumExpansions))
4555 return true;
4556
4557 if (!Expand) {
4558 // The transform has determined that we should perform a simple
4559 // transformation on the pack expansion, producing another pack
4560 // expansion.
4561 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
4562 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4563 if (OutPattern.isInvalid())
4564 return true;
4565
4566 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4567 Expansion->getEllipsisLoc(),
4568 NumExpansions);
4569 if (Out.isInvalid())
4570 return true;
4571
4572 if (ArgChanged)
4573 *ArgChanged = true;
4574 Outputs.push_back(Out.get());
4575 continue;
4576 }
4577
4578 // Record right away that the argument was changed. This needs
4579 // to happen even if the array expands to nothing.
4580 if (ArgChanged) *ArgChanged = true;
4581
4582 // The transform has determined that we should perform an elementwise
4583 // expansion of the pattern. Do so.
4584 for (unsigned I = 0; I != *NumExpansions; ++I) {
4585 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
4586 ExprResult Out = getDerived().TransformExpr(Pattern);
4587 if (Out.isInvalid())
4588 return true;
4589
4590 if (Out.get()->containsUnexpandedParameterPack()) {
4591 Out = getDerived().RebuildPackExpansion(
4592 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4593 if (Out.isInvalid())
4594 return true;
4595 }
4596
4597 Outputs.push_back(Out.get());
4598 }
4599
4600 // If we're supposed to retain a pack expansion, do so by temporarily
4601 // forgetting the partially-substituted parameter pack.
4602 if (RetainExpansion) {
4603 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4604
4605 ExprResult Out = getDerived().TransformExpr(Pattern);
4606 if (Out.isInvalid())
4607 return true;
4608
4609 Out = getDerived().RebuildPackExpansion(
4610 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4611 if (Out.isInvalid())
4612 return true;
4613
4614 Outputs.push_back(Out.get());
4615 }
4616
4617 continue;
4618 }
4619
4621 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4622 : getDerived().TransformExpr(Inputs[I]);
4623 if (Result.isInvalid())
4624 return true;
4625
4626 if (Result.get() != Inputs[I] && ArgChanged)
4627 *ArgChanged = true;
4628
4629 Outputs.push_back(Result.get());
4630 }
4631
4632 return false;
4633}
4634
4635template <typename Derived>
4638
4641 /*LambdaContextDecl=*/nullptr,
4643 /*ShouldEnter=*/Kind == Sema::ConditionKind::ConstexprIf);
4644
4645 if (Var) {
4646 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4648
4649 if (!ConditionVar)
4650 return Sema::ConditionError();
4651
4652 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4653 }
4654
4655 if (Expr) {
4656 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4657
4658 if (CondExpr.isInvalid())
4659 return Sema::ConditionError();
4660
4661 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4662 /*MissingOK=*/true);
4663 }
4664
4665 return Sema::ConditionResult();
4666}
4667
4668template <typename Derived>
4670 NestedNameSpecifierLoc NNS, QualType ObjectType,
4671 NamedDecl *FirstQualifierInScope) {
4673
4674 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4675 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4676 Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix)
4677 Qualifiers.push_back(Qualifier);
4678 };
4679 insertNNS(NNS);
4680
4681 CXXScopeSpec SS;
4682 while (!Qualifiers.empty()) {
4683 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4685
4686 switch (QNNS.getKind()) {
4688 llvm_unreachable("unexpected null nested name specifier");
4689
4692 Q.getLocalBeginLoc(), const_cast<NamespaceBaseDecl *>(
4694 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4695 break;
4696 }
4697
4699 // There is no meaningful transformation that one could perform on the
4700 // global scope.
4701 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4702 break;
4703
4705 CXXRecordDecl *RD = cast_or_null<CXXRecordDecl>(
4707 SS.MakeMicrosoftSuper(SemaRef.Context, RD, Q.getBeginLoc(),
4708 Q.getEndLoc());
4709 break;
4710 }
4711
4713 assert(SS.isEmpty());
4714 TypeLoc TL = Q.castAsTypeLoc();
4715
4716 if (auto DNT = TL.getAs<DependentNameTypeLoc>()) {
4717 NestedNameSpecifierLoc QualifierLoc = DNT.getQualifierLoc();
4718 if (QualifierLoc) {
4719 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4720 QualifierLoc, ObjectType, FirstQualifierInScope);
4721 if (!QualifierLoc)
4722 return NestedNameSpecifierLoc();
4723 ObjectType = QualType();
4724 FirstQualifierInScope = nullptr;
4725 }
4726 SS.Adopt(QualifierLoc);
4728 const_cast<IdentifierInfo *>(DNT.getTypePtr()->getIdentifier()),
4729 DNT.getNameLoc(), Q.getLocalEndLoc(), ObjectType);
4730 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo,
4731 false, SS,
4732 FirstQualifierInScope, false))
4733 return NestedNameSpecifierLoc();
4734 return SS.getWithLocInContext(SemaRef.Context);
4735 }
4736
4737 QualType T = TL.getType();
4738 TypeLocBuilder TLB;
4740 T = TransformTypeInObjectScope(TLB, TL, ObjectType,
4741 FirstQualifierInScope);
4742 if (T.isNull())
4743 return NestedNameSpecifierLoc();
4744 TL = TLB.getTypeLocInContext(SemaRef.Context, T);
4745 }
4746
4747 if (T->isDependentType() || T->isRecordType() ||
4748 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4749 if (T->isEnumeralType())
4750 SemaRef.Diag(TL.getBeginLoc(),
4751 diag::warn_cxx98_compat_enum_nested_name_spec);
4752 SS.Make(SemaRef.Context, TL, Q.getLocalEndLoc());
4753 break;
4754 }
4755 // If the nested-name-specifier is an invalid type def, don't emit an
4756 // error because a previous error should have already been emitted.
4758 if (!TTL || !TTL.getDecl()->isInvalidDecl()) {
4759 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4760 << T << SS.getRange();
4761 }
4762 return NestedNameSpecifierLoc();
4763 }
4764 }
4765 }
4766
4767 // Don't rebuild the nested-name-specifier if we don't have to.
4768 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4770 return NNS;
4771
4772 // If we can re-use the source-location data from the original
4773 // nested-name-specifier, do so.
4774 if (SS.location_size() == NNS.getDataLength() &&
4775 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4777
4778 // Allocate new nested-name-specifier location information.
4779 return SS.getWithLocInContext(SemaRef.Context);
4780}
4781
4782template<typename Derived>
4786 DeclarationName Name = NameInfo.getName();
4787 if (!Name)
4788 return DeclarationNameInfo();
4789
4790 switch (Name.getNameKind()) {
4798 return NameInfo;
4799
4801 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4802 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4803 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4804 if (!NewTemplate)
4805 return DeclarationNameInfo();
4806
4807 DeclarationNameInfo NewNameInfo(NameInfo);
4808 NewNameInfo.setName(
4809 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
4810 return NewNameInfo;
4811 }
4812
4816 TypeSourceInfo *NewTInfo;
4817 CanQualType NewCanTy;
4818 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4819 NewTInfo = getDerived().TransformType(OldTInfo);
4820 if (!NewTInfo)
4821 return DeclarationNameInfo();
4822 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4823 }
4824 else {
4825 NewTInfo = nullptr;
4826 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4827 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4828 if (NewT.isNull())
4829 return DeclarationNameInfo();
4830 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4831 }
4832
4833 DeclarationName NewName
4834 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4835 NewCanTy);
4836 DeclarationNameInfo NewNameInfo(NameInfo);
4837 NewNameInfo.setName(NewName);
4838 NewNameInfo.setNamedTypeInfo(NewTInfo);
4839 return NewNameInfo;
4840 }
4841 }
4842
4843 llvm_unreachable("Unknown name kind.");
4844}
4845
4846template <typename Derived>
4848 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4850 QualType ObjectType, bool AllowInjectedClassName) {
4851 if (const IdentifierInfo *II = IO.getIdentifier())
4852 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, *II, NameLoc,
4853 ObjectType, AllowInjectedClassName);
4854 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, IO.getOperator(),
4855 NameLoc, ObjectType,
4856 AllowInjectedClassName);
4857}
4858
4859template <typename Derived>
4861 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
4862 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
4863 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
4865 TemplateName UnderlyingName = QTN->getUnderlyingTemplate();
4866
4867 if (QualifierLoc) {
4868 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4869 QualifierLoc, ObjectType, FirstQualifierInScope);
4870 if (!QualifierLoc)
4871 return TemplateName();
4872 }
4873
4874 NestedNameSpecifierLoc UnderlyingQualifier;
4875 TemplateName NewUnderlyingName = getDerived().TransformTemplateName(
4876 UnderlyingQualifier, TemplateKWLoc, UnderlyingName, NameLoc, ObjectType,
4877 FirstQualifierInScope, AllowInjectedClassName);
4878 if (NewUnderlyingName.isNull())
4879 return TemplateName();
4880 assert(!UnderlyingQualifier && "unexpected qualifier");
4881
4882 if (!getDerived().AlwaysRebuild() &&
4883 QualifierLoc.getNestedNameSpecifier() == QTN->getQualifier() &&
4884 NewUnderlyingName == UnderlyingName)
4885 return Name;
4886 CXXScopeSpec SS;
4887 SS.Adopt(QualifierLoc);
4888 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4889 NewUnderlyingName);
4890 }
4891
4893 if (QualifierLoc) {
4894 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4895 QualifierLoc, ObjectType, FirstQualifierInScope);
4896 if (!QualifierLoc)
4897 return TemplateName();
4898 // The qualifier-in-scope and object type only apply to the leftmost
4899 // entity.
4900 ObjectType = QualType();
4901 }
4902
4903 if (!getDerived().AlwaysRebuild() &&
4904 QualifierLoc.getNestedNameSpecifier() == DTN->getQualifier() &&
4905 ObjectType.isNull())
4906 return Name;
4907
4908 CXXScopeSpec SS;
4909 SS.Adopt(QualifierLoc);
4910 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, DTN->getName(),
4911 NameLoc, ObjectType,
4912 AllowInjectedClassName);
4913 }
4914
4917 assert(!QualifierLoc && "Unexpected qualified SubstTemplateTemplateParm");
4918
4919 NestedNameSpecifierLoc ReplacementQualifierLoc;
4920 TemplateName ReplacementName = S->getReplacement();
4921 if (NestedNameSpecifier Qualifier = ReplacementName.getQualifier()) {
4923 Builder.MakeTrivial(SemaRef.Context, Qualifier, NameLoc);
4924 ReplacementQualifierLoc = Builder.getWithLocInContext(SemaRef.Context);
4925 }
4926
4927 TemplateName NewName = getDerived().TransformTemplateName(
4928 ReplacementQualifierLoc, TemplateKWLoc, ReplacementName, NameLoc,
4929 ObjectType, FirstQualifierInScope, AllowInjectedClassName);
4930 if (NewName.isNull())
4931 return TemplateName();
4932 Decl *AssociatedDecl =
4933 getDerived().TransformDecl(NameLoc, S->getAssociatedDecl());
4934 if (!getDerived().AlwaysRebuild() && NewName == S->getReplacement() &&
4935 AssociatedDecl == S->getAssociatedDecl())
4936 return Name;
4937 return SemaRef.Context.getSubstTemplateTemplateParm(
4938 NewName, AssociatedDecl, S->getIndex(), S->getPackIndex(),
4939 S->getFinal());
4940 }
4941
4942 assert(!Name.getAsDeducedTemplateName() &&
4943 "DeducedTemplateName should not escape partial ordering");
4944
4945 // FIXME: Preserve UsingTemplateName.
4946 if (auto *Template = Name.getAsTemplateDecl()) {
4947 assert(!QualifierLoc && "Unexpected qualifier");
4948 return TemplateName(cast_or_null<TemplateDecl>(
4949 getDerived().TransformDecl(NameLoc, Template)));
4950 }
4951
4954 assert(!QualifierLoc &&
4955 "Unexpected qualified SubstTemplateTemplateParmPack");
4956 return getDerived().RebuildTemplateName(
4957 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4958 SubstPack->getIndex(), SubstPack->getFinal());
4959 }
4960
4961 // These should be getting filtered out before they reach the AST.
4962 llvm_unreachable("overloaded function decl survived to here");
4963}
4964
4965template <typename Derived>
4967 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
4968 TemplateName Name, SourceLocation NameLoc) {
4969 TemplateName TN = getDerived().TransformTemplateName(
4970 QualifierLoc, TemplateKeywordLoc, Name, NameLoc);
4971 if (TN.isNull())
4972 return TemplateArgument();
4973 return TemplateArgument(TN);
4974}
4975
4976template<typename Derived>
4978 const TemplateArgument &Arg,
4979 TemplateArgumentLoc &Output) {
4980 Output = getSema().getTrivialTemplateArgumentLoc(
4981 Arg, QualType(), getDerived().getBaseLocation());
4982}
4983
4984template <typename Derived>
4986 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
4987 bool Uneval) {
4988 const TemplateArgument &Arg = Input.getArgument();
4989 switch (Arg.getKind()) {
4992 llvm_unreachable("Unexpected TemplateArgument");
4993
4998 // Transform a resolved template argument straight to a resolved template
4999 // argument. We get here when substituting into an already-substituted
5000 // template type argument during concept satisfaction checking.
5002 QualType NewT = getDerived().TransformType(T);
5003 if (NewT.isNull())
5004 return true;
5005
5007 ? Arg.getAsDecl()
5008 : nullptr;
5009 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
5011 : nullptr;
5012 if (D && !NewD)
5013 return true;
5014
5015 if (NewT == T && D == NewD)
5016 Output = Input;
5017 else if (Arg.getKind() == TemplateArgument::Integral)
5018 Output = TemplateArgumentLoc(
5019 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
5021 else if (Arg.getKind() == TemplateArgument::NullPtr)
5022 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
5024 else if (Arg.getKind() == TemplateArgument::Declaration)
5025 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
5028 Output = TemplateArgumentLoc(
5029 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
5031 else
5032 llvm_unreachable("unexpected template argument kind");
5033
5034 return false;
5035 }
5036
5038 TypeSourceInfo *TSI = Input.getTypeSourceInfo();
5039 if (!TSI)
5041
5042 TSI = getDerived().TransformType(TSI);
5043 if (!TSI)
5044 return true;
5045
5046 Output = TemplateArgumentLoc(TemplateArgument(TSI->getType()), TSI);
5047 return false;
5048 }
5049
5051 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
5052
5053 TemplateArgument Out = getDerived().TransformNamedTemplateTemplateArgument(
5054 QualifierLoc, Input.getTemplateKWLoc(), Arg.getAsTemplate(),
5055 Input.getTemplateNameLoc());
5056 if (Out.isNull())
5057 return true;
5058 Output = TemplateArgumentLoc(SemaRef.Context, Out, Input.getTemplateKWLoc(),
5059 QualifierLoc, Input.getTemplateNameLoc());
5060 return false;
5061 }
5062
5064 llvm_unreachable("Caller should expand pack expansions");
5065
5067 // Template argument expressions are constant expressions.
5069 getSema(),
5072 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
5074
5075 Expr *InputExpr = Input.getSourceExpression();
5076 if (!InputExpr)
5077 InputExpr = Input.getArgument().getAsExpr();
5078
5079 ExprResult E = getDerived().TransformExpr(InputExpr);
5080 E = SemaRef.ActOnConstantExpression(E);
5081 if (E.isInvalid())
5082 return true;
5083 Output = TemplateArgumentLoc(
5084 TemplateArgument(E.get(), /*IsCanonical=*/false), E.get());
5085 return false;
5086 }
5087 }
5088
5089 // Work around bogus GCC warning
5090 return true;
5091}
5092
5093/// Iterator adaptor that invents template argument location information
5094/// for each of the template arguments in its underlying iterator.
5095template<typename Derived, typename InputIterator>
5098 InputIterator Iter;
5099
5100public:
5103 typedef typename std::iterator_traits<InputIterator>::difference_type
5105 typedef std::input_iterator_tag iterator_category;
5106
5107 class pointer {
5109
5110 public:
5111 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5112
5113 const TemplateArgumentLoc *operator->() const { return &Arg; }
5114 };
5115
5117 InputIterator Iter)
5118 : Self(Self), Iter(Iter) { }
5119
5121 ++Iter;
5122 return *this;
5123 }
5124
5127 ++(*this);
5128 return Old;
5129 }
5130
5133 Self.InventTemplateArgumentLoc(*Iter, Result);
5134 return Result;
5135 }
5136
5137 pointer operator->() const { return pointer(**this); }
5138
5141 return X.Iter == Y.Iter;
5142 }
5143
5146 return X.Iter != Y.Iter;
5147 }
5148};
5149
5150template<typename Derived>
5151template<typename InputIterator>
5153 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5154 bool Uneval) {
5155 for (TemplateArgumentLoc In : llvm::make_range(First, Last)) {
5157 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5158 // Unpack argument packs, which we translate them into separate
5159 // arguments.
5160 // FIXME: We could do much better if we could guarantee that the
5161 // TemplateArgumentLocInfo for the pack expansion would be usable for
5162 // all of the template arguments in the argument pack.
5163 typedef TemplateArgumentLocInventIterator<Derived,
5165 PackLocIterator;
5166
5167 TemplateArgumentListInfo *PackOutput = &Outputs;
5169
5171 PackLocIterator(*this, In.getArgument().pack_begin()),
5172 PackLocIterator(*this, In.getArgument().pack_end()), *PackOutput,
5173 Uneval))
5174 return true;
5175
5176 continue;
5177 }
5178
5179 if (In.getArgument().isPackExpansion()) {
5180 UnexpandedInfo Info;
5181 TemplateArgumentLoc Prepared;
5182 if (PreparePackForExpansion(In, Uneval, Prepared, Info))
5183 return true;
5184 if (!Info.Expand) {
5185 Outputs.addArgument(Prepared);
5186 continue;
5187 }
5188
5189 // The transform has determined that we should perform an elementwise
5190 // expansion of the pattern. Do so.
5191 std::optional<ForgetSubstitutionRAII> ForgetSubst;
5193 ForgetSubst.emplace(getDerived());
5194 for (unsigned I = 0; I != *Info.NumExpansions; ++I) {
5195 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5196
5198 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5199 return true;
5200
5201 if (Out.getArgument().containsUnexpandedParameterPack()) {
5202 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5203 Info.OrigNumExpansions);
5204 if (Out.getArgument().isNull())
5205 return true;
5206 }
5207
5208 Outputs.addArgument(Out);
5209 }
5210
5211 // If we're supposed to retain a pack expansion, do so by temporarily
5212 // forgetting the partially-substituted parameter pack.
5213 if (Info.RetainExpansion) {
5214 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5215
5217 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5218 return true;
5219
5220 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5221 Info.OrigNumExpansions);
5222 if (Out.getArgument().isNull())
5223 return true;
5224
5225 Outputs.addArgument(Out);
5226 }
5227
5228 continue;
5229 }
5230
5231 // The simple case:
5232 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5233 return true;
5234
5235 Outputs.addArgument(Out);
5236 }
5237
5238 return false;
5239}
5240
5241template <typename Derived>
5242template <typename InputIterator>
5244 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5245 bool Uneval) {
5246
5247 // [C++26][temp.constr.normal]
5248 // any non-dependent concept template argument
5249 // is substituted into the constraint-expression of C.
5250 auto isNonDependentConceptArgument = [](const TemplateArgument &Arg) {
5251 return !Arg.isDependent() && Arg.isConceptOrConceptTemplateParameter();
5252 };
5253
5254 for (; First != Last; ++First) {
5257
5258 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5259 typedef TemplateArgumentLocInventIterator<Derived,
5261 PackLocIterator;
5263 PackLocIterator(*this, In.getArgument().pack_begin()),
5264 PackLocIterator(*this, In.getArgument().pack_end()), Outputs,
5265 Uneval))
5266 return true;
5267 continue;
5268 }
5269
5270 if (!isNonDependentConceptArgument(In.getArgument())) {
5271 Outputs.addArgument(In);
5272 continue;
5273 }
5274
5275 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5276 return true;
5277
5278 Outputs.addArgument(Out);
5279 }
5280
5281 return false;
5282}
5283
5284// FIXME: Find ways to reduce code duplication for pack expansions.
5285template <typename Derived>
5287 bool Uneval,
5289 UnexpandedInfo &Info) {
5290 auto ComputeInfo = [this](TemplateArgumentLoc Arg,
5291 bool IsLateExpansionAttempt, UnexpandedInfo &Info,
5292 TemplateArgumentLoc &Pattern) {
5293 assert(Arg.getArgument().isPackExpansion());
5294 // We have a pack expansion, for which we will be substituting into the
5295 // pattern.
5296 Pattern = getSema().getTemplateArgumentPackExpansionPattern(
5297 Arg, Info.Ellipsis, Info.OrigNumExpansions);
5299 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5300 if (IsLateExpansionAttempt) {
5301 // Request expansion only when there is an opportunity to expand a pack
5302 // that required a substituion first.
5303 bool SawPackTypes =
5304 llvm::any_of(Unexpanded, [](UnexpandedParameterPack P) {
5305 return P.first.dyn_cast<const SubstBuiltinTemplatePackType *>();
5306 });
5307 if (!SawPackTypes) {
5308 Info.Expand = false;
5309 return false;
5310 }
5311 }
5312 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5313
5314 // Determine whether the set of unexpanded parameter packs can and
5315 // should be expanded.
5316 Info.Expand = true;
5317 Info.RetainExpansion = false;
5318 Info.NumExpansions = Info.OrigNumExpansions;
5319 return getDerived().TryExpandParameterPacks(
5320 Info.Ellipsis, Pattern.getSourceRange(), Unexpanded,
5321 /*FailOnPackProducingTemplates=*/false, Info.Expand,
5322 Info.RetainExpansion, Info.NumExpansions);
5323 };
5324
5325 TemplateArgumentLoc Pattern;
5326 if (ComputeInfo(In, false, Info, Pattern))
5327 return true;
5328
5329 if (Info.Expand) {
5330 Out = Pattern;
5331 return false;
5332 }
5333
5334 // The transform has determined that we should perform a simple
5335 // transformation on the pack expansion, producing another pack
5336 // expansion.
5337 TemplateArgumentLoc OutPattern;
5338 std::optional<Sema::ArgPackSubstIndexRAII> SubstIndex(
5339 std::in_place, getSema(), std::nullopt);
5340 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5341 return true;
5342
5343 Out = getDerived().RebuildPackExpansion(OutPattern, Info.Ellipsis,
5344 Info.NumExpansions);
5345 if (Out.getArgument().isNull())
5346 return true;
5347 SubstIndex.reset();
5348
5349 if (!OutPattern.getArgument().containsUnexpandedParameterPack())
5350 return false;
5351
5352 // Some packs will learn their length after substitution, e.g.
5353 // __builtin_dedup_pack<T,int> has size 1 or 2, depending on the substitution
5354 // value of `T`.
5355 //
5356 // We only expand after we know sizes of all packs, check if this is the case
5357 // or not. However, we avoid a full template substitution and only do
5358 // expanstions after this point.
5359
5360 // E.g. when substituting template arguments of tuple with {T -> int} in the
5361 // following example:
5362 // template <class T>
5363 // struct TupleWithInt {
5364 // using type = std::tuple<__builtin_dedup_pack<T, int>...>;
5365 // };
5366 // TupleWithInt<int>::type y;
5367 // At this point we will see the `__builtin_dedup_pack<int, int>` with a known
5368 // lenght and run `ComputeInfo()` to provide the necessary information to our
5369 // caller.
5370 //
5371 // Note that we may still have situations where builtin is not going to be
5372 // expanded. For example:
5373 // template <class T>
5374 // struct Foo {
5375 // template <class U> using tuple_with_t =
5376 // std::tuple<__builtin_dedup_pack<T, U, int>...>; using type =
5377 // tuple_with_t<short>;
5378 // }
5379 // Because the substitution into `type` happens in dependent context, `type`
5380 // will be `tuple<builtin_dedup_pack<T, short, int>...>` after substitution
5381 // and the caller will not be able to expand it.
5382 ForgetSubstitutionRAII ForgetSubst(getDerived());
5383 if (ComputeInfo(Out, true, Info, OutPattern))
5384 return true;
5385 if (!Info.Expand)
5386 return false;
5387 Out = OutPattern;
5388 Info.ExpandUnderForgetSubstitions = true;
5389 return false;
5390}
5391
5392//===----------------------------------------------------------------------===//
5393// Type transformation
5394//===----------------------------------------------------------------------===//
5395
5396template<typename Derived>
5399 return T;
5400
5401 // Temporary workaround. All of these transformations should
5402 // eventually turn into transformations on TypeLocs.
5403 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5405
5406 TypeSourceInfo *NewTSI = getDerived().TransformType(TSI);
5407
5408 if (!NewTSI)
5409 return QualType();
5410
5411 return NewTSI->getType();
5412}
5413
5414template <typename Derived>
5416 // Refine the base location to the type's location.
5417 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5420 return TSI;
5421
5422 TypeLocBuilder TLB;
5423
5424 TypeLoc TL = TSI->getTypeLoc();
5425 TLB.reserve(TL.getFullDataSize());
5426
5427 QualType Result = getDerived().TransformType(TLB, TL);
5428 if (Result.isNull())
5429 return nullptr;
5430
5431 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5432}
5433
5434template<typename Derived>
5437 switch (T.getTypeLocClass()) {
5438#define ABSTRACT_TYPELOC(CLASS, PARENT)
5439#define TYPELOC(CLASS, PARENT) \
5440 case TypeLoc::CLASS: \
5441 return getDerived().Transform##CLASS##Type(TLB, \
5442 T.castAs<CLASS##TypeLoc>());
5443#include "clang/AST/TypeLocNodes.def"
5444 }
5445
5446 llvm_unreachable("unhandled type loc!");
5447}
5448
5449template<typename Derived>
5452 return TransformType(T);
5453
5455 return T;
5456 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5458 TypeSourceInfo *NewTSI = getDerived().TransformTypeWithDeducedTST(TSI);
5459 return NewTSI ? NewTSI->getType() : QualType();
5460}
5461
5462template <typename Derived>
5465 if (!isa<DependentNameType>(TSI->getType()))
5466 return TransformType(TSI);
5467
5468 // Refine the base location to the type's location.
5469 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5472 return TSI;
5473
5474 TypeLocBuilder TLB;
5475
5476 TypeLoc TL = TSI->getTypeLoc();
5477 TLB.reserve(TL.getFullDataSize());
5478
5479 auto QTL = TL.getAs<QualifiedTypeLoc>();
5480 if (QTL)
5481 TL = QTL.getUnqualifiedLoc();
5482
5483 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5484
5485 QualType Result = getDerived().TransformDependentNameType(
5486 TLB, DNTL, /*DeducedTSTContext*/true);
5487 if (Result.isNull())
5488 return nullptr;
5489
5490 if (QTL) {
5491 Result = getDerived().RebuildQualifiedType(Result, QTL);
5492 if (Result.isNull())
5493 return nullptr;
5495 }
5496
5497 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5498}
5499
5500template<typename Derived>
5505 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5506 auto SuppressObjCLifetime =
5507 T.getType().getLocalQualifiers().hasObjCLifetime();
5508 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5509 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5510 SuppressObjCLifetime);
5511 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5512 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5513 TLB, STTP, SuppressObjCLifetime);
5514 } else {
5515 Result = getDerived().TransformType(TLB, UnqualTL);
5516 }
5517
5518 if (Result.isNull())
5519 return QualType();
5520
5521 Result = getDerived().RebuildQualifiedType(Result, T);
5522
5523 if (Result.isNull())
5524 return QualType();
5525
5526 // RebuildQualifiedType might have updated the type, but not in a way
5527 // that invalidates the TypeLoc. (There's no location information for
5528 // qualifiers.)
5530
5531 return Result;
5532}
5533
5534template <typename Derived>
5536 QualifiedTypeLoc TL) {
5537
5538 SourceLocation Loc = TL.getBeginLoc();
5539 Qualifiers Quals = TL.getType().getLocalQualifiers();
5540
5541 if ((T.getAddressSpace() != LangAS::Default &&
5542 Quals.getAddressSpace() != LangAS::Default) &&
5543 T.getAddressSpace() != Quals.getAddressSpace()) {
5544 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5545 << TL.getType() << T;
5546 return QualType();
5547 }
5548
5549 PointerAuthQualifier LocalPointerAuth = Quals.getPointerAuth();
5550 if (LocalPointerAuth.isPresent()) {
5551 if (T.getPointerAuth().isPresent()) {
5552 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_redundant) << TL.getType();
5553 return QualType();
5554 }
5555 if (!T->isDependentType()) {
5556 if (!T->isSignableType(SemaRef.getASTContext())) {
5557 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_invalid_target) << T;
5558 return QualType();
5559 }
5560 }
5561 }
5562 // C++ [dcl.fct]p7:
5563 // [When] adding cv-qualifications on top of the function type [...] the
5564 // cv-qualifiers are ignored.
5565 if (T->isFunctionType()) {
5566 T = SemaRef.getASTContext().getAddrSpaceQualType(T,
5567 Quals.getAddressSpace());
5568 return T;
5569 }
5570
5571 // C++ [dcl.ref]p1:
5572 // when the cv-qualifiers are introduced through the use of a typedef-name
5573 // or decltype-specifier [...] the cv-qualifiers are ignored.
5574 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5575 // applied to a reference type.
5576 if (T->isReferenceType()) {
5577 // The only qualifier that applies to a reference type is restrict.
5578 if (!Quals.hasRestrict())
5579 return T;
5581 }
5582
5583 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5584 // resulting type.
5585 if (Quals.hasObjCLifetime()) {
5586 if (!T->isObjCLifetimeType() && !T->isDependentType())
5587 Quals.removeObjCLifetime();
5588 else if (T.getObjCLifetime()) {
5589 // Objective-C ARC:
5590 // A lifetime qualifier applied to a substituted template parameter
5591 // overrides the lifetime qualifier from the template argument.
5592 const AutoType *AutoTy;
5593 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5594 // 'auto' types behave the same way as template parameters.
5595 QualType Deduced = AutoTy->getDeducedType();
5596 Qualifiers Qs = Deduced.getQualifiers();
5597 Qs.removeObjCLifetime();
5598 Deduced =
5599 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5600 T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
5601 AutoTy->isDependentType(),
5602 /*isPack=*/false,
5603 AutoTy->getTypeConstraintConcept(),
5604 AutoTy->getTypeConstraintArguments());
5605 } else {
5606 // Otherwise, complain about the addition of a qualifier to an
5607 // already-qualified type.
5608 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5609 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5610 Quals.removeObjCLifetime();
5611 }
5612 }
5613 }
5614
5615 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5616}
5617
5618template <typename Derived>
5619QualType TreeTransform<Derived>::TransformTypeInObjectScope(
5620 TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType,
5621 NamedDecl *FirstQualifierInScope) {
5622 assert(!getDerived().AlreadyTransformed(TL.getType()));
5623
5624 switch (TL.getTypeLocClass()) {
5625 case TypeLoc::TemplateSpecialization:
5626 return getDerived().TransformTemplateSpecializationType(
5627 TLB, TL.castAs<TemplateSpecializationTypeLoc>(), ObjectType,
5628 FirstQualifierInScope, /*AllowInjectedClassName=*/true);
5629 case TypeLoc::DependentName:
5630 return getDerived().TransformDependentNameType(
5631 TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
5632 ObjectType, FirstQualifierInScope);
5633 default:
5634 // Any dependent canonical type can appear here, through type alias
5635 // templates.
5636 return getDerived().TransformType(TLB, TL);
5637 }
5638}
5639
5640template <class TyLoc> static inline
5642 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5643 NewT.setNameLoc(T.getNameLoc());
5644 return T.getType();
5645}
5646
5647template<typename Derived>
5648QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5649 BuiltinTypeLoc T) {
5650 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5651 NewT.setBuiltinLoc(T.getBuiltinLoc());
5652 if (T.needsExtraLocalData())
5653 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5654 return T.getType();
5655}
5656
5657template<typename Derived>
5659 ComplexTypeLoc T) {
5660 // FIXME: recurse?
5661 return TransformTypeSpecType(TLB, T);
5662}
5663
5664template <typename Derived>
5666 AdjustedTypeLoc TL) {
5667 // Adjustments applied during transformation are handled elsewhere.
5668 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5669}
5670
5671template<typename Derived>
5673 DecayedTypeLoc TL) {
5674 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5675 if (OriginalType.isNull())
5676 return QualType();
5677
5678 QualType Result = TL.getType();
5679 if (getDerived().AlwaysRebuild() ||
5680 OriginalType != TL.getOriginalLoc().getType())
5681 Result = SemaRef.Context.getDecayedType(OriginalType);
5682 TLB.push<DecayedTypeLoc>(Result);
5683 // Nothing to set for DecayedTypeLoc.
5684 return Result;
5685}
5686
5687template <typename Derived>
5691 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5692 if (OriginalType.isNull())
5693 return QualType();
5694
5695 QualType Result = TL.getType();
5696 if (getDerived().AlwaysRebuild() ||
5697 OriginalType != TL.getElementLoc().getType())
5698 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5699 TLB.push<ArrayParameterTypeLoc>(Result);
5700 // Nothing to set for ArrayParameterTypeLoc.
5701 return Result;
5702}
5703
5704template<typename Derived>
5706 PointerTypeLoc TL) {
5707 QualType PointeeType
5708 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5709 if (PointeeType.isNull())
5710 return QualType();
5711
5712 QualType Result = TL.getType();
5713 if (PointeeType->getAs<ObjCObjectType>()) {
5714 // A dependent pointer type 'T *' has is being transformed such
5715 // that an Objective-C class type is being replaced for 'T'. The
5716 // resulting pointer type is an ObjCObjectPointerType, not a
5717 // PointerType.
5718 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5719
5721 NewT.setStarLoc(TL.getStarLoc());
5722 return Result;
5723 }
5724
5725 if (getDerived().AlwaysRebuild() ||
5726 PointeeType != TL.getPointeeLoc().getType()) {
5727 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5728 if (Result.isNull())
5729 return QualType();
5730 }
5731
5732 // Objective-C ARC can add lifetime qualifiers to the type that we're
5733 // pointing to.
5734 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5735
5736 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5737 NewT.setSigilLoc(TL.getSigilLoc());
5738 return Result;
5739}
5740
5741template<typename Derived>
5745 QualType PointeeType
5746 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5747 if (PointeeType.isNull())
5748 return QualType();
5749
5750 QualType Result = TL.getType();
5751 if (getDerived().AlwaysRebuild() ||
5752 PointeeType != TL.getPointeeLoc().getType()) {
5753 Result = getDerived().RebuildBlockPointerType(PointeeType,
5754 TL.getSigilLoc());
5755 if (Result.isNull())
5756 return QualType();
5757 }
5758
5760 NewT.setSigilLoc(TL.getSigilLoc());
5761 return Result;
5762}
5763
5764/// Transforms a reference type. Note that somewhat paradoxically we
5765/// don't care whether the type itself is an l-value type or an r-value
5766/// type; we only care if the type was *written* as an l-value type
5767/// or an r-value type.
5768template<typename Derived>
5771 ReferenceTypeLoc TL) {
5772 const ReferenceType *T = TL.getTypePtr();
5773
5774 // Note that this works with the pointee-as-written.
5775 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5776 if (PointeeType.isNull())
5777 return QualType();
5778
5779 QualType Result = TL.getType();
5780 if (getDerived().AlwaysRebuild() ||
5781 PointeeType != T->getPointeeTypeAsWritten()) {
5782 Result = getDerived().RebuildReferenceType(PointeeType,
5783 T->isSpelledAsLValue(),
5784 TL.getSigilLoc());
5785 if (Result.isNull())
5786 return QualType();
5787 }
5788
5789 // Objective-C ARC can add lifetime qualifiers to the type that we're
5790 // referring to.
5793
5794 // r-value references can be rebuilt as l-value references.
5795 ReferenceTypeLoc NewTL;
5797 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5798 else
5799 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5800 NewTL.setSigilLoc(TL.getSigilLoc());
5801
5802 return Result;
5803}
5804
5805template<typename Derived>
5809 return TransformReferenceType(TLB, TL);
5810}
5811
5812template<typename Derived>
5813QualType
5814TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5815 RValueReferenceTypeLoc TL) {
5816 return TransformReferenceType(TLB, TL);
5817}
5818
5819template<typename Derived>
5823 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5824 if (PointeeType.isNull())
5825 return QualType();
5826
5827 const MemberPointerType *T = TL.getTypePtr();
5828
5829 NestedNameSpecifierLoc OldQualifierLoc = TL.getQualifierLoc();
5830 NestedNameSpecifierLoc NewQualifierLoc =
5831 getDerived().TransformNestedNameSpecifierLoc(OldQualifierLoc);
5832 if (!NewQualifierLoc)
5833 return QualType();
5834
5835 CXXRecordDecl *OldCls = T->getMostRecentCXXRecordDecl(), *NewCls = nullptr;
5836 if (OldCls) {
5837 NewCls = cast_or_null<CXXRecordDecl>(
5838 getDerived().TransformDecl(TL.getStarLoc(), OldCls));
5839 if (!NewCls)
5840 return QualType();
5841 }
5842
5843 QualType Result = TL.getType();
5844 if (getDerived().AlwaysRebuild() || PointeeType != T->getPointeeType() ||
5845 NewQualifierLoc.getNestedNameSpecifier() !=
5846 OldQualifierLoc.getNestedNameSpecifier() ||
5847 NewCls != OldCls) {
5848 CXXScopeSpec SS;
5849 SS.Adopt(NewQualifierLoc);
5850 Result = getDerived().RebuildMemberPointerType(PointeeType, SS, NewCls,
5851 TL.getStarLoc());
5852 if (Result.isNull())
5853 return QualType();
5854 }
5855
5856 // If we had to adjust the pointee type when building a member pointer, make
5857 // sure to push TypeLoc info for it.
5858 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5859 if (MPT && PointeeType != MPT->getPointeeType()) {
5860 assert(isa<AdjustedType>(MPT->getPointeeType()));
5861 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5862 }
5863
5865 NewTL.setSigilLoc(TL.getSigilLoc());
5866 NewTL.setQualifierLoc(NewQualifierLoc);
5867
5868 return Result;
5869}
5870
5871template<typename Derived>
5875 const ConstantArrayType *T = TL.getTypePtr();
5876 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5877 if (ElementType.isNull())
5878 return QualType();
5879
5880 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5881 Expr *OldSize = TL.getSizeExpr();
5882 if (!OldSize)
5883 OldSize = const_cast<Expr*>(T->getSizeExpr());
5884 Expr *NewSize = nullptr;
5885 if (OldSize) {
5888 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5889 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5890 }
5891
5892 QualType Result = TL.getType();
5893 if (getDerived().AlwaysRebuild() ||
5894 ElementType != T->getElementType() ||
5895 (T->getSizeExpr() && NewSize != OldSize)) {
5896 Result = getDerived().RebuildConstantArrayType(ElementType,
5897 T->getSizeModifier(),
5898 T->getSize(), NewSize,
5899 T->getIndexTypeCVRQualifiers(),
5900 TL.getBracketsRange());
5901 if (Result.isNull())
5902 return QualType();
5903 }
5904
5905 // We might have either a ConstantArrayType or a VariableArrayType now:
5906 // a ConstantArrayType is allowed to have an element type which is a
5907 // VariableArrayType if the type is dependent. Fortunately, all array
5908 // types have the same location layout.
5909 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5910 NewTL.setLBracketLoc(TL.getLBracketLoc());
5911 NewTL.setRBracketLoc(TL.getRBracketLoc());
5912 NewTL.setSizeExpr(NewSize);
5913
5914 return Result;
5915}
5916
5917template<typename Derived>
5919 TypeLocBuilder &TLB,
5921 const IncompleteArrayType *T = TL.getTypePtr();
5922 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5923 if (ElementType.isNull())
5924 return QualType();
5925
5926 QualType Result = TL.getType();
5927 if (getDerived().AlwaysRebuild() ||
5928 ElementType != T->getElementType()) {
5929 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5930 T->getSizeModifier(),
5931 T->getIndexTypeCVRQualifiers(),
5932 TL.getBracketsRange());
5933 if (Result.isNull())
5934 return QualType();
5935 }
5936
5938 NewTL.setLBracketLoc(TL.getLBracketLoc());
5939 NewTL.setRBracketLoc(TL.getRBracketLoc());
5940 NewTL.setSizeExpr(nullptr);
5941
5942 return Result;
5943}
5944
5945template<typename Derived>
5949 const VariableArrayType *T = TL.getTypePtr();
5950 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5951 if (ElementType.isNull())
5952 return QualType();
5953
5954 ExprResult SizeResult;
5955 {
5958 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5959 }
5960 if (SizeResult.isInvalid())
5961 return QualType();
5962 SizeResult =
5963 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5964 if (SizeResult.isInvalid())
5965 return QualType();
5966
5967 Expr *Size = SizeResult.get();
5968
5969 QualType Result = TL.getType();
5970 if (getDerived().AlwaysRebuild() ||
5971 ElementType != T->getElementType() ||
5972 Size != T->getSizeExpr()) {
5973 Result = getDerived().RebuildVariableArrayType(ElementType,
5974 T->getSizeModifier(),
5975 Size,
5976 T->getIndexTypeCVRQualifiers(),
5977 TL.getBracketsRange());
5978 if (Result.isNull())
5979 return QualType();
5980 }
5981
5982 // We might have constant size array now, but fortunately it has the same
5983 // location layout.
5984 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5985 NewTL.setLBracketLoc(TL.getLBracketLoc());
5986 NewTL.setRBracketLoc(TL.getRBracketLoc());
5987 NewTL.setSizeExpr(Size);
5988
5989 return Result;
5990}
5991
5992template<typename Derived>
5996 const DependentSizedArrayType *T = TL.getTypePtr();
5997 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5998 if (ElementType.isNull())
5999 return QualType();
6000
6001 // Array bounds are constant expressions.
6004
6005 // If we have a VLA then it won't be a constant.
6006 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
6007
6008 // Prefer the expression from the TypeLoc; the other may have been uniqued.
6009 Expr *origSize = TL.getSizeExpr();
6010 if (!origSize) origSize = T->getSizeExpr();
6011
6012 ExprResult sizeResult
6013 = getDerived().TransformExpr(origSize);
6014 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
6015 if (sizeResult.isInvalid())
6016 return QualType();
6017
6018 Expr *size = sizeResult.get();
6019
6020 QualType Result = TL.getType();
6021 if (getDerived().AlwaysRebuild() ||
6022 ElementType != T->getElementType() ||
6023 size != origSize) {
6024 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
6025 T->getSizeModifier(),
6026 size,
6027 T->getIndexTypeCVRQualifiers(),
6028 TL.getBracketsRange());
6029 if (Result.isNull())
6030 return QualType();
6031 }
6032
6033 // We might have any sort of array type now, but fortunately they
6034 // all have the same location layout.
6035 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6036 NewTL.setLBracketLoc(TL.getLBracketLoc());
6037 NewTL.setRBracketLoc(TL.getRBracketLoc());
6038 NewTL.setSizeExpr(size);
6039
6040 return Result;
6041}
6042
6043template <typename Derived>
6046 const DependentVectorType *T = TL.getTypePtr();
6047 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6048 if (ElementType.isNull())
6049 return QualType();
6050
6053
6054 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6055 Size = SemaRef.ActOnConstantExpression(Size);
6056 if (Size.isInvalid())
6057 return QualType();
6058
6059 QualType Result = TL.getType();
6060 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6061 Size.get() != T->getSizeExpr()) {
6062 Result = getDerived().RebuildDependentVectorType(
6063 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
6064 if (Result.isNull())
6065 return QualType();
6066 }
6067
6068 // Result might be dependent or not.
6071 TLB.push<DependentVectorTypeLoc>(Result);
6072 NewTL.setNameLoc(TL.getNameLoc());
6073 } else {
6074 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6075 NewTL.setNameLoc(TL.getNameLoc());
6076 }
6077
6078 return Result;
6079}
6080
6081template<typename Derived>
6083 TypeLocBuilder &TLB,
6085 const DependentSizedExtVectorType *T = TL.getTypePtr();
6086
6087 // FIXME: ext vector locs should be nested
6088 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6089 if (ElementType.isNull())
6090 return QualType();
6091
6092 // Vector sizes are constant expressions.
6095
6096 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6097 Size = SemaRef.ActOnConstantExpression(Size);
6098 if (Size.isInvalid())
6099 return QualType();
6100
6101 QualType Result = TL.getType();
6102 if (getDerived().AlwaysRebuild() ||
6103 ElementType != T->getElementType() ||
6104 Size.get() != T->getSizeExpr()) {
6105 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
6106 Size.get(),
6107 T->getAttributeLoc());
6108 if (Result.isNull())
6109 return QualType();
6110 }
6111
6112 // Result might be dependent or not.
6116 NewTL.setNameLoc(TL.getNameLoc());
6117 } else {
6118 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6119 NewTL.setNameLoc(TL.getNameLoc());
6120 }
6121
6122 return Result;
6123}
6124
6125template <typename Derived>
6129 const ConstantMatrixType *T = TL.getTypePtr();
6130 QualType ElementType = getDerived().TransformType(T->getElementType());
6131 if (ElementType.isNull())
6132 return QualType();
6133
6134 QualType Result = TL.getType();
6135 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
6136 Result = getDerived().RebuildConstantMatrixType(
6137 ElementType, T->getNumRows(), T->getNumColumns());
6138 if (Result.isNull())
6139 return QualType();
6140 }
6141
6143 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6144 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6145 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
6146 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
6147
6148 return Result;
6149}
6150
6151template <typename Derived>
6154 const DependentSizedMatrixType *T = TL.getTypePtr();
6155
6156 QualType ElementType = getDerived().TransformType(T->getElementType());
6157 if (ElementType.isNull()) {
6158 return QualType();
6159 }
6160
6161 // Matrix dimensions are constant expressions.
6164
6165 Expr *origRows = TL.getAttrRowOperand();
6166 if (!origRows)
6167 origRows = T->getRowExpr();
6168 Expr *origColumns = TL.getAttrColumnOperand();
6169 if (!origColumns)
6170 origColumns = T->getColumnExpr();
6171
6172 ExprResult rowResult = getDerived().TransformExpr(origRows);
6173 rowResult = SemaRef.ActOnConstantExpression(rowResult);
6174 if (rowResult.isInvalid())
6175 return QualType();
6176
6177 ExprResult columnResult = getDerived().TransformExpr(origColumns);
6178 columnResult = SemaRef.ActOnConstantExpression(columnResult);
6179 if (columnResult.isInvalid())
6180 return QualType();
6181
6182 Expr *rows = rowResult.get();
6183 Expr *columns = columnResult.get();
6184
6185 QualType Result = TL.getType();
6186 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6187 rows != origRows || columns != origColumns) {
6188 Result = getDerived().RebuildDependentSizedMatrixType(
6189 ElementType, rows, columns, T->getAttributeLoc());
6190
6191 if (Result.isNull())
6192 return QualType();
6193 }
6194
6195 // We might have any sort of matrix type now, but fortunately they
6196 // all have the same location layout.
6197 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
6198 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6199 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6200 NewTL.setAttrRowOperand(rows);
6201 NewTL.setAttrColumnOperand(columns);
6202 return Result;
6203}
6204
6205template <typename Derived>
6208 const DependentAddressSpaceType *T = TL.getTypePtr();
6209
6210 QualType pointeeType =
6211 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
6212
6213 if (pointeeType.isNull())
6214 return QualType();
6215
6216 // Address spaces are constant expressions.
6219
6220 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
6221 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
6222 if (AddrSpace.isInvalid())
6223 return QualType();
6224
6225 QualType Result = TL.getType();
6226 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
6227 AddrSpace.get() != T->getAddrSpaceExpr()) {
6228 Result = getDerived().RebuildDependentAddressSpaceType(
6229 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6230 if (Result.isNull())
6231 return QualType();
6232 }
6233
6234 // Result might be dependent or not.
6238
6239 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6240 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6241 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6242
6243 } else {
6244 TLB.TypeWasModifiedSafely(Result);
6245 }
6246
6247 return Result;
6248}
6249
6250template <typename Derived>
6252 VectorTypeLoc TL) {
6253 const VectorType *T = TL.getTypePtr();
6254 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6255 if (ElementType.isNull())
6256 return QualType();
6257
6258 QualType Result = TL.getType();
6259 if (getDerived().AlwaysRebuild() ||
6260 ElementType != T->getElementType()) {
6261 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6262 T->getVectorKind());
6263 if (Result.isNull())
6264 return QualType();
6265 }
6266
6267 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6268 NewTL.setNameLoc(TL.getNameLoc());
6269
6270 return Result;
6271}
6272
6273template<typename Derived>
6275 ExtVectorTypeLoc TL) {
6276 const VectorType *T = TL.getTypePtr();
6277 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6278 if (ElementType.isNull())
6279 return QualType();
6280
6281 QualType Result = TL.getType();
6282 if (getDerived().AlwaysRebuild() ||
6283 ElementType != T->getElementType()) {
6284 Result = getDerived().RebuildExtVectorType(ElementType,
6285 T->getNumElements(),
6286 /*FIXME*/ SourceLocation());
6287 if (Result.isNull())
6288 return QualType();
6289 }
6290
6291 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6292 NewTL.setNameLoc(TL.getNameLoc());
6293
6294 return Result;
6295}
6296
6297template <typename Derived>
6299 ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions,
6300 bool ExpectParameterPack) {
6301 TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
6302 TypeSourceInfo *NewTSI = nullptr;
6303
6304 if (NumExpansions && isa<PackExpansionType>(OldTSI->getType())) {
6305 // If we're substituting into a pack expansion type and we know the
6306 // length we want to expand to, just substitute for the pattern.
6307 TypeLoc OldTL = OldTSI->getTypeLoc();
6308 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6309
6310 TypeLocBuilder TLB;
6311 TypeLoc NewTL = OldTSI->getTypeLoc();
6312 TLB.reserve(NewTL.getFullDataSize());
6313
6314 QualType Result = getDerived().TransformType(TLB,
6315 OldExpansionTL.getPatternLoc());
6316 if (Result.isNull())
6317 return nullptr;
6318
6320 OldExpansionTL.getPatternLoc().getSourceRange(),
6321 OldExpansionTL.getEllipsisLoc(),
6322 NumExpansions);
6323 if (Result.isNull())
6324 return nullptr;
6325
6326 PackExpansionTypeLoc NewExpansionTL
6327 = TLB.push<PackExpansionTypeLoc>(Result);
6328 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6329 NewTSI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6330 } else
6331 NewTSI = getDerived().TransformType(OldTSI);
6332 if (!NewTSI)
6333 return nullptr;
6334
6335 if (NewTSI == OldTSI && indexAdjustment == 0)
6336 return OldParm;
6337
6339 SemaRef.Context, OldParm->getDeclContext(), OldParm->getInnerLocStart(),
6340 OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
6341 NewTSI, OldParm->getStorageClass(),
6342 /* DefArg */ nullptr);
6343 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6344 OldParm->getFunctionScopeIndex() + indexAdjustment);
6345 getDerived().transformedLocalDecl(OldParm, {newParm});
6346 return newParm;
6347}
6348
6349template <typename Derived>
6352 const QualType *ParamTypes,
6353 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6354 SmallVectorImpl<QualType> &OutParamTypes,
6357 unsigned *LastParamTransformed) {
6358 int indexAdjustment = 0;
6359
6360 unsigned NumParams = Params.size();
6361 for (unsigned i = 0; i != NumParams; ++i) {
6362 if (LastParamTransformed)
6363 *LastParamTransformed = i;
6364 if (ParmVarDecl *OldParm = Params[i]) {
6365 assert(OldParm->getFunctionScopeIndex() == i);
6366
6367 UnsignedOrNone NumExpansions = std::nullopt;
6368 ParmVarDecl *NewParm = nullptr;
6369 if (OldParm->isParameterPack()) {
6370 // We have a function parameter pack that may need to be expanded.
6372
6373 // Find the parameter packs that could be expanded.
6374 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6376 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6377 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6378
6379 // Determine whether we should expand the parameter packs.
6380 bool ShouldExpand = false;
6381 bool RetainExpansion = false;
6382 UnsignedOrNone OrigNumExpansions = std::nullopt;
6383 if (Unexpanded.size() > 0) {
6384 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6385 NumExpansions = OrigNumExpansions;
6387 ExpansionTL.getEllipsisLoc(), Pattern.getSourceRange(),
6388 Unexpanded, /*FailOnPackProducingTemplates=*/true,
6389 ShouldExpand, RetainExpansion, NumExpansions)) {
6390 return true;
6391 }
6392 } else {
6393#ifndef NDEBUG
6394 const AutoType *AT =
6395 Pattern.getType().getTypePtr()->getContainedAutoType();
6396 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6397 "Could not find parameter packs or undeduced auto type!");
6398#endif
6399 }
6400
6401 if (ShouldExpand) {
6402 // Expand the function parameter pack into multiple, separate
6403 // parameters.
6404 getDerived().ExpandingFunctionParameterPack(OldParm);
6405 for (unsigned I = 0; I != *NumExpansions; ++I) {
6406 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6407 ParmVarDecl *NewParm
6408 = getDerived().TransformFunctionTypeParam(OldParm,
6409 indexAdjustment++,
6410 OrigNumExpansions,
6411 /*ExpectParameterPack=*/false);
6412 if (!NewParm)
6413 return true;
6414
6415 if (ParamInfos)
6416 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6417 OutParamTypes.push_back(NewParm->getType());
6418 if (PVars)
6419 PVars->push_back(NewParm);
6420 }
6421
6422 // If we're supposed to retain a pack expansion, do so by temporarily
6423 // forgetting the partially-substituted parameter pack.
6424 if (RetainExpansion) {
6425 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6426 ParmVarDecl *NewParm
6427 = getDerived().TransformFunctionTypeParam(OldParm,
6428 indexAdjustment++,
6429 OrigNumExpansions,
6430 /*ExpectParameterPack=*/false);
6431 if (!NewParm)
6432 return true;
6433
6434 if (ParamInfos)
6435 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6436 OutParamTypes.push_back(NewParm->getType());
6437 if (PVars)
6438 PVars->push_back(NewParm);
6439 }
6440
6441 // The next parameter should have the same adjustment as the
6442 // last thing we pushed, but we post-incremented indexAdjustment
6443 // on every push. Also, if we push nothing, the adjustment should
6444 // go down by one.
6445 indexAdjustment--;
6446
6447 // We're done with the pack expansion.
6448 continue;
6449 }
6450
6451 // We'll substitute the parameter now without expanding the pack
6452 // expansion.
6453 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6454 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6455 indexAdjustment,
6456 NumExpansions,
6457 /*ExpectParameterPack=*/true);
6458 assert(NewParm->isParameterPack() &&
6459 "Parameter pack no longer a parameter pack after "
6460 "transformation.");
6461 } else {
6462 NewParm = getDerived().TransformFunctionTypeParam(
6463 OldParm, indexAdjustment, std::nullopt,
6464 /*ExpectParameterPack=*/false);
6465 }
6466
6467 if (!NewParm)
6468 return true;
6469
6470 if (ParamInfos)
6471 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6472 OutParamTypes.push_back(NewParm->getType());
6473 if (PVars)
6474 PVars->push_back(NewParm);
6475 continue;
6476 }
6477
6478 // Deal with the possibility that we don't have a parameter
6479 // declaration for this parameter.
6480 assert(ParamTypes);
6481 QualType OldType = ParamTypes[i];
6482 bool IsPackExpansion = false;
6483 UnsignedOrNone NumExpansions = std::nullopt;
6484 QualType NewType;
6485 if (const PackExpansionType *Expansion
6486 = dyn_cast<PackExpansionType>(OldType)) {
6487 // We have a function parameter pack that may need to be expanded.
6488 QualType Pattern = Expansion->getPattern();
6490 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6491
6492 // Determine whether we should expand the parameter packs.
6493 bool ShouldExpand = false;
6494 bool RetainExpansion = false;
6496 Loc, SourceRange(), Unexpanded,
6497 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
6498 RetainExpansion, NumExpansions)) {
6499 return true;
6500 }
6501
6502 if (ShouldExpand) {
6503 // Expand the function parameter pack into multiple, separate
6504 // parameters.
6505 for (unsigned I = 0; I != *NumExpansions; ++I) {
6506 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6507 QualType NewType = getDerived().TransformType(Pattern);
6508 if (NewType.isNull())
6509 return true;
6510
6511 if (NewType->containsUnexpandedParameterPack()) {
6512 NewType = getSema().getASTContext().getPackExpansionType(
6513 NewType, std::nullopt);
6514
6515 if (NewType.isNull())
6516 return true;
6517 }
6518
6519 if (ParamInfos)
6520 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6521 OutParamTypes.push_back(NewType);
6522 if (PVars)
6523 PVars->push_back(nullptr);
6524 }
6525
6526 // We're done with the pack expansion.
6527 continue;
6528 }
6529
6530 // If we're supposed to retain a pack expansion, do so by temporarily
6531 // forgetting the partially-substituted parameter pack.
6532 if (RetainExpansion) {
6533 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6534 QualType NewType = getDerived().TransformType(Pattern);
6535 if (NewType.isNull())
6536 return true;
6537
6538 if (ParamInfos)
6539 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6540 OutParamTypes.push_back(NewType);
6541 if (PVars)
6542 PVars->push_back(nullptr);
6543 }
6544
6545 // We'll substitute the parameter now without expanding the pack
6546 // expansion.
6547 OldType = Expansion->getPattern();
6548 IsPackExpansion = true;
6549 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6550 NewType = getDerived().TransformType(OldType);
6551 } else {
6552 NewType = getDerived().TransformType(OldType);
6553 }
6554
6555 if (NewType.isNull())
6556 return true;
6557
6558 if (IsPackExpansion)
6559 NewType = getSema().Context.getPackExpansionType(NewType,
6560 NumExpansions);
6561
6562 if (ParamInfos)
6563 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6564 OutParamTypes.push_back(NewType);
6565 if (PVars)
6566 PVars->push_back(nullptr);
6567 }
6568
6569#ifndef NDEBUG
6570 if (PVars) {
6571 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6572 if (ParmVarDecl *parm = (*PVars)[i])
6573 assert(parm->getFunctionScopeIndex() == i);
6574 }
6575#endif
6576
6577 return false;
6578}
6579
6580template<typename Derived>
6584 SmallVector<QualType, 4> ExceptionStorage;
6585 return getDerived().TransformFunctionProtoType(
6586 TLB, TL, nullptr, Qualifiers(),
6587 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6588 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6589 ExceptionStorage, Changed);
6590 });
6591}
6592
6593template<typename Derived> template<typename Fn>
6595 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6596 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6597
6598 // Transform the parameters and return type.
6599 //
6600 // We are required to instantiate the params and return type in source order.
6601 // When the function has a trailing return type, we instantiate the
6602 // parameters before the return type, since the return type can then refer
6603 // to the parameters themselves (via decltype, sizeof, etc.).
6604 //
6605 SmallVector<QualType, 4> ParamTypes;
6607 Sema::ExtParameterInfoBuilder ExtParamInfos;
6608 const FunctionProtoType *T = TL.getTypePtr();
6609
6610 QualType ResultType;
6611
6612 if (T->hasTrailingReturn()) {
6614 TL.getBeginLoc(), TL.getParams(),
6616 T->getExtParameterInfosOrNull(),
6617 ParamTypes, &ParamDecls, ExtParamInfos))
6618 return QualType();
6619
6620 {
6621 // C++11 [expr.prim.general]p3:
6622 // If a declaration declares a member function or member function
6623 // template of a class X, the expression this is a prvalue of type
6624 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6625 // and the end of the function-definition, member-declarator, or
6626 // declarator.
6627 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6628 Sema::CXXThisScopeRAII ThisScope(
6629 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6630
6631 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6632 if (ResultType.isNull())
6633 return QualType();
6634 }
6635 }
6636 else {
6637 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6638 if (ResultType.isNull())
6639 return QualType();
6640
6642 TL.getBeginLoc(), TL.getParams(),
6644 T->getExtParameterInfosOrNull(),
6645 ParamTypes, &ParamDecls, ExtParamInfos))
6646 return QualType();
6647 }
6648
6649 FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
6650
6651 bool EPIChanged = false;
6652 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6653 return QualType();
6654
6655 // Handle extended parameter information.
6656 if (auto NewExtParamInfos =
6657 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6658 if (!EPI.ExtParameterInfos ||
6660 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6661 EPIChanged = true;
6662 }
6663 EPI.ExtParameterInfos = NewExtParamInfos;
6664 } else if (EPI.ExtParameterInfos) {
6665 EPIChanged = true;
6666 EPI.ExtParameterInfos = nullptr;
6667 }
6668
6669 // Transform any function effects with unevaluated conditions.
6670 // Hold this set in a local for the rest of this function, since EPI
6671 // may need to hold a FunctionEffectsRef pointing into it.
6672 std::optional<FunctionEffectSet> NewFX;
6673 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6674 NewFX.emplace();
6677
6678 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6679 FunctionEffectWithCondition NewEC = PrevEC;
6680 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6681 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6682 if (NewExpr.isInvalid())
6683 return QualType();
6684 std::optional<FunctionEffectMode> Mode =
6685 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6686 if (!Mode)
6687 return QualType();
6688
6689 // The condition expression has been transformed, and re-evaluated.
6690 // It may or may not have become constant.
6691 switch (*Mode) {
6693 NewEC.Cond = {};
6694 break;
6696 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6697 NewEC.Cond = {};
6698 break;
6700 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6701 break;
6703 llvm_unreachable(
6704 "FunctionEffectMode::None shouldn't be possible here");
6705 }
6706 }
6707 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6708 TL.getBeginLoc())) {
6710 NewFX->insert(NewEC, Errs);
6711 assert(Errs.empty());
6712 }
6713 }
6714 EPI.FunctionEffects = *NewFX;
6715 EPIChanged = true;
6716 }
6717
6718 QualType Result = TL.getType();
6719 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6720 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6721 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6722 if (Result.isNull())
6723 return QualType();
6724 }
6725
6728 NewTL.setLParenLoc(TL.getLParenLoc());
6729 NewTL.setRParenLoc(TL.getRParenLoc());
6732 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6733 NewTL.setParam(i, ParamDecls[i]);
6734
6735 return Result;
6736}
6737
6738template<typename Derived>
6741 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6742 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6743
6744 // Instantiate a dynamic noexcept expression, if any.
6745 if (isComputedNoexcept(ESI.Type)) {
6746 // Update this scrope because ContextDecl in Sema will be used in
6747 // TransformExpr.
6748 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6749 Sema::CXXThisScopeRAII ThisScope(
6750 SemaRef, Method ? Method->getParent() : nullptr,
6751 Method ? Method->getMethodQualifiers() : Qualifiers{},
6752 Method != nullptr);
6755 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6756 if (NoexceptExpr.isInvalid())
6757 return true;
6758
6760 NoexceptExpr =
6761 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6762 if (NoexceptExpr.isInvalid())
6763 return true;
6764
6765 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6766 Changed = true;
6767 ESI.NoexceptExpr = NoexceptExpr.get();
6768 ESI.Type = EST;
6769 }
6770
6771 if (ESI.Type != EST_Dynamic)
6772 return false;
6773
6774 // Instantiate a dynamic exception specification's type.
6775 for (QualType T : ESI.Exceptions) {
6776 if (const PackExpansionType *PackExpansion =
6777 T->getAs<PackExpansionType>()) {
6778 Changed = true;
6779
6780 // We have a pack expansion. Instantiate it.
6782 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6783 Unexpanded);
6784 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6785
6786 // Determine whether the set of unexpanded parameter packs can and
6787 // should
6788 // be expanded.
6789 bool Expand = false;
6790 bool RetainExpansion = false;
6791 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
6792 // FIXME: Track the location of the ellipsis (and track source location
6793 // information for the types in the exception specification in general).
6795 Loc, SourceRange(), Unexpanded,
6796 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
6797 NumExpansions))
6798 return true;
6799
6800 if (!Expand) {
6801 // We can't expand this pack expansion into separate arguments yet;
6802 // just substitute into the pattern and create a new pack expansion
6803 // type.
6804 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6805 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6806 if (U.isNull())
6807 return true;
6808
6809 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6810 Exceptions.push_back(U);
6811 continue;
6812 }
6813
6814 // Substitute into the pack expansion pattern for each slice of the
6815 // pack.
6816 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6817 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
6818
6819 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6820 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6821 return true;
6822
6823 Exceptions.push_back(U);
6824 }
6825 } else {
6826 QualType U = getDerived().TransformType(T);
6827 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6828 return true;
6829 if (T != U)
6830 Changed = true;
6831
6832 Exceptions.push_back(U);
6833 }
6834 }
6835
6836 ESI.Exceptions = Exceptions;
6837 if (ESI.Exceptions.empty())
6838 ESI.Type = EST_DynamicNone;
6839 return false;
6840}
6841
6842template<typename Derived>
6844 TypeLocBuilder &TLB,
6846 const FunctionNoProtoType *T = TL.getTypePtr();
6847 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6848 if (ResultType.isNull())
6849 return QualType();
6850
6851 QualType Result = TL.getType();
6852 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6853 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6854
6857 NewTL.setLParenLoc(TL.getLParenLoc());
6858 NewTL.setRParenLoc(TL.getRParenLoc());
6860
6861 return Result;
6862}
6863
6864template <typename Derived>
6865QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6866 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6867
6868 const UnresolvedUsingType *T = TL.getTypePtr();
6869 bool Changed = false;
6870
6871 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6872 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6873 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6874 if (!QualifierLoc)
6875 return QualType();
6876 Changed |= QualifierLoc != OldQualifierLoc;
6877 }
6878
6879 auto *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6880 if (!D)
6881 return QualType();
6882 Changed |= D != T->getDecl();
6883
6884 QualType Result = TL.getType();
6885 if (getDerived().AlwaysRebuild() || Changed) {
6886 Result = getDerived().RebuildUnresolvedUsingType(
6887 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TL.getNameLoc(),
6888 D);
6889 if (Result.isNull())
6890 return QualType();
6891 }
6892
6894 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6895 QualifierLoc, TL.getNameLoc());
6896 else
6897 TLB.push<UnresolvedUsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6898 QualifierLoc, TL.getNameLoc());
6899 return Result;
6900}
6901
6902template <typename Derived>
6904 UsingTypeLoc TL) {
6905 const UsingType *T = TL.getTypePtr();
6906 bool Changed = false;
6907
6908 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6909 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6910 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6911 if (!QualifierLoc)
6912 return QualType();
6913 Changed |= QualifierLoc != OldQualifierLoc;
6914 }
6915
6916 auto *D = cast_or_null<UsingShadowDecl>(
6917 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6918 if (!D)
6919 return QualType();
6920 Changed |= D != T->getDecl();
6921
6922 QualType UnderlyingType = getDerived().TransformType(T->desugar());
6923 if (UnderlyingType.isNull())
6924 return QualType();
6925 Changed |= UnderlyingType != T->desugar();
6926
6927 QualType Result = TL.getType();
6928 if (getDerived().AlwaysRebuild() || Changed) {
6929 Result = getDerived().RebuildUsingType(
6930 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), D,
6931 UnderlyingType);
6932 if (Result.isNull())
6933 return QualType();
6934 }
6935 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(), QualifierLoc,
6936 TL.getNameLoc());
6937 return Result;
6938}
6939
6940template<typename Derived>
6942 TypedefTypeLoc TL) {
6943 const TypedefType *T = TL.getTypePtr();
6944 bool Changed = false;
6945
6946 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6947 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6948 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6949 if (!QualifierLoc)
6950 return QualType();
6951 Changed |= QualifierLoc != OldQualifierLoc;
6952 }
6953
6954 auto *Typedef = cast_or_null<TypedefNameDecl>(
6955 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6956 if (!Typedef)
6957 return QualType();
6958 Changed |= Typedef != T->getDecl();
6959
6960 // FIXME: Transform the UnderlyingType if different from decl.
6961
6962 QualType Result = TL.getType();
6963 if (getDerived().AlwaysRebuild() || Changed) {
6964 Result = getDerived().RebuildTypedefType(
6965 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), Typedef);
6966 if (Result.isNull())
6967 return QualType();
6968 }
6969
6970 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6971 QualifierLoc, TL.getNameLoc());
6972 return Result;
6973}
6974
6975template<typename Derived>
6977 TypeOfExprTypeLoc TL) {
6978 // typeof expressions are not potentially evaluated contexts
6982
6983 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
6984 if (E.isInvalid())
6985 return QualType();
6986
6987 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
6988 if (E.isInvalid())
6989 return QualType();
6990
6991 QualType Result = TL.getType();
6993 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
6994 Result =
6995 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
6996 if (Result.isNull())
6997 return QualType();
6998 }
6999
7000 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
7001 NewTL.setTypeofLoc(TL.getTypeofLoc());
7002 NewTL.setLParenLoc(TL.getLParenLoc());
7003 NewTL.setRParenLoc(TL.getRParenLoc());
7004
7005 return Result;
7006}
7007
7008template<typename Derived>
7010 TypeOfTypeLoc TL) {
7011 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
7012 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
7013 if (!New_Under_TI)
7014 return QualType();
7015
7016 QualType Result = TL.getType();
7017 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
7018 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
7019 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
7020 if (Result.isNull())
7021 return QualType();
7022 }
7023
7024 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
7025 NewTL.setTypeofLoc(TL.getTypeofLoc());
7026 NewTL.setLParenLoc(TL.getLParenLoc());
7027 NewTL.setRParenLoc(TL.getRParenLoc());
7028 NewTL.setUnmodifiedTInfo(New_Under_TI);
7029
7030 return Result;
7031}
7032
7033template<typename Derived>
7035 DecltypeTypeLoc TL) {
7036 const DecltypeType *T = TL.getTypePtr();
7037
7038 // decltype expressions are not potentially evaluated contexts
7042
7043 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
7044 if (E.isInvalid())
7045 return QualType();
7046
7047 E = getSema().ActOnDecltypeExpression(E.get());
7048 if (E.isInvalid())
7049 return QualType();
7050
7051 QualType Result = TL.getType();
7052 if (getDerived().AlwaysRebuild() ||
7053 E.get() != T->getUnderlyingExpr()) {
7054 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
7055 if (Result.isNull())
7056 return QualType();
7057 }
7058 else E.get();
7059
7060 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
7061 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
7062 NewTL.setRParenLoc(TL.getRParenLoc());
7063 return Result;
7064}
7065
7066template <typename Derived>
7070 // Transform the index
7071 ExprResult IndexExpr;
7072 {
7073 EnterExpressionEvaluationContext ConstantContext(
7075
7076 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
7077 if (IndexExpr.isInvalid())
7078 return QualType();
7079 }
7080 QualType Pattern = TL.getPattern();
7081
7082 const PackIndexingType *PIT = TL.getTypePtr();
7083 SmallVector<QualType, 5> SubtitutedTypes;
7084 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
7085
7086 bool NotYetExpanded = Types.empty();
7087 bool FullySubstituted = true;
7088
7089 if (Types.empty() && !PIT->expandsToEmptyPack())
7090 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
7091
7092 for (QualType T : Types) {
7093 if (!T->containsUnexpandedParameterPack()) {
7094 QualType Transformed = getDerived().TransformType(T);
7095 if (Transformed.isNull())
7096 return QualType();
7097 SubtitutedTypes.push_back(Transformed);
7098 continue;
7099 }
7100
7102 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
7103 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7104 // Determine whether the set of unexpanded parameter packs can and should
7105 // be expanded.
7106 bool ShouldExpand = true;
7107 bool RetainExpansion = false;
7108 UnsignedOrNone NumExpansions = std::nullopt;
7109 if (getDerived().TryExpandParameterPacks(
7110 TL.getEllipsisLoc(), SourceRange(), Unexpanded,
7111 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
7112 RetainExpansion, NumExpansions))
7113 return QualType();
7114 if (!ShouldExpand) {
7115 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7116 // FIXME: should we keep TypeLoc for individual expansions in
7117 // PackIndexingTypeLoc?
7118 TypeSourceInfo *TI =
7119 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
7120 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
7121 if (Pack.isNull())
7122 return QualType();
7123 if (NotYetExpanded) {
7124 FullySubstituted = false;
7125 QualType Out = getDerived().RebuildPackIndexingType(
7126 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7127 FullySubstituted);
7128 if (Out.isNull())
7129 return QualType();
7130
7132 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7133 return Out;
7134 }
7135 SubtitutedTypes.push_back(Pack);
7136 continue;
7137 }
7138 for (unsigned I = 0; I != *NumExpansions; ++I) {
7139 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
7140 QualType Out = getDerived().TransformType(T);
7141 if (Out.isNull())
7142 return QualType();
7143 SubtitutedTypes.push_back(Out);
7144 FullySubstituted &= !Out->containsUnexpandedParameterPack();
7145 }
7146 // If we're supposed to retain a pack expansion, do so by temporarily
7147 // forgetting the partially-substituted parameter pack.
7148 if (RetainExpansion) {
7149 FullySubstituted = false;
7150 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
7151 QualType Out = getDerived().TransformType(T);
7152 if (Out.isNull())
7153 return QualType();
7154 SubtitutedTypes.push_back(Out);
7155 }
7156 }
7157
7158 // A pack indexing type can appear in a larger pack expansion,
7159 // e.g. `Pack...[pack_of_indexes]...`
7160 // so we need to temporarily disable substitution of pack elements
7161 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7162 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
7163
7164 QualType Out = getDerived().RebuildPackIndexingType(
7165 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7166 FullySubstituted, SubtitutedTypes);
7167 if (Out.isNull())
7168 return Out;
7169
7171 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7172 return Out;
7173}
7174
7175template<typename Derived>
7177 TypeLocBuilder &TLB,
7179 QualType Result = TL.getType();
7180 TypeSourceInfo *NewBaseTSI = TL.getUnderlyingTInfo();
7181 if (Result->isDependentType()) {
7182 const UnaryTransformType *T = TL.getTypePtr();
7183
7184 NewBaseTSI = getDerived().TransformType(TL.getUnderlyingTInfo());
7185 if (!NewBaseTSI)
7186 return QualType();
7187 QualType NewBase = NewBaseTSI->getType();
7188
7189 Result = getDerived().RebuildUnaryTransformType(NewBase,
7190 T->getUTTKind(),
7191 TL.getKWLoc());
7192 if (Result.isNull())
7193 return QualType();
7194 }
7195
7197 NewTL.setKWLoc(TL.getKWLoc());
7198 NewTL.setParensRange(TL.getParensRange());
7199 NewTL.setUnderlyingTInfo(NewBaseTSI);
7200 return Result;
7201}
7202
7203template<typename Derived>
7206 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
7207
7208 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7209 TemplateName TemplateName = getDerived().TransformTemplateName(
7210 QualifierLoc, /*TemplateKELoc=*/SourceLocation(), T->getTemplateName(),
7211 TL.getTemplateNameLoc());
7212 if (TemplateName.isNull())
7213 return QualType();
7214
7215 QualType OldDeduced = T->getDeducedType();
7216 QualType NewDeduced;
7217 if (!OldDeduced.isNull()) {
7218 NewDeduced = getDerived().TransformType(OldDeduced);
7219 if (NewDeduced.isNull())
7220 return QualType();
7221 }
7222
7223 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
7224 T->getKeyword(), TemplateName, NewDeduced);
7225 if (Result.isNull())
7226 return QualType();
7227
7228 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7229 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7230 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7231 NewTL.setQualifierLoc(QualifierLoc);
7232 return Result;
7233}
7234
7235template <typename Derived>
7237 TagTypeLoc TL) {
7238 const TagType *T = TL.getTypePtr();
7239
7240 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7241 if (QualifierLoc) {
7242 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7243 if (!QualifierLoc)
7244 return QualType();
7245 }
7246
7247 auto *TD = cast_or_null<TagDecl>(
7248 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7249 if (!TD)
7250 return QualType();
7251
7252 QualType Result = TL.getType();
7253 if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() ||
7254 TD != T->getDecl()) {
7255 if (T->isCanonicalUnqualified())
7256 Result = getDerived().RebuildCanonicalTagType(TD);
7257 else
7258 Result = getDerived().RebuildTagType(
7259 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TD);
7260 if (Result.isNull())
7261 return QualType();
7262 }
7263
7264 TagTypeLoc NewTL = TLB.push<TagTypeLoc>(Result);
7266 NewTL.setQualifierLoc(QualifierLoc);
7267 NewTL.setNameLoc(TL.getNameLoc());
7268
7269 return Result;
7270}
7271
7272template <typename Derived>
7274 EnumTypeLoc TL) {
7275 return getDerived().TransformTagType(TLB, TL);
7276}
7277
7278template <typename Derived>
7279QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
7280 RecordTypeLoc TL) {
7281 return getDerived().TransformTagType(TLB, TL);
7282}
7283
7284template<typename Derived>
7286 TypeLocBuilder &TLB,
7288 return getDerived().TransformTagType(TLB, TL);
7289}
7290
7291template<typename Derived>
7293 TypeLocBuilder &TLB,
7295 return getDerived().TransformTemplateTypeParmType(
7296 TLB, TL,
7297 /*SuppressObjCLifetime=*/false);
7298}
7299
7300template <typename Derived>
7302 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7303 return TransformTypeSpecType(TLB, TL);
7304}
7305
7306template<typename Derived>
7307QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7308 TypeLocBuilder &TLB,
7309 SubstTemplateTypeParmTypeLoc TL) {
7310 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7311
7312 Decl *NewReplaced =
7313 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7314
7315 // Substitute into the replacement type, which itself might involve something
7316 // that needs to be transformed. This only tends to occur with default
7317 // template arguments of template template parameters.
7318 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7319 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7320 if (Replacement.isNull())
7321 return QualType();
7322
7323 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7324 Replacement, NewReplaced, T->getIndex(), T->getPackIndex(),
7325 T->getFinal());
7326
7327 // Propagate type-source information.
7328 SubstTemplateTypeParmTypeLoc NewTL
7329 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7330 NewTL.setNameLoc(TL.getNameLoc());
7331 return Result;
7332
7333}
7334template <typename Derived>
7337 return TransformTypeSpecType(TLB, TL);
7338}
7339
7340template<typename Derived>
7342 TypeLocBuilder &TLB,
7344 return getDerived().TransformSubstTemplateTypeParmPackType(
7345 TLB, TL, /*SuppressObjCLifetime=*/false);
7346}
7347
7348template <typename Derived>
7351 return TransformTypeSpecType(TLB, TL);
7352}
7353
7354template<typename Derived>
7355QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
7356 AtomicTypeLoc TL) {
7357 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7358 if (ValueType.isNull())
7359 return QualType();
7360
7361 QualType Result = TL.getType();
7362 if (getDerived().AlwaysRebuild() ||
7363 ValueType != TL.getValueLoc().getType()) {
7364 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7365 if (Result.isNull())
7366 return QualType();
7367 }
7368
7369 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7370 NewTL.setKWLoc(TL.getKWLoc());
7371 NewTL.setLParenLoc(TL.getLParenLoc());
7372 NewTL.setRParenLoc(TL.getRParenLoc());
7373
7374 return Result;
7375}
7376
7377template <typename Derived>
7379 PipeTypeLoc TL) {
7380 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7381 if (ValueType.isNull())
7382 return QualType();
7383
7384 QualType Result = TL.getType();
7385 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7386 const PipeType *PT = Result->castAs<PipeType>();
7387 bool isReadPipe = PT->isReadOnly();
7388 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7389 if (Result.isNull())
7390 return QualType();
7391 }
7392
7393 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7394 NewTL.setKWLoc(TL.getKWLoc());
7395
7396 return Result;
7397}
7398
7399template <typename Derived>
7401 BitIntTypeLoc TL) {
7402 const BitIntType *EIT = TL.getTypePtr();
7403 QualType Result = TL.getType();
7404
7405 if (getDerived().AlwaysRebuild()) {
7406 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7407 EIT->getNumBits(), TL.getNameLoc());
7408 if (Result.isNull())
7409 return QualType();
7410 }
7411
7412 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7413 NewTL.setNameLoc(TL.getNameLoc());
7414 return Result;
7415}
7416
7417template <typename Derived>
7420 const DependentBitIntType *EIT = TL.getTypePtr();
7421
7424 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7425 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7426
7427 if (BitsExpr.isInvalid())
7428 return QualType();
7429
7430 QualType Result = TL.getType();
7431
7432 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7433 Result = getDerived().RebuildDependentBitIntType(
7434 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7435
7436 if (Result.isNull())
7437 return QualType();
7438 }
7439
7442 NewTL.setNameLoc(TL.getNameLoc());
7443 } else {
7444 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7445 NewTL.setNameLoc(TL.getNameLoc());
7446 }
7447 return Result;
7448}
7449
7450template <typename Derived>
7453 llvm_unreachable("This type does not need to be transformed.");
7454}
7455
7456 /// Simple iterator that traverses the template arguments in a
7457 /// container that provides a \c getArgLoc() member function.
7458 ///
7459 /// This iterator is intended to be used with the iterator form of
7460 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7461 template<typename ArgLocContainer>
7463 ArgLocContainer *Container;
7464 unsigned Index;
7465
7466 public:
7469 typedef int difference_type;
7470 typedef std::input_iterator_tag iterator_category;
7471
7472 class pointer {
7474
7475 public:
7476 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7477
7479 return &Arg;
7480 }
7481 };
7482
7483
7485
7486 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7487 unsigned Index)
7488 : Container(&Container), Index(Index) { }
7489
7491 ++Index;
7492 return *this;
7493 }
7494
7497 ++(*this);
7498 return Old;
7499 }
7500
7502 return Container->getArgLoc(Index);
7503 }
7504
7506 return pointer(Container->getArgLoc(Index));
7507 }
7508
7511 return X.Container == Y.Container && X.Index == Y.Index;
7512 }
7513
7516 return !(X == Y);
7517 }
7518 };
7519
7520template<typename Derived>
7521QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7522 AutoTypeLoc TL) {
7523 const AutoType *T = TL.getTypePtr();
7524 QualType OldDeduced = T->getDeducedType();
7525 QualType NewDeduced;
7526 if (!OldDeduced.isNull()) {
7527 NewDeduced = getDerived().TransformType(OldDeduced);
7528 if (NewDeduced.isNull())
7529 return QualType();
7530 }
7531
7532 ConceptDecl *NewCD = nullptr;
7533 TemplateArgumentListInfo NewTemplateArgs;
7534 NestedNameSpecifierLoc NewNestedNameSpec;
7535 if (T->isConstrained()) {
7536 assert(TL.getConceptReference());
7537 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7538 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7539
7540 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7541 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7543 if (getDerived().TransformTemplateArguments(
7544 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7545 NewTemplateArgs))
7546 return QualType();
7547
7548 if (TL.getNestedNameSpecifierLoc()) {
7549 NewNestedNameSpec
7550 = getDerived().TransformNestedNameSpecifierLoc(
7551 TL.getNestedNameSpecifierLoc());
7552 if (!NewNestedNameSpec)
7553 return QualType();
7554 }
7555 }
7556
7557 QualType Result = TL.getType();
7558 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7559 T->isDependentType() || T->isConstrained()) {
7560 // FIXME: Maybe don't rebuild if all template arguments are the same.
7562 NewArgList.reserve(NewTemplateArgs.size());
7563 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7564 NewArgList.push_back(ArgLoc.getArgument());
7565 Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword(), NewCD,
7566 NewArgList);
7567 if (Result.isNull())
7568 return QualType();
7569 }
7570
7571 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7572 NewTL.setNameLoc(TL.getNameLoc());
7573 NewTL.setRParenLoc(TL.getRParenLoc());
7574 NewTL.setConceptReference(nullptr);
7575
7576 if (T->isConstrained()) {
7578 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7579 TL.getConceptNameLoc(),
7580 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7581 auto *CR = ConceptReference::Create(
7582 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7583 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7584 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7585 NewTL.setConceptReference(CR);
7586 }
7587
7588 return Result;
7589}
7590
7591template <typename Derived>
7594 return getDerived().TransformTemplateSpecializationType(
7595 TLB, TL, /*ObjectType=*/QualType(), /*FirstQualifierInScope=*/nullptr,
7596 /*AllowInjectedClassName=*/false);
7597}
7598
7599template <typename Derived>
7602 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
7603 const TemplateSpecializationType *T = TL.getTypePtr();
7604
7605 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7606 TemplateName Template = getDerived().TransformTemplateName(
7607 QualifierLoc, TL.getTemplateKeywordLoc(), T->getTemplateName(),
7608 TL.getTemplateNameLoc(), ObjectType, FirstQualifierInScope,
7609 AllowInjectedClassName);
7610 if (Template.isNull())
7611 return QualType();
7612
7613 TemplateArgumentListInfo NewTemplateArgs;
7614 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7615 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7617 ArgIterator;
7618 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7619 ArgIterator(TL, TL.getNumArgs()),
7620 NewTemplateArgs))
7621 return QualType();
7622
7623 // This needs to be rebuilt if either the arguments changed, or if the
7624 // original template changed. If the template changed, and even if the
7625 // arguments didn't change, these arguments might not correspond to their
7626 // respective parameters, therefore needing conversions.
7627 QualType Result = getDerived().RebuildTemplateSpecializationType(
7628 TL.getTypePtr()->getKeyword(), Template, TL.getTemplateNameLoc(),
7629 NewTemplateArgs);
7630
7631 if (!Result.isNull()) {
7633 TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getTemplateKeywordLoc(),
7634 TL.getTemplateNameLoc(), NewTemplateArgs);
7635 }
7636
7637 return Result;
7638}
7639
7640template <typename Derived>
7642 AttributedTypeLoc TL) {
7643 const AttributedType *oldType = TL.getTypePtr();
7644 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7645 if (modifiedType.isNull())
7646 return QualType();
7647
7648 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7649 const Attr *oldAttr = TL.getAttr();
7650 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7651 if (oldAttr && !newAttr)
7652 return QualType();
7653
7654 QualType result = TL.getType();
7655
7656 // FIXME: dependent operand expressions?
7657 if (getDerived().AlwaysRebuild() ||
7658 modifiedType != oldType->getModifiedType()) {
7659 // If the equivalent type is equal to the modified type, we don't want to
7660 // transform it as well because:
7661 //
7662 // 1. The transformation would yield the same result and is therefore
7663 // superfluous, and
7664 //
7665 // 2. Transforming the same type twice can cause problems, e.g. if it
7666 // is a FunctionProtoType, we may end up instantiating the function
7667 // parameters twice, which causes an assertion since the parameters
7668 // are already bound to their counterparts in the template for this
7669 // instantiation.
7670 //
7671 QualType equivalentType = modifiedType;
7672 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7673 TypeLocBuilder AuxiliaryTLB;
7674 AuxiliaryTLB.reserve(TL.getFullDataSize());
7675 equivalentType =
7676 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7677 if (equivalentType.isNull())
7678 return QualType();
7679 }
7680
7681 // Check whether we can add nullability; it is only represented as
7682 // type sugar, and therefore cannot be diagnosed in any other way.
7683 if (auto nullability = oldType->getImmediateNullability()) {
7684 if (!modifiedType->canHaveNullability()) {
7685 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7686 : TL.getModifiedLoc().getBeginLoc()),
7687 diag::err_nullability_nonpointer)
7688 << DiagNullabilityKind(*nullability, false) << modifiedType;
7689 return QualType();
7690 }
7691 }
7692
7693 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7694 modifiedType,
7695 equivalentType,
7696 TL.getAttr());
7697 }
7698
7699 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7700 newTL.setAttr(newAttr);
7701 return result;
7702}
7703
7704template <typename Derived>
7707 const CountAttributedType *OldTy = TL.getTypePtr();
7708 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7709 if (InnerTy.isNull())
7710 return QualType();
7711
7712 Expr *OldCount = TL.getCountExpr();
7713 Expr *NewCount = nullptr;
7714 if (OldCount) {
7715 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7716 if (CountResult.isInvalid())
7717 return QualType();
7718 NewCount = CountResult.get();
7719 }
7720
7721 QualType Result = TL.getType();
7722 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7723 OldCount != NewCount) {
7724 // Currently, CountAttributedType can only wrap incomplete array types.
7726 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7727 }
7728
7729 TLB.push<CountAttributedTypeLoc>(Result);
7730 return Result;
7731}
7732
7733template <typename Derived>
7736 // The BTFTagAttributedType is available for C only.
7737 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7738}
7739
7740template <typename Derived>
7743
7744 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7745
7746 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7747 if (WrappedTy.isNull())
7748 return QualType();
7749
7750 QualType ContainedTy = QualType();
7751 QualType OldContainedTy = oldType->getContainedType();
7752 if (!OldContainedTy.isNull()) {
7753 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7754 if (!oldContainedTSI)
7755 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7756 OldContainedTy, SourceLocation());
7757 TypeSourceInfo *ContainedTSI = getDerived().TransformType(oldContainedTSI);
7758 if (!ContainedTSI)
7759 return QualType();
7760 ContainedTy = ContainedTSI->getType();
7761 }
7762
7763 QualType Result = TL.getType();
7764 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7765 ContainedTy != oldType->getContainedType()) {
7767 WrappedTy, ContainedTy, oldType->getAttrs());
7768 }
7769
7771 return Result;
7772}
7773
7774template <typename Derived>
7777 // No transformations needed.
7778 return TL.getType();
7779}
7780
7781template<typename Derived>
7784 ParenTypeLoc TL) {
7785 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7786 if (Inner.isNull())
7787 return QualType();
7788
7789 QualType Result = TL.getType();
7790 if (getDerived().AlwaysRebuild() ||
7791 Inner != TL.getInnerLoc().getType()) {
7792 Result = getDerived().RebuildParenType(Inner);
7793 if (Result.isNull())
7794 return QualType();
7795 }
7796
7797 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7798 NewTL.setLParenLoc(TL.getLParenLoc());
7799 NewTL.setRParenLoc(TL.getRParenLoc());
7800 return Result;
7801}
7802
7803template <typename Derived>
7807 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7808 if (Inner.isNull())
7809 return QualType();
7810
7811 QualType Result = TL.getType();
7812 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7813 Result =
7814 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7815 if (Result.isNull())
7816 return QualType();
7817 }
7818
7820 NewTL.setExpansionLoc(TL.getExpansionLoc());
7821 return Result;
7822}
7823
7824template<typename Derived>
7825QualType TreeTransform<Derived>::TransformDependentNameType(
7827 return TransformDependentNameType(TLB, TL, false);
7828}
7829
7830template <typename Derived>
7831QualType TreeTransform<Derived>::TransformDependentNameType(
7832 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext,
7833 QualType ObjectType, NamedDecl *UnqualLookup) {
7834 const DependentNameType *T = TL.getTypePtr();
7835
7836 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7837 if (QualifierLoc) {
7838 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
7839 QualifierLoc, ObjectType, UnqualLookup);
7840 if (!QualifierLoc)
7841 return QualType();
7842 } else {
7843 assert((ObjectType.isNull() && !UnqualLookup) &&
7844 "must be transformed by TransformNestedNameSpecifierLoc");
7845 }
7846
7848 = getDerived().RebuildDependentNameType(T->getKeyword(),
7849 TL.getElaboratedKeywordLoc(),
7850 QualifierLoc,
7851 T->getIdentifier(),
7852 TL.getNameLoc(),
7853 DeducedTSTContext);
7854 if (Result.isNull())
7855 return QualType();
7856
7857 if (isa<TagType>(Result)) {
7858 auto NewTL = TLB.push<TagTypeLoc>(Result);
7859 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7860 NewTL.setQualifierLoc(QualifierLoc);
7861 NewTL.setNameLoc(TL.getNameLoc());
7863 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7864 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7865 NewTL.setTemplateNameLoc(TL.getNameLoc());
7866 NewTL.setQualifierLoc(QualifierLoc);
7867 } else if (isa<TypedefType>(Result)) {
7868 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7869 QualifierLoc, TL.getNameLoc());
7870 } else if (isa<UnresolvedUsingType>(Result)) {
7871 auto NewTL = TLB.push<UnresolvedUsingTypeLoc>(Result);
7872 NewTL.set(TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getNameLoc());
7873 } else {
7874 auto NewTL = TLB.push<DependentNameTypeLoc>(Result);
7875 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7876 NewTL.setQualifierLoc(QualifierLoc);
7877 NewTL.setNameLoc(TL.getNameLoc());
7878 }
7879 return Result;
7880}
7881
7882template<typename Derived>
7885 QualType Pattern
7886 = getDerived().TransformType(TLB, TL.getPatternLoc());
7887 if (Pattern.isNull())
7888 return QualType();
7889
7890 QualType Result = TL.getType();
7891 if (getDerived().AlwaysRebuild() ||
7892 Pattern != TL.getPatternLoc().getType()) {
7893 Result = getDerived().RebuildPackExpansionType(Pattern,
7894 TL.getPatternLoc().getSourceRange(),
7895 TL.getEllipsisLoc(),
7896 TL.getTypePtr()->getNumExpansions());
7897 if (Result.isNull())
7898 return QualType();
7899 }
7900
7902 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7903 return Result;
7904}
7905
7906template<typename Derived>
7910 // ObjCInterfaceType is never dependent.
7911 TLB.pushFullCopy(TL);
7912 return TL.getType();
7913}
7914
7915template<typename Derived>
7919 const ObjCTypeParamType *T = TL.getTypePtr();
7920 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7921 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7922 if (!OTP)
7923 return QualType();
7924
7925 QualType Result = TL.getType();
7926 if (getDerived().AlwaysRebuild() ||
7927 OTP != T->getDecl()) {
7928 Result = getDerived().RebuildObjCTypeParamType(
7929 OTP, TL.getProtocolLAngleLoc(),
7930 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7931 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7932 if (Result.isNull())
7933 return QualType();
7934 }
7935
7937 if (TL.getNumProtocols()) {
7938 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7939 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7940 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7941 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7942 }
7943 return Result;
7944}
7945
7946template<typename Derived>
7949 ObjCObjectTypeLoc TL) {
7950 // Transform base type.
7951 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
7952 if (BaseType.isNull())
7953 return QualType();
7954
7955 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
7956
7957 // Transform type arguments.
7958 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
7959 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
7960 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
7961 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
7962 QualType TypeArg = TypeArgInfo->getType();
7963 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
7964 AnyChanged = true;
7965
7966 // We have a pack expansion. Instantiate it.
7967 const auto *PackExpansion = PackExpansionLoc.getType()
7968 ->castAs<PackExpansionType>();
7970 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
7971 Unexpanded);
7972 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7973
7974 // Determine whether the set of unexpanded parameter packs can
7975 // and should be expanded.
7976 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
7977 bool Expand = false;
7978 bool RetainExpansion = false;
7979 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
7980 if (getDerived().TryExpandParameterPacks(
7981 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
7982 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
7983 RetainExpansion, NumExpansions))
7984 return QualType();
7985
7986 if (!Expand) {
7987 // We can't expand this pack expansion into separate arguments yet;
7988 // just substitute into the pattern and create a new pack expansion
7989 // type.
7990 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7991
7992 TypeLocBuilder TypeArgBuilder;
7993 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7994 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
7995 PatternLoc);
7996 if (NewPatternType.isNull())
7997 return QualType();
7998
7999 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
8000 NewPatternType, NumExpansions);
8001 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
8002 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
8003 NewTypeArgInfos.push_back(
8004 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
8005 continue;
8006 }
8007
8008 // Substitute into the pack expansion pattern for each slice of the
8009 // pack.
8010 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
8011 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
8012
8013 TypeLocBuilder TypeArgBuilder;
8014 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8015
8016 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
8017 PatternLoc);
8018 if (NewTypeArg.isNull())
8019 return QualType();
8020
8021 NewTypeArgInfos.push_back(
8022 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8023 }
8024
8025 continue;
8026 }
8027
8028 TypeLocBuilder TypeArgBuilder;
8029 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
8030 QualType NewTypeArg =
8031 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
8032 if (NewTypeArg.isNull())
8033 return QualType();
8034
8035 // If nothing changed, just keep the old TypeSourceInfo.
8036 if (NewTypeArg == TypeArg) {
8037 NewTypeArgInfos.push_back(TypeArgInfo);
8038 continue;
8039 }
8040
8041 NewTypeArgInfos.push_back(
8042 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8043 AnyChanged = true;
8044 }
8045
8046 QualType Result = TL.getType();
8047 if (getDerived().AlwaysRebuild() || AnyChanged) {
8048 // Rebuild the type.
8049 Result = getDerived().RebuildObjCObjectType(
8050 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
8051 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
8052 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8053 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8054
8055 if (Result.isNull())
8056 return QualType();
8057 }
8058
8059 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
8060 NewT.setHasBaseTypeAsWritten(true);
8061 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
8062 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
8063 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
8064 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
8065 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8066 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8067 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
8068 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8069 return Result;
8070}
8071
8072template<typename Derived>
8076 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8077 if (PointeeType.isNull())
8078 return QualType();
8079
8080 QualType Result = TL.getType();
8081 if (getDerived().AlwaysRebuild() ||
8082 PointeeType != TL.getPointeeLoc().getType()) {
8083 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8084 TL.getStarLoc());
8085 if (Result.isNull())
8086 return QualType();
8087 }
8088
8090 NewT.setStarLoc(TL.getStarLoc());
8091 return Result;
8092}
8093
8094//===----------------------------------------------------------------------===//
8095// Statement transformation
8096//===----------------------------------------------------------------------===//
8097template<typename Derived>
8100 return S;
8101}
8102
8103template<typename Derived>
8106 return getDerived().TransformCompoundStmt(S, false);
8107}
8108
8109template<typename Derived>
8112 bool IsStmtExpr) {
8113 Sema::CompoundScopeRAII CompoundScope(getSema());
8114 Sema::FPFeaturesStateRAII FPSave(getSema());
8115 if (S->hasStoredFPFeatures())
8116 getSema().resetFPOptions(
8117 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8118
8119 bool SubStmtInvalid = false;
8120 bool SubStmtChanged = false;
8121 SmallVector<Stmt*, 8> Statements;
8122 for (auto *B : S->body()) {
8123 StmtResult Result = getDerived().TransformStmt(
8124 B, IsStmtExpr && B == S->body_back() ? StmtDiscardKind::StmtExprResult
8125 : StmtDiscardKind::Discarded);
8126
8127 if (Result.isInvalid()) {
8128 // Immediately fail if this was a DeclStmt, since it's very
8129 // likely that this will cause problems for future statements.
8130 if (isa<DeclStmt>(B))
8131 return StmtError();
8132
8133 // Otherwise, just keep processing substatements and fail later.
8134 SubStmtInvalid = true;
8135 continue;
8136 }
8137
8138 SubStmtChanged = SubStmtChanged || Result.get() != B;
8139 Statements.push_back(Result.getAs<Stmt>());
8140 }
8141
8142 if (SubStmtInvalid)
8143 return StmtError();
8144
8145 if (!getDerived().AlwaysRebuild() &&
8146 !SubStmtChanged)
8147 return S;
8148
8149 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8150 Statements,
8151 S->getRBracLoc(),
8152 IsStmtExpr);
8153}
8154
8155template<typename Derived>
8158 ExprResult LHS, RHS;
8159 {
8162
8163 // Transform the left-hand case value.
8164 LHS = getDerived().TransformExpr(S->getLHS());
8165 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8166 if (LHS.isInvalid())
8167 return StmtError();
8168
8169 // Transform the right-hand case value (for the GNU case-range extension).
8170 RHS = getDerived().TransformExpr(S->getRHS());
8171 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8172 if (RHS.isInvalid())
8173 return StmtError();
8174 }
8175
8176 // Build the case statement.
8177 // Case statements are always rebuilt so that they will attached to their
8178 // transformed switch statement.
8179 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8180 LHS.get(),
8181 S->getEllipsisLoc(),
8182 RHS.get(),
8183 S->getColonLoc());
8184 if (Case.isInvalid())
8185 return StmtError();
8186
8187 // Transform the statement following the case
8188 StmtResult SubStmt =
8189 getDerived().TransformStmt(S->getSubStmt());
8190 if (SubStmt.isInvalid())
8191 return StmtError();
8192
8193 // Attach the body to the case statement
8194 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8195}
8196
8197template <typename Derived>
8199 // Transform the statement following the default case
8200 StmtResult SubStmt =
8201 getDerived().TransformStmt(S->getSubStmt());
8202 if (SubStmt.isInvalid())
8203 return StmtError();
8204
8205 // Default statements are always rebuilt
8206 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8207 SubStmt.get());
8208}
8209
8210template<typename Derived>
8213 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8214 if (SubStmt.isInvalid())
8215 return StmtError();
8216
8217 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8218 S->getDecl());
8219 if (!LD)
8220 return StmtError();
8221
8222 // If we're transforming "in-place" (we're not creating new local
8223 // declarations), assume we're replacing the old label statement
8224 // and clear out the reference to it.
8225 if (LD == S->getDecl())
8226 S->getDecl()->setStmt(nullptr);
8227
8228 // FIXME: Pass the real colon location in.
8229 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8231 SubStmt.get());
8232}
8233
8234template <typename Derived>
8236 if (!R)
8237 return R;
8238
8239 switch (R->getKind()) {
8240// Transform attributes by calling TransformXXXAttr.
8241#define ATTR(X) \
8242 case attr::X: \
8243 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8244#include "clang/Basic/AttrList.inc"
8245 }
8246 return R;
8247}
8248
8249template <typename Derived>
8251 const Stmt *InstS,
8252 const Attr *R) {
8253 if (!R)
8254 return R;
8255
8256 switch (R->getKind()) {
8257// Transform attributes by calling TransformStmtXXXAttr.
8258#define ATTR(X) \
8259 case attr::X: \
8260 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8261#include "clang/Basic/AttrList.inc"
8262 }
8263 return TransformAttr(R);
8264}
8265
8266template <typename Derived>
8269 StmtDiscardKind SDK) {
8270 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8271 if (SubStmt.isInvalid())
8272 return StmtError();
8273
8274 bool AttrsChanged = false;
8276
8277 // Visit attributes and keep track if any are transformed.
8278 for (const auto *I : S->getAttrs()) {
8279 const Attr *R =
8280 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8281 AttrsChanged |= (I != R);
8282 if (R)
8283 Attrs.push_back(R);
8284 }
8285
8286 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8287 return S;
8288
8289 // If transforming the attributes failed for all of the attributes in the
8290 // statement, don't make an AttributedStmt without attributes.
8291 if (Attrs.empty())
8292 return SubStmt;
8293
8294 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8295 SubStmt.get());
8296}
8297
8298template<typename Derived>
8301 // Transform the initialization statement
8302 StmtResult Init = getDerived().TransformStmt(S->getInit());
8303 if (Init.isInvalid())
8304 return StmtError();
8305
8307 if (!S->isConsteval()) {
8308 // Transform the condition
8309 Cond = getDerived().TransformCondition(
8310 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8311 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8313 if (Cond.isInvalid())
8314 return StmtError();
8315 }
8316
8317 // If this is a constexpr if, determine which arm we should instantiate.
8318 std::optional<bool> ConstexprConditionValue;
8319 if (S->isConstexpr())
8320 ConstexprConditionValue = Cond.getKnownValue();
8321
8322 // Transform the "then" branch.
8323 StmtResult Then;
8324 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8328 S->isNonNegatedConsteval());
8329
8330 Then = getDerived().TransformStmt(S->getThen());
8331 if (Then.isInvalid())
8332 return StmtError();
8333 } else {
8334 // Discarded branch is replaced with empty CompoundStmt so we can keep
8335 // proper source location for start and end of original branch, so
8336 // subsequent transformations like CoverageMapping work properly
8337 Then = new (getSema().Context)
8338 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8339 }
8340
8341 // Transform the "else" branch.
8342 StmtResult Else;
8343 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8347 S->isNegatedConsteval());
8348
8349 Else = getDerived().TransformStmt(S->getElse());
8350 if (Else.isInvalid())
8351 return StmtError();
8352 } else if (S->getElse() && ConstexprConditionValue &&
8353 *ConstexprConditionValue) {
8354 // Same thing here as with <then> branch, we are discarding it, we can't
8355 // replace it with NULL nor NullStmt as we need to keep for source location
8356 // range, for CoverageMapping
8357 Else = new (getSema().Context)
8358 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8359 }
8360
8361 if (!getDerived().AlwaysRebuild() &&
8362 Init.get() == S->getInit() &&
8363 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8364 Then.get() == S->getThen() &&
8365 Else.get() == S->getElse())
8366 return S;
8367
8368 return getDerived().RebuildIfStmt(
8369 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8370 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8371}
8372
8373template<typename Derived>
8376 // Transform the initialization statement
8377 StmtResult Init = getDerived().TransformStmt(S->getInit());
8378 if (Init.isInvalid())
8379 return StmtError();
8380
8381 // Transform the condition.
8382 Sema::ConditionResult Cond = getDerived().TransformCondition(
8383 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8385 if (Cond.isInvalid())
8386 return StmtError();
8387
8388 // Rebuild the switch statement.
8390 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8391 Init.get(), Cond, S->getRParenLoc());
8392 if (Switch.isInvalid())
8393 return StmtError();
8394
8395 // Transform the body of the switch statement.
8396 StmtResult Body = getDerived().TransformStmt(S->getBody());
8397 if (Body.isInvalid())
8398 return StmtError();
8399
8400 // Complete the switch statement.
8401 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8402 Body.get());
8403}
8404
8405template<typename Derived>
8408 // Transform the condition
8409 Sema::ConditionResult Cond = getDerived().TransformCondition(
8410 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8412 if (Cond.isInvalid())
8413 return StmtError();
8414
8415 // OpenACC Restricts a while-loop inside of certain construct/clause
8416 // combinations, so diagnose that here in OpenACC mode.
8418 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8419
8420 // Transform the body
8421 StmtResult Body = getDerived().TransformStmt(S->getBody());
8422 if (Body.isInvalid())
8423 return StmtError();
8424
8425 if (!getDerived().AlwaysRebuild() &&
8426 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8427 Body.get() == S->getBody())
8428 return Owned(S);
8429
8430 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8431 Cond, S->getRParenLoc(), Body.get());
8432}
8433
8434template<typename Derived>
8437 // OpenACC Restricts a do-loop inside of certain construct/clause
8438 // combinations, so diagnose that here in OpenACC mode.
8440 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8441
8442 // Transform the body
8443 StmtResult Body = getDerived().TransformStmt(S->getBody());
8444 if (Body.isInvalid())
8445 return StmtError();
8446
8447 // Transform the condition
8448 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8449 if (Cond.isInvalid())
8450 return StmtError();
8451
8452 if (!getDerived().AlwaysRebuild() &&
8453 Cond.get() == S->getCond() &&
8454 Body.get() == S->getBody())
8455 return S;
8456
8457 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8458 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8459 S->getRParenLoc());
8460}
8461
8462template<typename Derived>
8465 if (getSema().getLangOpts().OpenMP)
8466 getSema().OpenMP().startOpenMPLoop();
8467
8468 // Transform the initialization statement
8469 StmtResult Init = getDerived().TransformStmt(S->getInit());
8470 if (Init.isInvalid())
8471 return StmtError();
8472
8473 // In OpenMP loop region loop control variable must be captured and be
8474 // private. Perform analysis of first part (if any).
8475 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8476 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8477 Init.get());
8478
8479 // Transform the condition
8480 Sema::ConditionResult Cond = getDerived().TransformCondition(
8481 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8483 if (Cond.isInvalid())
8484 return StmtError();
8485
8486 // Transform the increment
8487 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8488 if (Inc.isInvalid())
8489 return StmtError();
8490
8491 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8492 if (S->getInc() && !FullInc.get())
8493 return StmtError();
8494
8495 // OpenACC Restricts a for-loop inside of certain construct/clause
8496 // combinations, so diagnose that here in OpenACC mode.
8498 SemaRef.OpenACC().ActOnForStmtBegin(
8499 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8500 Cond.get().second, S->getInc(), Inc.get());
8501
8502 // Transform the body
8503 StmtResult Body = getDerived().TransformStmt(S->getBody());
8504 if (Body.isInvalid())
8505 return StmtError();
8506
8507 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8508
8509 if (!getDerived().AlwaysRebuild() &&
8510 Init.get() == S->getInit() &&
8511 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8512 Inc.get() == S->getInc() &&
8513 Body.get() == S->getBody())
8514 return S;
8515
8516 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8517 Init.get(), Cond, FullInc,
8518 S->getRParenLoc(), Body.get());
8519}
8520
8521template<typename Derived>
8524 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8525 S->getLabel());
8526 if (!LD)
8527 return StmtError();
8528
8529 // Goto statements must always be rebuilt, to resolve the label.
8530 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8531 cast<LabelDecl>(LD));
8532}
8533
8534template<typename Derived>
8537 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8538 if (Target.isInvalid())
8539 return StmtError();
8540 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8541
8542 if (!getDerived().AlwaysRebuild() &&
8543 Target.get() == S->getTarget())
8544 return S;
8545
8546 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8547 Target.get());
8548}
8549
8550template<typename Derived>
8553 if (!S->hasLabelTarget())
8554 return S;
8555
8556 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8557 S->getLabelDecl());
8558 if (!LD)
8559 return StmtError();
8560
8561 return new (SemaRef.Context)
8562 ContinueStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8563}
8564
8565template<typename Derived>
8568 if (!S->hasLabelTarget())
8569 return S;
8570
8571 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8572 S->getLabelDecl());
8573 if (!LD)
8574 return StmtError();
8575
8576 return new (SemaRef.Context)
8577 BreakStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8578}
8579
8580template <typename Derived>
8582 StmtResult Result = getDerived().TransformStmt(S->getBody());
8583 if (!Result.isUsable())
8584 return StmtError();
8585 return DeferStmt::Create(getSema().Context, S->getDeferLoc(), Result.get());
8586}
8587
8588template<typename Derived>
8591 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8592 /*NotCopyInit*/false);
8593 if (Result.isInvalid())
8594 return StmtError();
8595
8596 // FIXME: We always rebuild the return statement because there is no way
8597 // to tell whether the return type of the function has changed.
8598 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8599}
8600
8601template<typename Derived>
8604 bool DeclChanged = false;
8606 LambdaScopeInfo *LSI = getSema().getCurLambda();
8607 for (auto *D : S->decls()) {
8608 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8609 if (!Transformed)
8610 return StmtError();
8611
8612 if (Transformed != D)
8613 DeclChanged = true;
8614
8615 if (LSI) {
8616 if (auto *TD = dyn_cast<TypeDecl>(Transformed)) {
8617 if (auto *TN = dyn_cast<TypedefNameDecl>(TD)) {
8618 LSI->ContainsUnexpandedParameterPack |=
8619 TN->getUnderlyingType()->containsUnexpandedParameterPack();
8620 } else {
8621 LSI->ContainsUnexpandedParameterPack |=
8622 getSema()
8623 .getASTContext()
8624 .getTypeDeclType(TD)
8625 ->containsUnexpandedParameterPack();
8626 }
8627 }
8628 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8629 LSI->ContainsUnexpandedParameterPack |=
8630 VD->getType()->containsUnexpandedParameterPack();
8631 }
8632
8633 Decls.push_back(Transformed);
8634 }
8635
8636 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8637 return S;
8638
8639 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8640}
8641
8642template<typename Derived>
8645
8646 SmallVector<Expr*, 8> Constraints;
8649
8650 SmallVector<Expr*, 8> Clobbers;
8651
8652 bool ExprsChanged = false;
8653
8654 auto RebuildString = [&](Expr *E) {
8655 ExprResult Result = getDerived().TransformExpr(E);
8656 if (!Result.isUsable())
8657 return Result;
8658 if (Result.get() != E) {
8659 ExprsChanged = true;
8660 Result = SemaRef.ActOnGCCAsmStmtString(Result.get(), /*ForLabel=*/false);
8661 }
8662 return Result;
8663 };
8664
8665 // Go through the outputs.
8666 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8667 Names.push_back(S->getOutputIdentifier(I));
8668
8669 ExprResult Result = RebuildString(S->getOutputConstraintExpr(I));
8670 if (Result.isInvalid())
8671 return StmtError();
8672
8673 Constraints.push_back(Result.get());
8674
8675 // Transform the output expr.
8676 Expr *OutputExpr = S->getOutputExpr(I);
8677 Result = getDerived().TransformExpr(OutputExpr);
8678 if (Result.isInvalid())
8679 return StmtError();
8680
8681 ExprsChanged |= Result.get() != OutputExpr;
8682
8683 Exprs.push_back(Result.get());
8684 }
8685
8686 // Go through the inputs.
8687 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8688 Names.push_back(S->getInputIdentifier(I));
8689
8690 ExprResult Result = RebuildString(S->getInputConstraintExpr(I));
8691 if (Result.isInvalid())
8692 return StmtError();
8693
8694 Constraints.push_back(Result.get());
8695
8696 // Transform the input expr.
8697 Expr *InputExpr = S->getInputExpr(I);
8698 Result = getDerived().TransformExpr(InputExpr);
8699 if (Result.isInvalid())
8700 return StmtError();
8701
8702 ExprsChanged |= Result.get() != InputExpr;
8703
8704 Exprs.push_back(Result.get());
8705 }
8706
8707 // Go through the Labels.
8708 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8709 Names.push_back(S->getLabelIdentifier(I));
8710
8711 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8712 if (Result.isInvalid())
8713 return StmtError();
8714 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8715 Exprs.push_back(Result.get());
8716 }
8717
8718 // Go through the clobbers.
8719 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) {
8720 ExprResult Result = RebuildString(S->getClobberExpr(I));
8721 if (Result.isInvalid())
8722 return StmtError();
8723 Clobbers.push_back(Result.get());
8724 }
8725
8726 ExprResult AsmString = RebuildString(S->getAsmStringExpr());
8727 if (AsmString.isInvalid())
8728 return StmtError();
8729
8730 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8731 return S;
8732
8733 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8734 S->isVolatile(), S->getNumOutputs(),
8735 S->getNumInputs(), Names.data(),
8736 Constraints, Exprs, AsmString.get(),
8737 Clobbers, S->getNumLabels(),
8738 S->getRParenLoc());
8739}
8740
8741template<typename Derived>
8744 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8745
8746 bool HadError = false, HadChange = false;
8747
8748 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8749 SmallVector<Expr*, 8> TransformedExprs;
8750 TransformedExprs.reserve(SrcExprs.size());
8751 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8752 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8753 if (!Result.isUsable()) {
8754 HadError = true;
8755 } else {
8756 HadChange |= (Result.get() != SrcExprs[i]);
8757 TransformedExprs.push_back(Result.get());
8758 }
8759 }
8760
8761 if (HadError) return StmtError();
8762 if (!HadChange && !getDerived().AlwaysRebuild())
8763 return Owned(S);
8764
8765 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8766 AsmToks, S->getAsmString(),
8767 S->getNumOutputs(), S->getNumInputs(),
8768 S->getAllConstraints(), S->getClobbers(),
8769 TransformedExprs, S->getEndLoc());
8770}
8771
8772// C++ Coroutines
8773template<typename Derived>
8776 auto *ScopeInfo = SemaRef.getCurFunction();
8777 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8778 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8779 ScopeInfo->NeedsCoroutineSuspends &&
8780 ScopeInfo->CoroutineSuspends.first == nullptr &&
8781 ScopeInfo->CoroutineSuspends.second == nullptr &&
8782 "expected clean scope info");
8783
8784 // Set that we have (possibly-invalid) suspend points before we do anything
8785 // that may fail.
8786 ScopeInfo->setNeedsCoroutineSuspends(false);
8787
8788 // We re-build the coroutine promise object (and the coroutine parameters its
8789 // type and constructor depend on) based on the types used in our current
8790 // function. We must do so, and set it on the current FunctionScopeInfo,
8791 // before attempting to transform the other parts of the coroutine body
8792 // statement, such as the implicit suspend statements (because those
8793 // statements reference the FunctionScopeInfo::CoroutinePromise).
8794 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8795 return StmtError();
8796 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8797 if (!Promise)
8798 return StmtError();
8799 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8800 ScopeInfo->CoroutinePromise = Promise;
8801
8802 // Transform the implicit coroutine statements constructed using dependent
8803 // types during the previous parse: initial and final suspensions, the return
8804 // object, and others. We also transform the coroutine function's body.
8805 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8806 if (InitSuspend.isInvalid())
8807 return StmtError();
8808 StmtResult FinalSuspend =
8809 getDerived().TransformStmt(S->getFinalSuspendStmt());
8810 if (FinalSuspend.isInvalid() ||
8811 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8812 return StmtError();
8813 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8814 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8815
8816 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8817 if (BodyRes.isInvalid())
8818 return StmtError();
8819
8820 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8821 if (Builder.isInvalid())
8822 return StmtError();
8823
8824 Expr *ReturnObject = S->getReturnValueInit();
8825 assert(ReturnObject && "the return object is expected to be valid");
8826 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8827 /*NoCopyInit*/ false);
8828 if (Res.isInvalid())
8829 return StmtError();
8830 Builder.ReturnValue = Res.get();
8831
8832 // If during the previous parse the coroutine still had a dependent promise
8833 // statement, we may need to build some implicit coroutine statements
8834 // (such as exception and fallthrough handlers) for the first time.
8835 if (S->hasDependentPromiseType()) {
8836 // We can only build these statements, however, if the current promise type
8837 // is not dependent.
8838 if (!Promise->getType()->isDependentType()) {
8839 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8840 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8841 "these nodes should not have been built yet");
8842 if (!Builder.buildDependentStatements())
8843 return StmtError();
8844 }
8845 } else {
8846 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8847 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8848 if (Res.isInvalid())
8849 return StmtError();
8850 Builder.OnFallthrough = Res.get();
8851 }
8852
8853 if (auto *OnException = S->getExceptionHandler()) {
8854 StmtResult Res = getDerived().TransformStmt(OnException);
8855 if (Res.isInvalid())
8856 return StmtError();
8857 Builder.OnException = Res.get();
8858 }
8859
8860 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8861 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8862 if (Res.isInvalid())
8863 return StmtError();
8864 Builder.ReturnStmtOnAllocFailure = Res.get();
8865 }
8866
8867 // Transform any additional statements we may have already built
8868 assert(S->getAllocate() && S->getDeallocate() &&
8869 "allocation and deallocation calls must already be built");
8870 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8871 if (AllocRes.isInvalid())
8872 return StmtError();
8873 Builder.Allocate = AllocRes.get();
8874
8875 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8876 if (DeallocRes.isInvalid())
8877 return StmtError();
8878 Builder.Deallocate = DeallocRes.get();
8879
8880 if (auto *ResultDecl = S->getResultDecl()) {
8881 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8882 if (Res.isInvalid())
8883 return StmtError();
8884 Builder.ResultDecl = Res.get();
8885 }
8886
8887 if (auto *ReturnStmt = S->getReturnStmt()) {
8888 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8889 if (Res.isInvalid())
8890 return StmtError();
8891 Builder.ReturnStmt = Res.get();
8892 }
8893 }
8894
8895 return getDerived().RebuildCoroutineBodyStmt(Builder);
8896}
8897
8898template<typename Derived>
8901 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8902 /*NotCopyInit*/false);
8903 if (Result.isInvalid())
8904 return StmtError();
8905
8906 // Always rebuild; we don't know if this needs to be injected into a new
8907 // context or if the promise type has changed.
8908 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8909 S->isImplicit());
8910}
8911
8912template <typename Derived>
8914 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8915 /*NotCopyInit*/ false);
8916 if (Operand.isInvalid())
8917 return ExprError();
8918
8919 // Rebuild the common-expr from the operand rather than transforming it
8920 // separately.
8921
8922 // FIXME: getCurScope() should not be used during template instantiation.
8923 // We should pick up the set of unqualified lookup results for operator
8924 // co_await during the initial parse.
8925 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8926 getSema().getCurScope(), E->getKeywordLoc());
8927
8928 // Always rebuild; we don't know if this needs to be injected into a new
8929 // context or if the promise type has changed.
8930 return getDerived().RebuildCoawaitExpr(
8931 E->getKeywordLoc(), Operand.get(),
8932 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8933}
8934
8935template <typename Derived>
8938 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8939 /*NotCopyInit*/ false);
8940 if (OperandResult.isInvalid())
8941 return ExprError();
8942
8943 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8944 E->getOperatorCoawaitLookup());
8945
8946 if (LookupResult.isInvalid())
8947 return ExprError();
8948
8949 // Always rebuild; we don't know if this needs to be injected into a new
8950 // context or if the promise type has changed.
8951 return getDerived().RebuildDependentCoawaitExpr(
8952 E->getKeywordLoc(), OperandResult.get(),
8954}
8955
8956template<typename Derived>
8959 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
8960 /*NotCopyInit*/false);
8961 if (Result.isInvalid())
8962 return ExprError();
8963
8964 // Always rebuild; we don't know if this needs to be injected into a new
8965 // context or if the promise type has changed.
8966 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
8967}
8968
8969// Objective-C Statements.
8970
8971template<typename Derived>
8974 // Transform the body of the @try.
8975 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
8976 if (TryBody.isInvalid())
8977 return StmtError();
8978
8979 // Transform the @catch statements (if present).
8980 bool AnyCatchChanged = false;
8981 SmallVector<Stmt*, 8> CatchStmts;
8982 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
8983 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
8984 if (Catch.isInvalid())
8985 return StmtError();
8986 if (Catch.get() != S->getCatchStmt(I))
8987 AnyCatchChanged = true;
8988 CatchStmts.push_back(Catch.get());
8989 }
8990
8991 // Transform the @finally statement (if present).
8992 StmtResult Finally;
8993 if (S->getFinallyStmt()) {
8994 Finally = getDerived().TransformStmt(S->getFinallyStmt());
8995 if (Finally.isInvalid())
8996 return StmtError();
8997 }
8998
8999 // If nothing changed, just retain this statement.
9000 if (!getDerived().AlwaysRebuild() &&
9001 TryBody.get() == S->getTryBody() &&
9002 !AnyCatchChanged &&
9003 Finally.get() == S->getFinallyStmt())
9004 return S;
9005
9006 // Build a new statement.
9007 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
9008 CatchStmts, Finally.get());
9009}
9010
9011template<typename Derived>
9014 // Transform the @catch parameter, if there is one.
9015 VarDecl *Var = nullptr;
9016 if (VarDecl *FromVar = S->getCatchParamDecl()) {
9017 TypeSourceInfo *TSInfo = nullptr;
9018 if (FromVar->getTypeSourceInfo()) {
9019 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
9020 if (!TSInfo)
9021 return StmtError();
9022 }
9023
9024 QualType T;
9025 if (TSInfo)
9026 T = TSInfo->getType();
9027 else {
9028 T = getDerived().TransformType(FromVar->getType());
9029 if (T.isNull())
9030 return StmtError();
9031 }
9032
9033 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
9034 if (!Var)
9035 return StmtError();
9036 }
9037
9038 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
9039 if (Body.isInvalid())
9040 return StmtError();
9041
9042 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
9043 S->getRParenLoc(),
9044 Var, Body.get());
9045}
9046
9047template<typename Derived>
9050 // Transform the body.
9051 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
9052 if (Body.isInvalid())
9053 return StmtError();
9054
9055 // If nothing changed, just retain this statement.
9056 if (!getDerived().AlwaysRebuild() &&
9057 Body.get() == S->getFinallyBody())
9058 return S;
9059
9060 // Build a new statement.
9061 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
9062 Body.get());
9063}
9064
9065template<typename Derived>
9069 if (S->getThrowExpr()) {
9070 Operand = getDerived().TransformExpr(S->getThrowExpr());
9071 if (Operand.isInvalid())
9072 return StmtError();
9073 }
9074
9075 if (!getDerived().AlwaysRebuild() &&
9076 Operand.get() == S->getThrowExpr())
9077 return S;
9078
9079 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
9080}
9081
9082template<typename Derived>
9086 // Transform the object we are locking.
9087 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
9088 if (Object.isInvalid())
9089 return StmtError();
9090 Object =
9091 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
9092 Object.get());
9093 if (Object.isInvalid())
9094 return StmtError();
9095
9096 // Transform the body.
9097 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
9098 if (Body.isInvalid())
9099 return StmtError();
9100
9101 // If nothing change, just retain the current statement.
9102 if (!getDerived().AlwaysRebuild() &&
9103 Object.get() == S->getSynchExpr() &&
9104 Body.get() == S->getSynchBody())
9105 return S;
9106
9107 // Build a new statement.
9108 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
9109 Object.get(), Body.get());
9110}
9111
9112template<typename Derived>
9116 // Transform the body.
9117 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
9118 if (Body.isInvalid())
9119 return StmtError();
9120
9121 // If nothing changed, just retain this statement.
9122 if (!getDerived().AlwaysRebuild() &&
9123 Body.get() == S->getSubStmt())
9124 return S;
9125
9126 // Build a new statement.
9127 return getDerived().RebuildObjCAutoreleasePoolStmt(
9128 S->getAtLoc(), Body.get());
9129}
9130
9131template<typename Derived>
9135 // Transform the element statement.
9136 StmtResult Element = getDerived().TransformStmt(
9137 S->getElement(), StmtDiscardKind::NotDiscarded);
9138 if (Element.isInvalid())
9139 return StmtError();
9140
9141 // Transform the collection expression.
9142 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9143 if (Collection.isInvalid())
9144 return StmtError();
9145
9146 // Transform the body.
9147 StmtResult Body = getDerived().TransformStmt(S->getBody());
9148 if (Body.isInvalid())
9149 return StmtError();
9150
9151 // If nothing changed, just retain this statement.
9152 if (!getDerived().AlwaysRebuild() &&
9153 Element.get() == S->getElement() &&
9154 Collection.get() == S->getCollection() &&
9155 Body.get() == S->getBody())
9156 return S;
9157
9158 // Build a new statement.
9159 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9160 Element.get(),
9161 Collection.get(),
9162 S->getRParenLoc(),
9163 Body.get());
9164}
9165
9166template <typename Derived>
9168 // Transform the exception declaration, if any.
9169 VarDecl *Var = nullptr;
9170 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9171 TypeSourceInfo *T =
9172 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9173 if (!T)
9174 return StmtError();
9175
9176 Var = getDerived().RebuildExceptionDecl(
9177 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9178 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9179 if (!Var || Var->isInvalidDecl())
9180 return StmtError();
9181 }
9182
9183 // Transform the actual exception handler.
9184 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9185 if (Handler.isInvalid())
9186 return StmtError();
9187
9188 if (!getDerived().AlwaysRebuild() && !Var &&
9189 Handler.get() == S->getHandlerBlock())
9190 return S;
9191
9192 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9193}
9194
9195template <typename Derived>
9197 // Transform the try block itself.
9198 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9199 if (TryBlock.isInvalid())
9200 return StmtError();
9201
9202 // Transform the handlers.
9203 bool HandlerChanged = false;
9204 SmallVector<Stmt *, 8> Handlers;
9205 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9206 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9207 if (Handler.isInvalid())
9208 return StmtError();
9209
9210 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9211 Handlers.push_back(Handler.getAs<Stmt>());
9212 }
9213
9214 getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
9215
9216 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9217 !HandlerChanged)
9218 return S;
9219
9220 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9221 Handlers);
9222}
9223
9224template<typename Derived>
9227 EnterExpressionEvaluationContext ForRangeInitContext(
9229 /*LambdaContextDecl=*/nullptr,
9231 getSema().getLangOpts().CPlusPlus23);
9232
9233 // P2718R0 - Lifetime extension in range-based for loops.
9234 if (getSema().getLangOpts().CPlusPlus23) {
9235 auto &LastRecord = getSema().currentEvaluationContext();
9236 LastRecord.InLifetimeExtendingContext = true;
9237 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9238 }
9240 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9241 if (Init.isInvalid())
9242 return StmtError();
9243
9244 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9245 if (Range.isInvalid())
9246 return StmtError();
9247
9248 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9249 assert(getSema().getLangOpts().CPlusPlus23 ||
9250 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9251 auto ForRangeLifetimeExtendTemps =
9252 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9253
9254 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9255 if (Begin.isInvalid())
9256 return StmtError();
9257 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9258 if (End.isInvalid())
9259 return StmtError();
9260
9261 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9262 if (Cond.isInvalid())
9263 return StmtError();
9264 if (Cond.get())
9265 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9266 if (Cond.isInvalid())
9267 return StmtError();
9268 if (Cond.get())
9269 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9270
9271 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9272 if (Inc.isInvalid())
9273 return StmtError();
9274 if (Inc.get())
9275 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9276
9277 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9278 if (LoopVar.isInvalid())
9279 return StmtError();
9280
9281 StmtResult NewStmt = S;
9282 if (getDerived().AlwaysRebuild() ||
9283 Init.get() != S->getInit() ||
9284 Range.get() != S->getRangeStmt() ||
9285 Begin.get() != S->getBeginStmt() ||
9286 End.get() != S->getEndStmt() ||
9287 Cond.get() != S->getCond() ||
9288 Inc.get() != S->getInc() ||
9289 LoopVar.get() != S->getLoopVarStmt()) {
9290 NewStmt = getDerived().RebuildCXXForRangeStmt(
9291 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9292 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9293 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9294 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9295 // Might not have attached any initializer to the loop variable.
9296 getSema().ActOnInitializerError(
9297 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9298 return StmtError();
9299 }
9300 }
9301
9302 // OpenACC Restricts a while-loop inside of certain construct/clause
9303 // combinations, so diagnose that here in OpenACC mode.
9305 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9306
9307 StmtResult Body = getDerived().TransformStmt(S->getBody());
9308 if (Body.isInvalid())
9309 return StmtError();
9310
9311 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9312
9313 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9314 // it now so we have a new statement to attach the body to.
9315 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9316 NewStmt = getDerived().RebuildCXXForRangeStmt(
9317 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9318 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9319 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9320 if (NewStmt.isInvalid())
9321 return StmtError();
9322 }
9323
9324 if (NewStmt.get() == S)
9325 return S;
9326
9327 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9328}
9329
9330template<typename Derived>
9334 // Transform the nested-name-specifier, if any.
9335 NestedNameSpecifierLoc QualifierLoc;
9336 if (S->getQualifierLoc()) {
9337 QualifierLoc
9338 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9339 if (!QualifierLoc)
9340 return StmtError();
9341 }
9342
9343 // Transform the declaration name.
9344 DeclarationNameInfo NameInfo = S->getNameInfo();
9345 if (NameInfo.getName()) {
9346 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9347 if (!NameInfo.getName())
9348 return StmtError();
9349 }
9350
9351 // Check whether anything changed.
9352 if (!getDerived().AlwaysRebuild() &&
9353 QualifierLoc == S->getQualifierLoc() &&
9354 NameInfo.getName() == S->getNameInfo().getName())
9355 return S;
9356
9357 // Determine whether this name exists, if we can.
9358 CXXScopeSpec SS;
9359 SS.Adopt(QualifierLoc);
9360 bool Dependent = false;
9361 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9363 if (S->isIfExists())
9364 break;
9365
9366 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9367
9369 if (S->isIfNotExists())
9370 break;
9371
9372 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9373
9375 Dependent = true;
9376 break;
9377
9379 return StmtError();
9380 }
9381
9382 // We need to continue with the instantiation, so do so now.
9383 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9384 if (SubStmt.isInvalid())
9385 return StmtError();
9386
9387 // If we have resolved the name, just transform to the substatement.
9388 if (!Dependent)
9389 return SubStmt;
9390
9391 // The name is still dependent, so build a dependent expression again.
9392 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9393 S->isIfExists(),
9394 QualifierLoc,
9395 NameInfo,
9396 SubStmt.get());
9397}
9398
9399template<typename Derived>
9402 NestedNameSpecifierLoc QualifierLoc;
9403 if (E->getQualifierLoc()) {
9404 QualifierLoc
9405 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9406 if (!QualifierLoc)
9407 return ExprError();
9408 }
9409
9410 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9411 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9412 if (!PD)
9413 return ExprError();
9414
9415 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9416 if (Base.isInvalid())
9417 return ExprError();
9418
9419 return new (SemaRef.getASTContext())
9420 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9422 QualifierLoc, E->getMemberLoc());
9423}
9424
9425template <typename Derived>
9428 auto BaseRes = getDerived().TransformExpr(E->getBase());
9429 if (BaseRes.isInvalid())
9430 return ExprError();
9431 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9432 if (IdxRes.isInvalid())
9433 return ExprError();
9434
9435 if (!getDerived().AlwaysRebuild() &&
9436 BaseRes.get() == E->getBase() &&
9437 IdxRes.get() == E->getIdx())
9438 return E;
9439
9440 return getDerived().RebuildArraySubscriptExpr(
9441 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9442}
9443
9444template <typename Derived>
9446 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9447 if (TryBlock.isInvalid())
9448 return StmtError();
9449
9450 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9451 if (Handler.isInvalid())
9452 return StmtError();
9453
9454 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9455 Handler.get() == S->getHandler())
9456 return S;
9457
9458 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9459 TryBlock.get(), Handler.get());
9460}
9461
9462template <typename Derived>
9464 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9465 if (Block.isInvalid())
9466 return StmtError();
9467
9468 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9469}
9470
9471template <typename Derived>
9473 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9474 if (FilterExpr.isInvalid())
9475 return StmtError();
9476
9477 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9478 if (Block.isInvalid())
9479 return StmtError();
9480
9481 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9482 Block.get());
9483}
9484
9485template <typename Derived>
9487 if (isa<SEHFinallyStmt>(Handler))
9488 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9489 else
9490 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9491}
9492
9493template<typename Derived>
9496 return S;
9497}
9498
9499//===----------------------------------------------------------------------===//
9500// OpenMP directive transformation
9501//===----------------------------------------------------------------------===//
9502
9503template <typename Derived>
9504StmtResult
9505TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9506 // OMPCanonicalLoops are eliminated during transformation, since they will be
9507 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9508 // after transformation.
9509 return getDerived().TransformStmt(L->getLoopStmt());
9510}
9511
9512template <typename Derived>
9515
9516 // Transform the clauses
9518 ArrayRef<OMPClause *> Clauses = D->clauses();
9519 TClauses.reserve(Clauses.size());
9520 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9521 I != E; ++I) {
9522 if (*I) {
9523 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9524 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9525 getDerived().getSema().OpenMP().EndOpenMPClause();
9526 if (Clause)
9527 TClauses.push_back(Clause);
9528 } else {
9529 TClauses.push_back(nullptr);
9530 }
9531 }
9532 StmtResult AssociatedStmt;
9533 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9534 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9535 D->getDirectiveKind(),
9536 /*CurScope=*/nullptr);
9537 StmtResult Body;
9538 {
9539 Sema::CompoundScopeRAII CompoundScope(getSema());
9540 Stmt *CS;
9541 if (D->getDirectiveKind() == OMPD_atomic ||
9542 D->getDirectiveKind() == OMPD_critical ||
9543 D->getDirectiveKind() == OMPD_section ||
9544 D->getDirectiveKind() == OMPD_master)
9545 CS = D->getAssociatedStmt();
9546 else
9547 CS = D->getRawStmt();
9548 Body = getDerived().TransformStmt(CS);
9549 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9550 getSema().getLangOpts().OpenMPIRBuilder)
9551 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9552 }
9553 AssociatedStmt =
9554 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9555 if (AssociatedStmt.isInvalid()) {
9556 return StmtError();
9557 }
9558 }
9559 if (TClauses.size() != Clauses.size()) {
9560 return StmtError();
9561 }
9562
9563 // Transform directive name for 'omp critical' directive.
9564 DeclarationNameInfo DirName;
9565 if (D->getDirectiveKind() == OMPD_critical) {
9566 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9567 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9568 }
9569 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9570 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9571 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9572 } else if (D->getDirectiveKind() == OMPD_cancel) {
9573 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9574 }
9575
9576 return getDerived().RebuildOMPExecutableDirective(
9577 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9578 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
9579}
9580
9581/// This is mostly the same as above, but allows 'informational' class
9582/// directives when rebuilding the stmt. It still takes an
9583/// OMPExecutableDirective-type argument because we're reusing that as the
9584/// superclass for the 'assume' directive at present, instead of defining a
9585/// mostly-identical OMPInformationalDirective parent class.
9586template <typename Derived>
9589
9590 // Transform the clauses
9592 ArrayRef<OMPClause *> Clauses = D->clauses();
9593 TClauses.reserve(Clauses.size());
9594 for (OMPClause *C : Clauses) {
9595 if (C) {
9596 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
9597 OMPClause *Clause = getDerived().TransformOMPClause(C);
9598 getDerived().getSema().OpenMP().EndOpenMPClause();
9599 if (Clause)
9600 TClauses.push_back(Clause);
9601 } else {
9602 TClauses.push_back(nullptr);
9603 }
9604 }
9605 StmtResult AssociatedStmt;
9606 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9607 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9608 D->getDirectiveKind(),
9609 /*CurScope=*/nullptr);
9610 StmtResult Body;
9611 {
9612 Sema::CompoundScopeRAII CompoundScope(getSema());
9613 assert(D->getDirectiveKind() == OMPD_assume &&
9614 "Unexpected informational directive");
9615 Stmt *CS = D->getAssociatedStmt();
9616 Body = getDerived().TransformStmt(CS);
9617 }
9618 AssociatedStmt =
9619 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9620 if (AssociatedStmt.isInvalid())
9621 return StmtError();
9622 }
9623 if (TClauses.size() != Clauses.size())
9624 return StmtError();
9625
9626 DeclarationNameInfo DirName;
9627
9628 return getDerived().RebuildOMPInformationalDirective(
9629 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
9630 D->getBeginLoc(), D->getEndLoc());
9631}
9632
9633template <typename Derived>
9636 // TODO: Fix This
9637 unsigned OMPVersion = getDerived().getSema().getLangOpts().OpenMP;
9638 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9639 << getOpenMPDirectiveName(D->getDirectiveKind(), OMPVersion);
9640 return StmtError();
9641}
9642
9643template <typename Derived>
9644StmtResult
9645TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9646 DeclarationNameInfo DirName;
9647 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9648 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
9649 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9650 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9651 return Res;
9652}
9653
9654template <typename Derived>
9657 DeclarationNameInfo DirName;
9658 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9659 OMPD_simd, DirName, nullptr, D->getBeginLoc());
9660 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9661 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9662 return Res;
9663}
9664
9665template <typename Derived>
9668 DeclarationNameInfo DirName;
9669 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9670 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9671 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9672 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9673 return Res;
9674}
9675
9676template <typename Derived>
9679 DeclarationNameInfo DirName;
9680 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9681 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9682 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9683 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9684 return Res;
9685}
9686
9687template <typename Derived>
9690 DeclarationNameInfo DirName;
9691 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9692 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9693 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9694 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9695 return Res;
9696}
9697
9698template <typename Derived>
9701 DeclarationNameInfo DirName;
9702 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9703 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9704 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9705 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9706 return Res;
9707}
9708
9709template <typename Derived>
9711 OMPInterchangeDirective *D) {
9712 DeclarationNameInfo DirName;
9713 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9714 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9715 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9716 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9717 return Res;
9718}
9719
9720template <typename Derived>
9723 DeclarationNameInfo DirName;
9724 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9725 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9726 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9727 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9728 return Res;
9729}
9730
9731template <typename Derived>
9734 DeclarationNameInfo DirName;
9735 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9736 OMPD_for, DirName, nullptr, D->getBeginLoc());
9737 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9738 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9739 return Res;
9740}
9741
9742template <typename Derived>
9745 DeclarationNameInfo DirName;
9746 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9747 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
9748 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9749 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9750 return Res;
9751}
9752
9753template <typename Derived>
9756 DeclarationNameInfo DirName;
9757 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9758 OMPD_sections, DirName, nullptr, D->getBeginLoc());
9759 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9760 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9761 return Res;
9762}
9763
9764template <typename Derived>
9767 DeclarationNameInfo DirName;
9768 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9769 OMPD_section, DirName, nullptr, D->getBeginLoc());
9770 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9771 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9772 return Res;
9773}
9774
9775template <typename Derived>
9778 DeclarationNameInfo DirName;
9779 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9780 OMPD_scope, DirName, nullptr, D->getBeginLoc());
9781 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9782 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9783 return Res;
9784}
9785
9786template <typename Derived>
9789 DeclarationNameInfo DirName;
9790 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9791 OMPD_single, DirName, nullptr, D->getBeginLoc());
9792 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9793 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9794 return Res;
9795}
9796
9797template <typename Derived>
9800 DeclarationNameInfo DirName;
9801 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9802 OMPD_master, DirName, nullptr, D->getBeginLoc());
9803 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9804 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9805 return Res;
9806}
9807
9808template <typename Derived>
9811 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9812 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
9813 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9814 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9815 return Res;
9816}
9817
9818template <typename Derived>
9820 OMPParallelForDirective *D) {
9821 DeclarationNameInfo DirName;
9822 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9823 OMPD_parallel_for, DirName, nullptr, D->getBeginLoc());
9824 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9825 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9826 return Res;
9827}
9828
9829template <typename Derived>
9831 OMPParallelForSimdDirective *D) {
9832 DeclarationNameInfo DirName;
9833 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9834 OMPD_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9835 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9836 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9837 return Res;
9838}
9839
9840template <typename Derived>
9842 OMPParallelMasterDirective *D) {
9843 DeclarationNameInfo DirName;
9844 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9845 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
9846 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9847 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9848 return Res;
9849}
9850
9851template <typename Derived>
9853 OMPParallelMaskedDirective *D) {
9854 DeclarationNameInfo DirName;
9855 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9856 OMPD_parallel_masked, DirName, nullptr, D->getBeginLoc());
9857 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9858 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9859 return Res;
9860}
9861
9862template <typename Derived>
9864 OMPParallelSectionsDirective *D) {
9865 DeclarationNameInfo DirName;
9866 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9867 OMPD_parallel_sections, DirName, nullptr, D->getBeginLoc());
9868 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9869 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9870 return Res;
9871}
9872
9873template <typename Derived>
9876 DeclarationNameInfo DirName;
9877 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9878 OMPD_task, DirName, nullptr, D->getBeginLoc());
9879 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9880 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9881 return Res;
9882}
9883
9884template <typename Derived>
9886 OMPTaskyieldDirective *D) {
9887 DeclarationNameInfo DirName;
9888 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9889 OMPD_taskyield, DirName, nullptr, D->getBeginLoc());
9890 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9891 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9892 return Res;
9893}
9894
9895template <typename Derived>
9898 DeclarationNameInfo DirName;
9899 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9900 OMPD_barrier, DirName, nullptr, D->getBeginLoc());
9901 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9902 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9903 return Res;
9904}
9905
9906template <typename Derived>
9909 DeclarationNameInfo DirName;
9910 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9911 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
9912 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9913 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9914 return Res;
9915}
9916
9917template <typename Derived>
9920 DeclarationNameInfo DirName;
9921 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9922 OMPD_assume, DirName, nullptr, D->getBeginLoc());
9923 StmtResult Res = getDerived().TransformOMPInformationalDirective(D);
9924 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9925 return Res;
9926}
9927
9928template <typename Derived>
9931 DeclarationNameInfo DirName;
9932 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9933 OMPD_error, DirName, nullptr, D->getBeginLoc());
9934 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9935 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9936 return Res;
9937}
9938
9939template <typename Derived>
9941 OMPTaskgroupDirective *D) {
9942 DeclarationNameInfo DirName;
9943 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9944 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
9945 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9946 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9947 return Res;
9948}
9949
9950template <typename Derived>
9953 DeclarationNameInfo DirName;
9954 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9955 OMPD_flush, DirName, nullptr, D->getBeginLoc());
9956 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9957 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9958 return Res;
9959}
9960
9961template <typename Derived>
9964 DeclarationNameInfo DirName;
9965 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9966 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
9967 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9968 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9969 return Res;
9970}
9971
9972template <typename Derived>
9975 DeclarationNameInfo DirName;
9976 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9977 OMPD_scan, DirName, nullptr, D->getBeginLoc());
9978 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9979 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9980 return Res;
9981}
9982
9983template <typename Derived>
9986 DeclarationNameInfo DirName;
9987 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9988 OMPD_ordered, DirName, nullptr, D->getBeginLoc());
9989 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9990 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9991 return Res;
9992}
9993
9994template <typename Derived>
9997 DeclarationNameInfo DirName;
9998 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9999 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
10000 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10001 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10002 return Res;
10003}
10004
10005template <typename Derived>
10008 DeclarationNameInfo DirName;
10009 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10010 OMPD_target, DirName, nullptr, D->getBeginLoc());
10011 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10012 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10013 return Res;
10014}
10015
10016template <typename Derived>
10018 OMPTargetDataDirective *D) {
10019 DeclarationNameInfo DirName;
10020 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10021 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
10022 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10023 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10024 return Res;
10025}
10026
10027template <typename Derived>
10029 OMPTargetEnterDataDirective *D) {
10030 DeclarationNameInfo DirName;
10031 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10032 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
10033 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10034 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10035 return Res;
10036}
10037
10038template <typename Derived>
10040 OMPTargetExitDataDirective *D) {
10041 DeclarationNameInfo DirName;
10042 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10043 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
10044 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10045 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10046 return Res;
10047}
10048
10049template <typename Derived>
10051 OMPTargetParallelDirective *D) {
10052 DeclarationNameInfo DirName;
10053 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10054 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
10055 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10056 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10057 return Res;
10058}
10059
10060template <typename Derived>
10062 OMPTargetParallelForDirective *D) {
10063 DeclarationNameInfo DirName;
10064 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10065 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
10066 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10067 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10068 return Res;
10069}
10070
10071template <typename Derived>
10073 OMPTargetUpdateDirective *D) {
10074 DeclarationNameInfo DirName;
10075 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10076 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
10077 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10078 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10079 return Res;
10080}
10081
10082template <typename Derived>
10085 DeclarationNameInfo DirName;
10086 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10087 OMPD_teams, DirName, nullptr, D->getBeginLoc());
10088 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10089 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10090 return Res;
10091}
10092
10093template <typename Derived>
10095 OMPCancellationPointDirective *D) {
10096 DeclarationNameInfo DirName;
10097 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10098 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
10099 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10100 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10101 return Res;
10102}
10103
10104template <typename Derived>
10107 DeclarationNameInfo DirName;
10108 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10109 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
10110 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10111 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10112 return Res;
10113}
10114
10115template <typename Derived>
10118 DeclarationNameInfo DirName;
10119 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10120 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
10121 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10122 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10123 return Res;
10124}
10125
10126template <typename Derived>
10128 OMPTaskLoopSimdDirective *D) {
10129 DeclarationNameInfo DirName;
10130 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10131 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10132 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10133 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10134 return Res;
10135}
10136
10137template <typename Derived>
10139 OMPMasterTaskLoopDirective *D) {
10140 DeclarationNameInfo DirName;
10141 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10142 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
10143 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10144 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10145 return Res;
10146}
10147
10148template <typename Derived>
10150 OMPMaskedTaskLoopDirective *D) {
10151 DeclarationNameInfo DirName;
10152 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10153 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10154 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10155 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10156 return Res;
10157}
10158
10159template <typename Derived>
10161 OMPMasterTaskLoopSimdDirective *D) {
10162 DeclarationNameInfo DirName;
10163 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10164 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10165 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10166 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10167 return Res;
10168}
10169
10170template <typename Derived>
10172 OMPMaskedTaskLoopSimdDirective *D) {
10173 DeclarationNameInfo DirName;
10174 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10175 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10176 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10177 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10178 return Res;
10179}
10180
10181template <typename Derived>
10183 OMPParallelMasterTaskLoopDirective *D) {
10184 DeclarationNameInfo DirName;
10185 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10186 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10187 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10188 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10189 return Res;
10190}
10191
10192template <typename Derived>
10194 OMPParallelMaskedTaskLoopDirective *D) {
10195 DeclarationNameInfo DirName;
10196 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10197 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10198 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10199 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10200 return Res;
10201}
10202
10203template <typename Derived>
10206 OMPParallelMasterTaskLoopSimdDirective *D) {
10207 DeclarationNameInfo DirName;
10208 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10209 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10210 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10211 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10212 return Res;
10213}
10214
10215template <typename Derived>
10218 OMPParallelMaskedTaskLoopSimdDirective *D) {
10219 DeclarationNameInfo DirName;
10220 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10221 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10222 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10223 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10224 return Res;
10225}
10226
10227template <typename Derived>
10229 OMPDistributeDirective *D) {
10230 DeclarationNameInfo DirName;
10231 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10232 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10233 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10234 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10235 return Res;
10236}
10237
10238template <typename Derived>
10240 OMPDistributeParallelForDirective *D) {
10241 DeclarationNameInfo DirName;
10242 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10243 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10244 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10245 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10246 return Res;
10247}
10248
10249template <typename Derived>
10252 OMPDistributeParallelForSimdDirective *D) {
10253 DeclarationNameInfo DirName;
10254 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10255 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10256 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10257 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10258 return Res;
10259}
10260
10261template <typename Derived>
10263 OMPDistributeSimdDirective *D) {
10264 DeclarationNameInfo DirName;
10265 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10266 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
10267 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10268 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10269 return Res;
10270}
10271
10272template <typename Derived>
10274 OMPTargetParallelForSimdDirective *D) {
10275 DeclarationNameInfo DirName;
10276 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10277 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10278 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10279 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10280 return Res;
10281}
10282
10283template <typename Derived>
10285 OMPTargetSimdDirective *D) {
10286 DeclarationNameInfo DirName;
10287 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10288 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
10289 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10290 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10291 return Res;
10292}
10293
10294template <typename Derived>
10296 OMPTeamsDistributeDirective *D) {
10297 DeclarationNameInfo DirName;
10298 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10299 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10300 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10301 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10302 return Res;
10303}
10304
10305template <typename Derived>
10307 OMPTeamsDistributeSimdDirective *D) {
10308 DeclarationNameInfo DirName;
10309 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10310 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10311 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10312 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10313 return Res;
10314}
10315
10316template <typename Derived>
10318 OMPTeamsDistributeParallelForSimdDirective *D) {
10319 DeclarationNameInfo DirName;
10320 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10321 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10322 D->getBeginLoc());
10323 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10324 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10325 return Res;
10326}
10327
10328template <typename Derived>
10330 OMPTeamsDistributeParallelForDirective *D) {
10331 DeclarationNameInfo DirName;
10332 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10333 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10334 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10335 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10336 return Res;
10337}
10338
10339template <typename Derived>
10341 OMPTargetTeamsDirective *D) {
10342 DeclarationNameInfo DirName;
10343 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10344 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10345 auto Res = getDerived().TransformOMPExecutableDirective(D);
10346 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10347 return Res;
10348}
10349
10350template <typename Derived>
10352 OMPTargetTeamsDistributeDirective *D) {
10353 DeclarationNameInfo DirName;
10354 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10355 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10356 auto Res = getDerived().TransformOMPExecutableDirective(D);
10357 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10358 return Res;
10359}
10360
10361template <typename Derived>
10364 OMPTargetTeamsDistributeParallelForDirective *D) {
10365 DeclarationNameInfo DirName;
10366 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10367 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10368 D->getBeginLoc());
10369 auto Res = getDerived().TransformOMPExecutableDirective(D);
10370 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10371 return Res;
10372}
10373
10374template <typename Derived>
10377 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10378 DeclarationNameInfo DirName;
10379 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10380 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10381 D->getBeginLoc());
10382 auto Res = getDerived().TransformOMPExecutableDirective(D);
10383 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10384 return Res;
10385}
10386
10387template <typename Derived>
10390 OMPTargetTeamsDistributeSimdDirective *D) {
10391 DeclarationNameInfo DirName;
10392 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10393 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10394 auto Res = getDerived().TransformOMPExecutableDirective(D);
10395 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10396 return Res;
10397}
10398
10399template <typename Derived>
10402 DeclarationNameInfo DirName;
10403 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10404 OMPD_interop, DirName, nullptr, D->getBeginLoc());
10405 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10406 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10407 return Res;
10408}
10409
10410template <typename Derived>
10413 DeclarationNameInfo DirName;
10414 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10415 OMPD_dispatch, DirName, nullptr, D->getBeginLoc());
10416 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10417 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10418 return Res;
10419}
10420
10421template <typename Derived>
10424 DeclarationNameInfo DirName;
10425 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10426 OMPD_masked, DirName, nullptr, D->getBeginLoc());
10427 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10428 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10429 return Res;
10430}
10431
10432template <typename Derived>
10434 OMPGenericLoopDirective *D) {
10435 DeclarationNameInfo DirName;
10436 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10437 OMPD_loop, DirName, nullptr, D->getBeginLoc());
10438 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10439 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10440 return Res;
10441}
10442
10443template <typename Derived>
10445 OMPTeamsGenericLoopDirective *D) {
10446 DeclarationNameInfo DirName;
10447 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10448 OMPD_teams_loop, DirName, nullptr, D->getBeginLoc());
10449 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10450 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10451 return Res;
10452}
10453
10454template <typename Derived>
10456 OMPTargetTeamsGenericLoopDirective *D) {
10457 DeclarationNameInfo DirName;
10458 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10459 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
10460 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10461 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10462 return Res;
10463}
10464
10465template <typename Derived>
10467 OMPParallelGenericLoopDirective *D) {
10468 DeclarationNameInfo DirName;
10469 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10470 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
10471 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10472 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10473 return Res;
10474}
10475
10476template <typename Derived>
10479 OMPTargetParallelGenericLoopDirective *D) {
10480 DeclarationNameInfo DirName;
10481 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10482 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10483 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10484 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10485 return Res;
10486}
10487
10488//===----------------------------------------------------------------------===//
10489// OpenMP clause transformation
10490//===----------------------------------------------------------------------===//
10491template <typename Derived>
10493 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10494 if (Cond.isInvalid())
10495 return nullptr;
10496 return getDerived().RebuildOMPIfClause(
10497 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10498 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10499}
10500
10501template <typename Derived>
10503 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10504 if (Cond.isInvalid())
10505 return nullptr;
10506 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10507 C->getLParenLoc(), C->getEndLoc());
10508}
10509
10510template <typename Derived>
10511OMPClause *
10513 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
10514 if (NumThreads.isInvalid())
10515 return nullptr;
10516 return getDerived().RebuildOMPNumThreadsClause(
10517 C->getModifier(), NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(),
10518 C->getModifierLoc(), C->getEndLoc());
10519}
10520
10521template <typename Derived>
10522OMPClause *
10524 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10525 if (E.isInvalid())
10526 return nullptr;
10527 return getDerived().RebuildOMPSafelenClause(
10528 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10529}
10530
10531template <typename Derived>
10532OMPClause *
10534 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10535 if (E.isInvalid())
10536 return nullptr;
10537 return getDerived().RebuildOMPAllocatorClause(
10538 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10539}
10540
10541template <typename Derived>
10542OMPClause *
10544 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
10545 if (E.isInvalid())
10546 return nullptr;
10547 return getDerived().RebuildOMPSimdlenClause(
10548 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10549}
10550
10551template <typename Derived>
10553 SmallVector<Expr *, 4> TransformedSizes;
10554 TransformedSizes.reserve(C->getNumSizes());
10555 bool Changed = false;
10556 for (Expr *E : C->getSizesRefs()) {
10557 if (!E) {
10558 TransformedSizes.push_back(nullptr);
10559 continue;
10560 }
10561
10562 ExprResult T = getDerived().TransformExpr(E);
10563 if (T.isInvalid())
10564 return nullptr;
10565 if (E != T.get())
10566 Changed = true;
10567 TransformedSizes.push_back(T.get());
10568 }
10569
10570 if (!Changed && !getDerived().AlwaysRebuild())
10571 return C;
10572 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
10573 C->getLParenLoc(), C->getEndLoc());
10574}
10575
10576template <typename Derived>
10577OMPClause *
10579 SmallVector<Expr *> TransformedArgs;
10580 TransformedArgs.reserve(C->getNumLoops());
10581 bool Changed = false;
10582 for (Expr *E : C->getArgsRefs()) {
10583 if (!E) {
10584 TransformedArgs.push_back(nullptr);
10585 continue;
10586 }
10587
10588 ExprResult T = getDerived().TransformExpr(E);
10589 if (T.isInvalid())
10590 return nullptr;
10591 if (E != T.get())
10592 Changed = true;
10593 TransformedArgs.push_back(T.get());
10594 }
10595
10596 if (!Changed && !getDerived().AlwaysRebuild())
10597 return C;
10598 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
10599 C->getLParenLoc(), C->getEndLoc());
10600}
10601
10602template <typename Derived>
10604 if (!getDerived().AlwaysRebuild())
10605 return C;
10606 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10607}
10608
10609template <typename Derived>
10610OMPClause *
10612 ExprResult T = getDerived().TransformExpr(C->getFactor());
10613 if (T.isInvalid())
10614 return nullptr;
10615 Expr *Factor = T.get();
10616 bool Changed = Factor != C->getFactor();
10617
10618 if (!Changed && !getDerived().AlwaysRebuild())
10619 return C;
10620 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10621 C->getEndLoc());
10622}
10623
10624template <typename Derived>
10625OMPClause *
10627 ExprResult F = getDerived().TransformExpr(C->getFirst());
10628 if (F.isInvalid())
10629 return nullptr;
10630
10631 ExprResult Cn = getDerived().TransformExpr(C->getCount());
10632 if (Cn.isInvalid())
10633 return nullptr;
10634
10635 Expr *First = F.get();
10636 Expr *Count = Cn.get();
10637
10638 bool Changed = (First != C->getFirst()) || (Count != C->getCount());
10639
10640 // If no changes and AlwaysRebuild() is false, return the original clause
10641 if (!Changed && !getDerived().AlwaysRebuild())
10642 return C;
10643
10644 return RebuildOMPLoopRangeClause(First, Count, C->getBeginLoc(),
10645 C->getLParenLoc(), C->getFirstLoc(),
10646 C->getCountLoc(), C->getEndLoc());
10647}
10648
10649template <typename Derived>
10650OMPClause *
10652 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10653 if (E.isInvalid())
10654 return nullptr;
10655 return getDerived().RebuildOMPCollapseClause(
10656 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10657}
10658
10659template <typename Derived>
10660OMPClause *
10662 return getDerived().RebuildOMPDefaultClause(
10663 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getDefaultVC(),
10664 C->getDefaultVCLoc(), C->getBeginLoc(), C->getLParenLoc(),
10665 C->getEndLoc());
10666}
10667
10668template <typename Derived>
10669OMPClause *
10671 // No need to rebuild this clause, no template-dependent parameters.
10672 return C;
10673}
10674
10675template <typename Derived>
10676OMPClause *
10678 return getDerived().RebuildOMPProcBindClause(
10679 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10680 C->getLParenLoc(), C->getEndLoc());
10681}
10682
10683template <typename Derived>
10684OMPClause *
10686 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10687 if (E.isInvalid())
10688 return nullptr;
10689 return getDerived().RebuildOMPScheduleClause(
10690 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10691 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10692 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10693 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10694}
10695
10696template <typename Derived>
10697OMPClause *
10699 ExprResult E;
10700 if (auto *Num = C->getNumForLoops()) {
10701 E = getDerived().TransformExpr(Num);
10702 if (E.isInvalid())
10703 return nullptr;
10704 }
10705 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10706 C->getLParenLoc(), E.get());
10707}
10708
10709template <typename Derived>
10710OMPClause *
10712 ExprResult E;
10713 if (Expr *Evt = C->getEventHandler()) {
10714 E = getDerived().TransformExpr(Evt);
10715 if (E.isInvalid())
10716 return nullptr;
10717 }
10718 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10719 C->getLParenLoc(), C->getEndLoc());
10720}
10721
10722template <typename Derived>
10723OMPClause *
10726 if (auto *Condition = C->getCondition()) {
10727 Cond = getDerived().TransformExpr(Condition);
10728 if (Cond.isInvalid())
10729 return nullptr;
10730 }
10731 return getDerived().RebuildOMPNowaitClause(Cond.get(), C->getBeginLoc(),
10732 C->getLParenLoc(), C->getEndLoc());
10733}
10734
10735template <typename Derived>
10736OMPClause *
10738 // No need to rebuild this clause, no template-dependent parameters.
10739 return C;
10740}
10741
10742template <typename Derived>
10743OMPClause *
10745 // No need to rebuild this clause, no template-dependent parameters.
10746 return C;
10747}
10748
10749template <typename Derived>
10751 // No need to rebuild this clause, no template-dependent parameters.
10752 return C;
10753}
10754
10755template <typename Derived>
10757 // No need to rebuild this clause, no template-dependent parameters.
10758 return C;
10759}
10760
10761template <typename Derived>
10762OMPClause *
10764 // No need to rebuild this clause, no template-dependent parameters.
10765 return C;
10766}
10767
10768template <typename Derived>
10769OMPClause *
10771 // No need to rebuild this clause, no template-dependent parameters.
10772 return C;
10773}
10774
10775template <typename Derived>
10776OMPClause *
10778 // No need to rebuild this clause, no template-dependent parameters.
10779 return C;
10780}
10781
10782template <typename Derived>
10784 // No need to rebuild this clause, no template-dependent parameters.
10785 return C;
10786}
10787
10788template <typename Derived>
10789OMPClause *
10791 return C;
10792}
10793
10794template <typename Derived>
10796 ExprResult E = getDerived().TransformExpr(C->getExpr());
10797 if (E.isInvalid())
10798 return nullptr;
10799 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
10800 C->getLParenLoc(), C->getEndLoc());
10801}
10802
10803template <typename Derived>
10804OMPClause *
10806 return C;
10807}
10808
10809template <typename Derived>
10810OMPClause *
10812 return C;
10813}
10814template <typename Derived>
10817 return C;
10818}
10819template <typename Derived>
10822 return C;
10823}
10824template <typename Derived>
10827 return C;
10828}
10829
10830template <typename Derived>
10831OMPClause *
10833 // No need to rebuild this clause, no template-dependent parameters.
10834 return C;
10835}
10836
10837template <typename Derived>
10838OMPClause *
10840 // No need to rebuild this clause, no template-dependent parameters.
10841 return C;
10842}
10843
10844template <typename Derived>
10845OMPClause *
10847 // No need to rebuild this clause, no template-dependent parameters.
10848 return C;
10849}
10850
10851template <typename Derived>
10852OMPClause *
10854 // No need to rebuild this clause, no template-dependent parameters.
10855 return C;
10856}
10857
10858template <typename Derived>
10859OMPClause *
10861 // No need to rebuild this clause, no template-dependent parameters.
10862 return C;
10863}
10864
10865template <typename Derived>
10867 // No need to rebuild this clause, no template-dependent parameters.
10868 return C;
10869}
10870
10871template <typename Derived>
10872OMPClause *
10874 // No need to rebuild this clause, no template-dependent parameters.
10875 return C;
10876}
10877
10878template <typename Derived>
10880 // No need to rebuild this clause, no template-dependent parameters.
10881 return C;
10882}
10883
10884template <typename Derived>
10885OMPClause *
10887 // No need to rebuild this clause, no template-dependent parameters.
10888 return C;
10889}
10890
10891template <typename Derived>
10893 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
10894 if (IVR.isInvalid())
10895 return nullptr;
10896
10897 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
10898 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
10899 for (Expr *E : llvm::drop_begin(C->varlist())) {
10900 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
10901 if (ER.isInvalid())
10902 return nullptr;
10903 InteropInfo.PreferTypes.push_back(ER.get());
10904 }
10905 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
10906 C->getBeginLoc(), C->getLParenLoc(),
10907 C->getVarLoc(), C->getEndLoc());
10908}
10909
10910template <typename Derived>
10912 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
10913 if (ER.isInvalid())
10914 return nullptr;
10915 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
10916 C->getLParenLoc(), C->getVarLoc(),
10917 C->getEndLoc());
10918}
10919
10920template <typename Derived>
10921OMPClause *
10923 ExprResult ER;
10924 if (Expr *IV = C->getInteropVar()) {
10925 ER = getDerived().TransformExpr(IV);
10926 if (ER.isInvalid())
10927 return nullptr;
10928 }
10929 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
10930 C->getLParenLoc(), C->getVarLoc(),
10931 C->getEndLoc());
10932}
10933
10934template <typename Derived>
10935OMPClause *
10937 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10938 if (Cond.isInvalid())
10939 return nullptr;
10940 return getDerived().RebuildOMPNovariantsClause(
10941 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10942}
10943
10944template <typename Derived>
10945OMPClause *
10947 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10948 if (Cond.isInvalid())
10949 return nullptr;
10950 return getDerived().RebuildOMPNocontextClause(
10951 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10952}
10953
10954template <typename Derived>
10955OMPClause *
10957 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
10958 if (ThreadID.isInvalid())
10959 return nullptr;
10960 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
10961 C->getLParenLoc(), C->getEndLoc());
10962}
10963
10964template <typename Derived>
10966 ExprResult E = getDerived().TransformExpr(C->getAlignment());
10967 if (E.isInvalid())
10968 return nullptr;
10969 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
10970 C->getLParenLoc(), C->getEndLoc());
10971}
10972
10973template <typename Derived>
10976 llvm_unreachable("unified_address clause cannot appear in dependent context");
10977}
10978
10979template <typename Derived>
10982 llvm_unreachable(
10983 "unified_shared_memory clause cannot appear in dependent context");
10984}
10985
10986template <typename Derived>
10989 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
10990}
10991
10992template <typename Derived>
10995 llvm_unreachable(
10996 "dynamic_allocators clause cannot appear in dependent context");
10997}
10998
10999template <typename Derived>
11002 llvm_unreachable(
11003 "atomic_default_mem_order clause cannot appear in dependent context");
11004}
11005
11006template <typename Derived>
11007OMPClause *
11009 llvm_unreachable("self_maps clause cannot appear in dependent context");
11010}
11011
11012template <typename Derived>
11014 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
11015 C->getBeginLoc(), C->getLParenLoc(),
11016 C->getEndLoc());
11017}
11018
11019template <typename Derived>
11020OMPClause *
11022 return getDerived().RebuildOMPSeverityClause(
11023 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
11024 C->getLParenLoc(), C->getEndLoc());
11025}
11026
11027template <typename Derived>
11028OMPClause *
11030 ExprResult E = getDerived().TransformExpr(C->getMessageString());
11031 if (E.isInvalid())
11032 return nullptr;
11033 return getDerived().RebuildOMPMessageClause(
11034 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11035}
11036
11037template <typename Derived>
11038OMPClause *
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 return getDerived().RebuildOMPPrivateClause(
11049 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11050}
11051
11052template <typename Derived>
11056 Vars.reserve(C->varlist_size());
11057 for (auto *VE : C->varlist()) {
11058 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11059 if (EVar.isInvalid())
11060 return nullptr;
11061 Vars.push_back(EVar.get());
11062 }
11063 return getDerived().RebuildOMPFirstprivateClause(
11064 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11065}
11066
11067template <typename Derived>
11068OMPClause *
11071 Vars.reserve(C->varlist_size());
11072 for (auto *VE : C->varlist()) {
11073 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11074 if (EVar.isInvalid())
11075 return nullptr;
11076 Vars.push_back(EVar.get());
11077 }
11078 return getDerived().RebuildOMPLastprivateClause(
11079 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11080 C->getLParenLoc(), C->getEndLoc());
11081}
11082
11083template <typename Derived>
11084OMPClause *
11087 Vars.reserve(C->varlist_size());
11088 for (auto *VE : C->varlist()) {
11089 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11090 if (EVar.isInvalid())
11091 return nullptr;
11092 Vars.push_back(EVar.get());
11093 }
11094 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11095 C->getLParenLoc(), C->getEndLoc());
11096}
11097
11098template <typename Derived>
11099OMPClause *
11102 Vars.reserve(C->varlist_size());
11103 for (auto *VE : C->varlist()) {
11104 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11105 if (EVar.isInvalid())
11106 return nullptr;
11107 Vars.push_back(EVar.get());
11108 }
11109 CXXScopeSpec ReductionIdScopeSpec;
11110 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11111
11112 DeclarationNameInfo NameInfo = C->getNameInfo();
11113 if (NameInfo.getName()) {
11114 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11115 if (!NameInfo.getName())
11116 return nullptr;
11117 }
11118 // Build a list of all UDR decls with the same names ranged by the Scopes.
11119 // The Scope boundary is a duplication of the previous decl.
11120 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11121 for (auto *E : C->reduction_ops()) {
11122 // Transform all the decls.
11123 if (E) {
11124 auto *ULE = cast<UnresolvedLookupExpr>(E);
11125 UnresolvedSet<8> Decls;
11126 for (auto *D : ULE->decls()) {
11127 NamedDecl *InstD =
11128 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11129 Decls.addDecl(InstD, InstD->getAccess());
11130 }
11131 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11132 SemaRef.Context, /*NamingClass=*/nullptr,
11133 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11134 /*ADL=*/true, Decls.begin(), Decls.end(),
11135 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11136 } else
11137 UnresolvedReductions.push_back(nullptr);
11138 }
11139 return getDerived().RebuildOMPReductionClause(
11140 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11141 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11142 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11143}
11144
11145template <typename Derived>
11149 Vars.reserve(C->varlist_size());
11150 for (auto *VE : C->varlist()) {
11151 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11152 if (EVar.isInvalid())
11153 return nullptr;
11154 Vars.push_back(EVar.get());
11155 }
11156 CXXScopeSpec ReductionIdScopeSpec;
11157 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11158
11159 DeclarationNameInfo NameInfo = C->getNameInfo();
11160 if (NameInfo.getName()) {
11161 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11162 if (!NameInfo.getName())
11163 return nullptr;
11164 }
11165 // Build a list of all UDR decls with the same names ranged by the Scopes.
11166 // The Scope boundary is a duplication of the previous decl.
11167 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11168 for (auto *E : C->reduction_ops()) {
11169 // Transform all the decls.
11170 if (E) {
11171 auto *ULE = cast<UnresolvedLookupExpr>(E);
11172 UnresolvedSet<8> Decls;
11173 for (auto *D : ULE->decls()) {
11174 NamedDecl *InstD =
11175 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11176 Decls.addDecl(InstD, InstD->getAccess());
11177 }
11178 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11179 SemaRef.Context, /*NamingClass=*/nullptr,
11180 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11181 /*ADL=*/true, Decls.begin(), Decls.end(),
11182 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11183 } else
11184 UnresolvedReductions.push_back(nullptr);
11185 }
11186 return getDerived().RebuildOMPTaskReductionClause(
11187 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11188 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11189}
11190
11191template <typename Derived>
11192OMPClause *
11195 Vars.reserve(C->varlist_size());
11196 for (auto *VE : C->varlist()) {
11197 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11198 if (EVar.isInvalid())
11199 return nullptr;
11200 Vars.push_back(EVar.get());
11201 }
11202 CXXScopeSpec ReductionIdScopeSpec;
11203 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11204
11205 DeclarationNameInfo NameInfo = C->getNameInfo();
11206 if (NameInfo.getName()) {
11207 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11208 if (!NameInfo.getName())
11209 return nullptr;
11210 }
11211 // Build a list of all UDR decls with the same names ranged by the Scopes.
11212 // The Scope boundary is a duplication of the previous decl.
11213 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11214 for (auto *E : C->reduction_ops()) {
11215 // Transform all the decls.
11216 if (E) {
11217 auto *ULE = cast<UnresolvedLookupExpr>(E);
11218 UnresolvedSet<8> Decls;
11219 for (auto *D : ULE->decls()) {
11220 NamedDecl *InstD =
11221 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11222 Decls.addDecl(InstD, InstD->getAccess());
11223 }
11224 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11225 SemaRef.Context, /*NamingClass=*/nullptr,
11226 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11227 /*ADL=*/true, Decls.begin(), Decls.end(),
11228 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11229 } else
11230 UnresolvedReductions.push_back(nullptr);
11231 }
11232 return getDerived().RebuildOMPInReductionClause(
11233 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11234 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11235}
11236
11237template <typename Derived>
11238OMPClause *
11241 Vars.reserve(C->varlist_size());
11242 for (auto *VE : C->varlist()) {
11243 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11244 if (EVar.isInvalid())
11245 return nullptr;
11246 Vars.push_back(EVar.get());
11247 }
11248 ExprResult Step = getDerived().TransformExpr(C->getStep());
11249 if (Step.isInvalid())
11250 return nullptr;
11251 return getDerived().RebuildOMPLinearClause(
11252 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11253 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11254 C->getEndLoc());
11255}
11256
11257template <typename Derived>
11258OMPClause *
11261 Vars.reserve(C->varlist_size());
11262 for (auto *VE : C->varlist()) {
11263 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11264 if (EVar.isInvalid())
11265 return nullptr;
11266 Vars.push_back(EVar.get());
11267 }
11268 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11269 if (Alignment.isInvalid())
11270 return nullptr;
11271 return getDerived().RebuildOMPAlignedClause(
11272 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11273 C->getColonLoc(), C->getEndLoc());
11274}
11275
11276template <typename Derived>
11277OMPClause *
11280 Vars.reserve(C->varlist_size());
11281 for (auto *VE : C->varlist()) {
11282 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11283 if (EVar.isInvalid())
11284 return nullptr;
11285 Vars.push_back(EVar.get());
11286 }
11287 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11288 C->getLParenLoc(), C->getEndLoc());
11289}
11290
11291template <typename Derived>
11292OMPClause *
11295 Vars.reserve(C->varlist_size());
11296 for (auto *VE : C->varlist()) {
11297 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11298 if (EVar.isInvalid())
11299 return nullptr;
11300 Vars.push_back(EVar.get());
11301 }
11302 return getDerived().RebuildOMPCopyprivateClause(
11303 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11304}
11305
11306template <typename Derived>
11309 Vars.reserve(C->varlist_size());
11310 for (auto *VE : C->varlist()) {
11311 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11312 if (EVar.isInvalid())
11313 return nullptr;
11314 Vars.push_back(EVar.get());
11315 }
11316 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11317 C->getLParenLoc(), C->getEndLoc());
11318}
11319
11320template <typename Derived>
11321OMPClause *
11323 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11324 if (E.isInvalid())
11325 return nullptr;
11326 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11327 C->getLParenLoc(), C->getEndLoc());
11328}
11329
11330template <typename Derived>
11331OMPClause *
11334 Expr *DepModifier = C->getModifier();
11335 if (DepModifier) {
11336 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11337 if (DepModRes.isInvalid())
11338 return nullptr;
11339 DepModifier = DepModRes.get();
11340 }
11341 Vars.reserve(C->varlist_size());
11342 for (auto *VE : C->varlist()) {
11343 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11344 if (EVar.isInvalid())
11345 return nullptr;
11346 Vars.push_back(EVar.get());
11347 }
11348 return getDerived().RebuildOMPDependClause(
11349 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11350 C->getOmpAllMemoryLoc()},
11351 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11352}
11353
11354template <typename Derived>
11355OMPClause *
11357 ExprResult E = getDerived().TransformExpr(C->getDevice());
11358 if (E.isInvalid())
11359 return nullptr;
11360 return getDerived().RebuildOMPDeviceClause(
11361 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11362 C->getModifierLoc(), C->getEndLoc());
11363}
11364
11365template <typename Derived, class T>
11368 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11369 DeclarationNameInfo &MapperIdInfo,
11370 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11371 // Transform expressions in the list.
11372 Vars.reserve(C->varlist_size());
11373 for (auto *VE : C->varlist()) {
11374 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11375 if (EVar.isInvalid())
11376 return true;
11377 Vars.push_back(EVar.get());
11378 }
11379 // Transform mapper scope specifier and identifier.
11380 NestedNameSpecifierLoc QualifierLoc;
11381 if (C->getMapperQualifierLoc()) {
11382 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11383 C->getMapperQualifierLoc());
11384 if (!QualifierLoc)
11385 return true;
11386 }
11387 MapperIdScopeSpec.Adopt(QualifierLoc);
11388 MapperIdInfo = C->getMapperIdInfo();
11389 if (MapperIdInfo.getName()) {
11390 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11391 if (!MapperIdInfo.getName())
11392 return true;
11393 }
11394 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11395 // the previous user-defined mapper lookup in dependent environment.
11396 for (auto *E : C->mapperlists()) {
11397 // Transform all the decls.
11398 if (E) {
11399 auto *ULE = cast<UnresolvedLookupExpr>(E);
11400 UnresolvedSet<8> Decls;
11401 for (auto *D : ULE->decls()) {
11402 NamedDecl *InstD =
11403 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11404 Decls.addDecl(InstD, InstD->getAccess());
11405 }
11406 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11407 TT.getSema().Context, /*NamingClass=*/nullptr,
11408 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11409 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11410 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11411 } else {
11412 UnresolvedMappers.push_back(nullptr);
11413 }
11414 }
11415 return false;
11416}
11417
11418template <typename Derived>
11419OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11420 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11422 Expr *IteratorModifier = C->getIteratorModifier();
11423 if (IteratorModifier) {
11424 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11425 if (MapModRes.isInvalid())
11426 return nullptr;
11427 IteratorModifier = MapModRes.get();
11428 }
11429 CXXScopeSpec MapperIdScopeSpec;
11430 DeclarationNameInfo MapperIdInfo;
11431 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11433 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11434 return nullptr;
11435 return getDerived().RebuildOMPMapClause(
11436 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11437 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11438 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11439}
11440
11441template <typename Derived>
11442OMPClause *
11444 Expr *Allocator = C->getAllocator();
11445 if (Allocator) {
11446 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11447 if (AllocatorRes.isInvalid())
11448 return nullptr;
11449 Allocator = AllocatorRes.get();
11450 }
11451 Expr *Alignment = C->getAlignment();
11452 if (Alignment) {
11453 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11454 if (AlignmentRes.isInvalid())
11455 return nullptr;
11456 Alignment = AlignmentRes.get();
11457 }
11459 Vars.reserve(C->varlist_size());
11460 for (auto *VE : C->varlist()) {
11461 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11462 if (EVar.isInvalid())
11463 return nullptr;
11464 Vars.push_back(EVar.get());
11465 }
11466 return getDerived().RebuildOMPAllocateClause(
11467 Allocator, Alignment, C->getFirstAllocateModifier(),
11468 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11469 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11470 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11471}
11472
11473template <typename Derived>
11474OMPClause *
11477 Vars.reserve(C->varlist_size());
11478 for (auto *VE : C->varlist()) {
11479 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11480 if (EVar.isInvalid())
11481 return nullptr;
11482 Vars.push_back(EVar.get());
11483 }
11484 return getDerived().RebuildOMPNumTeamsClause(
11485 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11486}
11487
11488template <typename Derived>
11489OMPClause *
11492 Vars.reserve(C->varlist_size());
11493 for (auto *VE : C->varlist()) {
11494 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11495 if (EVar.isInvalid())
11496 return nullptr;
11497 Vars.push_back(EVar.get());
11498 }
11499 return getDerived().RebuildOMPThreadLimitClause(
11500 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11501}
11502
11503template <typename Derived>
11504OMPClause *
11506 ExprResult E = getDerived().TransformExpr(C->getPriority());
11507 if (E.isInvalid())
11508 return nullptr;
11509 return getDerived().RebuildOMPPriorityClause(
11510 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11511}
11512
11513template <typename Derived>
11514OMPClause *
11516 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11517 if (E.isInvalid())
11518 return nullptr;
11519 return getDerived().RebuildOMPGrainsizeClause(
11520 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11521 C->getModifierLoc(), C->getEndLoc());
11522}
11523
11524template <typename Derived>
11525OMPClause *
11527 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11528 if (E.isInvalid())
11529 return nullptr;
11530 return getDerived().RebuildOMPNumTasksClause(
11531 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11532 C->getModifierLoc(), C->getEndLoc());
11533}
11534
11535template <typename Derived>
11537 ExprResult E = getDerived().TransformExpr(C->getHint());
11538 if (E.isInvalid())
11539 return nullptr;
11540 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11541 C->getLParenLoc(), C->getEndLoc());
11542}
11543
11544template <typename Derived>
11547 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11548 if (E.isInvalid())
11549 return nullptr;
11550 return getDerived().RebuildOMPDistScheduleClause(
11551 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11552 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11553}
11554
11555template <typename Derived>
11556OMPClause *
11558 // Rebuild Defaultmap Clause since we need to invoke the checking of
11559 // defaultmap(none:variable-category) after template initialization.
11560 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11561 C->getDefaultmapKind(),
11562 C->getBeginLoc(),
11563 C->getLParenLoc(),
11564 C->getDefaultmapModifierLoc(),
11565 C->getDefaultmapKindLoc(),
11566 C->getEndLoc());
11567}
11568
11569template <typename Derived>
11571 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11573 Expr *IteratorModifier = C->getIteratorModifier();
11574 if (IteratorModifier) {
11575 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11576 if (MapModRes.isInvalid())
11577 return nullptr;
11578 IteratorModifier = MapModRes.get();
11579 }
11580 CXXScopeSpec MapperIdScopeSpec;
11581 DeclarationNameInfo MapperIdInfo;
11582 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11584 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11585 return nullptr;
11586 return getDerived().RebuildOMPToClause(
11587 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11588 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11589 UnresolvedMappers);
11590}
11591
11592template <typename Derived>
11594 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11596 Expr *IteratorModifier = C->getIteratorModifier();
11597 if (IteratorModifier) {
11598 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11599 if (MapModRes.isInvalid())
11600 return nullptr;
11601 IteratorModifier = MapModRes.get();
11602 }
11603 CXXScopeSpec MapperIdScopeSpec;
11604 DeclarationNameInfo MapperIdInfo;
11605 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11607 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11608 return nullptr;
11609 return getDerived().RebuildOMPFromClause(
11610 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11611 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11612 UnresolvedMappers);
11613}
11614
11615template <typename Derived>
11619 Vars.reserve(C->varlist_size());
11620 for (auto *VE : C->varlist()) {
11621 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11622 if (EVar.isInvalid())
11623 return nullptr;
11624 Vars.push_back(EVar.get());
11625 }
11626 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11627 return getDerived().RebuildOMPUseDevicePtrClause(Vars, Locs);
11628}
11629
11630template <typename Derived>
11634 Vars.reserve(C->varlist_size());
11635 for (auto *VE : C->varlist()) {
11636 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11637 if (EVar.isInvalid())
11638 return nullptr;
11639 Vars.push_back(EVar.get());
11640 }
11641 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11642 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11643}
11644
11645template <typename Derived>
11646OMPClause *
11649 Vars.reserve(C->varlist_size());
11650 for (auto *VE : C->varlist()) {
11651 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11652 if (EVar.isInvalid())
11653 return nullptr;
11654 Vars.push_back(EVar.get());
11655 }
11656 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11657 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11658}
11659
11660template <typename Derived>
11664 Vars.reserve(C->varlist_size());
11665 for (auto *VE : C->varlist()) {
11666 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11667 if (EVar.isInvalid())
11668 return nullptr;
11669 Vars.push_back(EVar.get());
11670 }
11671 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11672 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11673}
11674
11675template <typename Derived>
11676OMPClause *
11679 Vars.reserve(C->varlist_size());
11680 for (auto *VE : C->varlist()) {
11681 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11682 if (EVar.isInvalid())
11683 return nullptr;
11684 Vars.push_back(EVar.get());
11685 }
11686 return getDerived().RebuildOMPNontemporalClause(
11687 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11688}
11689
11690template <typename Derived>
11691OMPClause *
11694 Vars.reserve(C->varlist_size());
11695 for (auto *VE : C->varlist()) {
11696 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11697 if (EVar.isInvalid())
11698 return nullptr;
11699 Vars.push_back(EVar.get());
11700 }
11701 return getDerived().RebuildOMPInclusiveClause(
11702 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11703}
11704
11705template <typename Derived>
11706OMPClause *
11709 Vars.reserve(C->varlist_size());
11710 for (auto *VE : C->varlist()) {
11711 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11712 if (EVar.isInvalid())
11713 return nullptr;
11714 Vars.push_back(EVar.get());
11715 }
11716 return getDerived().RebuildOMPExclusiveClause(
11717 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11718}
11719
11720template <typename Derived>
11724 Data.reserve(C->getNumberOfAllocators());
11725 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11726 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11727 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11728 if (Allocator.isInvalid())
11729 continue;
11730 ExprResult AllocatorTraits;
11731 if (Expr *AT = D.AllocatorTraits) {
11732 AllocatorTraits = getDerived().TransformExpr(AT);
11733 if (AllocatorTraits.isInvalid())
11734 continue;
11735 }
11736 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11737 NewD.Allocator = Allocator.get();
11738 NewD.AllocatorTraits = AllocatorTraits.get();
11739 NewD.LParenLoc = D.LParenLoc;
11740 NewD.RParenLoc = D.RParenLoc;
11741 }
11742 return getDerived().RebuildOMPUsesAllocatorsClause(
11743 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11744}
11745
11746template <typename Derived>
11747OMPClause *
11749 SmallVector<Expr *, 4> Locators;
11750 Locators.reserve(C->varlist_size());
11751 ExprResult ModifierRes;
11752 if (Expr *Modifier = C->getModifier()) {
11753 ModifierRes = getDerived().TransformExpr(Modifier);
11754 if (ModifierRes.isInvalid())
11755 return nullptr;
11756 }
11757 for (Expr *E : C->varlist()) {
11758 ExprResult Locator = getDerived().TransformExpr(E);
11759 if (Locator.isInvalid())
11760 continue;
11761 Locators.push_back(Locator.get());
11762 }
11763 return getDerived().RebuildOMPAffinityClause(
11764 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11765 ModifierRes.get(), Locators);
11766}
11767
11768template <typename Derived>
11770 return getDerived().RebuildOMPOrderClause(
11771 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11772 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11773}
11774
11775template <typename Derived>
11777 return getDerived().RebuildOMPBindClause(
11778 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11779 C->getLParenLoc(), C->getEndLoc());
11780}
11781
11782template <typename Derived>
11785 ExprResult Size = getDerived().TransformExpr(C->getSize());
11786 if (Size.isInvalid())
11787 return nullptr;
11788 return getDerived().RebuildOMPXDynCGroupMemClause(
11789 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11790}
11791
11792template <typename Derived>
11795 ExprResult Size = getDerived().TransformExpr(C->getSize());
11796 if (Size.isInvalid())
11797 return nullptr;
11798 return getDerived().RebuildOMPDynGroupprivateClause(
11799 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
11800 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
11801 C->getDynGroupprivateModifierLoc(),
11802 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
11803}
11804
11805template <typename Derived>
11806OMPClause *
11809 Vars.reserve(C->varlist_size());
11810 for (auto *VE : C->varlist()) {
11811 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11812 if (EVar.isInvalid())
11813 return nullptr;
11814 Vars.push_back(EVar.get());
11815 }
11816 return getDerived().RebuildOMPDoacrossClause(
11817 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11818 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11819}
11820
11821template <typename Derived>
11822OMPClause *
11825 for (auto *A : C->getAttrs())
11826 NewAttrs.push_back(getDerived().TransformAttr(A));
11827 return getDerived().RebuildOMPXAttributeClause(
11828 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11829}
11830
11831template <typename Derived>
11833 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11834}
11835
11836//===----------------------------------------------------------------------===//
11837// OpenACC transformation
11838//===----------------------------------------------------------------------===//
11839namespace {
11840template <typename Derived>
11841class OpenACCClauseTransform final
11842 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11843 TreeTransform<Derived> &Self;
11844 ArrayRef<const OpenACCClause *> ExistingClauses;
11845 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11846 OpenACCClause *NewClause = nullptr;
11847
11848 ExprResult VisitVar(Expr *VarRef) {
11849 ExprResult Res = Self.TransformExpr(VarRef);
11850
11851 if (!Res.isUsable())
11852 return Res;
11853
11854 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11855 ParsedClause.getClauseKind(),
11856 Res.get());
11857
11858 return Res;
11859 }
11860
11861 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11862 llvm::SmallVector<Expr *> InstantiatedVarList;
11863 for (Expr *CurVar : VarList) {
11864 ExprResult VarRef = VisitVar(CurVar);
11865
11866 if (VarRef.isUsable())
11867 InstantiatedVarList.push_back(VarRef.get());
11868 }
11869
11870 return InstantiatedVarList;
11871 }
11872
11873public:
11874 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11875 ArrayRef<const OpenACCClause *> ExistingClauses,
11876 SemaOpenACC::OpenACCParsedClause &PC)
11877 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
11878
11879 OpenACCClause *CreatedClause() const { return NewClause; }
11880
11881#define VISIT_CLAUSE(CLAUSE_NAME) \
11882 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11883#include "clang/Basic/OpenACCClauses.def"
11884};
11885
11886template <typename Derived>
11887void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11888 const OpenACCDefaultClause &C) {
11889 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
11890
11891 NewClause = OpenACCDefaultClause::Create(
11892 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
11893 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11894 ParsedClause.getEndLoc());
11895}
11896
11897template <typename Derived>
11898void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
11899 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11900 assert(Cond && "If constructed with invalid Condition");
11901 Sema::ConditionResult Res = Self.TransformCondition(
11902 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
11903
11904 if (Res.isInvalid() || !Res.get().second)
11905 return;
11906
11907 ParsedClause.setConditionDetails(Res.get().second);
11908
11909 NewClause = OpenACCIfClause::Create(
11910 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11911 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11912 ParsedClause.getEndLoc());
11913}
11914
11915template <typename Derived>
11916void OpenACCClauseTransform<Derived>::VisitSelfClause(
11917 const OpenACCSelfClause &C) {
11918
11919 // If this is an 'update' 'self' clause, this is actually a var list instead.
11920 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
11921 llvm::SmallVector<Expr *> InstantiatedVarList;
11922 for (Expr *CurVar : C.getVarList()) {
11923 ExprResult Res = Self.TransformExpr(CurVar);
11924
11925 if (!Res.isUsable())
11926 continue;
11927
11928 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11929 ParsedClause.getClauseKind(),
11930 Res.get());
11931
11932 if (Res.isUsable())
11933 InstantiatedVarList.push_back(Res.get());
11934 }
11935
11936 ParsedClause.setVarListDetails(InstantiatedVarList,
11938
11939 NewClause = OpenACCSelfClause::Create(
11940 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11941 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11942 ParsedClause.getEndLoc());
11943 } else {
11944
11945 if (C.hasConditionExpr()) {
11946 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11948 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
11950
11951 if (Res.isInvalid() || !Res.get().second)
11952 return;
11953
11954 ParsedClause.setConditionDetails(Res.get().second);
11955 }
11956
11957 NewClause = OpenACCSelfClause::Create(
11958 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11959 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11960 ParsedClause.getEndLoc());
11961 }
11962}
11963
11964template <typename Derived>
11965void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
11966 const OpenACCNumGangsClause &C) {
11967 llvm::SmallVector<Expr *> InstantiatedIntExprs;
11968
11969 for (Expr *CurIntExpr : C.getIntExprs()) {
11970 ExprResult Res = Self.TransformExpr(CurIntExpr);
11971
11972 if (!Res.isUsable())
11973 return;
11974
11975 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
11976 C.getClauseKind(),
11977 C.getBeginLoc(), Res.get());
11978 if (!Res.isUsable())
11979 return;
11980
11981 InstantiatedIntExprs.push_back(Res.get());
11982 }
11983
11984 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
11986 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11987 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
11988 ParsedClause.getEndLoc());
11989}
11990
11991template <typename Derived>
11992void OpenACCClauseTransform<Derived>::VisitPrivateClause(
11993 const OpenACCPrivateClause &C) {
11994 llvm::SmallVector<Expr *> InstantiatedVarList;
11996
11997 for (const auto [RefExpr, InitRecipe] :
11998 llvm::zip(C.getVarList(), C.getInitRecipes())) {
11999 ExprResult VarRef = VisitVar(RefExpr);
12000
12001 if (VarRef.isUsable()) {
12002 InstantiatedVarList.push_back(VarRef.get());
12003
12004 // We only have to create a new one if it is dependent, and Sema won't
12005 // make one of these unless the type is non-dependent.
12006 if (InitRecipe.isSet())
12007 InitRecipes.push_back(InitRecipe);
12008 else
12009 InitRecipes.push_back(
12010 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
12011 }
12012 }
12013 ParsedClause.setVarListDetails(InstantiatedVarList,
12015
12016 NewClause = OpenACCPrivateClause::Create(
12017 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12018 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12019 ParsedClause.getEndLoc());
12020}
12021
12022template <typename Derived>
12023void OpenACCClauseTransform<Derived>::VisitHostClause(
12024 const OpenACCHostClause &C) {
12025 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12027
12028 NewClause = OpenACCHostClause::Create(
12029 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12030 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12031 ParsedClause.getEndLoc());
12032}
12033
12034template <typename Derived>
12035void OpenACCClauseTransform<Derived>::VisitDeviceClause(
12036 const OpenACCDeviceClause &C) {
12037 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12039
12040 NewClause = OpenACCDeviceClause::Create(
12041 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12042 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12043 ParsedClause.getEndLoc());
12044}
12045
12046template <typename Derived>
12047void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
12049 llvm::SmallVector<Expr *> InstantiatedVarList;
12051
12052 for (const auto [RefExpr, InitRecipe] :
12053 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12054 ExprResult VarRef = VisitVar(RefExpr);
12055
12056 if (VarRef.isUsable()) {
12057 InstantiatedVarList.push_back(VarRef.get());
12058
12059 // We only have to create a new one if it is dependent, and Sema won't
12060 // make one of these unless the type is non-dependent.
12061 if (InitRecipe.isSet())
12062 InitRecipes.push_back(InitRecipe);
12063 else
12064 InitRecipes.push_back(
12065 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12066 VarRef.get()));
12067 }
12068 }
12069 ParsedClause.setVarListDetails(InstantiatedVarList,
12071
12073 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12074 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12075 ParsedClause.getEndLoc());
12076}
12077
12078template <typename Derived>
12079void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12080 const OpenACCNoCreateClause &C) {
12081 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12083
12085 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12086 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12087 ParsedClause.getEndLoc());
12088}
12089
12090template <typename Derived>
12091void OpenACCClauseTransform<Derived>::VisitPresentClause(
12092 const OpenACCPresentClause &C) {
12093 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12095
12096 NewClause = OpenACCPresentClause::Create(
12097 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12098 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12099 ParsedClause.getEndLoc());
12100}
12101
12102template <typename Derived>
12103void OpenACCClauseTransform<Derived>::VisitCopyClause(
12104 const OpenACCCopyClause &C) {
12105 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12106 C.getModifierList());
12107
12108 NewClause = OpenACCCopyClause::Create(
12109 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12110 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12111 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12112 ParsedClause.getEndLoc());
12113}
12114
12115template <typename Derived>
12116void OpenACCClauseTransform<Derived>::VisitLinkClause(
12117 const OpenACCLinkClause &C) {
12118 llvm_unreachable("link clause not valid unless a decl transform");
12119}
12120
12121template <typename Derived>
12122void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12124 llvm_unreachable("device_resident clause not valid unless a decl transform");
12125}
12126template <typename Derived>
12127void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12128 const OpenACCNoHostClause &C) {
12129 llvm_unreachable("nohost clause not valid unless a decl transform");
12130}
12131template <typename Derived>
12132void OpenACCClauseTransform<Derived>::VisitBindClause(
12133 const OpenACCBindClause &C) {
12134 llvm_unreachable("bind clause not valid unless a decl transform");
12135}
12136
12137template <typename Derived>
12138void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12139 const OpenACCCopyInClause &C) {
12140 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12141 C.getModifierList());
12142
12143 NewClause = OpenACCCopyInClause::Create(
12144 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12145 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12146 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12147 ParsedClause.getEndLoc());
12148}
12149
12150template <typename Derived>
12151void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12152 const OpenACCCopyOutClause &C) {
12153 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12154 C.getModifierList());
12155
12156 NewClause = OpenACCCopyOutClause::Create(
12157 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12158 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12159 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12160 ParsedClause.getEndLoc());
12161}
12162
12163template <typename Derived>
12164void OpenACCClauseTransform<Derived>::VisitCreateClause(
12165 const OpenACCCreateClause &C) {
12166 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12167 C.getModifierList());
12168
12169 NewClause = OpenACCCreateClause::Create(
12170 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12171 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12172 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12173 ParsedClause.getEndLoc());
12174}
12175template <typename Derived>
12176void OpenACCClauseTransform<Derived>::VisitAttachClause(
12177 const OpenACCAttachClause &C) {
12178 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12179
12180 // Ensure each var is a pointer type.
12181 llvm::erase_if(VarList, [&](Expr *E) {
12182 return Self.getSema().OpenACC().CheckVarIsPointerType(
12184 });
12185
12186 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12187 NewClause = OpenACCAttachClause::Create(
12188 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12189 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12190 ParsedClause.getEndLoc());
12191}
12192
12193template <typename Derived>
12194void OpenACCClauseTransform<Derived>::VisitDetachClause(
12195 const OpenACCDetachClause &C) {
12196 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12197
12198 // Ensure each var is a pointer type.
12199 llvm::erase_if(VarList, [&](Expr *E) {
12200 return Self.getSema().OpenACC().CheckVarIsPointerType(
12202 });
12203
12204 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12205 NewClause = OpenACCDetachClause::Create(
12206 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12207 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12208 ParsedClause.getEndLoc());
12209}
12210
12211template <typename Derived>
12212void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12213 const OpenACCDeleteClause &C) {
12214 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12216 NewClause = OpenACCDeleteClause::Create(
12217 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12218 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12219 ParsedClause.getEndLoc());
12220}
12221
12222template <typename Derived>
12223void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12224 const OpenACCUseDeviceClause &C) {
12225 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12228 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12229 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12230 ParsedClause.getEndLoc());
12231}
12232
12233template <typename Derived>
12234void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12235 const OpenACCDevicePtrClause &C) {
12236 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12237
12238 // Ensure each var is a pointer type.
12239 llvm::erase_if(VarList, [&](Expr *E) {
12240 return Self.getSema().OpenACC().CheckVarIsPointerType(
12242 });
12243
12244 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12246 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12247 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12248 ParsedClause.getEndLoc());
12249}
12250
12251template <typename Derived>
12252void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12253 const OpenACCNumWorkersClause &C) {
12254 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12255 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12256
12257 ExprResult Res = Self.TransformExpr(IntExpr);
12258 if (!Res.isUsable())
12259 return;
12260
12261 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12262 C.getClauseKind(),
12263 C.getBeginLoc(), Res.get());
12264 if (!Res.isUsable())
12265 return;
12266
12267 ParsedClause.setIntExprDetails(Res.get());
12269 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12270 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12271 ParsedClause.getEndLoc());
12272}
12273
12274template <typename Derived>
12275void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12276 const OpenACCDeviceNumClause &C) {
12277 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12278 assert(IntExpr && "device_num clause constructed with invalid int expr");
12279
12280 ExprResult Res = Self.TransformExpr(IntExpr);
12281 if (!Res.isUsable())
12282 return;
12283
12284 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12285 C.getClauseKind(),
12286 C.getBeginLoc(), Res.get());
12287 if (!Res.isUsable())
12288 return;
12289
12290 ParsedClause.setIntExprDetails(Res.get());
12292 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12293 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12294 ParsedClause.getEndLoc());
12295}
12296
12297template <typename Derived>
12298void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12300 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12301 assert(IntExpr && "default_async clause constructed with invalid int expr");
12302
12303 ExprResult Res = Self.TransformExpr(IntExpr);
12304 if (!Res.isUsable())
12305 return;
12306
12307 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12308 C.getClauseKind(),
12309 C.getBeginLoc(), Res.get());
12310 if (!Res.isUsable())
12311 return;
12312
12313 ParsedClause.setIntExprDetails(Res.get());
12315 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12316 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12317 ParsedClause.getEndLoc());
12318}
12319
12320template <typename Derived>
12321void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12323 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12324 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12325
12326 ExprResult Res = Self.TransformExpr(IntExpr);
12327 if (!Res.isUsable())
12328 return;
12329
12330 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12331 C.getClauseKind(),
12332 C.getBeginLoc(), Res.get());
12333 if (!Res.isUsable())
12334 return;
12335
12336 ParsedClause.setIntExprDetails(Res.get());
12338 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12339 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12340 ParsedClause.getEndLoc());
12341}
12342
12343template <typename Derived>
12344void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12345 const OpenACCAsyncClause &C) {
12346 if (C.hasIntExpr()) {
12347 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12348 if (!Res.isUsable())
12349 return;
12350
12351 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12352 C.getClauseKind(),
12353 C.getBeginLoc(), Res.get());
12354 if (!Res.isUsable())
12355 return;
12356 ParsedClause.setIntExprDetails(Res.get());
12357 }
12358
12359 NewClause = OpenACCAsyncClause::Create(
12360 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12361 ParsedClause.getLParenLoc(),
12362 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12363 : nullptr,
12364 ParsedClause.getEndLoc());
12365}
12366
12367template <typename Derived>
12368void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12369 const OpenACCWorkerClause &C) {
12370 if (C.hasIntExpr()) {
12371 // restrictions on this expression are all "does it exist in certain
12372 // situations" that are not possible to be dependent, so the only check we
12373 // have is that it transforms, and is an int expression.
12374 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12375 if (!Res.isUsable())
12376 return;
12377
12378 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12379 C.getClauseKind(),
12380 C.getBeginLoc(), Res.get());
12381 if (!Res.isUsable())
12382 return;
12383 ParsedClause.setIntExprDetails(Res.get());
12384 }
12385
12386 NewClause = OpenACCWorkerClause::Create(
12387 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12388 ParsedClause.getLParenLoc(),
12389 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12390 : nullptr,
12391 ParsedClause.getEndLoc());
12392}
12393
12394template <typename Derived>
12395void OpenACCClauseTransform<Derived>::VisitVectorClause(
12396 const OpenACCVectorClause &C) {
12397 if (C.hasIntExpr()) {
12398 // restrictions on this expression are all "does it exist in certain
12399 // situations" that are not possible to be dependent, so the only check we
12400 // have is that it transforms, and is an int expression.
12401 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12402 if (!Res.isUsable())
12403 return;
12404
12405 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12406 C.getClauseKind(),
12407 C.getBeginLoc(), Res.get());
12408 if (!Res.isUsable())
12409 return;
12410 ParsedClause.setIntExprDetails(Res.get());
12411 }
12412
12413 NewClause = OpenACCVectorClause::Create(
12414 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12415 ParsedClause.getLParenLoc(),
12416 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12417 : nullptr,
12418 ParsedClause.getEndLoc());
12419}
12420
12421template <typename Derived>
12422void OpenACCClauseTransform<Derived>::VisitWaitClause(
12423 const OpenACCWaitClause &C) {
12424 if (C.hasExprs()) {
12425 Expr *DevNumExpr = nullptr;
12426 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12427
12428 // Instantiate devnum expr if it exists.
12429 if (C.getDevNumExpr()) {
12430 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12431 if (!Res.isUsable())
12432 return;
12433 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12434 C.getClauseKind(),
12435 C.getBeginLoc(), Res.get());
12436 if (!Res.isUsable())
12437 return;
12438
12439 DevNumExpr = Res.get();
12440 }
12441
12442 // Instantiate queue ids.
12443 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12444 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12445 if (!Res.isUsable())
12446 return;
12447 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12448 C.getClauseKind(),
12449 C.getBeginLoc(), Res.get());
12450 if (!Res.isUsable())
12451 return;
12452
12453 InstantiatedQueueIdExprs.push_back(Res.get());
12454 }
12455
12456 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12457 std::move(InstantiatedQueueIdExprs));
12458 }
12459
12460 NewClause = OpenACCWaitClause::Create(
12461 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12462 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12463 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12464 ParsedClause.getEndLoc());
12465}
12466
12467template <typename Derived>
12468void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12469 const OpenACCDeviceTypeClause &C) {
12470 // Nothing to transform here, just create a new version of 'C'.
12472 Self.getSema().getASTContext(), C.getClauseKind(),
12473 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12474 C.getArchitectures(), ParsedClause.getEndLoc());
12475}
12476
12477template <typename Derived>
12478void OpenACCClauseTransform<Derived>::VisitAutoClause(
12479 const OpenACCAutoClause &C) {
12480 // Nothing to do, so just create a new node.
12481 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12482 ParsedClause.getBeginLoc(),
12483 ParsedClause.getEndLoc());
12484}
12485
12486template <typename Derived>
12487void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12488 const OpenACCIndependentClause &C) {
12489 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12490 ParsedClause.getBeginLoc(),
12491 ParsedClause.getEndLoc());
12492}
12493
12494template <typename Derived>
12495void OpenACCClauseTransform<Derived>::VisitSeqClause(
12496 const OpenACCSeqClause &C) {
12497 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12498 ParsedClause.getBeginLoc(),
12499 ParsedClause.getEndLoc());
12500}
12501template <typename Derived>
12502void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12503 const OpenACCFinalizeClause &C) {
12504 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12505 ParsedClause.getBeginLoc(),
12506 ParsedClause.getEndLoc());
12507}
12508
12509template <typename Derived>
12510void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12511 const OpenACCIfPresentClause &C) {
12512 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12513 ParsedClause.getBeginLoc(),
12514 ParsedClause.getEndLoc());
12515}
12516
12517template <typename Derived>
12518void OpenACCClauseTransform<Derived>::VisitReductionClause(
12519 const OpenACCReductionClause &C) {
12520 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12521 SmallVector<Expr *> ValidVars;
12523
12524 for (const auto [Var, OrigRecipe] :
12525 llvm::zip(TransformedVars, C.getRecipes())) {
12526 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12527 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12528 if (Res.isUsable()) {
12529 ValidVars.push_back(Res.get());
12530
12531 if (OrigRecipe.isSet())
12532 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
12533 else
12534 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
12535 C.getReductionOp(), Res.get()));
12536 }
12537 }
12538
12539 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12540 ExistingClauses, ParsedClause.getDirectiveKind(),
12541 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12542 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
12543}
12544
12545template <typename Derived>
12546void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12547 const OpenACCCollapseClause &C) {
12548 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12549 assert(LoopCount && "collapse clause constructed with invalid loop count");
12550
12551 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12552
12553 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12554 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12555 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12556
12557 NewLoopCount =
12558 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12559
12560 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12562 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12563 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12564 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12565}
12566
12567template <typename Derived>
12568void OpenACCClauseTransform<Derived>::VisitTileClause(
12569 const OpenACCTileClause &C) {
12570
12571 llvm::SmallVector<Expr *> TransformedExprs;
12572
12573 for (Expr *E : C.getSizeExprs()) {
12574 ExprResult NewSizeExpr = Self.TransformExpr(E);
12575
12576 if (!NewSizeExpr.isUsable())
12577 return;
12578
12579 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12580 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12581 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12582
12583 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12584
12585 if (!NewSizeExpr.isUsable())
12586 return;
12587 TransformedExprs.push_back(NewSizeExpr.get());
12588 }
12589
12590 ParsedClause.setIntExprDetails(TransformedExprs);
12591 NewClause = OpenACCTileClause::Create(
12592 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12593 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12594 ParsedClause.getEndLoc());
12595}
12596template <typename Derived>
12597void OpenACCClauseTransform<Derived>::VisitGangClause(
12598 const OpenACCGangClause &C) {
12599 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12600 llvm::SmallVector<Expr *> TransformedIntExprs;
12601
12602 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12603 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12604 if (!ER.isUsable())
12605 continue;
12606
12607 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12608 ParsedClause.getDirectiveKind(),
12609 C.getExpr(I).first, ER.get());
12610 if (!ER.isUsable())
12611 continue;
12612 TransformedGangKinds.push_back(C.getExpr(I).first);
12613 TransformedIntExprs.push_back(ER.get());
12614 }
12615
12616 NewClause = Self.getSema().OpenACC().CheckGangClause(
12617 ParsedClause.getDirectiveKind(), ExistingClauses,
12618 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12619 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12620}
12621} // namespace
12622template <typename Derived>
12623OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12624 ArrayRef<const OpenACCClause *> ExistingClauses,
12625 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12626
12628 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12629 ParsedClause.setEndLoc(OldClause->getEndLoc());
12630
12631 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12632 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12633
12634 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12635 ParsedClause};
12636 Transform.Visit(OldClause);
12637
12638 return Transform.CreatedClause();
12639}
12640
12641template <typename Derived>
12643TreeTransform<Derived>::TransformOpenACCClauseList(
12645 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12646 for (const auto *Clause : OldClauses) {
12647 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12648 TransformedClauses, DirKind, Clause))
12649 TransformedClauses.push_back(TransformedClause);
12650 }
12651 return TransformedClauses;
12652}
12653
12654template <typename Derived>
12657 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12658
12659 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12660 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12661 C->clauses());
12662
12663 if (getSema().OpenACC().ActOnStartStmtDirective(
12664 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12665 return StmtError();
12666
12667 // Transform Structured Block.
12668 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12669 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12670 C->clauses(), TransformedClauses);
12671 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12672 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12673 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12674
12675 return getDerived().RebuildOpenACCComputeConstruct(
12676 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12677 C->getEndLoc(), TransformedClauses, StrBlock);
12678}
12679
12680template <typename Derived>
12683
12684 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12685
12686 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12687 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12688 C->clauses());
12689
12690 if (getSema().OpenACC().ActOnStartStmtDirective(
12691 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12692 return StmtError();
12693
12694 // Transform Loop.
12695 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12696 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12697 C->clauses(), TransformedClauses);
12698 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12699 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12700 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12701
12702 return getDerived().RebuildOpenACCLoopConstruct(
12703 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12704 TransformedClauses, Loop);
12705}
12706
12707template <typename Derived>
12709 OpenACCCombinedConstruct *C) {
12710 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12711
12712 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12713 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12714 C->clauses());
12715
12716 if (getSema().OpenACC().ActOnStartStmtDirective(
12717 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12718 return StmtError();
12719
12720 // Transform Loop.
12721 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12722 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12723 C->clauses(), TransformedClauses);
12724 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12725 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12726 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12727
12728 return getDerived().RebuildOpenACCCombinedConstruct(
12729 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12730 C->getEndLoc(), TransformedClauses, Loop);
12731}
12732
12733template <typename Derived>
12736 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12737
12738 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12739 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12740 C->clauses());
12741 if (getSema().OpenACC().ActOnStartStmtDirective(
12742 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12743 return StmtError();
12744
12745 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12746 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12747 C->clauses(), TransformedClauses);
12748 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12749 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12750 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12751
12752 return getDerived().RebuildOpenACCDataConstruct(
12753 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12754 TransformedClauses, StrBlock);
12755}
12756
12757template <typename Derived>
12759 OpenACCEnterDataConstruct *C) {
12760 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12761
12762 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12763 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12764 C->clauses());
12765 if (getSema().OpenACC().ActOnStartStmtDirective(
12766 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12767 return StmtError();
12768
12769 return getDerived().RebuildOpenACCEnterDataConstruct(
12770 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12771 TransformedClauses);
12772}
12773
12774template <typename Derived>
12776 OpenACCExitDataConstruct *C) {
12777 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12778
12779 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12780 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12781 C->clauses());
12782 if (getSema().OpenACC().ActOnStartStmtDirective(
12783 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12784 return StmtError();
12785
12786 return getDerived().RebuildOpenACCExitDataConstruct(
12787 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12788 TransformedClauses);
12789}
12790
12791template <typename Derived>
12793 OpenACCHostDataConstruct *C) {
12794 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12795
12796 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12797 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12798 C->clauses());
12799 if (getSema().OpenACC().ActOnStartStmtDirective(
12800 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12801 return StmtError();
12802
12803 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12804 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12805 C->clauses(), TransformedClauses);
12806 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12807 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12808 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12809
12810 return getDerived().RebuildOpenACCHostDataConstruct(
12811 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12812 TransformedClauses, StrBlock);
12813}
12814
12815template <typename Derived>
12818 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12819
12820 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12821 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12822 C->clauses());
12823 if (getSema().OpenACC().ActOnStartStmtDirective(
12824 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12825 return StmtError();
12826
12827 return getDerived().RebuildOpenACCInitConstruct(
12828 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12829 TransformedClauses);
12830}
12831
12832template <typename Derived>
12834 OpenACCShutdownConstruct *C) {
12835 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12836
12837 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12838 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12839 C->clauses());
12840 if (getSema().OpenACC().ActOnStartStmtDirective(
12841 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12842 return StmtError();
12843
12844 return getDerived().RebuildOpenACCShutdownConstruct(
12845 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12846 TransformedClauses);
12847}
12848template <typename Derived>
12851 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12852
12853 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12854 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12855 C->clauses());
12856 if (getSema().OpenACC().ActOnStartStmtDirective(
12857 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12858 return StmtError();
12859
12860 return getDerived().RebuildOpenACCSetConstruct(
12861 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12862 TransformedClauses);
12863}
12864
12865template <typename Derived>
12867 OpenACCUpdateConstruct *C) {
12868 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12869
12870 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12871 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12872 C->clauses());
12873 if (getSema().OpenACC().ActOnStartStmtDirective(
12874 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12875 return StmtError();
12876
12877 return getDerived().RebuildOpenACCUpdateConstruct(
12878 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12879 TransformedClauses);
12880}
12881
12882template <typename Derived>
12885 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12886
12887 ExprResult DevNumExpr;
12888 if (C->hasDevNumExpr()) {
12889 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
12890
12891 if (DevNumExpr.isUsable())
12892 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
12894 C->getBeginLoc(), DevNumExpr.get());
12895 }
12896
12897 llvm::SmallVector<Expr *> QueueIdExprs;
12898
12899 for (Expr *QE : C->getQueueIdExprs()) {
12900 assert(QE && "Null queue id expr?");
12901 ExprResult NewEQ = getDerived().TransformExpr(QE);
12902
12903 if (!NewEQ.isUsable())
12904 break;
12905 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
12907 C->getBeginLoc(), NewEQ.get());
12908 if (NewEQ.isUsable())
12909 QueueIdExprs.push_back(NewEQ.get());
12910 }
12911
12912 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12913 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12914 C->clauses());
12915
12916 if (getSema().OpenACC().ActOnStartStmtDirective(
12917 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12918 return StmtError();
12919
12920 return getDerived().RebuildOpenACCWaitConstruct(
12921 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12922 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
12923 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
12924}
12925template <typename Derived>
12927 OpenACCCacheConstruct *C) {
12928 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12929
12930 llvm::SmallVector<Expr *> TransformedVarList;
12931 for (Expr *Var : C->getVarList()) {
12932 assert(Var && "Null var listexpr?");
12933
12934 ExprResult NewVar = getDerived().TransformExpr(Var);
12935
12936 if (!NewVar.isUsable())
12937 break;
12938
12939 NewVar = getSema().OpenACC().ActOnVar(
12940 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
12941 if (!NewVar.isUsable())
12942 break;
12943
12944 TransformedVarList.push_back(NewVar.get());
12945 }
12946
12947 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
12948 C->getBeginLoc(), {}))
12949 return StmtError();
12950
12951 return getDerived().RebuildOpenACCCacheConstruct(
12952 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12953 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
12954 C->getEndLoc());
12955}
12956
12957template <typename Derived>
12959 OpenACCAtomicConstruct *C) {
12960 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12961
12962 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12963 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12964 C->clauses());
12965
12966 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
12967 C->getBeginLoc(), {}))
12968 return StmtError();
12969
12970 // Transform Associated Stmt.
12971 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12972 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
12973
12974 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
12975 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
12976 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
12977 AssocStmt);
12978
12979 return getDerived().RebuildOpenACCAtomicConstruct(
12980 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
12981 C->getEndLoc(), TransformedClauses, AssocStmt);
12982}
12983
12984template <typename Derived>
12987 if (getDerived().AlwaysRebuild())
12988 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
12989 // Nothing can ever change, so there is never anything to transform.
12990 return E;
12991}
12992
12993//===----------------------------------------------------------------------===//
12994// Expression transformation
12995//===----------------------------------------------------------------------===//
12996template<typename Derived>
12999 return TransformExpr(E->getSubExpr());
13000}
13001
13002template <typename Derived>
13005 if (!E->isTypeDependent())
13006 return E;
13007
13008 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
13009
13010 if (!NewT)
13011 return ExprError();
13012
13013 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
13014 return E;
13015
13016 return getDerived().RebuildSYCLUniqueStableNameExpr(
13017 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
13018}
13019
13020template<typename Derived>
13023 if (!E->isTypeDependent())
13024 return E;
13025
13026 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13027 E->getIdentKind());
13028}
13029
13030template<typename Derived>
13033 NestedNameSpecifierLoc QualifierLoc;
13034 if (E->getQualifierLoc()) {
13035 QualifierLoc
13036 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13037 if (!QualifierLoc)
13038 return ExprError();
13039 }
13040
13041 ValueDecl *ND
13042 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13043 E->getDecl()));
13044 if (!ND || ND->isInvalidDecl())
13045 return ExprError();
13046
13047 NamedDecl *Found = ND;
13048 if (E->getFoundDecl() != E->getDecl()) {
13049 Found = cast_or_null<NamedDecl>(
13050 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13051 if (!Found)
13052 return ExprError();
13053 }
13054
13055 DeclarationNameInfo NameInfo = E->getNameInfo();
13056 if (NameInfo.getName()) {
13057 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13058 if (!NameInfo.getName())
13059 return ExprError();
13060 }
13061
13062 if (!getDerived().AlwaysRebuild() &&
13063 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13064 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13065 Found == E->getFoundDecl() &&
13066 NameInfo.getName() == E->getDecl()->getDeclName() &&
13067 !E->hasExplicitTemplateArgs()) {
13068
13069 // Mark it referenced in the new context regardless.
13070 // FIXME: this is a bit instantiation-specific.
13071 SemaRef.MarkDeclRefReferenced(E);
13072
13073 return E;
13074 }
13075
13076 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13077 if (E->hasExplicitTemplateArgs()) {
13078 TemplateArgs = &TransArgs;
13079 TransArgs.setLAngleLoc(E->getLAngleLoc());
13080 TransArgs.setRAngleLoc(E->getRAngleLoc());
13081 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13082 E->getNumTemplateArgs(),
13083 TransArgs))
13084 return ExprError();
13085 }
13086
13087 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13088 Found, TemplateArgs);
13089}
13090
13091template<typename Derived>
13094 return E;
13095}
13096
13097template <typename Derived>
13099 FixedPointLiteral *E) {
13100 return E;
13101}
13102
13103template<typename Derived>
13106 return E;
13107}
13108
13109template<typename Derived>
13112 return E;
13113}
13114
13115template<typename Derived>
13118 return E;
13119}
13120
13121template<typename Derived>
13124 return E;
13125}
13126
13127template<typename Derived>
13130 return getDerived().TransformCallExpr(E);
13131}
13132
13133template<typename Derived>
13136 ExprResult ControllingExpr;
13137 TypeSourceInfo *ControllingType = nullptr;
13138 if (E->isExprPredicate())
13139 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13140 else
13141 ControllingType = getDerived().TransformType(E->getControllingType());
13142
13143 if (ControllingExpr.isInvalid() && !ControllingType)
13144 return ExprError();
13145
13146 SmallVector<Expr *, 4> AssocExprs;
13148 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13149 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13150 if (TSI) {
13151 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13152 if (!AssocType)
13153 return ExprError();
13154 AssocTypes.push_back(AssocType);
13155 } else {
13156 AssocTypes.push_back(nullptr);
13157 }
13158
13159 ExprResult AssocExpr =
13160 getDerived().TransformExpr(Assoc.getAssociationExpr());
13161 if (AssocExpr.isInvalid())
13162 return ExprError();
13163 AssocExprs.push_back(AssocExpr.get());
13164 }
13165
13166 if (!ControllingType)
13167 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13168 E->getDefaultLoc(),
13169 E->getRParenLoc(),
13170 ControllingExpr.get(),
13171 AssocTypes,
13172 AssocExprs);
13173 return getDerived().RebuildGenericSelectionExpr(
13174 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13175 ControllingType, AssocTypes, AssocExprs);
13176}
13177
13178template<typename Derived>
13181 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13182 if (SubExpr.isInvalid())
13183 return ExprError();
13184
13185 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13186 return E;
13187
13188 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13189 E->getRParen());
13190}
13191
13192/// The operand of a unary address-of operator has special rules: it's
13193/// allowed to refer to a non-static member of a class even if there's no 'this'
13194/// object available.
13195template<typename Derived>
13198 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13199 return getDerived().TransformDependentScopeDeclRefExpr(
13200 DRE, /*IsAddressOfOperand=*/true, nullptr);
13201 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13202 return getDerived().TransformUnresolvedLookupExpr(
13203 ULE, /*IsAddressOfOperand=*/true);
13204 else
13205 return getDerived().TransformExpr(E);
13206}
13207
13208template<typename Derived>
13211 ExprResult SubExpr;
13212 if (E->getOpcode() == UO_AddrOf)
13213 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13214 else
13215 SubExpr = TransformExpr(E->getSubExpr());
13216 if (SubExpr.isInvalid())
13217 return ExprError();
13218
13219 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13220 return E;
13221
13222 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13223 E->getOpcode(),
13224 SubExpr.get());
13225}
13226
13227template<typename Derived>
13229TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13230 // Transform the type.
13231 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13232 if (!Type)
13233 return ExprError();
13234
13235 // Transform all of the components into components similar to what the
13236 // parser uses.
13237 // FIXME: It would be slightly more efficient in the non-dependent case to
13238 // just map FieldDecls, rather than requiring the rebuilder to look for
13239 // the fields again. However, __builtin_offsetof is rare enough in
13240 // template code that we don't care.
13241 bool ExprChanged = false;
13242 typedef Sema::OffsetOfComponent Component;
13243 SmallVector<Component, 4> Components;
13244 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13245 const OffsetOfNode &ON = E->getComponent(I);
13246 Component Comp;
13247 Comp.isBrackets = true;
13248 Comp.LocStart = ON.getSourceRange().getBegin();
13249 Comp.LocEnd = ON.getSourceRange().getEnd();
13250 switch (ON.getKind()) {
13251 case OffsetOfNode::Array: {
13252 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13253 ExprResult Index = getDerived().TransformExpr(FromIndex);
13254 if (Index.isInvalid())
13255 return ExprError();
13256
13257 ExprChanged = ExprChanged || Index.get() != FromIndex;
13258 Comp.isBrackets = true;
13259 Comp.U.E = Index.get();
13260 break;
13261 }
13262
13265 Comp.isBrackets = false;
13266 Comp.U.IdentInfo = ON.getFieldName();
13267 if (!Comp.U.IdentInfo)
13268 continue;
13269
13270 break;
13271
13272 case OffsetOfNode::Base:
13273 // Will be recomputed during the rebuild.
13274 continue;
13275 }
13276
13277 Components.push_back(Comp);
13278 }
13279
13280 // If nothing changed, retain the existing expression.
13281 if (!getDerived().AlwaysRebuild() &&
13282 Type == E->getTypeSourceInfo() &&
13283 !ExprChanged)
13284 return E;
13285
13286 // Build a new offsetof expression.
13287 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13288 Components, E->getRParenLoc());
13289}
13290
13291template<typename Derived>
13294 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13295 "opaque value expression requires transformation");
13296 return E;
13297}
13298
13299template <typename Derived>
13302 bool Changed = false;
13303 for (Expr *C : E->subExpressions()) {
13304 ExprResult NewC = getDerived().TransformExpr(C);
13305 if (NewC.isInvalid())
13306 return ExprError();
13307 Children.push_back(NewC.get());
13308
13309 Changed |= NewC.get() != C;
13310 }
13311 if (!getDerived().AlwaysRebuild() && !Changed)
13312 return E;
13313 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13314 Children, E->getType());
13315}
13316
13317template<typename Derived>
13320 // Rebuild the syntactic form. The original syntactic form has
13321 // opaque-value expressions in it, so strip those away and rebuild
13322 // the result. This is a really awful way of doing this, but the
13323 // better solution (rebuilding the semantic expressions and
13324 // rebinding OVEs as necessary) doesn't work; we'd need
13325 // TreeTransform to not strip away implicit conversions.
13326 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13327 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13328 if (result.isInvalid()) return ExprError();
13329
13330 // If that gives us a pseudo-object result back, the pseudo-object
13331 // expression must have been an lvalue-to-rvalue conversion which we
13332 // should reapply.
13333 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13334 result = SemaRef.PseudoObject().checkRValue(result.get());
13335
13336 return result;
13337}
13338
13339template<typename Derived>
13343 if (E->isArgumentType()) {
13344 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13345
13346 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13347 if (!NewT)
13348 return ExprError();
13349
13350 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13351 return E;
13352
13353 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13354 E->getKind(),
13355 E->getSourceRange());
13356 }
13357
13358 // C++0x [expr.sizeof]p1:
13359 // The operand is either an expression, which is an unevaluated operand
13360 // [...]
13364
13365 // Try to recover if we have something like sizeof(T::X) where X is a type.
13366 // Notably, there must be *exactly* one set of parens if X is a type.
13367 TypeSourceInfo *RecoveryTSI = nullptr;
13368 ExprResult SubExpr;
13369 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13370 if (auto *DRE =
13371 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13372 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13373 PE, DRE, false, &RecoveryTSI);
13374 else
13375 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13376
13377 if (RecoveryTSI) {
13378 return getDerived().RebuildUnaryExprOrTypeTrait(
13379 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13380 } else if (SubExpr.isInvalid())
13381 return ExprError();
13382
13383 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13384 return E;
13385
13386 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13387 E->getOperatorLoc(),
13388 E->getKind(),
13389 E->getSourceRange());
13390}
13391
13392template<typename Derived>
13395 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13396 if (LHS.isInvalid())
13397 return ExprError();
13398
13399 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13400 if (RHS.isInvalid())
13401 return ExprError();
13402
13403
13404 if (!getDerived().AlwaysRebuild() &&
13405 LHS.get() == E->getLHS() &&
13406 RHS.get() == E->getRHS())
13407 return E;
13408
13409 return getDerived().RebuildArraySubscriptExpr(
13410 LHS.get(),
13411 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13412}
13413
13414template <typename Derived>
13417 ExprResult Base = getDerived().TransformExpr(E->getBase());
13418 if (Base.isInvalid())
13419 return ExprError();
13420
13421 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13422 if (RowIdx.isInvalid())
13423 return ExprError();
13424
13425 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13426 RowIdx.get() == E->getRowIdx())
13427 return E;
13428
13429 return getDerived().RebuildMatrixSingleSubscriptExpr(Base.get(), RowIdx.get(),
13430 E->getRBracketLoc());
13431}
13432
13433template <typename Derived>
13436 ExprResult Base = getDerived().TransformExpr(E->getBase());
13437 if (Base.isInvalid())
13438 return ExprError();
13439
13440 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13441 if (RowIdx.isInvalid())
13442 return ExprError();
13443
13444 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13445 if (ColumnIdx.isInvalid())
13446 return ExprError();
13447
13448 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13449 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13450 return E;
13451
13452 return getDerived().RebuildMatrixSubscriptExpr(
13453 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13454}
13455
13456template <typename Derived>
13459 ExprResult Base = getDerived().TransformExpr(E->getBase());
13460 if (Base.isInvalid())
13461 return ExprError();
13462
13463 ExprResult LowerBound;
13464 if (E->getLowerBound()) {
13465 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13466 if (LowerBound.isInvalid())
13467 return ExprError();
13468 }
13469
13470 ExprResult Length;
13471 if (E->getLength()) {
13472 Length = getDerived().TransformExpr(E->getLength());
13473 if (Length.isInvalid())
13474 return ExprError();
13475 }
13476
13477 ExprResult Stride;
13478 if (E->isOMPArraySection()) {
13479 if (Expr *Str = E->getStride()) {
13480 Stride = getDerived().TransformExpr(Str);
13481 if (Stride.isInvalid())
13482 return ExprError();
13483 }
13484 }
13485
13486 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13487 LowerBound.get() == E->getLowerBound() &&
13488 Length.get() == E->getLength() &&
13489 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13490 return E;
13491
13492 return getDerived().RebuildArraySectionExpr(
13493 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13494 LowerBound.get(), E->getColonLocFirst(),
13495 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13496 Length.get(), Stride.get(), E->getRBracketLoc());
13497}
13498
13499template <typename Derived>
13502 ExprResult Base = getDerived().TransformExpr(E->getBase());
13503 if (Base.isInvalid())
13504 return ExprError();
13505
13507 bool ErrorFound = false;
13508 for (Expr *Dim : E->getDimensions()) {
13509 ExprResult DimRes = getDerived().TransformExpr(Dim);
13510 if (DimRes.isInvalid()) {
13511 ErrorFound = true;
13512 continue;
13513 }
13514 Dims.push_back(DimRes.get());
13515 }
13516
13517 if (ErrorFound)
13518 return ExprError();
13519 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13520 E->getRParenLoc(), Dims,
13521 E->getBracketsRanges());
13522}
13523
13524template <typename Derived>
13527 unsigned NumIterators = E->numOfIterators();
13529
13530 bool ErrorFound = false;
13531 bool NeedToRebuild = getDerived().AlwaysRebuild();
13532 for (unsigned I = 0; I < NumIterators; ++I) {
13533 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13534 Data[I].DeclIdent = D->getIdentifier();
13535 Data[I].DeclIdentLoc = D->getLocation();
13536 if (D->getLocation() == D->getBeginLoc()) {
13537 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13538 "Implicit type must be int.");
13539 } else {
13540 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13541 QualType DeclTy = getDerived().TransformType(D->getType());
13542 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13543 }
13544 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13545 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13546 ExprResult End = getDerived().TransformExpr(Range.End);
13547 ExprResult Step = getDerived().TransformExpr(Range.Step);
13548 ErrorFound = ErrorFound ||
13549 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13550 !Data[I].Type.get().isNull())) ||
13551 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13552 if (ErrorFound)
13553 continue;
13554 Data[I].Range.Begin = Begin.get();
13555 Data[I].Range.End = End.get();
13556 Data[I].Range.Step = Step.get();
13557 Data[I].AssignLoc = E->getAssignLoc(I);
13558 Data[I].ColonLoc = E->getColonLoc(I);
13559 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13560 NeedToRebuild =
13561 NeedToRebuild ||
13562 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13563 D->getType().getTypePtrOrNull()) ||
13564 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13565 Range.Step != Data[I].Range.Step;
13566 }
13567 if (ErrorFound)
13568 return ExprError();
13569 if (!NeedToRebuild)
13570 return E;
13571
13572 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13573 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13574 if (!Res.isUsable())
13575 return Res;
13576 auto *IE = cast<OMPIteratorExpr>(Res.get());
13577 for (unsigned I = 0; I < NumIterators; ++I)
13578 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13579 IE->getIteratorDecl(I));
13580 return Res;
13581}
13582
13583template<typename Derived>
13586 // Transform the callee.
13587 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13588 if (Callee.isInvalid())
13589 return ExprError();
13590
13591 // Transform arguments.
13592 bool ArgChanged = false;
13594 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13595 &ArgChanged))
13596 return ExprError();
13597
13598 if (!getDerived().AlwaysRebuild() &&
13599 Callee.get() == E->getCallee() &&
13600 !ArgChanged)
13601 return SemaRef.MaybeBindToTemporary(E);
13602
13603 // FIXME: Wrong source location information for the '('.
13604 SourceLocation FakeLParenLoc
13605 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13606
13607 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13608 if (E->hasStoredFPFeatures()) {
13609 FPOptionsOverride NewOverrides = E->getFPFeatures();
13610 getSema().CurFPFeatures =
13611 NewOverrides.applyOverrides(getSema().getLangOpts());
13612 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13613 }
13614
13615 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13616 Args,
13617 E->getRParenLoc());
13618}
13619
13620template<typename Derived>
13623 ExprResult Base = getDerived().TransformExpr(E->getBase());
13624 if (Base.isInvalid())
13625 return ExprError();
13626
13627 NestedNameSpecifierLoc QualifierLoc;
13628 if (E->hasQualifier()) {
13629 QualifierLoc
13630 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13631
13632 if (!QualifierLoc)
13633 return ExprError();
13634 }
13635 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13636
13638 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13639 E->getMemberDecl()));
13640 if (!Member)
13641 return ExprError();
13642
13643 NamedDecl *FoundDecl = E->getFoundDecl();
13644 if (FoundDecl == E->getMemberDecl()) {
13645 FoundDecl = Member;
13646 } else {
13647 FoundDecl = cast_or_null<NamedDecl>(
13648 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13649 if (!FoundDecl)
13650 return ExprError();
13651 }
13652
13653 if (!getDerived().AlwaysRebuild() &&
13654 Base.get() == E->getBase() &&
13655 QualifierLoc == E->getQualifierLoc() &&
13656 Member == E->getMemberDecl() &&
13657 FoundDecl == E->getFoundDecl() &&
13658 !E->hasExplicitTemplateArgs()) {
13659
13660 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13661 // for Openmp where the field need to be privatizized in the case.
13662 if (!(isa<CXXThisExpr>(E->getBase()) &&
13663 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13665 // Mark it referenced in the new context regardless.
13666 // FIXME: this is a bit instantiation-specific.
13667 SemaRef.MarkMemberReferenced(E);
13668 return E;
13669 }
13670 }
13671
13672 TemplateArgumentListInfo TransArgs;
13673 if (E->hasExplicitTemplateArgs()) {
13674 TransArgs.setLAngleLoc(E->getLAngleLoc());
13675 TransArgs.setRAngleLoc(E->getRAngleLoc());
13676 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13677 E->getNumTemplateArgs(),
13678 TransArgs))
13679 return ExprError();
13680 }
13681
13682 // FIXME: Bogus source location for the operator
13683 SourceLocation FakeOperatorLoc =
13684 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13685
13686 // FIXME: to do this check properly, we will need to preserve the
13687 // first-qualifier-in-scope here, just in case we had a dependent
13688 // base (and therefore couldn't do the check) and a
13689 // nested-name-qualifier (and therefore could do the lookup).
13690 NamedDecl *FirstQualifierInScope = nullptr;
13691 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13692 if (MemberNameInfo.getName()) {
13693 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13694 if (!MemberNameInfo.getName())
13695 return ExprError();
13696 }
13697
13698 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13699 E->isArrow(),
13700 QualifierLoc,
13701 TemplateKWLoc,
13702 MemberNameInfo,
13703 Member,
13704 FoundDecl,
13705 (E->hasExplicitTemplateArgs()
13706 ? &TransArgs : nullptr),
13707 FirstQualifierInScope);
13708}
13709
13710template<typename Derived>
13713 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13714 if (LHS.isInvalid())
13715 return ExprError();
13716
13717 ExprResult RHS =
13718 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13719 if (RHS.isInvalid())
13720 return ExprError();
13721
13722 if (!getDerived().AlwaysRebuild() &&
13723 LHS.get() == E->getLHS() &&
13724 RHS.get() == E->getRHS())
13725 return E;
13726
13727 if (E->isCompoundAssignmentOp())
13728 // FPFeatures has already been established from trailing storage
13729 return getDerived().RebuildBinaryOperator(
13730 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13731 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13732 FPOptionsOverride NewOverrides(E->getFPFeatures());
13733 getSema().CurFPFeatures =
13734 NewOverrides.applyOverrides(getSema().getLangOpts());
13735 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13736 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13737 LHS.get(), RHS.get());
13738}
13739
13740template <typename Derived>
13743 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13744
13745 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13746 if (LHS.isInvalid())
13747 return ExprError();
13748
13749 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13750 if (RHS.isInvalid())
13751 return ExprError();
13752
13753 // Extract the already-resolved callee declarations so that we can restrict
13754 // ourselves to using them as the unqualified lookup results when rebuilding.
13755 UnresolvedSet<2> UnqualLookups;
13756 bool ChangedAnyLookups = false;
13757 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13758 const_cast<Expr *>(Decomp.InnerBinOp)};
13759 for (Expr *PossibleBinOp : PossibleBinOps) {
13760 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13761 if (!Op)
13762 continue;
13763 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13764 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13765 continue;
13766
13767 // Transform the callee in case we built a call to a local extern
13768 // declaration.
13769 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13770 E->getOperatorLoc(), Callee->getFoundDecl()));
13771 if (!Found)
13772 return ExprError();
13773 if (Found != Callee->getFoundDecl())
13774 ChangedAnyLookups = true;
13775 UnqualLookups.addDecl(Found);
13776 }
13777
13778 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13779 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13780 // Mark all functions used in the rewrite as referenced. Note that when
13781 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13782 // function calls, and/or there might be a user-defined conversion sequence
13783 // applied to the operands of the <.
13784 // FIXME: this is a bit instantiation-specific.
13785 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13786 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13787 return E;
13788 }
13789
13790 return getDerived().RebuildCXXRewrittenBinaryOperator(
13791 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13792}
13793
13794template<typename Derived>
13798 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13799 FPOptionsOverride NewOverrides(E->getFPFeatures());
13800 getSema().CurFPFeatures =
13801 NewOverrides.applyOverrides(getSema().getLangOpts());
13802 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13803 return getDerived().TransformBinaryOperator(E);
13804}
13805
13806template<typename Derived>
13809 // Just rebuild the common and RHS expressions and see whether we
13810 // get any changes.
13811
13812 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13813 if (commonExpr.isInvalid())
13814 return ExprError();
13815
13816 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13817 if (rhs.isInvalid())
13818 return ExprError();
13819
13820 if (!getDerived().AlwaysRebuild() &&
13821 commonExpr.get() == e->getCommon() &&
13822 rhs.get() == e->getFalseExpr())
13823 return e;
13824
13825 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13826 e->getQuestionLoc(),
13827 nullptr,
13828 e->getColonLoc(),
13829 rhs.get());
13830}
13831
13832template<typename Derived>
13835 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13836 if (Cond.isInvalid())
13837 return ExprError();
13838
13839 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13840 if (LHS.isInvalid())
13841 return ExprError();
13842
13843 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13844 if (RHS.isInvalid())
13845 return ExprError();
13846
13847 if (!getDerived().AlwaysRebuild() &&
13848 Cond.get() == E->getCond() &&
13849 LHS.get() == E->getLHS() &&
13850 RHS.get() == E->getRHS())
13851 return E;
13852
13853 return getDerived().RebuildConditionalOperator(Cond.get(),
13854 E->getQuestionLoc(),
13855 LHS.get(),
13856 E->getColonLoc(),
13857 RHS.get());
13858}
13859
13860template<typename Derived>
13863 // Implicit casts are eliminated during transformation, since they
13864 // will be recomputed by semantic analysis after transformation.
13865 return getDerived().TransformExpr(E->getSubExprAsWritten());
13866}
13867
13868template<typename Derived>
13871 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
13872 if (!Type)
13873 return ExprError();
13874
13875 ExprResult SubExpr
13876 = getDerived().TransformExpr(E->getSubExprAsWritten());
13877 if (SubExpr.isInvalid())
13878 return ExprError();
13879
13880 if (!getDerived().AlwaysRebuild() &&
13881 Type == E->getTypeInfoAsWritten() &&
13882 SubExpr.get() == E->getSubExpr())
13883 return E;
13884
13885 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
13886 Type,
13887 E->getRParenLoc(),
13888 SubExpr.get());
13889}
13890
13891template<typename Derived>
13894 TypeSourceInfo *OldT = E->getTypeSourceInfo();
13895 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13896 if (!NewT)
13897 return ExprError();
13898
13899 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
13900 if (Init.isInvalid())
13901 return ExprError();
13902
13903 if (!getDerived().AlwaysRebuild() &&
13904 OldT == NewT &&
13905 Init.get() == E->getInitializer())
13906 return SemaRef.MaybeBindToTemporary(E);
13907
13908 // Note: the expression type doesn't necessarily match the
13909 // type-as-written, but that's okay, because it should always be
13910 // derivable from the initializer.
13911
13912 return getDerived().RebuildCompoundLiteralExpr(
13913 E->getLParenLoc(), NewT,
13914 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
13915}
13916
13917template<typename Derived>
13920 ExprResult Base = getDerived().TransformExpr(E->getBase());
13921 if (Base.isInvalid())
13922 return ExprError();
13923
13924 if (!getDerived().AlwaysRebuild() &&
13925 Base.get() == E->getBase())
13926 return E;
13927
13928 // FIXME: Bad source location
13929 SourceLocation FakeOperatorLoc =
13930 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
13931 return getDerived().RebuildExtVectorElementExpr(
13932 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
13933 E->getAccessor());
13934}
13935
13936template<typename Derived>
13939 if (InitListExpr *Syntactic = E->getSyntacticForm())
13940 E = Syntactic;
13941
13942 bool InitChanged = false;
13943
13946
13948 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
13949 Inits, &InitChanged))
13950 return ExprError();
13951
13952 if (!getDerived().AlwaysRebuild() && !InitChanged) {
13953 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
13954 // in some cases. We can't reuse it in general, because the syntactic and
13955 // semantic forms are linked, and we can't know that semantic form will
13956 // match even if the syntactic form does.
13957 }
13958
13959 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
13960 E->getRBraceLoc());
13961}
13962
13963template<typename Derived>
13966 Designation Desig;
13967
13968 // transform the initializer value
13969 ExprResult Init = getDerived().TransformExpr(E->getInit());
13970 if (Init.isInvalid())
13971 return ExprError();
13972
13973 // transform the designators.
13974 SmallVector<Expr*, 4> ArrayExprs;
13975 bool ExprChanged = false;
13976 for (const DesignatedInitExpr::Designator &D : E->designators()) {
13977 if (D.isFieldDesignator()) {
13978 if (D.getFieldDecl()) {
13979 FieldDecl *Field = cast_or_null<FieldDecl>(
13980 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
13981 if (Field != D.getFieldDecl())
13982 // Rebuild the expression when the transformed FieldDecl is
13983 // different to the already assigned FieldDecl.
13984 ExprChanged = true;
13985 if (Field->isAnonymousStructOrUnion())
13986 continue;
13987 } else {
13988 // Ensure that the designator expression is rebuilt when there isn't
13989 // a resolved FieldDecl in the designator as we don't want to assign
13990 // a FieldDecl to a pattern designator that will be instantiated again.
13991 ExprChanged = true;
13992 }
13993 Desig.AddDesignator(Designator::CreateFieldDesignator(
13994 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
13995 continue;
13996 }
13997
13998 if (D.isArrayDesignator()) {
13999 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
14000 if (Index.isInvalid())
14001 return ExprError();
14002
14003 Desig.AddDesignator(
14004 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
14005
14006 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
14007 ArrayExprs.push_back(Index.get());
14008 continue;
14009 }
14010
14011 assert(D.isArrayRangeDesignator() && "New kind of designator?");
14012 ExprResult Start
14013 = getDerived().TransformExpr(E->getArrayRangeStart(D));
14014 if (Start.isInvalid())
14015 return ExprError();
14016
14017 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
14018 if (End.isInvalid())
14019 return ExprError();
14020
14021 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
14022 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
14023
14024 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
14025 End.get() != E->getArrayRangeEnd(D);
14026
14027 ArrayExprs.push_back(Start.get());
14028 ArrayExprs.push_back(End.get());
14029 }
14030
14031 if (!getDerived().AlwaysRebuild() &&
14032 Init.get() == E->getInit() &&
14033 !ExprChanged)
14034 return E;
14035
14036 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14037 E->getEqualOrColonLoc(),
14038 E->usesGNUSyntax(), Init.get());
14039}
14040
14041// Seems that if TransformInitListExpr() only works on the syntactic form of an
14042// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14043template<typename Derived>
14047 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14048 "initializer");
14049 return ExprError();
14050}
14051
14052template<typename Derived>
14055 NoInitExpr *E) {
14056 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14057 return ExprError();
14058}
14059
14060template<typename Derived>
14063 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14064 return ExprError();
14065}
14066
14067template<typename Derived>
14070 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14071 return ExprError();
14072}
14073
14074template<typename Derived>
14078 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14079
14080 // FIXME: Will we ever have proper type location here? Will we actually
14081 // need to transform the type?
14082 QualType T = getDerived().TransformType(E->getType());
14083 if (T.isNull())
14084 return ExprError();
14085
14086 if (!getDerived().AlwaysRebuild() &&
14087 T == E->getType())
14088 return E;
14089
14090 return getDerived().RebuildImplicitValueInitExpr(T);
14091}
14092
14093template<typename Derived>
14096 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14097 if (!TInfo)
14098 return ExprError();
14099
14100 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14101 if (SubExpr.isInvalid())
14102 return ExprError();
14103
14104 if (!getDerived().AlwaysRebuild() &&
14105 TInfo == E->getWrittenTypeInfo() &&
14106 SubExpr.get() == E->getSubExpr())
14107 return E;
14108
14109 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14110 TInfo, E->getRParenLoc());
14111}
14112
14113template<typename Derived>
14116 bool ArgumentChanged = false;
14118 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14119 &ArgumentChanged))
14120 return ExprError();
14121
14122 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14123 Inits,
14124 E->getRParenLoc());
14125}
14126
14127/// Transform an address-of-label expression.
14128///
14129/// By default, the transformation of an address-of-label expression always
14130/// rebuilds the expression, so that the label identifier can be resolved to
14131/// the corresponding label statement by semantic analysis.
14132template<typename Derived>
14135 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14136 E->getLabel());
14137 if (!LD)
14138 return ExprError();
14139
14140 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14141 cast<LabelDecl>(LD));
14142}
14143
14144template<typename Derived>
14147 SemaRef.ActOnStartStmtExpr();
14148 StmtResult SubStmt
14149 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14150 if (SubStmt.isInvalid()) {
14151 SemaRef.ActOnStmtExprError();
14152 return ExprError();
14153 }
14154
14155 unsigned OldDepth = E->getTemplateDepth();
14156 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14157
14158 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14159 SubStmt.get() == E->getSubStmt()) {
14160 // Calling this an 'error' is unintuitive, but it does the right thing.
14161 SemaRef.ActOnStmtExprError();
14162 return SemaRef.MaybeBindToTemporary(E);
14163 }
14164
14165 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14166 E->getRParenLoc(), NewDepth);
14167}
14168
14169template<typename Derived>
14172 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14173 if (Cond.isInvalid())
14174 return ExprError();
14175
14176 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14177 if (LHS.isInvalid())
14178 return ExprError();
14179
14180 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14181 if (RHS.isInvalid())
14182 return ExprError();
14183
14184 if (!getDerived().AlwaysRebuild() &&
14185 Cond.get() == E->getCond() &&
14186 LHS.get() == E->getLHS() &&
14187 RHS.get() == E->getRHS())
14188 return E;
14189
14190 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14191 Cond.get(), LHS.get(), RHS.get(),
14192 E->getRParenLoc());
14193}
14194
14195template<typename Derived>
14198 return E;
14199}
14200
14201template<typename Derived>
14204 switch (E->getOperator()) {
14205 case OO_New:
14206 case OO_Delete:
14207 case OO_Array_New:
14208 case OO_Array_Delete:
14209 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14210
14211 case OO_Subscript:
14212 case OO_Call: {
14213 // This is a call to an object's operator().
14214 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14215
14216 // Transform the object itself.
14217 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14218 if (Object.isInvalid())
14219 return ExprError();
14220
14221 // FIXME: Poor location information. Also, if the location for the end of
14222 // the token is within a macro expansion, getLocForEndOfToken() will return
14223 // an invalid source location. If that happens and we have an otherwise
14224 // valid end location, use the valid one instead of the invalid one.
14225 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14226 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14227 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14228 FakeLParenLoc = EndLoc;
14229
14230 // Transform the call arguments.
14232 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14233 Args))
14234 return ExprError();
14235
14236 if (E->getOperator() == OO_Subscript)
14237 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14238 Args, E->getEndLoc());
14239
14240 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14241 E->getEndLoc());
14242 }
14243
14244#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14245 case OO_##Name: \
14246 break;
14247
14248#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14249#include "clang/Basic/OperatorKinds.def"
14250
14251 case OO_Conditional:
14252 llvm_unreachable("conditional operator is not actually overloadable");
14253
14254 case OO_None:
14256 llvm_unreachable("not an overloaded operator?");
14257 }
14258
14260 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14261 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14262 else
14263 First = getDerived().TransformExpr(E->getArg(0));
14264 if (First.isInvalid())
14265 return ExprError();
14266
14267 ExprResult Second;
14268 if (E->getNumArgs() == 2) {
14269 Second =
14270 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14271 if (Second.isInvalid())
14272 return ExprError();
14273 }
14274
14275 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14276 FPOptionsOverride NewOverrides(E->getFPFeatures());
14277 getSema().CurFPFeatures =
14278 NewOverrides.applyOverrides(getSema().getLangOpts());
14279 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14280
14281 Expr *Callee = E->getCallee();
14282 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14283 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14285 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14286 return ExprError();
14287
14288 return getDerived().RebuildCXXOperatorCallExpr(
14289 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14290 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14291 }
14292
14293 UnresolvedSet<1> Functions;
14294 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14295 Callee = ICE->getSubExprAsWritten();
14296 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14297 ValueDecl *VD = cast_or_null<ValueDecl>(
14298 getDerived().TransformDecl(DR->getLocation(), DR));
14299 if (!VD)
14300 return ExprError();
14301
14302 if (!isa<CXXMethodDecl>(VD))
14303 Functions.addDecl(VD);
14304
14305 return getDerived().RebuildCXXOperatorCallExpr(
14306 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14307 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14308}
14309
14310template<typename Derived>
14313 return getDerived().TransformCallExpr(E);
14314}
14315
14316template <typename Derived>
14318 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14319 getSema().CurContext != E->getParentContext();
14320
14321 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14322 return E;
14323
14324 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14325 E->getBeginLoc(), E->getEndLoc(),
14326 getSema().CurContext);
14327}
14328
14329template <typename Derived>
14331 return E;
14332}
14333
14334template<typename Derived>
14337 // Transform the callee.
14338 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14339 if (Callee.isInvalid())
14340 return ExprError();
14341
14342 // Transform exec config.
14343 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14344 if (EC.isInvalid())
14345 return ExprError();
14346
14347 // Transform arguments.
14348 bool ArgChanged = false;
14350 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14351 &ArgChanged))
14352 return ExprError();
14353
14354 if (!getDerived().AlwaysRebuild() &&
14355 Callee.get() == E->getCallee() &&
14356 !ArgChanged)
14357 return SemaRef.MaybeBindToTemporary(E);
14358
14359 // FIXME: Wrong source location information for the '('.
14360 SourceLocation FakeLParenLoc
14361 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14362 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14363 Args,
14364 E->getRParenLoc(), EC.get());
14365}
14366
14367template<typename Derived>
14370 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14371 if (!Type)
14372 return ExprError();
14373
14374 ExprResult SubExpr
14375 = getDerived().TransformExpr(E->getSubExprAsWritten());
14376 if (SubExpr.isInvalid())
14377 return ExprError();
14378
14379 if (!getDerived().AlwaysRebuild() &&
14380 Type == E->getTypeInfoAsWritten() &&
14381 SubExpr.get() == E->getSubExpr())
14382 return E;
14383 return getDerived().RebuildCXXNamedCastExpr(
14386 // FIXME. this should be '(' location
14387 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14388}
14389
14390template<typename Derived>
14393 TypeSourceInfo *TSI =
14394 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14395 if (!TSI)
14396 return ExprError();
14397
14398 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14399 if (Sub.isInvalid())
14400 return ExprError();
14401
14402 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14403 Sub.get(), BCE->getEndLoc());
14404}
14405
14406template<typename Derived>
14408TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14409 return getDerived().TransformCXXNamedCastExpr(E);
14410}
14411
14412template<typename Derived>
14415 return getDerived().TransformCXXNamedCastExpr(E);
14416}
14417
14418template<typename Derived>
14422 return getDerived().TransformCXXNamedCastExpr(E);
14423}
14424
14425template<typename Derived>
14428 return getDerived().TransformCXXNamedCastExpr(E);
14429}
14430
14431template<typename Derived>
14434 return getDerived().TransformCXXNamedCastExpr(E);
14435}
14436
14437template<typename Derived>
14442 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14443 if (!Type)
14444 return ExprError();
14445
14446 ExprResult SubExpr
14447 = getDerived().TransformExpr(E->getSubExprAsWritten());
14448 if (SubExpr.isInvalid())
14449 return ExprError();
14450
14451 if (!getDerived().AlwaysRebuild() &&
14452 Type == E->getTypeInfoAsWritten() &&
14453 SubExpr.get() == E->getSubExpr())
14454 return E;
14455
14456 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14457 E->getLParenLoc(),
14458 SubExpr.get(),
14459 E->getRParenLoc(),
14460 E->isListInitialization());
14461}
14462
14463template<typename Derived>
14466 if (E->isTypeOperand()) {
14467 TypeSourceInfo *TInfo
14468 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14469 if (!TInfo)
14470 return ExprError();
14471
14472 if (!getDerived().AlwaysRebuild() &&
14473 TInfo == E->getTypeOperandSourceInfo())
14474 return E;
14475
14476 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14477 TInfo, E->getEndLoc());
14478 }
14479
14480 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14481 // type. We must not unilaterally enter unevaluated context here, as then
14482 // semantic processing can re-transform an already transformed operand.
14483 Expr *Op = E->getExprOperand();
14485 if (E->isGLValue())
14486 if (auto *RD = Op->getType()->getAsCXXRecordDecl();
14487 RD && RD->isPolymorphic())
14488 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14489
14492
14493 ExprResult SubExpr = getDerived().TransformExpr(Op);
14494 if (SubExpr.isInvalid())
14495 return ExprError();
14496
14497 if (!getDerived().AlwaysRebuild() &&
14498 SubExpr.get() == E->getExprOperand())
14499 return E;
14500
14501 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14502 SubExpr.get(), E->getEndLoc());
14503}
14504
14505template<typename Derived>
14508 if (E->isTypeOperand()) {
14509 TypeSourceInfo *TInfo
14510 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14511 if (!TInfo)
14512 return ExprError();
14513
14514 if (!getDerived().AlwaysRebuild() &&
14515 TInfo == E->getTypeOperandSourceInfo())
14516 return E;
14517
14518 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14519 TInfo, E->getEndLoc());
14520 }
14521
14524
14525 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14526 if (SubExpr.isInvalid())
14527 return ExprError();
14528
14529 if (!getDerived().AlwaysRebuild() &&
14530 SubExpr.get() == E->getExprOperand())
14531 return E;
14532
14533 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14534 SubExpr.get(), E->getEndLoc());
14535}
14536
14537template<typename Derived>
14540 return E;
14541}
14542
14543template<typename Derived>
14547 return E;
14548}
14549
14550template<typename Derived>
14553
14554 // In lambdas, the qualifiers of the type depends of where in
14555 // the call operator `this` appear, and we do not have a good way to
14556 // rebuild this information, so we transform the type.
14557 //
14558 // In other contexts, the type of `this` may be overrided
14559 // for type deduction, so we need to recompute it.
14560 //
14561 // Always recompute the type if we're in the body of a lambda, and
14562 // 'this' is dependent on a lambda's explicit object parameter; we
14563 // also need to always rebuild the expression in this case to clear
14564 // the flag.
14565 QualType T = [&]() {
14566 auto &S = getSema();
14567 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14568 return S.getCurrentThisType();
14569 if (S.getCurLambda())
14570 return getDerived().TransformType(E->getType());
14571 return S.getCurrentThisType();
14572 }();
14573
14574 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14575 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14576 // Mark it referenced in the new context regardless.
14577 // FIXME: this is a bit instantiation-specific.
14578 getSema().MarkThisReferenced(E);
14579 return E;
14580 }
14581
14582 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14583}
14584
14585template<typename Derived>
14588 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14589 if (SubExpr.isInvalid())
14590 return ExprError();
14591
14592 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14593
14594 if (!getDerived().AlwaysRebuild() &&
14595 SubExpr.get() == E->getSubExpr())
14596 return E;
14597
14598 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14599 E->isThrownVariableInScope());
14600}
14601
14602template<typename Derived>
14605 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14606 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14607 if (!Param)
14608 return ExprError();
14609
14610 ExprResult InitRes;
14611 if (E->hasRewrittenInit()) {
14612 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14613 if (InitRes.isInvalid())
14614 return ExprError();
14615 }
14616
14617 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14618 E->getUsedContext() == SemaRef.CurContext &&
14619 InitRes.get() == E->getRewrittenExpr())
14620 return E;
14621
14622 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14623 InitRes.get());
14624}
14625
14626template<typename Derived>
14629 FieldDecl *Field = cast_or_null<FieldDecl>(
14630 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14631 if (!Field)
14632 return ExprError();
14633
14634 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14635 E->getUsedContext() == SemaRef.CurContext)
14636 return E;
14637
14638 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14639}
14640
14641template<typename Derived>
14645 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14646 if (!T)
14647 return ExprError();
14648
14649 if (!getDerived().AlwaysRebuild() &&
14650 T == E->getTypeSourceInfo())
14651 return E;
14652
14653 return getDerived().RebuildCXXScalarValueInitExpr(T,
14654 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14655 E->getRParenLoc());
14656}
14657
14658template<typename Derived>
14661 // Transform the type that we're allocating
14662 TypeSourceInfo *AllocTypeInfo =
14663 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14664 if (!AllocTypeInfo)
14665 return ExprError();
14666
14667 // Transform the size of the array we're allocating (if any).
14668 std::optional<Expr *> ArraySize;
14669 if (E->isArray()) {
14670 ExprResult NewArraySize;
14671 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14672 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14673 if (NewArraySize.isInvalid())
14674 return ExprError();
14675 }
14676 ArraySize = NewArraySize.get();
14677 }
14678
14679 // Transform the placement arguments (if any).
14680 bool ArgumentChanged = false;
14681 SmallVector<Expr*, 8> PlacementArgs;
14682 if (getDerived().TransformExprs(E->getPlacementArgs(),
14683 E->getNumPlacementArgs(), true,
14684 PlacementArgs, &ArgumentChanged))
14685 return ExprError();
14686
14687 // Transform the initializer (if any).
14688 Expr *OldInit = E->getInitializer();
14689 ExprResult NewInit;
14690 if (OldInit)
14691 NewInit = getDerived().TransformInitializer(OldInit, true);
14692 if (NewInit.isInvalid())
14693 return ExprError();
14694
14695 // Transform new operator and delete operator.
14696 FunctionDecl *OperatorNew = nullptr;
14697 if (E->getOperatorNew()) {
14698 OperatorNew = cast_or_null<FunctionDecl>(
14699 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14700 if (!OperatorNew)
14701 return ExprError();
14702 }
14703
14704 FunctionDecl *OperatorDelete = nullptr;
14705 if (E->getOperatorDelete()) {
14706 OperatorDelete = cast_or_null<FunctionDecl>(
14707 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14708 if (!OperatorDelete)
14709 return ExprError();
14710 }
14711
14712 if (!getDerived().AlwaysRebuild() &&
14713 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14714 ArraySize == E->getArraySize() &&
14715 NewInit.get() == OldInit &&
14716 OperatorNew == E->getOperatorNew() &&
14717 OperatorDelete == E->getOperatorDelete() &&
14718 !ArgumentChanged) {
14719 // Mark any declarations we need as referenced.
14720 // FIXME: instantiation-specific.
14721 if (OperatorNew)
14722 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14723 if (OperatorDelete)
14724 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14725
14726 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14727 QualType ElementType
14728 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14729 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14731 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14732 }
14733 }
14734
14735 return E;
14736 }
14737
14738 QualType AllocType = AllocTypeInfo->getType();
14739 if (!ArraySize) {
14740 // If no array size was specified, but the new expression was
14741 // instantiated with an array type (e.g., "new T" where T is
14742 // instantiated with "int[4]"), extract the outer bound from the
14743 // array type as our array size. We do this with constant and
14744 // dependently-sized array types.
14745 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14746 if (!ArrayT) {
14747 // Do nothing
14748 } else if (const ConstantArrayType *ConsArrayT
14749 = dyn_cast<ConstantArrayType>(ArrayT)) {
14750 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14751 SemaRef.Context.getSizeType(),
14752 /*FIXME:*/ E->getBeginLoc());
14753 AllocType = ConsArrayT->getElementType();
14754 } else if (const DependentSizedArrayType *DepArrayT
14755 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14756 if (DepArrayT->getSizeExpr()) {
14757 ArraySize = DepArrayT->getSizeExpr();
14758 AllocType = DepArrayT->getElementType();
14759 }
14760 }
14761 }
14762
14763 return getDerived().RebuildCXXNewExpr(
14764 E->getBeginLoc(), E->isGlobalNew(),
14765 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14766 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14767 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14768}
14769
14770template<typename Derived>
14773 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14774 if (Operand.isInvalid())
14775 return ExprError();
14776
14777 // Transform the delete operator, if known.
14778 FunctionDecl *OperatorDelete = nullptr;
14779 if (E->getOperatorDelete()) {
14780 OperatorDelete = cast_or_null<FunctionDecl>(
14781 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14782 if (!OperatorDelete)
14783 return ExprError();
14784 }
14785
14786 if (!getDerived().AlwaysRebuild() &&
14787 Operand.get() == E->getArgument() &&
14788 OperatorDelete == E->getOperatorDelete()) {
14789 // Mark any declarations we need as referenced.
14790 // FIXME: instantiation-specific.
14791 if (OperatorDelete)
14792 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14793
14794 if (!E->getArgument()->isTypeDependent()) {
14795 QualType Destroyed = SemaRef.Context.getBaseElementType(
14796 E->getDestroyedType());
14797 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14798 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14799 SemaRef.LookupDestructor(Record));
14800 }
14801
14802 return E;
14803 }
14804
14805 return getDerived().RebuildCXXDeleteExpr(
14806 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14807}
14808
14809template<typename Derived>
14813 ExprResult Base = getDerived().TransformExpr(E->getBase());
14814 if (Base.isInvalid())
14815 return ExprError();
14816
14817 ParsedType ObjectTypePtr;
14818 bool MayBePseudoDestructor = false;
14819 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14820 E->getOperatorLoc(),
14821 E->isArrow()? tok::arrow : tok::period,
14822 ObjectTypePtr,
14823 MayBePseudoDestructor);
14824 if (Base.isInvalid())
14825 return ExprError();
14826
14827 QualType ObjectType = ObjectTypePtr.get();
14828 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
14829 if (QualifierLoc) {
14830 QualifierLoc
14831 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
14832 if (!QualifierLoc)
14833 return ExprError();
14834 }
14835 CXXScopeSpec SS;
14836 SS.Adopt(QualifierLoc);
14837
14839 if (E->getDestroyedTypeInfo()) {
14840 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
14841 E->getDestroyedTypeInfo(), ObjectType,
14842 /*FirstQualifierInScope=*/nullptr);
14843 if (!DestroyedTypeInfo)
14844 return ExprError();
14845 Destroyed = DestroyedTypeInfo;
14846 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
14847 // We aren't likely to be able to resolve the identifier down to a type
14848 // now anyway, so just retain the identifier.
14849 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
14850 E->getDestroyedTypeLoc());
14851 } else {
14852 // Look for a destructor known with the given name.
14853 ParsedType T = SemaRef.getDestructorName(
14854 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
14855 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
14856 if (!T)
14857 return ExprError();
14858
14859 Destroyed
14861 E->getDestroyedTypeLoc());
14862 }
14863
14864 TypeSourceInfo *ScopeTypeInfo = nullptr;
14865 if (E->getScopeTypeInfo()) {
14866 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
14867 E->getScopeTypeInfo(), ObjectType, nullptr);
14868 if (!ScopeTypeInfo)
14869 return ExprError();
14870 }
14871
14872 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
14873 E->getOperatorLoc(),
14874 E->isArrow(),
14875 SS,
14876 ScopeTypeInfo,
14877 E->getColonColonLoc(),
14878 E->getTildeLoc(),
14879 Destroyed);
14880}
14881
14882template <typename Derived>
14884 bool RequiresADL,
14885 LookupResult &R) {
14886 // Transform all the decls.
14887 bool AllEmptyPacks = true;
14888 for (auto *OldD : Old->decls()) {
14889 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
14890 if (!InstD) {
14891 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
14892 // This can happen because of dependent hiding.
14893 if (isa<UsingShadowDecl>(OldD))
14894 continue;
14895 else {
14896 R.clear();
14897 return true;
14898 }
14899 }
14900
14901 // Expand using pack declarations.
14902 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
14903 ArrayRef<NamedDecl*> Decls = SingleDecl;
14904 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
14905 Decls = UPD->expansions();
14906
14907 // Expand using declarations.
14908 for (auto *D : Decls) {
14909 if (auto *UD = dyn_cast<UsingDecl>(D)) {
14910 for (auto *SD : UD->shadows())
14911 R.addDecl(SD);
14912 } else {
14913 R.addDecl(D);
14914 }
14915 }
14916
14917 AllEmptyPacks &= Decls.empty();
14918 }
14919
14920 // C++ [temp.res]/8.4.2:
14921 // The program is ill-formed, no diagnostic required, if [...] lookup for
14922 // a name in the template definition found a using-declaration, but the
14923 // lookup in the corresponding scope in the instantiation odoes not find
14924 // any declarations because the using-declaration was a pack expansion and
14925 // the corresponding pack is empty
14926 if (AllEmptyPacks && !RequiresADL) {
14927 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
14928 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
14929 return true;
14930 }
14931
14932 // Resolve a kind, but don't do any further analysis. If it's
14933 // ambiguous, the callee needs to deal with it.
14934 R.resolveKind();
14935
14936 if (Old->hasTemplateKeyword() && !R.empty()) {
14938 getSema().FilterAcceptableTemplateNames(R,
14939 /*AllowFunctionTemplates=*/true,
14940 /*AllowDependent=*/true);
14941 if (R.empty()) {
14942 // If a 'template' keyword was used, a lookup that finds only non-template
14943 // names is an error.
14944 getSema().Diag(R.getNameLoc(),
14945 diag::err_template_kw_refers_to_non_template)
14947 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
14948 getSema().Diag(FoundDecl->getLocation(),
14949 diag::note_template_kw_refers_to_non_template)
14950 << R.getLookupName();
14951 return true;
14952 }
14953 }
14954
14955 return false;
14956}
14957
14958template <typename Derived>
14963
14964template <typename Derived>
14967 bool IsAddressOfOperand) {
14968 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
14970
14971 // Transform the declaration set.
14972 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
14973 return ExprError();
14974
14975 // Rebuild the nested-name qualifier, if present.
14976 CXXScopeSpec SS;
14977 if (Old->getQualifierLoc()) {
14978 NestedNameSpecifierLoc QualifierLoc
14979 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
14980 if (!QualifierLoc)
14981 return ExprError();
14982
14983 SS.Adopt(QualifierLoc);
14984 }
14985
14986 if (Old->getNamingClass()) {
14987 CXXRecordDecl *NamingClass
14988 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
14989 Old->getNameLoc(),
14990 Old->getNamingClass()));
14991 if (!NamingClass) {
14992 R.clear();
14993 return ExprError();
14994 }
14995
14996 R.setNamingClass(NamingClass);
14997 }
14998
14999 // Rebuild the template arguments, if any.
15000 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
15001 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
15002 if (Old->hasExplicitTemplateArgs() &&
15003 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15004 Old->getNumTemplateArgs(),
15005 TransArgs)) {
15006 R.clear();
15007 return ExprError();
15008 }
15009
15010 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
15011 // a non-static data member is named in an unevaluated operand, or when
15012 // a member is named in a dependent class scope function template explicit
15013 // specialization that is neither declared static nor with an explicit object
15014 // parameter.
15015 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
15016 return SemaRef.BuildPossibleImplicitMemberExpr(
15017 SS, TemplateKWLoc, R,
15018 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
15019 /*S=*/nullptr);
15020
15021 // If we have neither explicit template arguments, nor the template keyword,
15022 // it's a normal declaration name or member reference.
15023 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
15024 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
15025
15026 // If we have template arguments, then rebuild the template-id expression.
15027 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
15028 Old->requiresADL(), &TransArgs);
15029}
15030
15031template<typename Derived>
15034 bool ArgChanged = false;
15036 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15037 TypeSourceInfo *From = E->getArg(I);
15038 TypeLoc FromTL = From->getTypeLoc();
15039 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15040 TypeLocBuilder TLB;
15041 TLB.reserve(FromTL.getFullDataSize());
15042 QualType To = getDerived().TransformType(TLB, FromTL);
15043 if (To.isNull())
15044 return ExprError();
15045
15046 if (To == From->getType())
15047 Args.push_back(From);
15048 else {
15049 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15050 ArgChanged = true;
15051 }
15052 continue;
15053 }
15054
15055 ArgChanged = true;
15056
15057 // We have a pack expansion. Instantiate it.
15058 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15059 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15061 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15062
15063 // Determine whether the set of unexpanded parameter packs can and should
15064 // be expanded.
15065 bool Expand = true;
15066 bool RetainExpansion = false;
15067 UnsignedOrNone OrigNumExpansions =
15068 ExpansionTL.getTypePtr()->getNumExpansions();
15069 UnsignedOrNone NumExpansions = OrigNumExpansions;
15070 if (getDerived().TryExpandParameterPacks(
15071 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15072 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15073 RetainExpansion, NumExpansions))
15074 return ExprError();
15075
15076 if (!Expand) {
15077 // The transform has determined that we should perform a simple
15078 // transformation on the pack expansion, producing another pack
15079 // expansion.
15080 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15081
15082 TypeLocBuilder TLB;
15083 TLB.reserve(From->getTypeLoc().getFullDataSize());
15084
15085 QualType To = getDerived().TransformType(TLB, PatternTL);
15086 if (To.isNull())
15087 return ExprError();
15088
15089 To = getDerived().RebuildPackExpansionType(To,
15090 PatternTL.getSourceRange(),
15091 ExpansionTL.getEllipsisLoc(),
15092 NumExpansions);
15093 if (To.isNull())
15094 return ExprError();
15095
15096 PackExpansionTypeLoc ToExpansionTL
15097 = TLB.push<PackExpansionTypeLoc>(To);
15098 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15099 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15100 continue;
15101 }
15102
15103 // Expand the pack expansion by substituting for each argument in the
15104 // pack(s).
15105 for (unsigned I = 0; I != *NumExpansions; ++I) {
15106 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15107 TypeLocBuilder TLB;
15108 TLB.reserve(PatternTL.getFullDataSize());
15109 QualType To = getDerived().TransformType(TLB, PatternTL);
15110 if (To.isNull())
15111 return ExprError();
15112
15113 if (To->containsUnexpandedParameterPack()) {
15114 To = getDerived().RebuildPackExpansionType(To,
15115 PatternTL.getSourceRange(),
15116 ExpansionTL.getEllipsisLoc(),
15117 NumExpansions);
15118 if (To.isNull())
15119 return ExprError();
15120
15121 PackExpansionTypeLoc ToExpansionTL
15122 = TLB.push<PackExpansionTypeLoc>(To);
15123 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15124 }
15125
15126 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15127 }
15128
15129 if (!RetainExpansion)
15130 continue;
15131
15132 // If we're supposed to retain a pack expansion, do so by temporarily
15133 // forgetting the partially-substituted parameter pack.
15134 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15135
15136 TypeLocBuilder TLB;
15137 TLB.reserve(From->getTypeLoc().getFullDataSize());
15138
15139 QualType To = getDerived().TransformType(TLB, PatternTL);
15140 if (To.isNull())
15141 return ExprError();
15142
15143 To = getDerived().RebuildPackExpansionType(To,
15144 PatternTL.getSourceRange(),
15145 ExpansionTL.getEllipsisLoc(),
15146 NumExpansions);
15147 if (To.isNull())
15148 return ExprError();
15149
15150 PackExpansionTypeLoc ToExpansionTL
15151 = TLB.push<PackExpansionTypeLoc>(To);
15152 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15153 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15154 }
15155
15156 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15157 return E;
15158
15159 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15160 E->getEndLoc());
15161}
15162
15163template<typename Derived>
15167 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15168 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15169 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15170 Old->NumTemplateArgs, TransArgs))
15171 return ExprError();
15172
15173 return getDerived().RebuildConceptSpecializationExpr(
15174 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15175 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15176 &TransArgs);
15177}
15178
15179template<typename Derived>
15182 SmallVector<ParmVarDecl*, 4> TransParams;
15183 SmallVector<QualType, 4> TransParamTypes;
15184 Sema::ExtParameterInfoBuilder ExtParamInfos;
15185
15186 // C++2a [expr.prim.req]p2
15187 // Expressions appearing within a requirement-body are unevaluated operands.
15191
15193 getSema().Context, getSema().CurContext,
15194 E->getBody()->getBeginLoc());
15195
15196 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15197
15198 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15199 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15200 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15201
15202 for (ParmVarDecl *Param : TransParams)
15203 if (Param)
15204 Param->setDeclContext(Body);
15205
15206 // On failure to transform, TransformRequiresTypeParams returns an expression
15207 // in the event that the transformation of the type params failed in some way.
15208 // It is expected that this will result in a 'not satisfied' Requires clause
15209 // when instantiating.
15210 if (!TypeParamResult.isUnset())
15211 return TypeParamResult;
15212
15214 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15215 TransReqs))
15216 return ExprError();
15217
15218 for (concepts::Requirement *Req : TransReqs) {
15219 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15220 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15221 ER->getReturnTypeRequirement()
15222 .getTypeConstraintTemplateParameterList()->getParam(0)
15223 ->setDeclContext(Body);
15224 }
15225 }
15226 }
15227
15228 return getDerived().RebuildRequiresExpr(
15229 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15230 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15231}
15232
15233template<typename Derived>
15237 for (concepts::Requirement *Req : Reqs) {
15238 concepts::Requirement *TransReq = nullptr;
15239 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15240 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15241 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15242 TransReq = getDerived().TransformExprRequirement(ExprReq);
15243 else
15244 TransReq = getDerived().TransformNestedRequirement(
15246 if (!TransReq)
15247 return true;
15248 Transformed.push_back(TransReq);
15249 }
15250 return false;
15251}
15252
15253template<typename Derived>
15257 if (Req->isSubstitutionFailure()) {
15258 if (getDerived().AlwaysRebuild())
15259 return getDerived().RebuildTypeRequirement(
15261 return Req;
15262 }
15263 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15264 if (!TransType)
15265 return nullptr;
15266 return getDerived().RebuildTypeRequirement(TransType);
15267}
15268
15269template<typename Derived>
15272 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15273 if (Req->isExprSubstitutionFailure())
15274 TransExpr = Req->getExprSubstitutionDiagnostic();
15275 else {
15276 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15277 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15278 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15279 if (TransExprRes.isInvalid())
15280 return nullptr;
15281 TransExpr = TransExprRes.get();
15282 }
15283
15284 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15285 const auto &RetReq = Req->getReturnTypeRequirement();
15286 if (RetReq.isEmpty())
15287 TransRetReq.emplace();
15288 else if (RetReq.isSubstitutionFailure())
15289 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15290 else if (RetReq.isTypeConstraint()) {
15291 TemplateParameterList *OrigTPL =
15292 RetReq.getTypeConstraintTemplateParameterList();
15294 getDerived().TransformTemplateParameterList(OrigTPL);
15295 if (!TPL)
15296 return nullptr;
15297 TransRetReq.emplace(TPL);
15298 }
15299 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15300 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15301 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15302 Req->getNoexceptLoc(),
15303 std::move(*TransRetReq));
15304 return getDerived().RebuildExprRequirement(
15306 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15307}
15308
15309template<typename Derived>
15313 if (Req->hasInvalidConstraint()) {
15314 if (getDerived().AlwaysRebuild())
15315 return getDerived().RebuildNestedRequirement(
15317 return Req;
15318 }
15319 ExprResult TransConstraint =
15320 getDerived().TransformExpr(Req->getConstraintExpr());
15321 if (TransConstraint.isInvalid())
15322 return nullptr;
15323 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15324}
15325
15326template<typename Derived>
15329 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15330 if (!T)
15331 return ExprError();
15332
15333 if (!getDerived().AlwaysRebuild() &&
15335 return E;
15336
15337 ExprResult SubExpr;
15338 {
15341 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15342 if (SubExpr.isInvalid())
15343 return ExprError();
15344 }
15345
15346 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15347 SubExpr.get(), E->getEndLoc());
15348}
15349
15350template<typename Derived>
15353 ExprResult SubExpr;
15354 {
15357 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15358 if (SubExpr.isInvalid())
15359 return ExprError();
15360
15361 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15362 return E;
15363 }
15364
15365 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15366 SubExpr.get(), E->getEndLoc());
15367}
15368
15369template <typename Derived>
15371 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15372 TypeSourceInfo **RecoveryTSI) {
15373 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15374 DRE, AddrTaken, RecoveryTSI);
15375
15376 // Propagate both errors and recovered types, which return ExprEmpty.
15377 if (!NewDRE.isUsable())
15378 return NewDRE;
15379
15380 // We got an expr, wrap it up in parens.
15381 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15382 return PE;
15383 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15384 PE->getRParen());
15385}
15386
15387template <typename Derived>
15393
15394template <typename Derived>
15396 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15397 TypeSourceInfo **RecoveryTSI) {
15398 assert(E->getQualifierLoc());
15399 NestedNameSpecifierLoc QualifierLoc =
15400 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15401 if (!QualifierLoc)
15402 return ExprError();
15403 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15404
15405 // TODO: If this is a conversion-function-id, verify that the
15406 // destination type name (if present) resolves the same way after
15407 // instantiation as it did in the local scope.
15408
15409 DeclarationNameInfo NameInfo =
15410 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15411 if (!NameInfo.getName())
15412 return ExprError();
15413
15414 if (!E->hasExplicitTemplateArgs()) {
15415 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15416 // Note: it is sufficient to compare the Name component of NameInfo:
15417 // if name has not changed, DNLoc has not changed either.
15418 NameInfo.getName() == E->getDeclName())
15419 return E;
15420
15421 return getDerived().RebuildDependentScopeDeclRefExpr(
15422 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15423 IsAddressOfOperand, RecoveryTSI);
15424 }
15425
15426 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15427 if (getDerived().TransformTemplateArguments(
15428 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15429 return ExprError();
15430
15431 return getDerived().RebuildDependentScopeDeclRefExpr(
15432 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15433 RecoveryTSI);
15434}
15435
15436template<typename Derived>
15439 // CXXConstructExprs other than for list-initialization and
15440 // CXXTemporaryObjectExpr are always implicit, so when we have
15441 // a 1-argument construction we just transform that argument.
15442 if (getDerived().AllowSkippingCXXConstructExpr() &&
15443 ((E->getNumArgs() == 1 ||
15444 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15445 (!getDerived().DropCallArgument(E->getArg(0))) &&
15446 !E->isListInitialization()))
15447 return getDerived().TransformInitializer(E->getArg(0),
15448 /*DirectInit*/ false);
15449
15450 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15451
15452 QualType T = getDerived().TransformType(E->getType());
15453 if (T.isNull())
15454 return ExprError();
15455
15456 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15457 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15458 if (!Constructor)
15459 return ExprError();
15460
15461 bool ArgumentChanged = false;
15463 {
15466 E->isListInitialization());
15467 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15468 &ArgumentChanged))
15469 return ExprError();
15470 }
15471
15472 if (!getDerived().AlwaysRebuild() &&
15473 T == E->getType() &&
15474 Constructor == E->getConstructor() &&
15475 !ArgumentChanged) {
15476 // Mark the constructor as referenced.
15477 // FIXME: Instantiation-specific
15478 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15479 return E;
15480 }
15481
15482 return getDerived().RebuildCXXConstructExpr(
15483 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15484 E->hadMultipleCandidates(), E->isListInitialization(),
15485 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15486 E->getConstructionKind(), E->getParenOrBraceRange());
15487}
15488
15489template<typename Derived>
15492 QualType T = getDerived().TransformType(E->getType());
15493 if (T.isNull())
15494 return ExprError();
15495
15496 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15497 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15498 if (!Constructor)
15499 return ExprError();
15500
15501 if (!getDerived().AlwaysRebuild() &&
15502 T == E->getType() &&
15503 Constructor == E->getConstructor()) {
15504 // Mark the constructor as referenced.
15505 // FIXME: Instantiation-specific
15506 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15507 return E;
15508 }
15509
15510 return getDerived().RebuildCXXInheritedCtorInitExpr(
15511 T, E->getLocation(), Constructor,
15512 E->constructsVBase(), E->inheritedFromVBase());
15513}
15514
15515/// Transform a C++ temporary-binding expression.
15516///
15517/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15518/// transform the subexpression and return that.
15519template<typename Derived>
15522 if (auto *Dtor = E->getTemporary()->getDestructor())
15523 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15524 const_cast<CXXDestructorDecl *>(Dtor));
15525 return getDerived().TransformExpr(E->getSubExpr());
15526}
15527
15528/// Transform a C++ expression that contains cleanups that should
15529/// be run after the expression is evaluated.
15530///
15531/// Since ExprWithCleanups nodes are implicitly generated, we
15532/// just transform the subexpression and return that.
15533template<typename Derived>
15536 return getDerived().TransformExpr(E->getSubExpr());
15537}
15538
15539template<typename Derived>
15543 TypeSourceInfo *T =
15544 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15545 if (!T)
15546 return ExprError();
15547
15548 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15549 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15550 if (!Constructor)
15551 return ExprError();
15552
15553 bool ArgumentChanged = false;
15555 Args.reserve(E->getNumArgs());
15556 {
15559 E->isListInitialization());
15560 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15561 &ArgumentChanged))
15562 return ExprError();
15563
15564 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15565 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc());
15566 if (Res.isInvalid())
15567 return ExprError();
15568 Args = {Res.get()};
15569 }
15570 }
15571
15572 if (!getDerived().AlwaysRebuild() &&
15573 T == E->getTypeSourceInfo() &&
15574 Constructor == E->getConstructor() &&
15575 !ArgumentChanged) {
15576 // FIXME: Instantiation-specific
15577 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15578 return SemaRef.MaybeBindToTemporary(E);
15579 }
15580
15581 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15582 return getDerived().RebuildCXXTemporaryObjectExpr(
15583 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15584}
15585
15586template<typename Derived>
15589 // Transform any init-capture expressions before entering the scope of the
15590 // lambda body, because they are not semantically within that scope.
15591 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15592 struct TransformedInitCapture {
15593 // The location of the ... if the result is retaining a pack expansion.
15594 SourceLocation EllipsisLoc;
15595 // Zero or more expansions of the init-capture.
15596 SmallVector<InitCaptureInfoTy, 4> Expansions;
15597 };
15599 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15600 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15601 CEnd = E->capture_end();
15602 C != CEnd; ++C) {
15603 if (!E->isInitCapture(C))
15604 continue;
15605
15606 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15607 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15608
15609 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15610 UnsignedOrNone NumExpansions) {
15611 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15612 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15613
15614 if (NewExprInitResult.isInvalid()) {
15615 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15616 return;
15617 }
15618 Expr *NewExprInit = NewExprInitResult.get();
15619
15620 QualType NewInitCaptureType =
15621 getSema().buildLambdaInitCaptureInitialization(
15622 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15623 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15624 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15626 NewExprInit);
15627 Result.Expansions.push_back(
15628 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15629 };
15630
15631 // If this is an init-capture pack, consider expanding the pack now.
15632 if (OldVD->isParameterPack()) {
15633 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15634 ->getTypeLoc()
15637 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15638
15639 // Determine whether the set of unexpanded parameter packs can and should
15640 // be expanded.
15641 bool Expand = true;
15642 bool RetainExpansion = false;
15643 UnsignedOrNone OrigNumExpansions =
15644 ExpansionTL.getTypePtr()->getNumExpansions();
15645 UnsignedOrNone NumExpansions = OrigNumExpansions;
15646 if (getDerived().TryExpandParameterPacks(
15647 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15648 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15649 RetainExpansion, NumExpansions))
15650 return ExprError();
15651 assert(!RetainExpansion && "Should not need to retain expansion after a "
15652 "capture since it cannot be extended");
15653 if (Expand) {
15654 for (unsigned I = 0; I != *NumExpansions; ++I) {
15655 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15656 SubstInitCapture(SourceLocation(), std::nullopt);
15657 }
15658 } else {
15659 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15660 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15661 }
15662 } else {
15663 SubstInitCapture(SourceLocation(), std::nullopt);
15664 }
15665 }
15666
15667 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15668 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15669
15670 // Create the local class that will describe the lambda.
15671
15672 // FIXME: DependencyKind below is wrong when substituting inside a templated
15673 // context that isn't a DeclContext (such as a variable template), or when
15674 // substituting an unevaluated lambda inside of a function's parameter's type
15675 // - as parameter types are not instantiated from within a function's DC. We
15676 // use evaluation contexts to distinguish the function parameter case.
15679 DeclContext *DC = getSema().CurContext;
15680 // A RequiresExprBodyDecl is not interesting for dependencies.
15681 // For the following case,
15682 //
15683 // template <typename>
15684 // concept C = requires { [] {}; };
15685 //
15686 // template <class F>
15687 // struct Widget;
15688 //
15689 // template <C F>
15690 // struct Widget<F> {};
15691 //
15692 // While we are substituting Widget<F>, the parent of DC would be
15693 // the template specialization itself. Thus, the lambda expression
15694 // will be deemed as dependent even if there are no dependent template
15695 // arguments.
15696 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15697 while (DC->isRequiresExprBody())
15698 DC = DC->getParent();
15699 if ((getSema().isUnevaluatedContext() ||
15700 getSema().isConstantEvaluatedContext()) &&
15701 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15702 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
15703 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15704 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15705
15706 CXXRecordDecl *OldClass = E->getLambdaClass();
15707 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15708 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15709 E->getCaptureDefault());
15710 getDerived().transformedLocalDecl(OldClass, {Class});
15711
15712 CXXMethodDecl *NewCallOperator =
15713 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15714
15715 // Enter the scope of the lambda.
15716 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15717 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15718 E->hasExplicitParameters(), E->isMutable());
15719
15720 // Introduce the context of the call operator.
15721 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15722 /*NewThisContext*/false);
15723
15724 bool Invalid = false;
15725
15726 // Transform captures.
15727 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15728 CEnd = E->capture_end();
15729 C != CEnd; ++C) {
15730 // When we hit the first implicit capture, tell Sema that we've finished
15731 // the list of explicit captures.
15732 if (C->isImplicit())
15733 break;
15734
15735 // Capturing 'this' is trivial.
15736 if (C->capturesThis()) {
15737 // If this is a lambda that is part of a default member initialiser
15738 // and which we're instantiating outside the class that 'this' is
15739 // supposed to refer to, adjust the type of 'this' accordingly.
15740 //
15741 // Otherwise, leave the type of 'this' as-is.
15742 Sema::CXXThisScopeRAII ThisScope(
15743 getSema(),
15744 dyn_cast_if_present<CXXRecordDecl>(
15745 getSema().getFunctionLevelDeclContext()),
15746 Qualifiers());
15747 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15748 /*BuildAndDiagnose*/ true, nullptr,
15749 C->getCaptureKind() == LCK_StarThis);
15750 continue;
15751 }
15752 // Captured expression will be recaptured during captured variables
15753 // rebuilding.
15754 if (C->capturesVLAType())
15755 continue;
15756
15757 // Rebuild init-captures, including the implied field declaration.
15758 if (E->isInitCapture(C)) {
15759 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15760
15761 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15763
15764 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15765 ExprResult Init = Info.first;
15766 QualType InitQualType = Info.second;
15767 if (Init.isInvalid() || InitQualType.isNull()) {
15768 Invalid = true;
15769 break;
15770 }
15771 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15772 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15773 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15774 getSema().CurContext);
15775 if (!NewVD) {
15776 Invalid = true;
15777 break;
15778 }
15779 NewVDs.push_back(NewVD);
15780 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15781 // Cases we want to tackle:
15782 // ([C(Pack)] {}, ...)
15783 // But rule out cases e.g.
15784 // [...C = Pack()] {}
15785 if (NewC.EllipsisLoc.isInvalid())
15786 LSI->ContainsUnexpandedParameterPack |=
15787 Init.get()->containsUnexpandedParameterPack();
15788 }
15789
15790 if (Invalid)
15791 break;
15792
15793 getDerived().transformedLocalDecl(OldVD, NewVDs);
15794 continue;
15795 }
15796
15797 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15798
15799 // Determine the capture kind for Sema.
15801 : C->getCaptureKind() == LCK_ByCopy
15804 SourceLocation EllipsisLoc;
15805 if (C->isPackExpansion()) {
15806 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15807 bool ShouldExpand = false;
15808 bool RetainExpansion = false;
15809 UnsignedOrNone NumExpansions = std::nullopt;
15810 if (getDerived().TryExpandParameterPacks(
15811 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
15812 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
15813 RetainExpansion, NumExpansions)) {
15814 Invalid = true;
15815 continue;
15816 }
15817
15818 if (ShouldExpand) {
15819 // The transform has determined that we should perform an expansion;
15820 // transform and capture each of the arguments.
15821 // expansion of the pattern. Do so.
15822 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
15823 for (unsigned I = 0; I != *NumExpansions; ++I) {
15824 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15825 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
15826 getDerived().TransformDecl(C->getLocation(), Pack));
15827 if (!CapturedVar) {
15828 Invalid = true;
15829 continue;
15830 }
15831
15832 // Capture the transformed variable.
15833 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
15834 }
15835
15836 // FIXME: Retain a pack expansion if RetainExpansion is true.
15837
15838 continue;
15839 }
15840
15841 EllipsisLoc = C->getEllipsisLoc();
15842 }
15843
15844 // Transform the captured variable.
15845 auto *CapturedVar = cast_or_null<ValueDecl>(
15846 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15847 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
15848 Invalid = true;
15849 continue;
15850 }
15851
15852 // This is not an init-capture; however it contains an unexpanded pack e.g.
15853 // ([Pack] {}(), ...)
15854 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
15855 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
15856
15857 // Capture the transformed variable.
15858 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
15859 EllipsisLoc);
15860 }
15861 getSema().finishLambdaExplicitCaptures(LSI);
15862
15863 // Transform the template parameters, and add them to the current
15864 // instantiation scope. The null case is handled correctly.
15865 auto TPL = getDerived().TransformTemplateParameterList(
15866 E->getTemplateParameterList());
15867 LSI->GLTemplateParameterList = TPL;
15868 if (TPL) {
15869 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
15870 TPL);
15871 LSI->ContainsUnexpandedParameterPack |=
15872 TPL->containsUnexpandedParameterPack();
15873 }
15874
15875 TypeLocBuilder NewCallOpTLBuilder;
15876 TypeLoc OldCallOpTypeLoc =
15877 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
15878 QualType NewCallOpType =
15879 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
15880 if (NewCallOpType.isNull())
15881 return ExprError();
15882 LSI->ContainsUnexpandedParameterPack |=
15883 NewCallOpType->containsUnexpandedParameterPack();
15884 TypeSourceInfo *NewCallOpTSI =
15885 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
15886
15887 // The type may be an AttributedType or some other kind of sugar;
15888 // get the actual underlying FunctionProtoType.
15889 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
15890 assert(FPTL && "Not a FunctionProtoType?");
15891
15892 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
15893 if (!TRC.ArgPackSubstIndex)
15895
15896 getSema().CompleteLambdaCallOperator(
15897 NewCallOperator, E->getCallOperator()->getLocation(),
15898 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
15899 E->getCallOperator()->getConstexprKind(),
15900 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
15901 E->hasExplicitResultType());
15902
15903 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
15904 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
15905
15906 {
15907 // Number the lambda for linkage purposes if necessary.
15908 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
15909
15910 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
15911 if (getDerived().ReplacingOriginal()) {
15912 Numbering = OldClass->getLambdaNumbering();
15913 }
15914
15915 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
15916 }
15917
15918 // FIXME: Sema's lambda-building mechanism expects us to push an expression
15919 // evaluation context even if we're not transforming the function body.
15920 getSema().PushExpressionEvaluationContextForFunction(
15922 E->getCallOperator());
15923
15924 StmtResult Body;
15925 {
15926 Sema::NonSFINAEContext _(getSema());
15929 C.PointOfInstantiation = E->getBody()->getBeginLoc();
15930 getSema().pushCodeSynthesisContext(C);
15931
15932 // Instantiate the body of the lambda expression.
15933 Body = Invalid ? StmtError()
15934 : getDerived().TransformLambdaBody(E, E->getBody());
15935
15936 getSema().popCodeSynthesisContext();
15937 }
15938
15939 // ActOnLambda* will pop the function scope for us.
15940 FuncScopeCleanup.disable();
15941
15942 if (Body.isInvalid()) {
15943 SavedContext.pop();
15944 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
15945 /*IsInstantiation=*/true);
15946 return ExprError();
15947 }
15948
15949 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
15950 /*IsInstantiation=*/true,
15951 /*RetainFunctionScopeInfo=*/true);
15952 SavedContext.pop();
15953
15954 // Recompute the dependency of the lambda so that we can defer the lambda call
15955 // construction until after we have all the necessary template arguments. For
15956 // example, given
15957 //
15958 // template <class> struct S {
15959 // template <class U>
15960 // using Type = decltype([](U){}(42.0));
15961 // };
15962 // void foo() {
15963 // using T = S<int>::Type<float>;
15964 // ^~~~~~
15965 // }
15966 //
15967 // We would end up here from instantiating S<int> when ensuring its
15968 // completeness. That would transform the lambda call expression regardless of
15969 // the absence of the corresponding argument for U.
15970 //
15971 // Going ahead with unsubstituted type U makes things worse: we would soon
15972 // compare the argument type (which is float) against the parameter U
15973 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
15974 // error suggesting unmatched types 'U' and 'float'!
15975 //
15976 // That said, everything will be fine if we defer that semantic checking.
15977 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
15978 // dependent. Since the CallExpr's dependency boils down to the lambda's
15979 // dependency in this case, we can harness that by recomputing the dependency
15980 // from the instantiation arguments.
15981 //
15982 // FIXME: Creating the type of a lambda requires us to have a dependency
15983 // value, which happens before its substitution. We update its dependency
15984 // *after* the substitution in case we can't decide the dependency
15985 // so early, e.g. because we want to see if any of the *substituted*
15986 // parameters are dependent.
15987 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
15988 Class->setLambdaDependencyKind(DependencyKind);
15989
15990 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
15991 Body.get()->getEndLoc(), LSI);
15992}
15993
15994template<typename Derived>
15999
16000template<typename Derived>
16003 // Transform captures.
16005 CEnd = E->capture_end();
16006 C != CEnd; ++C) {
16007 // When we hit the first implicit capture, tell Sema that we've finished
16008 // the list of explicit captures.
16009 if (!C->isImplicit())
16010 continue;
16011
16012 // Capturing 'this' is trivial.
16013 if (C->capturesThis()) {
16014 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16015 /*BuildAndDiagnose*/ true, nullptr,
16016 C->getCaptureKind() == LCK_StarThis);
16017 continue;
16018 }
16019 // Captured expression will be recaptured during captured variables
16020 // rebuilding.
16021 if (C->capturesVLAType())
16022 continue;
16023
16024 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16025 assert(!E->isInitCapture(C) && "implicit init-capture?");
16026
16027 // Transform the captured variable.
16028 VarDecl *CapturedVar = cast_or_null<VarDecl>(
16029 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16030 if (!CapturedVar || CapturedVar->isInvalidDecl())
16031 return StmtError();
16032
16033 // Capture the transformed variable.
16034 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16035 }
16036
16037 return S;
16038}
16039
16040template<typename Derived>
16044 TypeSourceInfo *T =
16045 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16046 if (!T)
16047 return ExprError();
16048
16049 bool ArgumentChanged = false;
16051 Args.reserve(E->getNumArgs());
16052 {
16056 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16057 &ArgumentChanged))
16058 return ExprError();
16059 }
16060
16061 if (!getDerived().AlwaysRebuild() &&
16062 T == E->getTypeSourceInfo() &&
16063 !ArgumentChanged)
16064 return E;
16065
16066 // FIXME: we're faking the locations of the commas
16067 return getDerived().RebuildCXXUnresolvedConstructExpr(
16068 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16069}
16070
16071template<typename Derived>
16075 // Transform the base of the expression.
16076 ExprResult Base((Expr*) nullptr);
16077 Expr *OldBase;
16078 QualType BaseType;
16079 QualType ObjectType;
16080 if (!E->isImplicitAccess()) {
16081 OldBase = E->getBase();
16082 Base = getDerived().TransformExpr(OldBase);
16083 if (Base.isInvalid())
16084 return ExprError();
16085
16086 // Start the member reference and compute the object's type.
16087 ParsedType ObjectTy;
16088 bool MayBePseudoDestructor = false;
16089 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16090 E->getOperatorLoc(),
16091 E->isArrow()? tok::arrow : tok::period,
16092 ObjectTy,
16093 MayBePseudoDestructor);
16094 if (Base.isInvalid())
16095 return ExprError();
16096
16097 ObjectType = ObjectTy.get();
16098 BaseType = ((Expr*) Base.get())->getType();
16099 } else {
16100 OldBase = nullptr;
16101 BaseType = getDerived().TransformType(E->getBaseType());
16102 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16103 }
16104
16105 // Transform the first part of the nested-name-specifier that qualifies
16106 // the member name.
16107 NamedDecl *FirstQualifierInScope
16108 = getDerived().TransformFirstQualifierInScope(
16109 E->getFirstQualifierFoundInScope(),
16110 E->getQualifierLoc().getBeginLoc());
16111
16112 NestedNameSpecifierLoc QualifierLoc;
16113 if (E->getQualifier()) {
16114 QualifierLoc
16115 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16116 ObjectType,
16117 FirstQualifierInScope);
16118 if (!QualifierLoc)
16119 return ExprError();
16120 }
16121
16122 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16123
16124 // TODO: If this is a conversion-function-id, verify that the
16125 // destination type name (if present) resolves the same way after
16126 // instantiation as it did in the local scope.
16127
16128 DeclarationNameInfo NameInfo
16129 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16130 if (!NameInfo.getName())
16131 return ExprError();
16132
16133 if (!E->hasExplicitTemplateArgs()) {
16134 // This is a reference to a member without an explicitly-specified
16135 // template argument list. Optimize for this common case.
16136 if (!getDerived().AlwaysRebuild() &&
16137 Base.get() == OldBase &&
16138 BaseType == E->getBaseType() &&
16139 QualifierLoc == E->getQualifierLoc() &&
16140 NameInfo.getName() == E->getMember() &&
16141 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16142 return E;
16143
16144 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16145 BaseType,
16146 E->isArrow(),
16147 E->getOperatorLoc(),
16148 QualifierLoc,
16149 TemplateKWLoc,
16150 FirstQualifierInScope,
16151 NameInfo,
16152 /*TemplateArgs*/nullptr);
16153 }
16154
16155 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16156 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16157 E->getNumTemplateArgs(),
16158 TransArgs))
16159 return ExprError();
16160
16161 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16162 BaseType,
16163 E->isArrow(),
16164 E->getOperatorLoc(),
16165 QualifierLoc,
16166 TemplateKWLoc,
16167 FirstQualifierInScope,
16168 NameInfo,
16169 &TransArgs);
16170}
16171
16172template <typename Derived>
16174 UnresolvedMemberExpr *Old) {
16175 // Transform the base of the expression.
16176 ExprResult Base((Expr *)nullptr);
16177 QualType BaseType;
16178 if (!Old->isImplicitAccess()) {
16179 Base = getDerived().TransformExpr(Old->getBase());
16180 if (Base.isInvalid())
16181 return ExprError();
16182 Base =
16183 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16184 if (Base.isInvalid())
16185 return ExprError();
16186 BaseType = Base.get()->getType();
16187 } else {
16188 BaseType = getDerived().TransformType(Old->getBaseType());
16189 }
16190
16191 NestedNameSpecifierLoc QualifierLoc;
16192 if (Old->getQualifierLoc()) {
16193 QualifierLoc =
16194 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16195 if (!QualifierLoc)
16196 return ExprError();
16197 }
16198
16199 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16200
16201 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16202
16203 // Transform the declaration set.
16204 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16205 return ExprError();
16206
16207 // Determine the naming class.
16208 if (Old->getNamingClass()) {
16209 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16210 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16211 if (!NamingClass)
16212 return ExprError();
16213
16214 R.setNamingClass(NamingClass);
16215 }
16216
16217 TemplateArgumentListInfo TransArgs;
16218 if (Old->hasExplicitTemplateArgs()) {
16219 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16220 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16221 if (getDerived().TransformTemplateArguments(
16222 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16223 return ExprError();
16224 }
16225
16226 // FIXME: to do this check properly, we will need to preserve the
16227 // first-qualifier-in-scope here, just in case we had a dependent
16228 // base (and therefore couldn't do the check) and a
16229 // nested-name-qualifier (and therefore could do the lookup).
16230 NamedDecl *FirstQualifierInScope = nullptr;
16231
16232 return getDerived().RebuildUnresolvedMemberExpr(
16233 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16234 TemplateKWLoc, FirstQualifierInScope, R,
16235 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16236}
16237
16238template<typename Derived>
16243 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16244 if (SubExpr.isInvalid())
16245 return ExprError();
16246
16247 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16248 return E;
16249
16250 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16251}
16252
16253template<typename Derived>
16256 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16257 if (Pattern.isInvalid())
16258 return ExprError();
16259
16260 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16261 return E;
16262
16263 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16264 E->getNumExpansions());
16265}
16266
16267template <typename Derived>
16269 ArrayRef<TemplateArgument> PackArgs) {
16271 for (const TemplateArgument &Arg : PackArgs) {
16272 if (!Arg.isPackExpansion()) {
16273 Result = *Result + 1;
16274 continue;
16275 }
16276
16277 TemplateArgumentLoc ArgLoc;
16278 InventTemplateArgumentLoc(Arg, ArgLoc);
16279
16280 // Find the pattern of the pack expansion.
16281 SourceLocation Ellipsis;
16282 UnsignedOrNone OrigNumExpansions = std::nullopt;
16283 TemplateArgumentLoc Pattern =
16284 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16285 OrigNumExpansions);
16286
16287 // Substitute under the pack expansion. Do not expand the pack (yet).
16288 TemplateArgumentLoc OutPattern;
16289 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16290 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16291 /*Uneval*/ true))
16292 return 1u;
16293
16294 // See if we can determine the number of arguments from the result.
16295 UnsignedOrNone NumExpansions =
16296 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16297 if (!NumExpansions) {
16298 // No: we must be in an alias template expansion, and we're going to
16299 // need to actually expand the packs.
16300 Result = std::nullopt;
16301 break;
16302 }
16303
16304 Result = *Result + *NumExpansions;
16305 }
16306 return Result;
16307}
16308
16309template<typename Derived>
16312 // If E is not value-dependent, then nothing will change when we transform it.
16313 // Note: This is an instantiation-centric view.
16314 if (!E->isValueDependent())
16315 return E;
16316
16319
16321 TemplateArgument ArgStorage;
16322
16323 // Find the argument list to transform.
16324 if (E->isPartiallySubstituted()) {
16325 PackArgs = E->getPartialArguments();
16326 } else if (E->isValueDependent()) {
16327 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16328 bool ShouldExpand = false;
16329 bool RetainExpansion = false;
16330 UnsignedOrNone NumExpansions = std::nullopt;
16331 if (getDerived().TryExpandParameterPacks(
16332 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16333 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16334 RetainExpansion, NumExpansions))
16335 return ExprError();
16336
16337 // If we need to expand the pack, build a template argument from it and
16338 // expand that.
16339 if (ShouldExpand) {
16340 auto *Pack = E->getPack();
16341 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16342 ArgStorage = getSema().Context.getPackExpansionType(
16343 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16344 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16345 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16346 } else {
16347 auto *VD = cast<ValueDecl>(Pack);
16348 ExprResult DRE = getSema().BuildDeclRefExpr(
16349 VD, VD->getType().getNonLValueExprType(getSema().Context),
16350 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16351 E->getPackLoc());
16352 if (DRE.isInvalid())
16353 return ExprError();
16354 ArgStorage = TemplateArgument(
16355 new (getSema().Context)
16356 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16357 /*IsCanonical=*/false);
16358 }
16359 PackArgs = ArgStorage;
16360 }
16361 }
16362
16363 // If we're not expanding the pack, just transform the decl.
16364 if (!PackArgs.size()) {
16365 auto *Pack = cast_or_null<NamedDecl>(
16366 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16367 if (!Pack)
16368 return ExprError();
16369 return getDerived().RebuildSizeOfPackExpr(
16370 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16371 std::nullopt, {});
16372 }
16373
16374 // Try to compute the result without performing a partial substitution.
16376 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16377
16378 // Common case: we could determine the number of expansions without
16379 // substituting.
16380 if (Result)
16381 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16382 E->getPackLoc(),
16383 E->getRParenLoc(), *Result, {});
16384
16385 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16386 E->getPackLoc());
16387 {
16388 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16390 Derived, const TemplateArgument*> PackLocIterator;
16391 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16392 PackLocIterator(*this, PackArgs.end()),
16393 TransformedPackArgs, /*Uneval*/true))
16394 return ExprError();
16395 }
16396
16397 // Check whether we managed to fully-expand the pack.
16398 // FIXME: Is it possible for us to do so and not hit the early exit path?
16400 bool PartialSubstitution = false;
16401 for (auto &Loc : TransformedPackArgs.arguments()) {
16402 Args.push_back(Loc.getArgument());
16403 if (Loc.getArgument().isPackExpansion())
16404 PartialSubstitution = true;
16405 }
16406
16407 if (PartialSubstitution)
16408 return getDerived().RebuildSizeOfPackExpr(
16409 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16410 std::nullopt, Args);
16411
16412 return getDerived().RebuildSizeOfPackExpr(
16413 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16414 /*Length=*/static_cast<unsigned>(Args.size()),
16415 /*PartialArgs=*/{});
16416}
16417
16418template <typename Derived>
16421 if (!E->isValueDependent())
16422 return E;
16423
16424 // Transform the index
16425 ExprResult IndexExpr;
16426 {
16427 EnterExpressionEvaluationContext ConstantContext(
16429 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16430 if (IndexExpr.isInvalid())
16431 return ExprError();
16432 }
16433
16434 SmallVector<Expr *, 5> ExpandedExprs;
16435 bool FullySubstituted = true;
16436 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16437 Expr *Pattern = E->getPackIdExpression();
16439 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16440 Unexpanded);
16441 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16442
16443 // Determine whether the set of unexpanded parameter packs can and should
16444 // be expanded.
16445 bool ShouldExpand = true;
16446 bool RetainExpansion = false;
16447 UnsignedOrNone OrigNumExpansions = std::nullopt,
16448 NumExpansions = std::nullopt;
16449 if (getDerived().TryExpandParameterPacks(
16450 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16451 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16452 RetainExpansion, NumExpansions))
16453 return true;
16454 if (!ShouldExpand) {
16455 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16456 ExprResult Pack = getDerived().TransformExpr(Pattern);
16457 if (Pack.isInvalid())
16458 return ExprError();
16459 return getDerived().RebuildPackIndexingExpr(
16460 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16461 {}, /*FullySubstituted=*/false);
16462 }
16463 for (unsigned I = 0; I != *NumExpansions; ++I) {
16464 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16465 ExprResult Out = getDerived().TransformExpr(Pattern);
16466 if (Out.isInvalid())
16467 return true;
16468 if (Out.get()->containsUnexpandedParameterPack()) {
16469 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16470 OrigNumExpansions);
16471 if (Out.isInvalid())
16472 return true;
16473 FullySubstituted = false;
16474 }
16475 ExpandedExprs.push_back(Out.get());
16476 }
16477 // If we're supposed to retain a pack expansion, do so by temporarily
16478 // forgetting the partially-substituted parameter pack.
16479 if (RetainExpansion) {
16480 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16481
16482 ExprResult Out = getDerived().TransformExpr(Pattern);
16483 if (Out.isInvalid())
16484 return true;
16485
16486 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16487 OrigNumExpansions);
16488 if (Out.isInvalid())
16489 return true;
16490 FullySubstituted = false;
16491 ExpandedExprs.push_back(Out.get());
16492 }
16493 } else if (!E->expandsToEmptyPack()) {
16494 if (getDerived().TransformExprs(E->getExpressions().data(),
16495 E->getExpressions().size(), false,
16496 ExpandedExprs))
16497 return ExprError();
16498 }
16499
16500 return getDerived().RebuildPackIndexingExpr(
16501 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16502 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16503}
16504
16505template <typename Derived>
16508 if (!getSema().ArgPackSubstIndex)
16509 // We aren't expanding the parameter pack, so just return ourselves.
16510 return E;
16511
16512 TemplateArgument Pack = E->getArgumentPack();
16514 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16515 E->getAssociatedDecl(), E->getParameterPack(),
16516 E->getParameterPackLocation(), Arg, SemaRef.getPackIndex(Pack),
16517 E->getFinal());
16518}
16519
16520template <typename Derived>
16523 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16524 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16525 if (Replacement.isInvalid())
16526 return true;
16527
16528 Decl *AssociatedDecl =
16529 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16530 if (!AssociatedDecl)
16531 return true;
16532
16533 if (Replacement.get() == OrigReplacement &&
16534 AssociatedDecl == E->getAssociatedDecl())
16535 return E;
16536
16537 auto getParamAndType = [E](Decl *AssociatedDecl)
16538 -> std::tuple<NonTypeTemplateParmDecl *, QualType> {
16539 auto [PDecl, Arg] =
16540 getReplacedTemplateParameter(AssociatedDecl, E->getIndex());
16541 auto *Param = cast<NonTypeTemplateParmDecl>(PDecl);
16542 if (Arg.isNull())
16543 return {Param, Param->getType()};
16544 if (UnsignedOrNone PackIndex = E->getPackIndex())
16545 Arg = Arg.getPackAsArray()[*PackIndex];
16546 return {Param, Arg.getNonTypeTemplateArgumentType()};
16547 };
16548
16549 // If the replacement expression did not change, and the parameter type
16550 // did not change, we can skip the semantic action because it would
16551 // produce the same result anyway.
16552 if (auto [Param, ParamType] = getParamAndType(AssociatedDecl);
16553 !SemaRef.Context.hasSameType(
16554 ParamType, std::get<1>(getParamAndType(E->getAssociatedDecl()))) ||
16555 Replacement.get() != OrigReplacement) {
16556 // When transforming the replacement expression previously, all Sema
16557 // specific annotations, such as implicit casts, are discarded. Calling the
16558 // corresponding sema action is necessary to recover those. Otherwise,
16559 // equivalency of the result would be lost.
16560 TemplateArgument SugaredConverted, CanonicalConverted;
16561 Replacement = SemaRef.CheckTemplateArgument(
16562 Param, ParamType, Replacement.get(), SugaredConverted,
16563 CanonicalConverted,
16564 /*StrictCheck=*/false, Sema::CTAK_Specified);
16565 if (Replacement.isInvalid())
16566 return true;
16567 } else {
16568 // Otherwise, the same expression would have been produced.
16569 Replacement = E->getReplacement();
16570 }
16571
16572 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16573 AssociatedDecl, E->getParameter(), E->getNameLoc(),
16574 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
16575 E->getPackIndex(), E->getFinal());
16576}
16577
16578template<typename Derived>
16581 // Default behavior is to do nothing with this transformation.
16582 return E;
16583}
16584
16585template<typename Derived>
16589 return getDerived().TransformExpr(E->getSubExpr());
16590}
16591
16592template<typename Derived>
16595 UnresolvedLookupExpr *Callee = nullptr;
16596 if (Expr *OldCallee = E->getCallee()) {
16597 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16598 if (CalleeResult.isInvalid())
16599 return ExprError();
16600 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16601 }
16602
16603 Expr *Pattern = E->getPattern();
16604
16606 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16607 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16608
16609 // Determine whether the set of unexpanded parameter packs can and should
16610 // be expanded.
16611 bool Expand = true;
16612 bool RetainExpansion = false;
16613 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16614 NumExpansions = OrigNumExpansions;
16615 if (getDerived().TryExpandParameterPacks(
16616 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16617 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16618 NumExpansions))
16619 return true;
16620
16621 if (!Expand) {
16622 // Do not expand any packs here, just transform and rebuild a fold
16623 // expression.
16624 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16625
16626 ExprResult LHS =
16627 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16628 if (LHS.isInvalid())
16629 return true;
16630
16631 ExprResult RHS =
16632 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16633 if (RHS.isInvalid())
16634 return true;
16635
16636 if (!getDerived().AlwaysRebuild() &&
16637 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16638 return E;
16639
16640 return getDerived().RebuildCXXFoldExpr(
16641 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16642 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16643 }
16644
16645 // Formally a fold expression expands to nested parenthesized expressions.
16646 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16647 // them.
16648 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16649 SemaRef.Diag(E->getEllipsisLoc(),
16650 clang::diag::err_fold_expression_limit_exceeded)
16651 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16652 << E->getSourceRange();
16653 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16654 return ExprError();
16655 }
16656
16657 // The transform has determined that we should perform an elementwise
16658 // expansion of the pattern. Do so.
16659 ExprResult Result = getDerived().TransformExpr(E->getInit());
16660 if (Result.isInvalid())
16661 return true;
16662 bool LeftFold = E->isLeftFold();
16663
16664 // If we're retaining an expansion for a right fold, it is the innermost
16665 // component and takes the init (if any).
16666 if (!LeftFold && RetainExpansion) {
16667 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16668
16669 ExprResult Out = getDerived().TransformExpr(Pattern);
16670 if (Out.isInvalid())
16671 return true;
16672
16673 Result = getDerived().RebuildCXXFoldExpr(
16674 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16675 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16676 if (Result.isInvalid())
16677 return true;
16678 }
16679
16680 bool WarnedOnComparison = false;
16681 for (unsigned I = 0; I != *NumExpansions; ++I) {
16682 Sema::ArgPackSubstIndexRAII SubstIndex(
16683 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16684 ExprResult Out = getDerived().TransformExpr(Pattern);
16685 if (Out.isInvalid())
16686 return true;
16687
16688 if (Out.get()->containsUnexpandedParameterPack()) {
16689 // We still have a pack; retain a pack expansion for this slice.
16690 Result = getDerived().RebuildCXXFoldExpr(
16691 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16692 E->getOperator(), E->getEllipsisLoc(),
16693 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16694 OrigNumExpansions);
16695 } else if (Result.isUsable()) {
16696 // We've got down to a single element; build a binary operator.
16697 Expr *LHS = LeftFold ? Result.get() : Out.get();
16698 Expr *RHS = LeftFold ? Out.get() : Result.get();
16699 if (Callee) {
16700 UnresolvedSet<16> Functions;
16701 Functions.append(Callee->decls_begin(), Callee->decls_end());
16702 Result = getDerived().RebuildCXXOperatorCallExpr(
16703 BinaryOperator::getOverloadedOperator(E->getOperator()),
16704 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16705 Functions, LHS, RHS);
16706 } else {
16707 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16708 E->getOperator(), LHS, RHS,
16709 /*ForFoldExpresion=*/true);
16710 if (!WarnedOnComparison && Result.isUsable()) {
16711 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16712 BO && BO->isComparisonOp()) {
16713 WarnedOnComparison = true;
16714 SemaRef.Diag(BO->getBeginLoc(),
16715 diag::warn_comparison_in_fold_expression)
16716 << BO->getOpcodeStr();
16717 }
16718 }
16719 }
16720 } else
16721 Result = Out;
16722
16723 if (Result.isInvalid())
16724 return true;
16725 }
16726
16727 // If we're retaining an expansion for a left fold, it is the outermost
16728 // component and takes the complete expansion so far as its init (if any).
16729 if (LeftFold && RetainExpansion) {
16730 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16731
16732 ExprResult Out = getDerived().TransformExpr(Pattern);
16733 if (Out.isInvalid())
16734 return true;
16735
16736 Result = getDerived().RebuildCXXFoldExpr(
16737 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16738 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16739 if (Result.isInvalid())
16740 return true;
16741 }
16742
16743 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16744 PE->setIsProducedByFoldExpansion();
16745
16746 // If we had no init and an empty pack, and we're not retaining an expansion,
16747 // then produce a fallback value or error.
16748 if (Result.isUnset())
16749 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16750 E->getOperator());
16751 return Result;
16752}
16753
16754template <typename Derived>
16757 SmallVector<Expr *, 4> TransformedInits;
16758 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16759
16760 QualType T = getDerived().TransformType(E->getType());
16761
16762 bool ArgChanged = false;
16763
16764 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16765 TransformedInits, &ArgChanged))
16766 return ExprError();
16767
16768 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16769 return E;
16770
16771 return getDerived().RebuildCXXParenListInitExpr(
16772 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16773 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16774}
16775
16776template<typename Derived>
16780 return getDerived().TransformExpr(E->getSubExpr());
16781}
16782
16783template<typename Derived>
16786 return SemaRef.MaybeBindToTemporary(E);
16787}
16788
16789template<typename Derived>
16792 return E;
16793}
16794
16795template<typename Derived>
16798 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16799 if (SubExpr.isInvalid())
16800 return ExprError();
16801
16802 if (!getDerived().AlwaysRebuild() &&
16803 SubExpr.get() == E->getSubExpr())
16804 return E;
16805
16806 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16807}
16808
16809template<typename Derived>
16812 // Transform each of the elements.
16813 SmallVector<Expr *, 8> Elements;
16814 bool ArgChanged = false;
16815 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
16816 /*IsCall=*/false, Elements, &ArgChanged))
16817 return ExprError();
16818
16819 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16820 return SemaRef.MaybeBindToTemporary(E);
16821
16822 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
16823 Elements.data(),
16824 Elements.size());
16825}
16826
16827template<typename Derived>
16831 // Transform each of the elements.
16833 bool ArgChanged = false;
16834 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
16835 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
16836
16837 if (OrigElement.isPackExpansion()) {
16838 // This key/value element is a pack expansion.
16840 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
16841 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
16842 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16843
16844 // Determine whether the set of unexpanded parameter packs can
16845 // and should be expanded.
16846 bool Expand = true;
16847 bool RetainExpansion = false;
16848 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
16849 UnsignedOrNone NumExpansions = OrigNumExpansions;
16850 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
16851 OrigElement.Value->getEndLoc());
16852 if (getDerived().TryExpandParameterPacks(
16853 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
16854 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16855 NumExpansions))
16856 return ExprError();
16857
16858 if (!Expand) {
16859 // The transform has determined that we should perform a simple
16860 // transformation on the pack expansion, producing another pack
16861 // expansion.
16862 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16863 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16864 if (Key.isInvalid())
16865 return ExprError();
16866
16867 if (Key.get() != OrigElement.Key)
16868 ArgChanged = true;
16869
16870 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16871 if (Value.isInvalid())
16872 return ExprError();
16873
16874 if (Value.get() != OrigElement.Value)
16875 ArgChanged = true;
16876
16877 ObjCDictionaryElement Expansion = {
16878 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
16879 };
16880 Elements.push_back(Expansion);
16881 continue;
16882 }
16883
16884 // Record right away that the argument was changed. This needs
16885 // to happen even if the array expands to nothing.
16886 ArgChanged = true;
16887
16888 // The transform has determined that we should perform an elementwise
16889 // expansion of the pattern. Do so.
16890 for (unsigned I = 0; I != *NumExpansions; ++I) {
16891 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16892 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16893 if (Key.isInvalid())
16894 return ExprError();
16895
16896 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16897 if (Value.isInvalid())
16898 return ExprError();
16899
16900 ObjCDictionaryElement Element = {
16901 Key.get(), Value.get(), SourceLocation(), NumExpansions
16902 };
16903
16904 // If any unexpanded parameter packs remain, we still have a
16905 // pack expansion.
16906 // FIXME: Can this really happen?
16907 if (Key.get()->containsUnexpandedParameterPack() ||
16908 Value.get()->containsUnexpandedParameterPack())
16909 Element.EllipsisLoc = OrigElement.EllipsisLoc;
16910
16911 Elements.push_back(Element);
16912 }
16913
16914 // FIXME: Retain a pack expansion if RetainExpansion is true.
16915
16916 // We've finished with this pack expansion.
16917 continue;
16918 }
16919
16920 // Transform and check key.
16921 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16922 if (Key.isInvalid())
16923 return ExprError();
16924
16925 if (Key.get() != OrigElement.Key)
16926 ArgChanged = true;
16927
16928 // Transform and check value.
16930 = getDerived().TransformExpr(OrigElement.Value);
16931 if (Value.isInvalid())
16932 return ExprError();
16933
16934 if (Value.get() != OrigElement.Value)
16935 ArgChanged = true;
16936
16937 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
16938 std::nullopt};
16939 Elements.push_back(Element);
16940 }
16941
16942 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16943 return SemaRef.MaybeBindToTemporary(E);
16944
16945 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
16946 Elements);
16947}
16948
16949template<typename Derived>
16952 TypeSourceInfo *EncodedTypeInfo
16953 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
16954 if (!EncodedTypeInfo)
16955 return ExprError();
16956
16957 if (!getDerived().AlwaysRebuild() &&
16958 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
16959 return E;
16960
16961 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
16962 EncodedTypeInfo,
16963 E->getRParenLoc());
16964}
16965
16966template<typename Derived>
16969 // This is a kind of implicit conversion, and it needs to get dropped
16970 // and recomputed for the same general reasons that ImplicitCastExprs
16971 // do, as well a more specific one: this expression is only valid when
16972 // it appears *immediately* as an argument expression.
16973 return getDerived().TransformExpr(E->getSubExpr());
16974}
16975
16976template<typename Derived>
16979 TypeSourceInfo *TSInfo
16980 = getDerived().TransformType(E->getTypeInfoAsWritten());
16981 if (!TSInfo)
16982 return ExprError();
16983
16984 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
16985 if (Result.isInvalid())
16986 return ExprError();
16987
16988 if (!getDerived().AlwaysRebuild() &&
16989 TSInfo == E->getTypeInfoAsWritten() &&
16990 Result.get() == E->getSubExpr())
16991 return E;
16992
16993 return SemaRef.ObjC().BuildObjCBridgedCast(
16994 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
16995 Result.get());
16996}
16997
16998template <typename Derived>
17001 return E;
17002}
17003
17004template<typename Derived>
17007 // Transform arguments.
17008 bool ArgChanged = false;
17010 Args.reserve(E->getNumArgs());
17011 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
17012 &ArgChanged))
17013 return ExprError();
17014
17015 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
17016 // Class message: transform the receiver type.
17017 TypeSourceInfo *ReceiverTypeInfo
17018 = getDerived().TransformType(E->getClassReceiverTypeInfo());
17019 if (!ReceiverTypeInfo)
17020 return ExprError();
17021
17022 // If nothing changed, just retain the existing message send.
17023 if (!getDerived().AlwaysRebuild() &&
17024 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
17025 return SemaRef.MaybeBindToTemporary(E);
17026
17027 // Build a new class message send.
17029 E->getSelectorLocs(SelLocs);
17030 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
17031 E->getSelector(),
17032 SelLocs,
17033 E->getMethodDecl(),
17034 E->getLeftLoc(),
17035 Args,
17036 E->getRightLoc());
17037 }
17038 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17039 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17040 if (!E->getMethodDecl())
17041 return ExprError();
17042
17043 // Build a new class message send to 'super'.
17045 E->getSelectorLocs(SelLocs);
17046 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17047 E->getSelector(),
17048 SelLocs,
17049 E->getReceiverType(),
17050 E->getMethodDecl(),
17051 E->getLeftLoc(),
17052 Args,
17053 E->getRightLoc());
17054 }
17055
17056 // Instance message: transform the receiver
17057 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17058 "Only class and instance messages may be instantiated");
17059 ExprResult Receiver
17060 = getDerived().TransformExpr(E->getInstanceReceiver());
17061 if (Receiver.isInvalid())
17062 return ExprError();
17063
17064 // If nothing changed, just retain the existing message send.
17065 if (!getDerived().AlwaysRebuild() &&
17066 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17067 return SemaRef.MaybeBindToTemporary(E);
17068
17069 // Build a new instance message send.
17071 E->getSelectorLocs(SelLocs);
17072 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17073 E->getSelector(),
17074 SelLocs,
17075 E->getMethodDecl(),
17076 E->getLeftLoc(),
17077 Args,
17078 E->getRightLoc());
17079}
17080
17081template<typename Derived>
17084 return E;
17085}
17086
17087template<typename Derived>
17090 return E;
17091}
17092
17093template<typename Derived>
17096 // Transform the base expression.
17097 ExprResult Base = getDerived().TransformExpr(E->getBase());
17098 if (Base.isInvalid())
17099 return ExprError();
17100
17101 // We don't need to transform the ivar; it will never change.
17102
17103 // If nothing changed, just retain the existing expression.
17104 if (!getDerived().AlwaysRebuild() &&
17105 Base.get() == E->getBase())
17106 return E;
17107
17108 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17109 E->getLocation(),
17110 E->isArrow(), E->isFreeIvar());
17111}
17112
17113template<typename Derived>
17116 // 'super' and types never change. Property never changes. Just
17117 // retain the existing expression.
17118 if (!E->isObjectReceiver())
17119 return E;
17120
17121 // Transform the base expression.
17122 ExprResult Base = getDerived().TransformExpr(E->getBase());
17123 if (Base.isInvalid())
17124 return ExprError();
17125
17126 // We don't need to transform the property; it will never change.
17127
17128 // If nothing changed, just retain the existing expression.
17129 if (!getDerived().AlwaysRebuild() &&
17130 Base.get() == E->getBase())
17131 return E;
17132
17133 if (E->isExplicitProperty())
17134 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17135 E->getExplicitProperty(),
17136 E->getLocation());
17137
17138 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17139 SemaRef.Context.PseudoObjectTy,
17140 E->getImplicitPropertyGetter(),
17141 E->getImplicitPropertySetter(),
17142 E->getLocation());
17143}
17144
17145template<typename Derived>
17148 // Transform the base expression.
17149 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17150 if (Base.isInvalid())
17151 return ExprError();
17152
17153 // Transform the key expression.
17154 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17155 if (Key.isInvalid())
17156 return ExprError();
17157
17158 // If nothing changed, just retain the existing expression.
17159 if (!getDerived().AlwaysRebuild() &&
17160 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17161 return E;
17162
17163 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17164 Base.get(), Key.get(),
17165 E->getAtIndexMethodDecl(),
17166 E->setAtIndexMethodDecl());
17167}
17168
17169template<typename Derived>
17172 // Transform the base expression.
17173 ExprResult Base = getDerived().TransformExpr(E->getBase());
17174 if (Base.isInvalid())
17175 return ExprError();
17176
17177 // If nothing changed, just retain the existing expression.
17178 if (!getDerived().AlwaysRebuild() &&
17179 Base.get() == E->getBase())
17180 return E;
17181
17182 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17183 E->getOpLoc(),
17184 E->isArrow());
17185}
17186
17187template<typename Derived>
17190 bool ArgumentChanged = false;
17191 SmallVector<Expr*, 8> SubExprs;
17192 SubExprs.reserve(E->getNumSubExprs());
17193 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17194 SubExprs, &ArgumentChanged))
17195 return ExprError();
17196
17197 if (!getDerived().AlwaysRebuild() &&
17198 !ArgumentChanged)
17199 return E;
17200
17201 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17202 SubExprs,
17203 E->getRParenLoc());
17204}
17205
17206template<typename Derived>
17209 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17210 if (SrcExpr.isInvalid())
17211 return ExprError();
17212
17213 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17214 if (!Type)
17215 return ExprError();
17216
17217 if (!getDerived().AlwaysRebuild() &&
17218 Type == E->getTypeSourceInfo() &&
17219 SrcExpr.get() == E->getSrcExpr())
17220 return E;
17221
17222 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17223 SrcExpr.get(), Type,
17224 E->getRParenLoc());
17225}
17226
17227template<typename Derived>
17230 BlockDecl *oldBlock = E->getBlockDecl();
17231
17232 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17233 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17234
17235 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17236 blockScope->TheDecl->setBlockMissingReturnType(
17237 oldBlock->blockMissingReturnType());
17238
17240 SmallVector<QualType, 4> paramTypes;
17241
17242 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17243
17244 // Parameter substitution.
17245 Sema::ExtParameterInfoBuilder extParamInfos;
17246 if (getDerived().TransformFunctionTypeParams(
17247 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17248 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17249 extParamInfos)) {
17250 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17251 return ExprError();
17252 }
17253
17254 QualType exprResultType =
17255 getDerived().TransformType(exprFunctionType->getReturnType());
17256
17257 auto epi = exprFunctionType->getExtProtoInfo();
17258 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17259
17261 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17262 blockScope->FunctionType = functionType;
17263
17264 // Set the parameters on the block decl.
17265 if (!params.empty())
17266 blockScope->TheDecl->setParams(params);
17267
17268 if (!oldBlock->blockMissingReturnType()) {
17269 blockScope->HasImplicitReturnType = false;
17270 blockScope->ReturnType = exprResultType;
17271 }
17272
17273 // Transform the body
17274 StmtResult body = getDerived().TransformStmt(E->getBody());
17275 if (body.isInvalid()) {
17276 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17277 return ExprError();
17278 }
17279
17280#ifndef NDEBUG
17281 // In builds with assertions, make sure that we captured everything we
17282 // captured before.
17283 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17284 for (const auto &I : oldBlock->captures()) {
17285 VarDecl *oldCapture = I.getVariable();
17286
17287 // Ignore parameter packs.
17288 if (oldCapture->isParameterPack())
17289 continue;
17290
17291 VarDecl *newCapture =
17292 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17293 oldCapture));
17294 assert(blockScope->CaptureMap.count(newCapture));
17295 }
17296
17297 // The this pointer may not be captured by the instantiated block, even when
17298 // it's captured by the original block, if the expression causing the
17299 // capture is in the discarded branch of a constexpr if statement.
17300 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17301 "this pointer isn't captured in the old block");
17302 }
17303#endif
17304
17305 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17306 /*Scope=*/nullptr);
17307}
17308
17309template<typename Derived>
17312 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17313 if (SrcExpr.isInvalid())
17314 return ExprError();
17315
17316 QualType Type = getDerived().TransformType(E->getType());
17317
17318 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17319 E->getRParenLoc());
17320}
17321
17322template<typename Derived>
17325 bool ArgumentChanged = false;
17326 SmallVector<Expr*, 8> SubExprs;
17327 SubExprs.reserve(E->getNumSubExprs());
17328 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17329 SubExprs, &ArgumentChanged))
17330 return ExprError();
17331
17332 if (!getDerived().AlwaysRebuild() &&
17333 !ArgumentChanged)
17334 return E;
17335
17336 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17337 E->getOp(), E->getRParenLoc());
17338}
17339
17340//===----------------------------------------------------------------------===//
17341// Type reconstruction
17342//===----------------------------------------------------------------------===//
17343
17344template<typename Derived>
17347 return SemaRef.BuildPointerType(PointeeType, Star,
17349}
17350
17351template<typename Derived>
17354 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17356}
17357
17358template<typename Derived>
17361 bool WrittenAsLValue,
17362 SourceLocation Sigil) {
17363 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17364 Sigil, getDerived().getBaseEntity());
17365}
17366
17367template <typename Derived>
17369 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17370 SourceLocation Sigil) {
17371 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17373}
17374
17375template<typename Derived>
17377 const ObjCTypeParamDecl *Decl,
17378 SourceLocation ProtocolLAngleLoc,
17380 ArrayRef<SourceLocation> ProtocolLocs,
17381 SourceLocation ProtocolRAngleLoc) {
17382 return SemaRef.ObjC().BuildObjCTypeParamType(
17383 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17384 /*FailOnError=*/true);
17385}
17386
17387template<typename Derived>
17389 QualType BaseType,
17390 SourceLocation Loc,
17391 SourceLocation TypeArgsLAngleLoc,
17393 SourceLocation TypeArgsRAngleLoc,
17394 SourceLocation ProtocolLAngleLoc,
17396 ArrayRef<SourceLocation> ProtocolLocs,
17397 SourceLocation ProtocolRAngleLoc) {
17398 return SemaRef.ObjC().BuildObjCObjectType(
17399 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17400 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17401 /*FailOnError=*/true,
17402 /*Rebuilding=*/true);
17403}
17404
17405template<typename Derived>
17407 QualType PointeeType,
17409 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17410}
17411
17412template <typename Derived>
17414 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17415 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17416 if (SizeExpr || !Size)
17417 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17418 IndexTypeQuals, BracketsRange,
17420
17421 QualType Types[] = {
17422 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17423 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17424 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17425 };
17426 QualType SizeType;
17427 for (const auto &T : Types)
17428 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17429 SizeType = T;
17430 break;
17431 }
17432
17433 // Note that we can return a VariableArrayType here in the case where
17434 // the element type was a dependent VariableArrayType.
17435 IntegerLiteral *ArraySize
17436 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17437 /*FIXME*/BracketsRange.getBegin());
17438 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17439 IndexTypeQuals, BracketsRange,
17441}
17442
17443template <typename Derived>
17445 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17446 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17447 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17448 IndexTypeQuals, BracketsRange);
17449}
17450
17451template <typename Derived>
17453 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17454 SourceRange BracketsRange) {
17455 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17456 IndexTypeQuals, BracketsRange);
17457}
17458
17459template <typename Derived>
17461 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17462 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17463 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17464 SizeExpr,
17465 IndexTypeQuals, BracketsRange);
17466}
17467
17468template <typename Derived>
17470 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17471 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17472 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17473 SizeExpr,
17474 IndexTypeQuals, BracketsRange);
17475}
17476
17477template <typename Derived>
17479 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17480 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17481 AttributeLoc);
17482}
17483
17484template <typename Derived>
17486 unsigned NumElements,
17487 VectorKind VecKind) {
17488 // FIXME: semantic checking!
17489 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17490}
17491
17492template <typename Derived>
17494 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17495 VectorKind VecKind) {
17496 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17497}
17498
17499template<typename Derived>
17501 unsigned NumElements,
17502 SourceLocation AttributeLoc) {
17503 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17504 NumElements, true);
17505 IntegerLiteral *VectorSize
17506 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17507 AttributeLoc);
17508 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17509}
17510
17511template<typename Derived>
17514 Expr *SizeExpr,
17515 SourceLocation AttributeLoc) {
17516 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17517}
17518
17519template <typename Derived>
17521 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17522 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17523 NumColumns);
17524}
17525
17526template <typename Derived>
17528 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17529 SourceLocation AttributeLoc) {
17530 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17531 AttributeLoc);
17532}
17533
17534template <typename Derived>
17538 return SemaRef.BuildFunctionType(T, ParamTypes,
17541 EPI);
17542}
17543
17544template<typename Derived>
17546 return SemaRef.Context.getFunctionNoProtoType(T);
17547}
17548
17549template <typename Derived>
17552 SourceLocation NameLoc, Decl *D) {
17553 assert(D && "no decl found");
17554 if (D->isInvalidDecl()) return QualType();
17555
17556 // FIXME: Doesn't account for ObjCInterfaceDecl!
17557 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17558 // A valid resolved using typename pack expansion decl can have multiple
17559 // UsingDecls, but they must each have exactly one type, and it must be
17560 // the same type in every case. But we must have at least one expansion!
17561 if (UPD->expansions().empty()) {
17562 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17563 << UPD->isCXXClassMember() << UPD;
17564 return QualType();
17565 }
17566
17567 // We might still have some unresolved types. Try to pick a resolved type
17568 // if we can. The final instantiation will check that the remaining
17569 // unresolved types instantiate to the type we pick.
17570 QualType FallbackT;
17571 QualType T;
17572 for (auto *E : UPD->expansions()) {
17573 QualType ThisT =
17574 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17575 if (ThisT.isNull())
17576 continue;
17577 if (ThisT->getAs<UnresolvedUsingType>())
17578 FallbackT = ThisT;
17579 else if (T.isNull())
17580 T = ThisT;
17581 else
17582 assert(getSema().Context.hasSameType(ThisT, T) &&
17583 "mismatched resolved types in using pack expansion");
17584 }
17585 return T.isNull() ? FallbackT : T;
17586 }
17587 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17588 assert(Using->hasTypename() &&
17589 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17590
17591 // A valid resolved using typename decl points to exactly one type decl.
17592 assert(++Using->shadow_begin() == Using->shadow_end());
17593
17594 UsingShadowDecl *Shadow = *Using->shadow_begin();
17595 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17596 return QualType();
17597 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17598 }
17600 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17601 return SemaRef.Context.getUnresolvedUsingType(
17603}
17604
17605template <typename Derived>
17607 TypeOfKind Kind) {
17608 return SemaRef.BuildTypeofExprType(E, Kind);
17609}
17610
17611template<typename Derived>
17613 TypeOfKind Kind) {
17614 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17615}
17616
17617template <typename Derived>
17619 return SemaRef.BuildDecltypeType(E);
17620}
17621
17622template <typename Derived>
17624 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17625 SourceLocation EllipsisLoc, bool FullySubstituted,
17626 ArrayRef<QualType> Expansions) {
17627 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17628 FullySubstituted, Expansions);
17629}
17630
17631template<typename Derived>
17633 UnaryTransformType::UTTKind UKind,
17634 SourceLocation Loc) {
17635 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17636}
17637
17638template <typename Derived>
17641 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17642 return SemaRef.CheckTemplateIdType(
17643 Keyword, Template, TemplateNameLoc, TemplateArgs,
17644 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17645}
17646
17647template<typename Derived>
17649 SourceLocation KWLoc) {
17650 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17651}
17652
17653template<typename Derived>
17655 SourceLocation KWLoc,
17656 bool isReadPipe) {
17657 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17658 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17659}
17660
17661template <typename Derived>
17663 unsigned NumBits,
17664 SourceLocation Loc) {
17665 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17666 NumBits, true);
17667 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17668 SemaRef.Context.IntTy, Loc);
17669 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17670}
17671
17672template <typename Derived>
17674 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17675 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17676}
17677
17678template <typename Derived>
17680 bool TemplateKW,
17681 TemplateName Name) {
17682 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17683 Name);
17684}
17685
17686template <typename Derived>
17688 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17689 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17691 TemplateName.setIdentifier(&Name, NameLoc);
17693 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17694 TemplateName, ParsedType::make(ObjectType),
17695 /*EnteringContext=*/false, Template,
17696 AllowInjectedClassName);
17697 return Template.get();
17698}
17699
17700template<typename Derived>
17703 SourceLocation TemplateKWLoc,
17704 OverloadedOperatorKind Operator,
17705 SourceLocation NameLoc,
17706 QualType ObjectType,
17707 bool AllowInjectedClassName) {
17708 UnqualifiedId Name;
17709 // FIXME: Bogus location information.
17710 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17711 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17713 getSema().ActOnTemplateName(
17714 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17715 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17716 return Template.get();
17717}
17718
17719template <typename Derived>
17722 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17723 Expr *Second) {
17724 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17725
17726 if (First->getObjectKind() == OK_ObjCProperty) {
17729 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17730 Opc, First, Second);
17731 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17732 if (Result.isInvalid())
17733 return ExprError();
17734 First = Result.get();
17735 }
17736
17737 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17738 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17739 if (Result.isInvalid())
17740 return ExprError();
17741 Second = Result.get();
17742 }
17743
17744 // Determine whether this should be a builtin operation.
17745 if (Op == OO_Subscript) {
17746 if (!First->getType()->isOverloadableType() &&
17747 !Second->getType()->isOverloadableType())
17748 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17749 OpLoc);
17750 } else if (Op == OO_Arrow) {
17751 // It is possible that the type refers to a RecoveryExpr created earlier
17752 // in the tree transformation.
17753 if (First->getType()->isDependentType())
17754 return ExprError();
17755 // -> is never a builtin operation.
17756 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17757 } else if (Second == nullptr || isPostIncDec) {
17758 if (!First->getType()->isOverloadableType() ||
17759 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17760 // The argument is not of overloadable type, or this is an expression
17761 // of the form &Class::member, so try to create a built-in unary
17762 // operation.
17764 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17765
17766 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17767 }
17768 } else {
17769 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17770 !First->getType()->isOverloadableType() &&
17771 !Second->getType()->isOverloadableType()) {
17772 // Neither of the arguments is type-dependent or has an overloadable
17773 // type, so try to create a built-in binary operation.
17776 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17777 if (Result.isInvalid())
17778 return ExprError();
17779
17780 return Result;
17781 }
17782 }
17783
17784 // Create the overloaded operator invocation for unary operators.
17785 if (!Second || isPostIncDec) {
17787 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17788 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17789 RequiresADL);
17790 }
17791
17792 // Create the overloaded operator invocation for binary operators.
17794 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17795 First, Second, RequiresADL);
17796 if (Result.isInvalid())
17797 return ExprError();
17798
17799 return Result;
17800}
17801
17802template<typename Derived>
17805 SourceLocation OperatorLoc,
17806 bool isArrow,
17807 CXXScopeSpec &SS,
17808 TypeSourceInfo *ScopeType,
17809 SourceLocation CCLoc,
17810 SourceLocation TildeLoc,
17811 PseudoDestructorTypeStorage Destroyed) {
17812 QualType CanonicalBaseType = Base->getType().getCanonicalType();
17813 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
17814 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
17815 (isArrow && isa<PointerType>(CanonicalBaseType) &&
17816 !cast<PointerType>(CanonicalBaseType)
17817 ->getPointeeType()
17818 ->getAsCanonical<RecordType>())) {
17819 // This pseudo-destructor expression is still a pseudo-destructor.
17820 return SemaRef.BuildPseudoDestructorExpr(
17821 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
17822 CCLoc, TildeLoc, Destroyed);
17823 }
17824
17825 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
17826 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
17827 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
17828 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
17829 NameInfo.setNamedTypeInfo(DestroyedType);
17830
17831 // The scope type is now known to be a valid nested name specifier
17832 // component. Tack it on to the nested name specifier.
17833 if (ScopeType) {
17834 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
17835 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
17836 diag::err_expected_class_or_namespace)
17837 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
17838 return ExprError();
17839 }
17840 SS.clear();
17841 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
17842 }
17843
17844 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
17845 return getSema().BuildMemberReferenceExpr(
17846 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
17847 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
17848 /*TemplateArgs*/ nullptr,
17849 /*S*/ nullptr);
17850}
17851
17852template<typename Derived>
17855 SourceLocation Loc = S->getBeginLoc();
17856 CapturedDecl *CD = S->getCapturedDecl();
17857 unsigned NumParams = CD->getNumParams();
17858 unsigned ContextParamPos = CD->getContextParamPosition();
17860 for (unsigned I = 0; I < NumParams; ++I) {
17861 if (I != ContextParamPos) {
17862 Params.push_back(
17863 std::make_pair(
17864 CD->getParam(I)->getName(),
17865 getDerived().TransformType(CD->getParam(I)->getType())));
17866 } else {
17867 Params.push_back(std::make_pair(StringRef(), QualType()));
17868 }
17869 }
17870 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
17871 S->getCapturedRegionKind(), Params);
17872 StmtResult Body;
17873 {
17874 Sema::CompoundScopeRAII CompoundScope(getSema());
17875 Body = getDerived().TransformStmt(S->getCapturedStmt());
17876 }
17877
17878 if (Body.isInvalid()) {
17879 getSema().ActOnCapturedRegionError();
17880 return StmtError();
17881 }
17882
17883 return getSema().ActOnCapturedRegionEnd(Body.get());
17884}
17885
17886template <typename Derived>
17889 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
17890 // function definition or instantiation of a function template specialization
17891 // and will therefore never appear in a dependent context.
17892 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
17893 "context");
17894}
17895
17896template <typename Derived>
17898 // We can transform the base expression and allow argument resolution to fill
17899 // in the rest.
17900 return getDerived().TransformExpr(E->getArgLValue());
17901}
17902
17903} // end namespace clang
17904
17905#endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
static Decl::Kind getKind(const Decl *D)
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.
TokenType getType() const
Returns the token's type, e.g.
SmallVector< AnnotatedLine *, 1 > Children
If this token starts a block, this contains all the unwrapped lines in it.
#define X(type, name)
Definition Value.h:97
llvm::MachO::Record Record
Definition MachO.h:31
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
This file declares semantic analysis for 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.
static bool PreparePackForExpansion(Sema &S, const CXXBaseSpecifier &Base, const MultiLevelTemplateArgumentList &TemplateArgs, TypeSourceInfo *&Out, UnexpandedInfo &Info)
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)
This represents 'pragma omp metadirective' directive.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
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.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType IntTy
CanQualType PseudoObjectTy
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
QualType getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
PtrTy get() const
Definition Ownership.h:171
bool isInvalid() const
Definition Ownership.h:167
bool isUsable() const
Definition Ownership.h:169
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition Expr.h:4550
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:6021
Represents a loop initializing the elements of an array.
Definition Expr.h:5968
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1804
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7171
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2721
Wrapper for source info for arrays.
Definition TypeLoc.h:1748
void setLBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1754
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition ExprCXX.h:2996
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:3034
ArrayTypeTrait getTrait() const
Definition ExprCXX.h:3036
Expr * getDimensionExpression() const
Definition ExprCXX.h:3046
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition ExprCXX.h:3042
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:3033
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3723
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6685
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6880
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2644
Attr - This represents one attribute.
Definition Attr.h:45
attr::Kind getKind() const
Definition Attr.h:91
Represents an attribute applied to a statement.
Definition Stmt.h:2194
Stmt * getSubStmt()
Definition Stmt.h:2230
SourceLocation getAttrLoc() const
Definition Stmt.h:2225
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2226
Type source information for an attributed type.
Definition TypeLoc.h:1008
void setAttr(const Attr *A)
Definition TypeLoc.h:1034
Type source information for an btf_tag attributed type.
Definition TypeLoc.h:1058
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition Expr.h:4453
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4038
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition Expr.cpp:2179
static bool isAssignmentOp(Opcode Opc)
Definition Expr.h:4174
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:2141
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8145
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4668
void setIsVariadic(bool value)
Definition Decl.h:4744
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6624
Wrapper for source info for block pointers.
Definition TypeLoc.h:1497
BreakStmt - This represents a break.
Definition Stmt.h:3126
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5476
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:5495
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:5494
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition Expr.h:3969
Represents a call to a CUDA kernel function.
Definition ExprCXX.h:234
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition ExprCXX.h:604
Represents binding an expression to a temporary.
Definition ExprCXX.h:1493
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition ExprCXX.h:723
CXXCatchStmt - This represents a C++ catch block.
Definition StmtCXX.h:28
A C++ const_cast expression (C++ [expr.const.cast]).
Definition ExprCXX.h:566
Represents a call to a C++ constructor.
Definition ExprCXX.h:1548
SourceRange getParenOrBraceRange() const
Definition ExprCXX.h:1729
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition ExprCXX.h:1691
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition ExprCXX.h:1641
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:581
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:575
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition ExprCXX.h:1630
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition ExprCXX.h:1688
Represents a C++ constructor within a class.
Definition DeclCXX.h:2604
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1270
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition ExprCXX.cpp:1039
A use of a default initializer in a constructor or in aggregate initialization.
Definition ExprCXX.h:1377
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2626
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition ExprCXX.h:3870
Represents a C++ destructor within a class.
Definition DeclCXX.h:2869
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:481
Represents a folding of a pack over an operator.
Definition ExprCXX.h:5032
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition StmtCXX.h:135
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition ExprCXX.h:1831
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition ExprCXX.h:1751
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:179
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2129
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition ExprCXX.h:375
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition ExprCXX.h:406
SourceRange getAngleBrackets() const LLVM_READONLY
Definition ExprCXX.h:413
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition ExprCXX.h:409
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition ExprCXX.h:2355
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition ExprCXX.h:4309
The null pointer literal (C++11 [lex.nullptr])
Definition ExprCXX.h:768
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:84
Represents a list-initialization with parenthesis.
Definition ExprCXX.h:5141
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition ExprCXX.h:2745
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
unsigned getLambdaDependencyKind() const
Definition DeclCXX.h:1854
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition ExprCXX.h:526
A rewritten comparison expression that was originally written using operator syntax.
Definition ExprCXX.h:286
An expression "T()" which creates an rvalue of a non-class type T.
Definition ExprCXX.h:2196
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:73
void Make(ASTContext &Context, TypeLoc TL, SourceLocation ColonColonLoc)
Make a nested-name-specifier of the form 'type::'.
Definition DeclSpec.cpp:51
char * location_data() const
Retrieve the data associated with the source-location information.
Definition DeclSpec.h:206
SourceRange getRange() const
Definition DeclSpec.h:79
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition DeclSpec.cpp:75
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition DeclSpec.h:94
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition DeclSpec.cpp:123
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition DeclSpec.h:210
void Extend(ASTContext &Context, NamespaceBaseDecl *Namespace, SourceLocation NamespaceLoc, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'name...
Definition DeclSpec.cpp:62
void MakeMicrosoftSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition DeclSpec.cpp:85
bool isEmpty() const
No scope specifier.
Definition DeclSpec.h:178
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition DeclSpec.cpp:103
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition ExprCXX.h:800
Represents a C++ functional cast expression that builds a temporary object.
Definition ExprCXX.h:1899
Represents the this expression in C++.
Definition ExprCXX.h:1154
A C++ throw-expression (C++ [except.throw]).
Definition ExprCXX.h:1208
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:69
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition ExprCXX.h:848
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition ExprCXX.h:3744
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition ExprCXX.h:3788
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition ExprCXX.h:3799
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition ExprCXX.h:3782
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition ExprCXX.h:3793
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition ExprCXX.h:3802
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1068
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2943
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:1516
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4940
unsigned getNumParams() const
Definition Decl.h:4978
unsigned getContextParamPosition() const
Definition Decl.h:5007
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4980
This captures a statement into a function.
Definition Stmt.h:3918
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1455
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:4022
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:4113
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition Stmt.cpp:1470
CaseStmt - Represent a case statement.
Definition Stmt.h:1911
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition Expr.cpp:1979
Expr * getSubExpr()
Definition Expr.h:3726
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4848
Represents a 'co_await' expression.
Definition ExprCXX.h:5369
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4300
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3605
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1731
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Stmt.h:1781
body_range body()
Definition Stmt.h:1794
SourceLocation getLBracLoc() const
Definition Stmt.h:1848
bool hasStoredFPFeatures() const
Definition Stmt.h:1778
Stmt * body_back()
Definition Stmt.h:1799
SourceLocation getRBracLoc() const
Definition Stmt.h:1849
Declaration of a C++20 concept.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
Represents the specialization of a concept - evaluates to a prvalue of type bool.
const TypeClass * getTypePtr() const
Definition TypeLoc.h:433
ConditionalOperator - The ?
Definition Expr.h:4391
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3761
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition Expr.h:1082
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4388
ContinueStmt - This represents a continue.
Definition Stmt.h:3110
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4719
Represents a 'co_return' statement in the C++ Coroutines TS.
Definition StmtCXX.h:473
Represents the body of a coroutine.
Definition StmtCXX.h:320
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
Definition TypeBase.h:3437
Represents a 'co_yield' expression.
Definition ExprCXX.h:5450
Wrapper for source info for pointers decayed from arrays and functions.
Definition TypeLoc.h:1445
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1449
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2109
DeclContextLookupResult lookup_result
Definition DeclBase.h:2577
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addDecl(Decl *D)
Add the declaration D into this context.
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1270
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1622
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
bool isInvalidDecl() const
Definition DeclBase.h:588
SourceLocation getLocation() const
Definition DeclBase.h:439
DeclContext * getDeclContext()
Definition DeclBase.h:448
AccessSpecifier getAccess() const
Definition DeclBase.h:507
The name of a declaration.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition Decl.h:822
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:809
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:1874
void setDecltypeLoc(SourceLocation Loc)
Definition TypeLoc.h:2259
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2484
DeferStmt - This represents a deferred statement.
Definition Stmt.h:3227
static DeferStmt * Create(ASTContext &Context, SourceLocation DeferLoc, Stmt *Body)
Definition Stmt.cpp:1514
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:1969
Represents an extended address space qualifier where the input address space value is dependent.
Definition TypeBase.h:4062
Represents a 'co_await' expression while the type of the promise is dependent.
Definition ExprCXX.h:5401
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2552
A qualified reference to a name whose declaration cannot yet be resolved.
Definition ExprCXX.h:3510
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3584
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition ExprCXX.h:3558
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3576
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition ExprCXX.h:3594
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3568
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3611
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3549
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3604
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3546
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4012
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2067
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4102
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition TypeBase.h:4435
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2039
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4228
Represents a single C99 designator.
Definition Expr.h:5594
Represents a C99 designated initializer expression.
Definition Expr.h:5551
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:872
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2823
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Definition TypeBase.h:4989
Expr * getCondition() const
Definition TypeBase.h:4996
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:744
Represents a reference to emded data.
Definition Expr.h:5126
RAII object that enters a new expression evaluation context.
Wrapper for source info for enum types.
Definition TypeLoc.h:863
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Definition Expr.h:3950
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition ExprCXX.h:3661
This represents one expression.
Definition Expr.h:112
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition Expr.h:177
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:194
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition Expr.h:451
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3081
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3213
QualType getType() const
Definition Expr.h:144
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition Expr.h:523
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition Expr.h:434
An expression trait intrinsic.
Definition ExprCXX.h:3069
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h:6564
Represents difference between two FPOptions values.
FPOptions applyOverrides(FPOptions Base)
Represents a member of a struct/union/class.
Definition Decl.h:3160
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2879
Represents a function declaration or definition.
Definition Decl.h:2000
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2774
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5237
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4882
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5522
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5508
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5103
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4847
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4841
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5269
param_type_iterator param_type_begin() const
Definition TypeBase.h:5713
unsigned getNumParams() const
Definition TypeLoc.h:1687
SourceLocation getLocalRangeEnd() const
Definition TypeLoc.h:1639
void setLocalRangeBegin(SourceLocation L)
Definition TypeLoc.h:1635
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1651
SourceRange getExceptionSpecRange() const
Definition TypeLoc.h:1667
void setParam(unsigned i, ParmVarDecl *VD)
Definition TypeLoc.h:1694
ArrayRef< ParmVarDecl * > getParams() const
Definition TypeLoc.h:1678
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1659
void setLocalRangeEnd(SourceLocation L)
Definition TypeLoc.h:1643
void setExceptionSpecRange(SourceRange R)
Definition TypeLoc.h:1673
TypeLoc getReturnLoc() const
Definition TypeLoc.h:1696
SourceLocation getLocalRangeBegin() const
Definition TypeLoc.h:1631
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1647
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1655
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4491
This represents a GCC inline-assembly statement extension.
Definition Stmt.h:3427
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition Expr.h:4923
Represents a C11 generic selection.
Definition Expr.h:6178
AssociationTy< false > Association
Definition Expr.h:6409
GotoStmt - This represents a direct goto.
Definition Stmt.h:2960
Type source information for HLSL attributed resource type.
Definition TypeLoc.h:1085
This class represents temporary values used to represent inout and out arguments in HLSL.
Definition Expr.h:7349
One of these records is kept for each identifier that is lexed.
IfStmt - This represents an if/then/else.
Definition Stmt.h:2250
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition Expr.h:1731
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition Expr.h:3853
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:6057
Represents a C array with an unspecified size.
Definition TypeBase.h:3910
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:2999
const TypeClass * getTypePtr() const
Definition TypeLoc.h:526
Describes an C or C++ initializer list.
Definition Expr.h:5299
InitListExpr * getSyntacticForm() const
Definition Expr.h:5472
Wrapper for source info for injected class names of class templates.
Definition TypeLoc.h:872
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:974
Represents the declaration of a label.
Definition Decl.h:524
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2137
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition ExprCXX.h:1968
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition ExprCXX.cpp:1363
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1358
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1367
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition ExprCXX.h:2033
Represents the results of name lookup.
Definition Lookup.h:147
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
Definition Lookup.h:607
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.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Definition Lookup.h:666
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition Lookup.h:576
DeclarationName getLookupName() const
Gets the name to look up.
Definition Lookup.h:265
This represents a Microsoft inline-assembly statement extension.
Definition Stmt.h:3646
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition StmtCXX.h:253
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4340
A member reference to an MSPropertyDecl.
Definition ExprCXX.h:936
MS property subscript expression.
Definition ExprCXX.h:1006
void setExpansionLoc(SourceLocation Loc)
Definition TypeLoc.h:1354
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4920
MatrixSingleSubscriptExpr - Matrix single subscript expression for the MatrixType extension when you ...
Definition Expr.h:2795
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2865
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2096
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3364
Wrapper for source info for member pointers.
Definition TypeLoc.h:1515
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3654
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition Template.h:76
This represents a decl that may have a name.
Definition Decl.h:274
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition Decl.h:487
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition Decl.h:295
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:301
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:340
Represents C++ namespaces and their aliases.
Definition Decl.h:573
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end 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.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
TypeLoc castAsTypeLoc() 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.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents a place-holder for an object not to be initialized by anything.
Definition Expr.h:5877
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h:1694
This represents the 'absent' clause in the 'pragma omp assume' directive.
This represents 'acq_rel' clause in the 'pragma omp atomic|flush' directives.
This represents 'acquire' clause in the 'pragma omp atomic|flush' directives.
This represents clause 'affinity' in the 'pragma omp task'-based directives.
This represents the 'align' clause in the 'pragma omp allocate' directive.
This represents clause 'aligned' in the 'pragma omp ...' directives.
This represents clause 'allocate' in the 'pragma omp ...' directives.
This represents 'allocator' clause in the 'pragma omp ...' directive.
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
Definition ExprOpenMP.h:24
This represents 'at' clause in the 'pragma omp error' directive.
This represents 'atomic_default_mem_order' clause in the 'pragma omp requires' directive.
This represents 'bind' clause in the 'pragma omp ...' directives.
This represents 'capture' clause in the 'pragma omp atomic' directive.
This is a basic class for representing single OpenMP clause.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
This represents 'collapse' clause in the 'pragma omp ...' directive.
This represents 'compare' clause in the 'pragma omp atomic' directive.
This represents the 'contains' clause in the 'pragma omp assume' directive.
This represents clause 'copyin' in the 'pragma omp ...' directives.
This represents clause 'copyprivate' in the 'pragma omp ...' directives.
This represents 'default' clause in the 'pragma omp ...' directive.
This represents 'defaultmap' clause in the 'pragma omp ...' directive.
This represents implicit clause 'depend' for the 'pragma omp task' directive.
This represents implicit clause 'depobj' for the 'pragma omp depobj' directive.
This represents 'destroy' clause in the 'pragma omp depobj' directive or the 'pragma omp interop' dir...
This represents 'detach' clause in the 'pragma omp task' directive.
This represents 'device' clause in the 'pragma omp ...' directive.
This represents 'dist_schedule' clause in the 'pragma omp ...' directive.
This represents the 'doacross' clause for the 'pragma omp ordered' directive.
This represents 'dyn_groupprivate' clause in 'pragma omp target ...' and 'pragma omp teams ....
This represents 'dynamic_allocators' clause in the 'pragma omp requires' directive.
This represents clause 'exclusive' in the 'pragma omp scan' directive.
This represents 'fail' clause in the 'pragma omp atomic' directive.
This represents 'filter' clause in the 'pragma omp ...' directive.
This represents 'final' clause in the 'pragma omp ...' directive.
This represents clause 'firstprivate' in the 'pragma omp ...' directives.
This represents implicit clause 'flush' for the 'pragma omp flush' directive.
This represents clause 'from' in the 'pragma omp ...' directives.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
This represents 'grainsize' clause in the 'pragma omp ...' directive.
This represents clause 'has_device_ptr' in the 'pragma omp ...' directives.
This represents 'hint' clause in the 'pragma omp ...' directive.
This represents the 'holds' clause in the 'pragma omp assume' directive.
This represents 'if' clause in the 'pragma omp ...' directive.
This represents clause 'in_reduction' in the 'pragma omp task' directives.
This represents clause 'inclusive' in the 'pragma omp scan' directive.
This represents the 'init' clause in 'pragma omp ...' directives.
This represents clause 'is_device_ptr' in the 'pragma omp ...' directives.
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
Definition ExprOpenMP.h:151
This represents clause 'lastprivate' in the 'pragma omp ...' directives.
This represents clause 'linear' in the 'pragma omp ...' directives.
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
This represents clauses with a list of expressions that are mappable.
This represents 'mergeable' clause in the 'pragma omp ...' directive.
This represents the 'message' clause in the 'pragma omp error' and the 'pragma omp parallel' directiv...
This represents the 'no_openmp' clause in the 'pragma omp assume' directive.
This represents the 'no_openmp_constructs' clause in the.
This represents the 'no_openmp_routines' clause in the 'pragma omp assume' directive.
This represents the 'no_parallelism' clause in the 'pragma omp assume' directive.
This represents 'nocontext' clause in the 'pragma omp ...' directive.
This represents 'nogroup' clause in the 'pragma omp ...' directive.
This represents clause 'nontemporal' in the 'pragma omp ...' directives.
This represents 'novariants' clause in the 'pragma omp ...' directive.
This represents 'nowait' clause in the 'pragma omp ...' directive.
This represents 'num_tasks' clause in the 'pragma omp ...' directive.
This represents 'num_teams' clause in the 'pragma omp ...' directive.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
This represents 'order' clause in the 'pragma omp ...' directive.
This represents 'ordered' clause in the 'pragma omp ...' directive.
Representation of the 'partial' clause of the 'pragma omp unroll' directive.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
This represents 'priority' clause in the 'pragma omp ...' directive.
This represents clause 'private' in the 'pragma omp ...' directives.
This represents 'proc_bind' clause in the 'pragma omp ...' directive.
This represents 'read' clause in the 'pragma omp atomic' directive.
This represents clause 'reduction' in the 'pragma omp ...' directives.
This represents 'relaxed' clause in the 'pragma omp atomic' directives.
This represents 'release' clause in the 'pragma omp atomic|flush' directives.
This represents 'reverse_offload' clause in the 'pragma omp requires' directive.
This represents 'simd' clause in the 'pragma omp ...' directive.
This represents 'safelen' clause in the 'pragma omp ...' directive.
This represents 'schedule' clause in the 'pragma omp ...' directive.
This represents 'self_maps' clause in the 'pragma omp requires' directive.
This represents 'seq_cst' clause in the 'pragma omp atomic|flush' directives.
This represents the 'severity' clause in the 'pragma omp error' and the 'pragma omp parallel' directi...
This represents clause 'shared' in the 'pragma omp ...' directives.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
This represents clause 'task_reduction' in the 'pragma omp taskgroup' directives.
This represents 'thread_limit' clause in the 'pragma omp ...' directive.
This represents 'threads' clause in the 'pragma omp ...' directive.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
This represents clause 'to' in the 'pragma omp ...' directives.
This represents 'unified_address' clause in the 'pragma omp requires' directive.
This represents 'unified_shared_memory' clause in the 'pragma omp requires' directive.
This represents 'untied' clause in the 'pragma omp ...' directive.
This represents 'update' clause in the 'pragma omp atomic' directive.
This represents the 'use' clause in 'pragma omp ...' directives.
This represents clause 'use_device_addr' in the 'pragma omp ...' directives.
This represents clause 'use_device_ptr' in the 'pragma omp ...' directives.
This represents clause 'uses_allocators' in the 'pragma omp target'-based directives.
This represents 'weak' clause in the 'pragma omp atomic' directives.
This represents 'write' clause in the 'pragma omp atomic' directive.
This represents 'ompx_attribute' clause in a directive that might generate an outlined function.
This represents 'ompx_bare' clause in the 'pragma omp target teams ...' directive.
This represents 'ompx_dyn_cgroup_mem' clause in the 'pragma omp target ...' directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition ExprObjC.h:192
Represents Objective-C's @catch statement.
Definition StmtObjC.h:77
Represents Objective-C's @finally statement.
Definition StmtObjC.h:127
Represents Objective-C's @synchronized statement.
Definition StmtObjC.h:303
Represents Objective-C's @throw statement.
Definition StmtObjC.h:358
Represents Objective-C's @try ... @catch ... @finally statement.
Definition StmtObjC.h:167
Represents Objective-C's @autoreleasepool Statement.
Definition StmtObjC.h:394
A runtime availability query.
Definition ExprObjC.h:1700
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition ExprObjC.h:88
ObjCBoxedExpr - used for generalized expression boxing.
Definition ExprObjC.h:128
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition ExprObjC.h:1640
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition ExprObjC.h:307
ObjCEncodeExpr, used for @encode in Objective-C.
Definition ExprObjC.h:407
Represents Objective-C's collection statement.
Definition StmtObjC.h:23
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition ExprObjC.h:1579
Wrapper for source info for ObjC interfaces.
Definition TypeLoc.h:1274
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition ExprObjC.h:1495
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1952
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:546
An expression that sends a message to the given Objective-C object or class.
Definition ExprObjC.h:937
@ SuperInstance
The receiver is the instance of the superclass object.
Definition ExprObjC.h:951
@ Instance
The receiver is an object instance.
Definition ExprObjC.h:945
@ SuperClass
The receiver is a superclass.
Definition ExprObjC.h:948
@ Class
The receiver is a class.
Definition ExprObjC.h:942
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Wraps an ObjCPointerType with source location information.
Definition TypeLoc.h:1557
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1563
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition TypeLoc.h:1229
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:731
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition ExprObjC.h:614
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition ExprObjC.h:502
ObjCSelectorExpr used for @selector in Objective-C.
Definition ExprObjC.h:452
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition ExprObjC.h:52
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition ExprObjC.h:836
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:578
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition TypeLoc.h:895
@ Array
An index into an array.
Definition Expr.h:2426
@ Identifier
A field in a dependent type, known only by its name.
Definition Expr.h:2430
@ Field
A field.
Definition Expr.h:2428
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition Expr.h:2433
static OpaquePtr make(QualType P)
Definition Ownership.h:61
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition Expr.h:1178
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1228
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition Expr.h:2090
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.
Represents a 'collapse' clause on a 'loop' construct.
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, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A 'default' clause, has the optional 'none' or 'present' argument.
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)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
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, ArrayRef< OpenACCFirstPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCHostClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
An 'if' clause, which has a required condition expression.
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, ArrayRef< OpenACCPrivateRecipe > InitRecipes, SourceLocation EndLoc)
A 'self' clause, which has an optional condition expression, or, in the event of an 'update' directiv...
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:3128
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition ExprCXX.h:3280
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3262
SourceLocation getNameLoc() const
Gets the location of the name.
Definition ExprCXX.h:3241
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3254
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition ExprCXX.h:3250
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3324
llvm::iterator_range< decls_iterator > decls() const
Definition ExprCXX.h:3227
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3330
DeclarationName getName() const
Gets the name looked up.
Definition ExprCXX.h:3238
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3270
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition ExprCXX.h:3277
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition ExprCXX.h:4363
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2604
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2600
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2616
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2287
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2182
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition Expr.h:2207
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition Expr.h:2211
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1382
Represents a parameter to a function.
Definition Decl.h:1790
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1850
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1823
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:2953
unsigned getFunctionScopeDepth() const
Definition Decl.h:1840
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2696
PipeType - OpenCL20.
Definition TypeBase.h:8111
bool isReadOnly() const
Definition TypeBase.h:8141
Pointer-authentication qualifiers.
Definition TypeBase.h:152
void setSigilLoc(SourceLocation Loc)
Definition TypeLoc.h:1461
TypeLoc getPointeeLoc() const
Definition TypeLoc.h:1465
SourceLocation getSigilLoc() const
Definition TypeLoc.h:1457
Wrapper for source info for pointers.
Definition TypeLoc.h:1484
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3329
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2005
Stores the type being destroyed by a pseudo-destructor expression.
Definition ExprCXX.h:2694
const IdentifierInfo * getIdentifier() const
Definition ExprCXX.h:2714
SourceLocation getLocation() const
Definition ExprCXX.h:2718
TypeSourceInfo * getTypeSourceInfo() const
Definition ExprCXX.h:2710
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h:6756
A (possibly-)qualified type.
Definition TypeBase.h:937
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition TypeBase.h:1004
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition TypeBase.h:8293
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition TypeBase.h:8333
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition TypeBase.h:8387
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8325
Represents a template name as written in source code.
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition TypeLoc.h:300
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
void removeObjCLifetime()
Definition TypeBase.h:551
bool hasRestrict() const
Definition TypeBase.h:477
static Qualifiers fromCVRMask(unsigned CVR)
Definition TypeBase.h:435
PointerAuthQualifier getPointerAuth() const
Definition TypeBase.h:603
bool hasObjCLifetime() const
Definition TypeBase.h:544
bool empty() const
Definition TypeBase.h:647
LangAS getAddressSpace() const
Definition TypeBase.h:571
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition Expr.h:7455
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3574
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3590
Represents the body of a requires-expression.
Definition DeclCXX.h:2098
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition DeclCXX.cpp:2389
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3151
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition Stmt.cpp:1323
Represents a __leave statement.
Definition Stmt.h:3879
SYCLKernelCallStmt represents the transformation that is applied to the body of a function declared w...
Definition StmtSYCL.h:37
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
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:193
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition SemaObjC.cpp:320
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:218
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:213
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition SemaObjC.cpp:238
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition SemaObjC.cpp:282
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:202
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:329
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.
Helper type for the registration/assignment of constructs that need to 'know' about their parent cons...
Helper type to restore the state of various 'loop' constructs when we run into a loop (for,...
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
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 * ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'filter' clause.
OMPClause * ActOnOpenMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on well-form 'full' clauses.
OMPClause * ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'detach' clause.
OMPClause * ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'use' clause.
OMPClause * ActOnOpenMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'private' clause.
OMPClause * ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc=SourceLocation(), Expr *NumForLoops=nullptr)
Called on well-formed 'ordered' clause.
OMPClause * 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 * ActOnOpenMPLoopRangeClause(Expr *First, Expr *Count, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc)
Called on well-form 'looprange' clause after parsing its arguments.
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 * 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 * ActOnOpenMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Condition)
Called on well-formed 'nowait' clause.
OMPClause * ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, OpenMPOrderClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'order' clause.
OMPClause * ActOnOpenMPSizesClause(ArrayRef< Expr * > SizeExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'sizes' clause.
OMPClause * ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'device' clause.
OMPClause * 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 * ActOnOpenMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_threads' clause.
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 * ActOnOpenMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'from' clause.
OMPClause * ActOnOpenMPDynGroupprivateClause(OpenMPDynGroupprivateClauseModifier M1, OpenMPDynGroupprivateClauseFallbackModifier M2, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation EndLoc)
Called on a well-formed 'dyn_groupprivate' clause.
void StartOpenMPDSABlock(OpenMPDirectiveKind K, const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc)
Called on start of new data sharing attribute block.
OMPClause * ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'severity' clause.
OMPClause * ActOnOpenMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'to' 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 * ActOnOpenMPReductionClause(ArrayRef< Expr * > VarList, OpenMPVarListDataTy::OpenMPReductionClauseModifiers Modifiers, 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 * 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 * ActOnOpenMPDefaultClause(llvm::omp::DefaultKind M, SourceLocation MLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCKindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'default' 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.
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:13604
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8434
A RAII object to enter scope of a compound statement.
Definition Sema.h:1290
A RAII object to temporarily push a declaration context.
Definition Sema.h:3467
A helper class for building up ExtParameterInfos.
Definition Sema.h:12997
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:13016
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13004
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14001
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:855
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
ExprResult ActOnCXXParenListInitExpr(ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
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)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition Sema.h:9315
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9323
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9318
bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend)
Check that the expression co_await promise.final_suspend() shall not be potentially-throwing.
ExprResult CreateBuiltinMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx, SourceLocation RBLoc)
ExprResult ActOnConstantExpression(ExprResult Res)
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)
SemaOpenMP & OpenMP()
Definition Sema.h:1501
void ActOnStartStmtExpr()
void ActOnStmtExprError()
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt={})
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
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...
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
Definition Sema.h:7826
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7828
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7827
ExprResult BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP, SourceLocation loc, TemplateArgument Replacement, UnsignedOrNone PackIndex, bool Final)
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:438
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
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:485
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition Sema.h:1526
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition Sema.h:11947
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:1283
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
DiagnosticsEngine & getDiagnostics() const
Definition Sema.h:923
SemaObjC & ObjC()
Definition Sema.h:1486
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:926
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)
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)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, bool DoCheckConstraintSatisfaction=true)
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
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)
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
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 *.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition Sema.cpp:83
const LangOptions & getLangOpts() const
Definition Sema.h:919
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
SemaOpenACC & OpenACC()
Definition Sema.h:1491
@ ReuseLambdaContextDecl
Definition Sema.h:7004
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)
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)
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
TemplateArgument getPackSubstitutedTemplateArgument(TemplateArgument Arg) const
Definition Sema.h:11750
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
bool buildCoroutineParameterMoves(SourceLocation Loc)
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
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:1314
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
UnsignedOrNone getPackIndex(TemplateArgument Pack) const
Definition Sema.h:11745
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition Sema.cpp:2513
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1414
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,...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
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...
ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Create a new AsTypeExpr node (bitcast) from the arguments.
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?
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.
UnsignedOrNone ArgPackSubstIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition Sema.h:13598
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
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.
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
Definition Sema.h:6717
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6727
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6696
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6722
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:75
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
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:8303
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc)
Complete a lambda-expression having processed and attached the lambda body.
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition Sema.h:11036
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition SemaStmt.cpp:563
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
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.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition SemaCast.cpp:337
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,...
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel)
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition SemaStmt.cpp:950
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
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.
OpaquePtr< TemplateName > TemplateTy
Definition Sema.h:1275
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static ConditionResult ConditionError()
Definition Sema.h:7812
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:436
SemaPseudoObject & PseudoObject()
Definition Sema.h:1511
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...
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition Sema.h:1274
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition SemaStmt.cpp:568
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition SemaStmt.cpp:532
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Definition Sema.h:8643
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
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)
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition Expr.h:4643
Represents an expression that computes the length of a parameter pack.
Definition ExprCXX.h:4441
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition ExprCXX.h:4503
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
Definition ExprCXX.h:4526
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Definition ExprCXX.cpp:1709
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition ExprCXX.h:4531
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
Definition ExprCXX.h:4500
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition ExprCXX.h:4506
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition ExprCXX.h:4509
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition Expr.h:5017
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition Expr.h:5077
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition Expr.h:4595
Stmt - This represents one statement.
Definition Stmt.h:85
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.cpp:362
@ NoStmtClass
Definition Stmt.h:88
StmtClass getStmtClass() const
Definition Stmt.h:1484
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:338
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1799
Wrapper for substituted template type parameters.
Definition TypeLoc.h:998
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition ExprCXX.h:4664
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition ExprCXX.h:4754
A structure for storing an already-substituted template template parameter pack.
A structure for storing the information associated with a substituted template template parameter.
Wrapper for substituted template type parameters.
Definition TypeLoc.h:992
SwitchStmt - This represents a 'switch' stmt.
Definition Stmt.h:2500
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3717
SourceLocation getNameLoc() const
Definition TypeLoc.h:822
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:801
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:809
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:816
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:824
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:805
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
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)
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
TypeSourceInfo * getTypeSourceInfo() const
Expr * getSourceExpression() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
const TemplateArgument * pack_iterator
Iterator that traverses the elements of a template argument pack.
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.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DeducedTemplateStorage * getAsDeducedTemplateName() const
Retrieve the deduced template info, if any.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
NestedNameSpecifier getQualifier() const
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceLocation getLAngleLoc() const
Definition TypeLoc.h:1878
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:1893
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:1876
SourceLocation getTemplateKeywordLoc() const
Definition TypeLoc.h:1872
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1862
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:1858
Wrapper for template type parameters.
Definition TypeLoc.h:881
The top declaration context.
Definition Decl.h:105
RAII object that temporarily sets the base location and entity used for reporting diagnostics in type...
TemporaryBase(const TemporaryBase &)=delete
TemporaryBase(TreeTransform &Self, SourceLocation Location, DeclarationName Entity)
TemporaryBase & operator=(const TemporaryBase &)=delete
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)
TemplateArgument TransformNamedTemplateTemplateArgument(NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName Name, SourceLocation NameLoc)
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.
ParmVarDecl * TransformFunctionTypeParam(ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack)
Transforms a single function-type parameter.
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 RebuildDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttributeLoc)
Build a new matrix type given the type and dependently-defined dimensions.
QualType RebuildTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, TagDecl *Tag)
Build a new class/struct/union/enum type.
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.
QualType RebuildDeducedTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, QualType Deduced)
By default, builds a new DeducedTemplateSpecializationType with the given deduced type.
ExprResult RebuildPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new expression pack expansion.
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.
TemplateName RebuildTemplateName(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final)
Build a new template name given a template template parameter pack and the.
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.
QualType RebuildUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, SourceLocation NameLoc, Decl *D)
Rebuild an unresolved typename type, given the decl that the UnresolvedUsingTypenameDecl was transfor...
OMPClause * RebuildOMPSizesClause(ArrayRef< Expr * > Sizes, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
ExprResult RebuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
Build a new predefined expression.
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.
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.
OMPClause * RebuildOMPNowaitClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nowait' clause.
QualType TransformType(QualType T)
Transforms the given type into another type.
UnsignedOrNone ComputeSizeOfPackExprWithoutSubstitution(ArrayRef< TemplateArgument > PackArgs)
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)
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)
OMPClause * RebuildOMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'device' clause.
OMPClause * RebuildOMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'has_device_addr' clause.
bool TryExpandParameterPacks(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions)
Determine whether we should expand a pack expansion with the given set of parameter packs into separa...
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...
OMPClause * RebuildOMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_threads' clause.
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.
ExprResult RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, UnresolvedLookupExpr *Lookup)
Build a new co_await expression.
StmtResult RebuildReturnStmt(SourceLocation ReturnLoc, Expr *Result)
Build a new return statement.
QualType TransformTemplateSpecializationType(TypeLocBuilder &TLB, TemplateSpecializationTypeLoc TL, QualType ObjectType, NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName)
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.
static StmtResult Owned(Stmt *S)
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.
QualType RebuildMemberPointerType(QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls, SourceLocation Sigil)
Build a new member pointer type given the pointee type and the qualifier it refers into.
ExprResult RebuildConceptSpecializationExpr(NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, TemplateArgumentListInfo *TALI)
OMPClause * RebuildOMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Build a new OpenMP 'defaultmap' clause.
StmtResult RebuildOpenACCCacheConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation ReadOnlyLoc, ArrayRef< Expr * > VarList, SourceLocation RParenLoc, SourceLocation EndLoc)
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.
OMPClause * RebuildOMPDefaultClause(DefaultKind Kind, SourceLocation KindKwLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'default' clause.
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.
OMPClause * RebuildOMPDynGroupprivateClause(OpenMPDynGroupprivateClauseModifier M1, OpenMPDynGroupprivateClauseFallbackModifier M2, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation EndLoc)
Build a new OpenMP 'dyn_groupprivate' clause.
ExprResult RebuildImplicitValueInitExpr(QualType T)
Build a new value-initialized expression.
bool TransformFunctionTypeParams(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const QualType *ParamTypes, const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > *PVars, Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed)
Transforms the parameters of a function type into the given vectors.
StmtResult RebuildGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
Build a new inline asm statement.
StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S)
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
Build a new template name given a nested name specifier and the name that is referred to as a templat...
TemplateName RebuildTemplateName(CXXScopeSpec &SS, bool TemplateKW, TemplateName Name)
Build a new template name given a nested name specifier, a flag indicating whether the "template" key...
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.
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.
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 RebuildMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx, SourceLocation RBracketLoc)
Build a new matrix single subscript expression.
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 RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS, bool ForFoldExpression=false)
Build a new binary operator expression.
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.
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.
QualType RebuildCanonicalTagType(TagDecl *Tag)
ExprResult RebuildObjCDictionaryLiteral(SourceRange Range, MutableArrayRef< ObjCDictionaryElement > Elements)
Build a new Objective-C dictionary literal.
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)
ExprResult RebuildCXXFoldExpr(UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
Build a new C++1z fold-expression.
OMPClause * TransformOMPClause(OMPClause *S)
Transform the given statement.
QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc)
Build a new atomic type given its value type.
ExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *SubExpr)
Build a new C-style cast expression.
QualType RebuildObjCObjectPointerType(QualType PointeeType, SourceLocation Star)
Build a new Objective-C object pointer type given the pointee type.
OMPClause * RebuildOMPLoopRangeClause(Expr *First, Expr *Count, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc)
bool PreparePackForExpansion(TemplateArgumentLoc In, bool Uneval, TemplateArgumentLoc &Out, UnexpandedInfo &Info)
Checks if the argument pack from In will need to be expanded and does the necessary prework.
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.
QualType RebuildUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, UsingShadowDecl *D, QualType UnderlyingType)
Build a new type found via an alias.
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.
StmtResult TransformStmt(Stmt *S, StmtDiscardKind SDK=StmtDiscardKind::Discarded)
Transform the given statement.
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
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 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.
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.
VarDecl * RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TInfo, QualType T)
Rebuild an Objective-C exception declaration.
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, IdentifierOrOverloadedOperator IO, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
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.
MultiLevelTemplateArgumentList ForgetSubstitution()
"Forget" the template substitution to allow transforming the AST without any template instantiations.
ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc, bool IsGlobalDelete, bool IsArrayForm, Expr *Operand)
Build a new C++ "delete" expression.
ExprResult RebuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP, SourceLocation Loc, TemplateArgument Arg, UnsignedOrNone PackIndex, bool Final)
bool TransformExceptionSpec(SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, SmallVectorImpl< QualType > &Exceptions, bool &Changed)
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 RebuildSizeOfPackExpr(SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length, ArrayRef< TemplateArgument > PartialArgs)
Build a new expression to compute the length of a parameter pack.
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)
void transformAttrs(Decl *Old, Decl *New)
Transform the attributes associated with the given declaration and place them on the new declaration.
QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL)
QualType RebuildTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &Args)
Build a new template specialization type.
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 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 RebuildPackExpansionType(QualType Pattern, SourceRange PatternRange, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new pack expansion 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.
OMPClause * RebuildOMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'to' clause.
ExprResult RebuildCXXParenListInitExpr(ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
TypeSourceInfo * TransformTypeWithDeducedTST(TypeSourceInfo *TSI)
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.
void RememberSubstitution(MultiLevelTemplateArgumentList)
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.
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 RebuildTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, TypedefNameDecl *Typedef)
Build a new typedef type.
QualType TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, Fn TransformExceptionSpec)
TemplateArgumentLoc RebuildPackExpansion(TemplateArgumentLoc Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new template argument pack expansion.
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)
TypeSourceInfo * TransformType(TypeSourceInfo *TSI)
Transforms the given type-with-location into a new type-with-location.
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.
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.
StmtResult RebuildOpenACCAtomicConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, OpenACCAtomicKind AtKind, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssociatedStmt)
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.
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.
ExprResult RebuildArraySubscriptExpr(Expr *LHS, SourceLocation LBracketLoc, Expr *RHS, SourceLocation RBracketLoc)
Build a new array subscript expression.
OMPClause * RebuildOMPReductionClause(ArrayRef< Expr * > VarList, OpenMPReductionClauseModifier Modifier, OpenMPOriginalSharingModifier OriginalSharingModifier, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'reduction' clause.
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)
TemplateName TransformTemplateName(NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc, TemplateName Name, SourceLocation NameLoc, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr, bool AllowInjectedClassName=false)
Transform the given template name.
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.
OMPClause * RebuildOMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'from' clause.
bool TransformConceptTemplateArguments(InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs, bool Uneval=false)
TypeLoc getTypeLocInContext(ASTContext &Context, QualType T)
Copies the type-location information to the given AST context and returns a TypeLoc referring into th...
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:349
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:154
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition TypeLoc.h:165
TypeLocClass getTypeLocClass() const
Definition TypeLoc.h:116
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition TypeLoc.h:2706
SourceLocation getBeginLoc() const
Get the begin source location.
Definition TypeLoc.cpp:193
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Definition TypeBase.h:6180
A container of type source information.
Definition TypeBase.h:8264
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition TypeLoc.h:267
QualType getType() const
Return the type wrapped by this type source info.
Definition TypeBase.h:8275
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:551
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition ExprCXX.h:2896
The base class of the type hierarchy.
Definition TypeBase.h:1833
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition TypeBase.h:2783
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition TypeBase.h:2405
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition TypeBase.h:9035
bool isObjCObjectPointerType() const
Definition TypeBase.h:8705
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9112
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3562
Wrapper for source info for typedefs.
Definition TypeLoc.h:777
void setTypeofLoc(SourceLocation Loc)
Definition TypeLoc.h:2171
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2625
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2244
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition Expr.h:2289
Expr * getSubExpr() const
Definition Expr.h:2285
Opcode getOpcode() const
Definition Expr.h:2280
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:1414
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2315
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:998
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3390
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition ExprCXX.h:3464
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition ExprCXX.h:3459
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:432
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4126
A set of unresolved declarations.
void append(iterator I, iterator E)
A set of unresolved declarations.
Wrapper for source info for unresolved typename using decls.
Definition TypeLoc.h:782
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition TypeBase.h:5985
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition ExprCXX.h:640
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3395
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3459
Wrapper for source info for types used via transparent aliases.
Definition TypeLoc.h:785
Represents a call to the builtin function __builtin_va_arg.
Definition Expr.h:4957
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
QualType getType() const
Definition Decl.h:723
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Definition Decl.cpp:5527
Value()=default
Represents a variable declaration or definition.
Definition Decl.h:926
@ CInit
C-style initialization with assignment.
Definition Decl.h:931
@ CallInit
Call-style initialization (C++98)
Definition Decl.h:934
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1168
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:3967
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2016
Represents a GCC generic vector type.
Definition TypeBase.h:4176
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2688
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
SourceLocation getNoexceptLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
Retains information about a block that is currently being parsed.
Definition ScopeInfo.h:790
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 ...
VE builtins.
const AstTypeMatcher< FunctionType > functionType
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition Descriptor.h:29
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
Definition Interp.h:960
bool Inc(InterpState &S, CodePtr OpPC, bool CanOverflow)
1) Pops a pointer from the stack 2) Load the value from the pointer 3) Writes the value increased by ...
Definition Interp.h:776
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OpenMPOriginalSharingModifier
OpenMP 6.0 original sharing modifiers.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
OpenACCDirectiveKind
bool isa(CodeGen::Address addr)
Definition Address.h:330
ArrayTypeTrait
Names for the array type traits.
Definition TypeTraits.h:42
@ CPlusPlus23
OpenACCAtomicKind
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition TypeBase.h:1792
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
TryCaptureKind
Definition Sema.h:652
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
Definition Lookup.h:64
@ NotFound
No entity found met the criteria.
Definition Lookup.h:41
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
Definition Lookup.h:54
@ Found
Name lookup found a single declaration that met the criteria.
Definition Lookup.h:50
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
Definition Lookup.h:59
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Definition Lookup.h:46
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
Definition Specifiers.h:39
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:61
CXXConstructionKind
Definition ExprCXX.h:1540
@ 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.
@ 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
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition Sema.h:603
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
Definition Sema.h:237
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ Detach
'detach' clause, allowed on the 'exit data' construct.
TypeOfKind
The kind of 'typeof' expression we're after.
Definition TypeBase.h:918
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
Definition OpenMPKinds.h:39
OpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
Expr * Cond
};
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
Definition Parser.h:142
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition TypeTraits.h:51
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
ExprResult ExprEmpty()
Definition Ownership.h:272
OpenMPDynGroupprivateClauseFallbackModifier
MutableArrayRef< Expr * > MultiExprArg
Definition Ownership.h:259
StmtResult StmtError()
Definition Ownership.h:266
@ Property
The type of a property.
Definition TypeBase.h:911
@ Result
The result type of a method or function.
Definition TypeBase.h:905
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3720
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
@ Template
We are parsing a template declaration.
Definition Parser.h:81
ActionResult< CXXBaseSpecifier * > BaseResult
Definition Ownership.h:252
OpenMPGrainsizeClauseModifier
OpenMPNumTasksClauseModifier
TagTypeKind
The kind of a tag type.
Definition TypeBase.h:5893
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:265
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:561
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
std::tuple< NamedDecl *, TemplateArgument > getReplacedTemplateParameter(Decl *D, unsigned Index)
Internal helper used by Subst* nodes to retrieve a parameter from the AssociatedDecl,...
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
OpenMPAllocateClauseModifier
OpenMP modifiers for 'allocate' clause.
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition OpenMPKinds.h:63
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition OpenMPKinds.h:25
OpenMPDynGroupprivateClauseModifier
@ 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
@ Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition Sema.h:799
@ Exists
The symbol exists.
Definition Sema.h:792
@ Error
An error occurred.
Definition Sema.h:802
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:795
MutableArrayRef< Stmt * > MultiStmtArg
Definition Ownership.h:260
OpenMPNumThreadsClauseModifier
U cast(CodeGen::Address addr)
Definition Address.h:327
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition OpenMPKinds.h:48
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition Ownership.h:230
SourceLocIdentKind
Definition Expr.h:5004
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5868
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5889
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5879
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5886
ActionResult< Expr * > ExprResult
Definition Ownership.h:249
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
TypeTrait
Names for traits that operate specifically on types.
Definition TypeTraits.h:21
@ Parens
New-expression has a C++98 paren-delimited initializer.
Definition ExprCXX.h:2245
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Uninstantiated
not instantiated yet
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition Expr.h:1989
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition OpenMPKinds.h:31
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
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:91
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:89
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 TypeBase.h:5006
Holds information about the various types of exception specification.
Definition TypeBase.h:5326
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5342
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5328
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5331
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5334
Extra information about a function prototype.
Definition TypeBase.h:5354
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5359
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
Definition Type.cpp:3276
const NamespaceBaseDecl * Namespace
Iterator range representation begin:end[:step].
Definition ExprOpenMP.h:154
Data for list of allocators.
This structure contains most locations needed for by an OMPVarListClause.
An element in an Objective-C dictionary literal.
Definition ExprObjC.h:260
Data for list of allocators.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition Sema.h:13074
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13105
An RAII helper that pops function a function scope on exit.
Definition Sema.h:1303
Keeps information about an identifier in a nested-name-spec.
Definition Sema.h:3267
Location information for a TemplateArgument.
UnsignedOrNone OrigNumExpansions
SourceLocation Ellipsis
UnsignedOrNone NumExpansions