clang 24.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"
42#include "clang/Sema/SemaHLSL.h"
44#include "clang/Sema/SemaObjC.h"
48#include "clang/Sema/SemaSYCL.h"
49#include "clang/Sema/Template.h"
50#include "llvm/ADT/ArrayRef.h"
51#include "llvm/Support/ErrorHandling.h"
52#include <algorithm>
53#include <optional>
54
55using namespace llvm::omp;
56
57namespace clang {
58using namespace sema;
59
60// This helper class is used to facilitate pack expansion during tree transform.
70
71/// A semantic tree transformation that allows one to transform one
72/// abstract syntax tree into another.
73///
74/// A new tree transformation is defined by creating a new subclass \c X of
75/// \c TreeTransform<X> and then overriding certain operations to provide
76/// behavior specific to that transformation. For example, template
77/// instantiation is implemented as a tree transformation where the
78/// transformation of TemplateTypeParmType nodes involves substituting the
79/// template arguments for their corresponding template parameters; a similar
80/// transformation is performed for non-type template parameters and
81/// template template parameters.
82///
83/// This tree-transformation template uses static polymorphism to allow
84/// subclasses to customize any of its operations. Thus, a subclass can
85/// override any of the transformation or rebuild operators by providing an
86/// operation with the same signature as the default implementation. The
87/// overriding function should not be virtual.
88///
89/// Semantic tree transformations are split into two stages, either of which
90/// can be replaced by a subclass. The "transform" step transforms an AST node
91/// or the parts of an AST node using the various transformation functions,
92/// then passes the pieces on to the "rebuild" step, which constructs a new AST
93/// node of the appropriate kind from the pieces. The default transformation
94/// routines recursively transform the operands to composite AST nodes (e.g.,
95/// the pointee type of a PointerType node) and, if any of those operand nodes
96/// were changed by the transformation, invokes the rebuild operation to create
97/// a new AST node.
98///
99/// Subclasses can customize the transformation at various levels. The
100/// most coarse-grained transformations involve replacing TransformType(),
101/// TransformExpr(), TransformDecl(), TransformNestedNameSpecifierLoc(),
102/// TransformTemplateName(), or TransformTemplateArgument() with entirely
103/// new implementations.
104///
105/// For more fine-grained transformations, subclasses can replace any of the
106/// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
107/// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
108/// replacing TransformTemplateTypeParmType() allows template instantiation
109/// to substitute template arguments for their corresponding template
110/// parameters. Additionally, subclasses can override the \c RebuildXXX
111/// functions to control how AST nodes are rebuilt when their operands change.
112/// By default, \c TreeTransform will invoke semantic analysis to rebuild
113/// AST nodes. However, certain other tree transformations (e.g, cloning) may
114/// be able to use more efficient rebuild steps.
115///
116/// There are a handful of other functions that can be overridden, allowing one
117/// to avoid traversing nodes that don't need any transformation
118/// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
119/// operands have not changed (\c AlwaysRebuild()), and customize the
120/// default locations and entity names used for type-checking
121/// (\c getBaseLocation(), \c getBaseEntity()).
122template<typename Derived>
124 /// Private RAII object that helps us forget and then re-remember
125 /// the template argument corresponding to a partially-substituted parameter
126 /// pack.
127 class ForgetPartiallySubstitutedPackRAII {
128 Derived &Self;
130 // Set the pack expansion index to -1 to avoid pack substitution and
131 // indicate that parameter packs should be instantiated as themselves.
132 Sema::ArgPackSubstIndexRAII ResetPackSubstIndex;
133
134 public:
135 ForgetPartiallySubstitutedPackRAII(Derived &Self)
136 : Self(Self), ResetPackSubstIndex(Self.getSema(), std::nullopt) {
137 Old = Self.ForgetPartiallySubstitutedPack();
138 }
139
140 ~ForgetPartiallySubstitutedPackRAII() {
141 Self.RememberPartiallySubstitutedPack(Old);
142 }
143 ForgetPartiallySubstitutedPackRAII(
144 const ForgetPartiallySubstitutedPackRAII &) = delete;
145 ForgetPartiallySubstitutedPackRAII &
146 operator=(const ForgetPartiallySubstitutedPackRAII &) = delete;
147 };
148
149protected:
151
152 /// The set of local declarations that have been transformed, for
153 /// cases where we are forced to build new declarations within the transformer
154 /// rather than in the subclass (e.g., lambda closure types).
155 llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls;
156
157public:
158 /// Initializes a new tree transformer.
160
161 /// Retrieves a reference to the derived class.
162 Derived &getDerived() { return static_cast<Derived&>(*this); }
163
164 /// Retrieves a reference to the derived class.
165 const Derived &getDerived() const {
166 return static_cast<const Derived&>(*this);
167 }
168
169 static inline ExprResult Owned(Expr *E) { return E; }
170 static inline StmtResult Owned(Stmt *S) { return S; }
171
172 /// Retrieves a reference to the semantic analysis object used for
173 /// this tree transform.
174 Sema &getSema() const { return SemaRef; }
175
176 /// Whether the transformation should always rebuild AST nodes, even
177 /// if none of the children have changed.
178 ///
179 /// Subclasses may override this function to specify when the transformation
180 /// should rebuild all AST nodes.
181 ///
182 /// We must always rebuild all AST nodes when performing variadic template
183 /// pack expansion, in order to avoid violating the AST invariant that each
184 /// statement node appears at most once in its containing declaration.
185 bool AlwaysRebuild() { return static_cast<bool>(SemaRef.ArgPackSubstIndex); }
186
187 /// Whether the transformation is forming an expression or statement that
188 /// replaces the original. In this case, we'll reuse mangling numbers from
189 /// existing lambdas.
190 bool ReplacingOriginal() { return false; }
191
192 /// Wether CXXConstructExpr can be skipped when they are implicit.
193 /// They will be reconstructed when used if needed.
194 /// This is useful when the user that cause rebuilding of the
195 /// CXXConstructExpr is outside of the expression at which the TreeTransform
196 /// started.
197 bool AllowSkippingCXXConstructExpr() { return true; }
198
199 /// Returns the location of the entity being transformed, if that
200 /// information was not available elsewhere in the AST.
201 ///
202 /// By default, returns no source-location information. Subclasses can
203 /// provide an alternative implementation that provides better location
204 /// information.
206
207 /// Returns the name of the entity being transformed, if that
208 /// information was not available elsewhere in the AST.
209 ///
210 /// By default, returns an empty name. Subclasses can provide an alternative
211 /// implementation with a more precise name.
213
214 /// Sets the "base" location and entity when that
215 /// information is known based on another transformation.
216 ///
217 /// By default, the source location and entity are ignored. Subclasses can
218 /// override this function to provide a customized implementation.
220
221 /// RAII object that temporarily sets the base location and entity
222 /// used for reporting diagnostics in types.
224 TreeTransform &Self;
225 SourceLocation OldLocation;
226 DeclarationName OldEntity;
227
228 public:
230 DeclarationName Entity) : Self(Self) {
231 OldLocation = Self.getDerived().getBaseLocation();
232 OldEntity = Self.getDerived().getBaseEntity();
233
234 if (Location.isValid())
235 Self.getDerived().setBase(Location, Entity);
236 }
237
239 Self.getDerived().setBase(OldLocation, OldEntity);
240 }
241 TemporaryBase(const TemporaryBase &) = delete;
243 };
244
245 /// Determine whether the given type \p T has already been
246 /// transformed.
247 ///
248 /// Subclasses can provide an alternative implementation of this routine
249 /// to short-circuit evaluation when it is known that a given type will
250 /// not change. For example, template instantiation need not traverse
251 /// non-dependent types.
253 return T.isNull();
254 }
255
256 /// Transform a template parameter depth level.
257 ///
258 /// During a transformation that transforms template parameters, this maps
259 /// an old template parameter depth to a new depth.
260 unsigned TransformTemplateDepth(unsigned Depth) {
261 return Depth;
262 }
263
264 /// Determine whether the given call argument should be dropped, e.g.,
265 /// because it is a default argument.
266 ///
267 /// Subclasses can provide an alternative implementation of this routine to
268 /// determine which kinds of call arguments get dropped. By default,
269 /// CXXDefaultArgument nodes are dropped (prior to transformation).
271 return E->isDefaultArgument();
272 }
273
274 /// Determine whether we should expand a pack expansion with the
275 /// given set of parameter packs into separate arguments by repeatedly
276 /// transforming the pattern.
277 ///
278 /// By default, the transformer never tries to expand pack expansions.
279 /// Subclasses can override this routine to provide different behavior.
280 ///
281 /// \param EllipsisLoc The location of the ellipsis that identifies the
282 /// pack expansion.
283 ///
284 /// \param PatternRange The source range that covers the entire pattern of
285 /// the pack expansion.
286 ///
287 /// \param Unexpanded The set of unexpanded parameter packs within the
288 /// pattern.
289 ///
290 /// \param ShouldExpand Will be set to \c true if the transformer should
291 /// expand the corresponding pack expansions into separate arguments. When
292 /// set, \c NumExpansions must also be set.
293 ///
294 /// \param RetainExpansion Whether the caller should add an unexpanded
295 /// pack expansion after all of the expanded arguments. This is used
296 /// when extending explicitly-specified template argument packs per
297 /// C++0x [temp.arg.explicit]p9.
298 ///
299 /// \param NumExpansions The number of separate arguments that will be in
300 /// the expanded form of the corresponding pack expansion. This is both an
301 /// input and an output parameter, which can be set by the caller if the
302 /// number of expansions is known a priori (e.g., due to a prior substitution)
303 /// and will be set by the callee when the number of expansions is known.
304 /// The callee must set this value when \c ShouldExpand is \c true; it may
305 /// set this value in other cases.
306 ///
307 /// \returns true if an error occurred (e.g., because the parameter packs
308 /// are to be instantiated with arguments of different lengths), false
309 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
310 /// must be set.
312 SourceRange PatternRange,
314 bool FailOnPackProducingTemplates,
315 bool &ShouldExpand, bool &RetainExpansion,
316 UnsignedOrNone &NumExpansions) {
317 ShouldExpand = false;
318 return false;
319 }
320
321 /// "Forget" about the partially-substituted pack template argument,
322 /// when performing an instantiation that must preserve the parameter pack
323 /// use.
324 ///
325 /// This routine is meant to be overridden by the template instantiator.
329
330 /// "Remember" the partially-substituted pack template argument
331 /// after performing an instantiation that must preserve the parameter pack
332 /// use.
333 ///
334 /// This routine is meant to be overridden by the template instantiator.
336
337 /// "Forget" the template substitution to allow transforming the AST without
338 /// any template instantiations. This is used to expand template packs when
339 /// their size is not known in advance (e.g. for builtins that produce type
340 /// packs).
343
344private:
345 struct ForgetSubstitutionRAII {
346 Derived &Self;
348
349 public:
350 ForgetSubstitutionRAII(Derived &Self) : Self(Self) {
351 Old = Self.ForgetSubstitution();
352 }
353
354 ~ForgetSubstitutionRAII() { Self.RememberSubstitution(std::move(Old)); }
355 };
356
357public:
358 /// Note to the derived class when a function parameter pack is
359 /// being expanded.
361
362 /// Transforms the given type into another type.
363 ///
364 /// By default, this routine transforms a type by creating a
365 /// TypeSourceInfo for it and delegating to the appropriate
366 /// function. This is expensive, but we don't mind, because
367 /// this method is deprecated anyway; all users should be
368 /// switched to storing TypeSourceInfos.
369 ///
370 /// \returns the transformed type.
372
373 /// Transforms the given type-with-location into a new
374 /// type-with-location.
375 ///
376 /// By default, this routine transforms a type by delegating to the
377 /// appropriate TransformXXXType to build a new type. Subclasses
378 /// may override this function (to take over all type
379 /// transformations) or some set of the TransformXXXType functions
380 /// to alter the transformation.
382
383 /// Transform the given type-with-location into a new
384 /// type, collecting location information in the given builder
385 /// as necessary.
386 ///
388
389 /// Transform a type that is permitted to produce a
390 /// DeducedTemplateSpecializationType.
391 ///
392 /// This is used in the (relatively rare) contexts where it is acceptable
393 /// for transformation to produce a class template type with deduced
394 /// template arguments.
395 /// @{
398 /// @}
399
400 /// The reason why the value of a statement is not discarded, if any.
406
407 /// Transform the given statement.
408 ///
409 /// By default, this routine transforms a statement by delegating to the
410 /// appropriate TransformXXXStmt function to transform a specific kind of
411 /// statement or the TransformExpr() function to transform an expression.
412 /// Subclasses may override this function to transform statements using some
413 /// other mechanism.
414 ///
415 /// \returns the transformed statement.
418
419 /// Transform the given statement.
420 ///
421 /// By default, this routine transforms a statement by delegating to the
422 /// appropriate TransformOMPXXXClause function to transform a specific kind
423 /// of clause. Subclasses may override this function to transform statements
424 /// using some other mechanism.
425 ///
426 /// \returns the transformed OpenMP clause.
428
429 /// Transform the given attribute.
430 ///
431 /// By default, this routine transforms a statement by delegating to the
432 /// appropriate TransformXXXAttr function to transform a specific kind
433 /// of attribute. Subclasses may override this function to transform
434 /// attributed statements/types using some other mechanism.
435 ///
436 /// \returns the transformed attribute
437 const Attr *TransformAttr(const Attr *S);
438
439 // Transform the given statement attribute.
440 //
441 // Delegates to the appropriate TransformXXXAttr function to transform a
442 // specific kind of statement attribute. Unlike the non-statement taking
443 // version of this, this implements all attributes, not just pragmas.
444 const Attr *TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS,
445 const Attr *A);
446
447 // Transform the specified attribute.
448 //
449 // Subclasses should override the transformation of attributes with a pragma
450 // spelling to transform expressions stored within the attribute.
451 //
452 // \returns the transformed attribute.
453#define ATTR(X) \
454 const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; }
455#include "clang/Basic/AttrList.inc"
456
457 // Transform the specified attribute.
458 //
459 // Subclasses should override the transformation of attributes to do
460 // transformation and checking of statement attributes. By default, this
461 // delegates to the non-statement taking version.
462 //
463 // \returns the transformed attribute.
464#define ATTR(X) \
465 const X##Attr *TransformStmt##X##Attr(const Stmt *, const Stmt *, \
466 const X##Attr *A) { \
467 return getDerived().Transform##X##Attr(A); \
468 }
469#include "clang/Basic/AttrList.inc"
470
471 /// Transform the given expression.
472 ///
473 /// By default, this routine transforms an expression by delegating to the
474 /// appropriate TransformXXXExpr function to build a new expression.
475 /// Subclasses may override this function to transform expressions using some
476 /// other mechanism.
477 ///
478 /// \returns the transformed expression.
480
481 /// Transform the given initializer.
482 ///
483 /// By default, this routine transforms an initializer by stripping off the
484 /// semantic nodes added by initialization, then passing the result to
485 /// TransformExpr or TransformExprs.
486 ///
487 /// \returns the transformed initializer.
489
490 /// Transform the given list of expressions.
491 ///
492 /// This routine transforms a list of expressions by invoking
493 /// \c TransformExpr() for each subexpression. However, it also provides
494 /// support for variadic templates by expanding any pack expansions (if the
495 /// derived class permits such expansion) along the way. When pack expansions
496 /// are present, the number of outputs may not equal the number of inputs.
497 ///
498 /// \param Inputs The set of expressions to be transformed.
499 ///
500 /// \param NumInputs The number of expressions in \c Inputs.
501 ///
502 /// \param IsCall If \c true, then this transform is being performed on
503 /// function-call arguments, and any arguments that should be dropped, will
504 /// be.
505 ///
506 /// \param Outputs The transformed input expressions will be added to this
507 /// vector.
508 ///
509 /// \param ArgChanged If non-NULL, will be set \c true if any argument changed
510 /// due to transformation.
511 ///
512 /// \returns true if an error occurred, false otherwise.
513 bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall,
515 bool *ArgChanged = nullptr);
516
517 /// Transform the given declaration, which is referenced from a type
518 /// or expression.
519 ///
520 /// By default, acts as the identity function on declarations, unless the
521 /// transformer has had to transform the declaration itself. Subclasses
522 /// may override this function to provide alternate behavior.
524 llvm::DenseMap<Decl *, Decl *>::iterator Known
525 = TransformedLocalDecls.find(D);
526 if (Known != TransformedLocalDecls.end())
527 return Known->second;
528
529 return D;
530 }
531
532 /// Transform the specified condition.
533 ///
534 /// By default, this transforms the variable and expression and rebuilds
535 /// the condition.
537 Expr *Expr,
539
540 /// Transform the attributes associated with the given declaration and
541 /// place them on the new declaration.
542 ///
543 /// By default, this operation does nothing. Subclasses may override this
544 /// behavior to transform attributes.
545 void transformAttrs(Decl *Old, Decl *New) { }
546
547 /// Note that a local declaration has been transformed by this
548 /// transformer.
549 ///
550 /// Local declarations are typically transformed via a call to
551 /// TransformDefinition. However, in some cases (e.g., lambda expressions),
552 /// the transformer itself has to transform the declarations. This routine
553 /// can be overridden by a subclass that keeps track of such mappings.
555 assert(New.size() == 1 &&
556 "must override transformedLocalDecl if performing pack expansion");
557 TransformedLocalDecls[Old] = New.front();
558 }
559
560 /// Transform the definition of the given declaration.
561 ///
562 /// By default, invokes TransformDecl() to transform the declaration.
563 /// Subclasses may override this function to provide alternate behavior.
565 return getDerived().TransformDecl(Loc, D);
566 }
567
568 /// Transform the given declaration, which was the first part of a
569 /// nested-name-specifier in a member access expression.
570 ///
571 /// This specific declaration transformation only applies to the first
572 /// identifier in a nested-name-specifier of a member access expression, e.g.,
573 /// the \c T in \c x->T::member
574 ///
575 /// By default, invokes TransformDecl() to transform the declaration.
576 /// Subclasses may override this function to provide alternate behavior.
578 return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D));
579 }
580
581 /// Transform the set of declarations in an OverloadExpr.
582 bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL,
583 LookupResult &R);
584
585 /// Transform the given nested-name-specifier with source-location
586 /// information.
587 ///
588 /// By default, transforms all of the types and declarations within the
589 /// nested-name-specifier. Subclasses may override this function to provide
590 /// alternate behavior.
593 QualType ObjectType = QualType(),
594 NamedDecl *FirstQualifierInScope = nullptr);
595
596 /// Transform the given declaration name.
597 ///
598 /// By default, transforms the types of conversion function, constructor,
599 /// and destructor names and then (if needed) rebuilds the declaration name.
600 /// Identifiers and selectors are returned unmodified. Subclasses may
601 /// override this function to provide alternate behavior.
604
614
615 /// Transform the given template name.
616 ///
617 /// \param SS The nested-name-specifier that qualifies the template
618 /// name. This nested-name-specifier must already have been transformed.
619 ///
620 /// \param Name The template name to transform.
621 ///
622 /// \param NameLoc The source location of the template name.
623 ///
624 /// \param ObjectType If we're translating a template name within a member
625 /// access expression, this is the type of the object whose member template
626 /// is being referenced.
627 ///
628 /// \param FirstQualifierInScope If the first part of a nested-name-specifier
629 /// also refers to a name within the current (lexical) scope, this is the
630 /// declaration it refers to.
631 ///
632 /// By default, transforms the template name by transforming the declarations
633 /// and nested-name-specifiers that occur within the template name.
634 /// Subclasses may override this function to provide alternate behavior.
636 SourceLocation TemplateKWLoc,
637 TemplateName Name, SourceLocation NameLoc,
638 QualType ObjectType = QualType(),
639 NamedDecl *FirstQualifierInScope = nullptr,
640 bool AllowInjectedClassName = false);
641
643 SourceLocation NameLoc);
644
645 /// Transform the given template argument.
646 ///
647 /// By default, this operation transforms the type, expression, or
648 /// declaration stored within the template argument and constructs a
649 /// new template argument from the transformed result. Subclasses may
650 /// override this function to provide alternate behavior.
651 ///
652 /// Returns true if there was an error.
654 TemplateArgumentLoc &Output,
655 bool Uneval = false);
656
658 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
659 TemplateName Name, SourceLocation NameLoc);
660
661 /// Transform the given set of template arguments.
662 ///
663 /// By default, this operation transforms all of the template arguments
664 /// in the input set using \c TransformTemplateArgument(), and appends
665 /// the transformed arguments to the output list.
666 ///
667 /// Note that this overload of \c TransformTemplateArguments() is merely
668 /// a convenience function. Subclasses that wish to override this behavior
669 /// should override the iterator-based member template version.
670 ///
671 /// \param Inputs The set of template arguments to be transformed.
672 ///
673 /// \param NumInputs The number of template arguments in \p Inputs.
674 ///
675 /// \param Outputs The set of transformed template arguments output by this
676 /// routine.
677 ///
678 /// Returns true if an error occurred.
680 unsigned NumInputs,
682 bool Uneval = false) {
683 return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs,
684 Uneval);
685 }
686
687 /// Transform the given set of template arguments.
688 ///
689 /// By default, this operation transforms all of the template arguments
690 /// in the input set using \c TransformTemplateArgument(), and appends
691 /// the transformed arguments to the output list.
692 ///
693 /// \param First An iterator to the first template argument.
694 ///
695 /// \param Last An iterator one step past the last template argument.
696 ///
697 /// \param Outputs The set of transformed template arguments output by this
698 /// routine.
699 ///
700 /// Returns true if an error occurred.
701 template<typename InputIterator>
703 InputIterator Last,
705 bool Uneval = false);
706
707 template <typename InputIterator>
709 InputIterator Last,
711 bool Uneval = false);
712
713 /// Checks if the argument pack from \p In will need to be expanded and does
714 /// the necessary prework.
715 /// Whether the expansion is needed is captured in Info.Expand.
716 ///
717 /// - When the expansion is required, \p Out will be a template pattern that
718 /// would need to be expanded.
719 /// - When the expansion must not happen, \p Out will be a pack that must be
720 /// returned to the outputs directly.
721 ///
722 /// \return true iff the error occurred
725
726 /// Fakes up a TemplateArgumentLoc for a given TemplateArgument.
728 TemplateArgumentLoc &ArgLoc);
729
730 /// Fakes up a TypeSourceInfo for a type.
732 return SemaRef.Context.getTrivialTypeSourceInfo(T,
734 }
735
736#define ABSTRACT_TYPELOC(CLASS, PARENT)
737#define TYPELOC(CLASS, PARENT) \
738 QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
739#include "clang/AST/TypeLocNodes.def"
740
743 bool SuppressObjCLifetime);
747 bool SuppressObjCLifetime);
748
749 template<typename Fn>
752 CXXRecordDecl *ThisContext,
753 Qualifiers ThisTypeQuals,
755
758 SmallVectorImpl<QualType> &Exceptions,
759 bool &Changed);
760
762
765 QualType ObjectType,
766 NamedDecl *FirstQualifierInScope,
767 bool AllowInjectedClassName);
768
770
771 /// Transforms the parameters of a function type into the
772 /// given vectors.
773 ///
774 /// The result vectors should be kept in sync; null entries in the
775 /// variables vector are acceptable.
776 ///
777 /// LastParamTransformed, if non-null, will be set to the index of the last
778 /// parameter on which transformation was started. In the event of an error,
779 /// this will contain the parameter which failed to instantiate.
780 ///
781 /// Return true on error.
784 const QualType *ParamTypes,
785 const FunctionProtoType::ExtParameterInfo *ParamInfos,
787 Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed);
788
791 const QualType *ParamTypes,
792 const FunctionProtoType::ExtParameterInfo *ParamInfos,
795 return getDerived().TransformFunctionTypeParams(
796 Loc, Params, ParamTypes, ParamInfos, PTypes, PVars, PInfos, nullptr);
797 }
798
799 /// Transforms the parameters of a requires expresison into the given vectors.
800 ///
801 /// The result vectors should be kept in sync; null entries in the
802 /// variables vector are acceptable.
803 ///
804 /// Returns an unset ExprResult on success. Returns an ExprResult the 'not
805 /// satisfied' RequiresExpr if subsitution failed, OR an ExprError, both of
806 /// which are cases where transformation shouldn't continue.
808 SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
814 KWLoc, Params, /*ParamTypes=*/nullptr,
815 /*ParamInfos=*/nullptr, PTypes, &TransParams, PInfos))
816 return ExprError();
817
818 return ExprResult{};
819 }
820
821 /// Transforms a single function-type parameter. Return null
822 /// on error.
823 ///
824 /// \param indexAdjustment - A number to add to the parameter's
825 /// scope index; can be negative
827 int indexAdjustment,
828 UnsignedOrNone NumExpansions,
829 bool ExpectParameterPack);
830
831 /// Transform the body of a lambda-expression.
833 /// Alternative implementation of TransformLambdaBody that skips transforming
834 /// the body.
836
842
844
846
849
854
856
858 bool IsAddressOfOperand,
859 TypeSourceInfo **RecoveryTSI);
860
862 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
863 TypeSourceInfo **RecoveryTSI);
864
866 bool IsAddressOfOperand);
867
869
871
872// FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
873// amount of stack usage with clang.
874#define STMT(Node, Parent) \
875 LLVM_ATTRIBUTE_NOINLINE \
876 StmtResult Transform##Node(Node *S);
877#define VALUESTMT(Node, Parent) \
878 LLVM_ATTRIBUTE_NOINLINE \
879 StmtResult Transform##Node(Node *S, StmtDiscardKind SDK);
880#define EXPR(Node, Parent) \
881 LLVM_ATTRIBUTE_NOINLINE \
882 ExprResult Transform##Node(Node *E);
883#define ABSTRACT_STMT(Stmt)
884#include "clang/AST/StmtNodes.inc"
885
886#define GEN_CLANG_CLAUSE_CLASS
887#define CLAUSE_CLASS(Enum, Str, Class) \
888 LLVM_ATTRIBUTE_NOINLINE \
889 OMPClause *Transform##Class(Class *S);
890#include "llvm/Frontend/OpenMP/OMP.inc"
891
892 /// Build a new qualified type given its unqualified type and type location.
893 ///
894 /// By default, this routine adds type qualifiers only to types that can
895 /// have qualifiers, and silently suppresses those qualifiers that are not
896 /// permitted. Subclasses may override this routine to provide different
897 /// behavior.
899
900 /// Build a new pointer type given its pointee type.
901 ///
902 /// By default, performs semantic analysis when building the pointer type.
903 /// Subclasses may override this routine to provide different behavior.
905
906 /// Build a new block pointer type given its pointee type.
907 ///
908 /// By default, performs semantic analysis when building the block pointer
909 /// type. Subclasses may override this routine to provide different behavior.
911
912 /// Build a new reference type given the type it references.
913 ///
914 /// By default, performs semantic analysis when building the
915 /// reference type. Subclasses may override this routine to provide
916 /// different behavior.
917 ///
918 /// \param LValue whether the type was written with an lvalue sigil
919 /// or an rvalue sigil.
921 bool LValue,
922 SourceLocation Sigil);
923
924 /// Build a new member pointer type given the pointee type and the
925 /// qualifier it refers into.
926 ///
927 /// By default, performs semantic analysis when building the member pointer
928 /// type. Subclasses may override this routine to provide different behavior.
930 const CXXScopeSpec &SS, CXXRecordDecl *Cls,
931 SourceLocation Sigil);
932
934 SourceLocation ProtocolLAngleLoc,
936 ArrayRef<SourceLocation> ProtocolLocs,
937 SourceLocation ProtocolRAngleLoc);
938
939 /// Build an Objective-C object type.
940 ///
941 /// By default, performs semantic analysis when building the object type.
942 /// Subclasses may override this routine to provide different behavior.
944 SourceLocation Loc,
945 SourceLocation TypeArgsLAngleLoc,
947 SourceLocation TypeArgsRAngleLoc,
948 SourceLocation ProtocolLAngleLoc,
950 ArrayRef<SourceLocation> ProtocolLocs,
951 SourceLocation ProtocolRAngleLoc);
952
953 /// Build a new Objective-C object pointer type given the pointee type.
954 ///
955 /// By default, directly builds the pointer type, with no additional semantic
956 /// analysis.
959
960 /// Build a new array type given the element type, size
961 /// modifier, size of the array (if known), size expression, and index type
962 /// qualifiers.
963 ///
964 /// By default, performs semantic analysis when building the array type.
965 /// Subclasses may override this routine to provide different behavior.
966 /// Also by default, all of the other Rebuild*Array
968 const llvm::APInt *Size, Expr *SizeExpr,
969 unsigned IndexTypeQuals, SourceRange BracketsRange);
970
971 /// Build a new constant array type given the element type, size
972 /// modifier, (known) size of the array, and index type qualifiers.
973 ///
974 /// By default, performs semantic analysis when building the array type.
975 /// Subclasses may override this routine to provide different behavior.
977 ArraySizeModifier SizeMod,
978 const llvm::APInt &Size, Expr *SizeExpr,
979 unsigned IndexTypeQuals,
980 SourceRange BracketsRange);
981
982 /// Build a new incomplete array type given the element type, size
983 /// modifier, and index type qualifiers.
984 ///
985 /// By default, performs semantic analysis when building the array type.
986 /// Subclasses may override this routine to provide different behavior.
988 ArraySizeModifier SizeMod,
989 unsigned IndexTypeQuals,
990 SourceRange BracketsRange);
991
992 /// Build a new variable-length array type given the element type,
993 /// size modifier, size expression, and index type qualifiers.
994 ///
995 /// By default, performs semantic analysis when building the array type.
996 /// Subclasses may override this routine to provide different behavior.
998 ArraySizeModifier SizeMod, Expr *SizeExpr,
999 unsigned IndexTypeQuals,
1000 SourceRange BracketsRange);
1001
1002 /// Build a new dependent-sized array type given the element type,
1003 /// size modifier, size expression, and index type qualifiers.
1004 ///
1005 /// By default, performs semantic analysis when building the array type.
1006 /// Subclasses may override this routine to provide different behavior.
1008 ArraySizeModifier SizeMod,
1009 Expr *SizeExpr,
1010 unsigned IndexTypeQuals,
1011 SourceRange BracketsRange);
1012
1013 /// Build a new vector type given the element type and
1014 /// number of elements.
1015 ///
1016 /// By default, performs semantic analysis when building the vector type.
1017 /// Subclasses may override this routine to provide different behavior.
1018 QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
1019 VectorKind VecKind);
1020
1021 /// Build a new potentially dependently-sized extended vector type
1022 /// given the element type and number of elements.
1023 ///
1024 /// By default, performs semantic analysis when building the vector type.
1025 /// Subclasses may override this routine to provide different behavior.
1027 SourceLocation AttributeLoc, VectorKind);
1028
1029 /// Build a new extended vector type given the element type and
1030 /// number of elements.
1031 ///
1032 /// By default, performs semantic analysis when building the vector type.
1033 /// Subclasses may override this routine to provide different behavior.
1034 QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
1035 SourceLocation AttributeLoc);
1036
1037 /// Build a new potentially dependently-sized extended vector type
1038 /// given the element type and number of elements.
1039 ///
1040 /// By default, performs semantic analysis when building the vector type.
1041 /// Subclasses may override this routine to provide different behavior.
1043 Expr *SizeExpr,
1044 SourceLocation AttributeLoc);
1045
1046 /// Build a new matrix type given the element type and dimensions.
1047 QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows,
1048 unsigned NumColumns);
1049
1050 /// Build a new matrix type given the type and dependently-defined
1051 /// dimensions.
1053 Expr *ColumnExpr,
1054 SourceLocation AttributeLoc);
1055
1056 /// Build a new DependentAddressSpaceType or return the pointee
1057 /// type variable with the correct address space (retrieved from
1058 /// AddrSpaceExpr) applied to it. The former will be returned in cases
1059 /// where the address space remains dependent.
1060 ///
1061 /// By default, performs semantic analysis when building the type with address
1062 /// space applied. Subclasses may override this routine to provide different
1063 /// behavior.
1065 Expr *AddrSpaceExpr,
1066 SourceLocation AttributeLoc);
1067
1068 /// Build a new function type.
1069 ///
1070 /// By default, performs semantic analysis when building the function type.
1071 /// Subclasses may override this routine to provide different behavior.
1073 MutableArrayRef<QualType> ParamTypes,
1075
1076 /// Build a new unprototyped function type.
1078
1079 /// Rebuild an unresolved typename type, given the decl that
1080 /// the UnresolvedUsingTypenameDecl was transformed to.
1082 NestedNameSpecifier Qualifier,
1083 SourceLocation NameLoc, Decl *D);
1084
1085 /// Build a new type found via an alias.
1088 QualType UnderlyingType) {
1089 return SemaRef.Context.getUsingType(Keyword, Qualifier, D, UnderlyingType);
1090 }
1091
1092 /// Build a new typedef type.
1094 NestedNameSpecifier Qualifier,
1096 return SemaRef.Context.getTypedefType(Keyword, Qualifier, Typedef);
1097 }
1098
1099 /// Build a new MacroDefined type.
1101 const IdentifierInfo *MacroII) {
1102 return SemaRef.Context.getMacroQualifiedType(T, MacroII);
1103 }
1104
1105 /// Build a new class/struct/union/enum type.
1107 NestedNameSpecifier Qualifier, TagDecl *Tag) {
1108 return SemaRef.Context.getTagType(Keyword, Qualifier, Tag,
1109 /*OwnsTag=*/false);
1110 }
1112 return SemaRef.Context.getCanonicalTagType(Tag);
1113 }
1114
1115 /// Build a new typeof(expr) type.
1116 ///
1117 /// By default, performs semantic analysis when building the typeof type.
1118 /// Subclasses may override this routine to provide different behavior.
1120 TypeOfKind Kind);
1121
1122 /// Build a new typeof(type) type.
1123 ///
1124 /// By default, builds a new TypeOfType with the given underlying type.
1126
1127 /// Build a new unary transform type.
1129 UnaryTransformType::UTTKind UKind,
1130 SourceLocation Loc);
1131
1132 /// Build a new C++11 decltype type.
1133 ///
1134 /// By default, performs semantic analysis when building the decltype type.
1135 /// Subclasses may override this routine to provide different behavior.
1137
1139 SourceLocation Loc,
1140 SourceLocation EllipsisLoc,
1141 bool FullySubstituted,
1142 ArrayRef<QualType> Expansions = {});
1143
1144 /// Build a new C++11 auto type.
1145 ///
1146 /// By default, builds a new AutoType with the given deduced type.
1149 TemplateName TypeConstraintConcept,
1150 ArrayRef<TemplateArgument> TypeConstraintArgs) {
1151 return SemaRef.Context.getAutoType(
1152 DK, DeducedAsType, Keyword, TypeConstraintConcept, TypeConstraintArgs);
1153 }
1154
1155 /// By default, builds a new DeducedTemplateSpecializationType with the given
1156 /// deduced type.
1160 return SemaRef.Context.getDeducedTemplateSpecializationType(
1161 DK, DeducedAsType, Keyword, Template);
1162 }
1163
1164 /// Build a new template specialization type.
1165 ///
1166 /// By default, performs semantic analysis when building the template
1167 /// specialization type. Subclasses may override this routine to provide
1168 /// different behavior.
1171 SourceLocation TemplateLoc,
1173
1174 /// Build a new parenthesized type.
1175 ///
1176 /// By default, builds a new ParenType type from the inner type.
1177 /// Subclasses may override this routine to provide different behavior.
1179 return SemaRef.BuildParenType(InnerType);
1180 }
1181
1182 /// Build a new typename type that refers to an identifier.
1183 ///
1184 /// By default, performs semantic analysis when building the typename type
1185 /// (or elaborated type). Subclasses may override this routine to provide
1186 /// different behavior.
1188 SourceLocation KeywordLoc,
1189 NestedNameSpecifierLoc QualifierLoc,
1190 const IdentifierInfo *Id,
1191 SourceLocation IdLoc,
1192 bool DeducedTSTContext) {
1193 CXXScopeSpec SS;
1194 SS.Adopt(QualifierLoc);
1195
1196 if (QualifierLoc.getNestedNameSpecifier().isDependent()) {
1197 // If the name is still dependent, just build a new dependent name type.
1198 if (!SemaRef.computeDeclContext(SS))
1199 return SemaRef.Context.getDependentNameType(Keyword,
1200 QualifierLoc.getNestedNameSpecifier(),
1201 Id);
1202 }
1203
1206 return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1207 *Id, IdLoc, DeducedTSTContext);
1208 }
1209
1211
1212 // We had a dependent elaborated-type-specifier that has been transformed
1213 // into a non-dependent elaborated-type-specifier. Find the tag we're
1214 // referring to.
1216 DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1217 if (!DC)
1218 return QualType();
1219
1220 if (SemaRef.RequireCompleteDeclContext(SS, DC))
1221 return QualType();
1222
1223 TagDecl *Tag = nullptr;
1224 SemaRef.LookupQualifiedName(Result, DC);
1225 switch (Result.getResultKind()) {
1228 break;
1229
1231 Tag = Result.getAsSingle<TagDecl>();
1232 break;
1233
1236 llvm_unreachable("Tag lookup cannot find non-tags");
1237
1239 // Let the LookupResult structure handle ambiguities.
1240 return QualType();
1241 }
1242
1243 if (!Tag) {
1244 // Check where the name exists but isn't a tag type and use that to emit
1245 // better diagnostics.
1247 SemaRef.LookupQualifiedName(Result, DC);
1248 switch (Result.getResultKind()) {
1252 NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1253 NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1254 SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag)
1255 << SomeDecl << NTK << Kind;
1256 SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1257 break;
1258 }
1259 default:
1260 SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1261 << Kind << Id << DC << QualifierLoc.getSourceRange();
1262 break;
1263 }
1264 return QualType();
1265 }
1266 if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1267 IdLoc, Id)) {
1268 SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1269 SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1270 return QualType();
1271 }
1272 return getDerived().RebuildTagType(
1273 Keyword, QualifierLoc.getNestedNameSpecifier(), Tag);
1274 }
1275
1276 /// Build a new pack expansion type.
1277 ///
1278 /// By default, builds a new PackExpansionType type from the given pattern.
1279 /// Subclasses may override this routine to provide different behavior.
1281 SourceLocation EllipsisLoc,
1282 UnsignedOrNone NumExpansions) {
1283 return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1284 NumExpansions);
1285 }
1286
1287 /// Build a new atomic type given its value type.
1288 ///
1289 /// By default, performs semantic analysis when building the atomic type.
1290 /// Subclasses may override this routine to provide different behavior.
1292
1293 /// Build a new pipe type given its value type.
1295 bool isReadPipe);
1296
1297 /// Build a bit-precise int given its value type.
1298 QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits,
1299 SourceLocation Loc);
1300
1301 /// Build a dependent bit-precise int given its value type.
1302 QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
1303 SourceLocation Loc);
1304
1305 /// Build a new template name given a nested name specifier, a flag
1306 /// indicating whether the "template" keyword was provided, and the template
1307 /// that the template name refers to.
1308 ///
1309 /// By default, builds the new template name directly. Subclasses may override
1310 /// this routine to provide different behavior.
1312 TemplateName Name);
1313
1314 /// Build a new template name given a nested name specifier and the
1315 /// name that is referred to as a template.
1316 ///
1317 /// By default, performs semantic analysis to determine whether the name can
1318 /// be resolved to a specific template, then builds the appropriate kind of
1319 /// template name. Subclasses may override this routine to provide different
1320 /// behavior.
1322 SourceLocation TemplateKWLoc,
1323 const IdentifierInfo &Name,
1324 SourceLocation NameLoc, QualType ObjectType,
1325 bool AllowInjectedClassName);
1326
1327 /// Build a new template name given a nested name specifier and the
1328 /// overloaded operator name that is referred to as a template.
1329 ///
1330 /// By default, performs semantic analysis to determine whether the name can
1331 /// be resolved to a specific template, then builds the appropriate kind of
1332 /// template name. Subclasses may override this routine to provide different
1333 /// behavior.
1335 SourceLocation TemplateKWLoc,
1336 OverloadedOperatorKind Operator,
1337 SourceLocation NameLoc, QualType ObjectType,
1338 bool AllowInjectedClassName);
1339
1341 SourceLocation TemplateKWLoc,
1343 SourceLocation NameLoc, QualType ObjectType,
1344 bool AllowInjectedClassName);
1345
1346 /// Build a new template name given a template template parameter pack
1347 /// and the
1348 ///
1349 /// By default, performs semantic analysis to determine whether the name can
1350 /// be resolved to a specific template, then builds the appropriate kind of
1351 /// template name. Subclasses may override this routine to provide different
1352 /// behavior.
1354 Decl *AssociatedDecl, unsigned Index,
1355 bool Final) {
1357 ArgPack, AssociatedDecl, Index, Final);
1358 }
1359
1360 /// Build a new pack-index-template-name ([temp.names]).
1361 ///
1362 /// By default, performs semantic analysis to build the new template name.
1363 /// Subclasses may override this routine to provide different behavior.
1366 bool FullySubstituted,
1367 ArrayRef<TemplateName> Expansions = {}) {
1369 Pattern, IndexExpr, FullySubstituted, Expansions);
1370 }
1371
1372 /// Build a new compound statement.
1373 ///
1374 /// By default, performs semantic analysis to build the new statement.
1375 /// Subclasses may override this routine to provide different behavior.
1377 MultiStmtArg Statements,
1378 SourceLocation RBraceLoc,
1379 bool IsStmtExpr) {
1380 return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1381 IsStmtExpr);
1382 }
1383
1384 /// Build a new case statement.
1385 ///
1386 /// By default, performs semantic analysis to build the new statement.
1387 /// Subclasses may override this routine to provide different behavior.
1389 Expr *LHS,
1390 SourceLocation EllipsisLoc,
1391 Expr *RHS,
1392 SourceLocation ColonLoc) {
1393 return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1394 ColonLoc);
1395 }
1396
1397 /// Attach the body to a new case statement.
1398 ///
1399 /// By default, performs semantic analysis to build the new statement.
1400 /// Subclasses may override this routine to provide different behavior.
1402 getSema().ActOnCaseStmtBody(S, Body);
1403 return S;
1404 }
1405
1406 /// Build a new default statement.
1407 ///
1408 /// By default, performs semantic analysis to build the new statement.
1409 /// Subclasses may override this routine to provide different behavior.
1411 SourceLocation ColonLoc,
1412 Stmt *SubStmt) {
1413 return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1414 /*CurScope=*/nullptr);
1415 }
1416
1417 /// Build a new label statement.
1418 ///
1419 /// By default, performs semantic analysis to build the new statement.
1420 /// Subclasses may override this routine to provide different behavior.
1422 SourceLocation ColonLoc, Stmt *SubStmt) {
1423 return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1424 }
1425
1426 /// Build a new attributed statement.
1427 ///
1428 /// By default, performs semantic analysis to build the new statement.
1429 /// Subclasses may override this routine to provide different behavior.
1432 Stmt *SubStmt) {
1433 if (SemaRef.CheckRebuiltStmtAttributes(Attrs))
1434 return StmtError();
1435 return SemaRef.BuildAttributedStmt(AttrLoc, Attrs, SubStmt);
1436 }
1437
1438 /// Build a new "if" statement.
1439 ///
1440 /// By default, performs semantic analysis to build the new statement.
1441 /// Subclasses may override this routine to provide different behavior.
1443 SourceLocation LParenLoc, Sema::ConditionResult Cond,
1444 SourceLocation RParenLoc, Stmt *Init, Stmt *Then,
1445 SourceLocation ElseLoc, Stmt *Else) {
1446 return getSema().ActOnIfStmt(IfLoc, Kind, LParenLoc, Init, Cond, RParenLoc,
1447 Then, ElseLoc, Else);
1448 }
1449
1450 /// Start building a new switch statement.
1451 ///
1452 /// By default, performs semantic analysis to build the new statement.
1453 /// Subclasses may override this routine to provide different behavior.
1455 SourceLocation LParenLoc, Stmt *Init,
1457 SourceLocation RParenLoc) {
1458 return getSema().ActOnStartOfSwitchStmt(SwitchLoc, LParenLoc, Init, Cond,
1459 RParenLoc);
1460 }
1461
1462 /// Attach the body to the switch statement.
1463 ///
1464 /// By default, performs semantic analysis to build the new statement.
1465 /// Subclasses may override this routine to provide different behavior.
1467 Stmt *Switch, Stmt *Body) {
1468 return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1469 }
1470
1471 /// Build a new while statement.
1472 ///
1473 /// By default, performs semantic analysis to build the new statement.
1474 /// Subclasses may override this routine to provide different behavior.
1477 SourceLocation RParenLoc, Stmt *Body) {
1478 return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body);
1479 }
1480
1481 /// Build a new do-while statement.
1482 ///
1483 /// By default, performs semantic analysis to build the new statement.
1484 /// Subclasses may override this routine to provide different behavior.
1486 SourceLocation WhileLoc, SourceLocation LParenLoc,
1487 Expr *Cond, SourceLocation RParenLoc) {
1488 return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1489 Cond, RParenLoc);
1490 }
1491
1492 /// Build a new for statement.
1493 ///
1494 /// By default, performs semantic analysis to build the new statement.
1495 /// Subclasses may override this routine to provide different behavior.
1498 Sema::FullExprArg Inc, SourceLocation RParenLoc,
1499 Stmt *Body) {
1500 return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1501 Inc, RParenLoc, Body);
1502 }
1503
1504 /// Build a new goto statement.
1505 ///
1506 /// By default, performs semantic analysis to build the new statement.
1507 /// Subclasses may override this routine to provide different behavior.
1509 LabelDecl *Label) {
1510 return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1511 }
1512
1513 /// Build a new indirect goto statement.
1514 ///
1515 /// By default, performs semantic analysis to build the new statement.
1516 /// Subclasses may override this routine to provide different behavior.
1518 SourceLocation StarLoc,
1519 Expr *Target) {
1520 return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1521 }
1522
1523 /// Build a new return statement.
1524 ///
1525 /// By default, performs semantic analysis to build the new statement.
1526 /// Subclasses may override this routine to provide different behavior.
1528 return getSema().BuildReturnStmt(ReturnLoc, Result);
1529 }
1530
1531 /// Build a new declaration statement.
1532 ///
1533 /// By default, performs semantic analysis to build the new statement.
1534 /// Subclasses may override this routine to provide different behavior.
1536 SourceLocation StartLoc, SourceLocation EndLoc) {
1538 return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1539 }
1540
1541 /// Build a new inline asm statement.
1542 ///
1543 /// By default, performs semantic analysis to build the new statement.
1544 /// Subclasses may override this routine to provide different behavior.
1546 bool IsVolatile, unsigned NumOutputs,
1547 unsigned NumInputs, IdentifierInfo **Names,
1548 MultiExprArg Constraints, MultiExprArg Exprs,
1549 Expr *AsmString, MultiExprArg Clobbers,
1550 unsigned NumLabels,
1551 SourceLocation RParenLoc) {
1552 return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1553 NumInputs, Names, Constraints, Exprs,
1554 AsmString, Clobbers, NumLabels, RParenLoc);
1555 }
1556
1557 /// Build a new MS style inline asm statement.
1558 ///
1559 /// By default, performs semantic analysis to build the new statement.
1560 /// Subclasses may override this routine to provide different behavior.
1562 ArrayRef<Token> AsmToks,
1563 StringRef AsmString,
1564 unsigned NumOutputs, unsigned NumInputs,
1565 ArrayRef<StringRef> Constraints,
1566 ArrayRef<StringRef> Clobbers,
1567 ArrayRef<Expr*> Exprs,
1568 SourceLocation EndLoc) {
1569 return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1570 NumOutputs, NumInputs,
1571 Constraints, Clobbers, Exprs, EndLoc);
1572 }
1573
1574 /// Build a new co_return statement.
1575 ///
1576 /// By default, performs semantic analysis to build the new statement.
1577 /// Subclasses may override this routine to provide different behavior.
1579 bool IsImplicit) {
1580 return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1581 }
1582
1583 /// Build a new co_await expression.
1584 ///
1585 /// By default, performs semantic analysis to build the new expression.
1586 /// Subclasses may override this routine to provide different behavior.
1588 UnresolvedLookupExpr *OpCoawaitLookup,
1589 bool IsImplicit) {
1590 // This function rebuilds a coawait-expr given its operator.
1591 // For an explicit coawait-expr, the rebuild involves the full set
1592 // of transformations performed by BuildUnresolvedCoawaitExpr(),
1593 // including calling await_transform().
1594 // For an implicit coawait-expr, we need to rebuild the "operator
1595 // coawait" but not await_transform(), so use BuildResolvedCoawaitExpr().
1596 // This mirrors how the implicit CoawaitExpr is originally created
1597 // in Sema::ActOnCoroutineBodyStart().
1598 if (IsImplicit) {
1600 CoawaitLoc, Operand, OpCoawaitLookup);
1601 if (Suspend.isInvalid())
1602 return ExprError();
1603 return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Operand,
1604 Suspend.get(), true);
1605 }
1606
1607 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Operand,
1608 OpCoawaitLookup);
1609 }
1610
1611 /// Build a new co_await expression.
1612 ///
1613 /// By default, performs semantic analysis to build the new expression.
1614 /// Subclasses may override this routine to provide different behavior.
1616 Expr *Result,
1617 UnresolvedLookupExpr *Lookup) {
1618 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1619 }
1620
1621 /// Build a new co_yield expression.
1622 ///
1623 /// By default, performs semantic analysis to build the new expression.
1624 /// Subclasses may override this routine to provide different behavior.
1626 return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1627 }
1628
1632
1633 /// Build a new Objective-C \@try statement.
1634 ///
1635 /// By default, performs semantic analysis to build the new statement.
1636 /// Subclasses may override this routine to provide different behavior.
1638 Stmt *TryBody,
1639 MultiStmtArg CatchStmts,
1640 Stmt *Finally) {
1641 return getSema().ObjC().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1642 Finally);
1643 }
1644
1645 /// Rebuild an Objective-C exception declaration.
1646 ///
1647 /// By default, performs semantic analysis to build the new declaration.
1648 /// Subclasses may override this routine to provide different behavior.
1650 TypeSourceInfo *TInfo, QualType T) {
1652 TInfo, T, ExceptionDecl->getInnerLocStart(),
1653 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
1654 }
1655
1656 /// Build a new Objective-C \@catch statement.
1657 ///
1658 /// By default, performs semantic analysis to build the new statement.
1659 /// Subclasses may override this routine to provide different behavior.
1661 SourceLocation RParenLoc,
1662 VarDecl *Var,
1663 Stmt *Body) {
1664 return getSema().ObjC().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, Var, Body);
1665 }
1666
1667 /// Build a new Objective-C \@finally statement.
1668 ///
1669 /// By default, performs semantic analysis to build the new statement.
1670 /// Subclasses may override this routine to provide different behavior.
1672 Stmt *Body) {
1673 return getSema().ObjC().ActOnObjCAtFinallyStmt(AtLoc, Body);
1674 }
1675
1676 /// Build a new Objective-C \@throw statement.
1677 ///
1678 /// By default, performs semantic analysis to build the new statement.
1679 /// Subclasses may override this routine to provide different behavior.
1681 Expr *Operand) {
1682 return getSema().ObjC().BuildObjCAtThrowStmt(AtLoc, Operand);
1683 }
1684
1685 /// Build a new OpenMP Canonical loop.
1686 ///
1687 /// Ensures that the outermost loop in @p LoopStmt is wrapped by a
1688 /// OMPCanonicalLoop.
1690 return getSema().OpenMP().ActOnOpenMPCanonicalLoop(LoopStmt);
1691 }
1692
1693 /// Build a new OpenMP executable directive.
1694 ///
1695 /// By default, performs semantic analysis to build the new statement.
1696 /// Subclasses may override this routine to provide different behavior.
1698 DeclarationNameInfo DirName,
1699 OpenMPDirectiveKind CancelRegion,
1700 ArrayRef<OMPClause *> Clauses,
1701 Stmt *AStmt, SourceLocation StartLoc,
1702 SourceLocation EndLoc) {
1703
1705 Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1706 }
1707
1708 /// Build a new OpenMP informational directive.
1710 DeclarationNameInfo DirName,
1711 ArrayRef<OMPClause *> Clauses,
1712 Stmt *AStmt,
1713 SourceLocation StartLoc,
1714 SourceLocation EndLoc) {
1715
1717 Kind, DirName, Clauses, AStmt, StartLoc, EndLoc);
1718 }
1719
1720 /// Build a new OpenMP 'if' 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 Expr *Condition, SourceLocation StartLoc,
1726 SourceLocation LParenLoc,
1727 SourceLocation NameModifierLoc,
1728 SourceLocation ColonLoc,
1729 SourceLocation EndLoc) {
1731 NameModifier, Condition, StartLoc, LParenLoc, NameModifierLoc, ColonLoc,
1732 EndLoc);
1733 }
1734
1735 /// Build a new OpenMP 'final' clause.
1736 ///
1737 /// By default, performs semantic analysis to build the new OpenMP clause.
1738 /// Subclasses may override this routine to provide different behavior.
1740 SourceLocation LParenLoc,
1741 SourceLocation EndLoc) {
1742 return getSema().OpenMP().ActOnOpenMPFinalClause(Condition, StartLoc,
1743 LParenLoc, EndLoc);
1744 }
1745
1746 /// Build a new OpenMP 'num_threads' clause.
1747 ///
1748 /// By default, performs semantic analysis to build the new OpenMP clause.
1749 /// Subclasses may override this routine to provide different behavior.
1751 ArrayRef<Expr *> VarList,
1752 OpenMPNumThreadsClauseModifier PrescriptivenessModifier,
1753 SourceLocation PrescriptivenessModifierLoc,
1754 OpenMPNumThreadsClauseModifier DimsModifier, Expr *DimsModifierExpr,
1755 SourceLocation DimsModifierLoc, SourceLocation StartLoc,
1756 SourceLocation LParenLoc, SourceLocation EndLoc) {
1758 VarList, PrescriptivenessModifier, PrescriptivenessModifierLoc,
1759 DimsModifier, DimsModifierExpr, DimsModifierLoc, StartLoc, LParenLoc,
1760 EndLoc);
1761 }
1762
1763 /// Build a new OpenMP 'safelen' clause.
1764 ///
1765 /// By default, performs semantic analysis to build the new OpenMP clause.
1766 /// Subclasses may override this routine to provide different behavior.
1768 SourceLocation LParenLoc,
1769 SourceLocation EndLoc) {
1770 return getSema().OpenMP().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc,
1771 EndLoc);
1772 }
1773
1774 /// Build a new OpenMP 'simdlen' clause.
1775 ///
1776 /// By default, performs semantic analysis to build the new OpenMP clause.
1777 /// Subclasses may override this routine to provide different behavior.
1779 SourceLocation LParenLoc,
1780 SourceLocation EndLoc) {
1781 return getSema().OpenMP().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc,
1782 EndLoc);
1783 }
1784
1786 SourceLocation StartLoc,
1787 SourceLocation LParenLoc,
1788 SourceLocation EndLoc) {
1789 return getSema().OpenMP().ActOnOpenMPSizesClause(Sizes, StartLoc, LParenLoc,
1790 EndLoc);
1791 }
1792
1794 SourceLocation StartLoc,
1795 SourceLocation LParenLoc,
1796 SourceLocation EndLoc,
1797 std::optional<unsigned> FillIdx,
1798 SourceLocation FillLoc) {
1799 unsigned FillCount = FillIdx ? 1 : 0;
1801 Counts, StartLoc, LParenLoc, EndLoc, FillIdx, FillLoc, FillCount);
1802 }
1803
1804 /// Build a new OpenMP 'permutation' clause.
1806 SourceLocation StartLoc,
1807 SourceLocation LParenLoc,
1808 SourceLocation EndLoc) {
1809 return getSema().OpenMP().ActOnOpenMPPermutationClause(PermExprs, StartLoc,
1810 LParenLoc, EndLoc);
1811 }
1812
1813 /// Build a new OpenMP 'full' clause.
1815 SourceLocation EndLoc) {
1816 return getSema().OpenMP().ActOnOpenMPFullClause(StartLoc, EndLoc);
1817 }
1818
1819 /// Build a new OpenMP 'partial' clause.
1821 SourceLocation LParenLoc,
1822 SourceLocation EndLoc) {
1823 return getSema().OpenMP().ActOnOpenMPPartialClause(Factor, StartLoc,
1824 LParenLoc, EndLoc);
1825 }
1826
1827 OMPClause *
1829 SourceLocation LParenLoc, SourceLocation FirstLoc,
1830 SourceLocation CountLoc, SourceLocation EndLoc) {
1832 First, Count, StartLoc, LParenLoc, FirstLoc, CountLoc, EndLoc);
1833 }
1834
1835 /// Build a new OpenMP 'allocator' clause.
1836 ///
1837 /// By default, performs semantic analysis to build the new OpenMP clause.
1838 /// Subclasses may override this routine to provide different behavior.
1840 SourceLocation LParenLoc,
1841 SourceLocation EndLoc) {
1842 return getSema().OpenMP().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc,
1843 EndLoc);
1844 }
1845
1846 /// Build a new OpenMP 'collapse' clause.
1847 ///
1848 /// By default, performs semantic analysis to build the new OpenMP clause.
1849 /// Subclasses may override this routine to provide different behavior.
1851 SourceLocation LParenLoc,
1852 SourceLocation EndLoc) {
1853 return getSema().OpenMP().ActOnOpenMPCollapseClause(Num, StartLoc,
1854 LParenLoc, EndLoc);
1855 }
1856
1857 /// Build a new OpenMP 'default' clause.
1858 ///
1859 /// By default, performs semantic analysis to build the new OpenMP clause.
1860 /// Subclasses may override this routine to provide different behavior.
1863 SourceLocation VCLoc,
1864 SourceLocation StartLoc,
1865 SourceLocation LParenLoc,
1866 SourceLocation EndLoc) {
1868 Kind, KindKwLoc, VCKind, VCLoc, StartLoc, LParenLoc, EndLoc);
1869 }
1870
1871 /// Build a new OpenMP 'proc_bind' clause.
1872 ///
1873 /// By default, performs semantic analysis to build the new OpenMP clause.
1874 /// Subclasses may override this routine to provide different behavior.
1876 SourceLocation KindKwLoc,
1877 SourceLocation StartLoc,
1878 SourceLocation LParenLoc,
1879 SourceLocation EndLoc) {
1881 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1882 }
1884 SourceLocation StartLoc,
1885 SourceLocation LParenLoc,
1886 SourceLocation EndLoc) {
1888 ImpexTypeArg, StartLoc, LParenLoc, EndLoc);
1889 }
1890
1891 /// Build a new OpenMP 'schedule' clause.
1892 ///
1893 /// By default, performs semantic analysis to build the new OpenMP clause.
1894 /// Subclasses may override this routine to provide different behavior.
1897 OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1898 SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1899 SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1901 M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1902 CommaLoc, EndLoc);
1903 }
1904
1905 /// Build a new OpenMP 'ordered' clause.
1906 ///
1907 /// By default, performs semantic analysis to build the new OpenMP clause.
1908 /// Subclasses may override this routine to provide different behavior.
1910 SourceLocation EndLoc,
1911 SourceLocation LParenLoc, Expr *Num) {
1912 return getSema().OpenMP().ActOnOpenMPOrderedClause(StartLoc, EndLoc,
1913 LParenLoc, Num);
1914 }
1915
1916 /// Build a new OpenMP 'nowait' clause.
1917 ///
1918 /// By default, performs semantic analysis to build the new OpenMP clause.
1919 /// Subclasses may override this routine to provide different behavior.
1921 SourceLocation LParenLoc,
1922 SourceLocation EndLoc) {
1923 return getSema().OpenMP().ActOnOpenMPNowaitClause(StartLoc, EndLoc,
1924 LParenLoc, Condition);
1925 }
1926
1927 /// Build a new OpenMP 'private' clause.
1928 ///
1929 /// By default, performs semantic analysis to build the new OpenMP clause.
1930 /// Subclasses may override this routine to provide different behavior.
1932 SourceLocation StartLoc,
1933 SourceLocation LParenLoc,
1934 SourceLocation EndLoc) {
1935 return getSema().OpenMP().ActOnOpenMPPrivateClause(VarList, StartLoc,
1936 LParenLoc, EndLoc);
1937 }
1938
1939 /// Build a new OpenMP 'firstprivate' clause.
1940 ///
1941 /// By default, performs semantic analysis to build the new OpenMP clause.
1942 /// Subclasses may override this routine to provide different behavior.
1944 SourceLocation StartLoc,
1945 SourceLocation LParenLoc,
1946 SourceLocation EndLoc) {
1947 return getSema().OpenMP().ActOnOpenMPFirstprivateClause(VarList, StartLoc,
1948 LParenLoc, EndLoc);
1949 }
1950
1951 /// Build a new OpenMP 'lastprivate' clause.
1952 ///
1953 /// By default, performs semantic analysis to build the new OpenMP clause.
1954 /// Subclasses may override this routine to provide different behavior.
1957 SourceLocation LPKindLoc,
1958 SourceLocation ColonLoc,
1959 SourceLocation StartLoc,
1960 SourceLocation LParenLoc,
1961 SourceLocation EndLoc) {
1963 VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1964 }
1965
1966 /// Build a new OpenMP 'shared' clause.
1967 ///
1968 /// By default, performs semantic analysis to build the new OpenMP clause.
1969 /// Subclasses may override this routine to provide different behavior.
1971 SourceLocation StartLoc,
1972 SourceLocation LParenLoc,
1973 SourceLocation EndLoc) {
1974 return getSema().OpenMP().ActOnOpenMPSharedClause(VarList, StartLoc,
1975 LParenLoc, EndLoc);
1976 }
1977
1978 /// Build a new OpenMP 'reduction' clause.
1979 ///
1980 /// By default, performs semantic analysis to build the new statement.
1981 /// Subclasses may override this routine to provide different behavior.
1984 OpenMPOriginalSharingModifier OriginalSharingModifier,
1985 SourceLocation StartLoc, SourceLocation LParenLoc,
1986 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1987 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
1988 const DeclarationNameInfo &ReductionId,
1989 ArrayRef<Expr *> UnresolvedReductions) {
1991 VarList, {Modifier, OriginalSharingModifier}, StartLoc, LParenLoc,
1992 ModifierLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, ReductionId,
1993 UnresolvedReductions);
1994 }
1995
1996 /// Build a new OpenMP 'task_reduction' clause.
1997 ///
1998 /// By default, performs semantic analysis to build the new statement.
1999 /// Subclasses may override this routine to provide different behavior.
2001 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2002 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
2003 CXXScopeSpec &ReductionIdScopeSpec,
2004 const DeclarationNameInfo &ReductionId,
2005 ArrayRef<Expr *> UnresolvedReductions) {
2007 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
2008 ReductionId, UnresolvedReductions);
2009 }
2010
2011 /// Build a new OpenMP 'in_reduction' clause.
2012 ///
2013 /// By default, performs semantic analysis to build the new statement.
2014 /// Subclasses may override this routine to provide different behavior.
2015 OMPClause *
2017 SourceLocation LParenLoc, SourceLocation ColonLoc,
2018 SourceLocation EndLoc,
2019 CXXScopeSpec &ReductionIdScopeSpec,
2020 const DeclarationNameInfo &ReductionId,
2021 ArrayRef<Expr *> UnresolvedReductions) {
2023 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
2024 ReductionId, UnresolvedReductions);
2025 }
2026
2027 /// Build a new OpenMP 'linear' clause.
2028 ///
2029 /// By default, performs semantic analysis to build the new OpenMP clause.
2030 /// Subclasses may override this routine to provide different behavior.
2032 ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc,
2033 SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier,
2034 SourceLocation ModifierLoc, SourceLocation ColonLoc,
2035 SourceLocation StepModifierLoc, SourceLocation EndLoc) {
2037 VarList, Step, StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc,
2038 StepModifierLoc, EndLoc);
2039 }
2040
2041 /// Build a new OpenMP 'aligned' clause.
2042 ///
2043 /// By default, performs semantic analysis to build the new OpenMP clause.
2044 /// Subclasses may override this routine to provide different behavior.
2046 SourceLocation StartLoc,
2047 SourceLocation LParenLoc,
2048 SourceLocation ColonLoc,
2049 SourceLocation EndLoc) {
2051 VarList, Alignment, StartLoc, LParenLoc, ColonLoc, EndLoc);
2052 }
2053
2054 /// Build a new OpenMP 'copyin' 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 StartLoc,
2060 SourceLocation LParenLoc,
2061 SourceLocation EndLoc) {
2062 return getSema().OpenMP().ActOnOpenMPCopyinClause(VarList, StartLoc,
2063 LParenLoc, EndLoc);
2064 }
2065
2066 /// Build a new OpenMP 'copyprivate' clause.
2067 ///
2068 /// By default, performs semantic analysis to build the new OpenMP clause.
2069 /// Subclasses may override this routine to provide different behavior.
2071 SourceLocation StartLoc,
2072 SourceLocation LParenLoc,
2073 SourceLocation EndLoc) {
2074 return getSema().OpenMP().ActOnOpenMPCopyprivateClause(VarList, StartLoc,
2075 LParenLoc, EndLoc);
2076 }
2077
2078 /// Build a new OpenMP 'flush' pseudo clause.
2079 ///
2080 /// By default, performs semantic analysis to build the new OpenMP clause.
2081 /// Subclasses may override this routine to provide different behavior.
2083 SourceLocation StartLoc,
2084 SourceLocation LParenLoc,
2085 SourceLocation EndLoc) {
2086 return getSema().OpenMP().ActOnOpenMPFlushClause(VarList, StartLoc,
2087 LParenLoc, EndLoc);
2088 }
2089
2090 /// Build a new OpenMP 'depobj' pseudo clause.
2091 ///
2092 /// By default, performs semantic analysis to build the new OpenMP clause.
2093 /// Subclasses may override this routine to provide different behavior.
2095 SourceLocation LParenLoc,
2096 SourceLocation EndLoc) {
2097 return getSema().OpenMP().ActOnOpenMPDepobjClause(Depobj, StartLoc,
2098 LParenLoc, EndLoc);
2099 }
2100
2101 /// Build a new OpenMP 'depend' pseudo clause.
2102 ///
2103 /// By default, performs semantic analysis to build the new OpenMP clause.
2104 /// Subclasses may override this routine to provide different behavior.
2106 Expr *DepModifier, ArrayRef<Expr *> VarList,
2107 SourceLocation StartLoc,
2108 SourceLocation LParenLoc,
2109 SourceLocation EndLoc) {
2111 Data, DepModifier, VarList, StartLoc, LParenLoc, EndLoc);
2112 }
2113
2114 /// Build a new OpenMP 'device' clause.
2115 ///
2116 /// By default, performs semantic analysis to build the new statement.
2117 /// Subclasses may override this routine to provide different behavior.
2119 Expr *Device, SourceLocation StartLoc,
2120 SourceLocation LParenLoc,
2121 SourceLocation ModifierLoc,
2122 SourceLocation EndLoc) {
2124 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2125 }
2126
2127 /// Build a new OpenMP 'map' clause.
2128 ///
2129 /// By default, performs semantic analysis to build the new OpenMP clause.
2130 /// Subclasses may override this routine to provide different behavior.
2132 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
2133 ArrayRef<SourceLocation> MapTypeModifiersLoc,
2134 CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId,
2135 OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
2136 SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
2137 const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) {
2139 IteratorModifier, MapTypeModifiers, MapTypeModifiersLoc,
2140 MapperIdScopeSpec, MapperId, MapType, IsMapTypeImplicit, MapLoc,
2141 ColonLoc, VarList, Locs,
2142 /*NoDiagnose=*/false, UnresolvedMappers);
2143 }
2144
2145 /// Build a new OpenMP 'allocate' clause.
2146 ///
2147 /// By default, performs semantic analysis to build the new OpenMP clause.
2148 /// Subclasses may override this routine to provide different behavior.
2149 OMPClause *
2150 RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment,
2151 OpenMPAllocateClauseModifier FirstModifier,
2152 SourceLocation FirstModifierLoc,
2153 OpenMPAllocateClauseModifier SecondModifier,
2154 SourceLocation SecondModifierLoc,
2155 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2156 SourceLocation LParenLoc, SourceLocation ColonLoc,
2157 SourceLocation EndLoc) {
2159 Allocate, Alignment, FirstModifier, FirstModifierLoc, SecondModifier,
2160 SecondModifierLoc, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc);
2161 }
2162
2163 /// Build a new OpenMP 'num_teams' clause.
2164 ///
2165 /// By default, performs semantic analysis to build the new statement.
2166 /// Subclasses may override this routine to provide different behavior.
2169 Expr *ModifierExpr, SourceLocation ModifierLoc,
2170 OpenMPNumTeamsClauseModifier ModifierExtra, Expr *ModifierExtraExpr,
2171 SourceLocation ModifierExtraLoc, SourceLocation StartLoc,
2172 SourceLocation LParenLoc, SourceLocation EndLoc) {
2174 VarList, Modifier, ModifierExpr, ModifierLoc, ModifierExtra,
2175 ModifierExtraExpr, ModifierExtraLoc, StartLoc, LParenLoc, EndLoc);
2176 }
2177
2178 /// Build a new OpenMP 'thread_limit' clause.
2179 ///
2180 /// By default, performs semantic analysis to build the new statement.
2181 /// Subclasses may override this routine to provide different behavior.
2184 Expr *ModifierExpr, SourceLocation ModifierLoc, SourceLocation StartLoc,
2185 SourceLocation LParenLoc, SourceLocation EndLoc) {
2187 VarList, Modifier, ModifierExpr, ModifierLoc, StartLoc, LParenLoc,
2188 EndLoc);
2189 }
2190
2191 /// Build a new OpenMP 'priority' clause.
2192 ///
2193 /// By default, performs semantic analysis to build the new statement.
2194 /// Subclasses may override this routine to provide different behavior.
2196 SourceLocation LParenLoc,
2197 SourceLocation EndLoc) {
2198 return getSema().OpenMP().ActOnOpenMPPriorityClause(Priority, StartLoc,
2199 LParenLoc, EndLoc);
2200 }
2201
2202 /// Build a new OpenMP 'grainsize' clause.
2203 ///
2204 /// By default, performs semantic analysis to build the new statement.
2205 /// Subclasses may override this routine to provide different behavior.
2207 Expr *Device, SourceLocation StartLoc,
2208 SourceLocation LParenLoc,
2209 SourceLocation ModifierLoc,
2210 SourceLocation EndLoc) {
2212 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2213 }
2214
2215 /// Build a new OpenMP 'num_tasks' clause.
2216 ///
2217 /// By default, performs semantic analysis to build the new statement.
2218 /// Subclasses may override this routine to provide different behavior.
2220 Expr *NumTasks, SourceLocation StartLoc,
2221 SourceLocation LParenLoc,
2222 SourceLocation ModifierLoc,
2223 SourceLocation EndLoc) {
2225 Modifier, NumTasks, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2226 }
2227
2228 /// Build a new OpenMP 'hint' clause.
2229 ///
2230 /// By default, performs semantic analysis to build the new statement.
2231 /// Subclasses may override this routine to provide different behavior.
2233 SourceLocation LParenLoc,
2234 SourceLocation EndLoc) {
2235 return getSema().OpenMP().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc,
2236 EndLoc);
2237 }
2238
2239 /// Build a new OpenMP 'detach' clause.
2240 ///
2241 /// By default, performs semantic analysis to build the new statement.
2242 /// Subclasses may override this routine to provide different behavior.
2244 SourceLocation LParenLoc,
2245 SourceLocation EndLoc) {
2246 return getSema().OpenMP().ActOnOpenMPDetachClause(Evt, StartLoc, LParenLoc,
2247 EndLoc);
2248 }
2249
2250 /// Build a new OpenMP 'dist_schedule' clause.
2251 ///
2252 /// By default, performs semantic analysis to build the new OpenMP clause.
2253 /// Subclasses may override this routine to provide different behavior.
2254 OMPClause *
2256 Expr *ChunkSize, SourceLocation StartLoc,
2257 SourceLocation LParenLoc, SourceLocation KindLoc,
2258 SourceLocation CommaLoc, SourceLocation EndLoc) {
2260 Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
2261 }
2262
2263 /// Build a new OpenMP 'to' clause.
2264 ///
2265 /// By default, performs semantic analysis to build the new statement.
2266 /// Subclasses may override this routine to provide different behavior.
2267 OMPClause *
2269 ArrayRef<SourceLocation> MotionModifiersLoc,
2270 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2271 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2272 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2273 ArrayRef<Expr *> UnresolvedMappers) {
2275 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2276 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2277 UnresolvedMappers);
2278 }
2279
2280 /// Build a new OpenMP 'from' clause.
2281 ///
2282 /// By default, performs semantic analysis to build the new statement.
2283 /// Subclasses may override this routine to provide different behavior.
2284 OMPClause *
2286 ArrayRef<SourceLocation> MotionModifiersLoc,
2287 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2288 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2289 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2290 ArrayRef<Expr *> UnresolvedMappers) {
2292 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2293 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2294 UnresolvedMappers);
2295 }
2296
2297 /// Build a new OpenMP 'use_device_ptr' clause.
2298 ///
2299 /// By default, performs semantic analysis to build the new OpenMP clause.
2300 /// Subclasses may override this routine to provide different behavior.
2302 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2303 OpenMPUseDevicePtrFallbackModifier FallbackModifier,
2304 SourceLocation FallbackModifierLoc) {
2306 VarList, Locs, FallbackModifier, FallbackModifierLoc);
2307 }
2308
2309 /// Build a new OpenMP 'use_device_addr' clause.
2310 ///
2311 /// By default, performs semantic analysis to build the new OpenMP clause.
2312 /// Subclasses may override this routine to provide different behavior.
2317
2318 /// Build a new OpenMP 'is_device_ptr' clause.
2319 ///
2320 /// By default, performs semantic analysis to build the new OpenMP clause.
2321 /// Subclasses may override this routine to provide different behavior.
2323 const OMPVarListLocTy &Locs) {
2324 return getSema().OpenMP().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
2325 }
2326
2327 /// Build a new OpenMP 'has_device_addr' clause.
2328 ///
2329 /// By default, performs semantic analysis to build the new OpenMP clause.
2330 /// Subclasses may override this routine to provide different behavior.
2335
2336 /// Build a new OpenMP 'defaultmap' clause.
2337 ///
2338 /// By default, performs semantic analysis to build the new OpenMP clause.
2339 /// Subclasses may override this routine to provide different behavior.
2342 SourceLocation StartLoc,
2343 SourceLocation LParenLoc,
2344 SourceLocation MLoc,
2345 SourceLocation KindLoc,
2346 SourceLocation EndLoc) {
2348 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2349 }
2350
2351 /// Build a new OpenMP 'nontemporal' clause.
2352 ///
2353 /// By default, performs semantic analysis to build the new OpenMP clause.
2354 /// Subclasses may override this routine to provide different behavior.
2356 SourceLocation StartLoc,
2357 SourceLocation LParenLoc,
2358 SourceLocation EndLoc) {
2359 return getSema().OpenMP().ActOnOpenMPNontemporalClause(VarList, StartLoc,
2360 LParenLoc, EndLoc);
2361 }
2362
2363 /// Build a new OpenMP 'inclusive' clause.
2364 ///
2365 /// By default, performs semantic analysis to build the new OpenMP clause.
2366 /// Subclasses may override this routine to provide different behavior.
2368 SourceLocation StartLoc,
2369 SourceLocation LParenLoc,
2370 SourceLocation EndLoc) {
2371 return getSema().OpenMP().ActOnOpenMPInclusiveClause(VarList, StartLoc,
2372 LParenLoc, EndLoc);
2373 }
2374
2375 /// Build a new OpenMP 'exclusive' clause.
2376 ///
2377 /// By default, performs semantic analysis to build the new OpenMP clause.
2378 /// Subclasses may override this routine to provide different behavior.
2380 SourceLocation StartLoc,
2381 SourceLocation LParenLoc,
2382 SourceLocation EndLoc) {
2383 return getSema().OpenMP().ActOnOpenMPExclusiveClause(VarList, StartLoc,
2384 LParenLoc, EndLoc);
2385 }
2386
2387 /// Build a new OpenMP 'uses_allocators' clause.
2388 ///
2389 /// By default, performs semantic analysis to build the new OpenMP clause.
2390 /// Subclasses may override this routine to provide different behavior.
2397
2398 /// Build a new OpenMP 'affinity' clause.
2399 ///
2400 /// By default, performs semantic analysis to build the new OpenMP clause.
2401 /// Subclasses may override this routine to provide different behavior.
2403 SourceLocation LParenLoc,
2404 SourceLocation ColonLoc,
2405 SourceLocation EndLoc, Expr *Modifier,
2406 ArrayRef<Expr *> Locators) {
2408 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2409 }
2410
2411 /// Build a new OpenMP 'order' clause.
2412 ///
2413 /// By default, performs semantic analysis to build the new OpenMP clause.
2414 /// Subclasses may override this routine to provide different behavior.
2416 OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc,
2417 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
2418 OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc) {
2420 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2421 }
2422
2423 /// Build a new OpenMP 'init' clause.
2424 ///
2425 /// By default, performs semantic analysis to build the new OpenMP clause.
2426 /// Subclasses may override this routine to provide different behavior.
2428 SourceLocation StartLoc,
2429 SourceLocation LParenLoc,
2430 SourceLocation VarLoc,
2431 SourceLocation EndLoc) {
2433 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2434 }
2435
2436 /// Build a new OpenMP 'use' clause.
2437 ///
2438 /// By default, performs semantic analysis to build the new OpenMP clause.
2439 /// Subclasses may override this routine to provide different behavior.
2441 SourceLocation LParenLoc,
2442 SourceLocation VarLoc, SourceLocation EndLoc) {
2443 return getSema().OpenMP().ActOnOpenMPUseClause(InteropVar, StartLoc,
2444 LParenLoc, VarLoc, EndLoc);
2445 }
2446
2447 /// Build a new OpenMP 'destroy' clause.
2448 ///
2449 /// By default, performs semantic analysis to build the new OpenMP clause.
2450 /// Subclasses may override this routine to provide different behavior.
2452 SourceLocation LParenLoc,
2453 SourceLocation VarLoc,
2454 SourceLocation EndLoc) {
2456 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2457 }
2458
2459 /// Build a new OpenMP 'novariants' clause.
2460 ///
2461 /// By default, performs semantic analysis to build the new OpenMP clause.
2462 /// Subclasses may override this routine to provide different behavior.
2464 SourceLocation StartLoc,
2465 SourceLocation LParenLoc,
2466 SourceLocation EndLoc) {
2468 LParenLoc, EndLoc);
2469 }
2470
2471 /// Build a new OpenMP 'nocontext' clause.
2472 ///
2473 /// By default, performs semantic analysis to build the new OpenMP clause.
2474 /// Subclasses may override this routine to provide different behavior.
2476 SourceLocation LParenLoc,
2477 SourceLocation EndLoc) {
2479 LParenLoc, EndLoc);
2480 }
2481
2482 /// Build a new OpenMP 'filter' clause.
2483 ///
2484 /// By default, performs semantic analysis to build the new OpenMP clause.
2485 /// Subclasses may override this routine to provide different behavior.
2487 SourceLocation LParenLoc,
2488 SourceLocation EndLoc) {
2489 return getSema().OpenMP().ActOnOpenMPFilterClause(ThreadID, StartLoc,
2490 LParenLoc, EndLoc);
2491 }
2492
2493 /// Build a new OpenMP 'bind' clause.
2494 ///
2495 /// By default, performs semantic analysis to build the new OpenMP clause.
2496 /// Subclasses may override this routine to provide different behavior.
2498 SourceLocation KindLoc,
2499 SourceLocation StartLoc,
2500 SourceLocation LParenLoc,
2501 SourceLocation EndLoc) {
2502 return getSema().OpenMP().ActOnOpenMPBindClause(Kind, KindLoc, StartLoc,
2503 LParenLoc, EndLoc);
2504 }
2505
2506 /// Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
2507 ///
2508 /// By default, performs semantic analysis to build the new OpenMP clause.
2509 /// Subclasses may override this routine to provide different behavior.
2511 SourceLocation LParenLoc,
2512 SourceLocation EndLoc) {
2513 return getSema().OpenMP().ActOnOpenMPXDynCGroupMemClause(Size, StartLoc,
2514 LParenLoc, EndLoc);
2515 }
2516
2517 /// Build a new OpenMP 'dyn_groupprivate' clause.
2518 ///
2519 /// By default, performs semantic analysis to build the new OpenMP clause.
2520 /// Subclasses may override this routine to provide different behavior.
2524 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc,
2525 SourceLocation M2Loc, SourceLocation EndLoc) {
2527 M1, M2, Size, StartLoc, LParenLoc, M1Loc, M2Loc, EndLoc);
2528 }
2529
2530 /// Build a new OpenMP 'ompx_attribute' clause.
2531 ///
2532 /// By default, performs semantic analysis to build the new OpenMP clause.
2533 /// Subclasses may override this routine to provide different behavior.
2535 SourceLocation StartLoc,
2536 SourceLocation LParenLoc,
2537 SourceLocation EndLoc) {
2538 return getSema().OpenMP().ActOnOpenMPXAttributeClause(Attrs, StartLoc,
2539 LParenLoc, EndLoc);
2540 }
2541
2542 /// Build a new OpenMP 'ompx_bare' clause.
2543 ///
2544 /// By default, performs semantic analysis to build the new OpenMP clause.
2545 /// Subclasses may override this routine to provide different behavior.
2547 SourceLocation EndLoc) {
2548 return getSema().OpenMP().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2549 }
2550
2551 /// Build a new OpenMP 'align' clause.
2552 ///
2553 /// By default, performs semantic analysis to build the new OpenMP clause.
2554 /// Subclasses may override this routine to provide different behavior.
2556 SourceLocation LParenLoc,
2557 SourceLocation EndLoc) {
2558 return getSema().OpenMP().ActOnOpenMPAlignClause(A, StartLoc, LParenLoc,
2559 EndLoc);
2560 }
2561
2562 /// Build a new OpenMP 'at' clause.
2563 ///
2564 /// By default, performs semantic analysis to build the new OpenMP clause.
2565 /// Subclasses may override this routine to provide different behavior.
2567 SourceLocation StartLoc,
2568 SourceLocation LParenLoc,
2569 SourceLocation EndLoc) {
2570 return getSema().OpenMP().ActOnOpenMPAtClause(Kind, KwLoc, StartLoc,
2571 LParenLoc, EndLoc);
2572 }
2573
2574 /// Build a new OpenMP 'severity' clause.
2575 ///
2576 /// By default, performs semantic analysis to build the new OpenMP clause.
2577 /// Subclasses may override this routine to provide different behavior.
2579 SourceLocation KwLoc,
2580 SourceLocation StartLoc,
2581 SourceLocation LParenLoc,
2582 SourceLocation EndLoc) {
2583 return getSema().OpenMP().ActOnOpenMPSeverityClause(Kind, KwLoc, StartLoc,
2584 LParenLoc, EndLoc);
2585 }
2586
2587 /// Build a new OpenMP 'message' clause.
2588 ///
2589 /// By default, performs semantic analysis to build the new OpenMP clause.
2590 /// Subclasses may override this routine to provide different behavior.
2592 SourceLocation LParenLoc,
2593 SourceLocation EndLoc) {
2594 return getSema().OpenMP().ActOnOpenMPMessageClause(MS, StartLoc, LParenLoc,
2595 EndLoc);
2596 }
2597
2598 /// Build a new OpenMP 'doacross' clause.
2599 ///
2600 /// By default, performs semantic analysis to build the new OpenMP clause.
2601 /// Subclasses may override this routine to provide different behavior.
2602 OMPClause *
2604 SourceLocation DepLoc, SourceLocation ColonLoc,
2605 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2606 SourceLocation LParenLoc, SourceLocation EndLoc) {
2608 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2609 }
2610
2611 /// Build a new OpenMP 'holds' clause.
2613 SourceLocation LParenLoc,
2614 SourceLocation EndLoc) {
2615 return getSema().OpenMP().ActOnOpenMPHoldsClause(A, StartLoc, LParenLoc,
2616 EndLoc);
2617 }
2618
2619 /// Rebuild the operand to an Objective-C \@synchronized statement.
2620 ///
2621 /// By default, performs semantic analysis to build the new statement.
2622 /// Subclasses may override this routine to provide different behavior.
2627
2628 /// Build a new Objective-C \@synchronized statement.
2629 ///
2630 /// By default, performs semantic analysis to build the new statement.
2631 /// Subclasses may override this routine to provide different behavior.
2636
2637 /// Build a new Objective-C \@autoreleasepool statement.
2638 ///
2639 /// By default, performs semantic analysis to build the new statement.
2640 /// Subclasses may override this routine to provide different behavior.
2645
2646 /// Build a new Objective-C fast enumeration statement.
2647 ///
2648 /// By default, performs semantic analysis to build the new statement.
2649 /// Subclasses may override this routine to provide different behavior.
2651 Stmt *Element,
2652 Expr *Collection,
2653 SourceLocation RParenLoc,
2654 Stmt *Body) {
2656 ForLoc, Element, Collection, RParenLoc);
2657 if (ForEachStmt.isInvalid())
2658 return StmtError();
2659
2660 return getSema().ObjC().FinishObjCForCollectionStmt(ForEachStmt.get(),
2661 Body);
2662 }
2663
2664 /// Build a new C++ exception declaration.
2665 ///
2666 /// By default, performs semantic analysis to build the new decaration.
2667 /// Subclasses may override this routine to provide different behavior.
2670 SourceLocation StartLoc,
2671 SourceLocation IdLoc,
2672 IdentifierInfo *Id) {
2674 StartLoc, IdLoc, Id);
2675 if (Var)
2676 getSema().CurContext->addDecl(Var);
2677 return Var;
2678 }
2679
2680 /// Build a new C++ catch statement.
2681 ///
2682 /// By default, performs semantic analysis to build the new statement.
2683 /// Subclasses may override this routine to provide different behavior.
2685 VarDecl *ExceptionDecl,
2686 Stmt *Handler) {
2687 return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2688 Handler));
2689 }
2690
2691 /// Build a new C++ try statement.
2692 ///
2693 /// By default, performs semantic analysis to build the new statement.
2694 /// Subclasses may override this routine to provide different behavior.
2696 ArrayRef<Stmt *> Handlers) {
2697 return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2698 }
2699
2700 /// Build a new C++0x range-based for statement.
2701 ///
2702 /// By default, performs semantic analysis to build the new statement.
2703 /// Subclasses may override this routine to provide different behavior.
2705 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init,
2706 SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond,
2707 Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc,
2708 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
2709 // If we've just learned that the range is actually an Objective-C
2710 // collection, treat this as an Objective-C fast enumeration loop.
2711 if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2712 if (RangeStmt->isSingleDecl()) {
2713 if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2714 if (RangeVar->isInvalidDecl())
2715 return StmtError();
2716
2717 Expr *RangeExpr = RangeVar->getInit();
2718 if (!RangeExpr->isTypeDependent() &&
2719 RangeExpr->getType()->isObjCObjectPointerType()) {
2720 // FIXME: Support init-statements in Objective-C++20 ranged for
2721 // statement.
2722 if (Init) {
2723 return SemaRef.Diag(Init->getBeginLoc(),
2724 diag::err_objc_for_range_init_stmt)
2725 << Init->getSourceRange();
2726 }
2728 ForLoc, LoopVar, RangeExpr, RParenLoc);
2729 }
2730 }
2731 }
2732 }
2733
2735 ForLoc, CoawaitLoc, Init, ColonLoc, Range, Begin, End, Cond, Inc,
2736 LoopVar, RParenLoc, Sema::BFRK_Rebuild, LifetimeExtendTemps);
2737 }
2738
2739 /// Build a new C++0x range-based for statement.
2740 ///
2741 /// By default, performs semantic analysis to build the new statement.
2742 /// Subclasses may override this routine to provide different behavior.
2744 bool IsIfExists,
2745 NestedNameSpecifierLoc QualifierLoc,
2746 DeclarationNameInfo NameInfo,
2747 Stmt *Nested) {
2748 return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2749 QualifierLoc, NameInfo, Nested);
2750 }
2751
2752 /// Attach body to a C++0x range-based for statement.
2753 ///
2754 /// By default, performs semantic analysis to finish the new statement.
2755 /// Subclasses may override this routine to provide different behavior.
2757 return getSema().FinishCXXForRangeStmt(ForRange, Body);
2758 }
2759
2761 Stmt *TryBlock, Stmt *Handler) {
2762 return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2763 }
2764
2766 Stmt *Block) {
2767 return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2768 }
2769
2771 return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2772 }
2773
2775 SourceLocation LParen,
2776 SourceLocation RParen,
2777 TypeSourceInfo *TSI) {
2778 return getSema().SYCL().BuildUniqueStableNameExpr(OpLoc, LParen, RParen,
2779 TSI);
2780 }
2781
2782 /// Build a new predefined expression.
2783 ///
2784 /// By default, performs semantic analysis to build the new expression.
2785 /// Subclasses may override this routine to provide different behavior.
2789
2790 /// Build a new expression that references a declaration.
2791 ///
2792 /// By default, performs semantic analysis to build the new expression.
2793 /// Subclasses may override this routine to provide different behavior.
2795 LookupResult &R,
2796 bool RequiresADL) {
2797 return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2798 }
2799
2800
2801 /// Build a new expression that references a declaration.
2802 ///
2803 /// By default, performs semantic analysis to build the new expression.
2804 /// Subclasses may override this routine to provide different behavior.
2806 ValueDecl *VD,
2807 const DeclarationNameInfo &NameInfo,
2809 TemplateArgumentListInfo *TemplateArgs) {
2810 CXXScopeSpec SS;
2811 SS.Adopt(QualifierLoc);
2812 return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2813 TemplateArgs);
2814 }
2815
2816 /// Build a new expression in parentheses.
2817 ///
2818 /// By default, performs semantic analysis to build the new expression.
2819 /// Subclasses may override this routine to provide different behavior.
2821 SourceLocation RParen) {
2822 return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2823 }
2824
2825 /// Build a new pseudo-destructor expression.
2826 ///
2827 /// By default, performs semantic analysis to build the new expression.
2828 /// Subclasses may override this routine to provide different behavior.
2830 SourceLocation OperatorLoc,
2831 bool isArrow,
2832 CXXScopeSpec &SS,
2833 TypeSourceInfo *ScopeType,
2834 SourceLocation CCLoc,
2835 SourceLocation TildeLoc,
2836 PseudoDestructorTypeStorage Destroyed);
2837
2838 /// Build a new unary operator expression.
2839 ///
2840 /// By default, performs semantic analysis to build the new expression.
2841 /// Subclasses may override this routine to provide different behavior.
2844 Expr *SubExpr) {
2845 return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2846 }
2847
2848 /// Build a new builtin offsetof expression.
2849 ///
2850 /// By default, performs semantic analysis to build the new expression.
2851 /// Subclasses may override this routine to provide different behavior.
2853 TypeSourceInfo *Type, const Designation &Desig,
2854 SourceLocation RParenLoc) {
2855 return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Desig, RParenLoc);
2856 }
2857
2858 /// Build a new sizeof, alignof or vec_step expression with a
2859 /// type argument.
2860 ///
2861 /// By default, performs semantic analysis to build the new expression.
2862 /// Subclasses may override this routine to provide different behavior.
2864 SourceLocation OpLoc,
2865 UnaryExprOrTypeTrait ExprKind,
2866 SourceRange R) {
2867 return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2868 }
2869
2870 /// Build a new sizeof, alignof or vec step expression with an
2871 /// expression argument.
2872 ///
2873 /// By default, performs semantic analysis to build the new expression.
2874 /// Subclasses may override this routine to provide different behavior.
2876 UnaryExprOrTypeTrait ExprKind,
2877 SourceRange R) {
2879 = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2880 if (Result.isInvalid())
2881 return ExprError();
2882
2883 return Result;
2884 }
2885
2886 /// Build a new array subscript expression.
2887 ///
2888 /// By default, performs semantic analysis to build the new expression.
2889 /// Subclasses may override this routine to provide different behavior.
2891 SourceLocation LBracketLoc,
2892 Expr *RHS,
2893 SourceLocation RBracketLoc) {
2894 return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2895 LBracketLoc, RHS,
2896 RBracketLoc);
2897 }
2898
2899 /// Build a new matrix single subscript expression.
2900 ///
2901 /// By default, performs semantic analysis to build the new expression.
2902 /// Subclasses may override this routine to provide different behavior.
2904 SourceLocation RBracketLoc) {
2906 RBracketLoc);
2907 }
2908
2909 /// Build a new matrix subscript expression.
2910 ///
2911 /// By default, performs semantic analysis to build the new expression.
2912 /// Subclasses may override this routine to provide different behavior.
2914 Expr *ColumnIdx,
2915 SourceLocation RBracketLoc) {
2916 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2917 RBracketLoc);
2918 }
2919
2920 /// Build a new array section expression.
2921 ///
2922 /// By default, performs semantic analysis to build the new expression.
2923 /// Subclasses may override this routine to provide different behavior.
2925 SourceLocation LBracketLoc,
2926 Expr *LowerBound,
2927 SourceLocation ColonLocFirst,
2928 SourceLocation ColonLocSecond,
2929 Expr *Length, Expr *Stride,
2930 SourceLocation RBracketLoc) {
2931 if (IsOMPArraySection)
2933 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2934 Stride, RBracketLoc);
2935
2936 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2937 "Stride/second colon not allowed for OpenACC");
2938
2940 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2941 }
2942
2943 /// Build a new array shaping expression.
2944 ///
2945 /// By default, performs semantic analysis to build the new expression.
2946 /// Subclasses may override this routine to provide different behavior.
2948 SourceLocation RParenLoc,
2949 ArrayRef<Expr *> Dims,
2950 ArrayRef<SourceRange> BracketsRanges) {
2952 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2953 }
2954
2955 /// Build a new iterator expression.
2956 ///
2957 /// By default, performs semantic analysis to build the new expression.
2958 /// Subclasses may override this routine to provide different behavior.
2961 SourceLocation RLoc,
2964 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2965 }
2966
2967 /// Build a new call expression.
2968 ///
2969 /// By default, performs semantic analysis to build the new expression.
2970 /// Subclasses may override this routine to provide different behavior.
2972 MultiExprArg Args,
2973 SourceLocation RParenLoc,
2974 Expr *ExecConfig = nullptr) {
2975 return getSema().ActOnCallExpr(
2976 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2977 }
2978
2980 MultiExprArg Args,
2981 SourceLocation RParenLoc) {
2983 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2984 }
2985
2986 /// Build a new member access expression.
2987 ///
2988 /// By default, performs semantic analysis to build the new expression.
2989 /// Subclasses may override this routine to provide different behavior.
2991 bool isArrow,
2992 NestedNameSpecifierLoc QualifierLoc,
2993 SourceLocation TemplateKWLoc,
2994 const DeclarationNameInfo &MemberNameInfo,
2996 NamedDecl *FoundDecl,
2997 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2998 NamedDecl *FirstQualifierInScope) {
3000 isArrow);
3001 if (!Member->getDeclName()) {
3002 // We have a reference to an unnamed field. This is always the
3003 // base of an anonymous struct/union member access, i.e. the
3004 // field is always of record type.
3005 assert(Member->getType()->isRecordType() &&
3006 "unnamed member not of record type?");
3007
3008 BaseResult =
3010 QualifierLoc.getNestedNameSpecifier(),
3011 FoundDecl, Member);
3012 if (BaseResult.isInvalid())
3013 return ExprError();
3014 Base = BaseResult.get();
3015
3016 // `TranformMaterializeTemporaryExpr()` removes materialized temporaries
3017 // from the AST, so we need to re-insert them if needed (since
3018 // `BuildFieldRefereneExpr()` doesn't do this).
3019 if (!isArrow && Base->isPRValue()) {
3021 if (BaseResult.isInvalid())
3022 return ExprError();
3023 Base = BaseResult.get();
3024 }
3025
3026 CXXScopeSpec EmptySS;
3028 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
3029 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
3030 MemberNameInfo);
3031 }
3032
3033 CXXScopeSpec SS;
3034 SS.Adopt(QualifierLoc);
3035
3036 Base = BaseResult.get();
3037 if (Base->containsErrors())
3038 return ExprError();
3039
3040 QualType BaseType = Base->getType();
3041
3042 if (isArrow && !BaseType->isPointerType())
3043 return ExprError();
3044
3045 // FIXME: this involves duplicating earlier analysis in a lot of
3046 // cases; we should avoid this when possible.
3047 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
3048 R.addDecl(FoundDecl);
3049 R.resolveKind();
3050
3051 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
3053 if (auto *ThisClass = cast<CXXThisExpr>(Base)
3054 ->getType()
3055 ->getPointeeType()
3056 ->getAsCXXRecordDecl()) {
3057 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
3058 // In unevaluated contexts, an expression supposed to be a member access
3059 // might reference a member in an unrelated class.
3060 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
3061 return getSema().BuildDeclRefExpr(Member, Member->getType(),
3062 VK_LValue, Member->getLocation());
3063 }
3064 }
3065
3066 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
3067 SS, TemplateKWLoc,
3068 FirstQualifierInScope,
3069 R, ExplicitTemplateArgs,
3070 /*S*/nullptr);
3071 }
3072
3073 /// Build a new binary operator expression.
3074 ///
3075 /// By default, performs semantic analysis to build the new expression.
3076 /// Subclasses may override this routine to provide different behavior.
3078 Expr *LHS, Expr *RHS,
3079 bool ForFoldExpression = false) {
3080 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS,
3081 ForFoldExpression);
3082 }
3083
3084 /// Build a new rewritten operator expression.
3085 ///
3086 /// By default, performs semantic analysis to build the new expression.
3087 /// Subclasses may override this routine to provide different behavior.
3089 SourceLocation OpLoc, BinaryOperatorKind Opcode,
3090 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
3091 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
3092 RHS, /*RequiresADL*/false);
3093 }
3094
3095 /// Build a new conditional operator expression.
3096 ///
3097 /// By default, performs semantic analysis to build the new expression.
3098 /// Subclasses may override this routine to provide different behavior.
3100 SourceLocation QuestionLoc,
3101 Expr *LHS,
3102 SourceLocation ColonLoc,
3103 Expr *RHS) {
3104 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
3105 LHS, RHS);
3106 }
3107
3108 /// Build a new C-style cast expression.
3109 ///
3110 /// By default, performs semantic analysis to build the new expression.
3111 /// Subclasses may override this routine to provide different behavior.
3113 TypeSourceInfo *TInfo,
3114 SourceLocation RParenLoc,
3115 Expr *SubExpr) {
3116 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
3117 SubExpr);
3118 }
3119
3120 /// Build a new compound literal expression.
3121 ///
3122 /// By default, performs semantic analysis to build the new expression.
3123 /// Subclasses may override this routine to provide different behavior.
3125 TypeSourceInfo *TInfo,
3126 SourceLocation RParenLoc,
3127 Expr *Init) {
3128 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
3129 Init);
3130 }
3131
3132 /// Build a new extended vector or matrix element access expression.
3133 ///
3134 /// By default, performs semantic analysis to build the new expression.
3135 /// Subclasses may override this routine to provide different behavior.
3137 SourceLocation OpLoc,
3138 bool IsArrow,
3139 SourceLocation AccessorLoc,
3140 IdentifierInfo &Accessor) {
3141
3142 CXXScopeSpec SS;
3143 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3145 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3146 /*FirstQualifierInScope*/ nullptr, NameInfo,
3147 /* TemplateArgs */ nullptr,
3148 /*S*/ nullptr);
3149 }
3150
3151 /// Build a new initializer list expression.
3152 ///
3153 /// By default, performs semantic analysis to build the new expression.
3154 /// Subclasses may override this routine to provide different behavior.
3156 SourceLocation RBraceLoc, bool IsExplicit) {
3157 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc, IsExplicit);
3158 }
3159
3160 /// Build a new designated initializer expression.
3161 ///
3162 /// By default, performs semantic analysis to build the new expression.
3163 /// Subclasses may override this routine to provide different behavior.
3165 MultiExprArg ArrayExprs,
3166 SourceLocation EqualOrColonLoc,
3167 bool GNUSyntax,
3168 Expr *Init) {
3170 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3171 Init);
3172 if (Result.isInvalid())
3173 return ExprError();
3174
3175 return Result;
3176 }
3177
3178 /// Build a new value-initialized expression.
3179 ///
3180 /// By default, builds the implicit value initialization without performing
3181 /// any semantic analysis. Subclasses may override this routine to provide
3182 /// different behavior.
3186
3187 /// Build a new \c va_arg expression.
3188 ///
3189 /// By default, performs semantic analysis to build the new expression.
3190 /// Subclasses may override this routine to provide different behavior.
3192 Expr *SubExpr, TypeSourceInfo *TInfo,
3193 SourceLocation RParenLoc) {
3194 return getSema().BuildVAArgExpr(BuiltinLoc,
3195 SubExpr, TInfo,
3196 RParenLoc);
3197 }
3198
3199 /// Build a new expression list in parentheses.
3200 ///
3201 /// By default, performs semantic analysis to build the new expression.
3202 /// Subclasses may override this routine to provide different behavior.
3204 MultiExprArg SubExprs,
3205 SourceLocation RParenLoc) {
3206 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3207 }
3208
3210 unsigned NumUserSpecifiedExprs,
3211 SourceLocation InitLoc,
3212 SourceLocation LParenLoc,
3213 SourceLocation RParenLoc) {
3214 return getSema().ActOnCXXParenListInitExpr(Args, T, NumUserSpecifiedExprs,
3215 InitLoc, LParenLoc, RParenLoc);
3216 }
3217
3218 /// Build a new address-of-label expression.
3219 ///
3220 /// By default, performs semantic analysis, using the name of the label
3221 /// rather than attempting to map the label statement itself.
3222 /// Subclasses may override this routine to provide different behavior.
3224 SourceLocation LabelLoc, LabelDecl *Label) {
3225 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3226 }
3227
3228 /// Build a new GNU statement expression.
3229 ///
3230 /// By default, performs semantic analysis to build the new expression.
3231 /// Subclasses may override this routine to provide different behavior.
3233 SourceLocation RParenLoc, unsigned TemplateDepth) {
3234 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3235 TemplateDepth);
3236 }
3237
3238 /// Build a new __builtin_choose_expr expression.
3239 ///
3240 /// By default, performs semantic analysis to build the new expression.
3241 /// Subclasses may override this routine to provide different behavior.
3243 Expr *Cond, Expr *LHS, Expr *RHS,
3244 SourceLocation RParenLoc) {
3245 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3246 Cond, LHS, RHS,
3247 RParenLoc);
3248 }
3249
3250 /// Build a new generic selection expression with an expression predicate.
3251 ///
3252 /// By default, performs semantic analysis to build the new expression.
3253 /// Subclasses may override this routine to provide different behavior.
3255 SourceLocation DefaultLoc,
3256 SourceLocation RParenLoc,
3257 Expr *ControllingExpr,
3259 ArrayRef<Expr *> Exprs) {
3260 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3261 /*PredicateIsExpr=*/true,
3262 ControllingExpr, Types, Exprs);
3263 }
3264
3265 /// Build a new generic selection expression with a type predicate.
3266 ///
3267 /// By default, performs semantic analysis to build the new expression.
3268 /// Subclasses may override this routine to provide different behavior.
3270 SourceLocation DefaultLoc,
3271 SourceLocation RParenLoc,
3272 TypeSourceInfo *ControllingType,
3274 ArrayRef<Expr *> Exprs) {
3275 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3276 /*PredicateIsExpr=*/false,
3277 ControllingType, Types, Exprs);
3278 }
3279
3280 /// Build a new overloaded operator call expression.
3281 ///
3282 /// By default, performs semantic analysis to build the new expression.
3283 /// The semantic analysis provides the behavior of template instantiation,
3284 /// copying with transformations that turn what looks like an overloaded
3285 /// operator call into a use of a builtin operator, performing
3286 /// argument-dependent lookup, etc. Subclasses may override this routine to
3287 /// provide different behavior.
3289 SourceLocation OpLoc,
3290 SourceLocation CalleeLoc,
3291 bool RequiresADL,
3292 const UnresolvedSetImpl &Functions,
3293 Expr *First, Expr *Second);
3294
3295 /// Build a new C++ "named" cast expression, such as static_cast or
3296 /// reinterpret_cast.
3297 ///
3298 /// By default, this routine dispatches to one of the more-specific routines
3299 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3300 /// Subclasses may override this routine to provide different behavior.
3303 SourceLocation LAngleLoc,
3304 TypeSourceInfo *TInfo,
3305 SourceLocation RAngleLoc,
3306 SourceLocation LParenLoc,
3307 Expr *SubExpr,
3308 SourceLocation RParenLoc) {
3309 switch (Class) {
3310 case Stmt::CXXStaticCastExprClass:
3311 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3312 RAngleLoc, LParenLoc,
3313 SubExpr, RParenLoc);
3314
3315 case Stmt::CXXDynamicCastExprClass:
3316 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3317 RAngleLoc, LParenLoc,
3318 SubExpr, RParenLoc);
3319
3320 case Stmt::CXXReinterpretCastExprClass:
3321 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3322 RAngleLoc, LParenLoc,
3323 SubExpr,
3324 RParenLoc);
3325
3326 case Stmt::CXXConstCastExprClass:
3327 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3328 RAngleLoc, LParenLoc,
3329 SubExpr, RParenLoc);
3330
3331 case Stmt::CXXAddrspaceCastExprClass:
3332 return getDerived().RebuildCXXAddrspaceCastExpr(
3333 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3334
3335 default:
3336 llvm_unreachable("Invalid C++ named cast");
3337 }
3338 }
3339
3340 /// Build a new C++ static_cast expression.
3341 ///
3342 /// By default, performs semantic analysis to build the new expression.
3343 /// Subclasses may override this routine to provide different behavior.
3345 SourceLocation LAngleLoc,
3346 TypeSourceInfo *TInfo,
3347 SourceLocation RAngleLoc,
3348 SourceLocation LParenLoc,
3349 Expr *SubExpr,
3350 SourceLocation RParenLoc) {
3351 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3352 TInfo, SubExpr,
3353 SourceRange(LAngleLoc, RAngleLoc),
3354 SourceRange(LParenLoc, RParenLoc));
3355 }
3356
3357 /// Build a new C++ dynamic_cast expression.
3358 ///
3359 /// By default, performs semantic analysis to build the new expression.
3360 /// Subclasses may override this routine to provide different behavior.
3362 SourceLocation LAngleLoc,
3363 TypeSourceInfo *TInfo,
3364 SourceLocation RAngleLoc,
3365 SourceLocation LParenLoc,
3366 Expr *SubExpr,
3367 SourceLocation RParenLoc) {
3368 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3369 TInfo, SubExpr,
3370 SourceRange(LAngleLoc, RAngleLoc),
3371 SourceRange(LParenLoc, RParenLoc));
3372 }
3373
3374 /// Build a new C++ reinterpret_cast expression.
3375 ///
3376 /// By default, performs semantic analysis to build the new expression.
3377 /// Subclasses may override this routine to provide different behavior.
3379 SourceLocation LAngleLoc,
3380 TypeSourceInfo *TInfo,
3381 SourceLocation RAngleLoc,
3382 SourceLocation LParenLoc,
3383 Expr *SubExpr,
3384 SourceLocation RParenLoc) {
3385 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3386 TInfo, SubExpr,
3387 SourceRange(LAngleLoc, RAngleLoc),
3388 SourceRange(LParenLoc, RParenLoc));
3389 }
3390
3391 /// Build a new C++ const_cast expression.
3392 ///
3393 /// By default, performs semantic analysis to build the new expression.
3394 /// Subclasses may override this routine to provide different behavior.
3396 SourceLocation LAngleLoc,
3397 TypeSourceInfo *TInfo,
3398 SourceLocation RAngleLoc,
3399 SourceLocation LParenLoc,
3400 Expr *SubExpr,
3401 SourceLocation RParenLoc) {
3402 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3403 TInfo, SubExpr,
3404 SourceRange(LAngleLoc, RAngleLoc),
3405 SourceRange(LParenLoc, RParenLoc));
3406 }
3407
3410 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3411 SourceLocation LParenLoc, Expr *SubExpr,
3412 SourceLocation RParenLoc) {
3413 return getSema().BuildCXXNamedCast(
3414 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3415 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3416 }
3417
3418 /// Build a new C++ functional-style cast expression.
3419 ///
3420 /// By default, performs semantic analysis to build the new expression.
3421 /// Subclasses may override this routine to provide different behavior.
3423 SourceLocation LParenLoc,
3424 Expr *Sub,
3425 SourceLocation RParenLoc,
3426 bool ListInitialization) {
3427 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3428 // CXXParenListInitExpr. Pass its expanded arguments so that the
3429 // CXXParenListInitExpr can be rebuilt.
3430 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3432 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3433 RParenLoc, ListInitialization);
3434
3435 if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub))
3437 TInfo, LParenLoc, PLE->getUserSpecifiedInitExprs(), RParenLoc,
3438 ListInitialization);
3439
3440 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3441 MultiExprArg(&Sub, 1), RParenLoc,
3442 ListInitialization);
3443 }
3444
3445 /// Build a new C++ __builtin_bit_cast expression.
3446 ///
3447 /// By default, performs semantic analysis to build the new expression.
3448 /// Subclasses may override this routine to provide different behavior.
3450 TypeSourceInfo *TSI, Expr *Sub,
3451 SourceLocation RParenLoc) {
3452 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3453 }
3454
3455 /// Build a new C++ typeid(type) expression.
3456 ///
3457 /// By default, performs semantic analysis to build the new expression.
3458 /// Subclasses may override this routine to provide different behavior.
3460 SourceLocation TypeidLoc,
3461 TypeSourceInfo *Operand,
3462 SourceLocation RParenLoc) {
3463 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3464 RParenLoc);
3465 }
3466
3467
3468 /// Build a new C++ typeid(expr) expression.
3469 ///
3470 /// By default, performs semantic analysis to build the new expression.
3471 /// Subclasses may override this routine to provide different behavior.
3473 SourceLocation TypeidLoc,
3474 Expr *Operand,
3475 SourceLocation RParenLoc) {
3476 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3477 RParenLoc);
3478 }
3479
3480 /// Build a new C++ __uuidof(type) expression.
3481 ///
3482 /// By default, performs semantic analysis to build the new expression.
3483 /// Subclasses may override this routine to provide different behavior.
3485 TypeSourceInfo *Operand,
3486 SourceLocation RParenLoc) {
3487 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3488 }
3489
3490 /// Build a new C++ __uuidof(expr) expression.
3491 ///
3492 /// By default, performs semantic analysis to build the new expression.
3493 /// Subclasses may override this routine to provide different behavior.
3495 Expr *Operand, SourceLocation RParenLoc) {
3496 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3497 }
3498
3499 /// Build a new C++ "this" expression.
3500 ///
3501 /// By default, performs semantic analysis to build a new "this" expression.
3502 /// Subclasses may override this routine to provide different behavior.
3504 QualType ThisType,
3505 bool isImplicit) {
3506 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3507 return ExprError();
3508 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3509 }
3510
3511 /// Build a new C++ throw expression.
3512 ///
3513 /// By default, performs semantic analysis to build the new expression.
3514 /// Subclasses may override this routine to provide different behavior.
3516 bool IsThrownVariableInScope) {
3517 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3518 }
3519
3520 /// Build a new C++ default-argument expression.
3521 ///
3522 /// By default, builds a new default-argument expression, which does not
3523 /// require any semantic analysis. Subclasses may override this routine to
3524 /// provide different behavior.
3526 Expr *RewrittenExpr) {
3527 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3528 RewrittenExpr, getSema().CurContext);
3529 }
3530
3531 /// Build a new C++11 default-initialization expression.
3532 ///
3533 /// By default, builds a new default field initialization expression, which
3534 /// does not require any semantic analysis. Subclasses may override this
3535 /// routine to provide different behavior.
3540
3541 /// Build a new C++ zero-initialization expression.
3542 ///
3543 /// By default, performs semantic analysis to build the new expression.
3544 /// Subclasses may override this routine to provide different behavior.
3546 SourceLocation LParenLoc,
3547 SourceLocation RParenLoc) {
3548 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3549 /*ListInitialization=*/false);
3550 }
3551
3552 /// Build a new C++ "new" expression.
3553 ///
3554 /// By default, performs semantic analysis to build the new expression.
3555 /// Subclasses may override this routine to provide different behavior.
3557 SourceLocation PlacementLParen,
3558 MultiExprArg PlacementArgs,
3559 SourceLocation PlacementRParen,
3560 SourceRange TypeIdParens, QualType AllocatedType,
3561 TypeSourceInfo *AllocatedTypeInfo,
3562 std::optional<Expr *> ArraySize,
3563 SourceRange DirectInitRange, Expr *Initializer) {
3564 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3565 PlacementLParen,
3566 PlacementArgs,
3567 PlacementRParen,
3568 TypeIdParens,
3569 AllocatedType,
3570 AllocatedTypeInfo,
3571 ArraySize,
3572 DirectInitRange,
3573 Initializer);
3574 }
3575
3576 /// Build a new C++ "delete" expression.
3577 ///
3578 /// By default, performs semantic analysis to build the new expression.
3579 /// Subclasses may override this routine to provide different behavior.
3581 bool IsGlobalDelete,
3582 bool IsArrayForm,
3583 Expr *Operand) {
3584 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3585 Operand);
3586 }
3587
3588 /// Build a new type trait expression.
3589 ///
3590 /// By default, performs semantic analysis to build the new expression.
3591 /// Subclasses may override this routine to provide different behavior.
3593 SourceLocation StartLoc,
3595 SourceLocation RParenLoc) {
3596 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3597 }
3598
3599 /// Build a new array type trait expression.
3600 ///
3601 /// By default, performs semantic analysis to build the new expression.
3602 /// Subclasses may override this routine to provide different behavior.
3603 ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait,
3604 SourceLocation StartLoc,
3605 TypeSourceInfo *TSInfo,
3606 Expr *DimExpr,
3607 SourceLocation RParenLoc) {
3608 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3609 }
3610
3611 /// Build a new expression trait expression.
3612 ///
3613 /// By default, performs semantic analysis to build the new expression.
3614 /// Subclasses may override this routine to provide different behavior.
3615 ExprResult RebuildExpressionTrait(ExpressionTrait Trait,
3616 SourceLocation StartLoc,
3617 Expr *Queried,
3618 SourceLocation RParenLoc) {
3619 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3620 }
3621
3622 /// Build a new (previously unresolved) declaration reference
3623 /// expression.
3624 ///
3625 /// By default, performs semantic analysis to build the new expression.
3626 /// Subclasses may override this routine to provide different behavior.
3628 NestedNameSpecifierLoc QualifierLoc,
3629 SourceLocation TemplateKWLoc,
3630 const DeclarationNameInfo &NameInfo,
3631 const TemplateArgumentListInfo *TemplateArgs,
3632 bool IsAddressOfOperand,
3633 TypeSourceInfo **RecoveryTSI) {
3634 CXXScopeSpec SS;
3635 SS.Adopt(QualifierLoc);
3636
3637 if (TemplateArgs || TemplateKWLoc.isValid())
3639 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3640
3642 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3643 }
3644
3645 /// Build a new template-id expression.
3646 ///
3647 /// By default, performs semantic analysis to build the new expression.
3648 /// Subclasses may override this routine to provide different behavior.
3650 SourceLocation TemplateKWLoc,
3651 LookupResult &R,
3652 bool RequiresADL,
3653 const TemplateArgumentListInfo *TemplateArgs) {
3654 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3655 TemplateArgs);
3656 }
3657
3658 /// Build a new object-construction expression.
3659 ///
3660 /// By default, performs semantic analysis to build the new expression.
3661 /// Subclasses may override this routine to provide different behavior.
3664 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3665 bool ListInitialization, bool StdInitListInitialization,
3666 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3667 SourceRange ParenRange) {
3668 // Reconstruct the constructor we originally found, which might be
3669 // different if this is a call to an inherited constructor.
3670 CXXConstructorDecl *FoundCtor = Constructor;
3671 if (Constructor->isInheritingConstructor())
3672 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3673
3674 SmallVector<Expr *, 8> ConvertedArgs;
3675 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3676 ConvertedArgs))
3677 return ExprError();
3678
3680 IsElidable,
3681 ConvertedArgs,
3682 HadMultipleCandidates,
3683 ListInitialization,
3684 StdInitListInitialization,
3685 RequiresZeroInit, ConstructKind,
3686 ParenRange);
3687 }
3688
3689 /// Build a new implicit construction via inherited constructor
3690 /// expression.
3693 bool ConstructsVBase,
3694 bool InheritedFromVBase) {
3696 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3697 }
3698
3699 /// Build a new object-construction expression.
3700 ///
3701 /// By default, performs semantic analysis to build the new expression.
3702 /// Subclasses may override this routine to provide different behavior.
3704 SourceLocation LParenOrBraceLoc,
3705 MultiExprArg Args,
3706 SourceLocation RParenOrBraceLoc,
3707 bool ListInitialization) {
3709 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3710 }
3711
3712 /// Build a new object-construction expression.
3713 ///
3714 /// By default, performs semantic analysis to build the new expression.
3715 /// Subclasses may override this routine to provide different behavior.
3717 SourceLocation LParenLoc,
3718 MultiExprArg Args,
3719 SourceLocation RParenLoc,
3720 bool ListInitialization) {
3721 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3722 RParenLoc, ListInitialization);
3723 }
3724
3725 /// Build a new member reference expression.
3726 ///
3727 /// By default, performs semantic analysis to build the new expression.
3728 /// Subclasses may override this routine to provide different behavior.
3730 QualType BaseType,
3731 bool IsArrow,
3732 SourceLocation OperatorLoc,
3733 NestedNameSpecifierLoc QualifierLoc,
3734 SourceLocation TemplateKWLoc,
3735 NamedDecl *FirstQualifierInScope,
3736 const DeclarationNameInfo &MemberNameInfo,
3737 const TemplateArgumentListInfo *TemplateArgs) {
3738 CXXScopeSpec SS;
3739 SS.Adopt(QualifierLoc);
3740
3741 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3742 OperatorLoc, IsArrow,
3743 SS, TemplateKWLoc,
3744 FirstQualifierInScope,
3745 MemberNameInfo,
3746 TemplateArgs, /*S*/nullptr);
3747 }
3748
3749 /// Build a new member reference expression.
3750 ///
3751 /// By default, performs semantic analysis to build the new expression.
3752 /// Subclasses may override this routine to provide different behavior.
3754 SourceLocation OperatorLoc,
3755 bool IsArrow,
3756 NestedNameSpecifierLoc QualifierLoc,
3757 SourceLocation TemplateKWLoc,
3758 NamedDecl *FirstQualifierInScope,
3759 LookupResult &R,
3760 const TemplateArgumentListInfo *TemplateArgs) {
3761 CXXScopeSpec SS;
3762 SS.Adopt(QualifierLoc);
3763
3764 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3765 OperatorLoc, IsArrow,
3766 SS, TemplateKWLoc,
3767 FirstQualifierInScope,
3768 R, TemplateArgs, /*S*/nullptr);
3769 }
3770
3771 /// Build a new noexcept expression.
3772 ///
3773 /// By default, performs semantic analysis to build the new expression.
3774 /// Subclasses may override this routine to provide different behavior.
3776 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3777 }
3778
3781
3782 /// Build a new expression to compute the length of a parameter pack.
3784 SourceLocation PackLoc,
3785 SourceLocation RParenLoc,
3786 UnsignedOrNone Length,
3787 ArrayRef<TemplateArgument> PartialArgs) {
3788 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3789 RParenLoc, Length, PartialArgs);
3790 }
3791
3793 SourceLocation RSquareLoc,
3794 Expr *PackIdExpression, Expr *IndexExpr,
3795 ArrayRef<Expr *> ExpandedExprs,
3796 bool FullySubstituted = false) {
3797 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3798 IndexExpr, RSquareLoc, ExpandedExprs,
3799 FullySubstituted);
3800 }
3801
3802 /// Build a new expression representing a call to a source location
3803 /// builtin.
3804 ///
3805 /// By default, performs semantic analysis to build the new expression.
3806 /// Subclasses may override this routine to provide different behavior.
3808 SourceLocation BuiltinLoc,
3809 SourceLocation RPLoc,
3810 DeclContext *ParentContext) {
3811 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3812 ParentContext);
3813 }
3814
3816 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3817 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3819 CXXScopeSpec SS;
3820 SS.Adopt(NNS);
3821 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3822 ConceptNameInfo,
3823 FoundDecl,
3824 NamedConcept, TALI);
3825 if (Result.isInvalid())
3826 return ExprError();
3827 return Result;
3828 }
3829
3830 /// \brief Build a new requires expression.
3831 ///
3832 /// By default, performs semantic analysis to build the new expression.
3833 /// Subclasses may override this routine to provide different behavior.
3836 SourceLocation LParenLoc,
3837 ArrayRef<ParmVarDecl *> LocalParameters,
3838 SourceLocation RParenLoc,
3840 SourceLocation ClosingBraceLoc) {
3841 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3842 LocalParameters, RParenLoc, Requirements,
3843 ClosingBraceLoc);
3844 }
3845
3849 return SemaRef.BuildTypeRequirement(SubstDiag);
3850 }
3851
3853 return SemaRef.BuildTypeRequirement(T);
3854 }
3855
3858 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3859 SourceLocation NoexceptLoc,
3861 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3862 std::move(Ret));
3863 }
3864
3866 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3868 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3869 std::move(Ret));
3870 }
3871
3873 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3874 const ASTConstraintSatisfaction &Satisfaction) {
3875 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3876 Satisfaction);
3877 }
3878
3880 return SemaRef.BuildNestedRequirement(Constraint);
3881 }
3882
3883 /// \brief Build a new Objective-C boxed expression.
3884 ///
3885 /// By default, performs semantic analysis to build the new expression.
3886 /// Subclasses may override this routine to provide different behavior.
3888 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3889 }
3890
3891 /// Build a new Objective-C array literal.
3892 ///
3893 /// By default, performs semantic analysis to build the new expression.
3894 /// Subclasses may override this routine to provide different behavior.
3896 Expr **Elements, unsigned NumElements) {
3898 Range, MultiExprArg(Elements, NumElements));
3899 }
3900
3902 Expr *Base, Expr *Key,
3903 ObjCMethodDecl *getterMethod,
3904 ObjCMethodDecl *setterMethod) {
3906 RB, Base, Key, getterMethod, setterMethod);
3907 }
3908
3909 /// Build a new Objective-C dictionary literal.
3910 ///
3911 /// By default, performs semantic analysis to build the new expression.
3912 /// Subclasses may override this routine to provide different behavior.
3917
3918 /// Build a new Objective-C \@encode expression.
3919 ///
3920 /// By default, performs semantic analysis to build the new expression.
3921 /// Subclasses may override this routine to provide different behavior.
3923 TypeSourceInfo *EncodeTypeInfo,
3924 SourceLocation RParenLoc) {
3925 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3926 RParenLoc);
3927 }
3928
3929 /// Build a new Objective-C class message.
3931 Selector Sel,
3932 ArrayRef<SourceLocation> SelectorLocs,
3934 SourceLocation LBracLoc,
3935 MultiExprArg Args,
3936 SourceLocation RBracLoc) {
3937 return SemaRef.ObjC().BuildClassMessage(
3938 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3939 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3940 RBracLoc, Args);
3941 }
3942
3943 /// Build a new Objective-C instance message.
3945 Selector Sel,
3946 ArrayRef<SourceLocation> SelectorLocs,
3948 SourceLocation LBracLoc,
3949 MultiExprArg Args,
3950 SourceLocation RBracLoc) {
3951 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3952 /*SuperLoc=*/SourceLocation(),
3953 Sel, Method, LBracLoc,
3954 SelectorLocs, RBracLoc, Args);
3955 }
3956
3957 /// Build a new Objective-C instance/class message to 'super'.
3959 Selector Sel,
3960 ArrayRef<SourceLocation> SelectorLocs,
3961 QualType SuperType,
3963 SourceLocation LBracLoc,
3964 MultiExprArg Args,
3965 SourceLocation RBracLoc) {
3966 return Method->isInstanceMethod()
3967 ? SemaRef.ObjC().BuildInstanceMessage(
3968 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3969 SelectorLocs, RBracLoc, Args)
3970 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3971 Sel, Method, LBracLoc,
3972 SelectorLocs, RBracLoc, Args);
3973 }
3974
3975 /// Build a new Objective-C ivar reference expression.
3976 ///
3977 /// By default, performs semantic analysis to build the new expression.
3978 /// Subclasses may override this routine to provide different behavior.
3980 SourceLocation IvarLoc,
3981 bool IsArrow, bool IsFreeIvar) {
3982 CXXScopeSpec SS;
3983 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3985 BaseArg, BaseArg->getType(),
3986 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3987 /*FirstQualifierInScope=*/nullptr, NameInfo,
3988 /*TemplateArgs=*/nullptr,
3989 /*S=*/nullptr);
3990 if (IsFreeIvar && Result.isUsable())
3991 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3992 return Result;
3993 }
3994
3995 /// Build a new Objective-C property reference expression.
3996 ///
3997 /// By default, performs semantic analysis to build the new expression.
3998 /// Subclasses may override this routine to provide different behavior.
4001 SourceLocation PropertyLoc) {
4002 CXXScopeSpec SS;
4003 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
4004 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
4005 /*FIXME:*/PropertyLoc,
4006 /*IsArrow=*/false,
4007 SS, SourceLocation(),
4008 /*FirstQualifierInScope=*/nullptr,
4009 NameInfo,
4010 /*TemplateArgs=*/nullptr,
4011 /*S=*/nullptr);
4012 }
4013
4014 /// Build a new Objective-C property reference expression.
4015 ///
4016 /// By default, performs semantic analysis to build the new expression.
4017 /// Subclasses may override this routine to provide different behavior.
4019 ObjCMethodDecl *Getter,
4020 ObjCMethodDecl *Setter,
4021 SourceLocation PropertyLoc) {
4022 // Since these expressions can only be value-dependent, we do not
4023 // need to perform semantic analysis again.
4024 return Owned(
4025 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
4027 PropertyLoc, Base));
4028 }
4029
4030 /// Build a new Objective-C "isa" expression.
4031 ///
4032 /// By default, performs semantic analysis to build the new expression.
4033 /// Subclasses may override this routine to provide different behavior.
4035 SourceLocation OpLoc, bool IsArrow) {
4036 CXXScopeSpec SS;
4037 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
4038 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
4039 OpLoc, IsArrow,
4040 SS, SourceLocation(),
4041 /*FirstQualifierInScope=*/nullptr,
4042 NameInfo,
4043 /*TemplateArgs=*/nullptr,
4044 /*S=*/nullptr);
4045 }
4046
4047 /// Build a new shuffle vector expression.
4048 ///
4049 /// By default, performs semantic analysis to build the new expression.
4050 /// Subclasses may override this routine to provide different behavior.
4052 MultiExprArg SubExprs,
4053 SourceLocation RParenLoc) {
4054 // Find the declaration for __builtin_shufflevector
4055 const IdentifierInfo &Name
4056 = SemaRef.Context.Idents.get("__builtin_shufflevector");
4057 TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
4058 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
4059 assert(!Lookup.empty() && "No __builtin_shufflevector?");
4060
4061 // Build a reference to the __builtin_shufflevector builtin
4063 Expr *Callee = new (SemaRef.Context)
4064 DeclRefExpr(SemaRef.Context, Builtin, false,
4065 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
4066 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
4067 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
4068 CK_BuiltinFnToFnPtr).get();
4069
4070 // Build the CallExpr
4071 ExprResult TheCall = CallExpr::Create(
4072 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
4073 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
4075
4076 // Type-check the __builtin_shufflevector expression.
4077 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
4078 }
4079
4080 /// Build a new convert vector expression.
4082 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
4083 SourceLocation RParenLoc) {
4084 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
4085 }
4086
4087 /// Build a new template argument pack expansion.
4088 ///
4089 /// By default, performs semantic analysis to build a new pack expansion
4090 /// for a template argument. Subclasses may override this routine to provide
4091 /// different behavior.
4093 SourceLocation EllipsisLoc,
4094 UnsignedOrNone NumExpansions) {
4095 switch (Pattern.getArgument().getKind()) {
4099 EllipsisLoc, NumExpansions);
4100 if (Result.isInvalid())
4101 return TemplateArgumentLoc();
4102
4104 /*IsCanonical=*/false),
4105 Result.get());
4106 }
4107
4109 return TemplateArgumentLoc(
4110 SemaRef.Context,
4112 NumExpansions),
4113 Pattern.getTemplateKWLoc(), Pattern.getTemplateQualifierLoc(),
4114 Pattern.getTemplateNameLoc(), EllipsisLoc);
4115
4123 llvm_unreachable("Pack expansion pattern has no parameter packs");
4124
4126 if (TypeSourceInfo *Expansion
4127 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4128 EllipsisLoc,
4129 NumExpansions))
4130 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4131 Expansion);
4132 break;
4133 }
4134
4135 return TemplateArgumentLoc();
4136 }
4137
4138 /// Build a new expression pack expansion.
4139 ///
4140 /// By default, performs semantic analysis to build a new pack expansion
4141 /// for an expression. Subclasses may override this routine to provide
4142 /// different behavior.
4144 UnsignedOrNone NumExpansions) {
4145 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4146 }
4147
4148 /// Build a new C++1z fold-expression.
4149 ///
4150 /// By default, performs semantic analysis in order to build a new fold
4151 /// expression.
4153 SourceLocation LParenLoc, Expr *LHS,
4154 BinaryOperatorKind Operator,
4155 SourceLocation EllipsisLoc, Expr *RHS,
4156 SourceLocation RParenLoc,
4157 UnsignedOrNone NumExpansions) {
4158 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4159 EllipsisLoc, RHS, RParenLoc,
4160 NumExpansions);
4161 }
4162
4164 LambdaScopeInfo *LSI) {
4165 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4166 if (Expr *Init = PVD->getInit())
4168 Init->containsUnexpandedParameterPack();
4169 else if (PVD->hasUninstantiatedDefaultArg())
4171 PVD->getUninstantiatedDefaultArg()
4172 ->containsUnexpandedParameterPack();
4173 }
4174 return getSema().BuildLambdaExpr(StartLoc, EndLoc);
4175 }
4176
4177 /// Build an empty C++1z fold-expression with the given operator.
4178 ///
4179 /// By default, produces the fallback value for the fold-expression, or
4180 /// produce an error if there is no fallback value.
4182 BinaryOperatorKind Operator) {
4183 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4184 }
4185
4186 /// Build a new atomic operation expression.
4187 ///
4188 /// By default, performs semantic analysis to build the new expression.
4189 /// Subclasses may override this routine to provide different behavior.
4192 SourceLocation RParenLoc) {
4193 // Use this for all of the locations, since we don't know the difference
4194 // between the call and the expr at this point.
4195 SourceRange Range{BuiltinLoc, RParenLoc};
4196 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4198 }
4199
4201 ArrayRef<Expr *> SubExprs, QualType Type) {
4202 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4203 }
4204
4206 SourceLocation BeginLoc,
4207 SourceLocation DirLoc,
4208 SourceLocation EndLoc,
4210 StmtResult StrBlock) {
4212 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4213 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, StrBlock);
4214 }
4215
4226
4228 SourceLocation BeginLoc,
4229 SourceLocation DirLoc,
4230 SourceLocation EndLoc,
4232 StmtResult Loop) {
4234 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4235 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, Loop);
4236 }
4237
4239 SourceLocation DirLoc,
4240 SourceLocation EndLoc,
4242 StmtResult StrBlock) {
4244 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4246 Clauses, StrBlock);
4247 }
4248
4258
4268
4270 SourceLocation DirLoc,
4271 SourceLocation EndLoc,
4273 StmtResult StrBlock) {
4277 Clauses, StrBlock);
4278 }
4279
4281 SourceLocation DirLoc,
4282 SourceLocation EndLoc,
4283 ArrayRef<OpenACCClause *> Clauses) {
4285 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4287 Clauses, {});
4288 }
4289
4299
4301 SourceLocation DirLoc,
4302 SourceLocation EndLoc,
4303 ArrayRef<OpenACCClause *> Clauses) {
4305 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4307 Clauses, {});
4308 }
4309
4311 SourceLocation DirLoc,
4312 SourceLocation EndLoc,
4313 ArrayRef<OpenACCClause *> Clauses) {
4315 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4317 Clauses, {});
4318 }
4319
4321 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4322 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4323 SourceLocation RParenLoc, SourceLocation EndLoc,
4324 ArrayRef<OpenACCClause *> Clauses) {
4326 Exprs.push_back(DevNumExpr);
4327 llvm::append_range(Exprs, QueueIdExprs);
4329 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4330 Exprs, OpenACCAtomicKind::None, RParenLoc, EndLoc, Clauses, {});
4331 }
4332
4334 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4335 SourceLocation ReadOnlyLoc, ArrayRef<Expr *> VarList,
4336 SourceLocation RParenLoc, SourceLocation EndLoc) {
4338 OpenACCDirectiveKind::Cache, BeginLoc, DirLoc, LParenLoc, ReadOnlyLoc,
4339 VarList, OpenACCAtomicKind::None, RParenLoc, EndLoc, {}, {});
4340 }
4341
4343 SourceLocation DirLoc,
4344 OpenACCAtomicKind AtKind,
4345 SourceLocation EndLoc,
4347 StmtResult AssociatedStmt) {
4349 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4350 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, Clauses,
4351 AssociatedStmt);
4352 }
4353
4357
4359 RebuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, unsigned Index,
4360 QualType ParamType, SourceLocation Loc,
4361 TemplateArgument Arg,
4362 UnsignedOrNone PackIndex, bool Final) {
4364 AssociatedDecl, Index, ParamType, Loc, Arg, PackIndex, Final);
4365 }
4366
4368 SourceLocation StartLoc,
4369 SourceLocation LParenLoc,
4370 SourceLocation EndLoc) {
4371 return getSema().OpenMP().ActOnOpenMPTransparentClause(ImpexType, StartLoc,
4372 LParenLoc, EndLoc);
4373 }
4374
4375private:
4376 QualType TransformTypeInObjectScope(TypeLocBuilder &TLB, TypeLoc TL,
4377 QualType ObjectType,
4378 NamedDecl *FirstQualifierInScope);
4379
4380 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4381 QualType ObjectType,
4382 NamedDecl *FirstQualifierInScope) {
4383 if (getDerived().AlreadyTransformed(TSInfo->getType()))
4384 return TSInfo;
4385
4386 TypeLocBuilder TLB;
4387 QualType T = TransformTypeInObjectScope(TLB, TSInfo->getTypeLoc(),
4388 ObjectType, FirstQualifierInScope);
4389 if (T.isNull())
4390 return nullptr;
4391 return TLB.getTypeSourceInfo(SemaRef.Context, T);
4392 }
4393
4394 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4395 DependentNameTypeLoc TL,
4396 bool DeducibleTSTContext,
4397 QualType ObjectType = QualType(),
4398 NamedDecl *UnqualLookup = nullptr);
4399
4401 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4403
4404 OpenACCClause *
4405 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4406 OpenACCDirectiveKind DirKind,
4407 const OpenACCClause *OldClause);
4408};
4409
4410template <typename Derived>
4412 if (!S)
4413 return S;
4414
4415 switch (S->getStmtClass()) {
4416 case Stmt::NoStmtClass: break;
4417
4418 // Transform individual statement nodes
4419 // Pass SDK into statements that can produce a value
4420#define STMT(Node, Parent) \
4421 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4422#define VALUESTMT(Node, Parent) \
4423 case Stmt::Node##Class: \
4424 return getDerived().Transform##Node(cast<Node>(S), SDK);
4425#define ABSTRACT_STMT(Node)
4426#define EXPR(Node, Parent)
4427#include "clang/AST/StmtNodes.inc"
4428
4429 // Transform expressions by calling TransformExpr.
4430#define STMT(Node, Parent)
4431#define ABSTRACT_STMT(Stmt)
4432#define EXPR(Node, Parent) case Stmt::Node##Class:
4433#include "clang/AST/StmtNodes.inc"
4434 {
4435 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4436
4438 E = getSema().ActOnStmtExprResult(E);
4439 return getSema().ActOnExprStmt(E, SDK == StmtDiscardKind::Discarded);
4440 }
4441 }
4442
4443 return S;
4444}
4445
4446template<typename Derived>
4448 if (!S)
4449 return S;
4450
4451 switch (S->getClauseKind()) {
4452 default: break;
4453 // Transform individual clause nodes
4454#define GEN_CLANG_CLAUSE_CLASS
4455#define CLAUSE_CLASS(Enum, Str, Class) \
4456 case Enum: \
4457 return getDerived().Transform##Class(cast<Class>(S));
4458#include "llvm/Frontend/OpenMP/OMP.inc"
4459 }
4460
4461 return S;
4462}
4463
4464
4465template<typename Derived>
4467 if (!E)
4468 return E;
4469
4470 switch (E->getStmtClass()) {
4471 case Stmt::NoStmtClass: break;
4472#define STMT(Node, Parent) case Stmt::Node##Class: break;
4473#define ABSTRACT_STMT(Stmt)
4474#define EXPR(Node, Parent) \
4475 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4476#include "clang/AST/StmtNodes.inc"
4477 }
4478
4479 return E;
4480}
4481
4482template<typename Derived>
4484 bool NotCopyInit) {
4485 // Initializers are instantiated like expressions, except that various outer
4486 // layers are stripped.
4487 if (!Init)
4488 return Init;
4489
4490 if (auto *FE = dyn_cast<FullExpr>(Init))
4491 Init = FE->getSubExpr();
4492
4493 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4494 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4495 Init = OVE->getSourceExpr();
4496 }
4497
4498 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4499 Init = MTE->getSubExpr();
4500
4501 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4502 Init = Binder->getSubExpr();
4503
4504 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4505 Init = ICE->getSubExprAsWritten();
4506
4507 if (CXXStdInitializerListExpr *ILE =
4508 dyn_cast<CXXStdInitializerListExpr>(Init))
4509 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4510
4511 // If this is copy-initialization, we only need to reconstruct
4512 // InitListExprs. Other forms of copy-initialization will be a no-op if
4513 // the initializer is already the right type.
4514 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4515 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4516 return getDerived().TransformExpr(Init);
4517
4518 // Revert value-initialization back to empty parens.
4519 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4520 SourceRange Parens = VIE->getSourceRange();
4521 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4522 Parens.getEnd());
4523 }
4524
4525 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4527 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4528 SourceLocation());
4529
4530 // Revert initialization by constructor back to a parenthesized or braced list
4531 // of expressions. Any other form of initializer can just be reused directly.
4532 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4533 return getDerived().TransformExpr(Init);
4534
4535 // If the initialization implicitly converted an initializer list to a
4536 // std::initializer_list object, unwrap the std::initializer_list too.
4537 if (Construct && Construct->isStdInitListInitialization())
4538 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4539
4540 // Enter a list-init context if this was list initialization.
4543 Construct->isListInitialization());
4544
4545 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4546 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4547 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4548 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4549 SmallVector<Expr*, 8> NewArgs;
4550 bool ArgChanged = false;
4551 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4552 /*IsCall*/true, NewArgs, &ArgChanged))
4553 return ExprError();
4554
4555 // If this was list initialization, revert to syntactic list form.
4556 if (Construct->isListInitialization())
4557 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4558 Construct->getEndLoc(),
4559 /*IsExplicit=*/true);
4560
4561 // Build a ParenListExpr to represent anything else.
4563 if (Parens.isInvalid()) {
4564 // This was a variable declaration's initialization for which no initializer
4565 // was specified.
4566 assert(NewArgs.empty() &&
4567 "no parens or braces but have direct init with arguments?");
4568 return ExprEmpty();
4569 }
4570 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4571 Parens.getEnd());
4572}
4573
4574template<typename Derived>
4576 unsigned NumInputs,
4577 bool IsCall,
4578 SmallVectorImpl<Expr *> &Outputs,
4579 bool *ArgChanged) {
4580 for (unsigned I = 0; I != NumInputs; ++I) {
4581 // If requested, drop call arguments that need to be dropped.
4582 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4583 if (ArgChanged)
4584 *ArgChanged = true;
4585
4586 break;
4587 }
4588
4589 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4590 Expr *Pattern = Expansion->getPattern();
4591
4593 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4594 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4595
4596 // Determine whether the set of unexpanded parameter packs can and should
4597 // be expanded.
4598 bool Expand = true;
4599 bool RetainExpansion = false;
4600 UnsignedOrNone OrigNumExpansions = Expansion->getNumExpansions();
4601 UnsignedOrNone NumExpansions = OrigNumExpansions;
4603 Expansion->getEllipsisLoc(), Pattern->getSourceRange(),
4604 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
4605 RetainExpansion, NumExpansions))
4606 return true;
4607
4608 if (!Expand) {
4609 // The transform has determined that we should perform a simple
4610 // transformation on the pack expansion, producing another pack
4611 // expansion.
4612 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
4613 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4614 if (OutPattern.isInvalid())
4615 return true;
4616
4617 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4618 Expansion->getEllipsisLoc(),
4619 NumExpansions);
4620 if (Out.isInvalid())
4621 return true;
4622
4623 if (ArgChanged)
4624 *ArgChanged = true;
4625 Outputs.push_back(Out.get());
4626 continue;
4627 }
4628
4629 // Record right away that the argument was changed. This needs
4630 // to happen even if the array expands to nothing.
4631 if (ArgChanged) *ArgChanged = true;
4632
4633 // The transform has determined that we should perform an elementwise
4634 // expansion of the pattern. Do so.
4635 for (unsigned I = 0; I != *NumExpansions; ++I) {
4636 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
4637 ExprResult Out = getDerived().TransformExpr(Pattern);
4638 if (Out.isInvalid())
4639 return true;
4640
4641 if (Out.get()->containsUnexpandedParameterPack()) {
4642 Out = getDerived().RebuildPackExpansion(
4643 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4644 if (Out.isInvalid())
4645 return true;
4646 }
4647
4648 Outputs.push_back(Out.get());
4649 }
4650
4651 // If we're supposed to retain a pack expansion, do so by temporarily
4652 // forgetting the partially-substituted parameter pack.
4653 if (RetainExpansion) {
4654 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4655
4656 ExprResult Out = getDerived().TransformExpr(Pattern);
4657 if (Out.isInvalid())
4658 return true;
4659
4660 Out = getDerived().RebuildPackExpansion(
4661 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4662 if (Out.isInvalid())
4663 return true;
4664
4665 Outputs.push_back(Out.get());
4666 }
4667
4668 continue;
4669 }
4670
4672 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4673 : getDerived().TransformExpr(Inputs[I]);
4674 if (Result.isInvalid())
4675 return true;
4676
4677 if (Result.get() != Inputs[I] && ArgChanged)
4678 *ArgChanged = true;
4679
4680 Outputs.push_back(Result.get());
4681 }
4682
4683 return false;
4684}
4685
4686template <typename Derived>
4689
4692 /*LambdaContextDecl=*/nullptr,
4694 /*ShouldEnter=*/Kind == Sema::ConditionKind::ConstexprIf);
4695
4696 if (Var) {
4697 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4699
4700 if (!ConditionVar)
4701 return Sema::ConditionError();
4702
4703 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4704 }
4705
4706 if (Expr) {
4707 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4708
4709 if (CondExpr.isInvalid())
4710 return Sema::ConditionError();
4711
4712 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4713 /*MissingOK=*/true);
4714 }
4715
4716 return Sema::ConditionResult();
4717}
4718
4719template <typename Derived>
4721 NestedNameSpecifierLoc NNS, QualType ObjectType,
4722 NamedDecl *FirstQualifierInScope) {
4724
4725 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4726 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4727 Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix)
4728 Qualifiers.push_back(Qualifier);
4729 };
4730 insertNNS(NNS);
4731
4732 CXXScopeSpec SS;
4733 while (!Qualifiers.empty()) {
4734 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4736
4737 switch (QNNS.getKind()) {
4739 llvm_unreachable("unexpected null nested name specifier");
4740
4743 Q.getLocalBeginLoc(), const_cast<NamespaceBaseDecl *>(
4745 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4746 break;
4747 }
4748
4750 // There is no meaningful transformation that one could perform on the
4751 // global scope.
4752 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4753 break;
4754
4756 CXXRecordDecl *RD = cast_or_null<CXXRecordDecl>(
4758 SS.MakeMicrosoftSuper(SemaRef.Context, RD, Q.getBeginLoc(),
4759 Q.getEndLoc());
4760 break;
4761 }
4762
4764 assert(SS.isEmpty());
4765 TypeLoc TL = Q.castAsTypeLoc();
4766
4767 if (auto DNT = TL.getAs<DependentNameTypeLoc>()) {
4768 NestedNameSpecifierLoc QualifierLoc = DNT.getQualifierLoc();
4769 if (QualifierLoc) {
4770 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4771 QualifierLoc, ObjectType, FirstQualifierInScope);
4772 if (!QualifierLoc)
4773 return NestedNameSpecifierLoc();
4774 ObjectType = QualType();
4775 FirstQualifierInScope = nullptr;
4776 }
4777 SS.Adopt(QualifierLoc);
4779 const_cast<IdentifierInfo *>(DNT.getTypePtr()->getIdentifier()),
4780 DNT.getNameLoc(), Q.getLocalEndLoc(), ObjectType);
4781 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo,
4782 false, SS,
4783 FirstQualifierInScope, false))
4784 return NestedNameSpecifierLoc();
4785 return SS.getWithLocInContext(SemaRef.Context);
4786 }
4787
4788 QualType T = TL.getType();
4789 TypeLocBuilder TLB;
4791 T = TransformTypeInObjectScope(TLB, TL, ObjectType,
4792 FirstQualifierInScope);
4793 if (T.isNull())
4794 return NestedNameSpecifierLoc();
4795 TL = TLB.getTypeLocInContext(SemaRef.Context, T);
4796 }
4797
4798 if (T->isDependentType() || T->isRecordType() ||
4799 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4800 if (T->isEnumeralType())
4801 SemaRef.Diag(TL.getBeginLoc(),
4802 diag::warn_cxx98_compat_enum_nested_name_spec);
4803 SS.Make(SemaRef.Context, TL, Q.getLocalEndLoc());
4804 break;
4805 }
4806 // If the nested-name-specifier is an invalid type def, don't emit an
4807 // error because a previous error should have already been emitted.
4809 if (!TTL || !TTL.getDecl()->isInvalidDecl()) {
4810 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4811 << T << SS.getRange();
4812 }
4813 return NestedNameSpecifierLoc();
4814 }
4815 }
4816 }
4817
4818 // Don't rebuild the nested-name-specifier if we don't have to.
4819 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4821 return NNS;
4822
4823 // If we can re-use the source-location data from the original
4824 // nested-name-specifier, do so.
4825 if (SS.location_size() == NNS.getDataLength() &&
4826 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4828
4829 // Allocate new nested-name-specifier location information.
4830 return SS.getWithLocInContext(SemaRef.Context);
4831}
4832
4833template<typename Derived>
4837 DeclarationName Name = NameInfo.getName();
4838 if (!Name)
4839 return DeclarationNameInfo();
4840
4841 switch (Name.getNameKind()) {
4849 return NameInfo;
4850
4852 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4853 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4854 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4855 if (!NewTemplate)
4856 return DeclarationNameInfo();
4857
4858 DeclarationNameInfo NewNameInfo(NameInfo);
4859 NewNameInfo.setName(
4860 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
4861 return NewNameInfo;
4862 }
4863
4867 TypeSourceInfo *NewTInfo;
4868 CanQualType NewCanTy;
4869 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4870 NewTInfo = getDerived().TransformType(OldTInfo);
4871 if (!NewTInfo)
4872 return DeclarationNameInfo();
4873 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4874 }
4875 else {
4876 NewTInfo = nullptr;
4877 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4878 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4879 if (NewT.isNull())
4880 return DeclarationNameInfo();
4881 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4882 }
4883
4884 DeclarationName NewName
4885 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4886 NewCanTy);
4887 DeclarationNameInfo NewNameInfo(NameInfo);
4888 NewNameInfo.setName(NewName);
4889 NewNameInfo.setNamedTypeInfo(NewTInfo);
4890 return NewNameInfo;
4891 }
4892 }
4893
4894 llvm_unreachable("Unknown name kind.");
4895}
4896
4897template <typename Derived>
4899 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4901 QualType ObjectType, bool AllowInjectedClassName) {
4902 if (const IdentifierInfo *II = IO.getIdentifier())
4903 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, *II, NameLoc,
4904 ObjectType, AllowInjectedClassName);
4905 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, IO.getOperator(),
4906 NameLoc, ObjectType,
4907 AllowInjectedClassName);
4908}
4909
4910template <typename Derived>
4912 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
4913 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
4914 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
4916 TemplateName UnderlyingName = QTN->getUnderlyingTemplate();
4917
4918 if (QualifierLoc) {
4919 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4920 QualifierLoc, ObjectType, FirstQualifierInScope);
4921 if (!QualifierLoc)
4922 return TemplateName();
4923 }
4924
4925 NestedNameSpecifierLoc UnderlyingQualifier;
4926 TemplateName NewUnderlyingName = getDerived().TransformTemplateName(
4927 UnderlyingQualifier, TemplateKWLoc, UnderlyingName, NameLoc, ObjectType,
4928 FirstQualifierInScope, AllowInjectedClassName);
4929 if (NewUnderlyingName.isNull())
4930 return TemplateName();
4931 assert(!UnderlyingQualifier && "unexpected qualifier");
4932
4933 if (!getDerived().AlwaysRebuild() &&
4934 QualifierLoc.getNestedNameSpecifier() == QTN->getQualifier() &&
4935 NewUnderlyingName == UnderlyingName)
4936 return Name;
4937 CXXScopeSpec SS;
4938 SS.Adopt(QualifierLoc);
4939 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4940 NewUnderlyingName);
4941 }
4942
4944 if (QualifierLoc) {
4945 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4946 QualifierLoc, ObjectType, FirstQualifierInScope);
4947 if (!QualifierLoc)
4948 return TemplateName();
4949 // The qualifier-in-scope and object type only apply to the leftmost
4950 // entity.
4951 ObjectType = QualType();
4952 }
4953
4954 if (!getDerived().AlwaysRebuild() &&
4955 QualifierLoc.getNestedNameSpecifier() == DTN->getQualifier() &&
4956 ObjectType.isNull())
4957 return Name;
4958
4959 CXXScopeSpec SS;
4960 SS.Adopt(QualifierLoc);
4961 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, DTN->getName(),
4962 NameLoc, ObjectType,
4963 AllowInjectedClassName);
4964 }
4965
4968 assert(!QualifierLoc && "Unexpected qualified SubstTemplateTemplateParm");
4969
4970 NestedNameSpecifierLoc ReplacementQualifierLoc;
4971 TemplateName ReplacementName = S->getReplacement();
4972 if (NestedNameSpecifier Qualifier = ReplacementName.getQualifier()) {
4974 Builder.MakeTrivial(SemaRef.Context, Qualifier, NameLoc);
4975 ReplacementQualifierLoc = Builder.getWithLocInContext(SemaRef.Context);
4976 }
4977
4978 TemplateName NewName = getDerived().TransformTemplateName(
4979 ReplacementQualifierLoc, TemplateKWLoc, ReplacementName, NameLoc,
4980 ObjectType, FirstQualifierInScope, AllowInjectedClassName);
4981 if (NewName.isNull())
4982 return TemplateName();
4983 Decl *AssociatedDecl =
4984 getDerived().TransformDecl(NameLoc, S->getAssociatedDecl());
4985 if (!getDerived().AlwaysRebuild() && NewName == S->getReplacement() &&
4986 AssociatedDecl == S->getAssociatedDecl())
4987 return Name;
4988 return SemaRef.Context.getSubstTemplateTemplateParm(
4989 NewName, AssociatedDecl, S->getIndex(), S->getPackIndex(),
4990 S->getFinal());
4991 }
4992
4994 assert(!QualifierLoc && "Unexpected qualified pack-index-template-name");
4995
4996 ExprResult IndexExpr;
4997 {
4998 EnterExpressionEvaluationContext ConstantContext(
5000 IndexExpr = getDerived().TransformExpr(PI->getIndexExpr());
5001 if (IndexExpr.isInvalid())
5002 return TemplateName();
5003 }
5004
5005 auto TransformOne = [&](TemplateName N) {
5006 NestedNameSpecifierLoc NoQualifier;
5007 return getDerived().TransformTemplateName(
5008 NoQualifier, TemplateKWLoc, N, NameLoc, ObjectType,
5009 FirstQualifierInScope, AllowInjectedClassName);
5010 };
5011
5012 TemplateName Pattern = PI->getPattern();
5013 SmallVector<TemplateName, 4> SubstitutedNames;
5014 ArrayRef<TemplateName> Names = PI->getExpansions();
5015
5016 bool NotYetExpanded = Names.empty();
5017 bool FullySubstituted = true;
5018
5019 if (Names.empty() && !PI->expandsToEmptyPack())
5020 Names = ArrayRef(&Pattern, 1);
5021
5022 for (TemplateName N : Names) {
5023 if (!N.containsUnexpandedParameterPack()) {
5024 TemplateName Transformed = TransformOne(N);
5025 if (Transformed.isNull())
5026 return TemplateName();
5027 SubstitutedNames.push_back(Transformed);
5028 continue;
5029 }
5030
5032 getSema().collectUnexpandedParameterPacks(N, Unexpanded);
5033 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5034
5035 bool ShouldExpand = true;
5036 bool RetainExpansion = false;
5037 UnsignedOrNone NumExpansions = std::nullopt;
5039 NameLoc, SourceRange(), Unexpanded,
5040 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
5041 RetainExpansion, NumExpansions))
5042 return TemplateName();
5043
5044 if (!ShouldExpand) {
5045 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
5046 TemplateName Pack = TransformOne(N);
5047 if (Pack.isNull())
5048 return TemplateName();
5049 if (NotYetExpanded) {
5050 FullySubstituted = false;
5051 return getDerived().RebuildPackIndexingTemplateName(
5052 Pack, IndexExpr.get(), FullySubstituted);
5053 }
5054 SubstitutedNames.push_back(Pack);
5055 continue;
5056 }
5057
5058 for (unsigned I = 0; I != *NumExpansions; ++I) {
5059 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5060 TemplateName Out = TransformOne(N);
5061 if (Out.isNull())
5062 return TemplateName();
5063 SubstitutedNames.push_back(Out);
5064 FullySubstituted &= !Out.containsUnexpandedParameterPack();
5065 }
5066
5067 // If we're supposed to retain a pack expansion, do so by temporarily
5068 // forgetting the partially-substituted parameter pack.
5069 if (RetainExpansion) {
5070 FullySubstituted = false;
5071 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5072 TemplateName Out = TransformOne(N);
5073 if (Out.isNull())
5074 return TemplateName();
5075 SubstitutedNames.push_back(Out);
5076 }
5077 }
5078
5079 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
5080 TemplateName NewPattern = TransformOne(Pattern);
5081 if (NewPattern.isNull())
5082 return TemplateName();
5083
5084 return getDerived().RebuildPackIndexingTemplateName(
5085 NewPattern, IndexExpr.get(), FullySubstituted, SubstitutedNames);
5086 }
5087
5088 assert(!Name.getAsDeducedTemplateName() &&
5089 "DeducedTemplateName should not escape partial ordering");
5090
5091 // FIXME: Preserve UsingTemplateName.
5092 if (auto *Template = Name.getAsTemplateDecl()) {
5093 assert(!QualifierLoc && "Unexpected qualifier");
5094 return TemplateName(cast_or_null<TemplateDecl>(
5095 getDerived().TransformDecl(NameLoc, Template)));
5096 }
5097
5100 assert(!QualifierLoc &&
5101 "Unexpected qualified SubstTemplateTemplateParmPack");
5102 return getDerived().RebuildTemplateName(
5103 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
5104 SubstPack->getIndex(), SubstPack->getFinal());
5105 }
5106
5107 // These should be getting filtered out before they reach the AST.
5108 llvm_unreachable("overloaded function decl survived to here");
5109}
5110
5111template <typename Derived>
5114 SourceLocation NameLoc) {
5115 NestedNameSpecifierLoc QualifierLoc;
5116 return getDerived().TransformTemplateName(
5117 QualifierLoc, /*TemplateKWLoc=*/SourceLocation(), Name, NameLoc);
5118}
5119
5120template <typename Derived>
5122 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
5123 TemplateName Name, SourceLocation NameLoc) {
5124 TemplateName TN = getDerived().TransformTemplateName(
5125 QualifierLoc, TemplateKeywordLoc, Name, NameLoc);
5126 if (TN.isNull())
5127 return TemplateArgument();
5128 return TemplateArgument(TN);
5129}
5130
5131template<typename Derived>
5133 const TemplateArgument &Arg,
5134 TemplateArgumentLoc &Output) {
5135 Output = getSema().getTrivialTemplateArgumentLoc(
5136 Arg, QualType(), getDerived().getBaseLocation());
5137}
5138
5139template <typename Derived>
5141 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
5142 bool Uneval) {
5143 const TemplateArgument &Arg = Input.getArgument();
5144 switch (Arg.getKind()) {
5147 llvm_unreachable("Unexpected TemplateArgument");
5148
5153 // Transform a resolved template argument straight to a resolved template
5154 // argument. We get here when substituting into an already-substituted
5155 // template type argument during concept satisfaction checking.
5157 QualType NewT = getDerived().TransformType(T);
5158 if (NewT.isNull())
5159 return true;
5160
5162 ? Arg.getAsDecl()
5163 : nullptr;
5164 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
5166 : nullptr;
5167 if (D && !NewD)
5168 return true;
5169
5170 if (NewT == T && D == NewD)
5171 Output = Input;
5172 else if (Arg.getKind() == TemplateArgument::Integral)
5173 Output = TemplateArgumentLoc(
5174 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
5176 else if (Arg.getKind() == TemplateArgument::NullPtr)
5177 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
5179 else if (Arg.getKind() == TemplateArgument::Declaration)
5180 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
5183 Output = TemplateArgumentLoc(
5184 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
5186 else
5187 llvm_unreachable("unexpected template argument kind");
5188
5189 return false;
5190 }
5191
5193 TypeSourceInfo *TSI = Input.getTypeSourceInfo();
5194 if (!TSI)
5196
5197 TSI = getDerived().TransformType(TSI);
5198 if (!TSI)
5199 return true;
5200
5201 Output = TemplateArgumentLoc(TemplateArgument(TSI->getType()), TSI);
5202 return false;
5203 }
5204
5206 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
5207
5208 TemplateArgument Out = getDerived().TransformNamedTemplateTemplateArgument(
5209 QualifierLoc, Input.getTemplateKWLoc(), Arg.getAsTemplate(),
5210 Input.getTemplateNameLoc());
5211 if (Out.isNull())
5212 return true;
5213 Output = TemplateArgumentLoc(SemaRef.Context, Out, Input.getTemplateKWLoc(),
5214 QualifierLoc, Input.getTemplateNameLoc());
5215 return false;
5216 }
5217
5219 llvm_unreachable("Caller should expand pack expansions");
5220
5222 // Template argument expressions are constant expressions.
5224 getSema(),
5227 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
5229
5230 Expr *InputExpr = Input.getSourceExpression();
5231 if (!InputExpr)
5232 InputExpr = Input.getArgument().getAsExpr();
5233
5234 ExprResult E = getDerived().TransformExpr(InputExpr);
5235 E = SemaRef.ActOnConstantExpression(E);
5236 if (E.isInvalid())
5237 return true;
5238 Output = TemplateArgumentLoc(
5239 TemplateArgument(E.get(), /*IsCanonical=*/false), E.get());
5240 return false;
5241 }
5242 }
5243
5244 // Work around bogus GCC warning
5245 return true;
5246}
5247
5248/// Iterator adaptor that invents template argument location information
5249/// for each of the template arguments in its underlying iterator.
5250template<typename Derived, typename InputIterator>
5253 InputIterator Iter;
5254
5255public:
5258 typedef typename std::iterator_traits<InputIterator>::difference_type
5260 typedef std::input_iterator_tag iterator_category;
5261
5262 class pointer {
5264
5265 public:
5266 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5267
5268 const TemplateArgumentLoc *operator->() const { return &Arg; }
5269 };
5270
5272 InputIterator Iter)
5273 : Self(Self), Iter(Iter) { }
5274
5276 ++Iter;
5277 return *this;
5278 }
5279
5282 ++(*this);
5283 return Old;
5284 }
5285
5288 Self.InventTemplateArgumentLoc(*Iter, Result);
5289 return Result;
5290 }
5291
5292 pointer operator->() const { return pointer(**this); }
5293
5296 return X.Iter == Y.Iter;
5297 }
5298
5301 return X.Iter != Y.Iter;
5302 }
5303};
5304
5305template<typename Derived>
5306template<typename InputIterator>
5308 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5309 bool Uneval) {
5310 for (TemplateArgumentLoc In : llvm::make_range(First, Last)) {
5312 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5313 // Unpack argument packs, which we translate them into separate
5314 // arguments.
5315 // FIXME: We could do much better if we could guarantee that the
5316 // TemplateArgumentLocInfo for the pack expansion would be usable for
5317 // all of the template arguments in the argument pack.
5318 typedef TemplateArgumentLocInventIterator<Derived,
5320 PackLocIterator;
5321
5322 TemplateArgumentListInfo *PackOutput = &Outputs;
5324
5326 PackLocIterator(*this, In.getArgument().pack_begin()),
5327 PackLocIterator(*this, In.getArgument().pack_end()), *PackOutput,
5328 Uneval))
5329 return true;
5330
5331 continue;
5332 }
5333
5334 if (In.getArgument().isPackExpansion()) {
5335 UnexpandedInfo Info;
5336 TemplateArgumentLoc Prepared;
5337 if (getDerived().PreparePackForExpansion(In, Uneval, Prepared, Info))
5338 return true;
5339 if (!Info.Expand) {
5340 Outputs.addArgument(Prepared);
5341 continue;
5342 }
5343
5344 // The transform has determined that we should perform an elementwise
5345 // expansion of the pattern. Do so.
5346 std::optional<ForgetSubstitutionRAII> ForgetSubst;
5348 ForgetSubst.emplace(getDerived());
5349 for (unsigned I = 0; I != *Info.NumExpansions; ++I) {
5350 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5351
5353 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5354 return true;
5355
5356 if (Out.getArgument().containsUnexpandedParameterPack()) {
5357 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5358 Info.OrigNumExpansions);
5359 if (Out.getArgument().isNull())
5360 return true;
5361 }
5362
5363 Outputs.addArgument(Out);
5364 }
5365
5366 // If we're supposed to retain a pack expansion, do so by temporarily
5367 // forgetting the partially-substituted parameter pack.
5368 if (Info.RetainExpansion) {
5369 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5370
5372 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5373 return true;
5374
5375 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5376 Info.OrigNumExpansions);
5377 if (Out.getArgument().isNull())
5378 return true;
5379
5380 Outputs.addArgument(Out);
5381 }
5382
5383 continue;
5384 }
5385
5386 // The simple case:
5387 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5388 return true;
5389
5390 Outputs.addArgument(Out);
5391 }
5392
5393 return false;
5394}
5395
5396template <typename Derived>
5397template <typename InputIterator>
5399 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5400 bool Uneval) {
5401
5402 // [C++26][temp.constr.normal]
5403 // any non-dependent concept template argument
5404 // is substituted into the constraint-expression of C.
5405 auto isNonDependentConceptArgument = [](const TemplateArgument &Arg) {
5406 return !Arg.isDependent() && Arg.isConceptOrConceptTemplateParameter();
5407 };
5408
5409 for (; First != Last; ++First) {
5412
5413 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5414 typedef TemplateArgumentLocInventIterator<Derived,
5416 PackLocIterator;
5418 PackLocIterator(*this, In.getArgument().pack_begin()),
5419 PackLocIterator(*this, In.getArgument().pack_end()), Outputs,
5420 Uneval))
5421 return true;
5422 continue;
5423 }
5424
5425 if (!isNonDependentConceptArgument(In.getArgument())) {
5426 Outputs.addArgument(In);
5427 continue;
5428 }
5429
5430 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5431 return true;
5432
5433 Outputs.addArgument(Out);
5434 }
5435
5436 return false;
5437}
5438
5439// FIXME: Find ways to reduce code duplication for pack expansions.
5440template <typename Derived>
5442 bool Uneval,
5444 UnexpandedInfo &Info) {
5445 auto ComputeInfo = [this](TemplateArgumentLoc Arg,
5446 bool IsLateExpansionAttempt, UnexpandedInfo &Info,
5447 TemplateArgumentLoc &Pattern) {
5448 assert(Arg.getArgument().isPackExpansion());
5449 // We have a pack expansion, for which we will be substituting into the
5450 // pattern.
5451 Pattern = getSema().getTemplateArgumentPackExpansionPattern(
5452 Arg, Info.Ellipsis, Info.OrigNumExpansions);
5454 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5455 if (IsLateExpansionAttempt) {
5456 // Request expansion only when there is an opportunity to expand a pack
5457 // that required a substituion first.
5458 bool SawPackTypes =
5459 llvm::any_of(Unexpanded, [](UnexpandedParameterPack P) {
5460 return P.first.dyn_cast<const SubstBuiltinTemplatePackType *>();
5461 });
5462 if (!SawPackTypes) {
5463 Info.Expand = false;
5464 return false;
5465 }
5466 }
5467 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5468
5469 // Determine whether the set of unexpanded parameter packs can and
5470 // should be expanded.
5471 Info.Expand = true;
5472 Info.RetainExpansion = false;
5473 Info.NumExpansions = Info.OrigNumExpansions;
5474 return getDerived().TryExpandParameterPacks(
5475 Info.Ellipsis, Pattern.getSourceRange(), Unexpanded,
5476 /*FailOnPackProducingTemplates=*/false, Info.Expand,
5477 Info.RetainExpansion, Info.NumExpansions);
5478 };
5479
5480 TemplateArgumentLoc Pattern;
5481 if (ComputeInfo(In, false, Info, Pattern))
5482 return true;
5483
5484 if (Info.Expand) {
5485 Out = Pattern;
5486 return false;
5487 }
5488
5489 // The transform has determined that we should perform a simple
5490 // transformation on the pack expansion, producing another pack
5491 // expansion.
5492 TemplateArgumentLoc OutPattern;
5493 std::optional<Sema::ArgPackSubstIndexRAII> SubstIndex(
5494 std::in_place, getSema(), std::nullopt);
5495 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5496 return true;
5497
5498 Out = getDerived().RebuildPackExpansion(OutPattern, Info.Ellipsis,
5499 Info.NumExpansions);
5500 if (Out.getArgument().isNull())
5501 return true;
5502 SubstIndex.reset();
5503
5504 if (!OutPattern.getArgument().containsUnexpandedParameterPack())
5505 return false;
5506
5507 // Some packs will learn their length after substitution, e.g.
5508 // __builtin_dedup_pack<T,int> has size 1 or 2, depending on the substitution
5509 // value of `T`.
5510 //
5511 // We only expand after we know sizes of all packs, check if this is the case
5512 // or not. However, we avoid a full template substitution and only do
5513 // expanstions after this point.
5514
5515 // E.g. when substituting template arguments of tuple with {T -> int} in the
5516 // following example:
5517 // template <class T>
5518 // struct TupleWithInt {
5519 // using type = std::tuple<__builtin_dedup_pack<T, int>...>;
5520 // };
5521 // TupleWithInt<int>::type y;
5522 // At this point we will see the `__builtin_dedup_pack<int, int>` with a known
5523 // length and run `ComputeInfo()` to provide the necessary information to our
5524 // caller.
5525 //
5526 // Note that we may still have situations where builtin is not going to be
5527 // expanded. For example:
5528 // template <class T>
5529 // struct Foo {
5530 // template <class U> using tuple_with_t =
5531 // std::tuple<__builtin_dedup_pack<T, U, int>...>; using type =
5532 // tuple_with_t<short>;
5533 // }
5534 // Because the substitution into `type` happens in dependent context, `type`
5535 // will be `tuple<builtin_dedup_pack<T, short, int>...>` after substitution
5536 // and the caller will not be able to expand it.
5537 ForgetSubstitutionRAII ForgetSubst(getDerived());
5538 if (ComputeInfo(Out, true, Info, OutPattern))
5539 return true;
5540 if (!Info.Expand)
5541 return false;
5542 Out = OutPattern;
5543 Info.ExpandUnderForgetSubstitions = true;
5544 return false;
5545}
5546
5547//===----------------------------------------------------------------------===//
5548// Type transformation
5549//===----------------------------------------------------------------------===//
5550
5551template<typename Derived>
5554 return T;
5555
5556 // Temporary workaround. All of these transformations should
5557 // eventually turn into transformations on TypeLocs.
5558 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5560
5561 TypeSourceInfo *NewTSI = getDerived().TransformType(TSI);
5562
5563 if (!NewTSI)
5564 return QualType();
5565
5566 return NewTSI->getType();
5567}
5568
5569template <typename Derived>
5571 // Refine the base location to the type's location.
5572 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5575 return TSI;
5576
5577 TypeLocBuilder TLB;
5578
5579 TypeLoc TL = TSI->getTypeLoc();
5580 TLB.reserve(TL.getFullDataSize());
5581
5582 QualType Result = getDerived().TransformType(TLB, TL);
5583 if (Result.isNull())
5584 return nullptr;
5585
5586 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5587}
5588
5589template<typename Derived>
5592 switch (T.getTypeLocClass()) {
5593#define ABSTRACT_TYPELOC(CLASS, PARENT)
5594#define TYPELOC(CLASS, PARENT) \
5595 case TypeLoc::CLASS: \
5596 return getDerived().Transform##CLASS##Type(TLB, \
5597 T.castAs<CLASS##TypeLoc>());
5598#include "clang/AST/TypeLocNodes.def"
5599 }
5600
5601 llvm_unreachable("unhandled type loc!");
5602}
5603
5604template<typename Derived>
5607 return TransformType(T);
5608
5610 return T;
5611 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5613 TypeSourceInfo *NewTSI = getDerived().TransformTypeWithDeducedTST(TSI);
5614 return NewTSI ? NewTSI->getType() : QualType();
5615}
5616
5617template <typename Derived>
5620 if (!isa<DependentNameType>(TSI->getType()))
5621 return TransformType(TSI);
5622
5623 // Refine the base location to the type's location.
5624 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5627 return TSI;
5628
5629 TypeLocBuilder TLB;
5630
5631 TypeLoc TL = TSI->getTypeLoc();
5632 TLB.reserve(TL.getFullDataSize());
5633
5634 auto QTL = TL.getAs<QualifiedTypeLoc>();
5635 if (QTL)
5636 TL = QTL.getUnqualifiedLoc();
5637
5638 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5639
5640 QualType Result = getDerived().TransformDependentNameType(
5641 TLB, DNTL, /*DeducedTSTContext*/true);
5642 if (Result.isNull())
5643 return nullptr;
5644
5645 if (QTL) {
5646 Result = getDerived().RebuildQualifiedType(Result, QTL);
5647 if (Result.isNull())
5648 return nullptr;
5650 }
5651
5652 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5653}
5654
5655template<typename Derived>
5660 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5661 auto SuppressObjCLifetime =
5662 T.getType().getLocalQualifiers().hasObjCLifetime();
5663 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5664 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5665 SuppressObjCLifetime);
5666 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5667 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5668 TLB, STTP, SuppressObjCLifetime);
5669 } else {
5670 Result = getDerived().TransformType(TLB, UnqualTL);
5671 }
5672
5673 if (Result.isNull())
5674 return QualType();
5675
5676 Result = getDerived().RebuildQualifiedType(Result, T);
5677
5678 if (Result.isNull())
5679 return QualType();
5680
5681 // RebuildQualifiedType might have updated the type, but not in a way
5682 // that invalidates the TypeLoc. (There's no location information for
5683 // qualifiers.)
5685
5686 return Result;
5687}
5688
5689template <typename Derived>
5691 QualifiedTypeLoc TL) {
5692
5693 SourceLocation Loc = TL.getBeginLoc();
5694 Qualifiers Quals = TL.getType().getLocalQualifiers();
5695
5696 if ((T.getAddressSpace() != LangAS::Default &&
5697 Quals.getAddressSpace() != LangAS::Default) &&
5698 T.getAddressSpace() != Quals.getAddressSpace()) {
5699 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5700 << TL.getType() << T;
5701 return QualType();
5702 }
5703
5704 PointerAuthQualifier LocalPointerAuth = Quals.getPointerAuth();
5705 if (LocalPointerAuth.isPresent()) {
5706 if (T.getPointerAuth().isPresent()) {
5707 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_redundant) << TL.getType();
5708 return QualType();
5709 }
5710 if (!T->isDependentType()) {
5711 if (!T->isSignableType(SemaRef.getASTContext())) {
5712 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_invalid_target) << T;
5713 return QualType();
5714 }
5715 }
5716 }
5717 // C++ [dcl.fct]p7:
5718 // [When] adding cv-qualifications on top of the function type [...] the
5719 // cv-qualifiers are ignored.
5720 if (T->isFunctionType()) {
5721 T = SemaRef.getASTContext().getAddrSpaceQualType(T,
5722 Quals.getAddressSpace());
5723 return T;
5724 }
5725
5726 // C++ [dcl.ref]p1:
5727 // when the cv-qualifiers are introduced through the use of a typedef-name
5728 // or decltype-specifier [...] the cv-qualifiers are ignored.
5729 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5730 // applied to a reference type.
5731 if (T->isReferenceType()) {
5732 // The only qualifier that applies to a reference type is restrict.
5733 if (!Quals.hasRestrict())
5734 return T;
5736 }
5737
5738 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5739 // resulting type.
5740 if (Quals.hasObjCLifetime()) {
5741 if (!T->isObjCLifetimeType() && !T->isDependentType())
5742 Quals.removeObjCLifetime();
5743 else if (T.getObjCLifetime()) {
5744 // Objective-C ARC:
5745 // A lifetime qualifier applied to a substituted template parameter
5746 // overrides the lifetime qualifier from the template argument.
5747 const AutoType *AutoTy;
5748 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5749 // 'auto' types behave the same way as template parameters.
5750 QualType Deduced = AutoTy->getDeducedType();
5751 Qualifiers Qs = Deduced.getQualifiers();
5752 Qs.removeObjCLifetime();
5753 Deduced =
5754 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5755 T = SemaRef.Context.getAutoType(AutoTy->getDeducedKind(), Deduced,
5756 AutoTy->getKeyword(),
5757 AutoTy->getTypeConstraintConcept(),
5758 AutoTy->getTypeConstraintArguments());
5759 } else {
5760 // Otherwise, complain about the addition of a qualifier to an
5761 // already-qualified type.
5762 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5763 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5764 Quals.removeObjCLifetime();
5765 }
5766 }
5767 }
5768
5769 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5770}
5771
5772template <typename Derived>
5773QualType TreeTransform<Derived>::TransformTypeInObjectScope(
5774 TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType,
5775 NamedDecl *FirstQualifierInScope) {
5776 assert(!getDerived().AlreadyTransformed(TL.getType()));
5777
5778 switch (TL.getTypeLocClass()) {
5779 case TypeLoc::TemplateSpecialization:
5780 return getDerived().TransformTemplateSpecializationType(
5781 TLB, TL.castAs<TemplateSpecializationTypeLoc>(), ObjectType,
5782 FirstQualifierInScope, /*AllowInjectedClassName=*/true);
5783 case TypeLoc::DependentName:
5784 return getDerived().TransformDependentNameType(
5785 TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
5786 ObjectType, FirstQualifierInScope);
5787 default:
5788 // Any dependent canonical type can appear here, through type alias
5789 // templates.
5790 return getDerived().TransformType(TLB, TL);
5791 }
5792}
5793
5794template <class TyLoc> static inline
5796 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5797 NewT.setNameLoc(T.getNameLoc());
5798 return T.getType();
5799}
5800
5801template<typename Derived>
5802QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5803 BuiltinTypeLoc T) {
5804 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5805 NewT.setBuiltinLoc(T.getBuiltinLoc());
5806 if (T.needsExtraLocalData())
5807 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5808 return T.getType();
5809}
5810
5811template<typename Derived>
5813 ComplexTypeLoc T) {
5814 // FIXME: recurse?
5815 return TransformTypeSpecType(TLB, T);
5816}
5817
5818template <typename Derived>
5820 AdjustedTypeLoc TL) {
5821 // Adjustments applied during transformation are handled elsewhere.
5822 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5823}
5824
5825template<typename Derived>
5827 DecayedTypeLoc TL) {
5828 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5829 if (OriginalType.isNull())
5830 return QualType();
5831
5832 QualType Result = TL.getType();
5833 if (getDerived().AlwaysRebuild() ||
5834 OriginalType != TL.getOriginalLoc().getType())
5835 Result = SemaRef.Context.getDecayedType(OriginalType);
5836 TLB.push<DecayedTypeLoc>(Result);
5837 // Nothing to set for DecayedTypeLoc.
5838 return Result;
5839}
5840
5841template <typename Derived>
5845 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5846 if (OriginalType.isNull())
5847 return QualType();
5848
5849 QualType Result = TL.getType();
5850 if (getDerived().AlwaysRebuild() ||
5851 OriginalType != TL.getElementLoc().getType())
5852 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5853 TLB.push<ArrayParameterTypeLoc>(Result);
5854 // Nothing to set for ArrayParameterTypeLoc.
5855 return Result;
5856}
5857
5858template<typename Derived>
5860 PointerTypeLoc TL) {
5861 QualType PointeeType
5862 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5863 if (PointeeType.isNull())
5864 return QualType();
5865
5866 QualType Result = TL.getType();
5867 if (PointeeType->getAs<ObjCObjectType>()) {
5868 // A dependent pointer type 'T *' has is being transformed such
5869 // that an Objective-C class type is being replaced for 'T'. The
5870 // resulting pointer type is an ObjCObjectPointerType, not a
5871 // PointerType.
5872 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5873
5875 NewT.setStarLoc(TL.getStarLoc());
5876 return Result;
5877 }
5878
5879 if (getDerived().AlwaysRebuild() ||
5880 PointeeType != TL.getPointeeLoc().getType()) {
5881 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5882 if (Result.isNull())
5883 return QualType();
5884 }
5885
5886 // Objective-C ARC can add lifetime qualifiers to the type that we're
5887 // pointing to.
5888 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5889
5890 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5891 NewT.setSigilLoc(TL.getSigilLoc());
5892 return Result;
5893}
5894
5895template<typename Derived>
5899 QualType PointeeType
5900 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5901 if (PointeeType.isNull())
5902 return QualType();
5903
5904 QualType Result = TL.getType();
5905 if (getDerived().AlwaysRebuild() ||
5906 PointeeType != TL.getPointeeLoc().getType()) {
5907 Result = getDerived().RebuildBlockPointerType(PointeeType,
5908 TL.getSigilLoc());
5909 if (Result.isNull())
5910 return QualType();
5911 }
5912
5914 NewT.setSigilLoc(TL.getSigilLoc());
5915 return Result;
5916}
5917
5918/// Transforms a reference type. Note that somewhat paradoxically we
5919/// don't care whether the type itself is an l-value type or an r-value
5920/// type; we only care if the type was *written* as an l-value type
5921/// or an r-value type.
5922template<typename Derived>
5925 ReferenceTypeLoc TL) {
5926 const ReferenceType *T = TL.getTypePtr();
5927
5928 // Note that this works with the pointee-as-written.
5929 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5930 if (PointeeType.isNull())
5931 return QualType();
5932
5933 QualType Result = TL.getType();
5934 if (getDerived().AlwaysRebuild() ||
5935 PointeeType != T->getPointeeTypeAsWritten()) {
5936 Result = getDerived().RebuildReferenceType(PointeeType,
5937 T->isSpelledAsLValue(),
5938 TL.getSigilLoc());
5939 if (Result.isNull())
5940 return QualType();
5941 }
5942
5943 // Objective-C ARC can add lifetime qualifiers to the type that we're
5944 // referring to.
5947
5948 // r-value references can be rebuilt as l-value references.
5949 ReferenceTypeLoc NewTL;
5951 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5952 else
5953 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5954 NewTL.setSigilLoc(TL.getSigilLoc());
5955
5956 return Result;
5957}
5958
5959template<typename Derived>
5963 return TransformReferenceType(TLB, TL);
5964}
5965
5966template<typename Derived>
5967QualType
5968TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5969 RValueReferenceTypeLoc TL) {
5970 return TransformReferenceType(TLB, TL);
5971}
5972
5973template<typename Derived>
5977 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5978 if (PointeeType.isNull())
5979 return QualType();
5980
5981 const MemberPointerType *T = TL.getTypePtr();
5982
5983 NestedNameSpecifierLoc OldQualifierLoc = TL.getQualifierLoc();
5984 NestedNameSpecifierLoc NewQualifierLoc =
5985 getDerived().TransformNestedNameSpecifierLoc(OldQualifierLoc);
5986 if (!NewQualifierLoc)
5987 return QualType();
5988
5989 CXXRecordDecl *OldCls = T->getMostRecentCXXRecordDecl(), *NewCls = nullptr;
5990 if (OldCls) {
5991 NewCls = cast_or_null<CXXRecordDecl>(
5992 getDerived().TransformDecl(TL.getStarLoc(), OldCls));
5993 if (!NewCls)
5994 return QualType();
5995 }
5996
5997 QualType Result = TL.getType();
5998 if (getDerived().AlwaysRebuild() || PointeeType != T->getPointeeType() ||
5999 NewQualifierLoc.getNestedNameSpecifier() !=
6000 OldQualifierLoc.getNestedNameSpecifier() ||
6001 NewCls != OldCls) {
6002 CXXScopeSpec SS;
6003 SS.Adopt(NewQualifierLoc);
6004 Result = getDerived().RebuildMemberPointerType(PointeeType, SS, NewCls,
6005 TL.getStarLoc());
6006 if (Result.isNull())
6007 return QualType();
6008 }
6009
6010 // If we had to adjust the pointee type when building a member pointer, make
6011 // sure to push TypeLoc info for it.
6012 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
6013 if (MPT && PointeeType != MPT->getPointeeType()) {
6014 assert(isa<AdjustedType>(MPT->getPointeeType()));
6015 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
6016 }
6017
6019 NewTL.setSigilLoc(TL.getSigilLoc());
6020 NewTL.setQualifierLoc(NewQualifierLoc);
6021
6022 return Result;
6023}
6024
6025template<typename Derived>
6029 const ConstantArrayType *T = TL.getTypePtr();
6030 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6031 if (ElementType.isNull())
6032 return QualType();
6033
6034 // Prefer the expression from the TypeLoc; the other may have been uniqued.
6035 Expr *OldSize = TL.getSizeExpr();
6036 if (!OldSize)
6037 OldSize = const_cast<Expr*>(T->getSizeExpr());
6038 Expr *NewSize = nullptr;
6039 if (OldSize) {
6042 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
6043 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
6044 }
6045
6046 QualType Result = TL.getType();
6047 if (getDerived().AlwaysRebuild() ||
6048 ElementType != T->getElementType() ||
6049 (T->getSizeExpr() && NewSize != OldSize)) {
6050 Result = getDerived().RebuildConstantArrayType(ElementType,
6051 T->getSizeModifier(),
6052 T->getSize(), NewSize,
6053 T->getIndexTypeCVRQualifiers(),
6054 TL.getBracketsRange());
6055 if (Result.isNull())
6056 return QualType();
6057 }
6058
6059 // We might have either a ConstantArrayType or a VariableArrayType now:
6060 // a ConstantArrayType is allowed to have an element type which is a
6061 // VariableArrayType if the type is dependent. Fortunately, all array
6062 // types have the same location layout.
6063 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6064 NewTL.setLBracketLoc(TL.getLBracketLoc());
6065 NewTL.setRBracketLoc(TL.getRBracketLoc());
6066 NewTL.setSizeExpr(NewSize);
6067
6068 return Result;
6069}
6070
6071template<typename Derived>
6073 TypeLocBuilder &TLB,
6075 const IncompleteArrayType *T = TL.getTypePtr();
6076 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6077 if (ElementType.isNull())
6078 return QualType();
6079
6080 QualType Result = TL.getType();
6081 if (getDerived().AlwaysRebuild() ||
6082 ElementType != T->getElementType()) {
6083 Result = getDerived().RebuildIncompleteArrayType(ElementType,
6084 T->getSizeModifier(),
6085 T->getIndexTypeCVRQualifiers(),
6086 TL.getBracketsRange());
6087 if (Result.isNull())
6088 return QualType();
6089 }
6090
6092 NewTL.setLBracketLoc(TL.getLBracketLoc());
6093 NewTL.setRBracketLoc(TL.getRBracketLoc());
6094 NewTL.setSizeExpr(nullptr);
6095
6096 return Result;
6097}
6098
6099template<typename Derived>
6103 const VariableArrayType *T = TL.getTypePtr();
6104 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6105 if (ElementType.isNull())
6106 return QualType();
6107
6108 ExprResult SizeResult;
6109 {
6112 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
6113 }
6114 if (SizeResult.isInvalid())
6115 return QualType();
6116 SizeResult =
6117 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
6118 if (SizeResult.isInvalid())
6119 return QualType();
6120
6121 Expr *Size = SizeResult.get();
6122
6123 QualType Result = TL.getType();
6124 if (getDerived().AlwaysRebuild() ||
6125 ElementType != T->getElementType() ||
6126 Size != T->getSizeExpr()) {
6127 Result = getDerived().RebuildVariableArrayType(ElementType,
6128 T->getSizeModifier(),
6129 Size,
6130 T->getIndexTypeCVRQualifiers(),
6131 TL.getBracketsRange());
6132 if (Result.isNull())
6133 return QualType();
6134 }
6135
6136 // We might have constant size array now, but fortunately it has the same
6137 // location layout.
6138 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6139 NewTL.setLBracketLoc(TL.getLBracketLoc());
6140 NewTL.setRBracketLoc(TL.getRBracketLoc());
6141 NewTL.setSizeExpr(Size);
6142
6143 return Result;
6144}
6145
6146template<typename Derived>
6150 const DependentSizedArrayType *T = TL.getTypePtr();
6151 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6152 if (ElementType.isNull())
6153 return QualType();
6154
6155 // Array bounds are constant expressions.
6158
6159 // If we have a VLA then it won't be a constant.
6160 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
6161
6162 // Prefer the expression from the TypeLoc; the other may have been uniqued.
6163 Expr *origSize = TL.getSizeExpr();
6164 if (!origSize) origSize = T->getSizeExpr();
6165
6166 ExprResult sizeResult
6167 = getDerived().TransformExpr(origSize);
6168 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
6169 if (sizeResult.isInvalid())
6170 return QualType();
6171
6172 Expr *size = sizeResult.get();
6173
6174 QualType Result = TL.getType();
6175 if (getDerived().AlwaysRebuild() ||
6176 ElementType != T->getElementType() ||
6177 size != origSize) {
6178 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
6179 T->getSizeModifier(),
6180 size,
6181 T->getIndexTypeCVRQualifiers(),
6182 TL.getBracketsRange());
6183 if (Result.isNull())
6184 return QualType();
6185 }
6186
6187 // We might have any sort of array type now, but fortunately they
6188 // all have the same location layout.
6189 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6190 NewTL.setLBracketLoc(TL.getLBracketLoc());
6191 NewTL.setRBracketLoc(TL.getRBracketLoc());
6192 NewTL.setSizeExpr(size);
6193
6194 return Result;
6195}
6196
6197template <typename Derived>
6200 const DependentVectorType *T = TL.getTypePtr();
6201 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6202 if (ElementType.isNull())
6203 return QualType();
6204
6207
6208 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6209 Size = SemaRef.ActOnConstantExpression(Size);
6210 if (Size.isInvalid())
6211 return QualType();
6212
6213 QualType Result = TL.getType();
6214 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6215 Size.get() != T->getSizeExpr()) {
6216 Result = getDerived().RebuildDependentVectorType(
6217 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
6218 if (Result.isNull())
6219 return QualType();
6220 }
6221
6222 // Result might be dependent or not.
6225 TLB.push<DependentVectorTypeLoc>(Result);
6226 NewTL.setNameLoc(TL.getNameLoc());
6227 } else {
6228 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6229 NewTL.setNameLoc(TL.getNameLoc());
6230 }
6231
6232 return Result;
6233}
6234
6235template<typename Derived>
6237 TypeLocBuilder &TLB,
6239 const DependentSizedExtVectorType *T = TL.getTypePtr();
6240
6241 // FIXME: ext vector locs should be nested
6242 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6243 if (ElementType.isNull())
6244 return QualType();
6245
6246 // Vector sizes are constant expressions.
6249
6250 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6251 Size = SemaRef.ActOnConstantExpression(Size);
6252 if (Size.isInvalid())
6253 return QualType();
6254
6255 QualType Result = TL.getType();
6256 if (getDerived().AlwaysRebuild() ||
6257 ElementType != T->getElementType() ||
6258 Size.get() != T->getSizeExpr()) {
6259 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
6260 Size.get(),
6261 T->getAttributeLoc());
6262 if (Result.isNull())
6263 return QualType();
6264 }
6265
6266 // Result might be dependent or not.
6270 NewTL.setNameLoc(TL.getNameLoc());
6271 } else {
6272 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6273 NewTL.setNameLoc(TL.getNameLoc());
6274 }
6275
6276 return Result;
6277}
6278
6279template <typename Derived>
6283 const ConstantMatrixType *T = TL.getTypePtr();
6284 QualType ElementType = getDerived().TransformType(T->getElementType());
6285 if (ElementType.isNull())
6286 return QualType();
6287
6288 QualType Result = TL.getType();
6289 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
6290 Result = getDerived().RebuildConstantMatrixType(
6291 ElementType, T->getNumRows(), T->getNumColumns());
6292 if (Result.isNull())
6293 return QualType();
6294 }
6295
6297 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6298 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6299 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
6300 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
6301
6302 return Result;
6303}
6304
6305template <typename Derived>
6308 const DependentSizedMatrixType *T = TL.getTypePtr();
6309
6310 QualType ElementType = getDerived().TransformType(T->getElementType());
6311 if (ElementType.isNull()) {
6312 return QualType();
6313 }
6314
6315 // Matrix dimensions are constant expressions.
6318
6319 Expr *origRows = TL.getAttrRowOperand();
6320 if (!origRows)
6321 origRows = T->getRowExpr();
6322 Expr *origColumns = TL.getAttrColumnOperand();
6323 if (!origColumns)
6324 origColumns = T->getColumnExpr();
6325
6326 ExprResult rowResult = getDerived().TransformExpr(origRows);
6327 rowResult = SemaRef.ActOnConstantExpression(rowResult);
6328 if (rowResult.isInvalid())
6329 return QualType();
6330
6331 ExprResult columnResult = getDerived().TransformExpr(origColumns);
6332 columnResult = SemaRef.ActOnConstantExpression(columnResult);
6333 if (columnResult.isInvalid())
6334 return QualType();
6335
6336 Expr *rows = rowResult.get();
6337 Expr *columns = columnResult.get();
6338
6339 QualType Result = TL.getType();
6340 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6341 rows != origRows || columns != origColumns) {
6342 Result = getDerived().RebuildDependentSizedMatrixType(
6343 ElementType, rows, columns, T->getAttributeLoc());
6344
6345 if (Result.isNull())
6346 return QualType();
6347 }
6348
6349 // We might have any sort of matrix type now, but fortunately they
6350 // all have the same location layout.
6351 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
6352 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6353 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6354 NewTL.setAttrRowOperand(rows);
6355 NewTL.setAttrColumnOperand(columns);
6356 return Result;
6357}
6358
6359template <typename Derived>
6362 const DependentAddressSpaceType *T = TL.getTypePtr();
6363
6364 QualType pointeeType =
6365 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
6366
6367 if (pointeeType.isNull())
6368 return QualType();
6369
6370 // Address spaces are constant expressions.
6373
6374 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
6375 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
6376 if (AddrSpace.isInvalid())
6377 return QualType();
6378
6379 QualType Result = TL.getType();
6380 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
6381 AddrSpace.get() != T->getAddrSpaceExpr()) {
6382 Result = getDerived().RebuildDependentAddressSpaceType(
6383 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6384 if (Result.isNull())
6385 return QualType();
6386 }
6387
6388 // Result might be dependent or not.
6392
6393 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6394 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6395 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6396
6397 } else {
6398 TLB.TypeWasModifiedSafely(Result);
6399 }
6400
6401 return Result;
6402}
6403
6404template <typename Derived>
6406 VectorTypeLoc TL) {
6407 const VectorType *T = TL.getTypePtr();
6408 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6409 if (ElementType.isNull())
6410 return QualType();
6411
6412 QualType Result = TL.getType();
6413 if (getDerived().AlwaysRebuild() ||
6414 ElementType != T->getElementType()) {
6415 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6416 T->getVectorKind());
6417 if (Result.isNull())
6418 return QualType();
6419 }
6420
6421 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6422 NewTL.setNameLoc(TL.getNameLoc());
6423
6424 return Result;
6425}
6426
6427template<typename Derived>
6429 ExtVectorTypeLoc TL) {
6430 const VectorType *T = TL.getTypePtr();
6431 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6432 if (ElementType.isNull())
6433 return QualType();
6434
6435 QualType Result = TL.getType();
6436 if (getDerived().AlwaysRebuild() ||
6437 ElementType != T->getElementType()) {
6438 Result = getDerived().RebuildExtVectorType(ElementType,
6439 T->getNumElements(),
6440 /*FIXME*/ SourceLocation());
6441 if (Result.isNull())
6442 return QualType();
6443 }
6444
6445 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6446 NewTL.setNameLoc(TL.getNameLoc());
6447
6448 return Result;
6449}
6450
6451template <typename Derived>
6453 ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions,
6454 bool ExpectParameterPack) {
6455 TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
6456 TypeSourceInfo *NewTSI = nullptr;
6457
6458 if (NumExpansions && isa<PackExpansionType>(OldTSI->getType())) {
6459 // If we're substituting into a pack expansion type and we know the
6460 // length we want to expand to, just substitute for the pattern.
6461 TypeLoc OldTL = OldTSI->getTypeLoc();
6462 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6463
6464 TypeLocBuilder TLB;
6465 TypeLoc NewTL = OldTSI->getTypeLoc();
6466 TLB.reserve(NewTL.getFullDataSize());
6467
6468 QualType Result = getDerived().TransformType(TLB,
6469 OldExpansionTL.getPatternLoc());
6470 if (Result.isNull())
6471 return nullptr;
6472
6474 OldExpansionTL.getPatternLoc().getSourceRange(),
6475 OldExpansionTL.getEllipsisLoc(),
6476 NumExpansions);
6477 if (Result.isNull())
6478 return nullptr;
6479
6480 PackExpansionTypeLoc NewExpansionTL
6481 = TLB.push<PackExpansionTypeLoc>(Result);
6482 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6483 NewTSI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6484 } else
6485 NewTSI = getDerived().TransformType(OldTSI);
6486 if (!NewTSI)
6487 return nullptr;
6488
6489 if (NewTSI == OldTSI && indexAdjustment == 0)
6490 return OldParm;
6491
6493 SemaRef.Context, OldParm->getDeclContext(), OldParm->getInnerLocStart(),
6494 OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
6495 NewTSI, OldParm->getStorageClass(),
6496 /* DefArg */ nullptr);
6497 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6498 OldParm->getFunctionScopeIndex() + indexAdjustment);
6499 getDerived().transformedLocalDecl(OldParm, {newParm});
6500 return newParm;
6501}
6502
6503template <typename Derived>
6506 const QualType *ParamTypes,
6507 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6508 SmallVectorImpl<QualType> &OutParamTypes,
6511 unsigned *LastParamTransformed) {
6512 int indexAdjustment = 0;
6513
6514 unsigned NumParams = Params.size();
6515 for (unsigned i = 0; i != NumParams; ++i) {
6516 if (LastParamTransformed)
6517 *LastParamTransformed = i;
6518 if (ParmVarDecl *OldParm = Params[i]) {
6519 assert(OldParm->getFunctionScopeIndex() == i);
6520
6521 UnsignedOrNone NumExpansions = std::nullopt;
6522 ParmVarDecl *NewParm = nullptr;
6523 if (OldParm->isParameterPack()) {
6524 // We have a function parameter pack that may need to be expanded.
6526
6527 // Find the parameter packs that could be expanded.
6528 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6530 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6531 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6532
6533 // Determine whether we should expand the parameter packs.
6534 bool ShouldExpand = false;
6535 bool RetainExpansion = false;
6536 UnsignedOrNone OrigNumExpansions = std::nullopt;
6537 if (Unexpanded.size() > 0) {
6538 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6539 NumExpansions = OrigNumExpansions;
6541 ExpansionTL.getEllipsisLoc(), Pattern.getSourceRange(),
6542 Unexpanded, /*FailOnPackProducingTemplates=*/true,
6543 ShouldExpand, RetainExpansion, NumExpansions)) {
6544 return true;
6545 }
6546 } else {
6547#ifndef NDEBUG
6548 const AutoType *AT =
6549 Pattern.getType().getTypePtr()->getContainedAutoType();
6550 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6551 "Could not find parameter packs or undeduced auto type!");
6552#endif
6553 }
6554
6555 if (ShouldExpand) {
6556 // Expand the function parameter pack into multiple, separate
6557 // parameters.
6558 getDerived().ExpandingFunctionParameterPack(OldParm);
6559 for (unsigned I = 0; I != *NumExpansions; ++I) {
6560 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6561 ParmVarDecl *NewParm
6562 = getDerived().TransformFunctionTypeParam(OldParm,
6563 indexAdjustment++,
6564 OrigNumExpansions,
6565 /*ExpectParameterPack=*/false);
6566 if (!NewParm)
6567 return true;
6568
6569 if (ParamInfos)
6570 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6571 OutParamTypes.push_back(NewParm->getType());
6572 if (PVars)
6573 PVars->push_back(NewParm);
6574 }
6575
6576 // If we're supposed to retain a pack expansion, do so by temporarily
6577 // forgetting the partially-substituted parameter pack.
6578 if (RetainExpansion) {
6579 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6580 ParmVarDecl *NewParm
6581 = getDerived().TransformFunctionTypeParam(OldParm,
6582 indexAdjustment++,
6583 OrigNumExpansions,
6584 /*ExpectParameterPack=*/false);
6585 if (!NewParm)
6586 return true;
6587
6588 if (ParamInfos)
6589 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6590 OutParamTypes.push_back(NewParm->getType());
6591 if (PVars)
6592 PVars->push_back(NewParm);
6593 }
6594
6595 // The next parameter should have the same adjustment as the
6596 // last thing we pushed, but we post-incremented indexAdjustment
6597 // on every push. Also, if we push nothing, the adjustment should
6598 // go down by one.
6599 indexAdjustment--;
6600
6601 // We're done with the pack expansion.
6602 continue;
6603 }
6604
6605 // We'll substitute the parameter now without expanding the pack
6606 // expansion.
6607 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6608 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6609 indexAdjustment,
6610 NumExpansions,
6611 /*ExpectParameterPack=*/true);
6612 assert(NewParm->isParameterPack() &&
6613 "Parameter pack no longer a parameter pack after "
6614 "transformation.");
6615 } else {
6616 NewParm = getDerived().TransformFunctionTypeParam(
6617 OldParm, indexAdjustment, std::nullopt,
6618 /*ExpectParameterPack=*/false);
6619 }
6620
6621 if (!NewParm)
6622 return true;
6623
6624 if (ParamInfos)
6625 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6626 OutParamTypes.push_back(NewParm->getType());
6627 if (PVars)
6628 PVars->push_back(NewParm);
6629 continue;
6630 }
6631
6632 // Deal with the possibility that we don't have a parameter
6633 // declaration for this parameter.
6634 assert(ParamTypes);
6635 QualType OldType = ParamTypes[i];
6636 bool IsPackExpansion = false;
6637 UnsignedOrNone NumExpansions = std::nullopt;
6638 QualType NewType;
6639 if (const PackExpansionType *Expansion
6640 = dyn_cast<PackExpansionType>(OldType)) {
6641 // We have a function parameter pack that may need to be expanded.
6642 QualType Pattern = Expansion->getPattern();
6644 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6645
6646 // Determine whether we should expand the parameter packs.
6647 bool ShouldExpand = false;
6648 bool RetainExpansion = false;
6650 Loc, SourceRange(), Unexpanded,
6651 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
6652 RetainExpansion, NumExpansions)) {
6653 return true;
6654 }
6655
6656 if (ShouldExpand) {
6657 // Expand the function parameter pack into multiple, separate
6658 // parameters.
6659 for (unsigned I = 0; I != *NumExpansions; ++I) {
6660 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6661 QualType NewType = getDerived().TransformType(Pattern);
6662 if (NewType.isNull())
6663 return true;
6664
6665 if (NewType->containsUnexpandedParameterPack()) {
6666 NewType = getSema().getASTContext().getPackExpansionType(
6667 NewType, std::nullopt);
6668
6669 if (NewType.isNull())
6670 return true;
6671 }
6672
6673 if (ParamInfos)
6674 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6675 OutParamTypes.push_back(NewType);
6676 if (PVars)
6677 PVars->push_back(nullptr);
6678 }
6679
6680 // We're done with the pack expansion.
6681 continue;
6682 }
6683
6684 // If we're supposed to retain a pack expansion, do so by temporarily
6685 // forgetting the partially-substituted parameter pack.
6686 if (RetainExpansion) {
6687 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6688 QualType NewType = getDerived().TransformType(Pattern);
6689 if (NewType.isNull())
6690 return true;
6691
6692 if (ParamInfos)
6693 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6694 OutParamTypes.push_back(NewType);
6695 if (PVars)
6696 PVars->push_back(nullptr);
6697 }
6698
6699 // We'll substitute the parameter now without expanding the pack
6700 // expansion.
6701 OldType = Expansion->getPattern();
6702 IsPackExpansion = true;
6703 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6704 NewType = getDerived().TransformType(OldType);
6705 } else {
6706 NewType = getDerived().TransformType(OldType);
6707 }
6708
6709 if (NewType.isNull())
6710 return true;
6711
6712 if (IsPackExpansion)
6713 NewType = getSema().Context.getPackExpansionType(NewType,
6714 NumExpansions);
6715
6716 if (ParamInfos)
6717 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6718 OutParamTypes.push_back(NewType);
6719 if (PVars)
6720 PVars->push_back(nullptr);
6721 }
6722
6723#ifndef NDEBUG
6724 if (PVars) {
6725 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6726 if (ParmVarDecl *parm = (*PVars)[i])
6727 assert(parm->getFunctionScopeIndex() == i);
6728 }
6729#endif
6730
6731 return false;
6732}
6733
6734template<typename Derived>
6738 SmallVector<QualType, 4> ExceptionStorage;
6739 return getDerived().TransformFunctionProtoType(
6740 TLB, TL, nullptr, Qualifiers(),
6741 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6742 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6743 ExceptionStorage, Changed);
6744 });
6745}
6746
6747template<typename Derived> template<typename Fn>
6749 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6750 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6751
6752 // Transform the parameters and return type.
6753 //
6754 // We are required to instantiate the params and return type in source order.
6755 // When the function has a trailing return type, we instantiate the
6756 // parameters before the return type, since the return type can then refer
6757 // to the parameters themselves (via decltype, sizeof, etc.).
6758 //
6759 SmallVector<QualType, 4> ParamTypes;
6761 Sema::ExtParameterInfoBuilder ExtParamInfos;
6762 const FunctionProtoType *T = TL.getTypePtr();
6763
6764 QualType ResultType;
6765
6766 if (T->hasTrailingReturn()) {
6768 TL.getBeginLoc(), TL.getParams(),
6770 T->getExtParameterInfosOrNull(),
6771 ParamTypes, &ParamDecls, ExtParamInfos))
6772 return QualType();
6773
6774 {
6775 // C++11 [expr.prim.general]p3:
6776 // If a declaration declares a member function or member function
6777 // template of a class X, the expression this is a prvalue of type
6778 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6779 // and the end of the function-definition, member-declarator, or
6780 // declarator.
6781 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6782 Sema::CXXThisScopeRAII ThisScope(
6783 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6784
6785 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6786 if (ResultType.isNull())
6787 return QualType();
6788 }
6789 }
6790 else {
6791 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6792 if (ResultType.isNull())
6793 return QualType();
6794
6796 TL.getBeginLoc(), TL.getParams(),
6798 T->getExtParameterInfosOrNull(),
6799 ParamTypes, &ParamDecls, ExtParamInfos))
6800 return QualType();
6801 }
6802
6803 FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
6804
6805 bool EPIChanged = false;
6806 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6807 return QualType();
6808
6809 // Handle extended parameter information.
6810 if (auto NewExtParamInfos =
6811 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6812 if (!EPI.ExtParameterInfos ||
6814 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6815 EPIChanged = true;
6816 }
6817 EPI.ExtParameterInfos = NewExtParamInfos;
6818 } else if (EPI.ExtParameterInfos) {
6819 EPIChanged = true;
6820 EPI.ExtParameterInfos = nullptr;
6821 }
6822
6823 // Transform any function effects with unevaluated conditions.
6824 // Hold this set in a local for the rest of this function, since EPI
6825 // may need to hold a FunctionEffectsRef pointing into it.
6826 std::optional<FunctionEffectSet> NewFX;
6827 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6828 NewFX.emplace();
6831
6832 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6833 FunctionEffectWithCondition NewEC = PrevEC;
6834 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6835 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6836 if (NewExpr.isInvalid())
6837 return QualType();
6838 std::optional<FunctionEffectMode> Mode =
6839 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6840 if (!Mode)
6841 return QualType();
6842
6843 // The condition expression has been transformed, and re-evaluated.
6844 // It may or may not have become constant.
6845 switch (*Mode) {
6847 NewEC.Cond = {};
6848 break;
6850 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6851 NewEC.Cond = {};
6852 break;
6854 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6855 break;
6857 llvm_unreachable(
6858 "FunctionEffectMode::None shouldn't be possible here");
6859 }
6860 }
6861 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6862 TL.getBeginLoc())) {
6864 NewFX->insert(NewEC, Errs);
6865 assert(Errs.empty());
6866 }
6867 }
6868 EPI.FunctionEffects = *NewFX;
6869 EPIChanged = true;
6870 }
6871
6872 QualType Result = TL.getType();
6873 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6874 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6875 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6876 if (Result.isNull())
6877 return QualType();
6878 }
6879
6882 NewTL.setLParenLoc(TL.getLParenLoc());
6883 NewTL.setRParenLoc(TL.getRParenLoc());
6886 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6887 NewTL.setParam(i, ParamDecls[i]);
6888
6889 return Result;
6890}
6891
6892template<typename Derived>
6895 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6896 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6897
6898 // Instantiate a dynamic noexcept expression, if any.
6899 if (isComputedNoexcept(ESI.Type)) {
6900 // Update this scrope because ContextDecl in Sema will be used in
6901 // TransformExpr.
6902 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6903 Sema::CXXThisScopeRAII ThisScope(
6904 SemaRef, Method ? Method->getParent() : nullptr,
6905 Method ? Method->getMethodQualifiers() : Qualifiers{},
6906 Method != nullptr);
6909 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6910 if (NoexceptExpr.isInvalid())
6911 return true;
6912
6914 NoexceptExpr =
6915 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6916 if (NoexceptExpr.isInvalid())
6917 return true;
6918
6919 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6920 Changed = true;
6921 ESI.NoexceptExpr = NoexceptExpr.get();
6922 ESI.Type = EST;
6923 }
6924
6925 if (ESI.Type != EST_Dynamic)
6926 return false;
6927
6928 // Instantiate a dynamic exception specification's type.
6929 for (QualType T : ESI.Exceptions) {
6930 if (const PackExpansionType *PackExpansion =
6931 T->getAs<PackExpansionType>()) {
6932 Changed = true;
6933
6934 // We have a pack expansion. Instantiate it.
6936 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6937 Unexpanded);
6938 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6939
6940 // Determine whether the set of unexpanded parameter packs can and
6941 // should
6942 // be expanded.
6943 bool Expand = false;
6944 bool RetainExpansion = false;
6945 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
6946 // FIXME: Track the location of the ellipsis (and track source location
6947 // information for the types in the exception specification in general).
6949 Loc, SourceRange(), Unexpanded,
6950 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
6951 NumExpansions))
6952 return true;
6953
6954 if (!Expand) {
6955 // We can't expand this pack expansion into separate arguments yet;
6956 // just substitute into the pattern and create a new pack expansion
6957 // type.
6958 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6959 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6960 if (U.isNull())
6961 return true;
6962
6963 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6964 Exceptions.push_back(U);
6965 continue;
6966 }
6967
6968 // Substitute into the pack expansion pattern for each slice of the
6969 // pack.
6970 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6971 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
6972
6973 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6974 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6975 return true;
6976
6977 Exceptions.push_back(U);
6978 }
6979 } else {
6980 QualType U = getDerived().TransformType(T);
6981 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6982 return true;
6983 if (T != U)
6984 Changed = true;
6985
6986 Exceptions.push_back(U);
6987 }
6988 }
6989
6990 ESI.Exceptions = Exceptions;
6991 if (ESI.Exceptions.empty())
6992 ESI.Type = EST_DynamicNone;
6993 return false;
6994}
6995
6996template<typename Derived>
6998 TypeLocBuilder &TLB,
7000 const FunctionNoProtoType *T = TL.getTypePtr();
7001 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
7002 if (ResultType.isNull())
7003 return QualType();
7004
7005 QualType Result = TL.getType();
7006 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
7007 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
7008
7011 NewTL.setLParenLoc(TL.getLParenLoc());
7012 NewTL.setRParenLoc(TL.getRParenLoc());
7014
7015 return Result;
7016}
7017
7018template <typename Derived>
7019QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
7020 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
7021
7022 const UnresolvedUsingType *T = TL.getTypePtr();
7023 bool Changed = false;
7024
7025 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7026 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
7027 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7028 if (!QualifierLoc)
7029 return QualType();
7030 Changed |= QualifierLoc != OldQualifierLoc;
7031 }
7032
7033 auto *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
7034 if (!D)
7035 return QualType();
7036 Changed |= D != T->getDecl();
7037
7038 QualType Result = TL.getType();
7039 if (getDerived().AlwaysRebuild() || Changed) {
7040 Result = getDerived().RebuildUnresolvedUsingType(
7041 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TL.getNameLoc(),
7042 D);
7043 if (Result.isNull())
7044 return QualType();
7045 }
7046
7048 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7049 QualifierLoc, TL.getNameLoc());
7050 else
7051 TLB.push<UnresolvedUsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7052 QualifierLoc, TL.getNameLoc());
7053 return Result;
7054}
7055
7056template <typename Derived>
7058 UsingTypeLoc TL) {
7059 const UsingType *T = TL.getTypePtr();
7060 bool Changed = false;
7061
7062 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7063 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
7064 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7065 if (!QualifierLoc)
7066 return QualType();
7067 Changed |= QualifierLoc != OldQualifierLoc;
7068 }
7069
7070 auto *D = cast_or_null<UsingShadowDecl>(
7071 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7072 if (!D)
7073 return QualType();
7074 Changed |= D != T->getDecl();
7075
7076 QualType UnderlyingType = getDerived().TransformType(T->desugar());
7077 if (UnderlyingType.isNull())
7078 return QualType();
7079 Changed |= UnderlyingType != T->desugar();
7080
7081 QualType Result = TL.getType();
7082 if (getDerived().AlwaysRebuild() || Changed) {
7083 Result = getDerived().RebuildUsingType(
7084 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), D,
7085 UnderlyingType);
7086 if (Result.isNull())
7087 return QualType();
7088 }
7089 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(), QualifierLoc,
7090 TL.getNameLoc());
7091 return Result;
7092}
7093
7094template<typename Derived>
7096 TypedefTypeLoc TL) {
7097 const TypedefType *T = TL.getTypePtr();
7098 bool Changed = false;
7099
7100 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7101 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
7102 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7103 if (!QualifierLoc)
7104 return QualType();
7105 Changed |= QualifierLoc != OldQualifierLoc;
7106 }
7107
7108 auto *Typedef = cast_or_null<TypedefNameDecl>(
7109 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7110 if (!Typedef)
7111 return QualType();
7112 Changed |= Typedef != T->getDecl();
7113
7114 // FIXME: Transform the UnderlyingType if different from decl.
7115
7116 QualType Result = TL.getType();
7117 if (getDerived().AlwaysRebuild() || Changed) {
7118 Result = getDerived().RebuildTypedefType(
7119 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), Typedef);
7120 if (Result.isNull())
7121 return QualType();
7122 }
7123
7124 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7125 QualifierLoc, TL.getNameLoc());
7126 return Result;
7127}
7128
7129template<typename Derived>
7131 TypeOfExprTypeLoc TL) {
7132 // typeof expressions are not potentially evaluated contexts
7136
7137 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
7138 if (E.isInvalid())
7139 return QualType();
7140
7141 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
7142 if (E.isInvalid())
7143 return QualType();
7144
7145 QualType Result = TL.getType();
7147 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
7148 Result =
7149 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
7150 if (Result.isNull())
7151 return QualType();
7152 }
7153
7154 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
7155 NewTL.setTypeofLoc(TL.getTypeofLoc());
7156 NewTL.setLParenLoc(TL.getLParenLoc());
7157 NewTL.setRParenLoc(TL.getRParenLoc());
7158
7159 return Result;
7160}
7161
7162template<typename Derived>
7164 TypeOfTypeLoc TL) {
7165 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
7166 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
7167 if (!New_Under_TI)
7168 return QualType();
7169
7170 QualType Result = TL.getType();
7171 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
7172 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
7173 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
7174 if (Result.isNull())
7175 return QualType();
7176 }
7177
7178 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
7179 NewTL.setTypeofLoc(TL.getTypeofLoc());
7180 NewTL.setLParenLoc(TL.getLParenLoc());
7181 NewTL.setRParenLoc(TL.getRParenLoc());
7182 NewTL.setUnmodifiedTInfo(New_Under_TI);
7183
7184 return Result;
7185}
7186
7187template<typename Derived>
7189 DecltypeTypeLoc TL) {
7190 const DecltypeType *T = TL.getTypePtr();
7191
7192 // decltype expressions are not potentially evaluated contexts
7196
7197 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
7198 if (E.isInvalid())
7199 return QualType();
7200
7201 E = getSema().ActOnDecltypeExpression(E.get());
7202 if (E.isInvalid())
7203 return QualType();
7204
7205 QualType Result = TL.getType();
7206 if (getDerived().AlwaysRebuild() ||
7207 E.get() != T->getUnderlyingExpr()) {
7208 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
7209 if (Result.isNull())
7210 return QualType();
7211 }
7212 else E.get();
7213
7214 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
7215 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
7216 NewTL.setRParenLoc(TL.getRParenLoc());
7217 return Result;
7218}
7219
7220template <typename Derived>
7224 // Transform the index
7225 ExprResult IndexExpr;
7226 {
7227 EnterExpressionEvaluationContext ConstantContext(
7229
7230 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
7231 if (IndexExpr.isInvalid())
7232 return QualType();
7233 }
7234 QualType Pattern = TL.getPattern();
7235
7236 const PackIndexingType *PIT = TL.getTypePtr();
7237 SmallVector<QualType, 5> SubtitutedTypes;
7238 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
7239
7240 bool NotYetExpanded = Types.empty();
7241 bool FullySubstituted = true;
7242
7243 if (Types.empty() && !PIT->expandsToEmptyPack())
7244 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
7245
7246 for (QualType T : Types) {
7247 if (!T->containsUnexpandedParameterPack()) {
7248 QualType Transformed = getDerived().TransformType(T);
7249 if (Transformed.isNull())
7250 return QualType();
7251 SubtitutedTypes.push_back(Transformed);
7252 continue;
7253 }
7254
7256 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
7257 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7258 // Determine whether the set of unexpanded parameter packs can and should
7259 // be expanded.
7260 bool ShouldExpand = true;
7261 bool RetainExpansion = false;
7262 UnsignedOrNone NumExpansions = std::nullopt;
7263 if (getDerived().TryExpandParameterPacks(
7264 TL.getEllipsisLoc(), SourceRange(), Unexpanded,
7265 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
7266 RetainExpansion, NumExpansions))
7267 return QualType();
7268 if (!ShouldExpand) {
7269 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7270 // FIXME: should we keep TypeLoc for individual expansions in
7271 // PackIndexingTypeLoc?
7272 TypeSourceInfo *TI =
7273 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
7274 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
7275 if (Pack.isNull())
7276 return QualType();
7277 if (NotYetExpanded) {
7278 FullySubstituted = false;
7279 QualType Out = getDerived().RebuildPackIndexingType(
7280 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7281 FullySubstituted);
7282 if (Out.isNull())
7283 return QualType();
7284
7286 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7287 return Out;
7288 }
7289 SubtitutedTypes.push_back(Pack);
7290 continue;
7291 }
7292 for (unsigned I = 0; I != *NumExpansions; ++I) {
7293 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
7294 QualType Out = getDerived().TransformType(T);
7295 if (Out.isNull())
7296 return QualType();
7297 SubtitutedTypes.push_back(Out);
7298 FullySubstituted &= !Out->containsUnexpandedParameterPack();
7299 }
7300 // If we're supposed to retain a pack expansion, do so by temporarily
7301 // forgetting the partially-substituted parameter pack.
7302 if (RetainExpansion) {
7303 FullySubstituted = false;
7304 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
7305 QualType Out = getDerived().TransformType(T);
7306 if (Out.isNull())
7307 return QualType();
7308 SubtitutedTypes.push_back(Out);
7309 }
7310 }
7311
7312 // A pack indexing type can appear in a larger pack expansion,
7313 // e.g. `Pack...[pack_of_indexes]...`
7314 // so we need to temporarily disable substitution of pack elements
7315 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7316 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
7317
7318 QualType Out = getDerived().RebuildPackIndexingType(
7319 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7320 FullySubstituted, SubtitutedTypes);
7321 if (Out.isNull())
7322 return Out;
7323
7325 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7326 return Out;
7327}
7328
7329template<typename Derived>
7331 TypeLocBuilder &TLB,
7333 QualType Result = TL.getType();
7334 TypeSourceInfo *NewBaseTSI = TL.getUnderlyingTInfo();
7335 if (Result->isDependentType()) {
7336 const UnaryTransformType *T = TL.getTypePtr();
7337
7338 NewBaseTSI = getDerived().TransformType(TL.getUnderlyingTInfo());
7339 if (!NewBaseTSI)
7340 return QualType();
7341 QualType NewBase = NewBaseTSI->getType();
7342
7343 Result = getDerived().RebuildUnaryTransformType(NewBase,
7344 T->getUTTKind(),
7345 TL.getKWLoc());
7346 if (Result.isNull())
7347 return QualType();
7348 }
7349
7351 NewTL.setKWLoc(TL.getKWLoc());
7352 NewTL.setParensRange(TL.getParensRange());
7353 NewTL.setUnderlyingTInfo(NewBaseTSI);
7354 return Result;
7355}
7356
7357template<typename Derived>
7360 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
7361
7362 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7363 TemplateName TemplateName = getDerived().TransformTemplateName(
7364 QualifierLoc, /*TemplateKELoc=*/SourceLocation(), T->getTemplateName(),
7365 TL.getTemplateNameLoc());
7366 if (TemplateName.isNull())
7367 return QualType();
7368
7369 QualType OldDeduced = T->getDeducedType();
7370 QualType NewDeduced;
7371 if (!OldDeduced.isNull()) {
7372 NewDeduced = getDerived().TransformType(OldDeduced);
7373 if (NewDeduced.isNull())
7374 return QualType();
7375 }
7376
7377 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
7378 NewDeduced.isNull() ? DeducedKind::Undeduced : DeducedKind::Deduced,
7379 NewDeduced, T->getKeyword(), TemplateName);
7380 if (Result.isNull())
7381 return QualType();
7382
7383 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7384 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7385 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7386 NewTL.setQualifierLoc(QualifierLoc);
7387 return Result;
7388}
7389
7390template <typename Derived>
7392 TagTypeLoc TL) {
7393 const TagType *T = TL.getTypePtr();
7394
7395 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7396 if (QualifierLoc) {
7397 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7398 if (!QualifierLoc)
7399 return QualType();
7400 }
7401
7402 auto *TD = cast_or_null<TagDecl>(
7403 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7404 if (!TD)
7405 return QualType();
7406
7407 QualType Result = TL.getType();
7408 if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() ||
7409 TD != T->getDecl()) {
7410 if (T->isCanonicalUnqualified())
7411 Result = getDerived().RebuildCanonicalTagType(TD);
7412 else
7413 Result = getDerived().RebuildTagType(
7414 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TD);
7415 if (Result.isNull())
7416 return QualType();
7417 }
7418
7419 TagTypeLoc NewTL = TLB.push<TagTypeLoc>(Result);
7421 NewTL.setQualifierLoc(QualifierLoc);
7422 NewTL.setNameLoc(TL.getNameLoc());
7423
7424 return Result;
7425}
7426
7427template <typename Derived>
7429 EnumTypeLoc TL) {
7430 return getDerived().TransformTagType(TLB, TL);
7431}
7432
7433template <typename Derived>
7434QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
7435 RecordTypeLoc TL) {
7436 return getDerived().TransformTagType(TLB, TL);
7437}
7438
7439template<typename Derived>
7441 TypeLocBuilder &TLB,
7443 return getDerived().TransformTagType(TLB, TL);
7444}
7445
7446template<typename Derived>
7448 TypeLocBuilder &TLB,
7450 return getDerived().TransformTemplateTypeParmType(
7451 TLB, TL,
7452 /*SuppressObjCLifetime=*/false);
7453}
7454
7455template <typename Derived>
7457 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7458 return TransformTypeSpecType(TLB, TL);
7459}
7460
7461template<typename Derived>
7462QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7463 TypeLocBuilder &TLB,
7464 SubstTemplateTypeParmTypeLoc TL) {
7465 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7466
7467 Decl *NewReplaced =
7468 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7469
7470 // Substitute into the replacement type, which itself might involve something
7471 // that needs to be transformed. This only tends to occur with default
7472 // template arguments of template template parameters.
7473 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7474 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7475 if (Replacement.isNull())
7476 return QualType();
7477
7478 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7479 Replacement, NewReplaced, T->getIndex(), T->getPackIndex(),
7480 T->getFinal());
7481
7482 // Propagate type-source information.
7483 SubstTemplateTypeParmTypeLoc NewTL
7484 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7485 NewTL.setNameLoc(TL.getNameLoc());
7486 return Result;
7487
7488}
7489template <typename Derived>
7492 return TransformTypeSpecType(TLB, TL);
7493}
7494
7495template<typename Derived>
7497 TypeLocBuilder &TLB,
7499 return getDerived().TransformSubstTemplateTypeParmPackType(
7500 TLB, TL, /*SuppressObjCLifetime=*/false);
7501}
7502
7503template <typename Derived>
7506 return TransformTypeSpecType(TLB, TL);
7507}
7508
7509template<typename Derived>
7510QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
7511 AtomicTypeLoc TL) {
7512 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7513 if (ValueType.isNull())
7514 return QualType();
7515
7516 QualType Result = TL.getType();
7517 if (getDerived().AlwaysRebuild() ||
7518 ValueType != TL.getValueLoc().getType()) {
7519 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7520 if (Result.isNull())
7521 return QualType();
7522 }
7523
7524 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7525 NewTL.setKWLoc(TL.getKWLoc());
7526 NewTL.setLParenLoc(TL.getLParenLoc());
7527 NewTL.setRParenLoc(TL.getRParenLoc());
7528
7529 return Result;
7530}
7531
7532template <typename Derived>
7534 PipeTypeLoc TL) {
7535 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7536 if (ValueType.isNull())
7537 return QualType();
7538
7539 QualType Result = TL.getType();
7540 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7541 const PipeType *PT = Result->castAs<PipeType>();
7542 bool isReadPipe = PT->isReadOnly();
7543 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7544 if (Result.isNull())
7545 return QualType();
7546 }
7547
7548 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7549 NewTL.setKWLoc(TL.getKWLoc());
7550
7551 return Result;
7552}
7553
7554template <typename Derived>
7556 BitIntTypeLoc TL) {
7557 const BitIntType *EIT = TL.getTypePtr();
7558 QualType Result = TL.getType();
7559
7560 if (getDerived().AlwaysRebuild()) {
7561 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7562 EIT->getNumBits(), TL.getNameLoc());
7563 if (Result.isNull())
7564 return QualType();
7565 }
7566
7567 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7568 NewTL.setNameLoc(TL.getNameLoc());
7569 return Result;
7570}
7571
7572template <typename Derived>
7575 const DependentBitIntType *EIT = TL.getTypePtr();
7576
7579 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7580 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7581
7582 if (BitsExpr.isInvalid())
7583 return QualType();
7584
7585 QualType Result = TL.getType();
7586
7587 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7588 Result = getDerived().RebuildDependentBitIntType(
7589 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7590
7591 if (Result.isNull())
7592 return QualType();
7593 }
7594
7597 NewTL.setNameLoc(TL.getNameLoc());
7598 } else {
7599 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7600 NewTL.setNameLoc(TL.getNameLoc());
7601 }
7602 return Result;
7603}
7604
7605template <typename Derived>
7608 llvm_unreachable("This type does not need to be transformed.");
7609}
7610
7611 /// Simple iterator that traverses the template arguments in a
7612 /// container that provides a \c getArgLoc() member function.
7613 ///
7614 /// This iterator is intended to be used with the iterator form of
7615 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7616 template<typename ArgLocContainer>
7618 ArgLocContainer *Container;
7619 unsigned Index;
7620
7621 public:
7624 typedef int difference_type;
7625 typedef std::input_iterator_tag iterator_category;
7626
7627 class pointer {
7629
7630 public:
7631 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7632
7634 return &Arg;
7635 }
7636 };
7637
7638
7640
7641 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7642 unsigned Index)
7643 : Container(&Container), Index(Index) { }
7644
7646 ++Index;
7647 return *this;
7648 }
7649
7652 ++(*this);
7653 return Old;
7654 }
7655
7657 return Container->getArgLoc(Index);
7658 }
7659
7661 return pointer(Container->getArgLoc(Index));
7662 }
7663
7666 return X.Container == Y.Container && X.Index == Y.Index;
7667 }
7668
7671 return !(X == Y);
7672 }
7673 };
7674
7675template<typename Derived>
7676QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7677 AutoTypeLoc TL) {
7678 const AutoType *T = TL.getTypePtr();
7679 QualType OldDeduced = T->getDeducedType();
7680 QualType NewDeduced;
7681 if (!OldDeduced.isNull()) {
7682 NewDeduced = getDerived().TransformType(OldDeduced);
7683 if (NewDeduced.isNull())
7684 return QualType();
7685 }
7686
7687 TemplateName NewCD;
7688 TemplateArgumentListInfo NewTemplateArgs;
7689 NestedNameSpecifierLoc NewNestedNameSpec;
7690 if (T->isConstrained()) {
7691 assert(TL.getConceptReference());
7692 NewCD = getDerived().TransformConceptTemplateName(
7693 T->getTypeConstraintConcept(), TL.getConceptNameLoc());
7694 if (NewCD.isNull())
7695 return QualType();
7696
7697 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7698 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7700 if (getDerived().TransformTemplateArguments(
7701 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7702 NewTemplateArgs))
7703 return QualType();
7704
7705 if (TL.getNestedNameSpecifierLoc()) {
7706 NewNestedNameSpec
7707 = getDerived().TransformNestedNameSpecifierLoc(
7708 TL.getNestedNameSpecifierLoc());
7709 if (!NewNestedNameSpec)
7710 return QualType();
7711 }
7712 }
7713
7714 QualType Result = TL.getType();
7715 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7716 T->isDependentType() || T->isConstrained()) {
7717 // FIXME: Maybe don't rebuild if all template arguments are the same.
7719 NewArgList.reserve(NewTemplateArgs.size());
7720 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7721 NewArgList.push_back(ArgLoc.getArgument());
7722 Result = getDerived().RebuildAutoType(
7723 NewDeduced.isNull() ? DeducedKind::Undeduced : DeducedKind::Deduced,
7724 NewDeduced, T->getKeyword(), NewCD, NewArgList);
7725 if (Result.isNull())
7726 return QualType();
7727 }
7728
7729 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7730 NewTL.setNameLoc(TL.getNameLoc());
7731 NewTL.setRParenLoc(TL.getRParenLoc());
7732 NewTL.setConceptReference(nullptr);
7733
7734 if (T->isConstrained()) {
7735 DeclarationName ConceptName =
7736 SemaRef.Context
7737 .getNameForTemplate(TL.getTypePtr()->getTypeConstraintConcept(),
7738 TL.getConceptNameLoc())
7739 .getName();
7741 DeclarationNameInfo(ConceptName, TL.getConceptNameLoc(), ConceptName);
7742 auto *CR = ConceptReference::Create(
7743 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7744 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7745 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7746 NewTL.setConceptReference(CR);
7747 }
7748
7749 return Result;
7750}
7751
7752template <typename Derived>
7755 return getDerived().TransformTemplateSpecializationType(
7756 TLB, TL, /*ObjectType=*/QualType(), /*FirstQualifierInScope=*/nullptr,
7757 /*AllowInjectedClassName=*/false);
7758}
7759
7760template <typename Derived>
7763 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
7764 const TemplateSpecializationType *T = TL.getTypePtr();
7765
7766 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7767 TemplateName Template = getDerived().TransformTemplateName(
7768 QualifierLoc, TL.getTemplateKeywordLoc(), T->getTemplateName(),
7769 TL.getTemplateNameLoc(), ObjectType, FirstQualifierInScope,
7770 AllowInjectedClassName);
7771 if (Template.isNull())
7772 return QualType();
7773
7774 TemplateArgumentListInfo NewTemplateArgs;
7775 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7776 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7778 ArgIterator;
7779 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7780 ArgIterator(TL, TL.getNumArgs()),
7781 NewTemplateArgs))
7782 return QualType();
7783
7784 // This needs to be rebuilt if either the arguments changed, or if the
7785 // original template changed. If the template changed, and even if the
7786 // arguments didn't change, these arguments might not correspond to their
7787 // respective parameters, therefore needing conversions.
7788 QualType Result = getDerived().RebuildTemplateSpecializationType(
7789 TL.getTypePtr()->getKeyword(), Template, TL.getTemplateNameLoc(),
7790 NewTemplateArgs);
7791
7792 if (!Result.isNull()) {
7794 TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getTemplateKeywordLoc(),
7795 TL.getTemplateNameLoc(), NewTemplateArgs);
7796 }
7797
7798 return Result;
7799}
7800
7801template <typename Derived>
7803 AttributedTypeLoc TL) {
7804 const AttributedType *oldType = TL.getTypePtr();
7805 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7806 if (modifiedType.isNull())
7807 return QualType();
7808
7809 // HLSL: re-validate matrix-layout markers after substitution. If the
7810 // post-substitution type is no longer a matrix, diagnose now.
7811 if (SemaRef.getLangOpts().HLSL &&
7813 oldType->getAttrKind(), modifiedType,
7814 TL.getAttr() ? TL.getAttr()->getLocation()
7815 : TL.getModifiedLoc().getBeginLoc()))
7816 return QualType();
7817
7818 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7819 const Attr *oldAttr = TL.getAttr();
7820 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7821 if (oldAttr && !newAttr)
7822 return QualType();
7823
7824 QualType result = TL.getType();
7825
7826 // FIXME: dependent operand expressions?
7827 if (getDerived().AlwaysRebuild() ||
7828 modifiedType != oldType->getModifiedType()) {
7829 // If the equivalent type is equal to the modified type, we don't want to
7830 // transform it as well because:
7831 //
7832 // 1. The transformation would yield the same result and is therefore
7833 // superfluous, and
7834 //
7835 // 2. Transforming the same type twice can cause problems, e.g. if it
7836 // is a FunctionProtoType, we may end up instantiating the function
7837 // parameters twice, which causes an assertion since the parameters
7838 // are already bound to their counterparts in the template for this
7839 // instantiation.
7840 //
7841 QualType equivalentType = modifiedType;
7842 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7843 TypeLocBuilder AuxiliaryTLB;
7844 AuxiliaryTLB.reserve(TL.getFullDataSize());
7845 equivalentType =
7846 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7847 if (equivalentType.isNull())
7848 return QualType();
7849 }
7850
7851 // Check whether we can add nullability; it is only represented as
7852 // type sugar, and therefore cannot be diagnosed in any other way.
7853 if (auto nullability = oldType->getImmediateNullability()) {
7854 if (!modifiedType->canHaveNullability()) {
7855 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7856 : TL.getModifiedLoc().getBeginLoc()),
7857 diag::err_nullability_nonpointer)
7858 << DiagNullabilityKind(*nullability, false) << modifiedType;
7859 return QualType();
7860 }
7861 }
7862
7863 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7864 modifiedType,
7865 equivalentType,
7866 TL.getAttr());
7867 }
7868
7869 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7870 newTL.setAttr(newAttr);
7871 return result;
7872}
7873
7874template <typename Derived>
7877 const CountAttributedType *OldTy = TL.getTypePtr();
7878 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7879 if (InnerTy.isNull())
7880 return QualType();
7881
7882 Expr *OldCount = TL.getCountExpr();
7883 Expr *NewCount = nullptr;
7884 if (OldCount) {
7885 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7886 if (CountResult.isInvalid())
7887 return QualType();
7888 NewCount = CountResult.get();
7889 }
7890
7891 QualType Result = TL.getType();
7892 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7893 OldCount != NewCount) {
7894 // Currently, CountAttributedType can only wrap incomplete array types.
7896 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7897 }
7898
7899 TLB.push<CountAttributedTypeLoc>(Result);
7900 return Result;
7901}
7902
7903template <typename Derived>
7907 const LateParsedAttrType *OldTy = TL.getTypePtr();
7908 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7909 if (InnerTy.isNull())
7910 return QualType();
7911
7912 QualType Result = TL.getType();
7913 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->getWrappedType()) {
7915 InnerTy, OldTy->getLateParsedAttribute());
7916 }
7917
7919 newTL.setAttrNameLoc(TL.getAttrNameLoc());
7920 return Result;
7921}
7922
7923template <typename Derived>
7926 // The BTFTagAttributedType is available for C only.
7927 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7928}
7929
7930template <typename Derived>
7933 const OverflowBehaviorType *OldTy = TL.getTypePtr();
7934 QualType InnerTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7935 if (InnerTy.isNull())
7936 return QualType();
7937
7938 QualType Result = TL.getType();
7939 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->getUnderlyingType()) {
7940 Result = SemaRef.Context.getOverflowBehaviorType(OldTy->getBehaviorKind(),
7941 InnerTy);
7942 if (Result.isNull())
7943 return QualType();
7944 }
7945
7947 NewTL.initializeLocal(SemaRef.Context, TL.getAttrLoc());
7948 return Result;
7949}
7950
7951template <typename Derived>
7954
7955 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7956
7957 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7958 if (WrappedTy.isNull())
7959 return QualType();
7960
7961 QualType ContainedTy = QualType();
7962 QualType OldContainedTy = oldType->getContainedType();
7963 TypeSourceInfo *ContainedTSI = nullptr;
7964 if (!OldContainedTy.isNull()) {
7965 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7966 if (!oldContainedTSI)
7967 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7968 OldContainedTy, SourceLocation());
7969 ContainedTSI = getDerived().TransformType(oldContainedTSI);
7970 if (!ContainedTSI)
7971 return QualType();
7972 ContainedTy = ContainedTSI->getType();
7973 }
7974
7975 HLSLAttributedResourceType::Attributes Attrs = oldType->getAttrs();
7976 if (Attrs.SampleCountExpr) {
7977 ExprResult SampleCountResult =
7978 getDerived().TransformExpr(Attrs.SampleCountExpr);
7979 if (SampleCountResult.isInvalid())
7980 return QualType();
7981 Attrs.SampleCountExpr = SampleCountResult.get();
7982 }
7983
7984 QualType Result = TL.getType();
7985 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7986 ContainedTy != oldType->getContainedType() ||
7987 Attrs.SampleCountExpr != oldType->getSampleCountExpr()) {
7988 Result = SemaRef.Context.getHLSLAttributedResourceType(WrappedTy,
7989 ContainedTy, Attrs);
7990 }
7991
7994 NewTL.setSourceRange(TL.getLocalSourceRange());
7995 NewTL.setContainedTypeSourceInfo(ContainedTSI);
7996 return Result;
7997}
7998
7999template <typename Derived>
8002 // No transformations needed.
8003 return TL.getType();
8004}
8005
8006template<typename Derived>
8009 ParenTypeLoc TL) {
8010 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
8011 if (Inner.isNull())
8012 return QualType();
8013
8014 QualType Result = TL.getType();
8015 if (getDerived().AlwaysRebuild() ||
8016 Inner != TL.getInnerLoc().getType()) {
8017 Result = getDerived().RebuildParenType(Inner);
8018 if (Result.isNull())
8019 return QualType();
8020 }
8021
8022 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
8023 NewTL.setLParenLoc(TL.getLParenLoc());
8024 NewTL.setRParenLoc(TL.getRParenLoc());
8025 return Result;
8026}
8027
8028template <typename Derived>
8032 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
8033 if (Inner.isNull())
8034 return QualType();
8035
8036 QualType Result = TL.getType();
8037 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
8038 Result =
8039 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
8040 if (Result.isNull())
8041 return QualType();
8042 }
8043
8045 NewTL.setExpansionLoc(TL.getExpansionLoc());
8046 return Result;
8047}
8048
8049template<typename Derived>
8050QualType TreeTransform<Derived>::TransformDependentNameType(
8052 return TransformDependentNameType(TLB, TL, false);
8053}
8054
8055template <typename Derived>
8056QualType TreeTransform<Derived>::TransformDependentNameType(
8057 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext,
8058 QualType ObjectType, NamedDecl *UnqualLookup) {
8059 const DependentNameType *T = TL.getTypePtr();
8060
8061 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
8062 if (QualifierLoc) {
8063 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
8064 QualifierLoc, ObjectType, UnqualLookup);
8065 if (!QualifierLoc)
8066 return QualType();
8067 } else {
8068 assert((ObjectType.isNull() && !UnqualLookup) &&
8069 "must be transformed by TransformNestedNameSpecifierLoc");
8070 }
8071
8073 = getDerived().RebuildDependentNameType(T->getKeyword(),
8074 TL.getElaboratedKeywordLoc(),
8075 QualifierLoc,
8076 T->getIdentifier(),
8077 TL.getNameLoc(),
8078 DeducedTSTContext);
8079 if (Result.isNull())
8080 return QualType();
8081
8082 if (isa<TagType>(Result)) {
8083 auto NewTL = TLB.push<TagTypeLoc>(Result);
8084 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
8085 NewTL.setQualifierLoc(QualifierLoc);
8086 NewTL.setNameLoc(TL.getNameLoc());
8088 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
8089 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
8090 NewTL.setTemplateNameLoc(TL.getNameLoc());
8091 NewTL.setQualifierLoc(QualifierLoc);
8092 } else if (isa<TypedefType>(Result)) {
8093 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
8094 QualifierLoc, TL.getNameLoc());
8095 } else if (isa<UnresolvedUsingType>(Result)) {
8096 auto NewTL = TLB.push<UnresolvedUsingTypeLoc>(Result);
8097 NewTL.set(TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getNameLoc());
8098 } else {
8099 auto NewTL = TLB.push<DependentNameTypeLoc>(Result);
8100 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
8101 NewTL.setQualifierLoc(QualifierLoc);
8102 NewTL.setNameLoc(TL.getNameLoc());
8103 }
8104 return Result;
8105}
8106
8107template<typename Derived>
8110 QualType Pattern
8111 = getDerived().TransformType(TLB, TL.getPatternLoc());
8112 if (Pattern.isNull())
8113 return QualType();
8114
8115 QualType Result = TL.getType();
8116 if (getDerived().AlwaysRebuild() ||
8117 Pattern != TL.getPatternLoc().getType()) {
8118 Result = getDerived().RebuildPackExpansionType(Pattern,
8119 TL.getPatternLoc().getSourceRange(),
8120 TL.getEllipsisLoc(),
8121 TL.getTypePtr()->getNumExpansions());
8122 if (Result.isNull())
8123 return QualType();
8124 }
8125
8127 NewT.setEllipsisLoc(TL.getEllipsisLoc());
8128 return Result;
8129}
8130
8131template<typename Derived>
8135 // ObjCInterfaceType is never dependent.
8136 TLB.pushFullCopy(TL);
8137 return TL.getType();
8138}
8139
8140template<typename Derived>
8144 const ObjCTypeParamType *T = TL.getTypePtr();
8145 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
8146 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
8147 if (!OTP)
8148 return QualType();
8149
8150 QualType Result = TL.getType();
8151 if (getDerived().AlwaysRebuild() ||
8152 OTP != T->getDecl()) {
8153 Result = getDerived().RebuildObjCTypeParamType(
8154 OTP, TL.getProtocolLAngleLoc(),
8155 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8156 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8157 if (Result.isNull())
8158 return QualType();
8159 }
8160
8162 if (TL.getNumProtocols()) {
8163 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8164 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8165 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
8166 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8167 }
8168 return Result;
8169}
8170
8171template<typename Derived>
8174 ObjCObjectTypeLoc TL) {
8175 // Transform base type.
8176 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
8177 if (BaseType.isNull())
8178 return QualType();
8179
8180 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
8181
8182 // Transform type arguments.
8183 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
8184 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
8185 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
8186 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
8187 QualType TypeArg = TypeArgInfo->getType();
8188 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
8189 AnyChanged = true;
8190
8191 // We have a pack expansion. Instantiate it.
8192 const auto *PackExpansion = PackExpansionLoc.getType()
8193 ->castAs<PackExpansionType>();
8195 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
8196 Unexpanded);
8197 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
8198
8199 // Determine whether the set of unexpanded parameter packs can
8200 // and should be expanded.
8201 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
8202 bool Expand = false;
8203 bool RetainExpansion = false;
8204 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
8205 if (getDerived().TryExpandParameterPacks(
8206 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
8207 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
8208 RetainExpansion, NumExpansions))
8209 return QualType();
8210
8211 if (!Expand) {
8212 // We can't expand this pack expansion into separate arguments yet;
8213 // just substitute into the pattern and create a new pack expansion
8214 // type.
8215 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
8216
8217 TypeLocBuilder TypeArgBuilder;
8218 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8219 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
8220 PatternLoc);
8221 if (NewPatternType.isNull())
8222 return QualType();
8223
8224 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
8225 NewPatternType, NumExpansions);
8226 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
8227 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
8228 NewTypeArgInfos.push_back(
8229 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
8230 continue;
8231 }
8232
8233 // Substitute into the pack expansion pattern for each slice of the
8234 // pack.
8235 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
8236 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
8237
8238 TypeLocBuilder TypeArgBuilder;
8239 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8240
8241 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
8242 PatternLoc);
8243 if (NewTypeArg.isNull())
8244 return QualType();
8245
8246 NewTypeArgInfos.push_back(
8247 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8248 }
8249
8250 continue;
8251 }
8252
8253 TypeLocBuilder TypeArgBuilder;
8254 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
8255 QualType NewTypeArg =
8256 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
8257 if (NewTypeArg.isNull())
8258 return QualType();
8259
8260 // If nothing changed, just keep the old TypeSourceInfo.
8261 if (NewTypeArg == TypeArg) {
8262 NewTypeArgInfos.push_back(TypeArgInfo);
8263 continue;
8264 }
8265
8266 NewTypeArgInfos.push_back(
8267 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8268 AnyChanged = true;
8269 }
8270
8271 QualType Result = TL.getType();
8272 if (getDerived().AlwaysRebuild() || AnyChanged) {
8273 // Rebuild the type.
8274 Result = getDerived().RebuildObjCObjectType(
8275 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
8276 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
8277 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8278 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8279
8280 if (Result.isNull())
8281 return QualType();
8282 }
8283
8284 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
8285 NewT.setHasBaseTypeAsWritten(true);
8286 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
8287 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
8288 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
8289 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
8290 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8291 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8292 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
8293 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8294 return Result;
8295}
8296
8297template<typename Derived>
8301 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8302 if (PointeeType.isNull())
8303 return QualType();
8304
8305 QualType Result = TL.getType();
8306 if (getDerived().AlwaysRebuild() ||
8307 PointeeType != TL.getPointeeLoc().getType()) {
8308 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8309 TL.getStarLoc());
8310 if (Result.isNull())
8311 return QualType();
8312 }
8313
8315 NewT.setStarLoc(TL.getStarLoc());
8316 return Result;
8317}
8318
8319//===----------------------------------------------------------------------===//
8320// Statement transformation
8321//===----------------------------------------------------------------------===//
8322template<typename Derived>
8325 return S;
8326}
8327
8328template<typename Derived>
8331 return getDerived().TransformCompoundStmt(S, false);
8332}
8333
8334template<typename Derived>
8337 bool IsStmtExpr) {
8338 Sema::CompoundScopeRAII CompoundScope(getSema());
8339 Sema::FPFeaturesStateRAII FPSave(getSema());
8340 if (S->hasStoredFPFeatures())
8341 getSema().resetFPOptions(
8342 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8343
8344 bool SubStmtInvalid = false;
8345 bool SubStmtChanged = false;
8346 SmallVector<Stmt*, 8> Statements;
8347 for (auto *B : S->body()) {
8348 StmtResult Result = getDerived().TransformStmt(
8349 B, IsStmtExpr && B == S->body_back() ? StmtDiscardKind::StmtExprResult
8350 : StmtDiscardKind::Discarded);
8351
8352 if (Result.isInvalid()) {
8353 // Immediately fail if this was a DeclStmt, since it's very
8354 // likely that this will cause problems for future statements.
8355 if (isa<DeclStmt>(B))
8356 return StmtError();
8357
8358 // Otherwise, just keep processing substatements and fail later.
8359 SubStmtInvalid = true;
8360 continue;
8361 }
8362
8363 SubStmtChanged = SubStmtChanged || Result.get() != B;
8364 Statements.push_back(Result.getAs<Stmt>());
8365 }
8366
8367 if (SubStmtInvalid)
8368 return StmtError();
8369
8370 if (!getDerived().AlwaysRebuild() &&
8371 !SubStmtChanged)
8372 return S;
8373
8374 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8375 Statements,
8376 S->getRBracLoc(),
8377 IsStmtExpr);
8378}
8379
8380template<typename Derived>
8383 ExprResult LHS, RHS;
8384 {
8387
8388 // Transform the left-hand case value.
8389 LHS = getDerived().TransformExpr(S->getLHS());
8390 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8391 if (LHS.isInvalid())
8392 return StmtError();
8393
8394 // Transform the right-hand case value (for the GNU case-range extension).
8395 RHS = getDerived().TransformExpr(S->getRHS());
8396 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8397 if (RHS.isInvalid())
8398 return StmtError();
8399 }
8400
8401 // Build the case statement.
8402 // Case statements are always rebuilt so that they will attached to their
8403 // transformed switch statement.
8404 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8405 LHS.get(),
8406 S->getEllipsisLoc(),
8407 RHS.get(),
8408 S->getColonLoc());
8409 if (Case.isInvalid())
8410 return StmtError();
8411
8412 // Transform the statement following the case
8413 StmtResult SubStmt =
8414 getDerived().TransformStmt(S->getSubStmt());
8415 if (SubStmt.isInvalid())
8416 return StmtError();
8417
8418 // Attach the body to the case statement
8419 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8420}
8421
8422template <typename Derived>
8424 // Transform the statement following the default case
8425 StmtResult SubStmt =
8426 getDerived().TransformStmt(S->getSubStmt());
8427 if (SubStmt.isInvalid())
8428 return StmtError();
8429
8430 // Default statements are always rebuilt
8431 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8432 SubStmt.get());
8433}
8434
8435template<typename Derived>
8438 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8439 if (SubStmt.isInvalid())
8440 return StmtError();
8441
8442 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8443 S->getDecl());
8444 if (!LD)
8445 return StmtError();
8446
8447 // If we're transforming "in-place" (we're not creating new local
8448 // declarations), assume we're replacing the old label statement
8449 // and clear out the reference to it.
8450 if (LD == S->getDecl())
8451 S->getDecl()->setStmt(nullptr);
8452
8453 // FIXME: Pass the real colon location in.
8454 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8456 SubStmt.get());
8457}
8458
8459template <typename Derived>
8461 if (!R)
8462 return R;
8463
8464 switch (R->getKind()) {
8465// Transform attributes by calling TransformXXXAttr.
8466#define ATTR(X) \
8467 case attr::X: \
8468 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8469#include "clang/Basic/AttrList.inc"
8470 }
8471 return R;
8472}
8473
8474template <typename Derived>
8476 const Stmt *InstS,
8477 const Attr *R) {
8478 if (!R)
8479 return R;
8480
8481 switch (R->getKind()) {
8482// Transform attributes by calling TransformStmtXXXAttr.
8483#define ATTR(X) \
8484 case attr::X: \
8485 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8486#include "clang/Basic/AttrList.inc"
8487 }
8488 return TransformAttr(R);
8489}
8490
8491template <typename Derived>
8494 StmtDiscardKind SDK) {
8495 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8496 if (SubStmt.isInvalid())
8497 return StmtError();
8498
8499 bool AttrsChanged = false;
8501
8502 // Visit attributes and keep track if any are transformed.
8503 for (const auto *I : S->getAttrs()) {
8504 const Attr *R =
8505 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8506 AttrsChanged |= (I != R);
8507 if (R)
8508 Attrs.push_back(R);
8509 }
8510
8511 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8512 return S;
8513
8514 // If transforming the attributes failed for all of the attributes in the
8515 // statement, don't make an AttributedStmt without attributes.
8516 if (Attrs.empty())
8517 return SubStmt;
8518
8519 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8520 SubStmt.get());
8521}
8522
8523template<typename Derived>
8526 // Transform the initialization statement
8527 StmtResult Init = getDerived().TransformStmt(S->getInit());
8528 if (Init.isInvalid())
8529 return StmtError();
8530
8532 if (!S->isConsteval()) {
8533 // Transform the condition
8534 Cond = getDerived().TransformCondition(
8535 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8536 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8538 if (Cond.isInvalid())
8539 return StmtError();
8540 }
8541
8542 // If this is a constexpr if, determine which arm we should instantiate.
8543 std::optional<bool> ConstexprConditionValue;
8544 if (S->isConstexpr())
8545 ConstexprConditionValue = Cond.getKnownValue();
8546
8547 // Transform the "then" branch.
8548 StmtResult Then;
8549 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8553 S->isNonNegatedConsteval());
8554
8555 Then = getDerived().TransformStmt(S->getThen());
8556 if (Then.isInvalid())
8557 return StmtError();
8558 } else {
8559 // Discarded branch is replaced with empty CompoundStmt so we can keep
8560 // proper source location for start and end of original branch, so
8561 // subsequent transformations like CoverageMapping work properly
8562 Then = new (getSema().Context)
8563 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8564 }
8565
8566 // Transform the "else" branch.
8567 StmtResult Else;
8568 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8572 S->isNegatedConsteval());
8573
8574 Else = getDerived().TransformStmt(S->getElse());
8575 if (Else.isInvalid())
8576 return StmtError();
8577 } else if (S->getElse() && ConstexprConditionValue &&
8578 *ConstexprConditionValue) {
8579 // Same thing here as with <then> branch, we are discarding it, we can't
8580 // replace it with NULL nor NullStmt as we need to keep for source location
8581 // range, for CoverageMapping
8582 Else = new (getSema().Context)
8583 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8584 }
8585
8586 if (!getDerived().AlwaysRebuild() &&
8587 Init.get() == S->getInit() &&
8588 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8589 Then.get() == S->getThen() &&
8590 Else.get() == S->getElse())
8591 return S;
8592
8593 return getDerived().RebuildIfStmt(
8594 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8595 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8596}
8597
8598template<typename Derived>
8601 // Transform the initialization statement
8602 StmtResult Init = getDerived().TransformStmt(S->getInit());
8603 if (Init.isInvalid())
8604 return StmtError();
8605
8606 // Transform the condition.
8607 Sema::ConditionResult Cond = getDerived().TransformCondition(
8608 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8610 if (Cond.isInvalid())
8611 return StmtError();
8612
8613 // Rebuild the switch statement.
8615 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8616 Init.get(), Cond, S->getRParenLoc());
8617 if (Switch.isInvalid())
8618 return StmtError();
8619
8620 // Transform the body of the switch statement.
8621 StmtResult Body = getDerived().TransformStmt(S->getBody());
8622
8623 // Complete the switch statement.
8624 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8625 Body.get());
8626}
8627
8628template<typename Derived>
8631 // Transform the condition
8632 Sema::ConditionResult Cond = getDerived().TransformCondition(
8633 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8635 if (Cond.isInvalid())
8636 return StmtError();
8637
8638 // OpenACC Restricts a while-loop inside of certain construct/clause
8639 // combinations, so diagnose that here in OpenACC mode.
8641 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8642
8643 // Transform the body
8644 StmtResult Body = getDerived().TransformStmt(S->getBody());
8645 if (Body.isInvalid())
8646 return StmtError();
8647
8648 if (!getDerived().AlwaysRebuild() &&
8649 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8650 Body.get() == S->getBody())
8651 return Owned(S);
8652
8653 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8654 Cond, S->getRParenLoc(), Body.get());
8655}
8656
8657template<typename Derived>
8660 // OpenACC Restricts a do-loop inside of certain construct/clause
8661 // combinations, so diagnose that here in OpenACC mode.
8663 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8664
8665 // Transform the body
8666 StmtResult Body = getDerived().TransformStmt(S->getBody());
8667 if (Body.isInvalid())
8668 return StmtError();
8669
8670 // Transform the condition
8671 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8672 if (Cond.isInvalid())
8673 return StmtError();
8674
8675 if (!getDerived().AlwaysRebuild() &&
8676 Cond.get() == S->getCond() &&
8677 Body.get() == S->getBody())
8678 return S;
8679
8680 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8681 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8682 S->getRParenLoc());
8683}
8684
8685template<typename Derived>
8688 if (getSema().getLangOpts().getOpenMPVersion())
8689 getSema().OpenMP().startOpenMPLoop();
8690
8691 // Transform the initialization statement
8692 StmtResult Init = getDerived().TransformStmt(S->getInit());
8693 if (Init.isInvalid())
8694 return StmtError();
8695
8696 // In OpenMP loop region loop control variable must be captured and be
8697 // private. Perform analysis of first part (if any).
8698 if (getSema().getLangOpts().getOpenMPVersion() && Init.isUsable())
8699 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8700 Init.get());
8701
8702 // Transform the condition
8703 Sema::ConditionResult Cond = getDerived().TransformCondition(
8704 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8706 if (Cond.isInvalid())
8707 return StmtError();
8708
8709 // Transform the increment
8710 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8711 if (Inc.isInvalid())
8712 return StmtError();
8713
8714 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8715 if (S->getInc() && !FullInc.get())
8716 return StmtError();
8717
8718 // OpenACC Restricts a for-loop inside of certain construct/clause
8719 // combinations, so diagnose that here in OpenACC mode.
8721 SemaRef.OpenACC().ActOnForStmtBegin(
8722 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8723 Cond.get().second, S->getInc(), Inc.get());
8724
8725 // Transform the body
8726 StmtResult Body = getDerived().TransformStmt(S->getBody());
8727 if (Body.isInvalid())
8728 return StmtError();
8729
8730 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8731
8732 if (!getDerived().AlwaysRebuild() &&
8733 Init.get() == S->getInit() &&
8734 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8735 Inc.get() == S->getInc() &&
8736 Body.get() == S->getBody())
8737 return S;
8738
8739 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8740 Init.get(), Cond, FullInc,
8741 S->getRParenLoc(), Body.get());
8742}
8743
8744template<typename Derived>
8747 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8748 S->getLabel());
8749 if (!LD)
8750 return StmtError();
8751
8752 // Goto statements must always be rebuilt, to resolve the label.
8753 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8754 cast<LabelDecl>(LD));
8755}
8756
8757template<typename Derived>
8760 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8761 if (Target.isInvalid())
8762 return StmtError();
8763 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8764
8765 if (!getDerived().AlwaysRebuild() &&
8766 Target.get() == S->getTarget())
8767 return S;
8768
8769 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8770 Target.get());
8771}
8772
8773template<typename Derived>
8776 if (!S->hasLabelTarget())
8777 return S;
8778
8779 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8780 S->getLabelDecl());
8781 if (!LD)
8782 return StmtError();
8783
8784 return new (SemaRef.Context)
8785 ContinueStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8786}
8787
8788template<typename Derived>
8791 if (!S->hasLabelTarget())
8792 return S;
8793
8794 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8795 S->getLabelDecl());
8796 if (!LD)
8797 return StmtError();
8798
8799 return new (SemaRef.Context)
8800 BreakStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8801}
8802
8803template <typename Derived>
8805 StmtResult Result = getDerived().TransformStmt(S->getBody());
8806 if (!Result.isUsable())
8807 return StmtError();
8808 return DeferStmt::Create(getSema().Context, S->getDeferLoc(), Result.get());
8809}
8810
8811template<typename Derived>
8814 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8815 /*NotCopyInit*/false);
8816 if (Result.isInvalid())
8817 return StmtError();
8818
8819 // FIXME: We always rebuild the return statement because there is no way
8820 // to tell whether the return type of the function has changed.
8821 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8822}
8823
8824template<typename Derived>
8827 bool DeclChanged = false;
8829 LambdaScopeInfo *LSI = getSema().getCurLambda();
8830 for (auto *D : S->decls()) {
8831 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8832 if (!Transformed)
8833 return StmtError();
8834
8835 if (Transformed != D)
8836 DeclChanged = true;
8837
8838 if (LSI) {
8839 if (auto *TD = dyn_cast<TypeDecl>(Transformed)) {
8840 if (auto *TN = dyn_cast<TypedefNameDecl>(TD)) {
8841 LSI->ContainsUnexpandedParameterPack |=
8842 TN->getUnderlyingType()->containsUnexpandedParameterPack();
8843 } else {
8844 LSI->ContainsUnexpandedParameterPack |=
8845 getSema()
8846 .getASTContext()
8847 .getTypeDeclType(TD)
8848 ->containsUnexpandedParameterPack();
8849 }
8850 }
8851 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8852 LSI->ContainsUnexpandedParameterPack |=
8853 VD->getType()->containsUnexpandedParameterPack();
8854 }
8855
8856 Decls.push_back(Transformed);
8857 }
8858
8859 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8860 return S;
8861
8862 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8863}
8864
8865template<typename Derived>
8868
8869 SmallVector<Expr*, 8> Constraints;
8872
8873 SmallVector<Expr*, 8> Clobbers;
8874
8875 bool ExprsChanged = false;
8876
8877 auto RebuildString = [&](Expr *E) {
8878 ExprResult Result = getDerived().TransformExpr(E);
8879 if (!Result.isUsable())
8880 return Result;
8881 if (Result.get() != E) {
8882 ExprsChanged = true;
8883 Result = SemaRef.ActOnGCCAsmStmtString(Result.get(), /*ForLabel=*/false);
8884 }
8885 return Result;
8886 };
8887
8888 // Go through the outputs.
8889 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8890 Names.push_back(S->getOutputIdentifier(I));
8891
8892 ExprResult Result = RebuildString(S->getOutputConstraintExpr(I));
8893 if (Result.isInvalid())
8894 return StmtError();
8895
8896 Constraints.push_back(Result.get());
8897
8898 // Transform the output expr.
8899 Expr *OutputExpr = S->getOutputExpr(I);
8900 Result = getDerived().TransformExpr(OutputExpr);
8901 if (Result.isInvalid())
8902 return StmtError();
8903
8904 ExprsChanged |= Result.get() != OutputExpr;
8905
8906 Exprs.push_back(Result.get());
8907 }
8908
8909 // Go through the inputs.
8910 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8911 Names.push_back(S->getInputIdentifier(I));
8912
8913 ExprResult Result = RebuildString(S->getInputConstraintExpr(I));
8914 if (Result.isInvalid())
8915 return StmtError();
8916
8917 Constraints.push_back(Result.get());
8918
8919 // Transform the input expr.
8920 Expr *InputExpr = S->getInputExpr(I);
8921 Result = getDerived().TransformExpr(InputExpr);
8922 if (Result.isInvalid())
8923 return StmtError();
8924
8925 ExprsChanged |= Result.get() != InputExpr;
8926
8927 Exprs.push_back(Result.get());
8928 }
8929
8930 // Go through the Labels.
8931 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8932 Names.push_back(S->getLabelIdentifier(I));
8933
8934 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8935 if (Result.isInvalid())
8936 return StmtError();
8937 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8938 Exprs.push_back(Result.get());
8939 }
8940
8941 // Go through the clobbers.
8942 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) {
8943 ExprResult Result = RebuildString(S->getClobberExpr(I));
8944 if (Result.isInvalid())
8945 return StmtError();
8946 Clobbers.push_back(Result.get());
8947 }
8948
8949 ExprResult AsmString = RebuildString(S->getAsmStringExpr());
8950 if (AsmString.isInvalid())
8951 return StmtError();
8952
8953 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8954 return S;
8955
8956 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8957 S->isVolatile(), S->getNumOutputs(),
8958 S->getNumInputs(), Names.data(),
8959 Constraints, Exprs, AsmString.get(),
8960 Clobbers, S->getNumLabels(),
8961 S->getRParenLoc());
8962}
8963
8964template<typename Derived>
8967 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8968
8969 bool HadError = false, HadChange = false;
8970
8971 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8972 SmallVector<Expr*, 8> TransformedExprs;
8973 TransformedExprs.reserve(SrcExprs.size());
8974 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8975 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8976 if (!Result.isUsable()) {
8977 HadError = true;
8978 } else {
8979 HadChange |= (Result.get() != SrcExprs[i]);
8980 TransformedExprs.push_back(Result.get());
8981 }
8982 }
8983
8984 if (HadError) return StmtError();
8985 if (!HadChange && !getDerived().AlwaysRebuild())
8986 return Owned(S);
8987
8988 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8989 AsmToks, S->getAsmString(),
8990 S->getNumOutputs(), S->getNumInputs(),
8991 S->getAllConstraints(), S->getClobbers(),
8992 TransformedExprs, S->getEndLoc());
8993}
8994
8995// C++ Coroutines
8996template<typename Derived>
8999 auto *ScopeInfo = SemaRef.getCurFunction();
9000 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
9001 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
9002 ScopeInfo->NeedsCoroutineSuspends &&
9003 ScopeInfo->CoroutineSuspends.first == nullptr &&
9004 ScopeInfo->CoroutineSuspends.second == nullptr &&
9005 "expected clean scope info");
9006
9007 // Set that we have (possibly-invalid) suspend points before we do anything
9008 // that may fail.
9009 ScopeInfo->setNeedsCoroutineSuspends(false);
9010
9011 // We re-build the coroutine promise object (and the coroutine parameters its
9012 // type and constructor depend on) based on the types used in our current
9013 // function. We must do so, and set it on the current FunctionScopeInfo,
9014 // before attempting to transform the other parts of the coroutine body
9015 // statement, such as the implicit suspend statements (because those
9016 // statements reference the FunctionScopeInfo::CoroutinePromise).
9017 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
9018 return StmtError();
9019 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
9020 if (!Promise)
9021 return StmtError();
9022 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
9023 ScopeInfo->CoroutinePromise = Promise;
9024
9025 // Transform the implicit coroutine statements constructed using dependent
9026 // types during the previous parse: initial and final suspensions, the return
9027 // object, and others. We also transform the coroutine function's body.
9028 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
9029 if (InitSuspend.isInvalid())
9030 return StmtError();
9031 StmtResult FinalSuspend =
9032 getDerived().TransformStmt(S->getFinalSuspendStmt());
9033 if (FinalSuspend.isInvalid() ||
9034 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
9035 return StmtError();
9036 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
9037 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
9038
9039 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
9040 if (BodyRes.isInvalid())
9041 return StmtError();
9042
9043 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
9044 if (Builder.isInvalid())
9045 return StmtError();
9046
9047 Expr *ReturnObject = S->getReturnValueInit();
9048 assert(ReturnObject && "the return object is expected to be valid");
9049 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
9050 /*NoCopyInit*/ false);
9051 if (Res.isInvalid())
9052 return StmtError();
9053 Builder.ReturnValue = Res.get();
9054
9055 // If during the previous parse the coroutine still had a dependent promise
9056 // statement, we may need to build some implicit coroutine statements
9057 // (such as exception and fallthrough handlers) for the first time.
9058 if (S->hasDependentPromiseType()) {
9059 // We can only build these statements, however, if the current promise type
9060 // is not dependent.
9061 if (!Promise->getType()->isDependentType()) {
9062 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
9063 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
9064 "these nodes should not have been built yet");
9065 if (!Builder.buildDependentStatements())
9066 return StmtError();
9067 }
9068 } else {
9069 if (auto *OnFallthrough = S->getFallthroughHandler()) {
9070 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
9071 if (Res.isInvalid())
9072 return StmtError();
9073 Builder.OnFallthrough = Res.get();
9074 }
9075
9076 if (auto *OnException = S->getExceptionHandler()) {
9077 StmtResult Res = getDerived().TransformStmt(OnException);
9078 if (Res.isInvalid())
9079 return StmtError();
9080 Builder.OnException = Res.get();
9081 }
9082
9083 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
9084 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
9085 if (Res.isInvalid())
9086 return StmtError();
9087 Builder.ReturnStmtOnAllocFailure = Res.get();
9088 }
9089
9090 // Transform any additional statements we may have already built
9091 assert(S->getAllocate() && S->getDeallocate() &&
9092 "allocation and deallocation calls must already be built");
9093 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
9094 if (AllocRes.isInvalid())
9095 return StmtError();
9096 Builder.Allocate = AllocRes.get();
9097
9098 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
9099 if (DeallocRes.isInvalid())
9100 return StmtError();
9101 Builder.Deallocate = DeallocRes.get();
9102
9103 if (auto *ResultDecl = S->getResultDecl()) {
9104 StmtResult Res = getDerived().TransformStmt(ResultDecl);
9105 if (Res.isInvalid())
9106 return StmtError();
9107 Builder.ResultDecl = Res.get();
9108 }
9109
9110 if (auto *ReturnStmt = S->getReturnStmt()) {
9111 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
9112 if (Res.isInvalid())
9113 return StmtError();
9114 Builder.ReturnStmt = Res.get();
9115 }
9116 }
9117
9118 return getDerived().RebuildCoroutineBodyStmt(Builder);
9119}
9120
9121template<typename Derived>
9124 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
9125 /*NotCopyInit*/false);
9126 if (Result.isInvalid())
9127 return StmtError();
9128
9129 // Always rebuild; we don't know if this needs to be injected into a new
9130 // context or if the promise type has changed.
9131 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
9132 S->isImplicit());
9133}
9134
9135template <typename Derived>
9137 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
9138 /*NotCopyInit*/ false);
9139 if (Operand.isInvalid())
9140 return ExprError();
9141
9142 // Rebuild the common-expr from the operand rather than transforming it
9143 // separately.
9144
9145 // FIXME: getCurScope() should not be used during template instantiation.
9146 // We should pick up the set of unqualified lookup results for operator
9147 // co_await during the initial parse.
9148 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
9149 getSema().getCurScope(), E->getKeywordLoc());
9150
9151 // Always rebuild; we don't know if this needs to be injected into a new
9152 // context or if the promise type has changed.
9153 return getDerived().RebuildCoawaitExpr(
9154 E->getKeywordLoc(), Operand.get(),
9155 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
9156}
9157
9158template <typename Derived>
9161 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
9162 /*NotCopyInit*/ false);
9163 if (OperandResult.isInvalid())
9164 return ExprError();
9165
9166 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
9167 E->getOperatorCoawaitLookup());
9168
9169 if (LookupResult.isInvalid())
9170 return ExprError();
9171
9172 // Always rebuild; we don't know if this needs to be injected into a new
9173 // context or if the promise type has changed.
9174 return getDerived().RebuildDependentCoawaitExpr(
9175 E->getKeywordLoc(), OperandResult.get(),
9177}
9178
9179template<typename Derived>
9182 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
9183 /*NotCopyInit*/false);
9184 if (Result.isInvalid())
9185 return ExprError();
9186
9187 // Always rebuild; we don't know if this needs to be injected into a new
9188 // context or if the promise type has changed.
9189 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
9190}
9191
9192// Objective-C Statements.
9193
9194template<typename Derived>
9197 // Transform the body of the @try.
9198 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
9199 if (TryBody.isInvalid())
9200 return StmtError();
9201
9202 // Transform the @catch statements (if present).
9203 bool AnyCatchChanged = false;
9204 SmallVector<Stmt*, 8> CatchStmts;
9205 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
9206 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
9207 if (Catch.isInvalid())
9208 return StmtError();
9209 if (Catch.get() != S->getCatchStmt(I))
9210 AnyCatchChanged = true;
9211 CatchStmts.push_back(Catch.get());
9212 }
9213
9214 // Transform the @finally statement (if present).
9215 StmtResult Finally;
9216 if (S->getFinallyStmt()) {
9217 Finally = getDerived().TransformStmt(S->getFinallyStmt());
9218 if (Finally.isInvalid())
9219 return StmtError();
9220 }
9221
9222 // If nothing changed, just retain this statement.
9223 if (!getDerived().AlwaysRebuild() &&
9224 TryBody.get() == S->getTryBody() &&
9225 !AnyCatchChanged &&
9226 Finally.get() == S->getFinallyStmt())
9227 return S;
9228
9229 // Build a new statement.
9230 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
9231 CatchStmts, Finally.get());
9232}
9233
9234template<typename Derived>
9237 // Transform the @catch parameter, if there is one.
9238 VarDecl *Var = nullptr;
9239 if (VarDecl *FromVar = S->getCatchParamDecl()) {
9240 TypeSourceInfo *TSInfo = nullptr;
9241 if (FromVar->getTypeSourceInfo()) {
9242 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
9243 if (!TSInfo)
9244 return StmtError();
9245 }
9246
9247 QualType T;
9248 if (TSInfo)
9249 T = TSInfo->getType();
9250 else {
9251 T = getDerived().TransformType(FromVar->getType());
9252 if (T.isNull())
9253 return StmtError();
9254 }
9255
9256 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
9257 if (!Var)
9258 return StmtError();
9259 }
9260
9261 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
9262 if (Body.isInvalid())
9263 return StmtError();
9264
9265 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
9266 S->getRParenLoc(),
9267 Var, Body.get());
9268}
9269
9270template<typename Derived>
9273 // Transform the body.
9274 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
9275 if (Body.isInvalid())
9276 return StmtError();
9277
9278 // If nothing changed, just retain this statement.
9279 if (!getDerived().AlwaysRebuild() &&
9280 Body.get() == S->getFinallyBody())
9281 return S;
9282
9283 // Build a new statement.
9284 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
9285 Body.get());
9286}
9287
9288template<typename Derived>
9292 if (S->getThrowExpr()) {
9293 Operand = getDerived().TransformExpr(S->getThrowExpr());
9294 if (Operand.isInvalid())
9295 return StmtError();
9296 }
9297
9298 if (!getDerived().AlwaysRebuild() &&
9299 Operand.get() == S->getThrowExpr())
9300 return S;
9301
9302 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
9303}
9304
9305template<typename Derived>
9309 // Transform the object we are locking.
9310 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
9311 if (Object.isInvalid())
9312 return StmtError();
9313 Object =
9314 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
9315 Object.get());
9316 if (Object.isInvalid())
9317 return StmtError();
9318
9319 // Transform the body.
9320 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
9321 if (Body.isInvalid())
9322 return StmtError();
9323
9324 // If nothing change, just retain the current statement.
9325 if (!getDerived().AlwaysRebuild() &&
9326 Object.get() == S->getSynchExpr() &&
9327 Body.get() == S->getSynchBody())
9328 return S;
9329
9330 // Build a new statement.
9331 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
9332 Object.get(), Body.get());
9333}
9334
9335template<typename Derived>
9339 // Transform the body.
9340 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
9341 if (Body.isInvalid())
9342 return StmtError();
9343
9344 // If nothing changed, just retain this statement.
9345 if (!getDerived().AlwaysRebuild() &&
9346 Body.get() == S->getSubStmt())
9347 return S;
9348
9349 // Build a new statement.
9350 return getDerived().RebuildObjCAutoreleasePoolStmt(
9351 S->getAtLoc(), Body.get());
9352}
9353
9354template<typename Derived>
9358 // Transform the element statement.
9359 StmtResult Element = getDerived().TransformStmt(
9360 S->getElement(), StmtDiscardKind::NotDiscarded);
9361 if (Element.isInvalid())
9362 return StmtError();
9363
9364 // Transform the collection expression.
9365 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9366 if (Collection.isInvalid())
9367 return StmtError();
9368
9369 // Transform the body.
9370 StmtResult Body = getDerived().TransformStmt(S->getBody());
9371 if (Body.isInvalid())
9372 return StmtError();
9373
9374 // If nothing changed, just retain this statement.
9375 if (!getDerived().AlwaysRebuild() &&
9376 Element.get() == S->getElement() &&
9377 Collection.get() == S->getCollection() &&
9378 Body.get() == S->getBody())
9379 return S;
9380
9381 // Build a new statement.
9382 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9383 Element.get(),
9384 Collection.get(),
9385 S->getRParenLoc(),
9386 Body.get());
9387}
9388
9389template <typename Derived>
9391 // Transform the exception declaration, if any.
9392 VarDecl *Var = nullptr;
9393 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9394 TypeSourceInfo *T =
9395 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9396 if (!T)
9397 return StmtError();
9398
9399 Var = getDerived().RebuildExceptionDecl(
9400 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9401 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9402 if (!Var || Var->isInvalidDecl())
9403 return StmtError();
9404 }
9405
9406 // Transform the actual exception handler.
9407 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9408 if (Handler.isInvalid())
9409 return StmtError();
9410
9411 if (!getDerived().AlwaysRebuild() && !Var &&
9412 Handler.get() == S->getHandlerBlock())
9413 return S;
9414
9415 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9416}
9417
9418template <typename Derived>
9420 // Transform the try block itself.
9421 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9422 if (TryBlock.isInvalid())
9423 return StmtError();
9424
9425 // Transform the handlers.
9426 bool HandlerChanged = false;
9427 SmallVector<Stmt *, 8> Handlers;
9428 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9429 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9430 if (Handler.isInvalid())
9431 return StmtError();
9432
9433 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9434 Handlers.push_back(Handler.getAs<Stmt>());
9435 }
9436
9437 getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
9438
9439 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9440 !HandlerChanged)
9441 return S;
9442
9443 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9444 Handlers);
9445}
9446
9447template<typename Derived>
9450 EnterExpressionEvaluationContext ForRangeInitContext(
9452 /*LambdaContextDecl=*/nullptr,
9454 getSema().getLangOpts().CPlusPlus23);
9455
9456 // P2718R0 - Lifetime extension in range-based for loops.
9457 if (getSema().getLangOpts().CPlusPlus23) {
9458 auto &LastRecord = getSema().currentEvaluationContext();
9459 LastRecord.InLifetimeExtendingContext = true;
9460 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9461 }
9463 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9464 if (Init.isInvalid())
9465 return StmtError();
9466
9467 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9468 if (Range.isInvalid())
9469 return StmtError();
9470
9471 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9472 assert(getSema().getLangOpts().CPlusPlus23 ||
9473 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9474 auto ForRangeLifetimeExtendTemps =
9475 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9476
9477 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9478 if (Begin.isInvalid())
9479 return StmtError();
9480 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9481 if (End.isInvalid())
9482 return StmtError();
9483
9484 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9485 if (Cond.isInvalid())
9486 return StmtError();
9487 if (Cond.get())
9488 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9489 if (Cond.isInvalid())
9490 return StmtError();
9491 if (Cond.get())
9492 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9493
9494 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9495 if (Inc.isInvalid())
9496 return StmtError();
9497 if (Inc.get())
9498 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9499
9500 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9501 if (LoopVar.isInvalid())
9502 return StmtError();
9503
9504 StmtResult NewStmt = S;
9505 if (getDerived().AlwaysRebuild() ||
9506 Init.get() != S->getInit() ||
9507 Range.get() != S->getRangeStmt() ||
9508 Begin.get() != S->getBeginStmt() ||
9509 End.get() != S->getEndStmt() ||
9510 Cond.get() != S->getCond() ||
9511 Inc.get() != S->getInc() ||
9512 LoopVar.get() != S->getLoopVarStmt()) {
9513 NewStmt = getDerived().RebuildCXXForRangeStmt(
9514 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9515 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9516 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9517 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9518 // Might not have attached any initializer to the loop variable.
9519 getSema().ActOnInitializerError(
9520 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9521 return StmtError();
9522 }
9523 }
9524
9525 // OpenACC Restricts a while-loop inside of certain construct/clause
9526 // combinations, so diagnose that here in OpenACC mode.
9528 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9529
9530 StmtResult Body = getDerived().TransformStmt(S->getBody());
9531 if (Body.isInvalid())
9532 return StmtError();
9533
9534 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9535
9536 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9537 // it now so we have a new statement to attach the body to.
9538 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9539 NewStmt = getDerived().RebuildCXXForRangeStmt(
9540 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9541 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9542 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9543 if (NewStmt.isInvalid())
9544 return StmtError();
9545 }
9546
9547 if (NewStmt.get() == S)
9548 return S;
9549
9550 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9551}
9552
9553template <typename Derived>
9556 assert(SemaRef.CurContext->isExpansionStmt());
9557
9558 Decl *ESD =
9559 getDerived().TransformDecl(S->getDecl()->getLocation(), S->getDecl());
9560 if (!ESD || ESD->isInvalidDecl())
9561 return StmtError();
9563
9564 // This is required because some parts of an expansion statement (e.g. the
9565 // init-statement) are not in a dependent context and must thus be transformed
9566 // in the parent context.
9567 auto TransformStmtInParentContext = [&](Stmt *SubStmt) -> StmtResult {
9568 Sema::ContextRAII CtxGuard(SemaRef, SemaRef.CurContext->getParent(),
9569 /*NewThis=*/false);
9570 return getDerived().TransformStmt(SubStmt);
9571 };
9572
9573 Stmt *Init = S->getInit();
9574 if (Init) {
9575 StmtResult SR = TransformStmtInParentContext(Init);
9576 if (SR.isInvalid())
9577 return StmtError();
9578 Init = SR.get();
9579 }
9580
9581 // Collect lifetime-extended temporaries in case this ends up being a
9582 // destructuring or iterating expansion statement.
9583 //
9584 // CWG 3140: Additionally, for iterating expansions statements, we need to
9585 // apply lifetime extension to the initializer of the range.
9586 ExprResult ExpansionInitializer;
9589 if (S->isDependent() || S->isIterating()) {
9591 SemaRef, SemaRef.currentEvaluationContext().Context);
9594
9595 if (S->isDependent()) {
9596 // The expansion initializer should not be in the context of the expansion
9597 // statement because it isn't instantiated when the expansion statement is
9598 // expanded.
9599 Sema::ContextRAII CtxGuard(SemaRef, SemaRef.CurContext->getParent(),
9600 /*NewThis=*/false);
9601 ExpansionInitializer =
9602 getDerived().TransformExpr(S->getExpansionInitializer());
9603 if (ExpansionInitializer.isInvalid())
9604 return StmtError();
9605 } else if (S->isIterating()) {
9606 Range = TransformStmtInParentContext(S->getRangeVarStmt());
9607 if (Range.isInvalid())
9608 return StmtError();
9609 }
9610
9611 ExpansionInitializer =
9612 SemaRef.MaybeCreateExprWithCleanups(ExpansionInitializer);
9613
9614 LifetimeExtendTemps =
9616 }
9617
9618 CXXExpansionStmtPattern *NewPattern = nullptr;
9619 if (S->isEnumerating()) {
9620 StmtResult ExpansionVar =
9621 getDerived().TransformStmt(S->getExpansionVarStmt());
9622 if (ExpansionVar.isInvalid())
9623 return StmtError();
9624
9626 SemaRef.Context, NewESD, Init, ExpansionVar.getAs<DeclStmt>(),
9627 S->getLParenLoc(), S->getColonLoc(), S->getRParenLoc());
9628 } else if (S->isIterating()) {
9629 StmtResult Begin = TransformStmtInParentContext(S->getBeginVarStmt());
9630 StmtResult Iter = TransformStmtInParentContext(S->getIterVarStmt());
9631 if (Begin.isInvalid() || Iter.isInvalid())
9632 return StmtError();
9633
9634 // The expansion variable is part of the pattern only and never ends
9635 // up in the instantiations, so keep it in the expansion statement's
9636 // DeclContext.
9637 StmtResult ExpansionVar =
9638 getDerived().TransformStmt(S->getExpansionVarStmt());
9639 if (ExpansionVar.isInvalid())
9640 return StmtError();
9641
9643 SemaRef.Context, NewESD, Init, ExpansionVar.getAs<DeclStmt>(),
9644 Range.getAs<DeclStmt>(), Begin.getAs<DeclStmt>(),
9645 Iter.getAs<DeclStmt>(), S->getLParenLoc(), S->getColonLoc(),
9646 S->getRParenLoc());
9647
9649 NewPattern->getRangeVar(), LifetimeExtendTemps);
9650 } else if (S->isDependent()) {
9651 StmtResult ExpansionVar =
9652 getDerived().TransformStmt(S->getExpansionVarStmt());
9653 if (ExpansionVar.isInvalid())
9654 return StmtError();
9655
9657 NewESD, Init, ExpansionVar.getAs<DeclStmt>(),
9658 ExpansionInitializer.get(), S->getLParenLoc(), S->getColonLoc(),
9659 S->getRParenLoc(), LifetimeExtendTemps);
9660
9661 if (Res.isInvalid())
9662 return StmtError();
9663
9664 NewPattern = cast<CXXExpansionStmtPattern>(Res.get());
9665 } else {
9666 // The only time we instantiate an expansion statement is if its expansion
9667 // size is dependent (otherwise, we only instantiate the expansions and
9668 // leave the underlying CXXExpansionStmtPattern as-is). Since destructuring
9669 // expansion statements never have a dependent size, we should never get
9670 // here.
9671 llvm_unreachable("destructuring pattern should never be instantiated");
9672 }
9673
9674 StmtResult Body = getDerived().TransformStmt(S->getBody());
9675 if (Body.isInvalid())
9676 return StmtError();
9677
9678 return SemaRef.FinishCXXExpansionStmt(NewPattern, Body.get());
9679}
9680
9681template <typename Derived>
9684 bool SubStmtChanged = false;
9685 auto TransformStmts = [&](SmallVectorImpl<Stmt *> &NewStmts,
9686 ArrayRef<Stmt *> OldStmts) {
9687 for (Stmt *OldDS : OldStmts) {
9688 StmtResult NewDS = getDerived().TransformStmt(OldDS);
9689 if (NewDS.isInvalid())
9690 return true;
9691
9692 SubStmtChanged |= NewDS.get() != OldDS;
9693 NewStmts.push_back(NewDS.get());
9694 }
9695
9696 return false;
9697 };
9698
9699 Decl *ESD =
9700 getDerived().TransformDecl(S->getParent()->getLocation(), S->getParent());
9701 if (!ESD || ESD->isInvalidDecl())
9702 return StmtError();
9704
9705 SmallVector<Stmt *> PreambleStmts;
9706 SmallVector<Stmt *> Instantiations;
9707
9708 // Apply lifetime extension to the preamble statements if this was a
9709 // destructuring expansion statement.
9710 {
9712 SemaRef, SemaRef.currentEvaluationContext().Context);
9715 if (TransformStmts(PreambleStmts, S->getPreambleStmts()))
9716 return StmtError();
9717
9718 if (S->shouldApplyLifetimeExtensionToPreamble()) {
9719 auto *VD =
9720 cast<VarDecl>(cast<DeclStmt>(PreambleStmts.front())->getSingleDecl());
9723 }
9724 }
9725
9726 if (TransformStmts(Instantiations, S->getInstantiations()))
9727 return StmtError();
9728
9729 if (!getDerived().AlwaysRebuild() && !SubStmtChanged)
9730 return S;
9731
9733 SemaRef.Context, NewESD, Instantiations, PreambleStmts,
9734 S->shouldApplyLifetimeExtensionToPreamble());
9735}
9736
9737template <typename Derived>
9740 ExprResult Range = getDerived().TransformExpr(E->getRangeExpr());
9741 ExprResult Idx = getDerived().TransformExpr(E->getIndexExpr());
9742 if (Range.isInvalid() || Idx.isInvalid())
9743 return ExprError();
9744
9745 if (!getDerived().AlwaysRebuild() && Range.get() == E->getRangeExpr() &&
9746 Idx.get() == E->getIndexExpr())
9747 return E;
9748
9749 return SemaRef.BuildCXXExpansionSelectExpr(Range.getAs<InitListExpr>(),
9750 Idx.get());
9751}
9752
9753template<typename Derived>
9757 // Transform the nested-name-specifier, if any.
9758 NestedNameSpecifierLoc QualifierLoc;
9759 if (S->getQualifierLoc()) {
9760 QualifierLoc
9761 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9762 if (!QualifierLoc)
9763 return StmtError();
9764 }
9765
9766 // Transform the declaration name.
9767 DeclarationNameInfo NameInfo = S->getNameInfo();
9768 if (NameInfo.getName()) {
9769 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9770 if (!NameInfo.getName())
9771 return StmtError();
9772 }
9773
9774 // Check whether anything changed.
9775 if (!getDerived().AlwaysRebuild() &&
9776 QualifierLoc == S->getQualifierLoc() &&
9777 NameInfo.getName() == S->getNameInfo().getName())
9778 return S;
9779
9780 // Determine whether this name exists, if we can.
9781 CXXScopeSpec SS;
9782 SS.Adopt(QualifierLoc);
9783 bool Dependent = false;
9784 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9786 if (S->isIfExists())
9787 break;
9788
9789 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9790
9792 if (S->isIfNotExists())
9793 break;
9794
9795 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9796
9798 Dependent = true;
9799 break;
9800
9802 return StmtError();
9803 }
9804
9805 // We need to continue with the instantiation, so do so now.
9806 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9807 if (SubStmt.isInvalid())
9808 return StmtError();
9809
9810 // If we have resolved the name, just transform to the substatement.
9811 if (!Dependent)
9812 return SubStmt;
9813
9814 // The name is still dependent, so build a dependent expression again.
9815 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9816 S->isIfExists(),
9817 QualifierLoc,
9818 NameInfo,
9819 SubStmt.get());
9820}
9821
9822template<typename Derived>
9825 NestedNameSpecifierLoc QualifierLoc;
9826 if (E->getQualifierLoc()) {
9827 QualifierLoc
9828 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9829 if (!QualifierLoc)
9830 return ExprError();
9831 }
9832
9833 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9834 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9835 if (!PD)
9836 return ExprError();
9837
9838 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9839 if (Base.isInvalid())
9840 return ExprError();
9841
9842 return new (SemaRef.getASTContext())
9843 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9845 QualifierLoc, E->getMemberLoc());
9846}
9847
9848template <typename Derived>
9851 auto BaseRes = getDerived().TransformExpr(E->getBase());
9852 if (BaseRes.isInvalid())
9853 return ExprError();
9854 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9855 if (IdxRes.isInvalid())
9856 return ExprError();
9857
9858 if (!getDerived().AlwaysRebuild() &&
9859 BaseRes.get() == E->getBase() &&
9860 IdxRes.get() == E->getIdx())
9861 return E;
9862
9863 return getDerived().RebuildArraySubscriptExpr(
9864 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9865}
9866
9867template <typename Derived>
9869 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9870 if (TryBlock.isInvalid())
9871 return StmtError();
9872
9873 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9874 if (Handler.isInvalid())
9875 return StmtError();
9876
9877 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9878 Handler.get() == S->getHandler())
9879 return S;
9880
9881 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9882 TryBlock.get(), Handler.get());
9883}
9884
9885template <typename Derived>
9887 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9888 if (Block.isInvalid())
9889 return StmtError();
9890
9891 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9892}
9893
9894template <typename Derived>
9896 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9897 if (FilterExpr.isInvalid())
9898 return StmtError();
9899
9900 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9901 if (Block.isInvalid())
9902 return StmtError();
9903
9904 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9905 Block.get());
9906}
9907
9908template <typename Derived>
9910 if (isa<SEHFinallyStmt>(Handler))
9911 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9912 else
9913 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9914}
9915
9916template<typename Derived>
9919 return S;
9920}
9921
9922//===----------------------------------------------------------------------===//
9923// OpenMP directive transformation
9924//===----------------------------------------------------------------------===//
9925
9926template <typename Derived>
9927StmtResult
9928TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9929 // OMPCanonicalLoops are eliminated during transformation, since they will be
9930 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9931 // after transformation.
9932 return getDerived().TransformStmt(L->getLoopStmt());
9933}
9934
9935template <typename Derived>
9938
9939 // Transform the clauses
9941 ArrayRef<OMPClause *> Clauses = D->clauses();
9942 TClauses.reserve(Clauses.size());
9943 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9944 I != E; ++I) {
9945 if (*I) {
9946 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9947 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9948 getDerived().getSema().OpenMP().EndOpenMPClause();
9949 if (Clause)
9950 TClauses.push_back(Clause);
9951 } else {
9952 TClauses.push_back(nullptr);
9953 }
9954 }
9955 StmtResult AssociatedStmt;
9956 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9957 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9958 D->getDirectiveKind(),
9959 /*CurScope=*/nullptr);
9960 StmtResult Body;
9961 {
9962 Sema::CompoundScopeRAII CompoundScope(getSema());
9963 Stmt *CS;
9964 if (D->getDirectiveKind() == OMPD_atomic ||
9965 D->getDirectiveKind() == OMPD_critical ||
9966 D->getDirectiveKind() == OMPD_section ||
9967 D->getDirectiveKind() == OMPD_master)
9968 CS = D->getAssociatedStmt();
9969 else
9970 CS = D->getRawStmt();
9971 Body = getDerived().TransformStmt(CS);
9972 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9973 getSema().getLangOpts().OpenMPIRBuilder)
9974 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9975 }
9976 AssociatedStmt =
9977 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9978 if (AssociatedStmt.isInvalid()) {
9979 return StmtError();
9980 }
9981 }
9982 if (TClauses.size() != Clauses.size()) {
9983 return StmtError();
9984 }
9985
9986 // Transform directive name for 'omp critical' directive.
9987 DeclarationNameInfo DirName;
9988 if (D->getDirectiveKind() == OMPD_critical) {
9989 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9990 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9991 }
9992 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9993 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9994 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9995 } else if (D->getDirectiveKind() == OMPD_cancel) {
9996 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9997 }
9998
9999 return getDerived().RebuildOMPExecutableDirective(
10000 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
10001 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
10002}
10003
10004/// This is mostly the same as above, but allows 'informational' class
10005/// directives when rebuilding the stmt. It still takes an
10006/// OMPExecutableDirective-type argument because we're reusing that as the
10007/// superclass for the 'assume' directive at present, instead of defining a
10008/// mostly-identical OMPInformationalDirective parent class.
10009template <typename Derived>
10012
10013 // Transform the clauses
10015 ArrayRef<OMPClause *> Clauses = D->clauses();
10016 TClauses.reserve(Clauses.size());
10017 for (OMPClause *C : Clauses) {
10018 if (C) {
10019 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
10020 OMPClause *Clause = getDerived().TransformOMPClause(C);
10021 getDerived().getSema().OpenMP().EndOpenMPClause();
10022 if (Clause)
10023 TClauses.push_back(Clause);
10024 } else {
10025 TClauses.push_back(nullptr);
10026 }
10027 }
10028 StmtResult AssociatedStmt;
10029 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
10030 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
10031 D->getDirectiveKind(),
10032 /*CurScope=*/nullptr);
10033 StmtResult Body;
10034 {
10035 Sema::CompoundScopeRAII CompoundScope(getSema());
10036 assert(D->getDirectiveKind() == OMPD_assume &&
10037 "Unexpected informational directive");
10038 Stmt *CS = D->getAssociatedStmt();
10039 Body = getDerived().TransformStmt(CS);
10040 }
10041 AssociatedStmt =
10042 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
10043 if (AssociatedStmt.isInvalid())
10044 return StmtError();
10045 }
10046 if (TClauses.size() != Clauses.size())
10047 return StmtError();
10048
10049 DeclarationNameInfo DirName;
10050
10051 return getDerived().RebuildOMPInformationalDirective(
10052 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
10053 D->getBeginLoc(), D->getEndLoc());
10054}
10055
10056template <typename Derived>
10059 // TODO: Fix This
10060 llvm::omp::Version OMPVersion =
10061 getDerived().getSema().getLangOpts().getOpenMPVersion();
10062 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
10063 << getOpenMPDirectiveName(D->getDirectiveKind(), OMPVersion);
10064 return StmtError();
10065}
10066
10067template <typename Derived>
10068StmtResult
10069TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
10070 DeclarationNameInfo DirName;
10071 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10072 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
10073 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10074 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10075 return Res;
10076}
10077
10078template <typename Derived>
10081 DeclarationNameInfo DirName;
10082 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10083 OMPD_simd, DirName, nullptr, D->getBeginLoc());
10084 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10085 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10086 return Res;
10087}
10088
10089template <typename Derived>
10092 DeclarationNameInfo DirName;
10093 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10094 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
10095 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10096 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10097 return Res;
10098}
10099
10100template <typename Derived>
10103 DeclarationNameInfo DirName;
10104 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10105 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
10106 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10107 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10108 return Res;
10109}
10110
10111template <typename Derived>
10114 DeclarationNameInfo DirName;
10115 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10116 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
10117 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10118 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10119 return Res;
10120}
10121
10122template <typename Derived>
10125 DeclarationNameInfo DirName;
10126 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10127 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
10128 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10129 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10130 return Res;
10131}
10132
10133template <typename Derived>
10135 OMPInterchangeDirective *D) {
10136 DeclarationNameInfo DirName;
10137 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10138 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
10139 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10140 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10141 return Res;
10142}
10143
10144template <typename Derived>
10147 DeclarationNameInfo DirName;
10148 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10149 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
10150 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10151 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10152 return Res;
10153}
10154
10155template <typename Derived>
10158 DeclarationNameInfo DirName;
10159 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10160 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
10161 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10162 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10163 return Res;
10164}
10165
10166template <typename Derived>
10169 DeclarationNameInfo DirName;
10170 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10171 OMPD_for, DirName, nullptr, D->getBeginLoc());
10172 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10173 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10174 return Res;
10175}
10176
10177template <typename Derived>
10180 DeclarationNameInfo DirName;
10181 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10182 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
10183 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10184 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10185 return Res;
10186}
10187
10188template <typename Derived>
10191 DeclarationNameInfo DirName;
10192 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10193 OMPD_sections, DirName, nullptr, D->getBeginLoc());
10194 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10195 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10196 return Res;
10197}
10198
10199template <typename Derived>
10202 DeclarationNameInfo DirName;
10203 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10204 OMPD_section, DirName, nullptr, D->getBeginLoc());
10205 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10206 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10207 return Res;
10208}
10209
10210template <typename Derived>
10213 DeclarationNameInfo DirName;
10214 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10215 OMPD_scope, DirName, nullptr, D->getBeginLoc());
10216 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10217 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10218 return Res;
10219}
10220
10221template <typename Derived>
10224 DeclarationNameInfo DirName;
10225 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10226 OMPD_single, DirName, nullptr, D->getBeginLoc());
10227 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10228 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10229 return Res;
10230}
10231
10232template <typename Derived>
10235 DeclarationNameInfo DirName;
10236 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10237 OMPD_master, DirName, nullptr, D->getBeginLoc());
10238 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10239 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10240 return Res;
10241}
10242
10243template <typename Derived>
10246 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10247 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
10248 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10249 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10250 return Res;
10251}
10252
10253template <typename Derived>
10255 OMPParallelForDirective *D) {
10256 DeclarationNameInfo DirName;
10257 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10258 OMPD_parallel_for, DirName, nullptr, D->getBeginLoc());
10259 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10260 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10261 return Res;
10262}
10263
10264template <typename Derived>
10266 OMPParallelForSimdDirective *D) {
10267 DeclarationNameInfo DirName;
10268 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10269 OMPD_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10270 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10271 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10272 return Res;
10273}
10274
10275template <typename Derived>
10277 OMPParallelMasterDirective *D) {
10278 DeclarationNameInfo DirName;
10279 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10280 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
10281 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10282 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10283 return Res;
10284}
10285
10286template <typename Derived>
10288 OMPParallelMaskedDirective *D) {
10289 DeclarationNameInfo DirName;
10290 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10291 OMPD_parallel_masked, DirName, nullptr, D->getBeginLoc());
10292 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10293 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10294 return Res;
10295}
10296
10297template <typename Derived>
10299 OMPParallelSectionsDirective *D) {
10300 DeclarationNameInfo DirName;
10301 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10302 OMPD_parallel_sections, DirName, nullptr, D->getBeginLoc());
10303 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10304 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10305 return Res;
10306}
10307
10308template <typename Derived>
10311 DeclarationNameInfo DirName;
10312 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10313 OMPD_task, DirName, nullptr, D->getBeginLoc());
10314 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10315 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10316 return Res;
10317}
10318
10319template <typename Derived>
10321 OMPTaskyieldDirective *D) {
10322 DeclarationNameInfo DirName;
10323 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10324 OMPD_taskyield, DirName, nullptr, D->getBeginLoc());
10325 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10326 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10327 return Res;
10328}
10329
10330template <typename Derived>
10333 DeclarationNameInfo DirName;
10334 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10335 OMPD_barrier, DirName, nullptr, D->getBeginLoc());
10336 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10337 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10338 return Res;
10339}
10340
10341template <typename Derived>
10344 DeclarationNameInfo DirName;
10345 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10346 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
10347 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10348 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10349 return Res;
10350}
10351
10352template <typename Derived>
10355 DeclarationNameInfo DirName;
10356 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10357 OMPD_assume, DirName, nullptr, D->getBeginLoc());
10358 StmtResult Res = getDerived().TransformOMPInformationalDirective(D);
10359 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10360 return Res;
10361}
10362
10363template <typename Derived>
10366 DeclarationNameInfo DirName;
10367 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10368 OMPD_error, DirName, nullptr, D->getBeginLoc());
10369 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10370 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10371 return Res;
10372}
10373
10374template <typename Derived>
10376 OMPTaskgroupDirective *D) {
10377 DeclarationNameInfo DirName;
10378 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10379 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
10380 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10381 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10382 return Res;
10383}
10384
10385template <typename Derived>
10388 DeclarationNameInfo DirName;
10389 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10390 OMPD_flush, DirName, nullptr, D->getBeginLoc());
10391 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10392 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10393 return Res;
10394}
10395
10396template <typename Derived>
10399 DeclarationNameInfo DirName;
10400 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10401 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
10402 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10403 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10404 return Res;
10405}
10406
10407template <typename Derived>
10410 DeclarationNameInfo DirName;
10411 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10412 OMPD_scan, DirName, nullptr, D->getBeginLoc());
10413 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10414 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10415 return Res;
10416}
10417
10418template <typename Derived>
10420 OMPOrderedStandaloneDirective *D) {
10421 DeclarationNameInfo DirName;
10422 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10423 OMPD_ordered_standalone, DirName, nullptr, D->getBeginLoc());
10424 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10425 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10426 return Res;
10427}
10428
10429template <typename Derived>
10431 OMPOrderedBlockAssocDirective *D) {
10432 DeclarationNameInfo DirName;
10433 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10434 OMPD_ordered_blockassoc, DirName, nullptr, D->getBeginLoc());
10435 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10436 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10437 return Res;
10438}
10439
10440template <typename Derived>
10443 DeclarationNameInfo DirName;
10444 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10445 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
10446 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10447 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10448 return Res;
10449}
10450
10451template <typename Derived>
10454 DeclarationNameInfo DirName;
10455 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10456 OMPD_target, DirName, nullptr, D->getBeginLoc());
10457 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10458 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10459 return Res;
10460}
10461
10462template <typename Derived>
10464 OMPTargetDataDirective *D) {
10465 DeclarationNameInfo DirName;
10466 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10467 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
10468 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10469 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10470 return Res;
10471}
10472
10473template <typename Derived>
10475 OMPTargetEnterDataDirective *D) {
10476 DeclarationNameInfo DirName;
10477 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10478 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
10479 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10480 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10481 return Res;
10482}
10483
10484template <typename Derived>
10486 OMPTargetExitDataDirective *D) {
10487 DeclarationNameInfo DirName;
10488 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10489 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
10490 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10491 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10492 return Res;
10493}
10494
10495template <typename Derived>
10497 OMPTargetParallelDirective *D) {
10498 DeclarationNameInfo DirName;
10499 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10500 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
10501 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10502 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10503 return Res;
10504}
10505
10506template <typename Derived>
10508 OMPTargetParallelForDirective *D) {
10509 DeclarationNameInfo DirName;
10510 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10511 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
10512 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10513 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10514 return Res;
10515}
10516
10517template <typename Derived>
10519 OMPTargetUpdateDirective *D) {
10520 DeclarationNameInfo DirName;
10521 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10522 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
10523 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10524 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10525 return Res;
10526}
10527
10528template <typename Derived>
10531 DeclarationNameInfo DirName;
10532 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10533 OMPD_teams, DirName, nullptr, D->getBeginLoc());
10534 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10535 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10536 return Res;
10537}
10538
10539template <typename Derived>
10541 OMPCancellationPointDirective *D) {
10542 DeclarationNameInfo DirName;
10543 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10544 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
10545 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10546 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10547 return Res;
10548}
10549
10550template <typename Derived>
10553 DeclarationNameInfo DirName;
10554 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10555 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
10556 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10557 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10558 return Res;
10559}
10560
10561template <typename Derived>
10564 DeclarationNameInfo DirName;
10565 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10566 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
10567 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10568 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10569 return Res;
10570}
10571
10572template <typename Derived>
10574 OMPTaskLoopSimdDirective *D) {
10575 DeclarationNameInfo DirName;
10576 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10577 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10578 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10579 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10580 return Res;
10581}
10582
10583template <typename Derived>
10585 OMPMasterTaskLoopDirective *D) {
10586 DeclarationNameInfo DirName;
10587 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10588 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
10589 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10590 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10591 return Res;
10592}
10593
10594template <typename Derived>
10596 OMPMaskedTaskLoopDirective *D) {
10597 DeclarationNameInfo DirName;
10598 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10599 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10600 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10601 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10602 return Res;
10603}
10604
10605template <typename Derived>
10607 OMPMasterTaskLoopSimdDirective *D) {
10608 DeclarationNameInfo DirName;
10609 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10610 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10611 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10612 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10613 return Res;
10614}
10615
10616template <typename Derived>
10618 OMPMaskedTaskLoopSimdDirective *D) {
10619 DeclarationNameInfo DirName;
10620 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10621 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10622 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10623 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10624 return Res;
10625}
10626
10627template <typename Derived>
10629 OMPParallelMasterTaskLoopDirective *D) {
10630 DeclarationNameInfo DirName;
10631 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10632 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10633 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10634 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10635 return Res;
10636}
10637
10638template <typename Derived>
10640 OMPParallelMaskedTaskLoopDirective *D) {
10641 DeclarationNameInfo DirName;
10642 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10643 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10644 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10645 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10646 return Res;
10647}
10648
10649template <typename Derived>
10652 OMPParallelMasterTaskLoopSimdDirective *D) {
10653 DeclarationNameInfo DirName;
10654 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10655 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10656 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10657 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10658 return Res;
10659}
10660
10661template <typename Derived>
10664 OMPParallelMaskedTaskLoopSimdDirective *D) {
10665 DeclarationNameInfo DirName;
10666 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10667 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10668 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10669 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10670 return Res;
10671}
10672
10673template <typename Derived>
10675 OMPDistributeDirective *D) {
10676 DeclarationNameInfo DirName;
10677 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10678 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10679 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10680 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10681 return Res;
10682}
10683
10684template <typename Derived>
10686 OMPDistributeParallelForDirective *D) {
10687 DeclarationNameInfo DirName;
10688 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10689 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10690 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10691 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10692 return Res;
10693}
10694
10695template <typename Derived>
10698 OMPDistributeParallelForSimdDirective *D) {
10699 DeclarationNameInfo DirName;
10700 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10701 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10702 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10703 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10704 return Res;
10705}
10706
10707template <typename Derived>
10709 OMPDistributeSimdDirective *D) {
10710 DeclarationNameInfo DirName;
10711 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10712 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
10713 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10714 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10715 return Res;
10716}
10717
10718template <typename Derived>
10720 OMPTargetParallelForSimdDirective *D) {
10721 DeclarationNameInfo DirName;
10722 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10723 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10724 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10725 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10726 return Res;
10727}
10728
10729template <typename Derived>
10731 OMPTargetSimdDirective *D) {
10732 DeclarationNameInfo DirName;
10733 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10734 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
10735 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10736 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10737 return Res;
10738}
10739
10740template <typename Derived>
10742 OMPTeamsDistributeDirective *D) {
10743 DeclarationNameInfo DirName;
10744 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10745 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10746 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10747 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10748 return Res;
10749}
10750
10751template <typename Derived>
10753 OMPTeamsDistributeSimdDirective *D) {
10754 DeclarationNameInfo DirName;
10755 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10756 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10757 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10758 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10759 return Res;
10760}
10761
10762template <typename Derived>
10764 OMPTeamsDistributeParallelForSimdDirective *D) {
10765 DeclarationNameInfo DirName;
10766 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10767 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10768 D->getBeginLoc());
10769 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10770 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10771 return Res;
10772}
10773
10774template <typename Derived>
10776 OMPTeamsDistributeParallelForDirective *D) {
10777 DeclarationNameInfo DirName;
10778 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10779 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10780 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10781 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10782 return Res;
10783}
10784
10785template <typename Derived>
10787 OMPTargetTeamsDirective *D) {
10788 DeclarationNameInfo DirName;
10789 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10790 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10791 auto Res = getDerived().TransformOMPExecutableDirective(D);
10792 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10793 return Res;
10794}
10795
10796template <typename Derived>
10798 OMPTargetTeamsDistributeDirective *D) {
10799 DeclarationNameInfo DirName;
10800 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10801 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10802 auto Res = getDerived().TransformOMPExecutableDirective(D);
10803 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10804 return Res;
10805}
10806
10807template <typename Derived>
10810 OMPTargetTeamsDistributeParallelForDirective *D) {
10811 DeclarationNameInfo DirName;
10812 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10813 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10814 D->getBeginLoc());
10815 auto Res = getDerived().TransformOMPExecutableDirective(D);
10816 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10817 return Res;
10818}
10819
10820template <typename Derived>
10823 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10824 DeclarationNameInfo DirName;
10825 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10826 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10827 D->getBeginLoc());
10828 auto Res = getDerived().TransformOMPExecutableDirective(D);
10829 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10830 return Res;
10831}
10832
10833template <typename Derived>
10836 OMPTargetTeamsDistributeSimdDirective *D) {
10837 DeclarationNameInfo DirName;
10838 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10839 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10840 auto Res = getDerived().TransformOMPExecutableDirective(D);
10841 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10842 return Res;
10843}
10844
10845template <typename Derived>
10848 DeclarationNameInfo DirName;
10849 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10850 OMPD_interop, DirName, nullptr, D->getBeginLoc());
10851 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10852 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10853 return Res;
10854}
10855
10856template <typename Derived>
10859 DeclarationNameInfo DirName;
10860 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10861 OMPD_dispatch, DirName, nullptr, D->getBeginLoc());
10862 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10863 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10864 return Res;
10865}
10866
10867template <typename Derived>
10870 DeclarationNameInfo DirName;
10871 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10872 OMPD_masked, DirName, nullptr, D->getBeginLoc());
10873 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10874 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10875 return Res;
10876}
10877
10878template <typename Derived>
10880 OMPGenericLoopDirective *D) {
10881 DeclarationNameInfo DirName;
10882 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10883 OMPD_loop, DirName, nullptr, D->getBeginLoc());
10884 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10885 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10886 return Res;
10887}
10888
10889template <typename Derived>
10891 OMPTeamsGenericLoopDirective *D) {
10892 DeclarationNameInfo DirName;
10893 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10894 OMPD_teams_loop, DirName, nullptr, D->getBeginLoc());
10895 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10896 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10897 return Res;
10898}
10899
10900template <typename Derived>
10902 OMPTargetTeamsGenericLoopDirective *D) {
10903 DeclarationNameInfo DirName;
10904 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10905 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
10906 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10907 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10908 return Res;
10909}
10910
10911template <typename Derived>
10913 OMPParallelGenericLoopDirective *D) {
10914 DeclarationNameInfo DirName;
10915 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10916 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
10917 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10918 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10919 return Res;
10920}
10921
10922template <typename Derived>
10925 OMPTargetParallelGenericLoopDirective *D) {
10926 DeclarationNameInfo DirName;
10927 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10928 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10929 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10930 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10931 return Res;
10932}
10933
10934//===----------------------------------------------------------------------===//
10935// OpenMP clause transformation
10936//===----------------------------------------------------------------------===//
10937template <typename Derived>
10939 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10940 if (Cond.isInvalid())
10941 return nullptr;
10942 return getDerived().RebuildOMPIfClause(
10943 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10944 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10945}
10946
10947template <typename Derived>
10949 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10950 if (Cond.isInvalid())
10951 return nullptr;
10952 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10953 C->getLParenLoc(), C->getEndLoc());
10954}
10955
10956template <typename Derived>
10957OMPClause *
10960 Vars.reserve(C->varlist_size());
10961 for (auto *VE : C->varlist()) {
10962 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10963 if (EVar.isInvalid())
10964 return nullptr;
10965 Vars.push_back(EVar.get());
10966 }
10967 Expr *DimsModifierExpr = C->getDimsModifierExpr();
10968 if (DimsModifierExpr) {
10969 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(DimsModifierExpr));
10970 if (EVar.isInvalid())
10971 return nullptr;
10972 DimsModifierExpr = EVar.get();
10973 }
10974 return getDerived().RebuildOMPNumThreadsClause(
10975 Vars, C->getPrescriptivenessModifier(),
10976 C->getPrescriptivenessModifierLoc(), C->getDimsModifier(),
10977 DimsModifierExpr, C->getDimsModifierLoc(), C->getBeginLoc(),
10978 C->getLParenLoc(), C->getEndLoc());
10979}
10980
10981template <typename Derived>
10982OMPClause *
10984 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10985 if (E.isInvalid())
10986 return nullptr;
10987 return getDerived().RebuildOMPSafelenClause(
10988 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10989}
10990
10991template <typename Derived>
10992OMPClause *
10994 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10995 if (E.isInvalid())
10996 return nullptr;
10997 return getDerived().RebuildOMPAllocatorClause(
10998 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10999}
11000
11001template <typename Derived>
11002OMPClause *
11004 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
11005 if (E.isInvalid())
11006 return nullptr;
11007 return getDerived().RebuildOMPSimdlenClause(
11008 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11009}
11010
11011template <typename Derived>
11013 SmallVector<Expr *, 4> TransformedSizes;
11014 TransformedSizes.reserve(C->getNumSizes());
11015 bool Changed = false;
11016 for (Expr *E : C->getSizesRefs()) {
11017 if (!E) {
11018 TransformedSizes.push_back(nullptr);
11019 continue;
11020 }
11021
11022 ExprResult T = getDerived().TransformExpr(E);
11023 if (T.isInvalid())
11024 return nullptr;
11025 if (E != T.get())
11026 Changed = true;
11027 TransformedSizes.push_back(T.get());
11028 }
11029
11030 if (!Changed && !getDerived().AlwaysRebuild())
11031 return C;
11032 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
11033 C->getLParenLoc(), C->getEndLoc());
11034}
11035
11036template <typename Derived>
11037OMPClause *
11039 SmallVector<Expr *, 4> TransformedCounts;
11040 TransformedCounts.reserve(C->getNumCounts());
11041 for (Expr *E : C->getCountsRefs()) {
11042 if (!E) {
11043 TransformedCounts.push_back(nullptr);
11044 continue;
11045 }
11046
11047 ExprResult T = getDerived().TransformExpr(E);
11048 if (T.isInvalid())
11049 return nullptr;
11050 TransformedCounts.push_back(T.get());
11051 }
11052
11053 return RebuildOMPCountsClause(TransformedCounts, C->getBeginLoc(),
11054 C->getLParenLoc(), C->getEndLoc(),
11055 C->getOmpFillIndex(), C->getOmpFillLoc());
11056}
11057
11058template <typename Derived>
11059OMPClause *
11061 SmallVector<Expr *> TransformedArgs;
11062 TransformedArgs.reserve(C->getNumLoops());
11063 bool Changed = false;
11064 for (Expr *E : C->getArgsRefs()) {
11065 if (!E) {
11066 TransformedArgs.push_back(nullptr);
11067 continue;
11068 }
11069
11070 ExprResult T = getDerived().TransformExpr(E);
11071 if (T.isInvalid())
11072 return nullptr;
11073 if (E != T.get())
11074 Changed = true;
11075 TransformedArgs.push_back(T.get());
11076 }
11077
11078 if (!Changed && !getDerived().AlwaysRebuild())
11079 return C;
11080 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
11081 C->getLParenLoc(), C->getEndLoc());
11082}
11083
11084template <typename Derived>
11086 if (!getDerived().AlwaysRebuild())
11087 return C;
11088 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
11089}
11090
11091template <typename Derived>
11092OMPClause *
11094 ExprResult T = getDerived().TransformExpr(C->getFactor());
11095 if (T.isInvalid())
11096 return nullptr;
11097 Expr *Factor = T.get();
11098 bool Changed = Factor != C->getFactor();
11099
11100 if (!Changed && !getDerived().AlwaysRebuild())
11101 return C;
11102 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
11103 C->getEndLoc());
11104}
11105
11106template <typename Derived>
11107OMPClause *
11109 ExprResult F = getDerived().TransformExpr(C->getFirst());
11110 if (F.isInvalid())
11111 return nullptr;
11112
11113 ExprResult Cn = getDerived().TransformExpr(C->getCount());
11114 if (Cn.isInvalid())
11115 return nullptr;
11116
11117 Expr *First = F.get();
11118 Expr *Count = Cn.get();
11119
11120 bool Changed = (First != C->getFirst()) || (Count != C->getCount());
11121
11122 // If no changes and AlwaysRebuild() is false, return the original clause
11123 if (!Changed && !getDerived().AlwaysRebuild())
11124 return C;
11125
11126 return RebuildOMPLoopRangeClause(First, Count, C->getBeginLoc(),
11127 C->getLParenLoc(), C->getFirstLoc(),
11128 C->getCountLoc(), C->getEndLoc());
11129}
11130
11131template <typename Derived>
11132OMPClause *
11134 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
11135 if (E.isInvalid())
11136 return nullptr;
11137 return getDerived().RebuildOMPCollapseClause(
11138 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11139}
11140
11141template <typename Derived>
11142OMPClause *
11144 return getDerived().RebuildOMPDefaultClause(
11145 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getDefaultVC(),
11146 C->getDefaultVCLoc(), C->getBeginLoc(), C->getLParenLoc(),
11147 C->getEndLoc());
11148}
11149
11150template <typename Derived>
11151OMPClause *
11153 // No need to rebuild this clause, no template-dependent parameters.
11154 return C;
11155}
11156
11157template <typename Derived>
11158OMPClause *
11160 Expr *Impex = C->getImpexType();
11161 ExprResult TransformedImpex = getDerived().TransformExpr(Impex);
11162
11163 if (TransformedImpex.isInvalid())
11164 return nullptr;
11165
11166 return getDerived().RebuildOMPTransparentClause(
11167 TransformedImpex.get(), C->getBeginLoc(), C->getLParenLoc(),
11168 C->getEndLoc());
11169}
11170
11171template <typename Derived>
11172OMPClause *
11174 return getDerived().RebuildOMPProcBindClause(
11175 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
11176 C->getLParenLoc(), C->getEndLoc());
11177}
11178
11179template <typename Derived>
11180OMPClause *
11182 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11183 if (E.isInvalid())
11184 return nullptr;
11185 return getDerived().RebuildOMPScheduleClause(
11186 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
11187 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11188 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
11189 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11190}
11191
11192template <typename Derived>
11193OMPClause *
11195 ExprResult E;
11196 if (auto *Num = C->getNumForLoops()) {
11197 E = getDerived().TransformExpr(Num);
11198 if (E.isInvalid())
11199 return nullptr;
11200 }
11201 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
11202 C->getLParenLoc(), E.get());
11203}
11204
11205template <typename Derived>
11206OMPClause *
11208 ExprResult E;
11209 if (Expr *Evt = C->getEventHandler()) {
11210 E = getDerived().TransformExpr(Evt);
11211 if (E.isInvalid())
11212 return nullptr;
11213 }
11214 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
11215 C->getLParenLoc(), C->getEndLoc());
11216}
11217
11218template <typename Derived>
11219OMPClause *
11221 ExprResult Cond;
11222 if (auto *Condition = C->getCondition()) {
11223 Cond = getDerived().TransformExpr(Condition);
11224 if (Cond.isInvalid())
11225 return nullptr;
11226 }
11227 return getDerived().RebuildOMPNowaitClause(Cond.get(), C->getBeginLoc(),
11228 C->getLParenLoc(), C->getEndLoc());
11229}
11230
11231template <typename Derived>
11232OMPClause *
11234 // No need to rebuild this clause, no template-dependent parameters.
11235 return C;
11236}
11237
11238template <typename Derived>
11239OMPClause *
11241 // No need to rebuild this clause, no template-dependent parameters.
11242 return C;
11243}
11244
11245template <typename Derived>
11247 // No need to rebuild this clause, no template-dependent parameters.
11248 return C;
11249}
11250
11251template <typename Derived>
11253 // No need to rebuild this clause, no template-dependent parameters.
11254 return C;
11255}
11256
11257template <typename Derived>
11258OMPClause *
11260 // No need to rebuild this clause, no template-dependent parameters.
11261 return C;
11262}
11263
11264template <typename Derived>
11266 OMPUpdateDependObjectsClause *C) {
11267 // No need to rebuild this clause, no template-dependent parameters.
11268 return C;
11269}
11270
11271template <typename Derived>
11272OMPClause *
11274 // No need to rebuild this clause, no template-dependent parameters.
11275 return C;
11276}
11277
11278template <typename Derived>
11279OMPClause *
11281 // No need to rebuild this clause, no template-dependent parameters.
11282 return C;
11283}
11284
11285template <typename Derived>
11287 // No need to rebuild this clause, no template-dependent parameters.
11288 return C;
11289}
11290
11291template <typename Derived>
11292OMPClause *
11294 return C;
11295}
11296
11297template <typename Derived>
11299 ExprResult E = getDerived().TransformExpr(C->getExpr());
11300 if (E.isInvalid())
11301 return nullptr;
11302 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
11303 C->getLParenLoc(), C->getEndLoc());
11304}
11305
11306template <typename Derived>
11307OMPClause *
11309 return C;
11310}
11311
11312template <typename Derived>
11313OMPClause *
11315 return C;
11316}
11317template <typename Derived>
11319 OMPNoOpenMPRoutinesClause *C) {
11320 return C;
11321}
11322template <typename Derived>
11324 OMPNoOpenMPConstructsClause *C) {
11325 return C;
11326}
11327template <typename Derived>
11329 OMPNoParallelismClause *C) {
11330 return C;
11331}
11332
11333template <typename Derived>
11334OMPClause *
11336 // No need to rebuild this clause, no template-dependent parameters.
11337 return C;
11338}
11339
11340template <typename Derived>
11341OMPClause *
11343 // No need to rebuild this clause, no template-dependent parameters.
11344 return C;
11345}
11346
11347template <typename Derived>
11348OMPClause *
11350 // No need to rebuild this clause, no template-dependent parameters.
11351 return C;
11352}
11353
11354template <typename Derived>
11355OMPClause *
11357 // No need to rebuild this clause, no template-dependent parameters.
11358 return C;
11359}
11360
11361template <typename Derived>
11362OMPClause *
11364 // No need to rebuild this clause, no template-dependent parameters.
11365 return C;
11366}
11367
11368template <typename Derived>
11370 // No need to rebuild this clause, no template-dependent parameters.
11371 return C;
11372}
11373
11374template <typename Derived>
11375OMPClause *
11377 // No need to rebuild this clause, no template-dependent parameters.
11378 return C;
11379}
11380
11381template <typename Derived>
11383 // No need to rebuild this clause, no template-dependent parameters.
11384 return C;
11385}
11386
11387template <typename Derived>
11388OMPClause *
11390 // No need to rebuild this clause, no template-dependent parameters.
11391 return C;
11392}
11393
11394template <typename Derived>
11396 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
11397 if (IVR.isInvalid())
11398 return nullptr;
11399
11400 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
11401 for (OMPInitClause::PrefView P : C->prefs()) {
11402 Expr *NewFr = nullptr;
11403 if (P.Fr) {
11404 ExprResult ER = getDerived().TransformExpr(P.Fr);
11405 if (ER.isInvalid())
11406 return nullptr;
11407 NewFr = ER.get();
11408 }
11409 SmallVector<Expr *, 2> NewAttrs;
11410 NewAttrs.reserve(P.Attrs.size());
11411 for (Expr *A : P.Attrs) {
11412 ExprResult ER = getDerived().TransformExpr(A);
11413 if (ER.isInvalid())
11414 return nullptr;
11415 NewAttrs.push_back(ER.get());
11416 }
11417 InteropInfo.Prefs.emplace_back(NewFr, std::move(NewAttrs));
11418 }
11419 InteropInfo.HasPreferAttrs = C->hasPreferAttrs();
11420 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
11421 C->getBeginLoc(), C->getLParenLoc(),
11422 C->getVarLoc(), C->getEndLoc());
11423}
11424
11425template <typename Derived>
11427 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
11428 if (ER.isInvalid())
11429 return nullptr;
11430 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
11431 C->getLParenLoc(), C->getVarLoc(),
11432 C->getEndLoc());
11433}
11434
11435template <typename Derived>
11436OMPClause *
11438 ExprResult ER;
11439 if (Expr *IV = C->getInteropVar()) {
11440 ER = getDerived().TransformExpr(IV);
11441 if (ER.isInvalid())
11442 return nullptr;
11443 }
11444 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
11445 C->getLParenLoc(), C->getVarLoc(),
11446 C->getEndLoc());
11447}
11448
11449template <typename Derived>
11450OMPClause *
11452 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11453 if (Cond.isInvalid())
11454 return nullptr;
11455 return getDerived().RebuildOMPNovariantsClause(
11456 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11457}
11458
11459template <typename Derived>
11460OMPClause *
11462 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11463 if (Cond.isInvalid())
11464 return nullptr;
11465 return getDerived().RebuildOMPNocontextClause(
11466 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11467}
11468
11469template <typename Derived>
11470OMPClause *
11472 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
11473 if (ThreadID.isInvalid())
11474 return nullptr;
11475 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
11476 C->getLParenLoc(), C->getEndLoc());
11477}
11478
11479template <typename Derived>
11481 ExprResult E = getDerived().TransformExpr(C->getAlignment());
11482 if (E.isInvalid())
11483 return nullptr;
11484 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
11485 C->getLParenLoc(), C->getEndLoc());
11486}
11487
11488template <typename Derived>
11490 OMPUnifiedAddressClause *C) {
11491 llvm_unreachable("unified_address clause cannot appear in dependent context");
11492}
11493
11494template <typename Derived>
11496 OMPUnifiedSharedMemoryClause *C) {
11497 llvm_unreachable(
11498 "unified_shared_memory clause cannot appear in dependent context");
11499}
11500
11501template <typename Derived>
11503 OMPReverseOffloadClause *C) {
11504 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
11505}
11506
11507template <typename Derived>
11509 OMPDynamicAllocatorsClause *C) {
11510 llvm_unreachable(
11511 "dynamic_allocators clause cannot appear in dependent context");
11512}
11513
11514template <typename Derived>
11516 OMPAtomicDefaultMemOrderClause *C) {
11517 llvm_unreachable(
11518 "atomic_default_mem_order clause cannot appear in dependent context");
11519}
11520
11521template <typename Derived>
11522OMPClause *
11524 llvm_unreachable("self_maps clause cannot appear in dependent context");
11525}
11526
11527template <typename Derived>
11529 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
11530 C->getBeginLoc(), C->getLParenLoc(),
11531 C->getEndLoc());
11532}
11533
11534template <typename Derived>
11535OMPClause *
11537 return getDerived().RebuildOMPSeverityClause(
11538 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
11539 C->getLParenLoc(), C->getEndLoc());
11540}
11541
11542template <typename Derived>
11543OMPClause *
11545 ExprResult E = getDerived().TransformExpr(C->getMessageString());
11546 if (E.isInvalid())
11547 return nullptr;
11548 return getDerived().RebuildOMPMessageClause(
11549 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11550}
11551
11552template <typename Derived>
11553OMPClause *
11556 Vars.reserve(C->varlist_size());
11557 for (auto *VE : C->varlist()) {
11558 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11559 if (EVar.isInvalid())
11560 return nullptr;
11561 Vars.push_back(EVar.get());
11562 }
11563 return getDerived().RebuildOMPPrivateClause(
11564 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11565}
11566
11567template <typename Derived>
11569 OMPFirstprivateClause *C) {
11571 Vars.reserve(C->varlist_size());
11572 for (auto *VE : C->varlist()) {
11573 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11574 if (EVar.isInvalid())
11575 return nullptr;
11576 Vars.push_back(EVar.get());
11577 }
11578 return getDerived().RebuildOMPFirstprivateClause(
11579 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11580}
11581
11582template <typename Derived>
11583OMPClause *
11586 Vars.reserve(C->varlist_size());
11587 for (auto *VE : C->varlist()) {
11588 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11589 if (EVar.isInvalid())
11590 return nullptr;
11591 Vars.push_back(EVar.get());
11592 }
11593 return getDerived().RebuildOMPLastprivateClause(
11594 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11595 C->getLParenLoc(), C->getEndLoc());
11596}
11597
11598template <typename Derived>
11599OMPClause *
11602 Vars.reserve(C->varlist_size());
11603 for (auto *VE : C->varlist()) {
11604 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11605 if (EVar.isInvalid())
11606 return nullptr;
11607 Vars.push_back(EVar.get());
11608 }
11609 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11610 C->getLParenLoc(), C->getEndLoc());
11611}
11612
11613template <typename Derived>
11614OMPClause *
11617 Vars.reserve(C->varlist_size());
11618 for (auto *VE : C->varlist()) {
11619 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11620 if (EVar.isInvalid())
11621 return nullptr;
11622 Vars.push_back(EVar.get());
11623 }
11624 CXXScopeSpec ReductionIdScopeSpec;
11625 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11626
11627 DeclarationNameInfo NameInfo = C->getNameInfo();
11628 if (NameInfo.getName()) {
11629 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11630 if (!NameInfo.getName())
11631 return nullptr;
11632 }
11633 // Build a list of all UDR decls with the same names ranged by the Scopes.
11634 // The Scope boundary is a duplication of the previous decl.
11635 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11636 for (auto *E : C->reduction_ops()) {
11637 // Transform all the decls.
11638 if (E) {
11639 auto *ULE = cast<UnresolvedLookupExpr>(E);
11640 UnresolvedSet<8> Decls;
11641 for (auto *D : ULE->decls()) {
11642 NamedDecl *InstD =
11643 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11644 Decls.addDecl(InstD, InstD->getAccess());
11645 }
11646 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11647 SemaRef.Context, /*NamingClass=*/nullptr,
11648 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11649 /*ADL=*/true, Decls.begin(), Decls.end(),
11650 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11651 } else
11652 UnresolvedReductions.push_back(nullptr);
11653 }
11654 return getDerived().RebuildOMPReductionClause(
11655 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11656 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11657 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11658}
11659
11660template <typename Derived>
11662 OMPTaskReductionClause *C) {
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 CXXScopeSpec ReductionIdScopeSpec;
11672 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11673
11674 DeclarationNameInfo NameInfo = C->getNameInfo();
11675 if (NameInfo.getName()) {
11676 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11677 if (!NameInfo.getName())
11678 return nullptr;
11679 }
11680 // Build a list of all UDR decls with the same names ranged by the Scopes.
11681 // The Scope boundary is a duplication of the previous decl.
11682 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11683 for (auto *E : C->reduction_ops()) {
11684 // Transform all the decls.
11685 if (E) {
11686 auto *ULE = cast<UnresolvedLookupExpr>(E);
11687 UnresolvedSet<8> Decls;
11688 for (auto *D : ULE->decls()) {
11689 NamedDecl *InstD =
11690 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11691 Decls.addDecl(InstD, InstD->getAccess());
11692 }
11693 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11694 SemaRef.Context, /*NamingClass=*/nullptr,
11695 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11696 /*ADL=*/true, Decls.begin(), Decls.end(),
11697 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11698 } else
11699 UnresolvedReductions.push_back(nullptr);
11700 }
11701 return getDerived().RebuildOMPTaskReductionClause(
11702 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11703 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11704}
11705
11706template <typename Derived>
11707OMPClause *
11710 Vars.reserve(C->varlist_size());
11711 for (auto *VE : C->varlist()) {
11712 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11713 if (EVar.isInvalid())
11714 return nullptr;
11715 Vars.push_back(EVar.get());
11716 }
11717 CXXScopeSpec ReductionIdScopeSpec;
11718 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11719
11720 DeclarationNameInfo NameInfo = C->getNameInfo();
11721 if (NameInfo.getName()) {
11722 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11723 if (!NameInfo.getName())
11724 return nullptr;
11725 }
11726 // Build a list of all UDR decls with the same names ranged by the Scopes.
11727 // The Scope boundary is a duplication of the previous decl.
11728 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11729 for (auto *E : C->reduction_ops()) {
11730 // Transform all the decls.
11731 if (E) {
11732 auto *ULE = cast<UnresolvedLookupExpr>(E);
11733 UnresolvedSet<8> Decls;
11734 for (auto *D : ULE->decls()) {
11735 NamedDecl *InstD =
11736 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11737 Decls.addDecl(InstD, InstD->getAccess());
11738 }
11739 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11740 SemaRef.Context, /*NamingClass=*/nullptr,
11741 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11742 /*ADL=*/true, Decls.begin(), Decls.end(),
11743 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11744 } else
11745 UnresolvedReductions.push_back(nullptr);
11746 }
11747 return getDerived().RebuildOMPInReductionClause(
11748 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11749 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11750}
11751
11752template <typename Derived>
11753OMPClause *
11756 Vars.reserve(C->varlist_size());
11757 for (auto *VE : C->varlist()) {
11758 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11759 if (EVar.isInvalid())
11760 return nullptr;
11761 Vars.push_back(EVar.get());
11762 }
11763 ExprResult Step = getDerived().TransformExpr(C->getStep());
11764 if (Step.isInvalid())
11765 return nullptr;
11766 return getDerived().RebuildOMPLinearClause(
11767 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11768 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11769 C->getEndLoc());
11770}
11771
11772template <typename Derived>
11773OMPClause *
11776 Vars.reserve(C->varlist_size());
11777 for (auto *VE : C->varlist()) {
11778 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11779 if (EVar.isInvalid())
11780 return nullptr;
11781 Vars.push_back(EVar.get());
11782 }
11783 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11784 if (Alignment.isInvalid())
11785 return nullptr;
11786 return getDerived().RebuildOMPAlignedClause(
11787 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11788 C->getColonLoc(), C->getEndLoc());
11789}
11790
11791template <typename Derived>
11792OMPClause *
11795 Vars.reserve(C->varlist_size());
11796 for (auto *VE : C->varlist()) {
11797 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11798 if (EVar.isInvalid())
11799 return nullptr;
11800 Vars.push_back(EVar.get());
11801 }
11802 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11803 C->getLParenLoc(), C->getEndLoc());
11804}
11805
11806template <typename Derived>
11807OMPClause *
11810 Vars.reserve(C->varlist_size());
11811 for (auto *VE : C->varlist()) {
11812 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11813 if (EVar.isInvalid())
11814 return nullptr;
11815 Vars.push_back(EVar.get());
11816 }
11817 return getDerived().RebuildOMPCopyprivateClause(
11818 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11819}
11820
11821template <typename Derived>
11824 Vars.reserve(C->varlist_size());
11825 for (auto *VE : C->varlist()) {
11826 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11827 if (EVar.isInvalid())
11828 return nullptr;
11829 Vars.push_back(EVar.get());
11830 }
11831 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11832 C->getLParenLoc(), C->getEndLoc());
11833}
11834
11835template <typename Derived>
11836OMPClause *
11838 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11839 if (E.isInvalid())
11840 return nullptr;
11841 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11842 C->getLParenLoc(), C->getEndLoc());
11843}
11844
11845template <typename Derived>
11846OMPClause *
11849 Expr *DepModifier = C->getModifier();
11850 if (DepModifier) {
11851 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11852 if (DepModRes.isInvalid())
11853 return nullptr;
11854 DepModifier = DepModRes.get();
11855 }
11856 Vars.reserve(C->varlist_size());
11857 for (auto *VE : C->varlist()) {
11858 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11859 if (EVar.isInvalid())
11860 return nullptr;
11861 Vars.push_back(EVar.get());
11862 }
11863 return getDerived().RebuildOMPDependClause(
11864 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11865 C->getOmpAllMemoryLoc()},
11866 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11867}
11868
11869template <typename Derived>
11870OMPClause *
11872 ExprResult E = getDerived().TransformExpr(C->getDevice());
11873 if (E.isInvalid())
11874 return nullptr;
11875 return getDerived().RebuildOMPDeviceClause(
11876 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11877 C->getModifierLoc(), C->getEndLoc());
11878}
11879
11880template <typename Derived, class T>
11883 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11884 DeclarationNameInfo &MapperIdInfo,
11885 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11886 // Transform expressions in the list.
11887 Vars.reserve(C->varlist_size());
11888 for (auto *VE : C->varlist()) {
11889 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11890 if (EVar.isInvalid())
11891 return true;
11892 Vars.push_back(EVar.get());
11893 }
11894 // Transform mapper scope specifier and identifier.
11895 NestedNameSpecifierLoc QualifierLoc;
11896 if (C->getMapperQualifierLoc()) {
11897 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11898 C->getMapperQualifierLoc());
11899 if (!QualifierLoc)
11900 return true;
11901 }
11902 MapperIdScopeSpec.Adopt(QualifierLoc);
11903 MapperIdInfo = C->getMapperIdInfo();
11904 if (MapperIdInfo.getName()) {
11905 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11906 if (!MapperIdInfo.getName())
11907 return true;
11908 }
11909 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11910 // the previous user-defined mapper lookup in dependent environment.
11911 for (auto *E : C->mapperlists()) {
11912 // Transform all the decls.
11913 if (E) {
11914 auto *ULE = cast<UnresolvedLookupExpr>(E);
11915 UnresolvedSet<8> Decls;
11916 for (auto *D : ULE->decls()) {
11917 NamedDecl *InstD =
11918 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11919 Decls.addDecl(InstD, InstD->getAccess());
11920 }
11921 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11922 TT.getSema().Context, /*NamingClass=*/nullptr,
11923 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11924 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11925 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11926 } else {
11927 UnresolvedMappers.push_back(nullptr);
11928 }
11929 }
11930 return false;
11931}
11932
11933template <typename Derived>
11934OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11935 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11937 Expr *IteratorModifier = C->getIteratorModifier();
11938 if (IteratorModifier) {
11939 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11940 if (MapModRes.isInvalid())
11941 return nullptr;
11942 IteratorModifier = MapModRes.get();
11943 }
11944 CXXScopeSpec MapperIdScopeSpec;
11945 DeclarationNameInfo MapperIdInfo;
11946 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11948 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11949 return nullptr;
11950 return getDerived().RebuildOMPMapClause(
11951 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11952 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11953 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11954}
11955
11956template <typename Derived>
11957OMPClause *
11959 Expr *Allocator = C->getAllocator();
11960 if (Allocator) {
11961 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11962 if (AllocatorRes.isInvalid())
11963 return nullptr;
11964 Allocator = AllocatorRes.get();
11965 }
11966 Expr *Alignment = C->getAlignment();
11967 if (Alignment) {
11968 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11969 if (AlignmentRes.isInvalid())
11970 return nullptr;
11971 Alignment = AlignmentRes.get();
11972 }
11974 Vars.reserve(C->varlist_size());
11975 for (auto *VE : C->varlist()) {
11976 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11977 if (EVar.isInvalid())
11978 return nullptr;
11979 Vars.push_back(EVar.get());
11980 }
11981 return getDerived().RebuildOMPAllocateClause(
11982 Allocator, Alignment, C->getFirstAllocateModifier(),
11983 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11984 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11985 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11986}
11987
11988template <typename Derived>
11989OMPClause *
11992 Vars.reserve(C->varlist_size());
11993 for (auto *VE : C->varlist()) {
11994 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11995 if (EVar.isInvalid())
11996 return nullptr;
11997 Vars.push_back(EVar.get());
11998 }
11999 Expr *ModifierExpr = C->getModifierExpr();
12000 if (ModifierExpr) {
12001 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(ModifierExpr));
12002 if (EVar.isInvalid())
12003 return nullptr;
12004 ModifierExpr = EVar.get();
12005 }
12006 return getDerived().RebuildOMPNumTeamsClause(
12007 Vars, C->getModifier(), ModifierExpr, C->getModifierLoc(),
12008 OMPC_NUMTEAMS_unknown, nullptr, SourceLocation(), C->getBeginLoc(),
12009 C->getLParenLoc(), C->getEndLoc());
12010}
12011
12012template <typename Derived>
12013OMPClause *
12016 Vars.reserve(C->varlist_size());
12017 for (auto *VE : C->varlist()) {
12018 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
12019 if (EVar.isInvalid())
12020 return nullptr;
12021 Vars.push_back(EVar.get());
12022 }
12023 Expr *ModifierExpr = C->getModifierExpr();
12024 if (ModifierExpr) {
12025 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(ModifierExpr));
12026 if (EVar.isInvalid())
12027 return nullptr;
12028 ModifierExpr = EVar.get();
12029 }
12030 return getDerived().RebuildOMPThreadLimitClause(
12031 Vars, C->getModifier(), ModifierExpr, C->getModifierLoc(),
12032 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12033}
12034
12035template <typename Derived>
12036OMPClause *
12038 ExprResult E = getDerived().TransformExpr(C->getPriority());
12039 if (E.isInvalid())
12040 return nullptr;
12041 return getDerived().RebuildOMPPriorityClause(
12042 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12043}
12044
12045template <typename Derived>
12046OMPClause *
12048 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
12049 if (E.isInvalid())
12050 return nullptr;
12051 return getDerived().RebuildOMPGrainsizeClause(
12052 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
12053 C->getModifierLoc(), C->getEndLoc());
12054}
12055
12056template <typename Derived>
12057OMPClause *
12059 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
12060 if (E.isInvalid())
12061 return nullptr;
12062 return getDerived().RebuildOMPNumTasksClause(
12063 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
12064 C->getModifierLoc(), C->getEndLoc());
12065}
12066
12067template <typename Derived>
12069 ExprResult E = getDerived().TransformExpr(C->getHint());
12070 if (E.isInvalid())
12071 return nullptr;
12072 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
12073 C->getLParenLoc(), C->getEndLoc());
12074}
12075
12076template <typename Derived>
12078 OMPDistScheduleClause *C) {
12079 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
12080 if (E.isInvalid())
12081 return nullptr;
12082 return getDerived().RebuildOMPDistScheduleClause(
12083 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
12084 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
12085}
12086
12087template <typename Derived>
12088OMPClause *
12090 // Rebuild Defaultmap Clause since we need to invoke the checking of
12091 // defaultmap(none:variable-category) after template initialization.
12092 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
12093 C->getDefaultmapKind(),
12094 C->getBeginLoc(),
12095 C->getLParenLoc(),
12096 C->getDefaultmapModifierLoc(),
12097 C->getDefaultmapKindLoc(),
12098 C->getEndLoc());
12099}
12100
12101template <typename Derived>
12103 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12105 Expr *IteratorModifier = C->getIteratorModifier();
12106 if (IteratorModifier) {
12107 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
12108 if (MapModRes.isInvalid())
12109 return nullptr;
12110 IteratorModifier = MapModRes.get();
12111 }
12112 CXXScopeSpec MapperIdScopeSpec;
12113 DeclarationNameInfo MapperIdInfo;
12114 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
12116 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
12117 return nullptr;
12118 return getDerived().RebuildOMPToClause(
12119 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
12120 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
12121 UnresolvedMappers);
12122}
12123
12124template <typename Derived>
12126 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12128 Expr *IteratorModifier = C->getIteratorModifier();
12129 if (IteratorModifier) {
12130 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
12131 if (MapModRes.isInvalid())
12132 return nullptr;
12133 IteratorModifier = MapModRes.get();
12134 }
12135 CXXScopeSpec MapperIdScopeSpec;
12136 DeclarationNameInfo MapperIdInfo;
12137 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
12139 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
12140 return nullptr;
12141 return getDerived().RebuildOMPFromClause(
12142 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
12143 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
12144 UnresolvedMappers);
12145}
12146
12147template <typename Derived>
12149 OMPUseDevicePtrClause *C) {
12151 Vars.reserve(C->varlist_size());
12152 for (auto *VE : C->varlist()) {
12153 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
12154 if (EVar.isInvalid())
12155 return nullptr;
12156 Vars.push_back(EVar.get());
12157 }
12158 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12159 return getDerived().RebuildOMPUseDevicePtrClause(
12160 Vars, Locs, C->getFallbackModifier(), C->getFallbackModifierLoc());
12161}
12162
12163template <typename Derived>
12165 OMPUseDeviceAddrClause *C) {
12167 Vars.reserve(C->varlist_size());
12168 for (auto *VE : C->varlist()) {
12169 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
12170 if (EVar.isInvalid())
12171 return nullptr;
12172 Vars.push_back(EVar.get());
12173 }
12174 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12175 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
12176}
12177
12178template <typename Derived>
12179OMPClause *
12182 Vars.reserve(C->varlist_size());
12183 for (auto *VE : C->varlist()) {
12184 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
12185 if (EVar.isInvalid())
12186 return nullptr;
12187 Vars.push_back(EVar.get());
12188 }
12189 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12190 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
12191}
12192
12193template <typename Derived>
12195 OMPHasDeviceAddrClause *C) {
12197 Vars.reserve(C->varlist_size());
12198 for (auto *VE : C->varlist()) {
12199 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
12200 if (EVar.isInvalid())
12201 return nullptr;
12202 Vars.push_back(EVar.get());
12203 }
12204 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12205 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
12206}
12207
12208template <typename Derived>
12209OMPClause *
12212 Vars.reserve(C->varlist_size());
12213 for (auto *VE : C->varlist()) {
12214 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
12215 if (EVar.isInvalid())
12216 return nullptr;
12217 Vars.push_back(EVar.get());
12218 }
12219 return getDerived().RebuildOMPNontemporalClause(
12220 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12221}
12222
12223template <typename Derived>
12224OMPClause *
12227 Vars.reserve(C->varlist_size());
12228 for (auto *VE : C->varlist()) {
12229 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
12230 if (EVar.isInvalid())
12231 return nullptr;
12232 Vars.push_back(EVar.get());
12233 }
12234 return getDerived().RebuildOMPInclusiveClause(
12235 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12236}
12237
12238template <typename Derived>
12239OMPClause *
12242 Vars.reserve(C->varlist_size());
12243 for (auto *VE : C->varlist()) {
12244 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
12245 if (EVar.isInvalid())
12246 return nullptr;
12247 Vars.push_back(EVar.get());
12248 }
12249 return getDerived().RebuildOMPExclusiveClause(
12250 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12251}
12252
12253template <typename Derived>
12255 OMPUsesAllocatorsClause *C) {
12257 Data.reserve(C->getNumberOfAllocators());
12258 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
12259 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
12260 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
12261 if (Allocator.isInvalid())
12262 continue;
12263 ExprResult AllocatorTraits;
12264 if (Expr *AT = D.AllocatorTraits) {
12265 AllocatorTraits = getDerived().TransformExpr(AT);
12266 if (AllocatorTraits.isInvalid())
12267 continue;
12268 }
12269 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
12270 NewD.Allocator = Allocator.get();
12271 NewD.AllocatorTraits = AllocatorTraits.get();
12272 NewD.LParenLoc = D.LParenLoc;
12273 NewD.RParenLoc = D.RParenLoc;
12274 }
12275 return getDerived().RebuildOMPUsesAllocatorsClause(
12276 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12277}
12278
12279template <typename Derived>
12280OMPClause *
12282 SmallVector<Expr *, 4> Locators;
12283 Locators.reserve(C->varlist_size());
12284 ExprResult ModifierRes;
12285 if (Expr *Modifier = C->getModifier()) {
12286 ModifierRes = getDerived().TransformExpr(Modifier);
12287 if (ModifierRes.isInvalid())
12288 return nullptr;
12289 }
12290 for (Expr *E : C->varlist()) {
12291 ExprResult Locator = getDerived().TransformExpr(E);
12292 if (Locator.isInvalid())
12293 continue;
12294 Locators.push_back(Locator.get());
12295 }
12296 return getDerived().RebuildOMPAffinityClause(
12297 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
12298 ModifierRes.get(), Locators);
12299}
12300
12301template <typename Derived>
12303 return getDerived().RebuildOMPOrderClause(
12304 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
12305 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
12306}
12307
12308template <typename Derived>
12310 return getDerived().RebuildOMPBindClause(
12311 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
12312 C->getLParenLoc(), C->getEndLoc());
12313}
12314
12315template <typename Derived>
12317 OMPXDynCGroupMemClause *C) {
12318 ExprResult Size = getDerived().TransformExpr(C->getSize());
12319 if (Size.isInvalid())
12320 return nullptr;
12321 return getDerived().RebuildOMPXDynCGroupMemClause(
12322 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12323}
12324
12325template <typename Derived>
12327 OMPDynGroupprivateClause *C) {
12328 ExprResult Size = getDerived().TransformExpr(C->getSize());
12329 if (Size.isInvalid())
12330 return nullptr;
12331 return getDerived().RebuildOMPDynGroupprivateClause(
12332 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
12333 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
12334 C->getDynGroupprivateModifierLoc(),
12335 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
12336}
12337
12338template <typename Derived>
12339OMPClause *
12342 Vars.reserve(C->varlist_size());
12343 for (auto *VE : C->varlist()) {
12344 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
12345 if (EVar.isInvalid())
12346 return nullptr;
12347 Vars.push_back(EVar.get());
12348 }
12349 return getDerived().RebuildOMPDoacrossClause(
12350 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
12351 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12352}
12353
12354template <typename Derived>
12355OMPClause *
12358 for (auto *A : C->getAttrs())
12359 NewAttrs.push_back(getDerived().TransformAttr(A));
12360 return getDerived().RebuildOMPXAttributeClause(
12361 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
12362}
12363
12364template <typename Derived>
12366 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
12367}
12368
12369//===----------------------------------------------------------------------===//
12370// OpenACC transformation
12371//===----------------------------------------------------------------------===//
12372namespace {
12373template <typename Derived>
12374class OpenACCClauseTransform final
12375 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
12376 TreeTransform<Derived> &Self;
12377 ArrayRef<const OpenACCClause *> ExistingClauses;
12378 SemaOpenACC::OpenACCParsedClause &ParsedClause;
12379 OpenACCClause *NewClause = nullptr;
12380
12381 ExprResult VisitVar(Expr *VarRef) {
12382 ExprResult Res = Self.TransformExpr(VarRef);
12383
12384 if (!Res.isUsable())
12385 return Res;
12386
12387 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
12388 ParsedClause.getClauseKind(),
12389 Res.get());
12390
12391 return Res;
12392 }
12393
12394 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
12395 llvm::SmallVector<Expr *> InstantiatedVarList;
12396 for (Expr *CurVar : VarList) {
12397 ExprResult VarRef = VisitVar(CurVar);
12398
12399 if (VarRef.isUsable())
12400 InstantiatedVarList.push_back(VarRef.get());
12401 }
12402
12403 return InstantiatedVarList;
12404 }
12405
12406public:
12407 OpenACCClauseTransform(TreeTransform<Derived> &Self,
12408 ArrayRef<const OpenACCClause *> ExistingClauses,
12409 SemaOpenACC::OpenACCParsedClause &PC)
12410 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
12411
12412 OpenACCClause *CreatedClause() const { return NewClause; }
12413
12414#define VISIT_CLAUSE(CLAUSE_NAME) \
12415 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
12416#include "clang/Basic/OpenACCClauses.def"
12417};
12418
12419template <typename Derived>
12420void OpenACCClauseTransform<Derived>::VisitDefaultClause(
12421 const OpenACCDefaultClause &C) {
12422 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
12423
12424 NewClause = OpenACCDefaultClause::Create(
12425 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
12426 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12427 ParsedClause.getEndLoc());
12428}
12429
12430template <typename Derived>
12431void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
12432 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12433 assert(Cond && "If constructed with invalid Condition");
12434 Sema::ConditionResult Res = Self.TransformCondition(
12435 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
12436
12437 if (Res.isInvalid() || !Res.get().second)
12438 return;
12439
12440 ParsedClause.setConditionDetails(Res.get().second);
12441
12442 NewClause = OpenACCIfClause::Create(
12443 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12444 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12445 ParsedClause.getEndLoc());
12446}
12447
12448template <typename Derived>
12449void OpenACCClauseTransform<Derived>::VisitSelfClause(
12450 const OpenACCSelfClause &C) {
12451
12452 // If this is an 'update' 'self' clause, this is actually a var list instead.
12453 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
12454 llvm::SmallVector<Expr *> InstantiatedVarList;
12455 for (Expr *CurVar : C.getVarList()) {
12456 ExprResult Res = Self.TransformExpr(CurVar);
12457
12458 if (!Res.isUsable())
12459 continue;
12460
12461 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
12462 ParsedClause.getClauseKind(),
12463 Res.get());
12464
12465 if (Res.isUsable())
12466 InstantiatedVarList.push_back(Res.get());
12467 }
12468
12469 ParsedClause.setVarListDetails(InstantiatedVarList,
12471
12472 NewClause = OpenACCSelfClause::Create(
12473 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12474 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12475 ParsedClause.getEndLoc());
12476 } else {
12477
12478 if (C.hasConditionExpr()) {
12479 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12481 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
12483
12484 if (Res.isInvalid() || !Res.get().second)
12485 return;
12486
12487 ParsedClause.setConditionDetails(Res.get().second);
12488 }
12489
12490 NewClause = OpenACCSelfClause::Create(
12491 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12492 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12493 ParsedClause.getEndLoc());
12494 }
12495}
12496
12497template <typename Derived>
12498void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
12499 const OpenACCNumGangsClause &C) {
12500 llvm::SmallVector<Expr *> InstantiatedIntExprs;
12501
12502 for (Expr *CurIntExpr : C.getIntExprs()) {
12503 ExprResult Res = Self.TransformExpr(CurIntExpr);
12504
12505 if (!Res.isUsable())
12506 return;
12507
12508 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12509 C.getClauseKind(),
12510 C.getBeginLoc(), Res.get());
12511 if (!Res.isUsable())
12512 return;
12513
12514 InstantiatedIntExprs.push_back(Res.get());
12515 }
12516
12517 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
12519 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12520 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12521 ParsedClause.getEndLoc());
12522}
12523
12524template <typename Derived>
12525void OpenACCClauseTransform<Derived>::VisitPrivateClause(
12526 const OpenACCPrivateClause &C) {
12527 llvm::SmallVector<Expr *> InstantiatedVarList;
12529
12530 for (const auto [RefExpr, InitRecipe] :
12531 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12532 ExprResult VarRef = VisitVar(RefExpr);
12533
12534 if (VarRef.isUsable()) {
12535 InstantiatedVarList.push_back(VarRef.get());
12536
12537 // We only have to create a new one if it is dependent, and Sema won't
12538 // make one of these unless the type is non-dependent.
12539 if (InitRecipe.isSet())
12540 InitRecipes.push_back(InitRecipe);
12541 else
12542 InitRecipes.push_back(
12543 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
12544 }
12545 }
12546 ParsedClause.setVarListDetails(InstantiatedVarList,
12548
12549 NewClause = OpenACCPrivateClause::Create(
12550 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12551 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12552 ParsedClause.getEndLoc());
12553}
12554
12555template <typename Derived>
12556void OpenACCClauseTransform<Derived>::VisitHostClause(
12557 const OpenACCHostClause &C) {
12558 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12560
12561 NewClause = OpenACCHostClause::Create(
12562 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12563 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12564 ParsedClause.getEndLoc());
12565}
12566
12567template <typename Derived>
12568void OpenACCClauseTransform<Derived>::VisitDeviceClause(
12569 const OpenACCDeviceClause &C) {
12570 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12572
12573 NewClause = OpenACCDeviceClause::Create(
12574 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12575 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12576 ParsedClause.getEndLoc());
12577}
12578
12579template <typename Derived>
12580void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
12582 llvm::SmallVector<Expr *> InstantiatedVarList;
12584
12585 for (const auto [RefExpr, InitRecipe] :
12586 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12587 ExprResult VarRef = VisitVar(RefExpr);
12588
12589 if (VarRef.isUsable()) {
12590 InstantiatedVarList.push_back(VarRef.get());
12591
12592 // We only have to create a new one if it is dependent, and Sema won't
12593 // make one of these unless the type is non-dependent.
12594 if (InitRecipe.isSet())
12595 InitRecipes.push_back(InitRecipe);
12596 else
12597 InitRecipes.push_back(
12598 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12599 VarRef.get()));
12600 }
12601 }
12602 ParsedClause.setVarListDetails(InstantiatedVarList,
12604
12606 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12607 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12608 ParsedClause.getEndLoc());
12609}
12610
12611template <typename Derived>
12612void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12613 const OpenACCNoCreateClause &C) {
12614 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12616
12618 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12619 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12620 ParsedClause.getEndLoc());
12621}
12622
12623template <typename Derived>
12624void OpenACCClauseTransform<Derived>::VisitPresentClause(
12625 const OpenACCPresentClause &C) {
12626 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12628
12629 NewClause = OpenACCPresentClause::Create(
12630 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12631 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12632 ParsedClause.getEndLoc());
12633}
12634
12635template <typename Derived>
12636void OpenACCClauseTransform<Derived>::VisitCopyClause(
12637 const OpenACCCopyClause &C) {
12638 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12639 C.getModifierList());
12640
12641 NewClause = OpenACCCopyClause::Create(
12642 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12643 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12644 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12645 ParsedClause.getEndLoc());
12646}
12647
12648template <typename Derived>
12649void OpenACCClauseTransform<Derived>::VisitLinkClause(
12650 const OpenACCLinkClause &C) {
12651 llvm_unreachable("link clause not valid unless a decl transform");
12652}
12653
12654template <typename Derived>
12655void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12657 llvm_unreachable("device_resident clause not valid unless a decl transform");
12658}
12659template <typename Derived>
12660void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12661 const OpenACCNoHostClause &C) {
12662 llvm_unreachable("nohost clause not valid unless a decl transform");
12663}
12664template <typename Derived>
12665void OpenACCClauseTransform<Derived>::VisitBindClause(
12666 const OpenACCBindClause &C) {
12667 llvm_unreachable("bind clause not valid unless a decl transform");
12668}
12669
12670template <typename Derived>
12671void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12672 const OpenACCCopyInClause &C) {
12673 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12674 C.getModifierList());
12675
12676 NewClause = OpenACCCopyInClause::Create(
12677 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12678 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12679 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12680 ParsedClause.getEndLoc());
12681}
12682
12683template <typename Derived>
12684void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12685 const OpenACCCopyOutClause &C) {
12686 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12687 C.getModifierList());
12688
12689 NewClause = OpenACCCopyOutClause::Create(
12690 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12691 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12692 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12693 ParsedClause.getEndLoc());
12694}
12695
12696template <typename Derived>
12697void OpenACCClauseTransform<Derived>::VisitCreateClause(
12698 const OpenACCCreateClause &C) {
12699 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12700 C.getModifierList());
12701
12702 NewClause = OpenACCCreateClause::Create(
12703 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12704 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12705 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12706 ParsedClause.getEndLoc());
12707}
12708template <typename Derived>
12709void OpenACCClauseTransform<Derived>::VisitAttachClause(
12710 const OpenACCAttachClause &C) {
12711 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12712
12713 // Ensure each var is a pointer type.
12714 llvm::erase_if(VarList, [&](Expr *E) {
12715 return Self.getSema().OpenACC().CheckVarIsPointerType(
12717 });
12718
12719 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12720 NewClause = OpenACCAttachClause::Create(
12721 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12722 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12723 ParsedClause.getEndLoc());
12724}
12725
12726template <typename Derived>
12727void OpenACCClauseTransform<Derived>::VisitDetachClause(
12728 const OpenACCDetachClause &C) {
12729 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12730
12731 // Ensure each var is a pointer type.
12732 llvm::erase_if(VarList, [&](Expr *E) {
12733 return Self.getSema().OpenACC().CheckVarIsPointerType(
12735 });
12736
12737 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12738 NewClause = OpenACCDetachClause::Create(
12739 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12740 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12741 ParsedClause.getEndLoc());
12742}
12743
12744template <typename Derived>
12745void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12746 const OpenACCDeleteClause &C) {
12747 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12749 NewClause = OpenACCDeleteClause::Create(
12750 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12751 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12752 ParsedClause.getEndLoc());
12753}
12754
12755template <typename Derived>
12756void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12757 const OpenACCUseDeviceClause &C) {
12758 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12761 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12762 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12763 ParsedClause.getEndLoc());
12764}
12765
12766template <typename Derived>
12767void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12768 const OpenACCDevicePtrClause &C) {
12769 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12770
12771 // Ensure each var is a pointer type.
12772 llvm::erase_if(VarList, [&](Expr *E) {
12773 return Self.getSema().OpenACC().CheckVarIsPointerType(
12775 });
12776
12777 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12779 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12780 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12781 ParsedClause.getEndLoc());
12782}
12783
12784template <typename Derived>
12785void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12786 const OpenACCNumWorkersClause &C) {
12787 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12788 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12789
12790 ExprResult Res = Self.TransformExpr(IntExpr);
12791 if (!Res.isUsable())
12792 return;
12793
12794 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12795 C.getClauseKind(),
12796 C.getBeginLoc(), Res.get());
12797 if (!Res.isUsable())
12798 return;
12799
12800 ParsedClause.setIntExprDetails(Res.get());
12802 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12803 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12804 ParsedClause.getEndLoc());
12805}
12806
12807template <typename Derived>
12808void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12809 const OpenACCDeviceNumClause &C) {
12810 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12811 assert(IntExpr && "device_num clause constructed with invalid int expr");
12812
12813 ExprResult Res = Self.TransformExpr(IntExpr);
12814 if (!Res.isUsable())
12815 return;
12816
12817 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12818 C.getClauseKind(),
12819 C.getBeginLoc(), Res.get());
12820 if (!Res.isUsable())
12821 return;
12822
12823 ParsedClause.setIntExprDetails(Res.get());
12825 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12826 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12827 ParsedClause.getEndLoc());
12828}
12829
12830template <typename Derived>
12831void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12833 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12834 assert(IntExpr && "default_async clause constructed with invalid int expr");
12835
12836 ExprResult Res = Self.TransformExpr(IntExpr);
12837 if (!Res.isUsable())
12838 return;
12839
12840 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12841 C.getClauseKind(),
12842 C.getBeginLoc(), Res.get());
12843 if (!Res.isUsable())
12844 return;
12845
12846 ParsedClause.setIntExprDetails(Res.get());
12848 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12849 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12850 ParsedClause.getEndLoc());
12851}
12852
12853template <typename Derived>
12854void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12856 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12857 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12858
12859 ExprResult Res = Self.TransformExpr(IntExpr);
12860 if (!Res.isUsable())
12861 return;
12862
12863 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12864 C.getClauseKind(),
12865 C.getBeginLoc(), Res.get());
12866 if (!Res.isUsable())
12867 return;
12868
12869 ParsedClause.setIntExprDetails(Res.get());
12871 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12872 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12873 ParsedClause.getEndLoc());
12874}
12875
12876template <typename Derived>
12877void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12878 const OpenACCAsyncClause &C) {
12879 if (C.hasIntExpr()) {
12880 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12881 if (!Res.isUsable())
12882 return;
12883
12884 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12885 C.getClauseKind(),
12886 C.getBeginLoc(), Res.get());
12887 if (!Res.isUsable())
12888 return;
12889 ParsedClause.setIntExprDetails(Res.get());
12890 }
12891
12892 NewClause = OpenACCAsyncClause::Create(
12893 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12894 ParsedClause.getLParenLoc(),
12895 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12896 : nullptr,
12897 ParsedClause.getEndLoc());
12898}
12899
12900template <typename Derived>
12901void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12902 const OpenACCWorkerClause &C) {
12903 if (C.hasIntExpr()) {
12904 // restrictions on this expression are all "does it exist in certain
12905 // situations" that are not possible to be dependent, so the only check we
12906 // have is that it transforms, and is an int expression.
12907 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12908 if (!Res.isUsable())
12909 return;
12910
12911 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12912 C.getClauseKind(),
12913 C.getBeginLoc(), Res.get());
12914 if (!Res.isUsable())
12915 return;
12916 ParsedClause.setIntExprDetails(Res.get());
12917 }
12918
12919 NewClause = OpenACCWorkerClause::Create(
12920 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12921 ParsedClause.getLParenLoc(),
12922 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12923 : nullptr,
12924 ParsedClause.getEndLoc());
12925}
12926
12927template <typename Derived>
12928void OpenACCClauseTransform<Derived>::VisitVectorClause(
12929 const OpenACCVectorClause &C) {
12930 if (C.hasIntExpr()) {
12931 // restrictions on this expression are all "does it exist in certain
12932 // situations" that are not possible to be dependent, so the only check we
12933 // have is that it transforms, and is an int expression.
12934 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12935 if (!Res.isUsable())
12936 return;
12937
12938 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12939 C.getClauseKind(),
12940 C.getBeginLoc(), Res.get());
12941 if (!Res.isUsable())
12942 return;
12943 ParsedClause.setIntExprDetails(Res.get());
12944 }
12945
12946 NewClause = OpenACCVectorClause::Create(
12947 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12948 ParsedClause.getLParenLoc(),
12949 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12950 : nullptr,
12951 ParsedClause.getEndLoc());
12952}
12953
12954template <typename Derived>
12955void OpenACCClauseTransform<Derived>::VisitWaitClause(
12956 const OpenACCWaitClause &C) {
12957 if (C.hasExprs()) {
12958 Expr *DevNumExpr = nullptr;
12959 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12960
12961 // Instantiate devnum expr if it exists.
12962 if (C.getDevNumExpr()) {
12963 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12964 if (!Res.isUsable())
12965 return;
12966 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12967 C.getClauseKind(),
12968 C.getBeginLoc(), Res.get());
12969 if (!Res.isUsable())
12970 return;
12971
12972 DevNumExpr = Res.get();
12973 }
12974
12975 // Instantiate queue ids.
12976 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12977 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12978 if (!Res.isUsable())
12979 return;
12980 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12981 C.getClauseKind(),
12982 C.getBeginLoc(), Res.get());
12983 if (!Res.isUsable())
12984 return;
12985
12986 InstantiatedQueueIdExprs.push_back(Res.get());
12987 }
12988
12989 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12990 std::move(InstantiatedQueueIdExprs));
12991 }
12992
12993 NewClause = OpenACCWaitClause::Create(
12994 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12995 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12996 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12997 ParsedClause.getEndLoc());
12998}
12999
13000template <typename Derived>
13001void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
13002 const OpenACCDeviceTypeClause &C) {
13003 // Nothing to transform here, just create a new version of 'C'.
13005 Self.getSema().getASTContext(), C.getClauseKind(),
13006 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
13007 C.getArchitectures(), ParsedClause.getEndLoc());
13008}
13009
13010template <typename Derived>
13011void OpenACCClauseTransform<Derived>::VisitAutoClause(
13012 const OpenACCAutoClause &C) {
13013 // Nothing to do, so just create a new node.
13014 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
13015 ParsedClause.getBeginLoc(),
13016 ParsedClause.getEndLoc());
13017}
13018
13019template <typename Derived>
13020void OpenACCClauseTransform<Derived>::VisitIndependentClause(
13021 const OpenACCIndependentClause &C) {
13022 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
13023 ParsedClause.getBeginLoc(),
13024 ParsedClause.getEndLoc());
13025}
13026
13027template <typename Derived>
13028void OpenACCClauseTransform<Derived>::VisitSeqClause(
13029 const OpenACCSeqClause &C) {
13030 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
13031 ParsedClause.getBeginLoc(),
13032 ParsedClause.getEndLoc());
13033}
13034template <typename Derived>
13035void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
13036 const OpenACCFinalizeClause &C) {
13037 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
13038 ParsedClause.getBeginLoc(),
13039 ParsedClause.getEndLoc());
13040}
13041
13042template <typename Derived>
13043void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
13044 const OpenACCIfPresentClause &C) {
13045 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
13046 ParsedClause.getBeginLoc(),
13047 ParsedClause.getEndLoc());
13048}
13049
13050template <typename Derived>
13051void OpenACCClauseTransform<Derived>::VisitReductionClause(
13052 const OpenACCReductionClause &C) {
13053 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
13054 SmallVector<Expr *> ValidVars;
13056
13057 for (const auto [Var, OrigRecipe] :
13058 llvm::zip(TransformedVars, C.getRecipes())) {
13059 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
13060 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
13061 if (Res.isUsable()) {
13062 ValidVars.push_back(Res.get());
13063
13064 if (OrigRecipe.isSet())
13065 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
13066 else
13067 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
13068 C.getReductionOp(), Res.get()));
13069 }
13070 }
13071
13072 NewClause = Self.getSema().OpenACC().CheckReductionClause(
13073 ExistingClauses, ParsedClause.getDirectiveKind(),
13074 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
13075 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
13076}
13077
13078template <typename Derived>
13079void OpenACCClauseTransform<Derived>::VisitCollapseClause(
13080 const OpenACCCollapseClause &C) {
13081 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
13082 assert(LoopCount && "collapse clause constructed with invalid loop count");
13083
13084 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
13085
13086 if (!NewLoopCount.isUsable())
13087 return;
13088
13089 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
13090 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
13091 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
13092
13093 // FIXME: It isn't clear whether this is properly tested here, we should
13094 // probably see if we can come up with a test for this.
13095 if (!NewLoopCount.isUsable())
13096 return;
13097
13098 NewLoopCount =
13099 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
13100
13101 // FIXME: It isn't clear whether this is properly tested here, we should
13102 // probably see if we can come up with a test for this.
13103 if (!NewLoopCount.isUsable())
13104 return;
13105
13106 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
13108 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
13109 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
13110 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
13111}
13112
13113template <typename Derived>
13114void OpenACCClauseTransform<Derived>::VisitTileClause(
13115 const OpenACCTileClause &C) {
13116
13117 llvm::SmallVector<Expr *> TransformedExprs;
13118
13119 for (Expr *E : C.getSizeExprs()) {
13120 ExprResult NewSizeExpr = Self.TransformExpr(E);
13121
13122 if (!NewSizeExpr.isUsable())
13123 return;
13124
13125 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
13126 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
13127 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
13128
13129 // FIXME: It isn't clear whether this is properly tested here, we should
13130 // probably see if we can come up with a test for this.
13131 if (!NewSizeExpr.isUsable())
13132 return;
13133
13134 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
13135
13136 if (!NewSizeExpr.isUsable())
13137 return;
13138 TransformedExprs.push_back(NewSizeExpr.get());
13139 }
13140
13141 ParsedClause.setIntExprDetails(TransformedExprs);
13142 NewClause = OpenACCTileClause::Create(
13143 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
13144 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
13145 ParsedClause.getEndLoc());
13146}
13147template <typename Derived>
13148void OpenACCClauseTransform<Derived>::VisitGangClause(
13149 const OpenACCGangClause &C) {
13150 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
13151 llvm::SmallVector<Expr *> TransformedIntExprs;
13152
13153 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
13154 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
13155 if (!ER.isUsable())
13156 continue;
13157
13158 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
13159 ParsedClause.getDirectiveKind(),
13160 C.getExpr(I).first, ER.get());
13161 if (!ER.isUsable())
13162 continue;
13163 TransformedGangKinds.push_back(C.getExpr(I).first);
13164 TransformedIntExprs.push_back(ER.get());
13165 }
13166
13167 NewClause = Self.getSema().OpenACC().CheckGangClause(
13168 ParsedClause.getDirectiveKind(), ExistingClauses,
13169 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
13170 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
13171}
13172} // namespace
13173template <typename Derived>
13174OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
13175 ArrayRef<const OpenACCClause *> ExistingClauses,
13176 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
13177
13179 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
13180 ParsedClause.setEndLoc(OldClause->getEndLoc());
13181
13182 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
13183 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
13184
13185 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
13186 ParsedClause};
13187 Transform.Visit(OldClause);
13188
13189 return Transform.CreatedClause();
13190}
13191
13192template <typename Derived>
13194TreeTransform<Derived>::TransformOpenACCClauseList(
13196 llvm::SmallVector<OpenACCClause *> TransformedClauses;
13197 for (const auto *Clause : OldClauses) {
13198 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
13199 TransformedClauses, DirKind, Clause))
13200 TransformedClauses.push_back(TransformedClause);
13201 }
13202 return TransformedClauses;
13203}
13204
13205template <typename Derived>
13208 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13209
13210 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13211 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13212 C->clauses());
13213
13214 if (getSema().OpenACC().ActOnStartStmtDirective(
13215 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13216 return StmtError();
13217
13218 // Transform Structured Block.
13219 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13220 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
13221 C->clauses(), TransformedClauses);
13222 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
13223 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
13224 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
13225
13226 return getDerived().RebuildOpenACCComputeConstruct(
13227 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
13228 C->getEndLoc(), TransformedClauses, StrBlock);
13229}
13230
13231template <typename Derived>
13234
13235 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13236
13237 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13238 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13239 C->clauses());
13240
13241 if (getSema().OpenACC().ActOnStartStmtDirective(
13242 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13243 return StmtError();
13244
13245 // Transform Loop.
13246 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13247 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
13248 C->clauses(), TransformedClauses);
13249 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
13250 Loop = getSema().OpenACC().ActOnAssociatedStmt(
13251 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
13252
13253 return getDerived().RebuildOpenACCLoopConstruct(
13254 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13255 TransformedClauses, Loop);
13256}
13257
13258template <typename Derived>
13260 OpenACCCombinedConstruct *C) {
13261 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13262
13263 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13264 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13265 C->clauses());
13266
13267 if (getSema().OpenACC().ActOnStartStmtDirective(
13268 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13269 return StmtError();
13270
13271 // Transform Loop.
13272 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13273 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
13274 C->clauses(), TransformedClauses);
13275 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
13276 Loop = getSema().OpenACC().ActOnAssociatedStmt(
13277 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
13278
13279 return getDerived().RebuildOpenACCCombinedConstruct(
13280 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
13281 C->getEndLoc(), TransformedClauses, Loop);
13282}
13283
13284template <typename Derived>
13287 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13288
13289 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13290 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13291 C->clauses());
13292 if (getSema().OpenACC().ActOnStartStmtDirective(
13293 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13294 return StmtError();
13295
13296 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13297 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
13298 C->clauses(), TransformedClauses);
13299 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
13300 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
13301 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
13302
13303 return getDerived().RebuildOpenACCDataConstruct(
13304 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13305 TransformedClauses, StrBlock);
13306}
13307
13308template <typename Derived>
13310 OpenACCEnterDataConstruct *C) {
13311 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13312
13313 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13314 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13315 C->clauses());
13316 if (getSema().OpenACC().ActOnStartStmtDirective(
13317 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13318 return StmtError();
13319
13320 return getDerived().RebuildOpenACCEnterDataConstruct(
13321 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13322 TransformedClauses);
13323}
13324
13325template <typename Derived>
13327 OpenACCExitDataConstruct *C) {
13328 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13329
13330 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13331 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13332 C->clauses());
13333 if (getSema().OpenACC().ActOnStartStmtDirective(
13334 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13335 return StmtError();
13336
13337 return getDerived().RebuildOpenACCExitDataConstruct(
13338 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13339 TransformedClauses);
13340}
13341
13342template <typename Derived>
13344 OpenACCHostDataConstruct *C) {
13345 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13346
13347 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13348 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13349 C->clauses());
13350 if (getSema().OpenACC().ActOnStartStmtDirective(
13351 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13352 return StmtError();
13353
13354 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13355 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
13356 C->clauses(), TransformedClauses);
13357 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
13358 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
13359 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
13360
13361 return getDerived().RebuildOpenACCHostDataConstruct(
13362 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13363 TransformedClauses, StrBlock);
13364}
13365
13366template <typename Derived>
13369 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13370
13371 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13372 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13373 C->clauses());
13374 if (getSema().OpenACC().ActOnStartStmtDirective(
13375 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13376 return StmtError();
13377
13378 return getDerived().RebuildOpenACCInitConstruct(
13379 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13380 TransformedClauses);
13381}
13382
13383template <typename Derived>
13385 OpenACCShutdownConstruct *C) {
13386 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13387
13388 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13389 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13390 C->clauses());
13391 if (getSema().OpenACC().ActOnStartStmtDirective(
13392 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13393 return StmtError();
13394
13395 return getDerived().RebuildOpenACCShutdownConstruct(
13396 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13397 TransformedClauses);
13398}
13399template <typename Derived>
13402 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13403
13404 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13405 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13406 C->clauses());
13407 if (getSema().OpenACC().ActOnStartStmtDirective(
13408 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13409 return StmtError();
13410
13411 return getDerived().RebuildOpenACCSetConstruct(
13412 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13413 TransformedClauses);
13414}
13415
13416template <typename Derived>
13418 OpenACCUpdateConstruct *C) {
13419 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13420
13421 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13422 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13423 C->clauses());
13424 if (getSema().OpenACC().ActOnStartStmtDirective(
13425 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13426 return StmtError();
13427
13428 return getDerived().RebuildOpenACCUpdateConstruct(
13429 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13430 TransformedClauses);
13431}
13432
13433template <typename Derived>
13436 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13437
13438 ExprResult DevNumExpr;
13439 if (C->hasDevNumExpr()) {
13440 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
13441
13442 if (DevNumExpr.isUsable())
13443 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
13445 C->getBeginLoc(), DevNumExpr.get());
13446 }
13447
13448 llvm::SmallVector<Expr *> QueueIdExprs;
13449
13450 for (Expr *QE : C->getQueueIdExprs()) {
13451 assert(QE && "Null queue id expr?");
13452 ExprResult NewEQ = getDerived().TransformExpr(QE);
13453
13454 if (!NewEQ.isUsable())
13455 break;
13456 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
13458 C->getBeginLoc(), NewEQ.get());
13459 if (NewEQ.isUsable())
13460 QueueIdExprs.push_back(NewEQ.get());
13461 }
13462
13463 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13464 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13465 C->clauses());
13466
13467 if (getSema().OpenACC().ActOnStartStmtDirective(
13468 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13469 return StmtError();
13470
13471 return getDerived().RebuildOpenACCWaitConstruct(
13472 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13473 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
13474 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
13475}
13476template <typename Derived>
13478 OpenACCCacheConstruct *C) {
13479 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13480
13481 llvm::SmallVector<Expr *> TransformedVarList;
13482 for (Expr *Var : C->getVarList()) {
13483 assert(Var && "Null var listexpr?");
13484
13485 ExprResult NewVar = getDerived().TransformExpr(Var);
13486
13487 if (!NewVar.isUsable())
13488 break;
13489
13490 NewVar = getSema().OpenACC().ActOnVar(
13491 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
13492 if (!NewVar.isUsable())
13493 break;
13494
13495 TransformedVarList.push_back(NewVar.get());
13496 }
13497
13498 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13499 C->getBeginLoc(), {}))
13500 return StmtError();
13501
13502 return getDerived().RebuildOpenACCCacheConstruct(
13503 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13504 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
13505 C->getEndLoc());
13506}
13507
13508template <typename Derived>
13510 OpenACCAtomicConstruct *C) {
13511 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13512
13513 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13514 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13515 C->clauses());
13516
13517 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13518 C->getBeginLoc(), {}))
13519 return StmtError();
13520
13521 // Transform Associated Stmt.
13522 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13523 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
13524
13525 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
13526 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
13527 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
13528 AssocStmt);
13529
13530 return getDerived().RebuildOpenACCAtomicConstruct(
13531 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
13532 C->getEndLoc(), TransformedClauses, AssocStmt);
13533}
13534
13535template <typename Derived>
13538 if (getDerived().AlwaysRebuild())
13539 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
13540 // Nothing can ever change, so there is never anything to transform.
13541 return E;
13542}
13543
13544//===----------------------------------------------------------------------===//
13545// Expression transformation
13546//===----------------------------------------------------------------------===//
13547template<typename Derived>
13550 return TransformExpr(E->getSubExpr());
13551}
13552
13553template <typename Derived>
13556 if (!E->isTypeDependent())
13557 return E;
13558
13559 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
13560
13561 if (!NewT)
13562 return ExprError();
13563
13564 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
13565 return E;
13566
13567 return getDerived().RebuildSYCLUniqueStableNameExpr(
13568 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
13569}
13570
13571template <typename Derived>
13574 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
13575 const auto *SKEPAttr = FD->template getAttr<SYCLKernelEntryPointAttr>();
13576 if (!SKEPAttr || SKEPAttr->isInvalidAttr())
13577 return StmtError();
13578
13579 ExprResult IdExpr = getDerived().TransformExpr(S->getKernelLaunchIdExpr());
13580 if (IdExpr.isInvalid())
13581 return StmtError();
13582
13583 StmtResult Body = getDerived().TransformStmt(S->getOriginalStmt());
13584 if (Body.isInvalid())
13585 return StmtError();
13586
13588 cast<FunctionDecl>(SemaRef.CurContext), cast<CompoundStmt>(Body.get()),
13589 IdExpr.get());
13590 if (SR.isInvalid())
13591 return StmtError();
13592
13593 return SR;
13594}
13595
13596template <typename Derived>
13598 // TODO(reflection): Implement its transform
13599 assert(false && "not implemented yet");
13600 return ExprError();
13601}
13602
13603template<typename Derived>
13606 if (!E->isTypeDependent())
13607 return E;
13608
13609 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13610 E->getIdentKind());
13611}
13612
13613template<typename Derived>
13616 NestedNameSpecifierLoc QualifierLoc;
13617 if (E->getQualifierLoc()) {
13618 QualifierLoc
13619 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13620 if (!QualifierLoc)
13621 return ExprError();
13622 }
13623
13624 ValueDecl *ND
13625 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13626 E->getDecl()));
13627 if (!ND || ND->isInvalidDecl())
13628 return ExprError();
13629
13630 NamedDecl *Found = ND;
13631 if (E->getFoundDecl() != E->getDecl()) {
13632 Found = cast_or_null<NamedDecl>(
13633 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13634 if (!Found)
13635 return ExprError();
13636 }
13637
13638 DeclarationNameInfo NameInfo = E->getNameInfo();
13639 if (NameInfo.getName()) {
13640 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13641 if (!NameInfo.getName())
13642 return ExprError();
13643 }
13644
13645 if (!getDerived().AlwaysRebuild() &&
13646 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13647 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13648 Found == E->getFoundDecl() &&
13649 NameInfo.getName() == E->getDecl()->getDeclName() &&
13650 !E->hasExplicitTemplateArgs()) {
13651
13652 // Mark it referenced in the new context regardless.
13653 // FIXME: this is a bit instantiation-specific.
13654 SemaRef.MarkDeclRefReferenced(E);
13655
13656 return E;
13657 }
13658
13659 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13660 if (E->hasExplicitTemplateArgs()) {
13661 TemplateArgs = &TransArgs;
13662 TransArgs.setLAngleLoc(E->getLAngleLoc());
13663 TransArgs.setRAngleLoc(E->getRAngleLoc());
13664 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13665 E->getNumTemplateArgs(),
13666 TransArgs))
13667 return ExprError();
13668 }
13669
13670 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13671 Found, TemplateArgs);
13672}
13673
13674template<typename Derived>
13677 return E;
13678}
13679
13680template <typename Derived>
13682 FixedPointLiteral *E) {
13683 return E;
13684}
13685
13686template<typename Derived>
13689 return E;
13690}
13691
13692template<typename Derived>
13695 return E;
13696}
13697
13698template<typename Derived>
13701 return E;
13702}
13703
13704template<typename Derived>
13707 return E;
13708}
13709
13710template<typename Derived>
13713 return getDerived().TransformCallExpr(E);
13714}
13715
13716template<typename Derived>
13719 ExprResult ControllingExpr;
13720 TypeSourceInfo *ControllingType = nullptr;
13721 if (E->isExprPredicate())
13722 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13723 else
13724 ControllingType = getDerived().TransformType(E->getControllingType());
13725
13726 if (ControllingExpr.isInvalid() && !ControllingType)
13727 return ExprError();
13728
13729 SmallVector<Expr *, 4> AssocExprs;
13731 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13732 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13733 if (TSI) {
13734 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13735 if (!AssocType)
13736 return ExprError();
13737 AssocTypes.push_back(AssocType);
13738 } else {
13739 AssocTypes.push_back(nullptr);
13740 }
13741
13742 ExprResult AssocExpr =
13743 getDerived().TransformExpr(Assoc.getAssociationExpr());
13744 if (AssocExpr.isInvalid())
13745 return ExprError();
13746 AssocExprs.push_back(AssocExpr.get());
13747 }
13748
13749 if (!ControllingType)
13750 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13751 E->getDefaultLoc(),
13752 E->getRParenLoc(),
13753 ControllingExpr.get(),
13754 AssocTypes,
13755 AssocExprs);
13756 return getDerived().RebuildGenericSelectionExpr(
13757 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13758 ControllingType, AssocTypes, AssocExprs);
13759}
13760
13761template<typename Derived>
13764 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13765 if (SubExpr.isInvalid())
13766 return ExprError();
13767
13768 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13769 return E;
13770
13771 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13772 E->getRParen());
13773}
13774
13775/// The operand of a unary address-of operator has special rules: it's
13776/// allowed to refer to a non-static member of a class even if there's no 'this'
13777/// object available.
13778template<typename Derived>
13781 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13782 return getDerived().TransformDependentScopeDeclRefExpr(
13783 DRE, /*IsAddressOfOperand=*/true, nullptr);
13784 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13785 return getDerived().TransformUnresolvedLookupExpr(
13786 ULE, /*IsAddressOfOperand=*/true);
13787 else
13788 return getDerived().TransformExpr(E);
13789}
13790
13791template<typename Derived>
13794 ExprResult SubExpr;
13795 if (E->getOpcode() == UO_AddrOf)
13796 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13797 else
13798 SubExpr = TransformExpr(E->getSubExpr());
13799 if (SubExpr.isInvalid())
13800 return ExprError();
13801
13802 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13803 return E;
13804
13805 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13806 E->getOpcode(),
13807 SubExpr.get());
13808}
13809
13810template<typename Derived>
13812TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13813 // Transform the type.
13814 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13815 if (!Type)
13816 return ExprError();
13817
13818 // Transform all of the components into a Designation similar to what the
13819 // parser builds.
13820 // FIXME: It would be slightly more efficient in the non-dependent case to
13821 // just map FieldDecls, rather than requiring the rebuilder to look for
13822 // the fields again. However, __builtin_offsetof is rare enough in
13823 // template code that we don't care.
13824 bool ExprChanged = false;
13825 Designation Desig;
13826 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13827 const OffsetOfNode &ON = E->getComponent(I);
13828 switch (ON.getKind()) {
13829 case OffsetOfNode::Array: {
13830 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13831 ExprResult Index = getDerived().TransformExpr(FromIndex);
13832 if (Index.isInvalid())
13833 return ExprError();
13834
13835 ExprChanged = ExprChanged || Index.get() != FromIndex;
13836 Designator AD =
13837 Designator::CreateArrayDesignator(Index.get(), ON.getBeginLoc());
13838 AD.setRBracketLoc(ON.getEndLoc());
13839 Desig.AddDesignator(AD);
13840 break;
13841 }
13842
13845 const IdentifierInfo *Name = ON.getFieldName();
13846 if (!Name)
13847 continue;
13848 // The leading designator has no '.'; subsequent ones do.
13849 SourceLocation DotLoc =
13850 Desig.empty() ? SourceLocation() : ON.getBeginLoc();
13851 Desig.AddDesignator(
13852 Designator::CreateFieldDesignator(Name, DotLoc, ON.getEndLoc()));
13853 break;
13854 }
13855
13856 case OffsetOfNode::Base:
13857 // Will be recomputed during the rebuild.
13858 continue;
13859 }
13860 }
13861
13862 // If nothing changed, retain the existing expression.
13863 if (!getDerived().AlwaysRebuild() &&
13864 Type == E->getTypeSourceInfo() &&
13865 !ExprChanged)
13866 return E;
13867
13868 // Build a new offsetof expression.
13869 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type, Desig,
13870 E->getRParenLoc());
13871}
13872
13873template<typename Derived>
13876 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13877 "opaque value expression requires transformation");
13878 return E;
13879}
13880
13881template <typename Derived>
13884 bool Changed = false;
13885 for (Expr *C : E->subExpressions()) {
13886 ExprResult NewC = getDerived().TransformExpr(C);
13887 if (NewC.isInvalid())
13888 return ExprError();
13889 Children.push_back(NewC.get());
13890
13891 Changed |= NewC.get() != C;
13892 }
13893 if (!getDerived().AlwaysRebuild() && !Changed)
13894 return E;
13895 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13896 Children, E->getType());
13897}
13898
13899template<typename Derived>
13902 // Rebuild the syntactic form. The original syntactic form has
13903 // opaque-value expressions in it, so strip those away and rebuild
13904 // the result. This is a really awful way of doing this, but the
13905 // better solution (rebuilding the semantic expressions and
13906 // rebinding OVEs as necessary) doesn't work; we'd need
13907 // TreeTransform to not strip away implicit conversions.
13908 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13909 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13910 if (result.isInvalid()) return ExprError();
13911
13912 // If that gives us a pseudo-object result back, the pseudo-object
13913 // expression must have been an lvalue-to-rvalue conversion which we
13914 // should reapply.
13915 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13916 result = SemaRef.PseudoObject().checkRValue(result.get());
13917
13918 return result;
13919}
13920
13921template<typename Derived>
13925 if (E->isArgumentType()) {
13926 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13927
13928 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13929 if (!NewT)
13930 return ExprError();
13931
13932 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13933 return E;
13934
13935 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13936 E->getKind(),
13937 E->getSourceRange());
13938 }
13939
13940 // C++0x [expr.sizeof]p1:
13941 // The operand is either an expression, which is an unevaluated operand
13942 // [...]
13946
13947 // Try to recover if we have something like sizeof(T::X) where X is a type.
13948 // Notably, there must be *exactly* one set of parens if X is a type.
13949 TypeSourceInfo *RecoveryTSI = nullptr;
13950 ExprResult SubExpr;
13951 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13952 if (auto *DRE =
13953 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13954 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13955 PE, DRE, false, &RecoveryTSI);
13956 else
13957 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13958
13959 if (RecoveryTSI) {
13960 return getDerived().RebuildUnaryExprOrTypeTrait(
13961 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13962 } else if (SubExpr.isInvalid())
13963 return ExprError();
13964
13965 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13966 return E;
13967
13968 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13969 E->getOperatorLoc(),
13970 E->getKind(),
13971 E->getSourceRange());
13972}
13973
13974template<typename Derived>
13977 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13978 if (LHS.isInvalid())
13979 return ExprError();
13980
13981 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13982 if (RHS.isInvalid())
13983 return ExprError();
13984
13985
13986 if (!getDerived().AlwaysRebuild() &&
13987 LHS.get() == E->getLHS() &&
13988 RHS.get() == E->getRHS())
13989 return E;
13990
13991 return getDerived().RebuildArraySubscriptExpr(
13992 LHS.get(),
13993 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13994}
13995
13996template <typename Derived>
13999 ExprResult Base = getDerived().TransformExpr(E->getBase());
14000 if (Base.isInvalid())
14001 return ExprError();
14002
14003 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
14004 if (RowIdx.isInvalid())
14005 return ExprError();
14006
14007 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
14008 RowIdx.get() == E->getRowIdx())
14009 return E;
14010
14011 return getDerived().RebuildMatrixSingleSubscriptExpr(Base.get(), RowIdx.get(),
14012 E->getRBracketLoc());
14013}
14014
14015template <typename Derived>
14018 ExprResult Base = getDerived().TransformExpr(E->getBase());
14019 if (Base.isInvalid())
14020 return ExprError();
14021
14022 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
14023 if (RowIdx.isInvalid())
14024 return ExprError();
14025
14026 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
14027 if (ColumnIdx.isInvalid())
14028 return ExprError();
14029
14030 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
14031 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
14032 return E;
14033
14034 return getDerived().RebuildMatrixSubscriptExpr(
14035 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
14036}
14037
14038template <typename Derived>
14041 ExprResult Base = getDerived().TransformExpr(E->getBase());
14042 if (Base.isInvalid())
14043 return ExprError();
14044
14045 ExprResult LowerBound;
14046 if (E->getLowerBound()) {
14047 LowerBound = getDerived().TransformExpr(E->getLowerBound());
14048 if (LowerBound.isInvalid())
14049 return ExprError();
14050 }
14051
14052 ExprResult Length;
14053 if (E->getLength()) {
14054 Length = getDerived().TransformExpr(E->getLength());
14055 if (Length.isInvalid())
14056 return ExprError();
14057 }
14058
14059 ExprResult Stride;
14060 if (E->isOMPArraySection()) {
14061 if (Expr *Str = E->getStride()) {
14062 Stride = getDerived().TransformExpr(Str);
14063 if (Stride.isInvalid())
14064 return ExprError();
14065 }
14066 }
14067
14068 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
14069 LowerBound.get() == E->getLowerBound() &&
14070 Length.get() == E->getLength() &&
14071 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
14072 return E;
14073
14074 return getDerived().RebuildArraySectionExpr(
14075 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
14076 LowerBound.get(), E->getColonLocFirst(),
14077 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
14078 Length.get(), Stride.get(), E->getRBracketLoc());
14079}
14080
14081template <typename Derived>
14084 ExprResult Base = getDerived().TransformExpr(E->getBase());
14085 if (Base.isInvalid())
14086 return ExprError();
14087
14089 bool ErrorFound = false;
14090 for (Expr *Dim : E->getDimensions()) {
14091 ExprResult DimRes = getDerived().TransformExpr(Dim);
14092 if (DimRes.isInvalid()) {
14093 ErrorFound = true;
14094 continue;
14095 }
14096 Dims.push_back(DimRes.get());
14097 }
14098
14099 if (ErrorFound)
14100 return ExprError();
14101 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
14102 E->getRParenLoc(), Dims,
14103 E->getBracketsRanges());
14104}
14105
14106template <typename Derived>
14109 unsigned NumIterators = E->numOfIterators();
14111
14112 bool ErrorFound = false;
14113 bool NeedToRebuild = getDerived().AlwaysRebuild();
14114 for (unsigned I = 0; I < NumIterators; ++I) {
14115 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
14116 Data[I].DeclIdent = D->getIdentifier();
14117 Data[I].DeclIdentLoc = D->getLocation();
14118 if (D->getLocation() == D->getBeginLoc()) {
14119 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
14120 "Implicit type must be int.");
14121 } else {
14122 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
14123 QualType DeclTy = getDerived().TransformType(D->getType());
14124 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
14125 }
14126 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
14127 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
14128 ExprResult End = getDerived().TransformExpr(Range.End);
14129 ExprResult Step = getDerived().TransformExpr(Range.Step);
14130 ErrorFound = ErrorFound ||
14131 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
14132 !Data[I].Type.get().isNull())) ||
14133 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
14134 if (ErrorFound)
14135 continue;
14136 Data[I].Range.Begin = Begin.get();
14137 Data[I].Range.End = End.get();
14138 Data[I].Range.Step = Step.get();
14139 Data[I].AssignLoc = E->getAssignLoc(I);
14140 Data[I].ColonLoc = E->getColonLoc(I);
14141 Data[I].SecColonLoc = E->getSecondColonLoc(I);
14142 NeedToRebuild =
14143 NeedToRebuild ||
14144 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
14145 D->getType().getTypePtrOrNull()) ||
14146 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
14147 Range.Step != Data[I].Range.Step;
14148 }
14149 if (ErrorFound)
14150 return ExprError();
14151 if (!NeedToRebuild)
14152 return E;
14153
14154 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
14155 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
14156 if (!Res.isUsable())
14157 return Res;
14158 auto *IE = cast<OMPIteratorExpr>(Res.get());
14159 for (unsigned I = 0; I < NumIterators; ++I)
14160 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
14161 IE->getIteratorDecl(I));
14162 return Res;
14163}
14164
14165template<typename Derived>
14168 // Transform the callee.
14169 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14170 if (Callee.isInvalid())
14171 return ExprError();
14172
14173 // Transform arguments.
14174 bool ArgChanged = false;
14176 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14177 &ArgChanged))
14178 return ExprError();
14179
14180 if (!getDerived().AlwaysRebuild() &&
14181 Callee.get() == E->getCallee() &&
14182 !ArgChanged)
14183 return SemaRef.MaybeBindToTemporary(E);
14184
14185 // FIXME: Wrong source location information for the '('.
14186 SourceLocation FakeLParenLoc
14187 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14188
14189 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14190 if (E->hasStoredFPFeatures()) {
14191 FPOptionsOverride NewOverrides = E->getFPFeatures();
14192 getSema().CurFPFeatures =
14193 NewOverrides.applyOverrides(getSema().getLangOpts());
14194 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14195 }
14196
14197 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14198 Args,
14199 E->getRParenLoc());
14200}
14201
14202template<typename Derived>
14205 ExprResult Base = getDerived().TransformExpr(E->getBase());
14206 if (Base.isInvalid())
14207 return ExprError();
14208
14209 NestedNameSpecifierLoc QualifierLoc;
14210 if (E->hasQualifier()) {
14211 QualifierLoc
14212 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
14213
14214 if (!QualifierLoc)
14215 return ExprError();
14216 }
14217 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
14218
14220 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
14221 E->getMemberDecl()));
14222 if (!Member)
14223 return ExprError();
14224
14225 NamedDecl *FoundDecl = E->getFoundDecl();
14226 if (FoundDecl == E->getMemberDecl()) {
14227 FoundDecl = Member;
14228 } else {
14229 FoundDecl = cast_or_null<NamedDecl>(
14230 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
14231 if (!FoundDecl)
14232 return ExprError();
14233 }
14234
14235 if (!getDerived().AlwaysRebuild() &&
14236 Base.get() == E->getBase() &&
14237 QualifierLoc == E->getQualifierLoc() &&
14238 Member == E->getMemberDecl() &&
14239 FoundDecl == E->getFoundDecl() &&
14240 !E->hasExplicitTemplateArgs()) {
14241
14242 // Skip for member expression of (this->f), rebuilt thisi->f is needed
14243 // for Openmp where the field need to be privatizized in the case.
14244 if (!(isa<CXXThisExpr>(E->getBase()) &&
14245 getSema().OpenMP().isOpenMPRebuildMemberExpr(
14247 // Mark it referenced in the new context regardless.
14248 // FIXME: this is a bit instantiation-specific.
14249 SemaRef.MarkMemberReferenced(E);
14250 return E;
14251 }
14252 }
14253
14254 TemplateArgumentListInfo TransArgs;
14255 if (E->hasExplicitTemplateArgs()) {
14256 TransArgs.setLAngleLoc(E->getLAngleLoc());
14257 TransArgs.setRAngleLoc(E->getRAngleLoc());
14258 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
14259 E->getNumTemplateArgs(),
14260 TransArgs))
14261 return ExprError();
14262 }
14263
14264 // FIXME: Bogus source location for the operator
14265 SourceLocation FakeOperatorLoc =
14266 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
14267
14268 // FIXME: to do this check properly, we will need to preserve the
14269 // first-qualifier-in-scope here, just in case we had a dependent
14270 // base (and therefore couldn't do the check) and a
14271 // nested-name-qualifier (and therefore could do the lookup).
14272 NamedDecl *FirstQualifierInScope = nullptr;
14273 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
14274 if (MemberNameInfo.getName()) {
14275 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
14276 if (!MemberNameInfo.getName())
14277 return ExprError();
14278 }
14279
14280 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
14281 E->isArrow(),
14282 QualifierLoc,
14283 TemplateKWLoc,
14284 MemberNameInfo,
14285 Member,
14286 FoundDecl,
14287 (E->hasExplicitTemplateArgs()
14288 ? &TransArgs : nullptr),
14289 FirstQualifierInScope);
14290}
14291
14292template<typename Derived>
14295 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14296 if (LHS.isInvalid())
14297 return ExprError();
14298
14299 ExprResult RHS =
14300 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
14301 if (RHS.isInvalid())
14302 return ExprError();
14303
14304 if (!getDerived().AlwaysRebuild() &&
14305 LHS.get() == E->getLHS() &&
14306 RHS.get() == E->getRHS())
14307 return E;
14308
14309 if (E->isCompoundAssignmentOp())
14310 // FPFeatures has already been established from trailing storage
14311 return getDerived().RebuildBinaryOperator(
14312 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
14313 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14314 FPOptionsOverride NewOverrides(E->getFPFeatures());
14315 getSema().CurFPFeatures =
14316 NewOverrides.applyOverrides(getSema().getLangOpts());
14317 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14318 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
14319 LHS.get(), RHS.get());
14320}
14321
14322template <typename Derived>
14325 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
14326
14327 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
14328 if (LHS.isInvalid())
14329 return ExprError();
14330
14331 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
14332 if (RHS.isInvalid())
14333 return ExprError();
14334
14335 // Extract the already-resolved callee declarations so that we can restrict
14336 // ourselves to using them as the unqualified lookup results when rebuilding.
14337 UnresolvedSet<2> UnqualLookups;
14338 bool ChangedAnyLookups = false;
14339 Expr *PossibleBinOps[] = {E->getSemanticForm(),
14340 const_cast<Expr *>(Decomp.InnerBinOp)};
14341 for (Expr *PossibleBinOp : PossibleBinOps) {
14342 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
14343 if (!Op)
14344 continue;
14345 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
14346 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
14347 continue;
14348
14349 // Transform the callee in case we built a call to a local extern
14350 // declaration.
14351 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
14352 E->getOperatorLoc(), Callee->getFoundDecl()));
14353 if (!Found)
14354 return ExprError();
14355 if (Found != Callee->getFoundDecl())
14356 ChangedAnyLookups = true;
14357 UnqualLookups.addDecl(Found);
14358 }
14359
14360 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
14361 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
14362 // Mark all functions used in the rewrite as referenced. Note that when
14363 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
14364 // function calls, and/or there might be a user-defined conversion sequence
14365 // applied to the operands of the <.
14366 // FIXME: this is a bit instantiation-specific.
14367 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
14368 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
14369 return E;
14370 }
14371
14372 return getDerived().RebuildCXXRewrittenBinaryOperator(
14373 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
14374}
14375
14376template<typename Derived>
14380 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14381 FPOptionsOverride NewOverrides(E->getFPFeatures());
14382 getSema().CurFPFeatures =
14383 NewOverrides.applyOverrides(getSema().getLangOpts());
14384 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14385 return getDerived().TransformBinaryOperator(E);
14386}
14387
14388template<typename Derived>
14391 // Just rebuild the common and RHS expressions and see whether we
14392 // get any changes.
14393
14394 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
14395 if (commonExpr.isInvalid())
14396 return ExprError();
14397
14398 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
14399 if (rhs.isInvalid())
14400 return ExprError();
14401
14402 if (!getDerived().AlwaysRebuild() &&
14403 commonExpr.get() == e->getCommon() &&
14404 rhs.get() == e->getFalseExpr())
14405 return e;
14406
14407 return getDerived().RebuildConditionalOperator(commonExpr.get(),
14408 e->getQuestionLoc(),
14409 nullptr,
14410 e->getColonLoc(),
14411 rhs.get());
14412}
14413
14414template<typename Derived>
14417 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14418 if (Cond.isInvalid())
14419 return ExprError();
14420
14421 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14422 if (LHS.isInvalid())
14423 return ExprError();
14424
14425 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14426 if (RHS.isInvalid())
14427 return ExprError();
14428
14429 if (!getDerived().AlwaysRebuild() &&
14430 Cond.get() == E->getCond() &&
14431 LHS.get() == E->getLHS() &&
14432 RHS.get() == E->getRHS())
14433 return E;
14434
14435 return getDerived().RebuildConditionalOperator(Cond.get(),
14436 E->getQuestionLoc(),
14437 LHS.get(),
14438 E->getColonLoc(),
14439 RHS.get());
14440}
14441
14442template<typename Derived>
14445 // Implicit casts are eliminated during transformation, since they
14446 // will be recomputed by semantic analysis after transformation.
14447 return getDerived().TransformExpr(E->getSubExprAsWritten());
14448}
14449
14450template<typename Derived>
14453 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14454 if (!Type)
14455 return ExprError();
14456
14457 ExprResult SubExpr
14458 = getDerived().TransformExpr(E->getSubExprAsWritten());
14459 if (SubExpr.isInvalid())
14460 return ExprError();
14461
14462 if (!getDerived().AlwaysRebuild() &&
14463 Type == E->getTypeInfoAsWritten() &&
14464 SubExpr.get() == E->getSubExpr())
14465 return E;
14466
14467 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
14468 Type,
14469 E->getRParenLoc(),
14470 SubExpr.get());
14471}
14472
14473template<typename Derived>
14476 TypeSourceInfo *OldT = E->getTypeSourceInfo();
14477 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
14478 if (!NewT)
14479 return ExprError();
14480
14481 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
14482 if (Init.isInvalid())
14483 return ExprError();
14484
14485 if (!getDerived().AlwaysRebuild() &&
14486 OldT == NewT &&
14487 Init.get() == E->getInitializer())
14488 return SemaRef.MaybeBindToTemporary(E);
14489
14490 // Note: the expression type doesn't necessarily match the
14491 // type-as-written, but that's okay, because it should always be
14492 // derivable from the initializer.
14493
14494 return getDerived().RebuildCompoundLiteralExpr(
14495 E->getLParenLoc(), NewT,
14496 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
14497}
14498
14499template<typename Derived>
14502 ExprResult Base = getDerived().TransformExpr(E->getBase());
14503 if (Base.isInvalid())
14504 return ExprError();
14505
14506 if (!getDerived().AlwaysRebuild() &&
14507 Base.get() == E->getBase())
14508 return E;
14509
14510 // FIXME: Bad source location
14511 SourceLocation FakeOperatorLoc =
14512 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14513 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14514 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
14515 E->getAccessor());
14516}
14517
14518template <typename Derived>
14521 ExprResult Base = getDerived().TransformExpr(E->getBase());
14522 if (Base.isInvalid())
14523 return ExprError();
14524
14525 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase())
14526 return E;
14527
14528 // FIXME: Bad source location
14529 SourceLocation FakeOperatorLoc =
14530 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14531 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14532 Base.get(), FakeOperatorLoc, /*isArrow*/ false, E->getAccessorLoc(),
14533 E->getAccessor());
14534}
14535
14536template<typename Derived>
14539 if (InitListExpr *Syntactic = E->getSyntacticForm())
14540 E = Syntactic;
14541
14542 bool InitChanged = false;
14543
14546
14548 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
14549 Inits, &InitChanged))
14550 return ExprError();
14551
14552 if (!getDerived().AlwaysRebuild() && !InitChanged) {
14553 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
14554 // in some cases. We can't reuse it in general, because the syntactic and
14555 // semantic forms are linked, and we can't know that semantic form will
14556 // match even if the syntactic form does.
14557 }
14558
14559 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
14560 E->getRBraceLoc(), E->isExplicit());
14561}
14562
14563template<typename Derived>
14566 Designation Desig;
14567
14568 // transform the initializer value
14569 ExprResult Init = getDerived().TransformExpr(E->getInit());
14570 if (Init.isInvalid())
14571 return ExprError();
14572
14573 // transform the designators.
14574 SmallVector<Expr*, 4> ArrayExprs;
14575 bool ExprChanged = false;
14576 for (const DesignatedInitExpr::Designator &D : E->designators()) {
14577 if (D.isFieldDesignator()) {
14578 if (D.getFieldDecl()) {
14579 FieldDecl *Field = cast_or_null<FieldDecl>(
14580 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
14581 if (Field != D.getFieldDecl())
14582 // Rebuild the expression when the transformed FieldDecl is
14583 // different to the already assigned FieldDecl.
14584 ExprChanged = true;
14585 if (Field->isAnonymousStructOrUnion())
14586 continue;
14587 } else {
14588 // Ensure that the designator expression is rebuilt when there isn't
14589 // a resolved FieldDecl in the designator as we don't want to assign
14590 // a FieldDecl to a pattern designator that will be instantiated again.
14591 ExprChanged = true;
14592 }
14593 Desig.AddDesignator(Designator::CreateFieldDesignator(
14594 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
14595 continue;
14596 }
14597
14598 if (D.isArrayDesignator()) {
14599 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
14600 if (Index.isInvalid())
14601 return ExprError();
14602
14603 Desig.AddDesignator(
14604 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
14605
14606 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
14607 ArrayExprs.push_back(Index.get());
14608 continue;
14609 }
14610
14611 assert(D.isArrayRangeDesignator() && "New kind of designator?");
14612 ExprResult Start
14613 = getDerived().TransformExpr(E->getArrayRangeStart(D));
14614 if (Start.isInvalid())
14615 return ExprError();
14616
14617 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
14618 if (End.isInvalid())
14619 return ExprError();
14620
14621 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
14622 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
14623
14624 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
14625 End.get() != E->getArrayRangeEnd(D);
14626
14627 ArrayExprs.push_back(Start.get());
14628 ArrayExprs.push_back(End.get());
14629 }
14630
14631 if (!getDerived().AlwaysRebuild() &&
14632 Init.get() == E->getInit() &&
14633 !ExprChanged)
14634 return E;
14635
14636 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14637 E->getEqualOrColonLoc(),
14638 E->usesGNUSyntax(), Init.get());
14639}
14640
14641// Seems that if TransformInitListExpr() only works on the syntactic form of an
14642// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14643template<typename Derived>
14647 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14648 "initializer");
14649 return ExprError();
14650}
14651
14652template<typename Derived>
14655 NoInitExpr *E) {
14656 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14657 return ExprError();
14658}
14659
14660template<typename Derived>
14663 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14664 return ExprError();
14665}
14666
14667template<typename Derived>
14670 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14671 return ExprError();
14672}
14673
14674template<typename Derived>
14678 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14679
14680 // FIXME: Will we ever have proper type location here? Will we actually
14681 // need to transform the type?
14682 QualType T = getDerived().TransformType(E->getType());
14683 if (T.isNull())
14684 return ExprError();
14685
14686 if (!getDerived().AlwaysRebuild() &&
14687 T == E->getType())
14688 return E;
14689
14690 return getDerived().RebuildImplicitValueInitExpr(T);
14691}
14692
14693template<typename Derived>
14696 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14697 if (!TInfo)
14698 return ExprError();
14699
14700 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14701 if (SubExpr.isInvalid())
14702 return ExprError();
14703
14704 if (!getDerived().AlwaysRebuild() &&
14705 TInfo == E->getWrittenTypeInfo() &&
14706 SubExpr.get() == E->getSubExpr())
14707 return E;
14708
14709 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14710 TInfo, E->getRParenLoc());
14711}
14712
14713template<typename Derived>
14716 bool ArgumentChanged = false;
14718 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14719 &ArgumentChanged))
14720 return ExprError();
14721
14722 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14723 Inits,
14724 E->getRParenLoc());
14725}
14726
14727/// Transform an address-of-label expression.
14728///
14729/// By default, the transformation of an address-of-label expression always
14730/// rebuilds the expression, so that the label identifier can be resolved to
14731/// the corresponding label statement by semantic analysis.
14732template<typename Derived>
14735 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14736 E->getLabel());
14737 if (!LD)
14738 return ExprError();
14739
14740 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14741 cast<LabelDecl>(LD));
14742}
14743
14744template<typename Derived>
14747 SemaRef.ActOnStartStmtExpr();
14748 StmtResult SubStmt
14749 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14750 if (SubStmt.isInvalid()) {
14751 SemaRef.ActOnStmtExprError();
14752 return ExprError();
14753 }
14754
14755 unsigned OldDepth = E->getTemplateDepth();
14756 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14757
14758 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14759 SubStmt.get() == E->getSubStmt()) {
14760 // Calling this an 'error' is unintuitive, but it does the right thing.
14761 SemaRef.ActOnStmtExprError();
14762 return SemaRef.MaybeBindToTemporary(E);
14763 }
14764
14765 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14766 E->getRParenLoc(), NewDepth);
14767}
14768
14769template<typename Derived>
14772 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14773 if (Cond.isInvalid())
14774 return ExprError();
14775
14776 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14777 if (LHS.isInvalid())
14778 return ExprError();
14779
14780 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14781 if (RHS.isInvalid())
14782 return ExprError();
14783
14784 if (!getDerived().AlwaysRebuild() &&
14785 Cond.get() == E->getCond() &&
14786 LHS.get() == E->getLHS() &&
14787 RHS.get() == E->getRHS())
14788 return E;
14789
14790 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14791 Cond.get(), LHS.get(), RHS.get(),
14792 E->getRParenLoc());
14793}
14794
14795template<typename Derived>
14798 return E;
14799}
14800
14801template<typename Derived>
14804 switch (E->getOperator()) {
14805 case OO_New:
14806 case OO_Delete:
14807 case OO_Array_New:
14808 case OO_Array_Delete:
14809 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14810
14811 case OO_Subscript:
14812 case OO_Call: {
14813 // This is a call to an object's operator().
14814 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14815
14816 // Transform the object itself.
14817 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14818 if (Object.isInvalid())
14819 return ExprError();
14820
14821 // FIXME: Poor location information. Also, if the location for the end of
14822 // the token is within a macro expansion, getLocForEndOfToken() will return
14823 // an invalid source location. If that happens and we have an otherwise
14824 // valid end location, use the valid one instead of the invalid one.
14825 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14826 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14827 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14828 FakeLParenLoc = EndLoc;
14829
14830 // Transform the call arguments.
14832 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14833 Args))
14834 return ExprError();
14835
14836 if (E->getOperator() == OO_Subscript)
14837 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14838 Args, E->getEndLoc());
14839
14840 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14841 E->getEndLoc());
14842 }
14843
14844#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14845 case OO_##Name: \
14846 break;
14847
14848#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14849#include "clang/Basic/OperatorKinds.def"
14850
14851 case OO_Conditional:
14852 llvm_unreachable("conditional operator is not actually overloadable");
14853
14854 case OO_None:
14856 llvm_unreachable("not an overloaded operator?");
14857 }
14858
14860 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14861 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14862 else
14863 First = getDerived().TransformExpr(E->getArg(0));
14864 if (First.isInvalid())
14865 return ExprError();
14866
14867 ExprResult Second;
14868 if (E->getNumArgs() == 2) {
14869 Second =
14870 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14871 if (Second.isInvalid())
14872 return ExprError();
14873 }
14874
14875 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14876 FPOptionsOverride NewOverrides(E->getFPFeatures());
14877 getSema().CurFPFeatures =
14878 NewOverrides.applyOverrides(getSema().getLangOpts());
14879 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14880
14881 Expr *Callee = E->getCallee();
14882 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14883 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14885 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14886 return ExprError();
14887
14888 return getDerived().RebuildCXXOperatorCallExpr(
14889 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14890 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14891 }
14892
14893 UnresolvedSet<1> Functions;
14894 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14895 Callee = ICE->getSubExprAsWritten();
14896 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14897 ValueDecl *VD = cast_or_null<ValueDecl>(
14898 getDerived().TransformDecl(DR->getLocation(), DR));
14899 if (!VD)
14900 return ExprError();
14901
14902 if (!isa<CXXMethodDecl>(VD))
14903 Functions.addDecl(VD);
14904
14905 return getDerived().RebuildCXXOperatorCallExpr(
14906 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14907 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14908}
14909
14910template<typename Derived>
14913 return getDerived().TransformCallExpr(E);
14914}
14915
14916template <typename Derived>
14918 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14919 getSema().CurContext != E->getParentContext();
14920
14921 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14922 return E;
14923
14924 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14925 E->getBeginLoc(), E->getEndLoc(),
14926 getSema().CurContext);
14927}
14928
14929template <typename Derived>
14931 return E;
14932}
14933
14934template<typename Derived>
14937 // Transform the callee.
14938 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14939 if (Callee.isInvalid())
14940 return ExprError();
14941
14942 // Transform exec config.
14943 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14944 if (EC.isInvalid())
14945 return ExprError();
14946
14947 // Transform arguments.
14948 bool ArgChanged = false;
14950 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14951 &ArgChanged))
14952 return ExprError();
14953
14954 if (!getDerived().AlwaysRebuild() &&
14955 Callee.get() == E->getCallee() &&
14956 !ArgChanged)
14957 return SemaRef.MaybeBindToTemporary(E);
14958
14959 // FIXME: Wrong source location information for the '('.
14960 SourceLocation FakeLParenLoc
14961 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14962 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14963 Args,
14964 E->getRParenLoc(), EC.get());
14965}
14966
14967template<typename Derived>
14970 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14971 if (!Type)
14972 return ExprError();
14973
14974 ExprResult SubExpr
14975 = getDerived().TransformExpr(E->getSubExprAsWritten());
14976 if (SubExpr.isInvalid())
14977 return ExprError();
14978
14979 if (!getDerived().AlwaysRebuild() &&
14980 Type == E->getTypeInfoAsWritten() &&
14981 SubExpr.get() == E->getSubExpr())
14982 return E;
14983 return getDerived().RebuildCXXNamedCastExpr(
14986 // FIXME. this should be '(' location
14987 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14988}
14989
14990template<typename Derived>
14993 TypeSourceInfo *TSI =
14994 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14995 if (!TSI)
14996 return ExprError();
14997
14998 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14999 if (Sub.isInvalid())
15000 return ExprError();
15001
15002 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
15003 Sub.get(), BCE->getEndLoc());
15004}
15005
15006template<typename Derived>
15008TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
15009 return getDerived().TransformCXXNamedCastExpr(E);
15010}
15011
15012template<typename Derived>
15015 return getDerived().TransformCXXNamedCastExpr(E);
15016}
15017
15018template<typename Derived>
15022 return getDerived().TransformCXXNamedCastExpr(E);
15023}
15024
15025template<typename Derived>
15028 return getDerived().TransformCXXNamedCastExpr(E);
15029}
15030
15031template<typename Derived>
15034 return getDerived().TransformCXXNamedCastExpr(E);
15035}
15036
15037template<typename Derived>
15042 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
15043 if (!Type)
15044 return ExprError();
15045
15046 ExprResult SubExpr
15047 = getDerived().TransformExpr(E->getSubExprAsWritten());
15048 if (SubExpr.isInvalid())
15049 return ExprError();
15050
15051 if (!getDerived().AlwaysRebuild() &&
15052 Type == E->getTypeInfoAsWritten() &&
15053 SubExpr.get() == E->getSubExpr())
15054 return E;
15055
15056 return getDerived().RebuildCXXFunctionalCastExpr(Type,
15057 E->getLParenLoc(),
15058 SubExpr.get(),
15059 E->getRParenLoc(),
15060 E->isListInitialization());
15061}
15062
15063template<typename Derived>
15066 if (E->isTypeOperand()) {
15067 TypeSourceInfo *TInfo
15068 = getDerived().TransformType(E->getTypeOperandSourceInfo());
15069 if (!TInfo)
15070 return ExprError();
15071
15072 if (!getDerived().AlwaysRebuild() &&
15073 TInfo == E->getTypeOperandSourceInfo())
15074 return E;
15075
15076 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
15077 TInfo, E->getEndLoc());
15078 }
15079
15080 // Typeid's operand is an unevaluated context, unless it's a polymorphic
15081 // type. We must not unilaterally enter unevaluated context here, as then
15082 // semantic processing can re-transform an already transformed operand.
15083 Expr *Op = E->getExprOperand();
15085 if (E->isGLValue()) {
15086 QualType OpType = Op->getType();
15087 if (auto *RD = OpType->getAsCXXRecordDecl()) {
15088 if (SemaRef.RequireCompleteType(E->getBeginLoc(), OpType,
15089 diag::err_incomplete_typeid))
15090 return ExprError();
15091
15092 if (RD->isPolymorphic())
15093 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
15094 }
15095 }
15096
15099
15100 ExprResult SubExpr = getDerived().TransformExpr(Op);
15101 if (SubExpr.isInvalid())
15102 return ExprError();
15103
15104 if (!getDerived().AlwaysRebuild() &&
15105 SubExpr.get() == E->getExprOperand())
15106 return E;
15107
15108 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
15109 SubExpr.get(), E->getEndLoc());
15110}
15111
15112template<typename Derived>
15115 if (E->isTypeOperand()) {
15116 TypeSourceInfo *TInfo
15117 = getDerived().TransformType(E->getTypeOperandSourceInfo());
15118 if (!TInfo)
15119 return ExprError();
15120
15121 if (!getDerived().AlwaysRebuild() &&
15122 TInfo == E->getTypeOperandSourceInfo())
15123 return E;
15124
15125 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
15126 TInfo, E->getEndLoc());
15127 }
15128
15131
15132 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
15133 if (SubExpr.isInvalid())
15134 return ExprError();
15135
15136 if (!getDerived().AlwaysRebuild() &&
15137 SubExpr.get() == E->getExprOperand())
15138 return E;
15139
15140 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
15141 SubExpr.get(), E->getEndLoc());
15142}
15143
15144template<typename Derived>
15147 return E;
15148}
15149
15150template<typename Derived>
15154 return E;
15155}
15156
15157template<typename Derived>
15160
15161 // In lambdas, the qualifiers of the type depends of where in
15162 // the call operator `this` appear, and we do not have a good way to
15163 // rebuild this information, so we transform the type.
15164 //
15165 // In other contexts, the type of `this` may be overrided
15166 // for type deduction, so we need to recompute it.
15167 //
15168 // Always recompute the type if we're in the body of a lambda, and
15169 // 'this' is dependent on a lambda's explicit object parameter; we
15170 // also need to always rebuild the expression in this case to clear
15171 // the flag.
15172 QualType T = [&]() {
15173 auto &S = getSema();
15174 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
15175 return S.getCurrentThisType();
15176 if (S.getCurLambda())
15177 return getDerived().TransformType(E->getType());
15178 return S.getCurrentThisType();
15179 }();
15180
15181 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
15182 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
15183 // Mark it referenced in the new context regardless.
15184 // FIXME: this is a bit instantiation-specific.
15185 getSema().MarkThisReferenced(E);
15186 return E;
15187 }
15188
15189 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
15190}
15191
15192template<typename Derived>
15195 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
15196 if (SubExpr.isInvalid())
15197 return ExprError();
15198
15199 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
15200
15201 if (!getDerived().AlwaysRebuild() &&
15202 SubExpr.get() == E->getSubExpr())
15203 return E;
15204
15205 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
15206 E->isThrownVariableInScope());
15207}
15208
15209template<typename Derived>
15212 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
15213 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
15214 if (!Param)
15215 return ExprError();
15216
15217 ExprResult InitRes;
15218 if (E->hasRewrittenInit()) {
15219 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
15220 if (InitRes.isInvalid())
15221 return ExprError();
15222 }
15223
15224 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
15225 E->getUsedContext() == SemaRef.CurContext &&
15226 InitRes.get() == E->getRewrittenExpr())
15227 return E;
15228
15229 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
15230 InitRes.get());
15231}
15232
15233template<typename Derived>
15236 FieldDecl *Field = cast_or_null<FieldDecl>(
15237 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
15238 if (!Field)
15239 return ExprError();
15240
15241 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
15242 E->getUsedContext() == SemaRef.CurContext)
15243 return E;
15244
15245 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
15246}
15247
15248template<typename Derived>
15252 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
15253 if (!T)
15254 return ExprError();
15255
15256 if (!getDerived().AlwaysRebuild() &&
15257 T == E->getTypeSourceInfo())
15258 return E;
15259
15260 return getDerived().RebuildCXXScalarValueInitExpr(T,
15261 /*FIXME:*/T->getTypeLoc().getEndLoc(),
15262 E->getRParenLoc());
15263}
15264
15265template<typename Derived>
15268 // Transform the type that we're allocating
15269 TypeSourceInfo *AllocTypeInfo =
15270 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
15271 if (!AllocTypeInfo)
15272 return ExprError();
15273
15274 // Transform the size of the array we're allocating (if any).
15275 std::optional<Expr *> ArraySize;
15276 if (E->isArray()) {
15277 ExprResult NewArraySize;
15278 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
15279 NewArraySize = getDerived().TransformExpr(*OldArraySize);
15280 if (NewArraySize.isInvalid())
15281 return ExprError();
15282 }
15283 ArraySize = NewArraySize.get();
15284 }
15285
15286 // Transform the placement arguments (if any).
15287 bool ArgumentChanged = false;
15288 SmallVector<Expr*, 8> PlacementArgs;
15289 if (getDerived().TransformExprs(E->getPlacementArgs(),
15290 E->getNumPlacementArgs(), true,
15291 PlacementArgs, &ArgumentChanged))
15292 return ExprError();
15293
15294 // Transform the initializer (if any).
15295 Expr *OldInit = E->getInitializer();
15296 ExprResult NewInit;
15297 if (OldInit)
15298 NewInit = getDerived().TransformInitializer(OldInit, true);
15299 if (NewInit.isInvalid())
15300 return ExprError();
15301
15302 // Transform new operator and delete operator.
15303 FunctionDecl *OperatorNew = nullptr;
15304 if (E->getOperatorNew()) {
15305 OperatorNew = cast_or_null<FunctionDecl>(
15306 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
15307 if (!OperatorNew)
15308 return ExprError();
15309 }
15310
15311 FunctionDecl *OperatorDelete = nullptr;
15312 if (E->getOperatorDelete()) {
15313 OperatorDelete = cast_or_null<FunctionDecl>(
15314 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
15315 if (!OperatorDelete)
15316 return ExprError();
15317 }
15318
15319 if (!getDerived().AlwaysRebuild() &&
15320 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
15321 ArraySize == E->getArraySize() &&
15322 NewInit.get() == OldInit &&
15323 OperatorNew == E->getOperatorNew() &&
15324 OperatorDelete == E->getOperatorDelete() &&
15325 !ArgumentChanged) {
15326 // Mark any declarations we need as referenced.
15327 // FIXME: instantiation-specific.
15328 if (OperatorNew)
15329 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
15330 if (OperatorDelete)
15331 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
15332
15333 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
15334 QualType ElementType
15335 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
15336 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
15338 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
15339 }
15340 }
15341
15342 return E;
15343 }
15344
15345 QualType AllocType = AllocTypeInfo->getType();
15346 if (!ArraySize) {
15347 // If no array size was specified, but the new expression was
15348 // instantiated with an array type (e.g., "new T" where T is
15349 // instantiated with "int[4]"), extract the outer bound from the
15350 // array type as our array size. We do this with constant and
15351 // dependently-sized array types.
15352 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
15353 if (!ArrayT) {
15354 // Do nothing
15355 } else if (const ConstantArrayType *ConsArrayT
15356 = dyn_cast<ConstantArrayType>(ArrayT)) {
15357 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
15358 SemaRef.Context.getSizeType(),
15359 /*FIXME:*/ E->getBeginLoc());
15360 AllocType = ConsArrayT->getElementType();
15361 } else if (const DependentSizedArrayType *DepArrayT
15362 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
15363 if (DepArrayT->getSizeExpr()) {
15364 ArraySize = DepArrayT->getSizeExpr();
15365 AllocType = DepArrayT->getElementType();
15366 }
15367 }
15368 }
15369
15370 return getDerived().RebuildCXXNewExpr(
15371 E->getBeginLoc(), E->isGlobalNew(),
15372 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
15373 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
15374 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
15375}
15376
15377template<typename Derived>
15380 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
15381 if (Operand.isInvalid())
15382 return ExprError();
15383
15384 // Transform the delete operator, if known.
15385 FunctionDecl *OperatorDelete = nullptr;
15386 if (E->getOperatorDelete()) {
15387 OperatorDelete = cast_or_null<FunctionDecl>(
15388 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
15389 if (!OperatorDelete)
15390 return ExprError();
15391 }
15392
15393 if (!getDerived().AlwaysRebuild() &&
15394 Operand.get() == E->getArgument() &&
15395 OperatorDelete == E->getOperatorDelete()) {
15396 // Mark any declarations we need as referenced.
15397 // FIXME: instantiation-specific.
15398 if (OperatorDelete)
15399 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
15400
15401 if (!E->getArgument()->isTypeDependent()) {
15403 E->getDestroyedType());
15404 if (auto *Record = Destroyed->getAsCXXRecordDecl())
15405 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15406 SemaRef.LookupDestructor(Record));
15407 }
15408
15409 return E;
15410 }
15411
15412 return getDerived().RebuildCXXDeleteExpr(
15413 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
15414}
15415
15416template<typename Derived>
15420 ExprResult Base = getDerived().TransformExpr(E->getBase());
15421 if (Base.isInvalid())
15422 return ExprError();
15423
15424 ParsedType ObjectTypePtr;
15425 bool MayBePseudoDestructor = false;
15426 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
15427 E->getOperatorLoc(),
15428 E->isArrow()? tok::arrow : tok::period,
15429 ObjectTypePtr,
15430 MayBePseudoDestructor);
15431 if (Base.isInvalid())
15432 return ExprError();
15433
15434 QualType ObjectType = ObjectTypePtr.get();
15435 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
15436 if (QualifierLoc) {
15437 QualifierLoc
15438 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
15439 if (!QualifierLoc)
15440 return ExprError();
15441 }
15442 CXXScopeSpec SS;
15443 SS.Adopt(QualifierLoc);
15444
15446 if (E->getDestroyedTypeInfo()) {
15447 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
15448 E->getDestroyedTypeInfo(), ObjectType,
15449 /*FirstQualifierInScope=*/nullptr);
15450 if (!DestroyedTypeInfo)
15451 return ExprError();
15452 Destroyed = DestroyedTypeInfo;
15453 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
15454 // We aren't likely to be able to resolve the identifier down to a type
15455 // now anyway, so just retain the identifier.
15456 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
15457 E->getDestroyedTypeLoc());
15458 } else {
15459 // Look for a destructor known with the given name.
15460 ParsedType T = SemaRef.getDestructorName(
15461 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
15462 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
15463 if (!T)
15464 return ExprError();
15465
15466 Destroyed
15468 E->getDestroyedTypeLoc());
15469 }
15470
15471 TypeSourceInfo *ScopeTypeInfo = nullptr;
15472 if (E->getScopeTypeInfo()) {
15473 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
15474 E->getScopeTypeInfo(), ObjectType, nullptr);
15475 if (!ScopeTypeInfo)
15476 return ExprError();
15477 }
15478
15479 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
15480 E->getOperatorLoc(),
15481 E->isArrow(),
15482 SS,
15483 ScopeTypeInfo,
15484 E->getColonColonLoc(),
15485 E->getTildeLoc(),
15486 Destroyed);
15487}
15488
15489template <typename Derived>
15491 bool RequiresADL,
15492 LookupResult &R) {
15493 // Transform all the decls.
15494 bool AllEmptyPacks = true;
15495 for (auto *OldD : Old->decls()) {
15496 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
15497 if (!InstD) {
15498 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
15499 // This can happen because of dependent hiding.
15500 if (isa<UsingShadowDecl>(OldD))
15501 continue;
15502 else {
15503 R.clear();
15504 return true;
15505 }
15506 }
15507
15508 // Expand using pack declarations.
15509 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
15510 ArrayRef<NamedDecl*> Decls = SingleDecl;
15511 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
15512 Decls = UPD->expansions();
15513
15514 // Expand using declarations.
15515 for (auto *D : Decls) {
15516 if (auto *UD = dyn_cast<UsingDecl>(D)) {
15517 for (auto *SD : UD->shadows())
15518 R.addDecl(SD);
15519 } else {
15520 R.addDecl(D);
15521 }
15522 }
15523
15524 AllEmptyPacks &= Decls.empty();
15525 }
15526
15527 // C++ [temp.res]/8.4.2:
15528 // The program is ill-formed, no diagnostic required, if [...] lookup for
15529 // a name in the template definition found a using-declaration, but the
15530 // lookup in the corresponding scope in the instantiation odoes not find
15531 // any declarations because the using-declaration was a pack expansion and
15532 // the corresponding pack is empty
15533 if (AllEmptyPacks && !RequiresADL) {
15534 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
15535 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
15536 return true;
15537 }
15538
15539 // Resolve a kind, but don't do any further analysis. If it's
15540 // ambiguous, the callee needs to deal with it.
15541 R.resolveKind();
15542
15543 if (Old->hasTemplateKeyword() && !R.empty()) {
15544 NamedDecl *FoundDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
15545 getSema().FilterAcceptableTemplateNames(R,
15546 /*AllowFunctionTemplates=*/true,
15547 /*AllowDependent=*/true);
15548 if (R.empty()) {
15549 // If a 'template' keyword was used, a lookup that finds only non-template
15550 // names is an error.
15551 getSema().Diag(R.getNameLoc(),
15552 diag::err_template_kw_refers_to_non_template)
15553 << R.getLookupName() << Old->getQualifierLoc().getSourceRange()
15554 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
15555 getSema().Diag(FoundDecl->getLocation(),
15556 diag::note_template_kw_refers_to_non_template)
15557 << R.getLookupName();
15558 return true;
15559 }
15560 }
15561
15562 return false;
15563}
15564
15565template <typename Derived>
15570
15571template <typename Derived>
15574 bool IsAddressOfOperand) {
15575 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
15577
15578 // Transform the declaration set.
15579 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
15580 return ExprError();
15581
15582 // Rebuild the nested-name qualifier, if present.
15583 CXXScopeSpec SS;
15584 if (Old->getQualifierLoc()) {
15585 NestedNameSpecifierLoc QualifierLoc
15586 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
15587 if (!QualifierLoc)
15588 return ExprError();
15589
15590 SS.Adopt(QualifierLoc);
15591 }
15592
15593 if (Old->getNamingClass()) {
15594 CXXRecordDecl *NamingClass
15595 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
15596 Old->getNameLoc(),
15597 Old->getNamingClass()));
15598 if (!NamingClass) {
15599 R.clear();
15600 return ExprError();
15601 }
15602
15603 R.setNamingClass(NamingClass);
15604 }
15605
15606 // Rebuild the template arguments, if any.
15607 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
15608 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
15609 if (Old->hasExplicitTemplateArgs() &&
15610 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15611 Old->getNumTemplateArgs(),
15612 TransArgs)) {
15613 R.clear();
15614 return ExprError();
15615 }
15616
15617 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
15618 // a non-static data member is named in an unevaluated operand, or when
15619 // a member is named in a dependent class scope function template explicit
15620 // specialization that is neither declared static nor with an explicit object
15621 // parameter.
15622 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
15623 return SemaRef.BuildPossibleImplicitMemberExpr(
15624 SS, TemplateKWLoc, R,
15625 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
15626 /*S=*/nullptr);
15627
15628 // If we have neither explicit template arguments, nor the template keyword,
15629 // it's a normal declaration name or member reference.
15630 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
15631 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
15632
15633 // If we have template arguments, then rebuild the template-id expression.
15634 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
15635 Old->requiresADL(), &TransArgs);
15636}
15637
15638template<typename Derived>
15641 bool ArgChanged = false;
15643 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15644 TypeSourceInfo *From = E->getArg(I);
15645 TypeLoc FromTL = From->getTypeLoc();
15646 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15647 TypeLocBuilder TLB;
15648 TLB.reserve(FromTL.getFullDataSize());
15649 QualType To = getDerived().TransformType(TLB, FromTL);
15650 if (To.isNull())
15651 return ExprError();
15652
15653 if (To == From->getType())
15654 Args.push_back(From);
15655 else {
15656 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15657 ArgChanged = true;
15658 }
15659 continue;
15660 }
15661
15662 ArgChanged = true;
15663
15664 // We have a pack expansion. Instantiate it.
15665 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15666 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15668 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15669
15670 // Determine whether the set of unexpanded parameter packs can and should
15671 // be expanded.
15672 bool Expand = true;
15673 bool RetainExpansion = false;
15674 UnsignedOrNone OrigNumExpansions =
15675 ExpansionTL.getTypePtr()->getNumExpansions();
15676 UnsignedOrNone NumExpansions = OrigNumExpansions;
15677 if (getDerived().TryExpandParameterPacks(
15678 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15679 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15680 RetainExpansion, NumExpansions))
15681 return ExprError();
15682
15683 if (!Expand) {
15684 // The transform has determined that we should perform a simple
15685 // transformation on the pack expansion, producing another pack
15686 // expansion.
15687 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15688
15689 TypeLocBuilder TLB;
15690 TLB.reserve(From->getTypeLoc().getFullDataSize());
15691
15692 QualType To = getDerived().TransformType(TLB, PatternTL);
15693 if (To.isNull())
15694 return ExprError();
15695
15696 To = getDerived().RebuildPackExpansionType(To,
15697 PatternTL.getSourceRange(),
15698 ExpansionTL.getEllipsisLoc(),
15699 NumExpansions);
15700 if (To.isNull())
15701 return ExprError();
15702
15703 PackExpansionTypeLoc ToExpansionTL
15704 = TLB.push<PackExpansionTypeLoc>(To);
15705 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15706 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15707 continue;
15708 }
15709
15710 // Expand the pack expansion by substituting for each argument in the
15711 // pack(s).
15712 for (unsigned I = 0; I != *NumExpansions; ++I) {
15713 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15714 TypeLocBuilder TLB;
15715 TLB.reserve(PatternTL.getFullDataSize());
15716 QualType To = getDerived().TransformType(TLB, PatternTL);
15717 if (To.isNull())
15718 return ExprError();
15719
15720 if (To->containsUnexpandedParameterPack()) {
15721 To = getDerived().RebuildPackExpansionType(To,
15722 PatternTL.getSourceRange(),
15723 ExpansionTL.getEllipsisLoc(),
15724 NumExpansions);
15725 if (To.isNull())
15726 return ExprError();
15727
15728 PackExpansionTypeLoc ToExpansionTL
15729 = TLB.push<PackExpansionTypeLoc>(To);
15730 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15731 }
15732
15733 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15734 }
15735
15736 if (!RetainExpansion)
15737 continue;
15738
15739 // If we're supposed to retain a pack expansion, do so by temporarily
15740 // forgetting the partially-substituted parameter pack.
15741 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15742
15743 TypeLocBuilder TLB;
15744 TLB.reserve(From->getTypeLoc().getFullDataSize());
15745
15746 QualType To = getDerived().TransformType(TLB, PatternTL);
15747 if (To.isNull())
15748 return ExprError();
15749
15750 To = getDerived().RebuildPackExpansionType(To,
15751 PatternTL.getSourceRange(),
15752 ExpansionTL.getEllipsisLoc(),
15753 NumExpansions);
15754 if (To.isNull())
15755 return ExprError();
15756
15757 PackExpansionTypeLoc ToExpansionTL
15758 = TLB.push<PackExpansionTypeLoc>(To);
15759 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15760 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15761 }
15762
15763 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15764 return E;
15765
15766 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15767 E->getEndLoc());
15768}
15769
15770template<typename Derived>
15774 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15775 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15776 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15777 Old->NumTemplateArgs, TransArgs))
15778 return ExprError();
15779
15780 return getDerived().RebuildConceptSpecializationExpr(
15781 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15782 E->getConceptNameInfo(), E->getFoundDecl(), E->getConceptDecl(),
15783 &TransArgs);
15784}
15785
15786template<typename Derived>
15789 SmallVector<ParmVarDecl*, 4> TransParams;
15790 SmallVector<QualType, 4> TransParamTypes;
15791 Sema::ExtParameterInfoBuilder ExtParamInfos;
15792
15793 // C++2a [expr.prim.req]p2
15794 // Expressions appearing within a requirement-body are unevaluated operands.
15798
15800 getSema().Context, getSema().CurContext,
15801 E->getBody()->getBeginLoc());
15802
15803 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15804
15805 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15806 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15807 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15808
15809 for (ParmVarDecl *Param : TransParams)
15810 if (Param)
15811 Param->setDeclContext(Body);
15812
15813 // On failure to transform, TransformRequiresTypeParams returns an expression
15814 // in the event that the transformation of the type params failed in some way.
15815 // It is expected that this will result in a 'not satisfied' Requires clause
15816 // when instantiating.
15817 if (!TypeParamResult.isUnset())
15818 return TypeParamResult;
15819
15821 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15822 TransReqs))
15823 return ExprError();
15824
15825 for (concepts::Requirement *Req : TransReqs) {
15826 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15827 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15828 ER->getReturnTypeRequirement()
15829 .getTypeConstraintTemplateParameterList()->getParam(0)
15830 ->setDeclContext(Body);
15831 }
15832 }
15833 }
15834
15835 return getDerived().RebuildRequiresExpr(
15836 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15837 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15838}
15839
15840template<typename Derived>
15844 for (concepts::Requirement *Req : Reqs) {
15845 concepts::Requirement *TransReq = nullptr;
15846 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15847 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15848 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15849 TransReq = getDerived().TransformExprRequirement(ExprReq);
15850 else
15851 TransReq = getDerived().TransformNestedRequirement(
15853 if (!TransReq)
15854 return true;
15855 Transformed.push_back(TransReq);
15856 }
15857 return false;
15858}
15859
15860template<typename Derived>
15864 if (Req->isSubstitutionFailure()) {
15865 if (getDerived().AlwaysRebuild())
15866 return getDerived().RebuildTypeRequirement(
15868 return Req;
15869 }
15870 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15871 if (!TransType)
15872 return nullptr;
15873 return getDerived().RebuildTypeRequirement(TransType);
15874}
15875
15876template<typename Derived>
15879 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15880 if (Req->isExprSubstitutionFailure())
15881 TransExpr = Req->getExprSubstitutionDiagnostic();
15882 else {
15883 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15884 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15885 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15886 if (TransExprRes.isInvalid())
15887 return nullptr;
15888 TransExpr = TransExprRes.get();
15889 }
15890
15891 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15892 const auto &RetReq = Req->getReturnTypeRequirement();
15893 if (RetReq.isEmpty())
15894 TransRetReq.emplace();
15895 else if (RetReq.isSubstitutionFailure())
15896 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15897 else if (RetReq.isTypeConstraint()) {
15898 TemplateParameterList *OrigTPL =
15899 RetReq.getTypeConstraintTemplateParameterList();
15901 getDerived().TransformTemplateParameterList(OrigTPL);
15902 if (!TPL)
15903 return nullptr;
15904 TransRetReq.emplace(TPL);
15905 }
15906 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15907 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15908 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15909 Req->getNoexceptLoc(),
15910 std::move(*TransRetReq));
15911 return getDerived().RebuildExprRequirement(
15913 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15914}
15915
15916template<typename Derived>
15920 if (Req->hasInvalidConstraint()) {
15921 if (getDerived().AlwaysRebuild())
15922 return getDerived().RebuildNestedRequirement(
15924 return Req;
15925 }
15926 ExprResult TransConstraint =
15927 getDerived().TransformExpr(Req->getConstraintExpr());
15928 if (TransConstraint.isInvalid())
15929 return nullptr;
15930 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15931}
15932
15933template<typename Derived>
15936 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15937 if (!T)
15938 return ExprError();
15939
15940 if (!getDerived().AlwaysRebuild() &&
15942 return E;
15943
15944 ExprResult SubExpr;
15945 {
15948 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15949 if (SubExpr.isInvalid())
15950 return ExprError();
15951 }
15952
15953 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15954 SubExpr.get(), E->getEndLoc());
15955}
15956
15957template<typename Derived>
15960 ExprResult SubExpr;
15961 {
15964 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15965 if (SubExpr.isInvalid())
15966 return ExprError();
15967
15968 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15969 return E;
15970 }
15971
15972 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15973 SubExpr.get(), E->getEndLoc());
15974}
15975
15976template <typename Derived>
15978 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15979 TypeSourceInfo **RecoveryTSI) {
15980 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15981 DRE, AddrTaken, RecoveryTSI);
15982
15983 // Propagate both errors and recovered types, which return ExprEmpty.
15984 if (!NewDRE.isUsable())
15985 return NewDRE;
15986
15987 // We got an expr, wrap it up in parens.
15988 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15989 return PE;
15990 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15991 PE->getRParen());
15992}
15993
15994template <typename Derived>
16000
16001template <typename Derived>
16003 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
16004 TypeSourceInfo **RecoveryTSI) {
16005 assert(E->getQualifierLoc());
16006 NestedNameSpecifierLoc QualifierLoc =
16007 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
16008 if (!QualifierLoc)
16009 return ExprError();
16010 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16011
16012 // TODO: If this is a conversion-function-id, verify that the
16013 // destination type name (if present) resolves the same way after
16014 // instantiation as it did in the local scope.
16015
16016 DeclarationNameInfo NameInfo =
16017 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
16018 if (!NameInfo.getName())
16019 return ExprError();
16020
16021 if (!E->hasExplicitTemplateArgs()) {
16022 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
16023 // Note: it is sufficient to compare the Name component of NameInfo:
16024 // if name has not changed, DNLoc has not changed either.
16025 NameInfo.getName() == E->getDeclName())
16026 return E;
16027
16028 return getDerived().RebuildDependentScopeDeclRefExpr(
16029 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
16030 IsAddressOfOperand, RecoveryTSI);
16031 }
16032
16033 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16034 if (getDerived().TransformTemplateArguments(
16035 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
16036 return ExprError();
16037
16038 return getDerived().RebuildDependentScopeDeclRefExpr(
16039 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
16040 RecoveryTSI);
16041}
16042
16043template<typename Derived>
16046 // CXXConstructExprs other than for list-initialization and
16047 // CXXTemporaryObjectExpr are always implicit, so when we have
16048 // a 1-argument construction we just transform that argument.
16049 if (getDerived().AllowSkippingCXXConstructExpr() &&
16050 ((E->getNumArgs() == 1 ||
16051 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
16052 (!getDerived().DropCallArgument(E->getArg(0))) &&
16053 !E->isListInitialization()))
16054 return getDerived().TransformInitializer(E->getArg(0),
16055 /*DirectInit*/ false);
16056
16057 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
16058
16059 QualType T = getDerived().TransformType(E->getType());
16060 if (T.isNull())
16061 return ExprError();
16062
16063 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
16064 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
16065 if (!Constructor)
16066 return ExprError();
16067
16068 bool ArgumentChanged = false;
16070 {
16073 E->isListInitialization());
16074 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
16075 &ArgumentChanged))
16076 return ExprError();
16077 }
16078
16079 if (!getDerived().AlwaysRebuild() &&
16080 T == E->getType() &&
16081 Constructor == E->getConstructor() &&
16082 !ArgumentChanged) {
16083 // Mark the constructor as referenced.
16084 // FIXME: Instantiation-specific
16085 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
16086 return E;
16087 }
16088
16089 return getDerived().RebuildCXXConstructExpr(
16090 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
16091 E->hadMultipleCandidates(), E->isListInitialization(),
16092 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
16093 E->getConstructionKind(), E->getParenOrBraceRange());
16094}
16095
16096template<typename Derived>
16099 QualType T = getDerived().TransformType(E->getType());
16100 if (T.isNull())
16101 return ExprError();
16102
16103 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
16104 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
16105 if (!Constructor)
16106 return ExprError();
16107
16108 if (!getDerived().AlwaysRebuild() &&
16109 T == E->getType() &&
16110 Constructor == E->getConstructor()) {
16111 // Mark the constructor as referenced.
16112 // FIXME: Instantiation-specific
16113 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
16114 return E;
16115 }
16116
16117 return getDerived().RebuildCXXInheritedCtorInitExpr(
16118 T, E->getLocation(), Constructor,
16119 E->constructsVBase(), E->inheritedFromVBase());
16120}
16121
16122/// Transform a C++ temporary-binding expression.
16123///
16124/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
16125/// transform the subexpression and return that.
16126template<typename Derived>
16129 if (auto *Dtor = E->getTemporary()->getDestructor())
16130 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
16131 const_cast<CXXDestructorDecl *>(Dtor));
16132 return getDerived().TransformExpr(E->getSubExpr());
16133}
16134
16135/// Transform a C++ expression that contains cleanups that should
16136/// be run after the expression is evaluated.
16137///
16138/// Since ExprWithCleanups nodes are implicitly generated, we
16139/// just transform the subexpression and return that.
16140template<typename Derived>
16143 return getDerived().TransformExpr(E->getSubExpr());
16144}
16145
16146template<typename Derived>
16150 TypeSourceInfo *T =
16151 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16152 if (!T)
16153 return ExprError();
16154
16155 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
16156 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
16157 if (!Constructor)
16158 return ExprError();
16159
16160 bool ArgumentChanged = false;
16162 Args.reserve(E->getNumArgs());
16163 {
16166 E->isListInitialization());
16167 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
16168 &ArgumentChanged))
16169 return ExprError();
16170
16171 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
16172 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc(),
16173 /*IsExplicit=*/true);
16174 if (Res.isInvalid())
16175 return ExprError();
16176 Args = {Res.get()};
16177 }
16178 }
16179
16180 if (!getDerived().AlwaysRebuild() &&
16181 T == E->getTypeSourceInfo() &&
16182 Constructor == E->getConstructor() &&
16183 !ArgumentChanged) {
16184 // FIXME: Instantiation-specific
16185 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
16186 return SemaRef.MaybeBindToTemporary(E);
16187 }
16188
16189 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
16190 return getDerived().RebuildCXXTemporaryObjectExpr(
16191 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
16192}
16193
16194template<typename Derived>
16197 // Transform any init-capture expressions before entering the scope of the
16198 // lambda body, because they are not semantically within that scope.
16199 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
16200 struct TransformedInitCapture {
16201 // The location of the ... if the result is retaining a pack expansion.
16202 SourceLocation EllipsisLoc;
16203 // Zero or more expansions of the init-capture.
16204 SmallVector<InitCaptureInfoTy, 4> Expansions;
16205 };
16207 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
16208 for (LambdaExpr::capture_iterator C = E->capture_begin(),
16209 CEnd = E->capture_end();
16210 C != CEnd; ++C) {
16211 if (!E->isInitCapture(C))
16212 continue;
16213
16214 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
16215 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
16216
16217 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
16218 UnsignedOrNone NumExpansions) {
16219 ExprResult NewExprInitResult = getDerived().TransformInitializer(
16220 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
16221
16222 if (NewExprInitResult.isInvalid()) {
16223 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
16224 return;
16225 }
16226 Expr *NewExprInit = NewExprInitResult.get();
16227
16228 QualType NewInitCaptureType =
16229 getSema().buildLambdaInitCaptureInitialization(
16230 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
16231 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
16232 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
16234 NewExprInit);
16235 Result.Expansions.push_back(
16236 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
16237 };
16238
16239 // If this is an init-capture pack, consider expanding the pack now.
16240 if (OldVD->isParameterPack()) {
16241 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
16242 ->getTypeLoc()
16245 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
16246
16247 // Determine whether the set of unexpanded parameter packs can and should
16248 // be expanded.
16249 bool Expand = true;
16250 bool RetainExpansion = false;
16251 UnsignedOrNone OrigNumExpansions =
16252 ExpansionTL.getTypePtr()->getNumExpansions();
16253 UnsignedOrNone NumExpansions = OrigNumExpansions;
16254 if (getDerived().TryExpandParameterPacks(
16255 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
16256 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
16257 RetainExpansion, NumExpansions))
16258 return ExprError();
16259 assert(!RetainExpansion && "Should not need to retain expansion after a "
16260 "capture since it cannot be extended");
16261 if (Expand) {
16262 for (unsigned I = 0; I != *NumExpansions; ++I) {
16263 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16264 SubstInitCapture(SourceLocation(), std::nullopt);
16265 }
16266 } else {
16267 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
16268 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
16269 }
16270 } else {
16271 SubstInitCapture(SourceLocation(), std::nullopt);
16272 }
16273 }
16274
16275 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
16276 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
16277
16278 // Create the local class that will describe the lambda.
16279
16280 // FIXME: DependencyKind below is wrong when substituting inside a templated
16281 // context that isn't a DeclContext (such as a variable template), or when
16282 // substituting an unevaluated lambda inside of a function's parameter's type
16283 // - as parameter types are not instantiated from within a function's DC. We
16284 // use evaluation contexts to distinguish the function parameter case.
16287 DeclContext *DC = getSema().CurContext;
16288 // A RequiresExprBodyDecl is not interesting for dependencies.
16289 // For the following case,
16290 //
16291 // template <typename>
16292 // concept C = requires { [] {}; };
16293 //
16294 // template <class F>
16295 // struct Widget;
16296 //
16297 // template <C F>
16298 // struct Widget<F> {};
16299 //
16300 // While we are substituting Widget<F>, the parent of DC would be
16301 // the template specialization itself. Thus, the lambda expression
16302 // will be deemed as dependent even if there are no dependent template
16303 // arguments.
16304 // (A ClassTemplateSpecializationDecl is always a dependent context.)
16305 while (DC->isRequiresExprBody() || isa<CXXExpansionStmtDecl>(DC))
16306 DC = DC->getParent();
16307 if ((getSema().isUnevaluatedContext() ||
16308 getSema().isConstantEvaluatedContext()) &&
16309 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
16310 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
16311 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
16312 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
16313
16314 CXXRecordDecl *OldClass = E->getLambdaClass();
16315 CXXRecordDecl *Class = getSema().createLambdaClosureType(
16316 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
16317 E->getCaptureDefault());
16318 getDerived().transformedLocalDecl(OldClass, {Class});
16319
16320 CXXMethodDecl *NewCallOperator =
16321 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
16322
16323 // Enter the scope of the lambda.
16324 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
16325 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
16326 E->hasExplicitParameters(), E->isMutable());
16327
16328 // Introduce the context of the call operator.
16329 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
16330 /*NewThisContext*/false);
16331
16332 bool Invalid = false;
16333
16334 // Transform captures.
16335 for (LambdaExpr::capture_iterator C = E->capture_begin(),
16336 CEnd = E->capture_end();
16337 C != CEnd; ++C) {
16338 // When we hit the first implicit capture, tell Sema that we've finished
16339 // the list of explicit captures.
16340 if (C->isImplicit())
16341 break;
16342
16343 // Capturing 'this' is trivial.
16344 if (C->capturesThis()) {
16345 // If this is a lambda that is part of a default member initialiser
16346 // and which we're instantiating outside the class that 'this' is
16347 // supposed to refer to, adjust the type of 'this' accordingly.
16348 //
16349 // Otherwise, leave the type of 'this' as-is.
16350 Sema::CXXThisScopeRAII ThisScope(
16351 getSema(),
16352 dyn_cast_if_present<CXXRecordDecl>(
16353 getSema().getFunctionLevelDeclContext()),
16354 Qualifiers());
16355 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16356 /*BuildAndDiagnose*/ true, nullptr,
16357 C->getCaptureKind() == LCK_StarThis);
16358 continue;
16359 }
16360 // Captured expression will be recaptured during captured variables
16361 // rebuilding.
16362 if (C->capturesVLAType())
16363 continue;
16364
16365 // Rebuild init-captures, including the implied field declaration.
16366 if (E->isInitCapture(C)) {
16367 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
16368
16369 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
16371
16372 for (InitCaptureInfoTy &Info : NewC.Expansions) {
16373 ExprResult Init = Info.first;
16374 QualType InitQualType = Info.second;
16375 if (Init.isInvalid() || InitQualType.isNull()) {
16376 Invalid = true;
16377 break;
16378 }
16379 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
16380 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
16381 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
16382 getSema().CurContext);
16383 if (!NewVD) {
16384 Invalid = true;
16385 break;
16386 }
16387 NewVDs.push_back(NewVD);
16388 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
16389 // Cases we want to tackle:
16390 // ([C(Pack)] {}, ...)
16391 // But rule out cases e.g.
16392 // [...C = Pack()] {}
16393 if (NewC.EllipsisLoc.isInvalid())
16394 LSI->ContainsUnexpandedParameterPack |=
16395 Init.get()->containsUnexpandedParameterPack();
16396 }
16397
16398 if (Invalid)
16399 break;
16400
16401 getDerived().transformedLocalDecl(OldVD, NewVDs);
16402 continue;
16403 }
16404
16405 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16406
16407 // Determine the capture kind for Sema.
16409 : C->getCaptureKind() == LCK_ByCopy
16412 SourceLocation EllipsisLoc;
16413 if (C->isPackExpansion()) {
16414 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
16415 bool ShouldExpand = false;
16416 bool RetainExpansion = false;
16417 UnsignedOrNone NumExpansions = std::nullopt;
16418 if (getDerived().TryExpandParameterPacks(
16419 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
16420 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16421 RetainExpansion, NumExpansions)) {
16422 Invalid = true;
16423 continue;
16424 }
16425
16426 if (ShouldExpand) {
16427 // The transform has determined that we should perform an expansion;
16428 // transform and capture each of the arguments.
16429 // expansion of the pattern. Do so.
16430 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
16431 for (unsigned I = 0; I != *NumExpansions; ++I) {
16432 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16433 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
16434 getDerived().TransformDecl(C->getLocation(), Pack));
16435 if (!CapturedVar) {
16436 Invalid = true;
16437 continue;
16438 }
16439
16440 // Capture the transformed variable.
16441 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
16442 }
16443
16444 // FIXME: Retain a pack expansion if RetainExpansion is true.
16445
16446 continue;
16447 }
16448
16449 EllipsisLoc = C->getEllipsisLoc();
16450 }
16451
16452 // Transform the captured variable.
16453 auto *CapturedVar = cast_or_null<ValueDecl>(
16454 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16455 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
16456 Invalid = true;
16457 continue;
16458 }
16459
16460 // This is not an init-capture; however it contains an unexpanded pack e.g.
16461 // ([Pack] {}(), ...)
16462 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
16463 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
16464
16465 // Capture the transformed variable.
16466 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
16467 EllipsisLoc);
16468 }
16469 getSema().finishLambdaExplicitCaptures(LSI);
16470
16471 // Transform the template parameters, and add them to the current
16472 // instantiation scope. The null case is handled correctly.
16473 auto TPL = getDerived().TransformTemplateParameterList(
16474 E->getTemplateParameterList());
16475 LSI->GLTemplateParameterList = TPL;
16476 if (TPL) {
16477 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
16478 TPL);
16479 LSI->ContainsUnexpandedParameterPack |=
16480 TPL->containsUnexpandedParameterPack();
16481 }
16482
16483 TypeLocBuilder NewCallOpTLBuilder;
16484 TypeLoc OldCallOpTypeLoc =
16485 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
16486 QualType NewCallOpType =
16487 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
16488 if (NewCallOpType.isNull())
16489 return ExprError();
16490 LSI->ContainsUnexpandedParameterPack |=
16491 NewCallOpType->containsUnexpandedParameterPack();
16492 TypeSourceInfo *NewCallOpTSI =
16493 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
16494
16495 // The type may be an AttributedType or some other kind of sugar;
16496 // get the actual underlying FunctionProtoType.
16497 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
16498 assert(FPTL && "Not a FunctionProtoType?");
16499
16500 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
16501 if (TRC) {
16502 ExprResult E = getDerived().TransformLambdaConstraint(
16503 const_cast<Expr *>(TRC.ConstraintExpr));
16504 if (E.isInvalid())
16505 return E;
16506 TRC.ConstraintExpr = E.get();
16507 }
16508
16509 LSI->BeforeCompoundStatement = false;
16510 getSema().CompleteLambdaCallOperator(
16511 NewCallOperator, E->getCallOperator()->getLocation(),
16512 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
16513 E->getCallOperator()->getConstexprKind(),
16514 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
16515 E->hasExplicitResultType());
16516
16517 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
16518 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
16519
16520 {
16521 // Number the lambda for linkage purposes if necessary.
16522 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
16523
16524 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
16525 if (getDerived().ReplacingOriginal()) {
16526 Numbering = OldClass->getLambdaNumbering();
16527 }
16528
16529 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
16530 }
16531
16532 // FIXME: Sema's lambda-building mechanism expects us to push an expression
16533 // evaluation context even if we're not transforming the function body.
16534 getSema().PushExpressionEvaluationContextForFunction(
16536 E->getCallOperator());
16537
16538 StmtResult Body;
16539 {
16540 Sema::NonSFINAEContext _(getSema());
16543 C.PointOfInstantiation = E->getBody()->getBeginLoc();
16544 getSema().pushCodeSynthesisContext(C);
16545
16546 // Instantiate the body of the lambda expression.
16547 Body = Invalid ? StmtError()
16548 : getDerived().TransformLambdaBody(E, E->getBody());
16549
16550 getSema().popCodeSynthesisContext();
16551 }
16552
16553 // ActOnLambda* will pop the function scope for us.
16554 FuncScopeCleanup.disable();
16555
16556 if (Body.isInvalid()) {
16557 SavedContext.pop();
16558 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
16559 /*IsInstantiation=*/true);
16560 return ExprError();
16561 }
16562
16563 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
16564 /*IsInstantiation=*/true,
16565 /*RetainFunctionScopeInfo=*/true);
16566 SavedContext.pop();
16567
16568 // Recompute the dependency of the lambda so that we can defer the lambda call
16569 // construction until after we have all the necessary template arguments. For
16570 // example, given
16571 //
16572 // template <class> struct S {
16573 // template <class U>
16574 // using Type = decltype([](U){}(42.0));
16575 // };
16576 // void foo() {
16577 // using T = S<int>::Type<float>;
16578 // ^~~~~~
16579 // }
16580 //
16581 // We would end up here from instantiating S<int> when ensuring its
16582 // completeness. That would transform the lambda call expression regardless of
16583 // the absence of the corresponding argument for U.
16584 //
16585 // Going ahead with unsubstituted type U makes things worse: we would soon
16586 // compare the argument type (which is float) against the parameter U
16587 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
16588 // error suggesting unmatched types 'U' and 'float'!
16589 //
16590 // That said, everything will be fine if we defer that semantic checking.
16591 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
16592 // dependent. Since the CallExpr's dependency boils down to the lambda's
16593 // dependency in this case, we can harness that by recomputing the dependency
16594 // from the instantiation arguments.
16595 //
16596 // FIXME: Creating the type of a lambda requires us to have a dependency
16597 // value, which happens before its substitution. We update its dependency
16598 // *after* the substitution in case we can't decide the dependency
16599 // so early, e.g. because we want to see if any of the *substituted*
16600 // parameters are dependent.
16601 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
16602 Class->setLambdaDependencyKind(DependencyKind);
16603
16604 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
16605 Body.get()->getEndLoc(), LSI);
16606}
16607
16608template<typename Derived>
16613
16614template<typename Derived>
16617 // Transform captures.
16619 CEnd = E->capture_end();
16620 C != CEnd; ++C) {
16621 // When we hit the first implicit capture, tell Sema that we've finished
16622 // the list of explicit captures.
16623 if (!C->isImplicit())
16624 continue;
16625
16626 // Capturing 'this' is trivial.
16627 if (C->capturesThis()) {
16628 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16629 /*BuildAndDiagnose*/ true, nullptr,
16630 C->getCaptureKind() == LCK_StarThis);
16631 continue;
16632 }
16633 // Captured expression will be recaptured during captured variables
16634 // rebuilding.
16635 if (C->capturesVLAType())
16636 continue;
16637
16638 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16639 assert(!E->isInitCapture(C) && "implicit init-capture?");
16640
16641 // Transform the captured variable.
16642 VarDecl *CapturedVar = cast_or_null<VarDecl>(
16643 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16644 if (!CapturedVar || CapturedVar->isInvalidDecl())
16645 return StmtError();
16646
16647 // Capture the transformed variable.
16648 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16649 }
16650
16651 return S;
16652}
16653
16654template<typename Derived>
16658 TypeSourceInfo *T =
16659 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16660 if (!T)
16661 return ExprError();
16662
16663 bool ArgumentChanged = false;
16665 Args.reserve(E->getNumArgs());
16666 {
16670 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16671 &ArgumentChanged))
16672 return ExprError();
16673 }
16674
16675 if (!getDerived().AlwaysRebuild() &&
16676 T == E->getTypeSourceInfo() &&
16677 !ArgumentChanged)
16678 return E;
16679
16680 // FIXME: we're faking the locations of the commas
16681 return getDerived().RebuildCXXUnresolvedConstructExpr(
16682 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16683}
16684
16685template <typename Derived>
16688
16689 TemplateName Name = getDerived().TransformConceptTemplateName(
16690 E->getTemplateName(), E->getNameLoc());
16691 if (Name.isNull())
16692 return ExprError();
16693
16694 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16695 if (getDerived().TransformTemplateArguments(
16696 E->template_arguments().data(), E->getNumTemplateArgs(), TransArgs))
16697 return ExprError();
16698
16699 TemplateDecl *TD = Name.getAsTemplateDecl();
16700 if (!TD)
16701 return SemaRef.CheckVarOrConceptTemplateTemplateId(E->getNameInfo(), Name,
16702 &TransArgs);
16703
16704 CXXScopeSpec SS;
16705
16706 LookupResult R(SemaRef, E->getNameInfo(), Sema::LookupOrdinaryName);
16707 R.addDecl(TD);
16708 R.resolveKind();
16709 return getDerived().RebuildTemplateIdExpr(
16710 SS, /*Template Keyword=*/SourceLocation(), R,
16711 /*RequiresADL=*/false, &TransArgs);
16712}
16713
16714template<typename Derived>
16718 // Transform the base of the expression.
16719 ExprResult Base((Expr*) nullptr);
16720 Expr *OldBase;
16721 QualType BaseType;
16722 QualType ObjectType;
16723 if (!E->isImplicitAccess()) {
16724 OldBase = E->getBase();
16725 Base = getDerived().TransformExpr(OldBase);
16726 if (Base.isInvalid())
16727 return ExprError();
16728
16729 // Start the member reference and compute the object's type.
16730 ParsedType ObjectTy;
16731 bool MayBePseudoDestructor = false;
16732 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16733 E->getOperatorLoc(),
16734 E->isArrow()? tok::arrow : tok::period,
16735 ObjectTy,
16736 MayBePseudoDestructor);
16737 if (Base.isInvalid())
16738 return ExprError();
16739
16740 ObjectType = ObjectTy.get();
16741 BaseType = ((Expr*) Base.get())->getType();
16742 } else {
16743 OldBase = nullptr;
16744 BaseType = getDerived().TransformType(E->getBaseType());
16745 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16746 }
16747
16748 // Transform the first part of the nested-name-specifier that qualifies
16749 // the member name.
16750 NamedDecl *FirstQualifierInScope
16751 = getDerived().TransformFirstQualifierInScope(
16752 E->getFirstQualifierFoundInScope(),
16753 E->getQualifierLoc().getBeginLoc());
16754
16755 NestedNameSpecifierLoc QualifierLoc;
16756 if (E->getQualifier()) {
16757 QualifierLoc
16758 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16759 ObjectType,
16760 FirstQualifierInScope);
16761 if (!QualifierLoc)
16762 return ExprError();
16763 }
16764
16765 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16766
16767 // TODO: If this is a conversion-function-id, verify that the
16768 // destination type name (if present) resolves the same way after
16769 // instantiation as it did in the local scope.
16770
16771 DeclarationNameInfo NameInfo
16772 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16773 if (!NameInfo.getName())
16774 return ExprError();
16775
16776 if (!E->hasExplicitTemplateArgs()) {
16777 // This is a reference to a member without an explicitly-specified
16778 // template argument list. Optimize for this common case.
16779 if (!getDerived().AlwaysRebuild() &&
16780 Base.get() == OldBase &&
16781 BaseType == E->getBaseType() &&
16782 QualifierLoc == E->getQualifierLoc() &&
16783 NameInfo.getName() == E->getMember() &&
16784 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16785 return E;
16786
16787 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16788 BaseType,
16789 E->isArrow(),
16790 E->getOperatorLoc(),
16791 QualifierLoc,
16792 TemplateKWLoc,
16793 FirstQualifierInScope,
16794 NameInfo,
16795 /*TemplateArgs*/nullptr);
16796 }
16797
16798 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16799 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16800 E->getNumTemplateArgs(),
16801 TransArgs))
16802 return ExprError();
16803
16804 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16805 BaseType,
16806 E->isArrow(),
16807 E->getOperatorLoc(),
16808 QualifierLoc,
16809 TemplateKWLoc,
16810 FirstQualifierInScope,
16811 NameInfo,
16812 &TransArgs);
16813}
16814
16815template <typename Derived>
16817 UnresolvedMemberExpr *Old) {
16818 // Transform the base of the expression.
16819 ExprResult Base((Expr *)nullptr);
16820 QualType BaseType;
16821 if (!Old->isImplicitAccess()) {
16822 Base = getDerived().TransformExpr(Old->getBase());
16823 if (Base.isInvalid())
16824 return ExprError();
16825 Base =
16826 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16827 if (Base.isInvalid())
16828 return ExprError();
16829 BaseType = Base.get()->getType();
16830 } else {
16831 BaseType = getDerived().TransformType(Old->getBaseType());
16832 }
16833
16834 NestedNameSpecifierLoc QualifierLoc;
16835 if (Old->getQualifierLoc()) {
16836 QualifierLoc =
16837 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16838 if (!QualifierLoc)
16839 return ExprError();
16840 }
16841
16842 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16843
16844 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16845
16846 // Transform the declaration set.
16847 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16848 return ExprError();
16849
16850 // Determine the naming class.
16851 if (Old->getNamingClass()) {
16852 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16853 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16854 if (!NamingClass)
16855 return ExprError();
16856
16857 R.setNamingClass(NamingClass);
16858 }
16859
16860 TemplateArgumentListInfo TransArgs;
16861 if (Old->hasExplicitTemplateArgs()) {
16862 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16863 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16864 if (getDerived().TransformTemplateArguments(
16865 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16866 return ExprError();
16867 }
16868
16869 // FIXME: to do this check properly, we will need to preserve the
16870 // first-qualifier-in-scope here, just in case we had a dependent
16871 // base (and therefore couldn't do the check) and a
16872 // nested-name-qualifier (and therefore could do the lookup).
16873 NamedDecl *FirstQualifierInScope = nullptr;
16874
16875 return getDerived().RebuildUnresolvedMemberExpr(
16876 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16877 TemplateKWLoc, FirstQualifierInScope, R,
16878 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16879}
16880
16881template<typename Derived>
16886 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16887 if (SubExpr.isInvalid())
16888 return ExprError();
16889
16890 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16891 return E;
16892
16893 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16894}
16895
16896template<typename Derived>
16899 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16900 if (Pattern.isInvalid())
16901 return ExprError();
16902
16903 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16904 return E;
16905
16906 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16907 E->getNumExpansions());
16908}
16909
16910template <typename Derived>
16912 ArrayRef<TemplateArgument> PackArgs) {
16914 for (const TemplateArgument &Arg : PackArgs) {
16915 if (!Arg.isPackExpansion()) {
16916 Result = *Result + 1;
16917 continue;
16918 }
16919
16920 TemplateArgumentLoc ArgLoc;
16921 InventTemplateArgumentLoc(Arg, ArgLoc);
16922
16923 // Find the pattern of the pack expansion.
16924 SourceLocation Ellipsis;
16925 UnsignedOrNone OrigNumExpansions = std::nullopt;
16926 TemplateArgumentLoc Pattern =
16927 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16928 OrigNumExpansions);
16929
16930 // Substitute under the pack expansion. Do not expand the pack (yet).
16931 TemplateArgumentLoc OutPattern;
16932 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16933 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16934 /*Uneval*/ true))
16935 return 1u;
16936
16937 // See if we can determine the number of arguments from the result.
16938 UnsignedOrNone NumExpansions =
16939 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16940 if (!NumExpansions) {
16941 // No: we must be in an alias template expansion, and we're going to
16942 // need to actually expand the packs.
16943 Result = std::nullopt;
16944 break;
16945 }
16946
16947 Result = *Result + *NumExpansions;
16948 }
16949 return Result;
16950}
16951
16952template<typename Derived>
16955 // If E is not value-dependent, then nothing will change when we transform it.
16956 // Note: This is an instantiation-centric view.
16957 if (!E->isValueDependent())
16958 return E;
16959
16962
16964 TemplateArgument ArgStorage;
16965
16966 // Find the argument list to transform.
16967 if (E->isPartiallySubstituted()) {
16968 PackArgs = E->getPartialArguments();
16969 } else if (E->isValueDependent()) {
16970 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16971 bool ShouldExpand = false;
16972 bool RetainExpansion = false;
16973 UnsignedOrNone NumExpansions = std::nullopt;
16974 if (getDerived().TryExpandParameterPacks(
16975 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16976 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16977 RetainExpansion, NumExpansions))
16978 return ExprError();
16979
16980 // If we need to expand the pack, build a template argument from it and
16981 // expand that.
16982 if (ShouldExpand) {
16983 auto *Pack = E->getPack();
16984 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16985 ArgStorage = getSema().Context.getPackExpansionType(
16986 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16987 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16988 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16989 } else {
16990 auto *VD = cast<ValueDecl>(Pack);
16991 ExprResult DRE = getSema().BuildDeclRefExpr(
16992 VD, VD->getType().getNonLValueExprType(getSema().Context),
16993 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16994 E->getPackLoc());
16995 if (DRE.isInvalid())
16996 return ExprError();
16997 ArgStorage = TemplateArgument(
16998 new (getSema().Context)
16999 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
17000 /*IsCanonical=*/false);
17001 }
17002 PackArgs = ArgStorage;
17003 }
17004 }
17005
17006 // If we're not expanding the pack, just transform the decl.
17007 if (!PackArgs.size()) {
17008 auto *Pack = cast_or_null<NamedDecl>(
17009 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
17010 if (!Pack)
17011 return ExprError();
17012 return getDerived().RebuildSizeOfPackExpr(
17013 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
17014 std::nullopt, {});
17015 }
17016
17017 // Try to compute the result without performing a partial substitution.
17019 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
17020
17021 // Common case: we could determine the number of expansions without
17022 // substituting.
17023 if (Result)
17024 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
17025 E->getPackLoc(),
17026 E->getRParenLoc(), *Result, {});
17027
17028 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
17029 E->getPackLoc());
17030 {
17031 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
17033 Derived, const TemplateArgument*> PackLocIterator;
17034 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
17035 PackLocIterator(*this, PackArgs.end()),
17036 TransformedPackArgs, /*Uneval*/true))
17037 return ExprError();
17038 }
17039
17040 // Check whether we managed to fully-expand the pack.
17041 // FIXME: Is it possible for us to do so and not hit the early exit path?
17043 bool PartialSubstitution = false;
17044 for (auto &Loc : TransformedPackArgs.arguments()) {
17045 Args.push_back(Loc.getArgument());
17046 if (Loc.getArgument().isPackExpansion())
17047 PartialSubstitution = true;
17048 }
17049
17050 if (PartialSubstitution)
17051 return getDerived().RebuildSizeOfPackExpr(
17052 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
17053 std::nullopt, Args);
17054
17055 return getDerived().RebuildSizeOfPackExpr(
17056 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
17057 /*Length=*/static_cast<unsigned>(Args.size()),
17058 /*PartialArgs=*/{});
17059}
17060
17061template <typename Derived>
17064 if (!E->isValueDependent())
17065 return E;
17066
17067 // Transform the index
17068 ExprResult IndexExpr;
17069 {
17070 EnterExpressionEvaluationContext ConstantContext(
17072 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
17073 if (IndexExpr.isInvalid())
17074 return ExprError();
17075 }
17076
17077 SmallVector<Expr *, 5> ExpandedExprs;
17078 bool FullySubstituted = true;
17079 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
17080 Expr *Pattern = E->getPackIdExpression();
17082 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
17083 Unexpanded);
17084 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
17085
17086 // Determine whether the set of unexpanded parameter packs can and should
17087 // be expanded.
17088 bool ShouldExpand = true;
17089 bool RetainExpansion = false;
17090 UnsignedOrNone OrigNumExpansions = std::nullopt,
17091 NumExpansions = std::nullopt;
17092 if (getDerived().TryExpandParameterPacks(
17093 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
17094 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
17095 RetainExpansion, NumExpansions))
17096 return true;
17097 if (!ShouldExpand) {
17098 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
17099 ExprResult Pack = getDerived().TransformExpr(Pattern);
17100 if (Pack.isInvalid())
17101 return ExprError();
17102 return getDerived().RebuildPackIndexingExpr(
17103 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
17104 {}, /*FullySubstituted=*/false);
17105 }
17106 for (unsigned I = 0; I != *NumExpansions; ++I) {
17107 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
17108 ExprResult Out = getDerived().TransformExpr(Pattern);
17109 if (Out.isInvalid())
17110 return true;
17111 if (Out.get()->containsUnexpandedParameterPack()) {
17112 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
17113 OrigNumExpansions);
17114 if (Out.isInvalid())
17115 return true;
17116 FullySubstituted = false;
17117 }
17118 ExpandedExprs.push_back(Out.get());
17119 }
17120 // If we're supposed to retain a pack expansion, do so by temporarily
17121 // forgetting the partially-substituted parameter pack.
17122 if (RetainExpansion) {
17123 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
17124
17125 ExprResult Out = getDerived().TransformExpr(Pattern);
17126 if (Out.isInvalid())
17127 return true;
17128
17129 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
17130 OrigNumExpansions);
17131 if (Out.isInvalid())
17132 return true;
17133 FullySubstituted = false;
17134 ExpandedExprs.push_back(Out.get());
17135 }
17136 } else if (!E->expandsToEmptyPack()) {
17137 if (getDerived().TransformExprs(E->getExpressions().data(),
17138 E->getExpressions().size(), false,
17139 ExpandedExprs))
17140 return ExprError();
17141 }
17142
17143 return getDerived().RebuildPackIndexingExpr(
17144 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
17145 IndexExpr.get(), ExpandedExprs, FullySubstituted);
17146}
17147
17148template <typename Derived>
17151 if (!getSema().ArgPackSubstIndex)
17152 // We aren't expanding the parameter pack, so just return ourselves.
17153 return E;
17154
17155 TemplateArgument Pack = E->getArgumentPack();
17157 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
17158 E->getAssociatedDecl(), E->getParameterPack()->getPosition(),
17159 E->getParameterPack()->getType(), E->getParameterPackLocation(), Arg,
17160 SemaRef.getPackIndex(Pack), E->getFinal());
17161}
17162
17163template <typename Derived>
17166 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
17167
17168 // Insert a constant-evaluated context for the transform.
17169 // Otherwise, when a normalized constraint places the replacement inside
17170 // an unevaluated operand (e.g. decltype), entities it refers to are not
17171 // odr-used, and the constant evaluation performed by CheckTemplateArgument
17172 // below can spuriously fail for otherwise valid replacements,
17173 // e.g. when a call materializes a function parameter of class type whose
17174 // special members were never instantiated.
17175 EnterExpressionEvaluationContext ConstantEvaluated(
17179
17180 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
17181 if (Replacement.isInvalid())
17182 return true;
17183
17184 Decl *AssociatedDecl =
17185 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
17186 if (!AssociatedDecl)
17187 return true;
17188
17189 QualType ParamType = TransformType(E->getParameterType());
17190 if (ParamType.isNull())
17191 return true;
17192
17193 if (Replacement.get() == OrigReplacement &&
17194 AssociatedDecl == E->getAssociatedDecl() &&
17195 ParamType == E->getParameterType())
17196 return E;
17197
17198 if (Replacement.get() != OrigReplacement ||
17199 ParamType != E->getParameterType()) {
17200 auto *Param = cast<NonTypeTemplateParmDecl>(std::get<0>(
17201 getReplacedTemplateParameter(AssociatedDecl, E->getIndex())));
17202 // When transforming the replacement expression previously, all Sema
17203 // specific annotations, such as implicit casts, are discarded. Calling the
17204 // corresponding sema action is necessary to recover those. Otherwise,
17205 // equivalency of the result would be lost.
17206 TemplateArgument SugaredConverted, CanonicalConverted;
17207 Replacement = SemaRef.CheckTemplateArgument(
17208 Param, ParamType, Replacement.get(), SugaredConverted,
17209 CanonicalConverted,
17210 /*StrictCheck=*/false, Sema::CTAK_Specified);
17211 if (Replacement.isInvalid())
17212 return true;
17213 } else {
17214 // Otherwise, the same expression would have been produced.
17215 Replacement = E->getReplacement();
17216 }
17217
17218 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
17219 AssociatedDecl, E->getIndex(), ParamType, E->getNameLoc(),
17220 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
17221 E->getPackIndex(), E->getFinal());
17222}
17223
17224template<typename Derived>
17227 // Default behavior is to do nothing with this transformation.
17228 return E;
17229}
17230
17231template<typename Derived>
17235 return getDerived().TransformExpr(E->getSubExpr());
17236}
17237
17238template<typename Derived>
17241 UnresolvedLookupExpr *Callee = nullptr;
17242 if (Expr *OldCallee = E->getCallee()) {
17243 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
17244 if (CalleeResult.isInvalid())
17245 return ExprError();
17246 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
17247 }
17248
17249 Expr *Pattern = E->getPattern();
17250
17252 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
17253 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
17254
17255 // Determine whether the set of unexpanded parameter packs can and should
17256 // be expanded.
17257 bool Expand = true;
17258 bool RetainExpansion = false;
17259 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
17260 NumExpansions = OrigNumExpansions;
17261 if (getDerived().TryExpandParameterPacks(
17262 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
17263 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
17264 NumExpansions))
17265 return true;
17266
17267 if (!Expand) {
17268 // Do not expand any packs here, just transform and rebuild a fold
17269 // expression.
17270 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
17271
17272 ExprResult LHS =
17273 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
17274 if (LHS.isInvalid())
17275 return true;
17276
17277 ExprResult RHS =
17278 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
17279 if (RHS.isInvalid())
17280 return true;
17281
17282 if (!getDerived().AlwaysRebuild() &&
17283 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
17284 return E;
17285
17286 return getDerived().RebuildCXXFoldExpr(
17287 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
17288 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
17289 }
17290
17291 // Formally a fold expression expands to nested parenthesized expressions.
17292 // Enforce this limit to avoid creating trees so deep we can't safely traverse
17293 // them.
17294 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
17295 SemaRef.Diag(E->getEllipsisLoc(),
17296 clang::diag::err_fold_expression_limit_exceeded)
17297 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
17298 << E->getSourceRange();
17299 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
17300 return ExprError();
17301 }
17302
17303 // The transform has determined that we should perform an elementwise
17304 // expansion of the pattern. Do so.
17305 ExprResult Result = getDerived().TransformExpr(E->getInit());
17306 if (Result.isInvalid())
17307 return true;
17308 bool LeftFold = E->isLeftFold();
17309
17310 // If we're retaining an expansion for a right fold, it is the innermost
17311 // component and takes the init (if any).
17312 if (!LeftFold && RetainExpansion) {
17313 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
17314
17315 ExprResult Out = getDerived().TransformExpr(Pattern);
17316 if (Out.isInvalid())
17317 return true;
17318
17319 Result = getDerived().RebuildCXXFoldExpr(
17320 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
17321 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
17322 if (Result.isInvalid())
17323 return true;
17324 }
17325
17326 bool WarnedOnComparison = false;
17327 for (unsigned I = 0; I != *NumExpansions; ++I) {
17328 Sema::ArgPackSubstIndexRAII SubstIndex(
17329 getSema(), LeftFold ? I : *NumExpansions - I - 1);
17330 ExprResult Out = getDerived().TransformExpr(Pattern);
17331 if (Out.isInvalid())
17332 return true;
17333
17334 if (Out.get()->containsUnexpandedParameterPack()) {
17335 // We still have a pack; retain a pack expansion for this slice.
17336 Result = getDerived().RebuildCXXFoldExpr(
17337 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
17338 E->getOperator(), E->getEllipsisLoc(),
17339 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
17340 OrigNumExpansions);
17341 } else if (Result.isUsable()) {
17342 // We've got down to a single element; build a binary operator.
17343 Expr *LHS = LeftFold ? Result.get() : Out.get();
17344 Expr *RHS = LeftFold ? Out.get() : Result.get();
17345 if (Callee) {
17346 UnresolvedSet<16> Functions;
17347 Functions.append(Callee->decls_begin(), Callee->decls_end());
17348 Result = getDerived().RebuildCXXOperatorCallExpr(
17349 BinaryOperator::getOverloadedOperator(E->getOperator()),
17350 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
17351 Functions, LHS, RHS);
17352 } else {
17353 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
17354 E->getOperator(), LHS, RHS,
17355 /*ForFoldExpresion=*/true);
17356 if (!WarnedOnComparison && Result.isUsable()) {
17357 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
17358 BO && BO->isComparisonOp()) {
17359 WarnedOnComparison = true;
17360 SemaRef.Diag(BO->getBeginLoc(),
17361 diag::warn_comparison_in_fold_expression)
17362 << BO->getOpcodeStr();
17363 }
17364 }
17365 }
17366 } else
17367 Result = Out;
17368
17369 if (Result.isInvalid())
17370 return true;
17371 }
17372
17373 // If we're retaining an expansion for a left fold, it is the outermost
17374 // component and takes the complete expansion so far as its init (if any).
17375 if (LeftFold && RetainExpansion) {
17376 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
17377
17378 ExprResult Out = getDerived().TransformExpr(Pattern);
17379 if (Out.isInvalid())
17380 return true;
17381
17382 Result = getDerived().RebuildCXXFoldExpr(
17383 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
17384 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
17385 if (Result.isInvalid())
17386 return true;
17387 }
17388
17389 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
17390 PE->setIsProducedByFoldExpansion();
17391
17392 // If we had no init and an empty pack, and we're not retaining an expansion,
17393 // then produce a fallback value or error.
17394 if (Result.isUnset())
17395 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
17396 E->getOperator());
17397 return Result;
17398}
17399
17400template <typename Derived>
17403 SmallVector<Expr *, 4> TransformedInits;
17404 ArrayRef<Expr *> InitExprs = E->getInitExprs();
17405
17406 QualType T = getDerived().TransformType(E->getType());
17407
17408 bool ArgChanged = false;
17409
17410 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
17411 TransformedInits, &ArgChanged))
17412 return ExprError();
17413
17414 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
17415 return E;
17416
17417 return getDerived().RebuildCXXParenListInitExpr(
17418 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
17419 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
17420}
17421
17422template<typename Derived>
17426 return getDerived().TransformExpr(E->getSubExpr());
17427}
17428
17429template<typename Derived>
17432 return SemaRef.MaybeBindToTemporary(E);
17433}
17434
17435template<typename Derived>
17438 return E;
17439}
17440
17441template<typename Derived>
17444 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
17445 if (SubExpr.isInvalid())
17446 return ExprError();
17447
17448 if (!getDerived().AlwaysRebuild() &&
17449 SubExpr.get() == E->getSubExpr())
17450 return E;
17451
17452 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
17453}
17454
17455template<typename Derived>
17458 // Transform each of the elements.
17459 SmallVector<Expr *, 8> Elements;
17460 bool ArgChanged = false;
17461 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
17462 /*IsCall=*/false, Elements, &ArgChanged))
17463 return ExprError();
17464
17465 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17466 return SemaRef.MaybeBindToTemporary(E);
17467
17468 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
17469 Elements.data(),
17470 Elements.size());
17471}
17472
17473template<typename Derived>
17477 // Transform each of the elements.
17479 bool ArgChanged = false;
17480 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
17481 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
17482
17483 if (OrigElement.isPackExpansion()) {
17484 // This key/value element is a pack expansion.
17486 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
17487 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
17488 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
17489
17490 // Determine whether the set of unexpanded parameter packs can
17491 // and should be expanded.
17492 bool Expand = true;
17493 bool RetainExpansion = false;
17494 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
17495 UnsignedOrNone NumExpansions = OrigNumExpansions;
17496 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
17497 OrigElement.Value->getEndLoc());
17498 if (getDerived().TryExpandParameterPacks(
17499 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
17500 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
17501 NumExpansions))
17502 return ExprError();
17503
17504 if (!Expand) {
17505 // The transform has determined that we should perform a simple
17506 // transformation on the pack expansion, producing another pack
17507 // expansion.
17508 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
17509 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17510 if (Key.isInvalid())
17511 return ExprError();
17512
17513 if (Key.get() != OrigElement.Key)
17514 ArgChanged = true;
17515
17516 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17517 if (Value.isInvalid())
17518 return ExprError();
17519
17520 if (Value.get() != OrigElement.Value)
17521 ArgChanged = true;
17522
17523 ObjCDictionaryElement Expansion = {
17524 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
17525 };
17526 Elements.push_back(Expansion);
17527 continue;
17528 }
17529
17530 // Record right away that the argument was changed. This needs
17531 // to happen even if the array expands to nothing.
17532 ArgChanged = true;
17533
17534 // The transform has determined that we should perform an elementwise
17535 // expansion of the pattern. Do so.
17536 for (unsigned I = 0; I != *NumExpansions; ++I) {
17537 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
17538 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17539 if (Key.isInvalid())
17540 return ExprError();
17541
17542 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17543 if (Value.isInvalid())
17544 return ExprError();
17545
17546 ObjCDictionaryElement Element = {
17547 Key.get(), Value.get(), SourceLocation(), NumExpansions
17548 };
17549
17550 // If any unexpanded parameter packs remain, we still have a
17551 // pack expansion.
17552 // FIXME: Can this really happen?
17553 if (Key.get()->containsUnexpandedParameterPack() ||
17554 Value.get()->containsUnexpandedParameterPack())
17555 Element.EllipsisLoc = OrigElement.EllipsisLoc;
17556
17557 Elements.push_back(Element);
17558 }
17559
17560 // FIXME: Retain a pack expansion if RetainExpansion is true.
17561
17562 // We've finished with this pack expansion.
17563 continue;
17564 }
17565
17566 // Transform and check key.
17567 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17568 if (Key.isInvalid())
17569 return ExprError();
17570
17571 if (Key.get() != OrigElement.Key)
17572 ArgChanged = true;
17573
17574 // Transform and check value.
17576 = getDerived().TransformExpr(OrigElement.Value);
17577 if (Value.isInvalid())
17578 return ExprError();
17579
17580 if (Value.get() != OrigElement.Value)
17581 ArgChanged = true;
17582
17583 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
17584 std::nullopt};
17585 Elements.push_back(Element);
17586 }
17587
17588 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17589 return SemaRef.MaybeBindToTemporary(E);
17590
17591 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
17592 Elements);
17593}
17594
17595template<typename Derived>
17598 TypeSourceInfo *EncodedTypeInfo
17599 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
17600 if (!EncodedTypeInfo)
17601 return ExprError();
17602
17603 if (!getDerived().AlwaysRebuild() &&
17604 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
17605 return E;
17606
17607 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
17608 EncodedTypeInfo,
17609 E->getRParenLoc());
17610}
17611
17612template<typename Derived>
17615 // This is a kind of implicit conversion, and it needs to get dropped
17616 // and recomputed for the same general reasons that ImplicitCastExprs
17617 // do, as well a more specific one: this expression is only valid when
17618 // it appears *immediately* as an argument expression.
17619 return getDerived().TransformExpr(E->getSubExpr());
17620}
17621
17622template<typename Derived>
17625 TypeSourceInfo *TSInfo
17626 = getDerived().TransformType(E->getTypeInfoAsWritten());
17627 if (!TSInfo)
17628 return ExprError();
17629
17630 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
17631 if (Result.isInvalid())
17632 return ExprError();
17633
17634 if (!getDerived().AlwaysRebuild() &&
17635 TSInfo == E->getTypeInfoAsWritten() &&
17636 Result.get() == E->getSubExpr())
17637 return E;
17638
17639 return SemaRef.ObjC().BuildObjCBridgedCast(
17640 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
17641 Result.get());
17642}
17643
17644template <typename Derived>
17647 return E;
17648}
17649
17650template<typename Derived>
17653 // Transform arguments.
17654 bool ArgChanged = false;
17656 Args.reserve(E->getNumArgs());
17657 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
17658 &ArgChanged))
17659 return ExprError();
17660
17661 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
17662 // Class message: transform the receiver type.
17663 TypeSourceInfo *ReceiverTypeInfo
17664 = getDerived().TransformType(E->getClassReceiverTypeInfo());
17665 if (!ReceiverTypeInfo)
17666 return ExprError();
17667
17668 // If nothing changed, just retain the existing message send.
17669 if (!getDerived().AlwaysRebuild() &&
17670 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
17671 return SemaRef.MaybeBindToTemporary(E);
17672
17673 // Build a new class message send.
17675 E->getSelectorLocs(SelLocs);
17676 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
17677 E->getSelector(),
17678 SelLocs,
17679 E->getMethodDecl(),
17680 E->getLeftLoc(),
17681 Args,
17682 E->getRightLoc());
17683 }
17684 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17685 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17686 if (!E->getMethodDecl())
17687 return ExprError();
17688
17689 // Build a new class message send to 'super'.
17691 E->getSelectorLocs(SelLocs);
17692 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17693 E->getSelector(),
17694 SelLocs,
17695 E->getReceiverType(),
17696 E->getMethodDecl(),
17697 E->getLeftLoc(),
17698 Args,
17699 E->getRightLoc());
17700 }
17701
17702 // Instance message: transform the receiver
17703 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17704 "Only class and instance messages may be instantiated");
17705 ExprResult Receiver
17706 = getDerived().TransformExpr(E->getInstanceReceiver());
17707 if (Receiver.isInvalid())
17708 return ExprError();
17709
17710 // If nothing changed, just retain the existing message send.
17711 if (!getDerived().AlwaysRebuild() &&
17712 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17713 return SemaRef.MaybeBindToTemporary(E);
17714
17715 // Build a new instance message send.
17717 E->getSelectorLocs(SelLocs);
17718 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17719 E->getSelector(),
17720 SelLocs,
17721 E->getMethodDecl(),
17722 E->getLeftLoc(),
17723 Args,
17724 E->getRightLoc());
17725}
17726
17727template<typename Derived>
17730 return E;
17731}
17732
17733template<typename Derived>
17736 return E;
17737}
17738
17739template<typename Derived>
17742 // Transform the base expression.
17743 ExprResult Base = getDerived().TransformExpr(E->getBase());
17744 if (Base.isInvalid())
17745 return ExprError();
17746
17747 // We don't need to transform the ivar; it will never change.
17748
17749 // If nothing changed, just retain the existing expression.
17750 if (!getDerived().AlwaysRebuild() &&
17751 Base.get() == E->getBase())
17752 return E;
17753
17754 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17755 E->getLocation(),
17756 E->isArrow(), E->isFreeIvar());
17757}
17758
17759template<typename Derived>
17762 // 'super' and types never change. Property never changes. Just
17763 // retain the existing expression.
17764 if (!E->isObjectReceiver())
17765 return E;
17766
17767 // Transform the base expression.
17768 ExprResult Base = getDerived().TransformExpr(E->getBase());
17769 if (Base.isInvalid())
17770 return ExprError();
17771
17772 // We don't need to transform the property; it will never change.
17773
17774 // If nothing changed, just retain the existing expression.
17775 if (!getDerived().AlwaysRebuild() &&
17776 Base.get() == E->getBase())
17777 return E;
17778
17779 if (E->isExplicitProperty())
17780 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17781 E->getExplicitProperty(),
17782 E->getLocation());
17783
17784 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17785 SemaRef.Context.PseudoObjectTy,
17786 E->getImplicitPropertyGetter(),
17787 E->getImplicitPropertySetter(),
17788 E->getLocation());
17789}
17790
17791template<typename Derived>
17794 // Transform the base expression.
17795 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17796 if (Base.isInvalid())
17797 return ExprError();
17798
17799 // Transform the key expression.
17800 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17801 if (Key.isInvalid())
17802 return ExprError();
17803
17804 // If nothing changed, just retain the existing expression.
17805 if (!getDerived().AlwaysRebuild() &&
17806 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17807 return E;
17808
17809 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17810 Base.get(), Key.get(),
17811 E->getAtIndexMethodDecl(),
17812 E->setAtIndexMethodDecl());
17813}
17814
17815template<typename Derived>
17818 // Transform the base expression.
17819 ExprResult Base = getDerived().TransformExpr(E->getBase());
17820 if (Base.isInvalid())
17821 return ExprError();
17822
17823 // If nothing changed, just retain the existing expression.
17824 if (!getDerived().AlwaysRebuild() &&
17825 Base.get() == E->getBase())
17826 return E;
17827
17828 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17829 E->getOpLoc(),
17830 E->isArrow());
17831}
17832
17833template<typename Derived>
17836 bool ArgumentChanged = false;
17837 SmallVector<Expr*, 8> SubExprs;
17838 SubExprs.reserve(E->getNumSubExprs());
17839 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17840 SubExprs, &ArgumentChanged))
17841 return ExprError();
17842
17843 if (!getDerived().AlwaysRebuild() &&
17844 !ArgumentChanged)
17845 return E;
17846
17847 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17848 SubExprs,
17849 E->getRParenLoc());
17850}
17851
17852template<typename Derived>
17855 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17856 if (SrcExpr.isInvalid())
17857 return ExprError();
17858
17859 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17860 if (!Type)
17861 return ExprError();
17862
17863 if (!getDerived().AlwaysRebuild() &&
17864 Type == E->getTypeSourceInfo() &&
17865 SrcExpr.get() == E->getSrcExpr())
17866 return E;
17867
17868 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17869 SrcExpr.get(), Type,
17870 E->getRParenLoc());
17871}
17872
17873template<typename Derived>
17876 BlockDecl *oldBlock = E->getBlockDecl();
17877
17878 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17879 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17880
17881 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17882 blockScope->TheDecl->setBlockMissingReturnType(
17883 oldBlock->blockMissingReturnType());
17884
17886 SmallVector<QualType, 4> paramTypes;
17887
17888 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17889
17890 // Parameter substitution.
17891 Sema::ExtParameterInfoBuilder extParamInfos;
17892 if (getDerived().TransformFunctionTypeParams(
17893 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17894 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17895 extParamInfos)) {
17896 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17897 return ExprError();
17898 }
17899
17900 QualType exprResultType =
17901 getDerived().TransformType(exprFunctionType->getReturnType());
17902
17903 auto epi = exprFunctionType->getExtProtoInfo();
17904 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17905
17907 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17908 blockScope->FunctionType = functionType;
17909
17910 // Set the parameters on the block decl.
17911 if (!params.empty())
17912 blockScope->TheDecl->setParams(params);
17913
17914 if (!oldBlock->blockMissingReturnType()) {
17915 blockScope->HasImplicitReturnType = false;
17916 blockScope->ReturnType = exprResultType;
17917 }
17918
17919 // Transform the body
17920 StmtResult body = getDerived().TransformStmt(E->getBody());
17921 if (body.isInvalid()) {
17922 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17923 return ExprError();
17924 }
17925
17926#ifndef NDEBUG
17927 // In builds with assertions, make sure that we captured everything we
17928 // captured before.
17929 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17930 for (const auto &I : oldBlock->captures()) {
17931 VarDecl *oldCapture = I.getVariable();
17932
17933 // Ignore parameter packs.
17934 if (oldCapture->isParameterPack())
17935 continue;
17936
17937 VarDecl *newCapture =
17938 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17939 oldCapture));
17940 assert(blockScope->CaptureMap.count(newCapture));
17941 }
17942 }
17943#endif
17944
17945 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17946 /*Scope=*/nullptr);
17947}
17948
17949template<typename Derived>
17952 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17953 if (SrcExpr.isInvalid())
17954 return ExprError();
17955
17956 QualType Type = getDerived().TransformType(E->getType());
17957
17958 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17959 E->getRParenLoc());
17960}
17961
17962template<typename Derived>
17965 bool ArgumentChanged = false;
17966 SmallVector<Expr*, 8> SubExprs;
17967 SubExprs.reserve(E->getNumSubExprs());
17968 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17969 SubExprs, &ArgumentChanged))
17970 return ExprError();
17971
17972 if (!getDerived().AlwaysRebuild() &&
17973 !ArgumentChanged)
17974 return E;
17975
17976 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17977 E->getOp(), E->getRParenLoc());
17978}
17979
17980//===----------------------------------------------------------------------===//
17981// Type reconstruction
17982//===----------------------------------------------------------------------===//
17983
17984template<typename Derived>
17987 return SemaRef.BuildPointerType(PointeeType, Star,
17989}
17990
17991template<typename Derived>
17994 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17996}
17997
17998template<typename Derived>
18001 bool WrittenAsLValue,
18002 SourceLocation Sigil) {
18003 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
18004 Sigil, getDerived().getBaseEntity());
18005}
18006
18007template <typename Derived>
18009 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
18010 SourceLocation Sigil) {
18011 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
18013}
18014
18015template<typename Derived>
18017 const ObjCTypeParamDecl *Decl,
18018 SourceLocation ProtocolLAngleLoc,
18020 ArrayRef<SourceLocation> ProtocolLocs,
18021 SourceLocation ProtocolRAngleLoc) {
18022 return SemaRef.ObjC().BuildObjCTypeParamType(
18023 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
18024 /*FailOnError=*/true);
18025}
18026
18027template<typename Derived>
18029 QualType BaseType,
18030 SourceLocation Loc,
18031 SourceLocation TypeArgsLAngleLoc,
18033 SourceLocation TypeArgsRAngleLoc,
18034 SourceLocation ProtocolLAngleLoc,
18036 ArrayRef<SourceLocation> ProtocolLocs,
18037 SourceLocation ProtocolRAngleLoc) {
18038 return SemaRef.ObjC().BuildObjCObjectType(
18039 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
18040 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
18041 /*FailOnError=*/true,
18042 /*Rebuilding=*/true);
18043}
18044
18045template<typename Derived>
18047 QualType PointeeType,
18049 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
18050}
18051
18052template <typename Derived>
18054 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
18055 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
18056 if (SizeExpr || !Size)
18057 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
18058 IndexTypeQuals, BracketsRange,
18060
18061 QualType Types[] = {
18062 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
18063 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
18064 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
18065 };
18066 QualType SizeType;
18067 for (const auto &T : Types)
18068 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
18069 SizeType = T;
18070 break;
18071 }
18072
18073 // Note that we can return a VariableArrayType here in the case where
18074 // the element type was a dependent VariableArrayType.
18075 IntegerLiteral *ArraySize
18076 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
18077 /*FIXME*/BracketsRange.getBegin());
18078 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
18079 IndexTypeQuals, BracketsRange,
18081}
18082
18083template <typename Derived>
18085 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
18086 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
18087 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
18088 IndexTypeQuals, BracketsRange);
18089}
18090
18091template <typename Derived>
18093 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
18094 SourceRange BracketsRange) {
18095 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
18096 IndexTypeQuals, BracketsRange);
18097}
18098
18099template <typename Derived>
18101 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
18102 unsigned IndexTypeQuals, SourceRange BracketsRange) {
18103 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
18104 SizeExpr,
18105 IndexTypeQuals, BracketsRange);
18106}
18107
18108template <typename Derived>
18110 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
18111 unsigned IndexTypeQuals, SourceRange BracketsRange) {
18112 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
18113 SizeExpr,
18114 IndexTypeQuals, BracketsRange);
18115}
18116
18117template <typename Derived>
18119 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
18120 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
18121 AttributeLoc);
18122}
18123
18124template <typename Derived>
18126 unsigned NumElements,
18127 VectorKind VecKind) {
18128 // FIXME: semantic checking!
18129 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
18130}
18131
18132template <typename Derived>
18134 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
18135 VectorKind VecKind) {
18136 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
18137}
18138
18139template<typename Derived>
18141 unsigned NumElements,
18142 SourceLocation AttributeLoc) {
18143 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
18144 NumElements, true);
18145 IntegerLiteral *VectorSize
18146 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
18147 AttributeLoc);
18148 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
18149}
18150
18151template<typename Derived>
18154 Expr *SizeExpr,
18155 SourceLocation AttributeLoc) {
18156 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
18157}
18158
18159template <typename Derived>
18161 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
18162 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
18163 NumColumns);
18164}
18165
18166template <typename Derived>
18168 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
18169 SourceLocation AttributeLoc) {
18170 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
18171 AttributeLoc);
18172}
18173
18174template <typename Derived>
18178 return SemaRef.BuildFunctionType(T, ParamTypes,
18181 EPI);
18182}
18183
18184template<typename Derived>
18186 return SemaRef.Context.getFunctionNoProtoType(T);
18187}
18188
18189template <typename Derived>
18192 SourceLocation NameLoc, Decl *D) {
18193 assert(D && "no decl found");
18194 if (D->isInvalidDecl()) return QualType();
18195
18196 // FIXME: Doesn't account for ObjCInterfaceDecl!
18197 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
18198 // A valid resolved using typename pack expansion decl can have multiple
18199 // UsingDecls, but they must each have exactly one type, and it must be
18200 // the same type in every case. But we must have at least one expansion!
18201 if (UPD->expansions().empty()) {
18202 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
18203 << UPD->isCXXClassMember() << UPD;
18204 return QualType();
18205 }
18206
18207 // We might still have some unresolved types. Try to pick a resolved type
18208 // if we can. The final instantiation will check that the remaining
18209 // unresolved types instantiate to the type we pick.
18210 QualType FallbackT;
18211 QualType T;
18212 for (auto *E : UPD->expansions()) {
18213 QualType ThisT =
18214 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
18215 if (ThisT.isNull())
18216 continue;
18217 if (ThisT->getAs<UnresolvedUsingType>())
18218 FallbackT = ThisT;
18219 else if (T.isNull())
18220 T = ThisT;
18221 else
18222 assert(getSema().Context.hasSameType(ThisT, T) &&
18223 "mismatched resolved types in using pack expansion");
18224 }
18225 return T.isNull() ? FallbackT : T;
18226 }
18227 if (auto *Using = dyn_cast<UsingDecl>(D)) {
18228 assert(Using->hasTypename() &&
18229 "UnresolvedUsingTypenameDecl transformed to non-typename using");
18230
18231 // A valid resolved using typename decl points to exactly one type decl.
18232 assert(++Using->shadow_begin() == Using->shadow_end());
18233
18234 UsingShadowDecl *Shadow = *Using->shadow_begin();
18235 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
18236 return QualType();
18237 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
18238 }
18240 "UnresolvedUsingTypenameDecl transformed to non-using decl");
18241 return SemaRef.Context.getUnresolvedUsingType(
18243}
18244
18245template <typename Derived>
18247 TypeOfKind Kind) {
18248 return SemaRef.BuildTypeofExprType(E, Kind);
18249}
18250
18251template<typename Derived>
18253 TypeOfKind Kind) {
18254 return SemaRef.Context.getTypeOfType(Underlying, Kind);
18255}
18256
18257template <typename Derived>
18259 return SemaRef.BuildDecltypeType(E);
18260}
18261
18262template <typename Derived>
18264 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
18265 SourceLocation EllipsisLoc, bool FullySubstituted,
18266 ArrayRef<QualType> Expansions) {
18267 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
18268 FullySubstituted, Expansions);
18269}
18270
18271template<typename Derived>
18273 UnaryTransformType::UTTKind UKind,
18274 SourceLocation Loc) {
18275 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
18276}
18277
18278template <typename Derived>
18281 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
18282 return SemaRef.CheckTemplateIdType(
18283 Keyword, Template, TemplateNameLoc, TemplateArgs,
18284 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
18285}
18286
18287template<typename Derived>
18289 SourceLocation KWLoc) {
18290 return SemaRef.BuildAtomicType(ValueType, KWLoc);
18291}
18292
18293template<typename Derived>
18295 SourceLocation KWLoc,
18296 bool isReadPipe) {
18297 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
18298 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
18299}
18300
18301template <typename Derived>
18303 unsigned NumBits,
18304 SourceLocation Loc) {
18305 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
18306 NumBits, true);
18307 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
18308 SemaRef.Context.IntTy, Loc);
18309 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
18310}
18311
18312template <typename Derived>
18314 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
18315 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
18316}
18317
18318template <typename Derived>
18320 bool TemplateKW,
18321 TemplateName Name) {
18322 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
18323 Name);
18324}
18325
18326template <typename Derived>
18328 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
18329 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
18331 TemplateName.setIdentifier(&Name, NameLoc);
18333 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
18334 TemplateName, ParsedType::make(ObjectType),
18335 /*EnteringContext=*/false, Template,
18336 AllowInjectedClassName);
18337 return Template.get();
18338}
18339
18340template<typename Derived>
18343 SourceLocation TemplateKWLoc,
18344 OverloadedOperatorKind Operator,
18345 SourceLocation NameLoc,
18346 QualType ObjectType,
18347 bool AllowInjectedClassName) {
18348 UnqualifiedId Name;
18349 // FIXME: Bogus location information.
18350 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
18351 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
18353 getSema().ActOnTemplateName(
18354 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
18355 /*EnteringContext=*/false, Template, AllowInjectedClassName);
18356 return Template.get();
18357}
18358
18359template <typename Derived>
18362 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
18363 Expr *Second) {
18364 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
18365
18366 if (First->getObjectKind() == OK_ObjCProperty) {
18369 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
18370 Opc, First, Second);
18371 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
18372 if (Result.isInvalid())
18373 return ExprError();
18374 First = Result.get();
18375 }
18376
18377 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
18378 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
18379 if (Result.isInvalid())
18380 return ExprError();
18381 Second = Result.get();
18382 }
18383
18384 // Determine whether this should be a builtin operation.
18385 if (Op == OO_Subscript) {
18386 if (!First->getType()->isOverloadableType() &&
18387 !Second->getType()->isOverloadableType())
18388 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
18389 OpLoc);
18390 } else if (Op == OO_Arrow) {
18391 // It is possible that the type refers to a RecoveryExpr created earlier
18392 // in the tree transformation.
18393 if (First->getType()->isDependentType())
18394 return ExprError();
18395 // -> is never a builtin operation.
18396 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
18397 } else if (Second == nullptr || isPostIncDec) {
18398 if (!First->getType()->isOverloadableType() ||
18399 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
18400 // The argument is not of overloadable type, or this is an expression
18401 // of the form &Class::member, so try to create a built-in unary
18402 // operation.
18404 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
18405
18406 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
18407 }
18408 } else {
18409 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
18410 !First->getType()->isOverloadableType() &&
18411 !Second->getType()->isOverloadableType()) {
18412 // Neither of the arguments is type-dependent or has an overloadable
18413 // type, so try to create a built-in binary operation.
18416 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
18417 if (Result.isInvalid())
18418 return ExprError();
18419
18420 return Result;
18421 }
18422 }
18423
18424 // Create the overloaded operator invocation for unary operators.
18425 if (!Second || isPostIncDec) {
18427 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
18428 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
18429 RequiresADL);
18430 }
18431
18432 // Create the overloaded operator invocation for binary operators.
18434 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
18435 First, Second, RequiresADL);
18436 if (Result.isInvalid())
18437 return ExprError();
18438
18439 return Result;
18440}
18441
18442template<typename Derived>
18445 SourceLocation OperatorLoc,
18446 bool isArrow,
18447 CXXScopeSpec &SS,
18448 TypeSourceInfo *ScopeType,
18449 SourceLocation CCLoc,
18450 SourceLocation TildeLoc,
18451 PseudoDestructorTypeStorage Destroyed) {
18452 QualType CanonicalBaseType = Base->getType().getCanonicalType();
18453 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
18454 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
18455 (isArrow && isa<PointerType>(CanonicalBaseType) &&
18456 !cast<PointerType>(CanonicalBaseType)
18457 ->getPointeeType()
18458 ->getAsCanonical<RecordType>())) {
18459 // This pseudo-destructor expression is still a pseudo-destructor.
18460 return SemaRef.BuildPseudoDestructorExpr(
18461 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
18462 CCLoc, TildeLoc, Destroyed);
18463 }
18464
18465 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
18466 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
18467 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
18468 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
18469 NameInfo.setNamedTypeInfo(DestroyedType);
18470
18471 // The scope type is now known to be a valid nested name specifier
18472 // component. Tack it on to the nested name specifier.
18473 if (ScopeType) {
18474 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
18475 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
18476 diag::err_expected_class_or_namespace)
18477 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
18478 return ExprError();
18479 }
18480 SS.clear();
18481 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
18482 }
18483
18484 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
18485 return getSema().BuildMemberReferenceExpr(
18486 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
18487 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
18488 /*TemplateArgs*/ nullptr,
18489 /*S*/ nullptr);
18490}
18491
18492template<typename Derived>
18495 SourceLocation Loc = S->getBeginLoc();
18496 CapturedDecl *CD = S->getCapturedDecl();
18497 unsigned NumParams = CD->getNumParams();
18498 unsigned ContextParamPos = CD->getContextParamPosition();
18500 for (unsigned I = 0; I < NumParams; ++I) {
18501 if (I != ContextParamPos) {
18502 Params.push_back(
18503 std::make_pair(
18504 CD->getParam(I)->getName(),
18505 getDerived().TransformType(CD->getParam(I)->getType())));
18506 } else {
18507 Params.push_back(std::make_pair(StringRef(), QualType()));
18508 }
18509 }
18510 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
18511 S->getCapturedRegionKind(), Params);
18512 StmtResult Body;
18513 {
18514 Sema::CompoundScopeRAII CompoundScope(getSema());
18515 Body = getDerived().TransformStmt(S->getCapturedStmt());
18516 }
18517
18518 if (Body.isInvalid()) {
18519 getSema().ActOnCapturedRegionError();
18520 return StmtError();
18521 }
18522
18523 return getSema().ActOnCapturedRegionEnd(Body.get());
18524}
18525
18526template <typename Derived>
18529 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
18530 // function definition or instantiation of a function template specialization
18531 // and will therefore never appear in a dependent context.
18532 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
18533 "context");
18534}
18535
18536template <typename Derived>
18538 // We can transform the base expression and allow argument resolution to fill
18539 // in the rest.
18540 return getDerived().TransformExpr(E->getArgLValue());
18541}
18542
18543} // end namespace clang
18544
18545#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.
Result
Implement __builtin_bit_cast and related operations.
#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.
llvm::json::Object Object
This file declares semantic analysis for HLSL constructs.
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)
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
This represents clause 'map' in the 'pragma omp ...' directives.
This represents clauses with a list of expressions that are mappable. Examples of these clauses are '...
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 getLateParsedAttrType(QualType Wrapped, LateParsedTypeAttribute *LateParsedAttr) const
Return a placeholder type for a late-parsed type attribute.
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>.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
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:4594
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:6071
Represents a loop initializing the elements of an array.
Definition Expr.h:6018
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1864
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7269
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2765
Wrapper for source info for arrays.
Definition TypeLoc.h:1808
void setLBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1814
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition ExprCXX.h:3010
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:3048
ArrayTypeTrait getTrait() const
Definition ExprCXX.h:3050
Expr * getDimensionExpression() const
Definition ExprCXX.h:3060
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition ExprCXX.h:3056
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:3047
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3800
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6783
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6978
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2704
Attr - This represents one attribute.
Definition Attr.h:46
Represents an attribute applied to a statement.
Definition Stmt.h:2215
Stmt * getSubStmt()
Definition Stmt.h:2251
SourceLocation getAttrLoc() const
Definition Stmt.h:2246
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2247
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:4497
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4082
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition Expr.cpp:2211
static bool isAssignmentOp(Opcode Opc)
Definition Expr.h:4218
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:2173
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8276
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4807
void setIsVariadic(bool value)
Definition Decl.h:4883
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6722
Wrapper for source info for block pointers.
Definition TypeLoc.h:1557
BreakStmt - This represents a break.
Definition Stmt.h:3147
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5529
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:5548
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:5547
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition Expr.h:4013
Represents a call to a CUDA kernel function.
Definition ExprCXX.h:238
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition ExprCXX.h:608
Represents binding an expression to a temporary.
Definition ExprCXX.h:1497
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition ExprCXX.h:727
CXXCatchStmt - This represents a C++ catch block.
Definition StmtCXX.h:29
A C++ const_cast expression (C++ [expr.const.cast]).
Definition ExprCXX.h:570
Represents a call to a C++ constructor.
Definition ExprCXX.h:1552
SourceRange getParenOrBraceRange() const
Definition ExprCXX.h:1733
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition ExprCXX.h:1695
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition ExprCXX.h:1645
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:612
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:606
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition ExprCXX.h:1634
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition ExprCXX.h:1692
Represents a C++ constructor within a class.
Definition DeclCXX.h:2641
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1274
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition ExprCXX.cpp:1072
A use of a default initializer in a constructor or in aggregate initialization.
Definition ExprCXX.h:1381
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2630
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition ExprCXX.h:3923
Represents a C++ destructor within a class.
Definition DeclCXX.h:2906
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:485
Helper that selects an expression from an InitListExpr depending on the current expansion index.
Definition ExprCXX.h:5611
Represents a C++26 expansion statement declaration.
Represents the code generated for an expanded expansion statement.
Definition StmtCXX.h:1028
static CXXExpansionStmtInstantiation * Create(ASTContext &C, CXXExpansionStmtDecl *Parent, ArrayRef< Stmt * > Instantiations, ArrayRef< Stmt * > PreambleStmts, bool ShouldApplyLifetimeExtensionToPreamble)
Definition StmtCXX.cpp:261
CXXExpansionStmtPattern - Represents an unexpanded C++ expansion statement.
Definition StmtCXX.h:675
static CXXExpansionStmtPattern * CreateIterating(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, DeclStmt *Range, DeclStmt *Begin, DeclStmt *Iter, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create an iterating expansion statement pattern.
Definition StmtCXX.cpp:194
static CXXExpansionStmtPattern * CreateEnumerating(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create an enumerating expansion statement pattern.
Definition StmtCXX.cpp:185
Represents a folding of a pack over an operator.
Definition ExprCXX.h:5085
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition StmtCXX.h:136
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition ExprCXX.h:1835
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition ExprCXX.h:1755
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:183
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2149
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition ExprCXX.h:379
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition ExprCXX.h:410
SourceRange getAngleBrackets() const LLVM_READONLY
Definition ExprCXX.h:417
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition ExprCXX.h:413
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition ExprCXX.h:2359
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition ExprCXX.h:4362
The null pointer literal (C++11 [lex.nullptr])
Definition ExprCXX.h:772
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:85
Represents a list-initialization with parenthesis.
Definition ExprCXX.h:5194
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition ExprCXX.h:2749
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
unsigned getLambdaDependencyKind() const
Definition DeclCXX.h:1878
Represents a C++26 reflect expression [expr.reflect].
Definition ExprCXX.h:5561
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition ExprCXX.h:530
A rewritten comparison expression that was originally written using operator syntax.
Definition ExprCXX.h:290
An expression "T()" which creates an rvalue of a non-class type T.
Definition ExprCXX.h:2200
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:76
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:209
SourceRange getRange() const
Definition DeclSpec.h:82
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:97
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:213
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:181
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:804
Represents a C++ functional cast expression that builds a temporary object.
Definition ExprCXX.h:1903
Represents the this expression in C++.
Definition ExprCXX.h:1158
A C++ throw-expression (C++ [except.throw]).
Definition ExprCXX.h:1212
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:70
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition ExprCXX.h:852
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition ExprCXX.h:3797
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition ExprCXX.h:3841
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition ExprCXX.h:3852
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition ExprCXX.h:3835
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition ExprCXX.h:3846
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition ExprCXX.h:3855
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1072
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2987
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:1545
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:5079
unsigned getNumParams() const
Definition Decl.h:5117
unsigned getContextParamPosition() const
Definition Decl.h:5146
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5119
This captures a statement into a function.
Definition Stmt.h:3949
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1493
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:4053
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:4144
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition Stmt.cpp:1508
CaseStmt - Represent a case statement.
Definition Stmt.h:1932
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition Expr.cpp:2010
Expr * getSubExpr()
Definition Expr.h:3770
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4892
Represents a 'co_await' expression.
Definition ExprCXX.h:5422
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4344
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3649
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1752
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Stmt.h:1802
body_range body()
Definition Stmt.h:1815
SourceLocation getLBracLoc() const
Definition Stmt.h:1869
bool hasStoredFPFeatures() const
Definition Stmt.h:1799
Stmt * body_back()
Definition Stmt.h:1820
SourceLocation getRBracLoc() const
Definition Stmt.h:1870
Declaration of a C++20 concept.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateName 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:4435
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3838
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition Expr.h:1102
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4465
ContinueStmt - This represents a continue.
Definition Stmt.h:3131
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4763
Represents a 'co_return' statement in the C++ Coroutines TS.
Definition StmtCXX.h:474
Represents the body of a coroutine.
Definition StmtCXX.h:321
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
Definition TypeBase.h:3498
Represents a 'co_yield' expression.
Definition ExprCXX.h:5503
Wrapper for source info for pointers decayed from arrays and functions.
Definition TypeLoc.h:1505
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:1466
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2126
DeclContextLookupResult lookup_result
Definition DeclBase.h:2607
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.
bool isExpansionStmt() const
Definition DeclBase.h:2215
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1290
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1643
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
bool isInvalidDecl() const
Definition DeclBase.h:596
SourceLocation getLocation() const
Definition DeclBase.h:447
DeclContext * getDeclContext()
Definition DeclBase.h:456
AccessSpecifier getAccess() const
Definition DeclBase.h:515
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:823
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:810
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:1952
void setDecltypeLoc(SourceLocation Loc)
Definition TypeLoc.h:2319
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2544
DeferStmt - This represents a deferred statement.
Definition Stmt.h:3248
static DeferStmt * Create(ASTContext &Context, SourceLocation DeferLoc, Stmt *Body)
Definition Stmt.cpp:1552
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:2029
Represents an extended address space qualifier where the input address space value is dependent.
Definition TypeBase.h:4139
Represents a 'co_await' expression while the type of the promise is dependent.
Definition ExprCXX.h:5454
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2612
A qualified reference to a name whose declaration cannot yet be resolved.
Definition ExprCXX.h:3563
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3637
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition ExprCXX.h:3611
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3629
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition ExprCXX.h:3647
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3621
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3664
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3602
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3657
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3599
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4089
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2127
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4179
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition TypeBase.h:4551
A template-id naming a variable template or a concept through a template template parameter.
Definition ExprCXX.h:3479
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2099
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4305
Represents a single C99 designator.
Definition Expr.h:5644
Represents a C99 designated initializer expression.
Definition Expr.h:5601
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:221
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
Definition Designator.h:185
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
Definition Designator.h:155
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
Definition Designator.h:115
bool hasErrorOccurred() const
Definition Diagnostic.h:893
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2844
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Definition TypeBase.h:5105
Expr * getCondition() const
Definition TypeBase.h:5112
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:744
Represents a reference to emded data.
Definition Expr.h:5179
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:3994
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition ExprCXX.h:3714
This represents one expression.
Definition Expr.h:113
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition Expr.h:178
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:195
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition Expr.h:455
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3115
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3247
QualType getType() const
Definition Expr.h:145
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition Expr.h:527
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition Expr.h:438
An expression trait intrinsic.
Definition ExprCXX.h:3083
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h:6660
Represents difference between two FPOptions values.
FPOptions applyOverrides(FPOptions Base)
Represents a member of a struct/union/class.
Definition Decl.h:3295
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2900
Represents a function declaration or definition.
Definition Decl.h:2059
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2905
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5353
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4998
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5774
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5760
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5219
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4963
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4894
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5385
param_type_iterator param_type_begin() const
Definition TypeBase.h:5829
unsigned getNumParams() const
Definition TypeLoc.h:1747
SourceLocation getLocalRangeEnd() const
Definition TypeLoc.h:1699
void setLocalRangeBegin(SourceLocation L)
Definition TypeLoc.h:1695
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1711
SourceRange getExceptionSpecRange() const
Definition TypeLoc.h:1727
void setParam(unsigned i, ParmVarDecl *VD)
Definition TypeLoc.h:1754
ArrayRef< ParmVarDecl * > getParams() const
Definition TypeLoc.h:1738
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1719
void setLocalRangeEnd(SourceLocation L)
Definition TypeLoc.h:1703
void setExceptionSpecRange(SourceRange R)
Definition TypeLoc.h:1733
TypeLoc getReturnLoc() const
Definition TypeLoc.h:1756
SourceLocation getLocalRangeBegin() const
Definition TypeLoc.h:1691
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1707
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1715
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4607
This represents a GCC inline-assembly statement extension.
Definition Stmt.h:3458
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition Expr.h:4967
Represents a C11 generic selection.
Definition Expr.h:6232
AssociationTy< false > Association
Definition Expr.h:6465
GotoStmt - This represents a direct goto.
Definition Stmt.h:2981
Type source information for HLSL attributed resource type.
Definition TypeLoc.h:1113
void setSourceRange(const SourceRange &R)
Definition TypeLoc.h:1124
This class represents temporary values used to represent inout and out arguments in HLSL.
Definition Expr.h:7447
One of these records is kept for each identifier that is lexed.
IfStmt - This represents an if/then/else.
Definition Stmt.h:2271
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition Expr.h:1751
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition Expr.h:3897
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:6107
Represents a C array with an unspecified size.
Definition TypeBase.h:3987
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:3020
const TypeClass * getTypePtr() const
Definition TypeLoc.h:526
Describes an C or C++ initializer list.
Definition Expr.h:5352
InitListExpr * getSyntacticForm() const
Definition Expr.h:5522
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:981
Represents the declaration of a label.
Definition Decl.h:525
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2158
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition ExprCXX.h:1972
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition ExprCXX.cpp:1396
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1391
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1400
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition ExprCXX.h:2037
llvm::omp::Version getOpenMPVersion() const
Return the OpenMP version.
void setAttrNameLoc(SourceLocation Loc)
Definition TypeLoc.h:1373
Represents a placeholder type for late-parsed type attributes.
Definition TypeBase.h:3557
Represents the results of name lookup.
Definition Lookup.h:147
This represents a Microsoft inline-assembly statement extension.
Definition Stmt.h:3677
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition StmtCXX.h:254
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4378
A member reference to an MSPropertyDecl.
Definition ExprCXX.h:940
MS property subscript expression.
Definition ExprCXX.h:1010
void setExpansionLoc(SourceLocation Loc)
Definition TypeLoc.h:1414
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4973
MatrixSingleSubscriptExpr - Matrix single subscript expression for the MatrixType extension when you ...
Definition Expr.h:2839
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2909
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2156
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3408
Wrapper for source info for member pointers.
Definition TypeLoc.h:1575
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3731
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:275
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition Decl.h:296
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:302
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:341
Represents C++ namespaces and their aliases.
Definition Decl.h:574
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:5927
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h:1715
This represents the 'align' clause in the 'pragma omp allocate' directive.
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 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 the 'counts' clause in the 'pragma omp split' directive.
This represents 'default' clause in the 'pragma omp ...' directive.
This represents 'final' clause in the 'pragma omp ...' directive.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
This represents 'if' clause in the 'pragma omp ...' directive.
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
Definition ExprOpenMP.h:151
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
This represents 'num_threads' 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 'safelen' clause in the 'pragma omp ...' directive.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition ExprObjC.h:219
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:1735
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition ExprObjC.h:118
ObjCBoxedExpr - used for generalized expression boxing.
Definition ExprObjC.h:158
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition ExprObjC.h:1675
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition ExprObjC.h:341
ObjCEncodeExpr, used for @encode in Objective-C.
Definition ExprObjC.h:440
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:1614
Wrapper for source info for ObjC interfaces.
Definition TypeLoc.h:1303
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition ExprObjC.h:1530
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1958
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:581
An expression that sends a message to the given Objective-C object or class.
Definition ExprObjC.h:972
@ SuperInstance
The receiver is the instance of the superclass object.
Definition ExprObjC.h:986
@ Instance
The receiver is an object instance.
Definition ExprObjC.h:980
@ SuperClass
The receiver is a superclass.
Definition ExprObjC.h:983
@ Class
The receiver is a class.
Definition ExprObjC.h:977
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Wraps an ObjCPointerType with source location information.
Definition TypeLoc.h:1617
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1623
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition TypeLoc.h:1258
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:734
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition ExprObjC.h:649
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition ExprObjC.h:537
ObjCSelectorExpr used for @selector in Objective-C.
Definition ExprObjC.h:485
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition ExprObjC.h:83
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition ExprObjC.h:871
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:581
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:2470
@ Identifier
A field in a dependent type, known only by its name.
Definition Expr.h:2474
@ Field
A field.
Definition Expr.h:2472
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition Expr.h:2477
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:1198
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1248
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition Expr.h:2134
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)
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1093
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition ExprCXX.h:3142
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition ExprCXX.h:3294
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3276
SourceLocation getNameLoc() const
Gets the location of the name.
Definition ExprCXX.h:3255
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3268
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition ExprCXX.h:3264
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3306
llvm::iterator_range< decls_iterator > decls() const
Definition ExprCXX.h:3241
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3312
DeclarationName getName() const
Gets the name looked up.
Definition ExprCXX.h:3252
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3284
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition ExprCXX.h:3291
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition ExprCXX.h:4416
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2664
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2660
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2676
A structure for storing a pack-index-template-name ([temp.names]).
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2347
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2226
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition Expr.h:2251
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition Expr.h:2255
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1442
Represents a parameter to a function.
Definition Decl.h:1820
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1880
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1853
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:2945
unsigned getFunctionScopeDepth() const
Definition Decl.h:1870
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2756
PipeType - OpenCL20.
Definition TypeBase.h:8247
bool isReadOnly() const
Definition TypeBase.h:8272
Pointer-authentication qualifiers.
Definition TypeBase.h:153
void setSigilLoc(SourceLocation Loc)
Definition TypeLoc.h:1521
TypeLoc getPointeeLoc() const
Definition TypeLoc.h:1525
SourceLocation getSigilLoc() const
Definition TypeLoc.h:1517
Wrapper for source info for pointers.
Definition TypeLoc.h:1544
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3396
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2049
Stores the type being destroyed by a pseudo-destructor expression.
Definition ExprCXX.h:2698
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h:6854
A (possibly-)qualified type.
Definition TypeBase.h:938
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition TypeBase.h:1005
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8450
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:332
void removeObjCLifetime()
Definition TypeBase.h:552
bool hasRestrict() const
Definition TypeBase.h:478
static Qualifiers fromCVRMask(unsigned CVR)
Definition TypeBase.h:436
PointerAuthQualifier getPointerAuth() const
Definition TypeBase.h:604
bool hasObjCLifetime() const
Definition TypeBase.h:545
bool empty() const
Definition TypeBase.h:648
LangAS getAddressSpace() const
Definition TypeBase.h:572
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition Expr.h:7553
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3658
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3674
Represents the body of a requires-expression.
Definition DeclCXX.h:2118
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition DeclCXX.cpp:2405
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:3172
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition Stmt.cpp:1361
Represents a __leave statement.
Definition Stmt.h:3910
SYCLKernelCallStmt represents the transformation that is applied to the body of a function declared w...
Definition StmtSYCL.h:36
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
bool diagnoseMatrixLayoutInstantiation(attr::Kind K, QualType T, SourceLocation Loc)
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 * ActOnOpenMPCountsClause(ArrayRef< Expr * > CountExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, std::optional< unsigned > FillIdx, SourceLocation FillLoc, unsigned FillCount)
Called on well-formed 'counts' clause after parsing its arguments.
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 * ActOnOpenMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'shared' clause.
OMPClause * ActOnOpenMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyin' clause.
OMPClause * ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'destroy' clause.
OMPClause * ActOnOpenMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Called on well-formed 'affinity' clause.
OMPClause * ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depend' clause.
OMPClause * ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'doacross' clause.
OMPClause * ActOnOpenMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, OpenMPUseDevicePtrFallbackModifier FallbackModifier, SourceLocation FallbackModifierLoc)
Called on well-formed 'use_device_ptr' 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 * ActOnOpenMPNumThreadsClause(ArrayRef< Expr * > VarList, OpenMPNumThreadsClauseModifier SimpleModifier, SourceLocation SimpleModifierLoc, OpenMPNumThreadsClauseModifier ComplexModifier, Expr *ComplexModifierExpr, SourceLocation ComplexModifierLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_threads' clause.
OMPClause * ActOnOpenMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'in_reduction' clause.
OMPClause * ActOnOpenMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'flush' pseudo clause.
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
OMPClause * ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'message' clause.
OMPClause * ActOnOpenMPThreadLimitClause(ArrayRef< Expr * > VarList, OpenMPThreadLimitClauseModifier Modifier, Expr *ModifierExpr, SourceLocation ModifierLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' 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 * 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 * ActOnOpenMPTransparentClause(Expr *Transparent, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'transparent' clause.
OMPClause * ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'hint' clause.
OMPClause * ActOnOpenMPNumTeamsClause(ArrayRef< Expr * > VarList, OpenMPNumTeamsClauseModifier Modifier, Expr *ModifierExpr, SourceLocation ModifierLoc, OpenMPNumTeamsClauseModifier ModifierExtra, Expr *ModifierExtraExpr, SourceLocation ModifierExtraLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' clause.
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
OMPClause * ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'at' clause.
OMPClause * ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'init' clause.
OMPClause * ActOnOpenMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_addr' clause.
OMPClause * ActOnOpenMPAllocateClause(Expr *Allocator, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocate' clause.
OMPClause * ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'final' clause.
OMPClause * ActOnOpenMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, bool NoDiagnose=false, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'map' clause.
OMPClause * ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_tasks' clause.
OMPClause * 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)
StmtResult BuildSYCLKernelCallStmt(FunctionDecl *FD, CompoundStmt *Body, Expr *LaunchIdExpr)
Builds a SYCLKernelCallStmt to wrap 'Body' and to be used as the body of 'FD'.
Definition SemaSYCL.cpp:774
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition SemaSYCL.cpp:154
RAII object used to change the argument pack substitution index within a Sema object.
Definition Sema.h:13760
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8476
A RAII object to enter scope of a compound statement.
Definition Sema.h:1313
std::optional< bool > getKnownValue() const
Definition Sema.h:7851
A RAII object to temporarily push a declaration context.
Definition Sema.h:3532
A helper class for building up ExtParameterInfos.
Definition Sema.h:13129
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:13148
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13136
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14155
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:863
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:9370
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9378
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9373
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:1531
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:7867
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7869
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7868
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition Sema.h:6965
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:439
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:486
StmtResult BuildNonEnumeratingCXXExpansionStmtPattern(CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVarStmt, Expr *ExpansionInitializer, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
TemplateName BuildPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< TemplateName > Expansions={})
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition Sema.h:1556
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:12063
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:1304
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:932
SemaObjC & ObjC()
Definition Sema.h:1516
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:935
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)
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, const Designation &Desig, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
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:84
const LangOptions & getLangOpts() const
Definition Sema.h:928
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
SemaOpenACC & OpenACC()
Definition Sema.h:1521
@ ReuseLambdaContextDecl
Definition Sema.h:7056
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 TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
SemaHLSL & HLSL()
Definition Sema.h:1481
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
TemplateArgument getPackSubstitutedTemplateArgument(TemplateArgument Arg) const
Definition Sema.h:11865
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:1339
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:11860
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition Sema.cpp:2674
void ApplyForRangeOrExpansionStatementLifetimeExtension(VarDecl *RangeVar, ArrayRef< MaterializeTemporaryExpr * > Temporaries)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1444
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 CheckVarOrConceptTemplateTemplateId(const DeclarationNameInfo &NameInfo, TemplateName Template, const TemplateArgumentListInfo *TemplateArgs)
ExprResult BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, unsigned Index, QualType ParamType, SourceLocation loc, TemplateArgument Replacement, UnsignedOrNone PackIndex, bool Final)
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.
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:6766
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6776
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6745
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6771
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:76
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
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:8345
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
ExprResult BuildCXXExpansionSelectExpr(InitListExpr *Range, Expr *Idx)
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
StmtResult FinishCXXExpansionStmt(Stmt *Expansion, Stmt *Body)
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:11114
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition SemaStmt.cpp:586
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:338
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:976
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:1296
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static ConditionResult ConditionError()
Definition Sema.h:7853
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:437
SemaPseudoObject & PseudoObject()
Definition Sema.h:1541
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:1295
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition SemaStmt.cpp:591
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition SemaStmt.cpp:552
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:8689
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:4687
Represents an expression that computes the length of a parameter pack.
Definition ExprCXX.h:4494
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition ExprCXX.h:4556
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
Definition ExprCXX.h:4579
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Definition ExprCXX.cpp:1741
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition ExprCXX.h:4584
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
Definition ExprCXX.h:4553
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition ExprCXX.h:4559
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition ExprCXX.h:4562
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition Expr.h:5070
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition Expr.h:5130
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:4639
Stmt - This represents one statement.
Definition Stmt.h:85
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.cpp:367
@ NoStmtClass
Definition Stmt.h:88
StmtClass getStmtClass() const
Definition Stmt.h:1505
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:343
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1819
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:4717
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition ExprCXX.h:4807
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:2521
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3852
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.
PackIndexingTemplateStorage * getAsPackIndexingTemplate() const
Retrieve the pack-index-template-name storage, if any.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceLocation getLAngleLoc() const
Definition TypeLoc.h:1938
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:1953
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:1936
SourceLocation getTemplateKeywordLoc() const
Definition TypeLoc.h:1932
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1922
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:1918
Wrapper for template type parameters.
Definition TypeLoc.h:881
The top declaration context.
Definition Decl.h:106
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)
ExprResult TransformLambdaConstraint(Expr *AC)
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.
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.
OMPClause * RebuildOMPNumTeamsClause(ArrayRef< Expr * > VarList, OpenMPNumTeamsClauseModifier Modifier, Expr *ModifierExpr, SourceLocation ModifierLoc, OpenMPNumTeamsClauseModifier ModifierExtra, Expr *ModifierExtraExpr, SourceLocation ModifierExtraLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_teams' clause.
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)
TemplateName RebuildPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr, bool FullySubstituted, ArrayRef< TemplateName > Expansions={})
Build a new pack-index-template-name ([temp.names]).
QualType RebuildTypeOfType(QualType Underlying, TypeOfKind Kind)
Build a new typeof(type) type.
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, Expr *SubExpr, TypeSourceInfo *TInfo, SourceLocation RParenLoc)
Build a new va_arg expression.
ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, SourceLocation RParenLoc)
Build a new C++ zero-initialization expression.
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr)
StmtResult RebuildSEHFinallyStmt(SourceLocation Loc, Stmt *Block)
OMPClause * RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'simdlen' clause.
StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
Build a new C++ try statement.
StmtDiscardKind
The reason why the value of a statement is not discarded, if any.
ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, UnresolvedLookupExpr *OpCoawaitLookup, bool IsImplicit)
Build a new co_await expression.
bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, unsigned NumInputs, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
ExprResult RebuildDesignatedInitExpr(Designation &Desig, MultiExprArg ArrayExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Build a new designated initializer expression.
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 RebuildInitList(SourceLocation LBraceLoc, MultiExprArg Inits, SourceLocation RBraceLoc, bool IsExplicit)
Build a new initializer list 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.
OMPClause * RebuildOpenMPTransparentClause(Expr *ImpexType, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
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.
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.
TemplateName TransformConceptTemplateName(TemplateName Name, SourceLocation NameLoc)
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...
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.
QualType RebuildAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateName TypeConstraintConcept, ArrayRef< TemplateArgument > TypeConstraintArgs)
Build a new C++11 auto type.
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.
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 * 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.
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)
OMPClause * RebuildOMPCountsClause(ArrayRef< Expr * > Counts, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, std::optional< unsigned > FillIdx, SourceLocation FillLoc)
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.
OMPClause * RebuildOMPThreadLimitClause(ArrayRef< Expr * > VarList, OpenMPThreadLimitClauseModifier Modifier, Expr *ModifierExpr, SourceLocation ModifierLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'thread_limit' clause.
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.
OMPClause * RebuildOMPNumThreadsClause(ArrayRef< Expr * > VarList, OpenMPNumThreadsClauseModifier PrescriptivenessModifier, SourceLocation PrescriptivenessModifierLoc, OpenMPNumThreadsClauseModifier DimsModifier, Expr *DimsModifierExpr, SourceLocation DimsModifierLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_threads' clause.
QualType RebuildDependentSizedArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new dependent-sized array type given the element type, size modifier, size expression,...
NamedDecl * TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc)
Transform the given declaration, which was the first part of a nested-name-specifier in a member acce...
OMPClause * RebuildOMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'inclusive' clause.
StmtResult TransformOMPInformationalDirective(OMPExecutableDirective *S)
This is mostly the same as above, but allows 'informational' class directives when rebuilding the stm...
concepts::ExprRequirement * RebuildExprRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
OMPClause * RebuildOMPTransparentClause(Expr *ImpexTypeArg, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
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 RebuildExtVectorOrMatrixElementExpr(Expr *Base, SourceLocation OpLoc, bool IsArrow, SourceLocation AccessorLoc, IdentifierInfo &Accessor)
Build a new extended vector or matrix element access expression.
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.
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'.
ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc, TypeSourceInfo *Type, const Designation &Desig, SourceLocation RParenLoc)
Build a new builtin offsetof expression.
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.
QualType RebuildDeducedTemplateSpecializationType(DeducedKind DK, QualType DeducedAsType, ElaboratedTypeKeyword Keyword, TemplateName Template)
By default, builds a new DeducedTemplateSpecializationType with the given deduced 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 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)
OMPClause * RebuildOMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, OpenMPUseDevicePtrFallbackModifier FallbackModifier, SourceLocation FallbackModifierLoc)
Build a new OpenMP 'use_device_ptr' clause.
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.
ExprResult RebuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, unsigned Index, QualType ParamType, SourceLocation Loc, TemplateArgument Arg, UnsignedOrNone PackIndex, bool Final)
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:2766
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:6295
A container of type source information.
Definition TypeBase.h:8389
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:8400
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:2900
The base class of the type hierarchy.
Definition TypeBase.h:1879
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition TypeBase.h:2469
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition TypeBase.h:9177
bool isObjCObjectPointerType() const
Definition TypeBase.h:8834
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9254
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3697
Wrapper for source info for typedefs.
Definition TypeLoc.h:777
void setTypeofLoc(SourceLocation Loc)
Definition TypeLoc.h:2231
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2669
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2288
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition Expr.h:2333
Expr * getSubExpr() const
Definition Expr.h:2329
Opcode getOpcode() const
Definition Expr.h:2324
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:1443
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2375
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:1039
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:3372
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition ExprCXX.h:3446
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition ExprCXX.h:3441
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:463
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4179
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:6100
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition ExprCXX.h:644
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3428
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3492
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:5001
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:713
QualType getType() const
Definition Decl.h:724
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Definition Decl.cpp:5660
Value()=default
Represents a variable declaration or definition.
Definition Decl.h:933
@ CInit
C-style initialization with assignment.
Definition Decl.h:938
@ CallInit
Call-style initialization (C++98)
Definition Decl.h:941
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1175
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:4044
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2076
Represents a GCC generic vector type.
Definition TypeBase.h:4253
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2709
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:791
bool ContainsUnexpandedParameterPack
Whether this contains an unexpanded parameter pack.
Definition ScopeInfo.h:729
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition ScopeInfo.h:872
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Definition ScopeInfo.h:875
@ 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
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:983
Top level wrappers for InstallAPI frontend operations.
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
@ CPlusPlus23
OpenACCAtomicKind
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition TypeBase.h:1838
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
TryCaptureKind
Definition Sema.h:647
@ 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:40
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:61
CXXConstructionKind
Definition ExprCXX.h:1544
@ 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:162
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:598
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
Definition Sema.h:243
@ 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:919
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
Definition OpenMPKinds.h:39
OpenMPNumTeamsClauseModifier
@ OMPC_NUMTEAMS_unknown
OpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
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
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:912
@ Result
The result type of a method or function.
Definition TypeBase.h:906
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3797
OptionalUnsigned< unsigned > UnsignedOrNone
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:6008
bool transformOMPMappableExprListClause(TreeTransform< Derived > &TT, OMPMappableExprListClause< T > *C, llvm::SmallVectorImpl< Expr * > &Vars, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperIdInfo, llvm::SmallVectorImpl< Expr * > &UnresolvedMappers)
OpenMPUseDevicePtrFallbackModifier
OpenMP 6.1 use_device_ptr fallback modifier.
ExprResult ExprError()
Definition Ownership.h:265
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:556
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
DeducedKind
Definition TypeBase.h:1811
@ Deduced
The normal deduced case.
Definition TypeBase.h:1818
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
Definition TypeBase.h:1813
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:136
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition Specifiers.h:140
OpenMPThreadLimitClauseModifier
@ Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition Sema.h:806
@ Exists
The symbol exists.
Definition Sema.h:799
@ Error
An error occurred.
Definition Sema.h:809
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:802
MutableArrayRef< Stmt * > MultiStmtArg
Definition Ownership.h:260
OpenMPNumThreadsClauseModifier
U cast(CodeGen::Address addr)
Definition Address.h:327
@ PackIndex
Index of a pack indexing expression or specifier.
Definition Sema.h:845
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:5057
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5983
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:6004
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5994
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:6001
ActionResult< Expr * > ExprResult
Definition Ownership.h:249
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
@ Parens
New-expression has a C++98 paren-delimited initializer.
Definition ExprCXX.h:2249
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:2033
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
Expr * AllocatorTraits
Allocator traits.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
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)
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
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition TypeBase.h:5122
Holds information about the various types of exception specification.
Definition TypeBase.h:5442
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5458
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5444
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5447
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5450
Extra information about a function prototype.
Definition TypeBase.h:5470
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5475
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:3434
const NamespaceBaseDecl * Namespace
Iterator range representation begin:end[:step].
Definition ExprOpenMP.h:154
This structure contains most locations needed for by an OMPVarListClause.
An element in an Objective-C dictionary literal.
Definition ExprObjC.h:294
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:13209
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13240
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
Definition Sema.h:6887
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition Sema.h:6855
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
Definition Sema.h:6893
ExpressionEvaluationContext Context
The expression evaluation context.
Definition Sema.h:6803
An RAII helper that pops function a function scope on exit.
Definition Sema.h:1328
Keeps information about an identifier in a nested-name-spec.
Definition Sema.h:3332
Location information for a TemplateArgument.
UnsignedOrNone OrigNumExpansions
SourceLocation Ellipsis
UnsignedOrNone NumExpansions