clang 23.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
642 /// Transform the given template argument.
643 ///
644 /// By default, this operation transforms the type, expression, or
645 /// declaration stored within the template argument and constructs a
646 /// new template argument from the transformed result. Subclasses may
647 /// override this function to provide alternate behavior.
648 ///
649 /// Returns true if there was an error.
651 TemplateArgumentLoc &Output,
652 bool Uneval = false);
653
655 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
656 TemplateName Name, SourceLocation NameLoc);
657
658 /// Transform the given set of template arguments.
659 ///
660 /// By default, this operation transforms all of the template arguments
661 /// in the input set using \c TransformTemplateArgument(), and appends
662 /// the transformed arguments to the output list.
663 ///
664 /// Note that this overload of \c TransformTemplateArguments() is merely
665 /// a convenience function. Subclasses that wish to override this behavior
666 /// should override the iterator-based member template version.
667 ///
668 /// \param Inputs The set of template arguments to be transformed.
669 ///
670 /// \param NumInputs The number of template arguments in \p Inputs.
671 ///
672 /// \param Outputs The set of transformed template arguments output by this
673 /// routine.
674 ///
675 /// Returns true if an error occurred.
677 unsigned NumInputs,
679 bool Uneval = false) {
680 return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs,
681 Uneval);
682 }
683
684 /// Transform the given set of template arguments.
685 ///
686 /// By default, this operation transforms all of the template arguments
687 /// in the input set using \c TransformTemplateArgument(), and appends
688 /// the transformed arguments to the output list.
689 ///
690 /// \param First An iterator to the first template argument.
691 ///
692 /// \param Last An iterator one step past the last template argument.
693 ///
694 /// \param Outputs The set of transformed template arguments output by this
695 /// routine.
696 ///
697 /// Returns true if an error occurred.
698 template<typename InputIterator>
700 InputIterator Last,
702 bool Uneval = false);
703
704 template <typename InputIterator>
706 InputIterator Last,
708 bool Uneval = false);
709
710 /// Checks if the argument pack from \p In will need to be expanded and does
711 /// the necessary prework.
712 /// Whether the expansion is needed is captured in Info.Expand.
713 ///
714 /// - When the expansion is required, \p Out will be a template pattern that
715 /// would need to be expanded.
716 /// - When the expansion must not happen, \p Out will be a pack that must be
717 /// returned to the outputs directly.
718 ///
719 /// \return true iff the error occurred
722
723 /// Fakes up a TemplateArgumentLoc for a given TemplateArgument.
725 TemplateArgumentLoc &ArgLoc);
726
727 /// Fakes up a TypeSourceInfo for a type.
729 return SemaRef.Context.getTrivialTypeSourceInfo(T,
731 }
732
733#define ABSTRACT_TYPELOC(CLASS, PARENT)
734#define TYPELOC(CLASS, PARENT) \
735 QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
736#include "clang/AST/TypeLocNodes.def"
737
740 bool SuppressObjCLifetime);
744 bool SuppressObjCLifetime);
745
746 template<typename Fn>
749 CXXRecordDecl *ThisContext,
750 Qualifiers ThisTypeQuals,
752
755 SmallVectorImpl<QualType> &Exceptions,
756 bool &Changed);
757
759
762 QualType ObjectType,
763 NamedDecl *FirstQualifierInScope,
764 bool AllowInjectedClassName);
765
767
768 /// Transforms the parameters of a function type into the
769 /// given vectors.
770 ///
771 /// The result vectors should be kept in sync; null entries in the
772 /// variables vector are acceptable.
773 ///
774 /// LastParamTransformed, if non-null, will be set to the index of the last
775 /// parameter on which transformation was started. In the event of an error,
776 /// this will contain the parameter which failed to instantiate.
777 ///
778 /// Return true on error.
781 const QualType *ParamTypes,
782 const FunctionProtoType::ExtParameterInfo *ParamInfos,
784 Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed);
785
788 const QualType *ParamTypes,
789 const FunctionProtoType::ExtParameterInfo *ParamInfos,
792 return getDerived().TransformFunctionTypeParams(
793 Loc, Params, ParamTypes, ParamInfos, PTypes, PVars, PInfos, nullptr);
794 }
795
796 /// Transforms the parameters of a requires expresison into the given vectors.
797 ///
798 /// The result vectors should be kept in sync; null entries in the
799 /// variables vector are acceptable.
800 ///
801 /// Returns an unset ExprResult on success. Returns an ExprResult the 'not
802 /// satisfied' RequiresExpr if subsitution failed, OR an ExprError, both of
803 /// which are cases where transformation shouldn't continue.
805 SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
811 KWLoc, Params, /*ParamTypes=*/nullptr,
812 /*ParamInfos=*/nullptr, PTypes, &TransParams, PInfos))
813 return ExprError();
814
815 return ExprResult{};
816 }
817
818 /// Transforms a single function-type parameter. Return null
819 /// on error.
820 ///
821 /// \param indexAdjustment - A number to add to the parameter's
822 /// scope index; can be negative
824 int indexAdjustment,
825 UnsignedOrNone NumExpansions,
826 bool ExpectParameterPack);
827
828 /// Transform the body of a lambda-expression.
830 /// Alternative implementation of TransformLambdaBody that skips transforming
831 /// the body.
833
839
841
844
849
851
853 bool IsAddressOfOperand,
854 TypeSourceInfo **RecoveryTSI);
855
857 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
858 TypeSourceInfo **RecoveryTSI);
859
861 bool IsAddressOfOperand);
862
864
866
867// FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
868// amount of stack usage with clang.
869#define STMT(Node, Parent) \
870 LLVM_ATTRIBUTE_NOINLINE \
871 StmtResult Transform##Node(Node *S);
872#define VALUESTMT(Node, Parent) \
873 LLVM_ATTRIBUTE_NOINLINE \
874 StmtResult Transform##Node(Node *S, StmtDiscardKind SDK);
875#define EXPR(Node, Parent) \
876 LLVM_ATTRIBUTE_NOINLINE \
877 ExprResult Transform##Node(Node *E);
878#define ABSTRACT_STMT(Stmt)
879#include "clang/AST/StmtNodes.inc"
880
881#define GEN_CLANG_CLAUSE_CLASS
882#define CLAUSE_CLASS(Enum, Str, Class) \
883 LLVM_ATTRIBUTE_NOINLINE \
884 OMPClause *Transform##Class(Class *S);
885#include "llvm/Frontend/OpenMP/OMP.inc"
886
887 /// Build a new qualified type given its unqualified type and type location.
888 ///
889 /// By default, this routine adds type qualifiers only to types that can
890 /// have qualifiers, and silently suppresses those qualifiers that are not
891 /// permitted. Subclasses may override this routine to provide different
892 /// behavior.
894
895 /// Build a new pointer type given its pointee type.
896 ///
897 /// By default, performs semantic analysis when building the pointer type.
898 /// Subclasses may override this routine to provide different behavior.
900
901 /// Build a new block pointer type given its pointee type.
902 ///
903 /// By default, performs semantic analysis when building the block pointer
904 /// type. Subclasses may override this routine to provide different behavior.
906
907 /// Build a new reference type given the type it references.
908 ///
909 /// By default, performs semantic analysis when building the
910 /// reference type. Subclasses may override this routine to provide
911 /// different behavior.
912 ///
913 /// \param LValue whether the type was written with an lvalue sigil
914 /// or an rvalue sigil.
916 bool LValue,
917 SourceLocation Sigil);
918
919 /// Build a new member pointer type given the pointee type and the
920 /// qualifier it refers into.
921 ///
922 /// By default, performs semantic analysis when building the member pointer
923 /// type. Subclasses may override this routine to provide different behavior.
925 const CXXScopeSpec &SS, CXXRecordDecl *Cls,
926 SourceLocation Sigil);
927
929 SourceLocation ProtocolLAngleLoc,
931 ArrayRef<SourceLocation> ProtocolLocs,
932 SourceLocation ProtocolRAngleLoc);
933
934 /// Build an Objective-C object type.
935 ///
936 /// By default, performs semantic analysis when building the object type.
937 /// Subclasses may override this routine to provide different behavior.
939 SourceLocation Loc,
940 SourceLocation TypeArgsLAngleLoc,
942 SourceLocation TypeArgsRAngleLoc,
943 SourceLocation ProtocolLAngleLoc,
945 ArrayRef<SourceLocation> ProtocolLocs,
946 SourceLocation ProtocolRAngleLoc);
947
948 /// Build a new Objective-C object pointer type given the pointee type.
949 ///
950 /// By default, directly builds the pointer type, with no additional semantic
951 /// analysis.
954
955 /// Build a new array type given the element type, size
956 /// modifier, size of the array (if known), size expression, and index type
957 /// qualifiers.
958 ///
959 /// By default, performs semantic analysis when building the array type.
960 /// Subclasses may override this routine to provide different behavior.
961 /// Also by default, all of the other Rebuild*Array
963 const llvm::APInt *Size, Expr *SizeExpr,
964 unsigned IndexTypeQuals, SourceRange BracketsRange);
965
966 /// Build a new constant array type given the element type, size
967 /// modifier, (known) size of the array, and index type qualifiers.
968 ///
969 /// By default, performs semantic analysis when building the array type.
970 /// Subclasses may override this routine to provide different behavior.
972 ArraySizeModifier SizeMod,
973 const llvm::APInt &Size, Expr *SizeExpr,
974 unsigned IndexTypeQuals,
975 SourceRange BracketsRange);
976
977 /// Build a new incomplete array type given the element type, size
978 /// modifier, and index type qualifiers.
979 ///
980 /// By default, performs semantic analysis when building the array type.
981 /// Subclasses may override this routine to provide different behavior.
983 ArraySizeModifier SizeMod,
984 unsigned IndexTypeQuals,
985 SourceRange BracketsRange);
986
987 /// Build a new variable-length array type given the element type,
988 /// size modifier, size expression, and index type qualifiers.
989 ///
990 /// By default, performs semantic analysis when building the array type.
991 /// Subclasses may override this routine to provide different behavior.
993 ArraySizeModifier SizeMod, Expr *SizeExpr,
994 unsigned IndexTypeQuals,
995 SourceRange BracketsRange);
996
997 /// Build a new dependent-sized array type given the element type,
998 /// size modifier, size expression, and index type qualifiers.
999 ///
1000 /// By default, performs semantic analysis when building the array type.
1001 /// Subclasses may override this routine to provide different behavior.
1003 ArraySizeModifier SizeMod,
1004 Expr *SizeExpr,
1005 unsigned IndexTypeQuals,
1006 SourceRange BracketsRange);
1007
1008 /// Build a new vector type given the element type and
1009 /// number of elements.
1010 ///
1011 /// By default, performs semantic analysis when building the vector type.
1012 /// Subclasses may override this routine to provide different behavior.
1013 QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
1014 VectorKind VecKind);
1015
1016 /// Build a new potentially dependently-sized extended vector type
1017 /// given the element type and number of elements.
1018 ///
1019 /// By default, performs semantic analysis when building the vector type.
1020 /// Subclasses may override this routine to provide different behavior.
1022 SourceLocation AttributeLoc, VectorKind);
1023
1024 /// Build a new extended vector type given the element type and
1025 /// number of elements.
1026 ///
1027 /// By default, performs semantic analysis when building the vector type.
1028 /// Subclasses may override this routine to provide different behavior.
1029 QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
1030 SourceLocation AttributeLoc);
1031
1032 /// Build a new potentially dependently-sized extended vector type
1033 /// given the element type and number of elements.
1034 ///
1035 /// By default, performs semantic analysis when building the vector type.
1036 /// Subclasses may override this routine to provide different behavior.
1038 Expr *SizeExpr,
1039 SourceLocation AttributeLoc);
1040
1041 /// Build a new matrix type given the element type and dimensions.
1042 QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows,
1043 unsigned NumColumns);
1044
1045 /// Build a new matrix type given the type and dependently-defined
1046 /// dimensions.
1048 Expr *ColumnExpr,
1049 SourceLocation AttributeLoc);
1050
1051 /// Build a new DependentAddressSpaceType or return the pointee
1052 /// type variable with the correct address space (retrieved from
1053 /// AddrSpaceExpr) applied to it. The former will be returned in cases
1054 /// where the address space remains dependent.
1055 ///
1056 /// By default, performs semantic analysis when building the type with address
1057 /// space applied. Subclasses may override this routine to provide different
1058 /// behavior.
1060 Expr *AddrSpaceExpr,
1061 SourceLocation AttributeLoc);
1062
1063 /// Build a new function type.
1064 ///
1065 /// By default, performs semantic analysis when building the function type.
1066 /// Subclasses may override this routine to provide different behavior.
1068 MutableArrayRef<QualType> ParamTypes,
1070
1071 /// Build a new unprototyped function type.
1073
1074 /// Rebuild an unresolved typename type, given the decl that
1075 /// the UnresolvedUsingTypenameDecl was transformed to.
1077 NestedNameSpecifier Qualifier,
1078 SourceLocation NameLoc, Decl *D);
1079
1080 /// Build a new type found via an alias.
1083 QualType UnderlyingType) {
1084 return SemaRef.Context.getUsingType(Keyword, Qualifier, D, UnderlyingType);
1085 }
1086
1087 /// Build a new typedef type.
1089 NestedNameSpecifier Qualifier,
1091 return SemaRef.Context.getTypedefType(Keyword, Qualifier, Typedef);
1092 }
1093
1094 /// Build a new MacroDefined type.
1096 const IdentifierInfo *MacroII) {
1097 return SemaRef.Context.getMacroQualifiedType(T, MacroII);
1098 }
1099
1100 /// Build a new class/struct/union/enum type.
1102 NestedNameSpecifier Qualifier, TagDecl *Tag) {
1103 return SemaRef.Context.getTagType(Keyword, Qualifier, Tag,
1104 /*OwnsTag=*/false);
1105 }
1107 return SemaRef.Context.getCanonicalTagType(Tag);
1108 }
1109
1110 /// Build a new typeof(expr) type.
1111 ///
1112 /// By default, performs semantic analysis when building the typeof type.
1113 /// Subclasses may override this routine to provide different behavior.
1115 TypeOfKind Kind);
1116
1117 /// Build a new typeof(type) type.
1118 ///
1119 /// By default, builds a new TypeOfType with the given underlying type.
1121
1122 /// Build a new unary transform type.
1124 UnaryTransformType::UTTKind UKind,
1125 SourceLocation Loc);
1126
1127 /// Build a new C++11 decltype type.
1128 ///
1129 /// By default, performs semantic analysis when building the decltype type.
1130 /// Subclasses may override this routine to provide different behavior.
1132
1134 SourceLocation Loc,
1135 SourceLocation EllipsisLoc,
1136 bool FullySubstituted,
1137 ArrayRef<QualType> Expansions = {});
1138
1139 /// Build a new C++11 auto type.
1140 ///
1141 /// By default, builds a new AutoType with the given deduced type.
1144 ConceptDecl *TypeConstraintConcept,
1145 ArrayRef<TemplateArgument> TypeConstraintArgs) {
1146 return SemaRef.Context.getAutoType(
1147 DK, DeducedAsType, Keyword, TypeConstraintConcept, TypeConstraintArgs);
1148 }
1149
1150 /// By default, builds a new DeducedTemplateSpecializationType with the given
1151 /// deduced type.
1155 return SemaRef.Context.getDeducedTemplateSpecializationType(
1156 DK, DeducedAsType, Keyword, Template);
1157 }
1158
1159 /// Build a new template specialization type.
1160 ///
1161 /// By default, performs semantic analysis when building the template
1162 /// specialization type. Subclasses may override this routine to provide
1163 /// different behavior.
1166 SourceLocation TemplateLoc,
1168
1169 /// Build a new parenthesized type.
1170 ///
1171 /// By default, builds a new ParenType type from the inner type.
1172 /// Subclasses may override this routine to provide different behavior.
1174 return SemaRef.BuildParenType(InnerType);
1175 }
1176
1177 /// Build a new typename type that refers to an identifier.
1178 ///
1179 /// By default, performs semantic analysis when building the typename type
1180 /// (or elaborated type). Subclasses may override this routine to provide
1181 /// different behavior.
1183 SourceLocation KeywordLoc,
1184 NestedNameSpecifierLoc QualifierLoc,
1185 const IdentifierInfo *Id,
1186 SourceLocation IdLoc,
1187 bool DeducedTSTContext) {
1188 CXXScopeSpec SS;
1189 SS.Adopt(QualifierLoc);
1190
1191 if (QualifierLoc.getNestedNameSpecifier().isDependent()) {
1192 // If the name is still dependent, just build a new dependent name type.
1193 if (!SemaRef.computeDeclContext(SS))
1194 return SemaRef.Context.getDependentNameType(Keyword,
1195 QualifierLoc.getNestedNameSpecifier(),
1196 Id);
1197 }
1198
1201 return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1202 *Id, IdLoc, DeducedTSTContext);
1203 }
1204
1206
1207 // We had a dependent elaborated-type-specifier that has been transformed
1208 // into a non-dependent elaborated-type-specifier. Find the tag we're
1209 // referring to.
1211 DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1212 if (!DC)
1213 return QualType();
1214
1215 if (SemaRef.RequireCompleteDeclContext(SS, DC))
1216 return QualType();
1217
1218 TagDecl *Tag = nullptr;
1219 SemaRef.LookupQualifiedName(Result, DC);
1220 switch (Result.getResultKind()) {
1223 break;
1224
1226 Tag = Result.getAsSingle<TagDecl>();
1227 break;
1228
1231 llvm_unreachable("Tag lookup cannot find non-tags");
1232
1234 // Let the LookupResult structure handle ambiguities.
1235 return QualType();
1236 }
1237
1238 if (!Tag) {
1239 // Check where the name exists but isn't a tag type and use that to emit
1240 // better diagnostics.
1242 SemaRef.LookupQualifiedName(Result, DC);
1243 switch (Result.getResultKind()) {
1247 NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1248 NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1249 SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag)
1250 << SomeDecl << NTK << Kind;
1251 SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1252 break;
1253 }
1254 default:
1255 SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1256 << Kind << Id << DC << QualifierLoc.getSourceRange();
1257 break;
1258 }
1259 return QualType();
1260 }
1261 if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1262 IdLoc, Id)) {
1263 SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1264 SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1265 return QualType();
1266 }
1267 return getDerived().RebuildTagType(
1268 Keyword, QualifierLoc.getNestedNameSpecifier(), Tag);
1269 }
1270
1271 /// Build a new pack expansion type.
1272 ///
1273 /// By default, builds a new PackExpansionType type from the given pattern.
1274 /// Subclasses may override this routine to provide different behavior.
1276 SourceLocation EllipsisLoc,
1277 UnsignedOrNone NumExpansions) {
1278 return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1279 NumExpansions);
1280 }
1281
1282 /// Build a new atomic type given its value type.
1283 ///
1284 /// By default, performs semantic analysis when building the atomic type.
1285 /// Subclasses may override this routine to provide different behavior.
1287
1288 /// Build a new pipe type given its value type.
1290 bool isReadPipe);
1291
1292 /// Build a bit-precise int given its value type.
1293 QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits,
1294 SourceLocation Loc);
1295
1296 /// Build a dependent bit-precise int given its value type.
1297 QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
1298 SourceLocation Loc);
1299
1300 /// Build a new template name given a nested name specifier, a flag
1301 /// indicating whether the "template" keyword was provided, and the template
1302 /// that the template name refers to.
1303 ///
1304 /// By default, builds the new template name directly. Subclasses may override
1305 /// this routine to provide different behavior.
1307 TemplateName Name);
1308
1309 /// Build a new template name given a nested name specifier and the
1310 /// name that is referred to as a template.
1311 ///
1312 /// By default, performs semantic analysis to determine whether the name can
1313 /// be resolved to a specific template, then builds the appropriate kind of
1314 /// template name. Subclasses may override this routine to provide different
1315 /// behavior.
1317 SourceLocation TemplateKWLoc,
1318 const IdentifierInfo &Name,
1319 SourceLocation NameLoc, QualType ObjectType,
1320 bool AllowInjectedClassName);
1321
1322 /// Build a new template name given a nested name specifier and the
1323 /// overloaded operator name that is referred to as a template.
1324 ///
1325 /// By default, performs semantic analysis to determine whether the name can
1326 /// be resolved to a specific template, then builds the appropriate kind of
1327 /// template name. Subclasses may override this routine to provide different
1328 /// behavior.
1330 SourceLocation TemplateKWLoc,
1331 OverloadedOperatorKind Operator,
1332 SourceLocation NameLoc, QualType ObjectType,
1333 bool AllowInjectedClassName);
1334
1336 SourceLocation TemplateKWLoc,
1338 SourceLocation NameLoc, QualType ObjectType,
1339 bool AllowInjectedClassName);
1340
1341 /// Build a new template name given a template template parameter pack
1342 /// and the
1343 ///
1344 /// By default, performs semantic analysis to determine whether the name can
1345 /// be resolved to a specific template, then builds the appropriate kind of
1346 /// template name. Subclasses may override this routine to provide different
1347 /// behavior.
1349 Decl *AssociatedDecl, unsigned Index,
1350 bool Final) {
1352 ArgPack, AssociatedDecl, Index, Final);
1353 }
1354
1355 /// Build a new compound statement.
1356 ///
1357 /// By default, performs semantic analysis to build the new statement.
1358 /// Subclasses may override this routine to provide different behavior.
1360 MultiStmtArg Statements,
1361 SourceLocation RBraceLoc,
1362 bool IsStmtExpr) {
1363 return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1364 IsStmtExpr);
1365 }
1366
1367 /// Build a new case statement.
1368 ///
1369 /// By default, performs semantic analysis to build the new statement.
1370 /// Subclasses may override this routine to provide different behavior.
1372 Expr *LHS,
1373 SourceLocation EllipsisLoc,
1374 Expr *RHS,
1375 SourceLocation ColonLoc) {
1376 return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1377 ColonLoc);
1378 }
1379
1380 /// Attach the body to a new case statement.
1381 ///
1382 /// By default, performs semantic analysis to build the new statement.
1383 /// Subclasses may override this routine to provide different behavior.
1385 getSema().ActOnCaseStmtBody(S, Body);
1386 return S;
1387 }
1388
1389 /// Build a new default statement.
1390 ///
1391 /// By default, performs semantic analysis to build the new statement.
1392 /// Subclasses may override this routine to provide different behavior.
1394 SourceLocation ColonLoc,
1395 Stmt *SubStmt) {
1396 return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1397 /*CurScope=*/nullptr);
1398 }
1399
1400 /// Build a new label statement.
1401 ///
1402 /// By default, performs semantic analysis to build the new statement.
1403 /// Subclasses may override this routine to provide different behavior.
1405 SourceLocation ColonLoc, Stmt *SubStmt) {
1406 return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1407 }
1408
1409 /// Build a new attributed statement.
1410 ///
1411 /// By default, performs semantic analysis to build the new statement.
1412 /// Subclasses may override this routine to provide different behavior.
1415 Stmt *SubStmt) {
1416 if (SemaRef.CheckRebuiltStmtAttributes(Attrs))
1417 return StmtError();
1418 return SemaRef.BuildAttributedStmt(AttrLoc, Attrs, SubStmt);
1419 }
1420
1421 /// Build a new "if" statement.
1422 ///
1423 /// By default, performs semantic analysis to build the new statement.
1424 /// Subclasses may override this routine to provide different behavior.
1427 SourceLocation RParenLoc, Stmt *Init, Stmt *Then,
1428 SourceLocation ElseLoc, Stmt *Else) {
1429 return getSema().ActOnIfStmt(IfLoc, Kind, LParenLoc, Init, Cond, RParenLoc,
1430 Then, ElseLoc, Else);
1431 }
1432
1433 /// Start building a new switch statement.
1434 ///
1435 /// By default, performs semantic analysis to build the new statement.
1436 /// Subclasses may override this routine to provide different behavior.
1438 SourceLocation LParenLoc, Stmt *Init,
1440 SourceLocation RParenLoc) {
1441 return getSema().ActOnStartOfSwitchStmt(SwitchLoc, LParenLoc, Init, Cond,
1442 RParenLoc);
1443 }
1444
1445 /// Attach the body to the switch statement.
1446 ///
1447 /// By default, performs semantic analysis to build the new statement.
1448 /// Subclasses may override this routine to provide different behavior.
1450 Stmt *Switch, Stmt *Body) {
1451 return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1452 }
1453
1454 /// Build a new while statement.
1455 ///
1456 /// By default, performs semantic analysis to build the new statement.
1457 /// Subclasses may override this routine to provide different behavior.
1460 SourceLocation RParenLoc, Stmt *Body) {
1461 return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body);
1462 }
1463
1464 /// Build a new do-while statement.
1465 ///
1466 /// By default, performs semantic analysis to build the new statement.
1467 /// Subclasses may override this routine to provide different behavior.
1469 SourceLocation WhileLoc, SourceLocation LParenLoc,
1470 Expr *Cond, SourceLocation RParenLoc) {
1471 return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1472 Cond, RParenLoc);
1473 }
1474
1475 /// Build a new for statement.
1476 ///
1477 /// By default, performs semantic analysis to build the new statement.
1478 /// Subclasses may override this routine to provide different behavior.
1481 Sema::FullExprArg Inc, SourceLocation RParenLoc,
1482 Stmt *Body) {
1483 return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1484 Inc, RParenLoc, Body);
1485 }
1486
1487 /// Build a new goto statement.
1488 ///
1489 /// By default, performs semantic analysis to build the new statement.
1490 /// Subclasses may override this routine to provide different behavior.
1492 LabelDecl *Label) {
1493 return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1494 }
1495
1496 /// Build a new indirect goto statement.
1497 ///
1498 /// By default, performs semantic analysis to build the new statement.
1499 /// Subclasses may override this routine to provide different behavior.
1501 SourceLocation StarLoc,
1502 Expr *Target) {
1503 return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1504 }
1505
1506 /// Build a new return statement.
1507 ///
1508 /// By default, performs semantic analysis to build the new statement.
1509 /// Subclasses may override this routine to provide different behavior.
1511 return getSema().BuildReturnStmt(ReturnLoc, Result);
1512 }
1513
1514 /// Build a new declaration statement.
1515 ///
1516 /// By default, performs semantic analysis to build the new statement.
1517 /// Subclasses may override this routine to provide different behavior.
1519 SourceLocation StartLoc, SourceLocation EndLoc) {
1521 return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1522 }
1523
1524 /// Build a new inline asm statement.
1525 ///
1526 /// By default, performs semantic analysis to build the new statement.
1527 /// Subclasses may override this routine to provide different behavior.
1529 bool IsVolatile, unsigned NumOutputs,
1530 unsigned NumInputs, IdentifierInfo **Names,
1531 MultiExprArg Constraints, MultiExprArg Exprs,
1532 Expr *AsmString, MultiExprArg Clobbers,
1533 unsigned NumLabels,
1534 SourceLocation RParenLoc) {
1535 return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1536 NumInputs, Names, Constraints, Exprs,
1537 AsmString, Clobbers, NumLabels, RParenLoc);
1538 }
1539
1540 /// Build a new MS style inline asm statement.
1541 ///
1542 /// By default, performs semantic analysis to build the new statement.
1543 /// Subclasses may override this routine to provide different behavior.
1545 ArrayRef<Token> AsmToks,
1546 StringRef AsmString,
1547 unsigned NumOutputs, unsigned NumInputs,
1548 ArrayRef<StringRef> Constraints,
1549 ArrayRef<StringRef> Clobbers,
1550 ArrayRef<Expr*> Exprs,
1551 SourceLocation EndLoc) {
1552 return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1553 NumOutputs, NumInputs,
1554 Constraints, Clobbers, Exprs, EndLoc);
1555 }
1556
1557 /// Build a new co_return statement.
1558 ///
1559 /// By default, performs semantic analysis to build the new statement.
1560 /// Subclasses may override this routine to provide different behavior.
1562 bool IsImplicit) {
1563 return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1564 }
1565
1566 /// Build a new co_await expression.
1567 ///
1568 /// By default, performs semantic analysis to build the new expression.
1569 /// Subclasses may override this routine to provide different behavior.
1571 UnresolvedLookupExpr *OpCoawaitLookup,
1572 bool IsImplicit) {
1573 // This function rebuilds a coawait-expr given its operator.
1574 // For an explicit coawait-expr, the rebuild involves the full set
1575 // of transformations performed by BuildUnresolvedCoawaitExpr(),
1576 // including calling await_transform().
1577 // For an implicit coawait-expr, we need to rebuild the "operator
1578 // coawait" but not await_transform(), so use BuildResolvedCoawaitExpr().
1579 // This mirrors how the implicit CoawaitExpr is originally created
1580 // in Sema::ActOnCoroutineBodyStart().
1581 if (IsImplicit) {
1583 CoawaitLoc, Operand, OpCoawaitLookup);
1584 if (Suspend.isInvalid())
1585 return ExprError();
1586 return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Operand,
1587 Suspend.get(), true);
1588 }
1589
1590 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Operand,
1591 OpCoawaitLookup);
1592 }
1593
1594 /// Build a new co_await expression.
1595 ///
1596 /// By default, performs semantic analysis to build the new expression.
1597 /// Subclasses may override this routine to provide different behavior.
1599 Expr *Result,
1600 UnresolvedLookupExpr *Lookup) {
1601 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1602 }
1603
1604 /// Build a new co_yield expression.
1605 ///
1606 /// By default, performs semantic analysis to build the new expression.
1607 /// Subclasses may override this routine to provide different behavior.
1609 return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1610 }
1611
1615
1616 /// Build a new Objective-C \@try statement.
1617 ///
1618 /// By default, performs semantic analysis to build the new statement.
1619 /// Subclasses may override this routine to provide different behavior.
1621 Stmt *TryBody,
1622 MultiStmtArg CatchStmts,
1623 Stmt *Finally) {
1624 return getSema().ObjC().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1625 Finally);
1626 }
1627
1628 /// Rebuild an Objective-C exception declaration.
1629 ///
1630 /// By default, performs semantic analysis to build the new declaration.
1631 /// Subclasses may override this routine to provide different behavior.
1633 TypeSourceInfo *TInfo, QualType T) {
1635 TInfo, T, ExceptionDecl->getInnerLocStart(),
1636 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
1637 }
1638
1639 /// Build a new Objective-C \@catch statement.
1640 ///
1641 /// By default, performs semantic analysis to build the new statement.
1642 /// Subclasses may override this routine to provide different behavior.
1644 SourceLocation RParenLoc,
1645 VarDecl *Var,
1646 Stmt *Body) {
1647 return getSema().ObjC().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, Var, Body);
1648 }
1649
1650 /// Build a new Objective-C \@finally statement.
1651 ///
1652 /// By default, performs semantic analysis to build the new statement.
1653 /// Subclasses may override this routine to provide different behavior.
1655 Stmt *Body) {
1656 return getSema().ObjC().ActOnObjCAtFinallyStmt(AtLoc, Body);
1657 }
1658
1659 /// Build a new Objective-C \@throw statement.
1660 ///
1661 /// By default, performs semantic analysis to build the new statement.
1662 /// Subclasses may override this routine to provide different behavior.
1664 Expr *Operand) {
1665 return getSema().ObjC().BuildObjCAtThrowStmt(AtLoc, Operand);
1666 }
1667
1668 /// Build a new OpenMP Canonical loop.
1669 ///
1670 /// Ensures that the outermost loop in @p LoopStmt is wrapped by a
1671 /// OMPCanonicalLoop.
1673 return getSema().OpenMP().ActOnOpenMPCanonicalLoop(LoopStmt);
1674 }
1675
1676 /// Build a new OpenMP executable directive.
1677 ///
1678 /// By default, performs semantic analysis to build the new statement.
1679 /// Subclasses may override this routine to provide different behavior.
1681 DeclarationNameInfo DirName,
1682 OpenMPDirectiveKind CancelRegion,
1683 ArrayRef<OMPClause *> Clauses,
1684 Stmt *AStmt, SourceLocation StartLoc,
1685 SourceLocation EndLoc) {
1686
1688 Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1689 }
1690
1691 /// Build a new OpenMP informational directive.
1693 DeclarationNameInfo DirName,
1694 ArrayRef<OMPClause *> Clauses,
1695 Stmt *AStmt,
1696 SourceLocation StartLoc,
1697 SourceLocation EndLoc) {
1698
1700 Kind, DirName, Clauses, AStmt, StartLoc, EndLoc);
1701 }
1702
1703 /// Build a new OpenMP 'if' clause.
1704 ///
1705 /// By default, performs semantic analysis to build the new OpenMP clause.
1706 /// Subclasses may override this routine to provide different behavior.
1708 Expr *Condition, SourceLocation StartLoc,
1709 SourceLocation LParenLoc,
1710 SourceLocation NameModifierLoc,
1711 SourceLocation ColonLoc,
1712 SourceLocation EndLoc) {
1714 NameModifier, Condition, StartLoc, LParenLoc, NameModifierLoc, ColonLoc,
1715 EndLoc);
1716 }
1717
1718 /// Build a new OpenMP 'final' clause.
1719 ///
1720 /// By default, performs semantic analysis to build the new OpenMP clause.
1721 /// Subclasses may override this routine to provide different behavior.
1723 SourceLocation LParenLoc,
1724 SourceLocation EndLoc) {
1725 return getSema().OpenMP().ActOnOpenMPFinalClause(Condition, StartLoc,
1726 LParenLoc, EndLoc);
1727 }
1728
1729 /// Build a new OpenMP 'num_threads' clause.
1730 ///
1731 /// By default, performs semantic analysis to build the new OpenMP clause.
1732 /// Subclasses may override this routine to provide different behavior.
1734 Expr *NumThreads,
1735 SourceLocation StartLoc,
1736 SourceLocation LParenLoc,
1737 SourceLocation ModifierLoc,
1738 SourceLocation EndLoc) {
1740 Modifier, NumThreads, StartLoc, LParenLoc, ModifierLoc, EndLoc);
1741 }
1742
1743 /// Build a new OpenMP 'safelen' clause.
1744 ///
1745 /// By default, performs semantic analysis to build the new OpenMP clause.
1746 /// Subclasses may override this routine to provide different behavior.
1748 SourceLocation LParenLoc,
1749 SourceLocation EndLoc) {
1750 return getSema().OpenMP().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc,
1751 EndLoc);
1752 }
1753
1754 /// Build a new OpenMP 'simdlen' clause.
1755 ///
1756 /// By default, performs semantic analysis to build the new OpenMP clause.
1757 /// Subclasses may override this routine to provide different behavior.
1759 SourceLocation LParenLoc,
1760 SourceLocation EndLoc) {
1761 return getSema().OpenMP().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc,
1762 EndLoc);
1763 }
1764
1766 SourceLocation StartLoc,
1767 SourceLocation LParenLoc,
1768 SourceLocation EndLoc) {
1769 return getSema().OpenMP().ActOnOpenMPSizesClause(Sizes, StartLoc, LParenLoc,
1770 EndLoc);
1771 }
1772
1774 SourceLocation StartLoc,
1775 SourceLocation LParenLoc,
1776 SourceLocation EndLoc,
1777 std::optional<unsigned> FillIdx,
1778 SourceLocation FillLoc) {
1779 unsigned FillCount = FillIdx ? 1 : 0;
1781 Counts, StartLoc, LParenLoc, EndLoc, FillIdx, FillLoc, FillCount);
1782 }
1783
1784 /// Build a new OpenMP 'permutation' clause.
1786 SourceLocation StartLoc,
1787 SourceLocation LParenLoc,
1788 SourceLocation EndLoc) {
1789 return getSema().OpenMP().ActOnOpenMPPermutationClause(PermExprs, StartLoc,
1790 LParenLoc, EndLoc);
1791 }
1792
1793 /// Build a new OpenMP 'full' clause.
1795 SourceLocation EndLoc) {
1796 return getSema().OpenMP().ActOnOpenMPFullClause(StartLoc, EndLoc);
1797 }
1798
1799 /// Build a new OpenMP 'partial' clause.
1801 SourceLocation LParenLoc,
1802 SourceLocation EndLoc) {
1803 return getSema().OpenMP().ActOnOpenMPPartialClause(Factor, StartLoc,
1804 LParenLoc, EndLoc);
1805 }
1806
1807 OMPClause *
1809 SourceLocation LParenLoc, SourceLocation FirstLoc,
1810 SourceLocation CountLoc, SourceLocation EndLoc) {
1812 First, Count, StartLoc, LParenLoc, FirstLoc, CountLoc, EndLoc);
1813 }
1814
1815 /// Build a new OpenMP 'allocator' clause.
1816 ///
1817 /// By default, performs semantic analysis to build the new OpenMP clause.
1818 /// Subclasses may override this routine to provide different behavior.
1820 SourceLocation LParenLoc,
1821 SourceLocation EndLoc) {
1822 return getSema().OpenMP().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc,
1823 EndLoc);
1824 }
1825
1826 /// Build a new OpenMP 'collapse' clause.
1827 ///
1828 /// By default, performs semantic analysis to build the new OpenMP clause.
1829 /// Subclasses may override this routine to provide different behavior.
1831 SourceLocation LParenLoc,
1832 SourceLocation EndLoc) {
1833 return getSema().OpenMP().ActOnOpenMPCollapseClause(Num, StartLoc,
1834 LParenLoc, EndLoc);
1835 }
1836
1837 /// Build a new OpenMP 'default' clause.
1838 ///
1839 /// By default, performs semantic analysis to build the new OpenMP clause.
1840 /// Subclasses may override this routine to provide different behavior.
1843 SourceLocation VCLoc,
1844 SourceLocation StartLoc,
1845 SourceLocation LParenLoc,
1846 SourceLocation EndLoc) {
1848 Kind, KindKwLoc, VCKind, VCLoc, StartLoc, LParenLoc, EndLoc);
1849 }
1850
1851 /// Build a new OpenMP 'proc_bind' clause.
1852 ///
1853 /// By default, performs semantic analysis to build the new OpenMP clause.
1854 /// Subclasses may override this routine to provide different behavior.
1856 SourceLocation KindKwLoc,
1857 SourceLocation StartLoc,
1858 SourceLocation LParenLoc,
1859 SourceLocation EndLoc) {
1861 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1862 }
1864 SourceLocation StartLoc,
1865 SourceLocation LParenLoc,
1866 SourceLocation EndLoc) {
1868 ImpexTypeArg, StartLoc, LParenLoc, EndLoc);
1869 }
1870
1871 /// Build a new OpenMP 'schedule' clause.
1872 ///
1873 /// By default, performs semantic analysis to build the new OpenMP clause.
1874 /// Subclasses may override this routine to provide different behavior.
1877 OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1878 SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1879 SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1881 M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1882 CommaLoc, EndLoc);
1883 }
1884
1885 /// Build a new OpenMP 'ordered' clause.
1886 ///
1887 /// By default, performs semantic analysis to build the new OpenMP clause.
1888 /// Subclasses may override this routine to provide different behavior.
1890 SourceLocation EndLoc,
1891 SourceLocation LParenLoc, Expr *Num) {
1892 return getSema().OpenMP().ActOnOpenMPOrderedClause(StartLoc, EndLoc,
1893 LParenLoc, Num);
1894 }
1895
1896 /// Build a new OpenMP 'nowait' clause.
1897 ///
1898 /// By default, performs semantic analysis to build the new OpenMP clause.
1899 /// Subclasses may override this routine to provide different behavior.
1901 SourceLocation LParenLoc,
1902 SourceLocation EndLoc) {
1903 return getSema().OpenMP().ActOnOpenMPNowaitClause(StartLoc, EndLoc,
1904 LParenLoc, Condition);
1905 }
1906
1907 /// Build a new OpenMP 'private' clause.
1908 ///
1909 /// By default, performs semantic analysis to build the new OpenMP clause.
1910 /// Subclasses may override this routine to provide different behavior.
1912 SourceLocation StartLoc,
1913 SourceLocation LParenLoc,
1914 SourceLocation EndLoc) {
1915 return getSema().OpenMP().ActOnOpenMPPrivateClause(VarList, StartLoc,
1916 LParenLoc, EndLoc);
1917 }
1918
1919 /// Build a new OpenMP 'firstprivate' clause.
1920 ///
1921 /// By default, performs semantic analysis to build the new OpenMP clause.
1922 /// Subclasses may override this routine to provide different behavior.
1924 SourceLocation StartLoc,
1925 SourceLocation LParenLoc,
1926 SourceLocation EndLoc) {
1927 return getSema().OpenMP().ActOnOpenMPFirstprivateClause(VarList, StartLoc,
1928 LParenLoc, EndLoc);
1929 }
1930
1931 /// Build a new OpenMP 'lastprivate' clause.
1932 ///
1933 /// By default, performs semantic analysis to build the new OpenMP clause.
1934 /// Subclasses may override this routine to provide different behavior.
1937 SourceLocation LPKindLoc,
1938 SourceLocation ColonLoc,
1939 SourceLocation StartLoc,
1940 SourceLocation LParenLoc,
1941 SourceLocation EndLoc) {
1943 VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1944 }
1945
1946 /// Build a new OpenMP 'shared' clause.
1947 ///
1948 /// By default, performs semantic analysis to build the new OpenMP clause.
1949 /// Subclasses may override this routine to provide different behavior.
1951 SourceLocation StartLoc,
1952 SourceLocation LParenLoc,
1953 SourceLocation EndLoc) {
1954 return getSema().OpenMP().ActOnOpenMPSharedClause(VarList, StartLoc,
1955 LParenLoc, EndLoc);
1956 }
1957
1958 /// Build a new OpenMP 'reduction' clause.
1959 ///
1960 /// By default, performs semantic analysis to build the new statement.
1961 /// Subclasses may override this routine to provide different behavior.
1964 OpenMPOriginalSharingModifier OriginalSharingModifier,
1965 SourceLocation StartLoc, SourceLocation LParenLoc,
1966 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1967 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
1968 const DeclarationNameInfo &ReductionId,
1969 ArrayRef<Expr *> UnresolvedReductions) {
1971 VarList, {Modifier, OriginalSharingModifier}, StartLoc, LParenLoc,
1972 ModifierLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, ReductionId,
1973 UnresolvedReductions);
1974 }
1975
1976 /// Build a new OpenMP 'task_reduction' clause.
1977 ///
1978 /// By default, performs semantic analysis to build the new statement.
1979 /// Subclasses may override this routine to provide different behavior.
1981 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1982 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
1983 CXXScopeSpec &ReductionIdScopeSpec,
1984 const DeclarationNameInfo &ReductionId,
1985 ArrayRef<Expr *> UnresolvedReductions) {
1987 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1988 ReductionId, UnresolvedReductions);
1989 }
1990
1991 /// Build a new OpenMP 'in_reduction' clause.
1992 ///
1993 /// By default, performs semantic analysis to build the new statement.
1994 /// Subclasses may override this routine to provide different behavior.
1995 OMPClause *
1997 SourceLocation LParenLoc, SourceLocation ColonLoc,
1998 SourceLocation EndLoc,
1999 CXXScopeSpec &ReductionIdScopeSpec,
2000 const DeclarationNameInfo &ReductionId,
2001 ArrayRef<Expr *> UnresolvedReductions) {
2003 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
2004 ReductionId, UnresolvedReductions);
2005 }
2006
2007 /// Build a new OpenMP 'linear' clause.
2008 ///
2009 /// By default, performs semantic analysis to build the new OpenMP clause.
2010 /// Subclasses may override this routine to provide different behavior.
2012 ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc,
2013 SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier,
2014 SourceLocation ModifierLoc, SourceLocation ColonLoc,
2015 SourceLocation StepModifierLoc, SourceLocation EndLoc) {
2017 VarList, Step, StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc,
2018 StepModifierLoc, EndLoc);
2019 }
2020
2021 /// Build a new OpenMP 'aligned' clause.
2022 ///
2023 /// By default, performs semantic analysis to build the new OpenMP clause.
2024 /// Subclasses may override this routine to provide different behavior.
2026 SourceLocation StartLoc,
2027 SourceLocation LParenLoc,
2028 SourceLocation ColonLoc,
2029 SourceLocation EndLoc) {
2031 VarList, Alignment, StartLoc, LParenLoc, ColonLoc, EndLoc);
2032 }
2033
2034 /// Build a new OpenMP 'copyin' clause.
2035 ///
2036 /// By default, performs semantic analysis to build the new OpenMP clause.
2037 /// Subclasses may override this routine to provide different behavior.
2039 SourceLocation StartLoc,
2040 SourceLocation LParenLoc,
2041 SourceLocation EndLoc) {
2042 return getSema().OpenMP().ActOnOpenMPCopyinClause(VarList, StartLoc,
2043 LParenLoc, EndLoc);
2044 }
2045
2046 /// Build a new OpenMP 'copyprivate' clause.
2047 ///
2048 /// By default, performs semantic analysis to build the new OpenMP clause.
2049 /// Subclasses may override this routine to provide different behavior.
2051 SourceLocation StartLoc,
2052 SourceLocation LParenLoc,
2053 SourceLocation EndLoc) {
2054 return getSema().OpenMP().ActOnOpenMPCopyprivateClause(VarList, StartLoc,
2055 LParenLoc, EndLoc);
2056 }
2057
2058 /// Build a new OpenMP 'flush' pseudo clause.
2059 ///
2060 /// By default, performs semantic analysis to build the new OpenMP clause.
2061 /// Subclasses may override this routine to provide different behavior.
2063 SourceLocation StartLoc,
2064 SourceLocation LParenLoc,
2065 SourceLocation EndLoc) {
2066 return getSema().OpenMP().ActOnOpenMPFlushClause(VarList, StartLoc,
2067 LParenLoc, EndLoc);
2068 }
2069
2070 /// Build a new OpenMP 'depobj' pseudo clause.
2071 ///
2072 /// By default, performs semantic analysis to build the new OpenMP clause.
2073 /// Subclasses may override this routine to provide different behavior.
2075 SourceLocation LParenLoc,
2076 SourceLocation EndLoc) {
2077 return getSema().OpenMP().ActOnOpenMPDepobjClause(Depobj, StartLoc,
2078 LParenLoc, EndLoc);
2079 }
2080
2081 /// Build a new OpenMP 'depend' pseudo clause.
2082 ///
2083 /// By default, performs semantic analysis to build the new OpenMP clause.
2084 /// Subclasses may override this routine to provide different behavior.
2086 Expr *DepModifier, ArrayRef<Expr *> VarList,
2087 SourceLocation StartLoc,
2088 SourceLocation LParenLoc,
2089 SourceLocation EndLoc) {
2091 Data, DepModifier, VarList, StartLoc, LParenLoc, EndLoc);
2092 }
2093
2094 /// Build a new OpenMP 'device' clause.
2095 ///
2096 /// By default, performs semantic analysis to build the new statement.
2097 /// Subclasses may override this routine to provide different behavior.
2099 Expr *Device, SourceLocation StartLoc,
2100 SourceLocation LParenLoc,
2101 SourceLocation ModifierLoc,
2102 SourceLocation EndLoc) {
2104 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2105 }
2106
2107 /// Build a new OpenMP 'map' clause.
2108 ///
2109 /// By default, performs semantic analysis to build the new OpenMP clause.
2110 /// Subclasses may override this routine to provide different behavior.
2112 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
2113 ArrayRef<SourceLocation> MapTypeModifiersLoc,
2114 CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId,
2115 OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
2116 SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
2117 const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) {
2119 IteratorModifier, MapTypeModifiers, MapTypeModifiersLoc,
2120 MapperIdScopeSpec, MapperId, MapType, IsMapTypeImplicit, MapLoc,
2121 ColonLoc, VarList, Locs,
2122 /*NoDiagnose=*/false, UnresolvedMappers);
2123 }
2124
2125 /// Build a new OpenMP 'allocate' clause.
2126 ///
2127 /// By default, performs semantic analysis to build the new OpenMP clause.
2128 /// Subclasses may override this routine to provide different behavior.
2129 OMPClause *
2130 RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment,
2131 OpenMPAllocateClauseModifier FirstModifier,
2132 SourceLocation FirstModifierLoc,
2133 OpenMPAllocateClauseModifier SecondModifier,
2134 SourceLocation SecondModifierLoc,
2135 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2136 SourceLocation LParenLoc, SourceLocation ColonLoc,
2137 SourceLocation EndLoc) {
2139 Allocate, Alignment, FirstModifier, FirstModifierLoc, SecondModifier,
2140 SecondModifierLoc, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc);
2141 }
2142
2143 /// Build a new OpenMP 'num_teams' clause.
2144 ///
2145 /// By default, performs semantic analysis to build the new statement.
2146 /// Subclasses may override this routine to provide different behavior.
2148 SourceLocation StartLoc,
2149 SourceLocation LParenLoc,
2150 SourceLocation EndLoc) {
2151 return getSema().OpenMP().ActOnOpenMPNumTeamsClause(VarList, StartLoc,
2152 LParenLoc, EndLoc);
2153 }
2154
2155 /// Build a new OpenMP 'thread_limit' clause.
2156 ///
2157 /// By default, performs semantic analysis to build the new statement.
2158 /// Subclasses may override this routine to provide different behavior.
2160 SourceLocation StartLoc,
2161 SourceLocation LParenLoc,
2162 SourceLocation EndLoc) {
2163 return getSema().OpenMP().ActOnOpenMPThreadLimitClause(VarList, StartLoc,
2164 LParenLoc, EndLoc);
2165 }
2166
2167 /// Build a new OpenMP 'priority' clause.
2168 ///
2169 /// By default, performs semantic analysis to build the new statement.
2170 /// Subclasses may override this routine to provide different behavior.
2172 SourceLocation LParenLoc,
2173 SourceLocation EndLoc) {
2174 return getSema().OpenMP().ActOnOpenMPPriorityClause(Priority, StartLoc,
2175 LParenLoc, EndLoc);
2176 }
2177
2178 /// Build a new OpenMP 'grainsize' clause.
2179 ///
2180 /// By default, performs semantic analysis to build the new statement.
2181 /// Subclasses may override this routine to provide different behavior.
2183 Expr *Device, SourceLocation StartLoc,
2184 SourceLocation LParenLoc,
2185 SourceLocation ModifierLoc,
2186 SourceLocation EndLoc) {
2188 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2189 }
2190
2191 /// Build a new OpenMP 'num_tasks' clause.
2192 ///
2193 /// By default, performs semantic analysis to build the new statement.
2194 /// Subclasses may override this routine to provide different behavior.
2196 Expr *NumTasks, SourceLocation StartLoc,
2197 SourceLocation LParenLoc,
2198 SourceLocation ModifierLoc,
2199 SourceLocation EndLoc) {
2201 Modifier, NumTasks, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2202 }
2203
2204 /// Build a new OpenMP 'hint' clause.
2205 ///
2206 /// By default, performs semantic analysis to build the new statement.
2207 /// Subclasses may override this routine to provide different behavior.
2209 SourceLocation LParenLoc,
2210 SourceLocation EndLoc) {
2211 return getSema().OpenMP().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc,
2212 EndLoc);
2213 }
2214
2215 /// Build a new OpenMP 'detach' clause.
2216 ///
2217 /// By default, performs semantic analysis to build the new statement.
2218 /// Subclasses may override this routine to provide different behavior.
2220 SourceLocation LParenLoc,
2221 SourceLocation EndLoc) {
2222 return getSema().OpenMP().ActOnOpenMPDetachClause(Evt, StartLoc, LParenLoc,
2223 EndLoc);
2224 }
2225
2226 /// Build a new OpenMP 'dist_schedule' clause.
2227 ///
2228 /// By default, performs semantic analysis to build the new OpenMP clause.
2229 /// Subclasses may override this routine to provide different behavior.
2230 OMPClause *
2232 Expr *ChunkSize, SourceLocation StartLoc,
2233 SourceLocation LParenLoc, SourceLocation KindLoc,
2234 SourceLocation CommaLoc, SourceLocation EndLoc) {
2236 Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
2237 }
2238
2239 /// Build a new OpenMP 'to' clause.
2240 ///
2241 /// By default, performs semantic analysis to build the new statement.
2242 /// Subclasses may override this routine to provide different behavior.
2243 OMPClause *
2245 ArrayRef<SourceLocation> MotionModifiersLoc,
2246 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2247 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2248 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2249 ArrayRef<Expr *> UnresolvedMappers) {
2251 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2252 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2253 UnresolvedMappers);
2254 }
2255
2256 /// Build a new OpenMP 'from' clause.
2257 ///
2258 /// By default, performs semantic analysis to build the new statement.
2259 /// Subclasses may override this routine to provide different behavior.
2260 OMPClause *
2262 ArrayRef<SourceLocation> MotionModifiersLoc,
2263 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2264 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2265 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2266 ArrayRef<Expr *> UnresolvedMappers) {
2268 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2269 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2270 UnresolvedMappers);
2271 }
2272
2273 /// Build a new OpenMP 'use_device_ptr' clause.
2274 ///
2275 /// By default, performs semantic analysis to build the new OpenMP clause.
2276 /// Subclasses may override this routine to provide different behavior.
2278 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2279 OpenMPUseDevicePtrFallbackModifier FallbackModifier,
2280 SourceLocation FallbackModifierLoc) {
2282 VarList, Locs, FallbackModifier, FallbackModifierLoc);
2283 }
2284
2285 /// Build a new OpenMP 'use_device_addr' clause.
2286 ///
2287 /// By default, performs semantic analysis to build the new OpenMP clause.
2288 /// Subclasses may override this routine to provide different behavior.
2293
2294 /// Build a new OpenMP 'is_device_ptr' clause.
2295 ///
2296 /// By default, performs semantic analysis to build the new OpenMP clause.
2297 /// Subclasses may override this routine to provide different behavior.
2299 const OMPVarListLocTy &Locs) {
2300 return getSema().OpenMP().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
2301 }
2302
2303 /// Build a new OpenMP 'has_device_addr' clause.
2304 ///
2305 /// By default, performs semantic analysis to build the new OpenMP clause.
2306 /// Subclasses may override this routine to provide different behavior.
2311
2312 /// Build a new OpenMP 'defaultmap' clause.
2313 ///
2314 /// By default, performs semantic analysis to build the new OpenMP clause.
2315 /// Subclasses may override this routine to provide different behavior.
2318 SourceLocation StartLoc,
2319 SourceLocation LParenLoc,
2320 SourceLocation MLoc,
2321 SourceLocation KindLoc,
2322 SourceLocation EndLoc) {
2324 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2325 }
2326
2327 /// Build a new OpenMP 'nontemporal' clause.
2328 ///
2329 /// By default, performs semantic analysis to build the new OpenMP clause.
2330 /// Subclasses may override this routine to provide different behavior.
2332 SourceLocation StartLoc,
2333 SourceLocation LParenLoc,
2334 SourceLocation EndLoc) {
2335 return getSema().OpenMP().ActOnOpenMPNontemporalClause(VarList, StartLoc,
2336 LParenLoc, EndLoc);
2337 }
2338
2339 /// Build a new OpenMP 'inclusive' clause.
2340 ///
2341 /// By default, performs semantic analysis to build the new OpenMP clause.
2342 /// Subclasses may override this routine to provide different behavior.
2344 SourceLocation StartLoc,
2345 SourceLocation LParenLoc,
2346 SourceLocation EndLoc) {
2347 return getSema().OpenMP().ActOnOpenMPInclusiveClause(VarList, StartLoc,
2348 LParenLoc, EndLoc);
2349 }
2350
2351 /// Build a new OpenMP 'exclusive' 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().ActOnOpenMPExclusiveClause(VarList, StartLoc,
2360 LParenLoc, EndLoc);
2361 }
2362
2363 /// Build a new OpenMP 'uses_allocators' clause.
2364 ///
2365 /// By default, performs semantic analysis to build the new OpenMP clause.
2366 /// Subclasses may override this routine to provide different behavior.
2373
2374 /// Build a new OpenMP 'affinity' clause.
2375 ///
2376 /// By default, performs semantic analysis to build the new OpenMP clause.
2377 /// Subclasses may override this routine to provide different behavior.
2379 SourceLocation LParenLoc,
2380 SourceLocation ColonLoc,
2381 SourceLocation EndLoc, Expr *Modifier,
2382 ArrayRef<Expr *> Locators) {
2384 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2385 }
2386
2387 /// Build a new OpenMP 'order' clause.
2388 ///
2389 /// By default, performs semantic analysis to build the new OpenMP clause.
2390 /// Subclasses may override this routine to provide different behavior.
2392 OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc,
2393 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
2394 OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc) {
2396 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2397 }
2398
2399 /// Build a new OpenMP 'init' clause.
2400 ///
2401 /// By default, performs semantic analysis to build the new OpenMP clause.
2402 /// Subclasses may override this routine to provide different behavior.
2404 SourceLocation StartLoc,
2405 SourceLocation LParenLoc,
2406 SourceLocation VarLoc,
2407 SourceLocation EndLoc) {
2409 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2410 }
2411
2412 /// Build a new OpenMP 'use' clause.
2413 ///
2414 /// By default, performs semantic analysis to build the new OpenMP clause.
2415 /// Subclasses may override this routine to provide different behavior.
2417 SourceLocation LParenLoc,
2418 SourceLocation VarLoc, SourceLocation EndLoc) {
2419 return getSema().OpenMP().ActOnOpenMPUseClause(InteropVar, StartLoc,
2420 LParenLoc, VarLoc, EndLoc);
2421 }
2422
2423 /// Build a new OpenMP 'destroy' 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 LParenLoc,
2429 SourceLocation VarLoc,
2430 SourceLocation EndLoc) {
2432 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2433 }
2434
2435 /// Build a new OpenMP 'novariants' clause.
2436 ///
2437 /// By default, performs semantic analysis to build the new OpenMP clause.
2438 /// Subclasses may override this routine to provide different behavior.
2440 SourceLocation StartLoc,
2441 SourceLocation LParenLoc,
2442 SourceLocation EndLoc) {
2444 LParenLoc, EndLoc);
2445 }
2446
2447 /// Build a new OpenMP 'nocontext' 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 EndLoc) {
2455 LParenLoc, EndLoc);
2456 }
2457
2458 /// Build a new OpenMP 'filter' clause.
2459 ///
2460 /// By default, performs semantic analysis to build the new OpenMP clause.
2461 /// Subclasses may override this routine to provide different behavior.
2463 SourceLocation LParenLoc,
2464 SourceLocation EndLoc) {
2465 return getSema().OpenMP().ActOnOpenMPFilterClause(ThreadID, StartLoc,
2466 LParenLoc, EndLoc);
2467 }
2468
2469 /// Build a new OpenMP 'bind' clause.
2470 ///
2471 /// By default, performs semantic analysis to build the new OpenMP clause.
2472 /// Subclasses may override this routine to provide different behavior.
2474 SourceLocation KindLoc,
2475 SourceLocation StartLoc,
2476 SourceLocation LParenLoc,
2477 SourceLocation EndLoc) {
2478 return getSema().OpenMP().ActOnOpenMPBindClause(Kind, KindLoc, StartLoc,
2479 LParenLoc, EndLoc);
2480 }
2481
2482 /// Build a new OpenMP 'ompx_dyn_cgroup_mem' 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().ActOnOpenMPXDynCGroupMemClause(Size, StartLoc,
2490 LParenLoc, EndLoc);
2491 }
2492
2493 /// Build a new OpenMP 'dyn_groupprivate' clause.
2494 ///
2495 /// By default, performs semantic analysis to build the new OpenMP clause.
2496 /// Subclasses may override this routine to provide different behavior.
2500 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc,
2501 SourceLocation M2Loc, SourceLocation EndLoc) {
2503 M1, M2, Size, StartLoc, LParenLoc, M1Loc, M2Loc, EndLoc);
2504 }
2505
2506 /// Build a new OpenMP 'ompx_attribute' 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 StartLoc,
2512 SourceLocation LParenLoc,
2513 SourceLocation EndLoc) {
2514 return getSema().OpenMP().ActOnOpenMPXAttributeClause(Attrs, StartLoc,
2515 LParenLoc, EndLoc);
2516 }
2517
2518 /// Build a new OpenMP 'ompx_bare' clause.
2519 ///
2520 /// By default, performs semantic analysis to build the new OpenMP clause.
2521 /// Subclasses may override this routine to provide different behavior.
2523 SourceLocation EndLoc) {
2524 return getSema().OpenMP().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2525 }
2526
2527 /// Build a new OpenMP 'align' clause.
2528 ///
2529 /// By default, performs semantic analysis to build the new OpenMP clause.
2530 /// Subclasses may override this routine to provide different behavior.
2532 SourceLocation LParenLoc,
2533 SourceLocation EndLoc) {
2534 return getSema().OpenMP().ActOnOpenMPAlignClause(A, StartLoc, LParenLoc,
2535 EndLoc);
2536 }
2537
2538 /// Build a new OpenMP 'at' clause.
2539 ///
2540 /// By default, performs semantic analysis to build the new OpenMP clause.
2541 /// Subclasses may override this routine to provide different behavior.
2543 SourceLocation StartLoc,
2544 SourceLocation LParenLoc,
2545 SourceLocation EndLoc) {
2546 return getSema().OpenMP().ActOnOpenMPAtClause(Kind, KwLoc, StartLoc,
2547 LParenLoc, EndLoc);
2548 }
2549
2550 /// Build a new OpenMP 'severity' clause.
2551 ///
2552 /// By default, performs semantic analysis to build the new OpenMP clause.
2553 /// Subclasses may override this routine to provide different behavior.
2555 SourceLocation KwLoc,
2556 SourceLocation StartLoc,
2557 SourceLocation LParenLoc,
2558 SourceLocation EndLoc) {
2559 return getSema().OpenMP().ActOnOpenMPSeverityClause(Kind, KwLoc, StartLoc,
2560 LParenLoc, EndLoc);
2561 }
2562
2563 /// Build a new OpenMP 'message' clause.
2564 ///
2565 /// By default, performs semantic analysis to build the new OpenMP clause.
2566 /// Subclasses may override this routine to provide different behavior.
2568 SourceLocation LParenLoc,
2569 SourceLocation EndLoc) {
2570 return getSema().OpenMP().ActOnOpenMPMessageClause(MS, StartLoc, LParenLoc,
2571 EndLoc);
2572 }
2573
2574 /// Build a new OpenMP 'doacross' clause.
2575 ///
2576 /// By default, performs semantic analysis to build the new OpenMP clause.
2577 /// Subclasses may override this routine to provide different behavior.
2578 OMPClause *
2580 SourceLocation DepLoc, SourceLocation ColonLoc,
2581 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2582 SourceLocation LParenLoc, SourceLocation EndLoc) {
2584 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2585 }
2586
2587 /// Build a new OpenMP 'holds' clause.
2589 SourceLocation LParenLoc,
2590 SourceLocation EndLoc) {
2591 return getSema().OpenMP().ActOnOpenMPHoldsClause(A, StartLoc, LParenLoc,
2592 EndLoc);
2593 }
2594
2595 /// Rebuild the operand to an Objective-C \@synchronized statement.
2596 ///
2597 /// By default, performs semantic analysis to build the new statement.
2598 /// Subclasses may override this routine to provide different behavior.
2603
2604 /// Build a new Objective-C \@synchronized statement.
2605 ///
2606 /// By default, performs semantic analysis to build the new statement.
2607 /// Subclasses may override this routine to provide different behavior.
2612
2613 /// Build a new Objective-C \@autoreleasepool statement.
2614 ///
2615 /// By default, performs semantic analysis to build the new statement.
2616 /// Subclasses may override this routine to provide different behavior.
2621
2622 /// Build a new Objective-C fast enumeration statement.
2623 ///
2624 /// By default, performs semantic analysis to build the new statement.
2625 /// Subclasses may override this routine to provide different behavior.
2627 Stmt *Element,
2628 Expr *Collection,
2629 SourceLocation RParenLoc,
2630 Stmt *Body) {
2632 ForLoc, Element, Collection, RParenLoc);
2633 if (ForEachStmt.isInvalid())
2634 return StmtError();
2635
2636 return getSema().ObjC().FinishObjCForCollectionStmt(ForEachStmt.get(),
2637 Body);
2638 }
2639
2640 /// Build a new C++ exception declaration.
2641 ///
2642 /// By default, performs semantic analysis to build the new decaration.
2643 /// Subclasses may override this routine to provide different behavior.
2646 SourceLocation StartLoc,
2647 SourceLocation IdLoc,
2648 IdentifierInfo *Id) {
2650 StartLoc, IdLoc, Id);
2651 if (Var)
2652 getSema().CurContext->addDecl(Var);
2653 return Var;
2654 }
2655
2656 /// Build a new C++ catch statement.
2657 ///
2658 /// By default, performs semantic analysis to build the new statement.
2659 /// Subclasses may override this routine to provide different behavior.
2661 VarDecl *ExceptionDecl,
2662 Stmt *Handler) {
2663 return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2664 Handler));
2665 }
2666
2667 /// Build a new C++ try statement.
2668 ///
2669 /// By default, performs semantic analysis to build the new statement.
2670 /// Subclasses may override this routine to provide different behavior.
2672 ArrayRef<Stmt *> Handlers) {
2673 return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2674 }
2675
2676 /// Build a new C++0x range-based for statement.
2677 ///
2678 /// By default, performs semantic analysis to build the new statement.
2679 /// Subclasses may override this routine to provide different behavior.
2681 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init,
2682 SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond,
2683 Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc,
2684 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
2685 // If we've just learned that the range is actually an Objective-C
2686 // collection, treat this as an Objective-C fast enumeration loop.
2687 if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2688 if (RangeStmt->isSingleDecl()) {
2689 if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2690 if (RangeVar->isInvalidDecl())
2691 return StmtError();
2692
2693 Expr *RangeExpr = RangeVar->getInit();
2694 if (!RangeExpr->isTypeDependent() &&
2695 RangeExpr->getType()->isObjCObjectPointerType()) {
2696 // FIXME: Support init-statements in Objective-C++20 ranged for
2697 // statement.
2698 if (Init) {
2699 return SemaRef.Diag(Init->getBeginLoc(),
2700 diag::err_objc_for_range_init_stmt)
2701 << Init->getSourceRange();
2702 }
2704 ForLoc, LoopVar, RangeExpr, RParenLoc);
2705 }
2706 }
2707 }
2708 }
2709
2711 ForLoc, CoawaitLoc, Init, ColonLoc, Range, Begin, End, Cond, Inc,
2712 LoopVar, RParenLoc, Sema::BFRK_Rebuild, LifetimeExtendTemps);
2713 }
2714
2715 /// Build a new C++0x range-based for statement.
2716 ///
2717 /// By default, performs semantic analysis to build the new statement.
2718 /// Subclasses may override this routine to provide different behavior.
2720 bool IsIfExists,
2721 NestedNameSpecifierLoc QualifierLoc,
2722 DeclarationNameInfo NameInfo,
2723 Stmt *Nested) {
2724 return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2725 QualifierLoc, NameInfo, Nested);
2726 }
2727
2728 /// Attach body to a C++0x range-based for statement.
2729 ///
2730 /// By default, performs semantic analysis to finish the new statement.
2731 /// Subclasses may override this routine to provide different behavior.
2733 return getSema().FinishCXXForRangeStmt(ForRange, Body);
2734 }
2735
2737 Stmt *TryBlock, Stmt *Handler) {
2738 return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2739 }
2740
2742 Stmt *Block) {
2743 return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2744 }
2745
2747 return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2748 }
2749
2751 SourceLocation LParen,
2752 SourceLocation RParen,
2753 TypeSourceInfo *TSI) {
2754 return getSema().SYCL().BuildUniqueStableNameExpr(OpLoc, LParen, RParen,
2755 TSI);
2756 }
2757
2758 /// Build a new predefined expression.
2759 ///
2760 /// By default, performs semantic analysis to build the new expression.
2761 /// Subclasses may override this routine to provide different behavior.
2765
2766 /// Build a new expression that references a declaration.
2767 ///
2768 /// By default, performs semantic analysis to build the new expression.
2769 /// Subclasses may override this routine to provide different behavior.
2771 LookupResult &R,
2772 bool RequiresADL) {
2773 return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2774 }
2775
2776
2777 /// Build a new expression that references a declaration.
2778 ///
2779 /// By default, performs semantic analysis to build the new expression.
2780 /// Subclasses may override this routine to provide different behavior.
2782 ValueDecl *VD,
2783 const DeclarationNameInfo &NameInfo,
2785 TemplateArgumentListInfo *TemplateArgs) {
2786 CXXScopeSpec SS;
2787 SS.Adopt(QualifierLoc);
2788 return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2789 TemplateArgs);
2790 }
2791
2792 /// Build a new expression in parentheses.
2793 ///
2794 /// By default, performs semantic analysis to build the new expression.
2795 /// Subclasses may override this routine to provide different behavior.
2797 SourceLocation RParen) {
2798 return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2799 }
2800
2801 /// Build a new pseudo-destructor expression.
2802 ///
2803 /// By default, performs semantic analysis to build the new expression.
2804 /// Subclasses may override this routine to provide different behavior.
2806 SourceLocation OperatorLoc,
2807 bool isArrow,
2808 CXXScopeSpec &SS,
2809 TypeSourceInfo *ScopeType,
2810 SourceLocation CCLoc,
2811 SourceLocation TildeLoc,
2812 PseudoDestructorTypeStorage Destroyed);
2813
2814 /// Build a new unary operator expression.
2815 ///
2816 /// By default, performs semantic analysis to build the new expression.
2817 /// Subclasses may override this routine to provide different behavior.
2820 Expr *SubExpr) {
2821 return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2822 }
2823
2824 /// Build a new builtin offsetof expression.
2825 ///
2826 /// By default, performs semantic analysis to build the new expression.
2827 /// Subclasses may override this routine to provide different behavior.
2831 SourceLocation RParenLoc) {
2832 return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2833 RParenLoc);
2834 }
2835
2836 /// Build a new sizeof, alignof or vec_step expression with a
2837 /// type argument.
2838 ///
2839 /// By default, performs semantic analysis to build the new expression.
2840 /// Subclasses may override this routine to provide different behavior.
2842 SourceLocation OpLoc,
2843 UnaryExprOrTypeTrait ExprKind,
2844 SourceRange R) {
2845 return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2846 }
2847
2848 /// Build a new sizeof, alignof or vec step expression with an
2849 /// expression argument.
2850 ///
2851 /// By default, performs semantic analysis to build the new expression.
2852 /// Subclasses may override this routine to provide different behavior.
2854 UnaryExprOrTypeTrait ExprKind,
2855 SourceRange R) {
2857 = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2858 if (Result.isInvalid())
2859 return ExprError();
2860
2861 return Result;
2862 }
2863
2864 /// Build a new array subscript expression.
2865 ///
2866 /// By default, performs semantic analysis to build the new expression.
2867 /// Subclasses may override this routine to provide different behavior.
2869 SourceLocation LBracketLoc,
2870 Expr *RHS,
2871 SourceLocation RBracketLoc) {
2872 return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2873 LBracketLoc, RHS,
2874 RBracketLoc);
2875 }
2876
2877 /// Build a new matrix single subscript expression.
2878 ///
2879 /// By default, performs semantic analysis to build the new expression.
2880 /// Subclasses may override this routine to provide different behavior.
2882 SourceLocation RBracketLoc) {
2884 RBracketLoc);
2885 }
2886
2887 /// Build a new matrix subscript expression.
2888 ///
2889 /// By default, performs semantic analysis to build the new expression.
2890 /// Subclasses may override this routine to provide different behavior.
2892 Expr *ColumnIdx,
2893 SourceLocation RBracketLoc) {
2894 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2895 RBracketLoc);
2896 }
2897
2898 /// Build a new array section expression.
2899 ///
2900 /// By default, performs semantic analysis to build the new expression.
2901 /// Subclasses may override this routine to provide different behavior.
2903 SourceLocation LBracketLoc,
2904 Expr *LowerBound,
2905 SourceLocation ColonLocFirst,
2906 SourceLocation ColonLocSecond,
2907 Expr *Length, Expr *Stride,
2908 SourceLocation RBracketLoc) {
2909 if (IsOMPArraySection)
2911 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2912 Stride, RBracketLoc);
2913
2914 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2915 "Stride/second colon not allowed for OpenACC");
2916
2918 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2919 }
2920
2921 /// Build a new array shaping expression.
2922 ///
2923 /// By default, performs semantic analysis to build the new expression.
2924 /// Subclasses may override this routine to provide different behavior.
2926 SourceLocation RParenLoc,
2927 ArrayRef<Expr *> Dims,
2928 ArrayRef<SourceRange> BracketsRanges) {
2930 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2931 }
2932
2933 /// Build a new iterator expression.
2934 ///
2935 /// By default, performs semantic analysis to build the new expression.
2936 /// Subclasses may override this routine to provide different behavior.
2939 SourceLocation RLoc,
2942 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2943 }
2944
2945 /// Build a new call expression.
2946 ///
2947 /// By default, performs semantic analysis to build the new expression.
2948 /// Subclasses may override this routine to provide different behavior.
2950 MultiExprArg Args,
2951 SourceLocation RParenLoc,
2952 Expr *ExecConfig = nullptr) {
2953 return getSema().ActOnCallExpr(
2954 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2955 }
2956
2958 MultiExprArg Args,
2959 SourceLocation RParenLoc) {
2961 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2962 }
2963
2964 /// Build a new member access expression.
2965 ///
2966 /// By default, performs semantic analysis to build the new expression.
2967 /// Subclasses may override this routine to provide different behavior.
2969 bool isArrow,
2970 NestedNameSpecifierLoc QualifierLoc,
2971 SourceLocation TemplateKWLoc,
2972 const DeclarationNameInfo &MemberNameInfo,
2974 NamedDecl *FoundDecl,
2975 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2976 NamedDecl *FirstQualifierInScope) {
2978 isArrow);
2979 if (!Member->getDeclName()) {
2980 // We have a reference to an unnamed field. This is always the
2981 // base of an anonymous struct/union member access, i.e. the
2982 // field is always of record type.
2983 assert(Member->getType()->isRecordType() &&
2984 "unnamed member not of record type?");
2985
2986 BaseResult =
2988 QualifierLoc.getNestedNameSpecifier(),
2989 FoundDecl, Member);
2990 if (BaseResult.isInvalid())
2991 return ExprError();
2992 Base = BaseResult.get();
2993
2994 // `TranformMaterializeTemporaryExpr()` removes materialized temporaries
2995 // from the AST, so we need to re-insert them if needed (since
2996 // `BuildFieldRefereneExpr()` doesn't do this).
2997 if (!isArrow && Base->isPRValue()) {
2999 if (BaseResult.isInvalid())
3000 return ExprError();
3001 Base = BaseResult.get();
3002 }
3003
3004 CXXScopeSpec EmptySS;
3006 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
3007 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
3008 MemberNameInfo);
3009 }
3010
3011 CXXScopeSpec SS;
3012 SS.Adopt(QualifierLoc);
3013
3014 Base = BaseResult.get();
3015 if (Base->containsErrors())
3016 return ExprError();
3017
3018 QualType BaseType = Base->getType();
3019
3020 if (isArrow && !BaseType->isPointerType())
3021 return ExprError();
3022
3023 // FIXME: this involves duplicating earlier analysis in a lot of
3024 // cases; we should avoid this when possible.
3025 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
3026 R.addDecl(FoundDecl);
3027 R.resolveKind();
3028
3029 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
3031 if (auto *ThisClass = cast<CXXThisExpr>(Base)
3032 ->getType()
3033 ->getPointeeType()
3034 ->getAsCXXRecordDecl()) {
3035 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
3036 // In unevaluated contexts, an expression supposed to be a member access
3037 // might reference a member in an unrelated class.
3038 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
3039 return getSema().BuildDeclRefExpr(Member, Member->getType(),
3040 VK_LValue, Member->getLocation());
3041 }
3042 }
3043
3044 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
3045 SS, TemplateKWLoc,
3046 FirstQualifierInScope,
3047 R, ExplicitTemplateArgs,
3048 /*S*/nullptr);
3049 }
3050
3051 /// Build a new binary operator expression.
3052 ///
3053 /// By default, performs semantic analysis to build the new expression.
3054 /// Subclasses may override this routine to provide different behavior.
3056 Expr *LHS, Expr *RHS,
3057 bool ForFoldExpression = false) {
3058 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS,
3059 ForFoldExpression);
3060 }
3061
3062 /// Build a new rewritten operator expression.
3063 ///
3064 /// By default, performs semantic analysis to build the new expression.
3065 /// Subclasses may override this routine to provide different behavior.
3067 SourceLocation OpLoc, BinaryOperatorKind Opcode,
3068 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
3069 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
3070 RHS, /*RequiresADL*/false);
3071 }
3072
3073 /// Build a new conditional 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 SourceLocation QuestionLoc,
3079 Expr *LHS,
3080 SourceLocation ColonLoc,
3081 Expr *RHS) {
3082 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
3083 LHS, RHS);
3084 }
3085
3086 /// Build a new C-style cast expression.
3087 ///
3088 /// By default, performs semantic analysis to build the new expression.
3089 /// Subclasses may override this routine to provide different behavior.
3091 TypeSourceInfo *TInfo,
3092 SourceLocation RParenLoc,
3093 Expr *SubExpr) {
3094 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
3095 SubExpr);
3096 }
3097
3098 /// Build a new compound literal expression.
3099 ///
3100 /// By default, performs semantic analysis to build the new expression.
3101 /// Subclasses may override this routine to provide different behavior.
3103 TypeSourceInfo *TInfo,
3104 SourceLocation RParenLoc,
3105 Expr *Init) {
3106 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
3107 Init);
3108 }
3109
3110 /// Build a new extended vector or matrix element access expression.
3111 ///
3112 /// By default, performs semantic analysis to build the new expression.
3113 /// Subclasses may override this routine to provide different behavior.
3115 SourceLocation OpLoc,
3116 bool IsArrow,
3117 SourceLocation AccessorLoc,
3118 IdentifierInfo &Accessor) {
3119
3120 CXXScopeSpec SS;
3121 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3123 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3124 /*FirstQualifierInScope*/ nullptr, NameInfo,
3125 /* TemplateArgs */ nullptr,
3126 /*S*/ nullptr);
3127 }
3128
3129 /// Build a new initializer list expression.
3130 ///
3131 /// By default, performs semantic analysis to build the new expression.
3132 /// Subclasses may override this routine to provide different behavior.
3134 SourceLocation RBraceLoc, bool IsExplicit) {
3135 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc, IsExplicit);
3136 }
3137
3138 /// Build a new designated initializer expression.
3139 ///
3140 /// By default, performs semantic analysis to build the new expression.
3141 /// Subclasses may override this routine to provide different behavior.
3143 MultiExprArg ArrayExprs,
3144 SourceLocation EqualOrColonLoc,
3145 bool GNUSyntax,
3146 Expr *Init) {
3148 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3149 Init);
3150 if (Result.isInvalid())
3151 return ExprError();
3152
3153 return Result;
3154 }
3155
3156 /// Build a new value-initialized expression.
3157 ///
3158 /// By default, builds the implicit value initialization without performing
3159 /// any semantic analysis. Subclasses may override this routine to provide
3160 /// different behavior.
3164
3165 /// Build a new \c va_arg expression.
3166 ///
3167 /// By default, performs semantic analysis to build the new expression.
3168 /// Subclasses may override this routine to provide different behavior.
3170 Expr *SubExpr, TypeSourceInfo *TInfo,
3171 SourceLocation RParenLoc) {
3172 return getSema().BuildVAArgExpr(BuiltinLoc,
3173 SubExpr, TInfo,
3174 RParenLoc);
3175 }
3176
3177 /// Build a new expression list in parentheses.
3178 ///
3179 /// By default, performs semantic analysis to build the new expression.
3180 /// Subclasses may override this routine to provide different behavior.
3182 MultiExprArg SubExprs,
3183 SourceLocation RParenLoc) {
3184 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3185 }
3186
3188 unsigned NumUserSpecifiedExprs,
3189 SourceLocation InitLoc,
3190 SourceLocation LParenLoc,
3191 SourceLocation RParenLoc) {
3192 return getSema().ActOnCXXParenListInitExpr(Args, T, NumUserSpecifiedExprs,
3193 InitLoc, LParenLoc, RParenLoc);
3194 }
3195
3196 /// Build a new address-of-label expression.
3197 ///
3198 /// By default, performs semantic analysis, using the name of the label
3199 /// rather than attempting to map the label statement itself.
3200 /// Subclasses may override this routine to provide different behavior.
3202 SourceLocation LabelLoc, LabelDecl *Label) {
3203 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3204 }
3205
3206 /// Build a new GNU statement expression.
3207 ///
3208 /// By default, performs semantic analysis to build the new expression.
3209 /// Subclasses may override this routine to provide different behavior.
3211 SourceLocation RParenLoc, unsigned TemplateDepth) {
3212 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3213 TemplateDepth);
3214 }
3215
3216 /// Build a new __builtin_choose_expr expression.
3217 ///
3218 /// By default, performs semantic analysis to build the new expression.
3219 /// Subclasses may override this routine to provide different behavior.
3221 Expr *Cond, Expr *LHS, Expr *RHS,
3222 SourceLocation RParenLoc) {
3223 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3224 Cond, LHS, RHS,
3225 RParenLoc);
3226 }
3227
3228 /// Build a new generic selection expression with an expression predicate.
3229 ///
3230 /// By default, performs semantic analysis to build the new expression.
3231 /// Subclasses may override this routine to provide different behavior.
3233 SourceLocation DefaultLoc,
3234 SourceLocation RParenLoc,
3235 Expr *ControllingExpr,
3237 ArrayRef<Expr *> Exprs) {
3238 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3239 /*PredicateIsExpr=*/true,
3240 ControllingExpr, Types, Exprs);
3241 }
3242
3243 /// Build a new generic selection expression with a type predicate.
3244 ///
3245 /// By default, performs semantic analysis to build the new expression.
3246 /// Subclasses may override this routine to provide different behavior.
3248 SourceLocation DefaultLoc,
3249 SourceLocation RParenLoc,
3250 TypeSourceInfo *ControllingType,
3252 ArrayRef<Expr *> Exprs) {
3253 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3254 /*PredicateIsExpr=*/false,
3255 ControllingType, Types, Exprs);
3256 }
3257
3258 /// Build a new overloaded operator call expression.
3259 ///
3260 /// By default, performs semantic analysis to build the new expression.
3261 /// The semantic analysis provides the behavior of template instantiation,
3262 /// copying with transformations that turn what looks like an overloaded
3263 /// operator call into a use of a builtin operator, performing
3264 /// argument-dependent lookup, etc. Subclasses may override this routine to
3265 /// provide different behavior.
3267 SourceLocation OpLoc,
3268 SourceLocation CalleeLoc,
3269 bool RequiresADL,
3270 const UnresolvedSetImpl &Functions,
3271 Expr *First, Expr *Second);
3272
3273 /// Build a new C++ "named" cast expression, such as static_cast or
3274 /// reinterpret_cast.
3275 ///
3276 /// By default, this routine dispatches to one of the more-specific routines
3277 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3278 /// Subclasses may override this routine to provide different behavior.
3281 SourceLocation LAngleLoc,
3282 TypeSourceInfo *TInfo,
3283 SourceLocation RAngleLoc,
3284 SourceLocation LParenLoc,
3285 Expr *SubExpr,
3286 SourceLocation RParenLoc) {
3287 switch (Class) {
3288 case Stmt::CXXStaticCastExprClass:
3289 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3290 RAngleLoc, LParenLoc,
3291 SubExpr, RParenLoc);
3292
3293 case Stmt::CXXDynamicCastExprClass:
3294 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3295 RAngleLoc, LParenLoc,
3296 SubExpr, RParenLoc);
3297
3298 case Stmt::CXXReinterpretCastExprClass:
3299 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3300 RAngleLoc, LParenLoc,
3301 SubExpr,
3302 RParenLoc);
3303
3304 case Stmt::CXXConstCastExprClass:
3305 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3306 RAngleLoc, LParenLoc,
3307 SubExpr, RParenLoc);
3308
3309 case Stmt::CXXAddrspaceCastExprClass:
3310 return getDerived().RebuildCXXAddrspaceCastExpr(
3311 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3312
3313 default:
3314 llvm_unreachable("Invalid C++ named cast");
3315 }
3316 }
3317
3318 /// Build a new C++ static_cast expression.
3319 ///
3320 /// By default, performs semantic analysis to build the new expression.
3321 /// Subclasses may override this routine to provide different behavior.
3323 SourceLocation LAngleLoc,
3324 TypeSourceInfo *TInfo,
3325 SourceLocation RAngleLoc,
3326 SourceLocation LParenLoc,
3327 Expr *SubExpr,
3328 SourceLocation RParenLoc) {
3329 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3330 TInfo, SubExpr,
3331 SourceRange(LAngleLoc, RAngleLoc),
3332 SourceRange(LParenLoc, RParenLoc));
3333 }
3334
3335 /// Build a new C++ dynamic_cast expression.
3336 ///
3337 /// By default, performs semantic analysis to build the new expression.
3338 /// Subclasses may override this routine to provide different behavior.
3340 SourceLocation LAngleLoc,
3341 TypeSourceInfo *TInfo,
3342 SourceLocation RAngleLoc,
3343 SourceLocation LParenLoc,
3344 Expr *SubExpr,
3345 SourceLocation RParenLoc) {
3346 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3347 TInfo, SubExpr,
3348 SourceRange(LAngleLoc, RAngleLoc),
3349 SourceRange(LParenLoc, RParenLoc));
3350 }
3351
3352 /// Build a new C++ reinterpret_cast expression.
3353 ///
3354 /// By default, performs semantic analysis to build the new expression.
3355 /// Subclasses may override this routine to provide different behavior.
3357 SourceLocation LAngleLoc,
3358 TypeSourceInfo *TInfo,
3359 SourceLocation RAngleLoc,
3360 SourceLocation LParenLoc,
3361 Expr *SubExpr,
3362 SourceLocation RParenLoc) {
3363 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3364 TInfo, SubExpr,
3365 SourceRange(LAngleLoc, RAngleLoc),
3366 SourceRange(LParenLoc, RParenLoc));
3367 }
3368
3369 /// Build a new C++ const_cast expression.
3370 ///
3371 /// By default, performs semantic analysis to build the new expression.
3372 /// Subclasses may override this routine to provide different behavior.
3374 SourceLocation LAngleLoc,
3375 TypeSourceInfo *TInfo,
3376 SourceLocation RAngleLoc,
3377 SourceLocation LParenLoc,
3378 Expr *SubExpr,
3379 SourceLocation RParenLoc) {
3380 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3381 TInfo, SubExpr,
3382 SourceRange(LAngleLoc, RAngleLoc),
3383 SourceRange(LParenLoc, RParenLoc));
3384 }
3385
3388 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3389 SourceLocation LParenLoc, Expr *SubExpr,
3390 SourceLocation RParenLoc) {
3391 return getSema().BuildCXXNamedCast(
3392 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3393 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3394 }
3395
3396 /// Build a new C++ functional-style cast expression.
3397 ///
3398 /// By default, performs semantic analysis to build the new expression.
3399 /// Subclasses may override this routine to provide different behavior.
3401 SourceLocation LParenLoc,
3402 Expr *Sub,
3403 SourceLocation RParenLoc,
3404 bool ListInitialization) {
3405 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3406 // CXXParenListInitExpr. Pass its expanded arguments so that the
3407 // CXXParenListInitExpr can be rebuilt.
3408 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3410 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3411 RParenLoc, ListInitialization);
3412
3413 if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub))
3415 TInfo, LParenLoc, PLE->getInitExprs(), RParenLoc, ListInitialization);
3416
3417 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3418 MultiExprArg(&Sub, 1), RParenLoc,
3419 ListInitialization);
3420 }
3421
3422 /// Build a new C++ __builtin_bit_cast expression.
3423 ///
3424 /// By default, performs semantic analysis to build the new expression.
3425 /// Subclasses may override this routine to provide different behavior.
3427 TypeSourceInfo *TSI, Expr *Sub,
3428 SourceLocation RParenLoc) {
3429 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3430 }
3431
3432 /// Build a new C++ typeid(type) expression.
3433 ///
3434 /// By default, performs semantic analysis to build the new expression.
3435 /// Subclasses may override this routine to provide different behavior.
3437 SourceLocation TypeidLoc,
3438 TypeSourceInfo *Operand,
3439 SourceLocation RParenLoc) {
3440 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3441 RParenLoc);
3442 }
3443
3444
3445 /// Build a new C++ typeid(expr) expression.
3446 ///
3447 /// By default, performs semantic analysis to build the new expression.
3448 /// Subclasses may override this routine to provide different behavior.
3450 SourceLocation TypeidLoc,
3451 Expr *Operand,
3452 SourceLocation RParenLoc) {
3453 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3454 RParenLoc);
3455 }
3456
3457 /// Build a new C++ __uuidof(type) expression.
3458 ///
3459 /// By default, performs semantic analysis to build the new expression.
3460 /// Subclasses may override this routine to provide different behavior.
3462 TypeSourceInfo *Operand,
3463 SourceLocation RParenLoc) {
3464 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3465 }
3466
3467 /// Build a new C++ __uuidof(expr) expression.
3468 ///
3469 /// By default, performs semantic analysis to build the new expression.
3470 /// Subclasses may override this routine to provide different behavior.
3472 Expr *Operand, SourceLocation RParenLoc) {
3473 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3474 }
3475
3476 /// Build a new C++ "this" expression.
3477 ///
3478 /// By default, performs semantic analysis to build a new "this" expression.
3479 /// Subclasses may override this routine to provide different behavior.
3481 QualType ThisType,
3482 bool isImplicit) {
3483 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3484 return ExprError();
3485 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3486 }
3487
3488 /// Build a new C++ throw expression.
3489 ///
3490 /// By default, performs semantic analysis to build the new expression.
3491 /// Subclasses may override this routine to provide different behavior.
3493 bool IsThrownVariableInScope) {
3494 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3495 }
3496
3497 /// Build a new C++ default-argument expression.
3498 ///
3499 /// By default, builds a new default-argument expression, which does not
3500 /// require any semantic analysis. Subclasses may override this routine to
3501 /// provide different behavior.
3503 Expr *RewrittenExpr) {
3504 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3505 RewrittenExpr, getSema().CurContext);
3506 }
3507
3508 /// Build a new C++11 default-initialization expression.
3509 ///
3510 /// By default, builds a new default field initialization expression, which
3511 /// does not require any semantic analysis. Subclasses may override this
3512 /// routine to provide different behavior.
3517
3518 /// Build a new C++ zero-initialization expression.
3519 ///
3520 /// By default, performs semantic analysis to build the new expression.
3521 /// Subclasses may override this routine to provide different behavior.
3523 SourceLocation LParenLoc,
3524 SourceLocation RParenLoc) {
3525 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3526 /*ListInitialization=*/false);
3527 }
3528
3529 /// Build a new C++ "new" expression.
3530 ///
3531 /// By default, performs semantic analysis to build the new expression.
3532 /// Subclasses may override this routine to provide different behavior.
3534 SourceLocation PlacementLParen,
3535 MultiExprArg PlacementArgs,
3536 SourceLocation PlacementRParen,
3537 SourceRange TypeIdParens, QualType AllocatedType,
3538 TypeSourceInfo *AllocatedTypeInfo,
3539 std::optional<Expr *> ArraySize,
3540 SourceRange DirectInitRange, Expr *Initializer) {
3541 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3542 PlacementLParen,
3543 PlacementArgs,
3544 PlacementRParen,
3545 TypeIdParens,
3546 AllocatedType,
3547 AllocatedTypeInfo,
3548 ArraySize,
3549 DirectInitRange,
3550 Initializer);
3551 }
3552
3553 /// Build a new C++ "delete" expression.
3554 ///
3555 /// By default, performs semantic analysis to build the new expression.
3556 /// Subclasses may override this routine to provide different behavior.
3558 bool IsGlobalDelete,
3559 bool IsArrayForm,
3560 Expr *Operand) {
3561 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3562 Operand);
3563 }
3564
3565 /// Build a new type trait expression.
3566 ///
3567 /// By default, performs semantic analysis to build the new expression.
3568 /// Subclasses may override this routine to provide different behavior.
3570 SourceLocation StartLoc,
3572 SourceLocation RParenLoc) {
3573 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3574 }
3575
3576 /// Build a new array type trait expression.
3577 ///
3578 /// By default, performs semantic analysis to build the new expression.
3579 /// Subclasses may override this routine to provide different behavior.
3581 SourceLocation StartLoc,
3582 TypeSourceInfo *TSInfo,
3583 Expr *DimExpr,
3584 SourceLocation RParenLoc) {
3585 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3586 }
3587
3588 /// Build a new expression 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,
3594 Expr *Queried,
3595 SourceLocation RParenLoc) {
3596 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3597 }
3598
3599 /// Build a new (previously unresolved) declaration reference
3600 /// expression.
3601 ///
3602 /// By default, performs semantic analysis to build the new expression.
3603 /// Subclasses may override this routine to provide different behavior.
3605 NestedNameSpecifierLoc QualifierLoc,
3606 SourceLocation TemplateKWLoc,
3607 const DeclarationNameInfo &NameInfo,
3608 const TemplateArgumentListInfo *TemplateArgs,
3609 bool IsAddressOfOperand,
3610 TypeSourceInfo **RecoveryTSI) {
3611 CXXScopeSpec SS;
3612 SS.Adopt(QualifierLoc);
3613
3614 if (TemplateArgs || TemplateKWLoc.isValid())
3616 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3617
3619 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3620 }
3621
3622 /// Build a new template-id expression.
3623 ///
3624 /// By default, performs semantic analysis to build the new expression.
3625 /// Subclasses may override this routine to provide different behavior.
3627 SourceLocation TemplateKWLoc,
3628 LookupResult &R,
3629 bool RequiresADL,
3630 const TemplateArgumentListInfo *TemplateArgs) {
3631 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3632 TemplateArgs);
3633 }
3634
3635 /// Build a new object-construction expression.
3636 ///
3637 /// By default, performs semantic analysis to build the new expression.
3638 /// Subclasses may override this routine to provide different behavior.
3641 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3642 bool ListInitialization, bool StdInitListInitialization,
3643 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3644 SourceRange ParenRange) {
3645 // Reconstruct the constructor we originally found, which might be
3646 // different if this is a call to an inherited constructor.
3647 CXXConstructorDecl *FoundCtor = Constructor;
3648 if (Constructor->isInheritingConstructor())
3649 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3650
3651 SmallVector<Expr *, 8> ConvertedArgs;
3652 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3653 ConvertedArgs))
3654 return ExprError();
3655
3656 return getSema().BuildCXXConstructExpr(Loc, T, Constructor,
3657 IsElidable,
3658 ConvertedArgs,
3659 HadMultipleCandidates,
3660 ListInitialization,
3661 StdInitListInitialization,
3662 RequiresZeroInit, ConstructKind,
3663 ParenRange);
3664 }
3665
3666 /// Build a new implicit construction via inherited constructor
3667 /// expression.
3670 bool ConstructsVBase,
3671 bool InheritedFromVBase) {
3673 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3674 }
3675
3676 /// Build a new object-construction expression.
3677 ///
3678 /// By default, performs semantic analysis to build the new expression.
3679 /// Subclasses may override this routine to provide different behavior.
3681 SourceLocation LParenOrBraceLoc,
3682 MultiExprArg Args,
3683 SourceLocation RParenOrBraceLoc,
3684 bool ListInitialization) {
3686 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3687 }
3688
3689 /// Build a new object-construction expression.
3690 ///
3691 /// By default, performs semantic analysis to build the new expression.
3692 /// Subclasses may override this routine to provide different behavior.
3694 SourceLocation LParenLoc,
3695 MultiExprArg Args,
3696 SourceLocation RParenLoc,
3697 bool ListInitialization) {
3698 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3699 RParenLoc, ListInitialization);
3700 }
3701
3702 /// Build a new member reference expression.
3703 ///
3704 /// By default, performs semantic analysis to build the new expression.
3705 /// Subclasses may override this routine to provide different behavior.
3707 QualType BaseType,
3708 bool IsArrow,
3709 SourceLocation OperatorLoc,
3710 NestedNameSpecifierLoc QualifierLoc,
3711 SourceLocation TemplateKWLoc,
3712 NamedDecl *FirstQualifierInScope,
3713 const DeclarationNameInfo &MemberNameInfo,
3714 const TemplateArgumentListInfo *TemplateArgs) {
3715 CXXScopeSpec SS;
3716 SS.Adopt(QualifierLoc);
3717
3718 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3719 OperatorLoc, IsArrow,
3720 SS, TemplateKWLoc,
3721 FirstQualifierInScope,
3722 MemberNameInfo,
3723 TemplateArgs, /*S*/nullptr);
3724 }
3725
3726 /// Build a new member reference expression.
3727 ///
3728 /// By default, performs semantic analysis to build the new expression.
3729 /// Subclasses may override this routine to provide different behavior.
3731 SourceLocation OperatorLoc,
3732 bool IsArrow,
3733 NestedNameSpecifierLoc QualifierLoc,
3734 SourceLocation TemplateKWLoc,
3735 NamedDecl *FirstQualifierInScope,
3736 LookupResult &R,
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 R, TemplateArgs, /*S*/nullptr);
3746 }
3747
3748 /// Build a new noexcept expression.
3749 ///
3750 /// By default, performs semantic analysis to build the new expression.
3751 /// Subclasses may override this routine to provide different behavior.
3753 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3754 }
3755
3758
3759 /// Build a new expression to compute the length of a parameter pack.
3761 SourceLocation PackLoc,
3762 SourceLocation RParenLoc,
3763 UnsignedOrNone Length,
3764 ArrayRef<TemplateArgument> PartialArgs) {
3765 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3766 RParenLoc, Length, PartialArgs);
3767 }
3768
3770 SourceLocation RSquareLoc,
3771 Expr *PackIdExpression, Expr *IndexExpr,
3772 ArrayRef<Expr *> ExpandedExprs,
3773 bool FullySubstituted = false) {
3774 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3775 IndexExpr, RSquareLoc, ExpandedExprs,
3776 FullySubstituted);
3777 }
3778
3779 /// Build a new expression representing a call to a source location
3780 /// builtin.
3781 ///
3782 /// By default, performs semantic analysis to build the new expression.
3783 /// Subclasses may override this routine to provide different behavior.
3785 SourceLocation BuiltinLoc,
3786 SourceLocation RPLoc,
3787 DeclContext *ParentContext) {
3788 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3789 ParentContext);
3790 }
3791
3793 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3794 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3796 CXXScopeSpec SS;
3797 SS.Adopt(NNS);
3798 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3799 ConceptNameInfo,
3800 FoundDecl,
3801 NamedConcept, TALI);
3802 if (Result.isInvalid())
3803 return ExprError();
3804 return Result;
3805 }
3806
3807 /// \brief Build a new requires expression.
3808 ///
3809 /// By default, performs semantic analysis to build the new expression.
3810 /// Subclasses may override this routine to provide different behavior.
3813 SourceLocation LParenLoc,
3814 ArrayRef<ParmVarDecl *> LocalParameters,
3815 SourceLocation RParenLoc,
3817 SourceLocation ClosingBraceLoc) {
3818 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3819 LocalParameters, RParenLoc, Requirements,
3820 ClosingBraceLoc);
3821 }
3822
3826 return SemaRef.BuildTypeRequirement(SubstDiag);
3827 }
3828
3830 return SemaRef.BuildTypeRequirement(T);
3831 }
3832
3835 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3836 SourceLocation NoexceptLoc,
3838 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3839 std::move(Ret));
3840 }
3841
3843 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3845 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3846 std::move(Ret));
3847 }
3848
3850 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3851 const ASTConstraintSatisfaction &Satisfaction) {
3852 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3853 Satisfaction);
3854 }
3855
3857 return SemaRef.BuildNestedRequirement(Constraint);
3858 }
3859
3860 /// \brief Build a new Objective-C boxed expression.
3861 ///
3862 /// By default, performs semantic analysis to build the new expression.
3863 /// Subclasses may override this routine to provide different behavior.
3865 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3866 }
3867
3868 /// Build a new Objective-C array literal.
3869 ///
3870 /// By default, performs semantic analysis to build the new expression.
3871 /// Subclasses may override this routine to provide different behavior.
3873 Expr **Elements, unsigned NumElements) {
3875 Range, MultiExprArg(Elements, NumElements));
3876 }
3877
3879 Expr *Base, Expr *Key,
3880 ObjCMethodDecl *getterMethod,
3881 ObjCMethodDecl *setterMethod) {
3883 RB, Base, Key, getterMethod, setterMethod);
3884 }
3885
3886 /// Build a new Objective-C dictionary literal.
3887 ///
3888 /// By default, performs semantic analysis to build the new expression.
3889 /// Subclasses may override this routine to provide different behavior.
3894
3895 /// Build a new Objective-C \@encode expression.
3896 ///
3897 /// By default, performs semantic analysis to build the new expression.
3898 /// Subclasses may override this routine to provide different behavior.
3900 TypeSourceInfo *EncodeTypeInfo,
3901 SourceLocation RParenLoc) {
3902 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3903 RParenLoc);
3904 }
3905
3906 /// Build a new Objective-C class message.
3908 Selector Sel,
3909 ArrayRef<SourceLocation> SelectorLocs,
3911 SourceLocation LBracLoc,
3912 MultiExprArg Args,
3913 SourceLocation RBracLoc) {
3914 return SemaRef.ObjC().BuildClassMessage(
3915 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3916 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3917 RBracLoc, Args);
3918 }
3919
3920 /// Build a new Objective-C instance message.
3922 Selector Sel,
3923 ArrayRef<SourceLocation> SelectorLocs,
3925 SourceLocation LBracLoc,
3926 MultiExprArg Args,
3927 SourceLocation RBracLoc) {
3928 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3929 /*SuperLoc=*/SourceLocation(),
3930 Sel, Method, LBracLoc,
3931 SelectorLocs, RBracLoc, Args);
3932 }
3933
3934 /// Build a new Objective-C instance/class message to 'super'.
3936 Selector Sel,
3937 ArrayRef<SourceLocation> SelectorLocs,
3938 QualType SuperType,
3940 SourceLocation LBracLoc,
3941 MultiExprArg Args,
3942 SourceLocation RBracLoc) {
3943 return Method->isInstanceMethod()
3944 ? SemaRef.ObjC().BuildInstanceMessage(
3945 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3946 SelectorLocs, RBracLoc, Args)
3947 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3948 Sel, Method, LBracLoc,
3949 SelectorLocs, RBracLoc, Args);
3950 }
3951
3952 /// Build a new Objective-C ivar reference expression.
3953 ///
3954 /// By default, performs semantic analysis to build the new expression.
3955 /// Subclasses may override this routine to provide different behavior.
3957 SourceLocation IvarLoc,
3958 bool IsArrow, bool IsFreeIvar) {
3959 CXXScopeSpec SS;
3960 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3962 BaseArg, BaseArg->getType(),
3963 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3964 /*FirstQualifierInScope=*/nullptr, NameInfo,
3965 /*TemplateArgs=*/nullptr,
3966 /*S=*/nullptr);
3967 if (IsFreeIvar && Result.isUsable())
3968 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3969 return Result;
3970 }
3971
3972 /// Build a new Objective-C property reference expression.
3973 ///
3974 /// By default, performs semantic analysis to build the new expression.
3975 /// Subclasses may override this routine to provide different behavior.
3978 SourceLocation PropertyLoc) {
3979 CXXScopeSpec SS;
3980 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3981 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3982 /*FIXME:*/PropertyLoc,
3983 /*IsArrow=*/false,
3984 SS, SourceLocation(),
3985 /*FirstQualifierInScope=*/nullptr,
3986 NameInfo,
3987 /*TemplateArgs=*/nullptr,
3988 /*S=*/nullptr);
3989 }
3990
3991 /// Build a new Objective-C property reference expression.
3992 ///
3993 /// By default, performs semantic analysis to build the new expression.
3994 /// Subclasses may override this routine to provide different behavior.
3996 ObjCMethodDecl *Getter,
3997 ObjCMethodDecl *Setter,
3998 SourceLocation PropertyLoc) {
3999 // Since these expressions can only be value-dependent, we do not
4000 // need to perform semantic analysis again.
4001 return Owned(
4002 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
4004 PropertyLoc, Base));
4005 }
4006
4007 /// Build a new Objective-C "isa" expression.
4008 ///
4009 /// By default, performs semantic analysis to build the new expression.
4010 /// Subclasses may override this routine to provide different behavior.
4012 SourceLocation OpLoc, bool IsArrow) {
4013 CXXScopeSpec SS;
4014 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
4015 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
4016 OpLoc, IsArrow,
4017 SS, SourceLocation(),
4018 /*FirstQualifierInScope=*/nullptr,
4019 NameInfo,
4020 /*TemplateArgs=*/nullptr,
4021 /*S=*/nullptr);
4022 }
4023
4024 /// Build a new shuffle vector expression.
4025 ///
4026 /// By default, performs semantic analysis to build the new expression.
4027 /// Subclasses may override this routine to provide different behavior.
4029 MultiExprArg SubExprs,
4030 SourceLocation RParenLoc) {
4031 // Find the declaration for __builtin_shufflevector
4032 const IdentifierInfo &Name
4033 = SemaRef.Context.Idents.get("__builtin_shufflevector");
4034 TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
4035 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
4036 assert(!Lookup.empty() && "No __builtin_shufflevector?");
4037
4038 // Build a reference to the __builtin_shufflevector builtin
4040 Expr *Callee = new (SemaRef.Context)
4041 DeclRefExpr(SemaRef.Context, Builtin, false,
4042 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
4043 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
4044 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
4045 CK_BuiltinFnToFnPtr).get();
4046
4047 // Build the CallExpr
4048 ExprResult TheCall = CallExpr::Create(
4049 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
4050 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
4052
4053 // Type-check the __builtin_shufflevector expression.
4054 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
4055 }
4056
4057 /// Build a new convert vector expression.
4059 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
4060 SourceLocation RParenLoc) {
4061 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
4062 }
4063
4064 /// Build a new template argument pack expansion.
4065 ///
4066 /// By default, performs semantic analysis to build a new pack expansion
4067 /// for a template argument. Subclasses may override this routine to provide
4068 /// different behavior.
4070 SourceLocation EllipsisLoc,
4071 UnsignedOrNone NumExpansions) {
4072 switch (Pattern.getArgument().getKind()) {
4076 EllipsisLoc, NumExpansions);
4077 if (Result.isInvalid())
4078 return TemplateArgumentLoc();
4079
4081 /*IsCanonical=*/false),
4082 Result.get());
4083 }
4084
4086 return TemplateArgumentLoc(
4087 SemaRef.Context,
4089 NumExpansions),
4090 Pattern.getTemplateKWLoc(), Pattern.getTemplateQualifierLoc(),
4091 Pattern.getTemplateNameLoc(), EllipsisLoc);
4092
4100 llvm_unreachable("Pack expansion pattern has no parameter packs");
4101
4103 if (TypeSourceInfo *Expansion
4104 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4105 EllipsisLoc,
4106 NumExpansions))
4107 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4108 Expansion);
4109 break;
4110 }
4111
4112 return TemplateArgumentLoc();
4113 }
4114
4115 /// Build a new expression pack expansion.
4116 ///
4117 /// By default, performs semantic analysis to build a new pack expansion
4118 /// for an expression. Subclasses may override this routine to provide
4119 /// different behavior.
4121 UnsignedOrNone NumExpansions) {
4122 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4123 }
4124
4125 /// Build a new C++1z fold-expression.
4126 ///
4127 /// By default, performs semantic analysis in order to build a new fold
4128 /// expression.
4130 SourceLocation LParenLoc, Expr *LHS,
4131 BinaryOperatorKind Operator,
4132 SourceLocation EllipsisLoc, Expr *RHS,
4133 SourceLocation RParenLoc,
4134 UnsignedOrNone NumExpansions) {
4135 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4136 EllipsisLoc, RHS, RParenLoc,
4137 NumExpansions);
4138 }
4139
4141 LambdaScopeInfo *LSI) {
4142 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4143 if (Expr *Init = PVD->getInit())
4145 Init->containsUnexpandedParameterPack();
4146 else if (PVD->hasUninstantiatedDefaultArg())
4148 PVD->getUninstantiatedDefaultArg()
4149 ->containsUnexpandedParameterPack();
4150 }
4151 return getSema().BuildLambdaExpr(StartLoc, EndLoc);
4152 }
4153
4154 /// Build an empty C++1z fold-expression with the given operator.
4155 ///
4156 /// By default, produces the fallback value for the fold-expression, or
4157 /// produce an error if there is no fallback value.
4159 BinaryOperatorKind Operator) {
4160 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4161 }
4162
4163 /// Build a new atomic operation expression.
4164 ///
4165 /// By default, performs semantic analysis to build the new expression.
4166 /// Subclasses may override this routine to provide different behavior.
4169 SourceLocation RParenLoc) {
4170 // Use this for all of the locations, since we don't know the difference
4171 // between the call and the expr at this point.
4172 SourceRange Range{BuiltinLoc, RParenLoc};
4173 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4175 }
4176
4178 ArrayRef<Expr *> SubExprs, QualType Type) {
4179 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4180 }
4181
4183 SourceLocation BeginLoc,
4184 SourceLocation DirLoc,
4185 SourceLocation EndLoc,
4187 StmtResult StrBlock) {
4189 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4190 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, StrBlock);
4191 }
4192
4203
4205 SourceLocation BeginLoc,
4206 SourceLocation DirLoc,
4207 SourceLocation EndLoc,
4209 StmtResult Loop) {
4211 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4212 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, Loop);
4213 }
4214
4216 SourceLocation DirLoc,
4217 SourceLocation EndLoc,
4219 StmtResult StrBlock) {
4221 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4223 Clauses, StrBlock);
4224 }
4225
4235
4245
4247 SourceLocation DirLoc,
4248 SourceLocation EndLoc,
4250 StmtResult StrBlock) {
4254 Clauses, StrBlock);
4255 }
4256
4258 SourceLocation DirLoc,
4259 SourceLocation EndLoc,
4260 ArrayRef<OpenACCClause *> Clauses) {
4262 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4264 Clauses, {});
4265 }
4266
4276
4278 SourceLocation DirLoc,
4279 SourceLocation EndLoc,
4280 ArrayRef<OpenACCClause *> Clauses) {
4282 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4284 Clauses, {});
4285 }
4286
4288 SourceLocation DirLoc,
4289 SourceLocation EndLoc,
4290 ArrayRef<OpenACCClause *> Clauses) {
4292 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4294 Clauses, {});
4295 }
4296
4298 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4299 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4300 SourceLocation RParenLoc, SourceLocation EndLoc,
4301 ArrayRef<OpenACCClause *> Clauses) {
4303 Exprs.push_back(DevNumExpr);
4304 llvm::append_range(Exprs, QueueIdExprs);
4306 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4307 Exprs, OpenACCAtomicKind::None, RParenLoc, EndLoc, Clauses, {});
4308 }
4309
4311 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4312 SourceLocation ReadOnlyLoc, ArrayRef<Expr *> VarList,
4313 SourceLocation RParenLoc, SourceLocation EndLoc) {
4315 OpenACCDirectiveKind::Cache, BeginLoc, DirLoc, LParenLoc, ReadOnlyLoc,
4316 VarList, OpenACCAtomicKind::None, RParenLoc, EndLoc, {}, {});
4317 }
4318
4320 SourceLocation DirLoc,
4321 OpenACCAtomicKind AtKind,
4322 SourceLocation EndLoc,
4324 StmtResult AssociatedStmt) {
4326 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4327 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, Clauses,
4328 AssociatedStmt);
4329 }
4330
4334
4336 RebuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, unsigned Index,
4337 QualType ParamType, SourceLocation Loc,
4338 TemplateArgument Arg,
4339 UnsignedOrNone PackIndex, bool Final) {
4341 AssociatedDecl, Index, ParamType, Loc, Arg, PackIndex, Final);
4342 }
4343
4345 SourceLocation StartLoc,
4346 SourceLocation LParenLoc,
4347 SourceLocation EndLoc) {
4348 return getSema().OpenMP().ActOnOpenMPTransparentClause(ImpexType, StartLoc,
4349 LParenLoc, EndLoc);
4350 }
4351
4352private:
4353 QualType TransformTypeInObjectScope(TypeLocBuilder &TLB, TypeLoc TL,
4354 QualType ObjectType,
4355 NamedDecl *FirstQualifierInScope);
4356
4357 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4358 QualType ObjectType,
4359 NamedDecl *FirstQualifierInScope) {
4360 if (getDerived().AlreadyTransformed(TSInfo->getType()))
4361 return TSInfo;
4362
4363 TypeLocBuilder TLB;
4364 QualType T = TransformTypeInObjectScope(TLB, TSInfo->getTypeLoc(),
4365 ObjectType, FirstQualifierInScope);
4366 if (T.isNull())
4367 return nullptr;
4368 return TLB.getTypeSourceInfo(SemaRef.Context, T);
4369 }
4370
4371 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4372 DependentNameTypeLoc TL,
4373 bool DeducibleTSTContext,
4374 QualType ObjectType = QualType(),
4375 NamedDecl *UnqualLookup = nullptr);
4376
4378 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4380
4381 OpenACCClause *
4382 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4383 OpenACCDirectiveKind DirKind,
4384 const OpenACCClause *OldClause);
4385};
4386
4387template <typename Derived>
4389 if (!S)
4390 return S;
4391
4392 switch (S->getStmtClass()) {
4393 case Stmt::NoStmtClass: break;
4394
4395 // Transform individual statement nodes
4396 // Pass SDK into statements that can produce a value
4397#define STMT(Node, Parent) \
4398 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4399#define VALUESTMT(Node, Parent) \
4400 case Stmt::Node##Class: \
4401 return getDerived().Transform##Node(cast<Node>(S), SDK);
4402#define ABSTRACT_STMT(Node)
4403#define EXPR(Node, Parent)
4404#include "clang/AST/StmtNodes.inc"
4405
4406 // Transform expressions by calling TransformExpr.
4407#define STMT(Node, Parent)
4408#define ABSTRACT_STMT(Stmt)
4409#define EXPR(Node, Parent) case Stmt::Node##Class:
4410#include "clang/AST/StmtNodes.inc"
4411 {
4412 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4413
4415 E = getSema().ActOnStmtExprResult(E);
4416 return getSema().ActOnExprStmt(E, SDK == StmtDiscardKind::Discarded);
4417 }
4418 }
4419
4420 return S;
4421}
4422
4423template<typename Derived>
4425 if (!S)
4426 return S;
4427
4428 switch (S->getClauseKind()) {
4429 default: break;
4430 // Transform individual clause nodes
4431#define GEN_CLANG_CLAUSE_CLASS
4432#define CLAUSE_CLASS(Enum, Str, Class) \
4433 case Enum: \
4434 return getDerived().Transform##Class(cast<Class>(S));
4435#include "llvm/Frontend/OpenMP/OMP.inc"
4436 }
4437
4438 return S;
4439}
4440
4441
4442template<typename Derived>
4444 if (!E)
4445 return E;
4446
4447 switch (E->getStmtClass()) {
4448 case Stmt::NoStmtClass: break;
4449#define STMT(Node, Parent) case Stmt::Node##Class: break;
4450#define ABSTRACT_STMT(Stmt)
4451#define EXPR(Node, Parent) \
4452 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4453#include "clang/AST/StmtNodes.inc"
4454 }
4455
4456 return E;
4457}
4458
4459template<typename Derived>
4461 bool NotCopyInit) {
4462 // Initializers are instantiated like expressions, except that various outer
4463 // layers are stripped.
4464 if (!Init)
4465 return Init;
4466
4467 if (auto *FE = dyn_cast<FullExpr>(Init))
4468 Init = FE->getSubExpr();
4469
4470 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4471 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4472 Init = OVE->getSourceExpr();
4473 }
4474
4475 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4476 Init = MTE->getSubExpr();
4477
4478 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4479 Init = Binder->getSubExpr();
4480
4481 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4482 Init = ICE->getSubExprAsWritten();
4483
4484 if (CXXStdInitializerListExpr *ILE =
4485 dyn_cast<CXXStdInitializerListExpr>(Init))
4486 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4487
4488 // If this is copy-initialization, we only need to reconstruct
4489 // InitListExprs. Other forms of copy-initialization will be a no-op if
4490 // the initializer is already the right type.
4491 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4492 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4493 return getDerived().TransformExpr(Init);
4494
4495 // Revert value-initialization back to empty parens.
4496 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4497 SourceRange Parens = VIE->getSourceRange();
4498 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4499 Parens.getEnd());
4500 }
4501
4502 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4504 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4505 SourceLocation());
4506
4507 // Revert initialization by constructor back to a parenthesized or braced list
4508 // of expressions. Any other form of initializer can just be reused directly.
4509 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4510 return getDerived().TransformExpr(Init);
4511
4512 // If the initialization implicitly converted an initializer list to a
4513 // std::initializer_list object, unwrap the std::initializer_list too.
4514 if (Construct && Construct->isStdInitListInitialization())
4515 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4516
4517 // Enter a list-init context if this was list initialization.
4520 Construct->isListInitialization());
4521
4522 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4523 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4524 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4525 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4526 SmallVector<Expr*, 8> NewArgs;
4527 bool ArgChanged = false;
4528 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4529 /*IsCall*/true, NewArgs, &ArgChanged))
4530 return ExprError();
4531
4532 // If this was list initialization, revert to syntactic list form.
4533 if (Construct->isListInitialization())
4534 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4535 Construct->getEndLoc(),
4536 /*IsExplicit=*/true);
4537
4538 // Build a ParenListExpr to represent anything else.
4540 if (Parens.isInvalid()) {
4541 // This was a variable declaration's initialization for which no initializer
4542 // was specified.
4543 assert(NewArgs.empty() &&
4544 "no parens or braces but have direct init with arguments?");
4545 return ExprEmpty();
4546 }
4547 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4548 Parens.getEnd());
4549}
4550
4551template<typename Derived>
4553 unsigned NumInputs,
4554 bool IsCall,
4555 SmallVectorImpl<Expr *> &Outputs,
4556 bool *ArgChanged) {
4557 for (unsigned I = 0; I != NumInputs; ++I) {
4558 // If requested, drop call arguments that need to be dropped.
4559 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4560 if (ArgChanged)
4561 *ArgChanged = true;
4562
4563 break;
4564 }
4565
4566 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4567 Expr *Pattern = Expansion->getPattern();
4568
4570 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4571 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4572
4573 // Determine whether the set of unexpanded parameter packs can and should
4574 // be expanded.
4575 bool Expand = true;
4576 bool RetainExpansion = false;
4577 UnsignedOrNone OrigNumExpansions = Expansion->getNumExpansions();
4578 UnsignedOrNone NumExpansions = OrigNumExpansions;
4580 Expansion->getEllipsisLoc(), Pattern->getSourceRange(),
4581 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
4582 RetainExpansion, NumExpansions))
4583 return true;
4584
4585 if (!Expand) {
4586 // The transform has determined that we should perform a simple
4587 // transformation on the pack expansion, producing another pack
4588 // expansion.
4589 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
4590 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4591 if (OutPattern.isInvalid())
4592 return true;
4593
4594 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4595 Expansion->getEllipsisLoc(),
4596 NumExpansions);
4597 if (Out.isInvalid())
4598 return true;
4599
4600 if (ArgChanged)
4601 *ArgChanged = true;
4602 Outputs.push_back(Out.get());
4603 continue;
4604 }
4605
4606 // Record right away that the argument was changed. This needs
4607 // to happen even if the array expands to nothing.
4608 if (ArgChanged) *ArgChanged = true;
4609
4610 // The transform has determined that we should perform an elementwise
4611 // expansion of the pattern. Do so.
4612 for (unsigned I = 0; I != *NumExpansions; ++I) {
4613 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
4614 ExprResult Out = getDerived().TransformExpr(Pattern);
4615 if (Out.isInvalid())
4616 return true;
4617
4618 if (Out.get()->containsUnexpandedParameterPack()) {
4619 Out = getDerived().RebuildPackExpansion(
4620 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4621 if (Out.isInvalid())
4622 return true;
4623 }
4624
4625 Outputs.push_back(Out.get());
4626 }
4627
4628 // If we're supposed to retain a pack expansion, do so by temporarily
4629 // forgetting the partially-substituted parameter pack.
4630 if (RetainExpansion) {
4631 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4632
4633 ExprResult Out = getDerived().TransformExpr(Pattern);
4634 if (Out.isInvalid())
4635 return true;
4636
4637 Out = getDerived().RebuildPackExpansion(
4638 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4639 if (Out.isInvalid())
4640 return true;
4641
4642 Outputs.push_back(Out.get());
4643 }
4644
4645 continue;
4646 }
4647
4649 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4650 : getDerived().TransformExpr(Inputs[I]);
4651 if (Result.isInvalid())
4652 return true;
4653
4654 if (Result.get() != Inputs[I] && ArgChanged)
4655 *ArgChanged = true;
4656
4657 Outputs.push_back(Result.get());
4658 }
4659
4660 return false;
4661}
4662
4663template <typename Derived>
4666
4669 /*LambdaContextDecl=*/nullptr,
4671 /*ShouldEnter=*/Kind == Sema::ConditionKind::ConstexprIf);
4672
4673 if (Var) {
4674 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4676
4677 if (!ConditionVar)
4678 return Sema::ConditionError();
4679
4680 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4681 }
4682
4683 if (Expr) {
4684 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4685
4686 if (CondExpr.isInvalid())
4687 return Sema::ConditionError();
4688
4689 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4690 /*MissingOK=*/true);
4691 }
4692
4693 return Sema::ConditionResult();
4694}
4695
4696template <typename Derived>
4698 NestedNameSpecifierLoc NNS, QualType ObjectType,
4699 NamedDecl *FirstQualifierInScope) {
4701
4702 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4703 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4704 Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix)
4705 Qualifiers.push_back(Qualifier);
4706 };
4707 insertNNS(NNS);
4708
4709 CXXScopeSpec SS;
4710 while (!Qualifiers.empty()) {
4711 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4713
4714 switch (QNNS.getKind()) {
4716 llvm_unreachable("unexpected null nested name specifier");
4717
4720 Q.getLocalBeginLoc(), const_cast<NamespaceBaseDecl *>(
4722 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4723 break;
4724 }
4725
4727 // There is no meaningful transformation that one could perform on the
4728 // global scope.
4729 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4730 break;
4731
4733 CXXRecordDecl *RD = cast_or_null<CXXRecordDecl>(
4735 SS.MakeMicrosoftSuper(SemaRef.Context, RD, Q.getBeginLoc(),
4736 Q.getEndLoc());
4737 break;
4738 }
4739
4741 assert(SS.isEmpty());
4742 TypeLoc TL = Q.castAsTypeLoc();
4743
4744 if (auto DNT = TL.getAs<DependentNameTypeLoc>()) {
4745 NestedNameSpecifierLoc QualifierLoc = DNT.getQualifierLoc();
4746 if (QualifierLoc) {
4747 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4748 QualifierLoc, ObjectType, FirstQualifierInScope);
4749 if (!QualifierLoc)
4750 return NestedNameSpecifierLoc();
4751 ObjectType = QualType();
4752 FirstQualifierInScope = nullptr;
4753 }
4754 SS.Adopt(QualifierLoc);
4756 const_cast<IdentifierInfo *>(DNT.getTypePtr()->getIdentifier()),
4757 DNT.getNameLoc(), Q.getLocalEndLoc(), ObjectType);
4758 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo,
4759 false, SS,
4760 FirstQualifierInScope, false))
4761 return NestedNameSpecifierLoc();
4762 return SS.getWithLocInContext(SemaRef.Context);
4763 }
4764
4765 QualType T = TL.getType();
4766 TypeLocBuilder TLB;
4767 if (!getDerived().AlreadyTransformed(T)) {
4768 T = TransformTypeInObjectScope(TLB, TL, ObjectType,
4769 FirstQualifierInScope);
4770 if (T.isNull())
4771 return NestedNameSpecifierLoc();
4772 TL = TLB.getTypeLocInContext(SemaRef.Context, T);
4773 }
4774
4775 if (T->isDependentType() || T->isRecordType() ||
4776 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4777 if (T->isEnumeralType())
4778 SemaRef.Diag(TL.getBeginLoc(),
4779 diag::warn_cxx98_compat_enum_nested_name_spec);
4780 SS.Make(SemaRef.Context, TL, Q.getLocalEndLoc());
4781 break;
4782 }
4783 // If the nested-name-specifier is an invalid type def, don't emit an
4784 // error because a previous error should have already been emitted.
4786 if (!TTL || !TTL.getDecl()->isInvalidDecl()) {
4787 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4788 << T << SS.getRange();
4789 }
4790 return NestedNameSpecifierLoc();
4791 }
4792 }
4793 }
4794
4795 // Don't rebuild the nested-name-specifier if we don't have to.
4796 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4798 return NNS;
4799
4800 // If we can re-use the source-location data from the original
4801 // nested-name-specifier, do so.
4802 if (SS.location_size() == NNS.getDataLength() &&
4803 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4805
4806 // Allocate new nested-name-specifier location information.
4807 return SS.getWithLocInContext(SemaRef.Context);
4808}
4809
4810template<typename Derived>
4814 DeclarationName Name = NameInfo.getName();
4815 if (!Name)
4816 return DeclarationNameInfo();
4817
4818 switch (Name.getNameKind()) {
4826 return NameInfo;
4827
4829 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4830 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4831 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4832 if (!NewTemplate)
4833 return DeclarationNameInfo();
4834
4835 DeclarationNameInfo NewNameInfo(NameInfo);
4836 NewNameInfo.setName(
4837 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
4838 return NewNameInfo;
4839 }
4840
4844 TypeSourceInfo *NewTInfo;
4845 CanQualType NewCanTy;
4846 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4847 NewTInfo = getDerived().TransformType(OldTInfo);
4848 if (!NewTInfo)
4849 return DeclarationNameInfo();
4850 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4851 }
4852 else {
4853 NewTInfo = nullptr;
4854 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4855 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4856 if (NewT.isNull())
4857 return DeclarationNameInfo();
4858 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4859 }
4860
4861 DeclarationName NewName
4862 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4863 NewCanTy);
4864 DeclarationNameInfo NewNameInfo(NameInfo);
4865 NewNameInfo.setName(NewName);
4866 NewNameInfo.setNamedTypeInfo(NewTInfo);
4867 return NewNameInfo;
4868 }
4869 }
4870
4871 llvm_unreachable("Unknown name kind.");
4872}
4873
4874template <typename Derived>
4876 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4878 QualType ObjectType, bool AllowInjectedClassName) {
4879 if (const IdentifierInfo *II = IO.getIdentifier())
4880 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, *II, NameLoc,
4881 ObjectType, AllowInjectedClassName);
4882 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, IO.getOperator(),
4883 NameLoc, ObjectType,
4884 AllowInjectedClassName);
4885}
4886
4887template <typename Derived>
4889 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
4890 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
4891 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
4893 TemplateName UnderlyingName = QTN->getUnderlyingTemplate();
4894
4895 if (QualifierLoc) {
4896 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4897 QualifierLoc, ObjectType, FirstQualifierInScope);
4898 if (!QualifierLoc)
4899 return TemplateName();
4900 }
4901
4902 NestedNameSpecifierLoc UnderlyingQualifier;
4903 TemplateName NewUnderlyingName = getDerived().TransformTemplateName(
4904 UnderlyingQualifier, TemplateKWLoc, UnderlyingName, NameLoc, ObjectType,
4905 FirstQualifierInScope, AllowInjectedClassName);
4906 if (NewUnderlyingName.isNull())
4907 return TemplateName();
4908 assert(!UnderlyingQualifier && "unexpected qualifier");
4909
4910 if (!getDerived().AlwaysRebuild() &&
4911 QualifierLoc.getNestedNameSpecifier() == QTN->getQualifier() &&
4912 NewUnderlyingName == UnderlyingName)
4913 return Name;
4914 CXXScopeSpec SS;
4915 SS.Adopt(QualifierLoc);
4916 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4917 NewUnderlyingName);
4918 }
4919
4921 if (QualifierLoc) {
4922 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4923 QualifierLoc, ObjectType, FirstQualifierInScope);
4924 if (!QualifierLoc)
4925 return TemplateName();
4926 // The qualifier-in-scope and object type only apply to the leftmost
4927 // entity.
4928 ObjectType = QualType();
4929 }
4930
4931 if (!getDerived().AlwaysRebuild() &&
4932 QualifierLoc.getNestedNameSpecifier() == DTN->getQualifier() &&
4933 ObjectType.isNull())
4934 return Name;
4935
4936 CXXScopeSpec SS;
4937 SS.Adopt(QualifierLoc);
4938 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, DTN->getName(),
4939 NameLoc, ObjectType,
4940 AllowInjectedClassName);
4941 }
4942
4945 assert(!QualifierLoc && "Unexpected qualified SubstTemplateTemplateParm");
4946
4947 NestedNameSpecifierLoc ReplacementQualifierLoc;
4948 TemplateName ReplacementName = S->getReplacement();
4949 if (NestedNameSpecifier Qualifier = ReplacementName.getQualifier()) {
4951 Builder.MakeTrivial(SemaRef.Context, Qualifier, NameLoc);
4952 ReplacementQualifierLoc = Builder.getWithLocInContext(SemaRef.Context);
4953 }
4954
4955 TemplateName NewName = getDerived().TransformTemplateName(
4956 ReplacementQualifierLoc, TemplateKWLoc, ReplacementName, NameLoc,
4957 ObjectType, FirstQualifierInScope, AllowInjectedClassName);
4958 if (NewName.isNull())
4959 return TemplateName();
4960 Decl *AssociatedDecl =
4961 getDerived().TransformDecl(NameLoc, S->getAssociatedDecl());
4962 if (!getDerived().AlwaysRebuild() && NewName == S->getReplacement() &&
4963 AssociatedDecl == S->getAssociatedDecl())
4964 return Name;
4965 return SemaRef.Context.getSubstTemplateTemplateParm(
4966 NewName, AssociatedDecl, S->getIndex(), S->getPackIndex(),
4967 S->getFinal());
4968 }
4969
4970 assert(!Name.getAsDeducedTemplateName() &&
4971 "DeducedTemplateName should not escape partial ordering");
4972
4973 // FIXME: Preserve UsingTemplateName.
4974 if (auto *Template = Name.getAsTemplateDecl()) {
4975 assert(!QualifierLoc && "Unexpected qualifier");
4976 return TemplateName(cast_or_null<TemplateDecl>(
4977 getDerived().TransformDecl(NameLoc, Template)));
4978 }
4979
4982 assert(!QualifierLoc &&
4983 "Unexpected qualified SubstTemplateTemplateParmPack");
4984 return getDerived().RebuildTemplateName(
4985 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4986 SubstPack->getIndex(), SubstPack->getFinal());
4987 }
4988
4989 // These should be getting filtered out before they reach the AST.
4990 llvm_unreachable("overloaded function decl survived to here");
4991}
4992
4993template <typename Derived>
4995 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
4996 TemplateName Name, SourceLocation NameLoc) {
4997 TemplateName TN = getDerived().TransformTemplateName(
4998 QualifierLoc, TemplateKeywordLoc, Name, NameLoc);
4999 if (TN.isNull())
5000 return TemplateArgument();
5001 return TemplateArgument(TN);
5002}
5003
5004template<typename Derived>
5006 const TemplateArgument &Arg,
5007 TemplateArgumentLoc &Output) {
5008 Output = getSema().getTrivialTemplateArgumentLoc(
5009 Arg, QualType(), getDerived().getBaseLocation());
5010}
5011
5012template <typename Derived>
5014 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
5015 bool Uneval) {
5016 const TemplateArgument &Arg = Input.getArgument();
5017 switch (Arg.getKind()) {
5020 llvm_unreachable("Unexpected TemplateArgument");
5021
5026 // Transform a resolved template argument straight to a resolved template
5027 // argument. We get here when substituting into an already-substituted
5028 // template type argument during concept satisfaction checking.
5030 QualType NewT = getDerived().TransformType(T);
5031 if (NewT.isNull())
5032 return true;
5033
5035 ? Arg.getAsDecl()
5036 : nullptr;
5037 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
5039 : nullptr;
5040 if (D && !NewD)
5041 return true;
5042
5043 if (NewT == T && D == NewD)
5044 Output = Input;
5045 else if (Arg.getKind() == TemplateArgument::Integral)
5046 Output = TemplateArgumentLoc(
5047 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
5049 else if (Arg.getKind() == TemplateArgument::NullPtr)
5050 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
5052 else if (Arg.getKind() == TemplateArgument::Declaration)
5053 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
5056 Output = TemplateArgumentLoc(
5057 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
5059 else
5060 llvm_unreachable("unexpected template argument kind");
5061
5062 return false;
5063 }
5064
5066 TypeSourceInfo *TSI = Input.getTypeSourceInfo();
5067 if (!TSI)
5069
5070 TSI = getDerived().TransformType(TSI);
5071 if (!TSI)
5072 return true;
5073
5074 Output = TemplateArgumentLoc(TemplateArgument(TSI->getType()), TSI);
5075 return false;
5076 }
5077
5079 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
5080
5081 TemplateArgument Out = getDerived().TransformNamedTemplateTemplateArgument(
5082 QualifierLoc, Input.getTemplateKWLoc(), Arg.getAsTemplate(),
5083 Input.getTemplateNameLoc());
5084 if (Out.isNull())
5085 return true;
5086 Output = TemplateArgumentLoc(SemaRef.Context, Out, Input.getTemplateKWLoc(),
5087 QualifierLoc, Input.getTemplateNameLoc());
5088 return false;
5089 }
5090
5092 llvm_unreachable("Caller should expand pack expansions");
5093
5095 // Template argument expressions are constant expressions.
5097 getSema(),
5100 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
5102
5103 Expr *InputExpr = Input.getSourceExpression();
5104 if (!InputExpr)
5105 InputExpr = Input.getArgument().getAsExpr();
5106
5107 ExprResult E = getDerived().TransformExpr(InputExpr);
5108 E = SemaRef.ActOnConstantExpression(E);
5109 if (E.isInvalid())
5110 return true;
5111 Output = TemplateArgumentLoc(
5112 TemplateArgument(E.get(), /*IsCanonical=*/false), E.get());
5113 return false;
5114 }
5115 }
5116
5117 // Work around bogus GCC warning
5118 return true;
5119}
5120
5121/// Iterator adaptor that invents template argument location information
5122/// for each of the template arguments in its underlying iterator.
5123template<typename Derived, typename InputIterator>
5126 InputIterator Iter;
5127
5128public:
5131 typedef typename std::iterator_traits<InputIterator>::difference_type
5133 typedef std::input_iterator_tag iterator_category;
5134
5135 class pointer {
5137
5138 public:
5139 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5140
5141 const TemplateArgumentLoc *operator->() const { return &Arg; }
5142 };
5143
5145 InputIterator Iter)
5146 : Self(Self), Iter(Iter) { }
5147
5149 ++Iter;
5150 return *this;
5151 }
5152
5155 ++(*this);
5156 return Old;
5157 }
5158
5161 Self.InventTemplateArgumentLoc(*Iter, Result);
5162 return Result;
5163 }
5164
5165 pointer operator->() const { return pointer(**this); }
5166
5169 return X.Iter == Y.Iter;
5170 }
5171
5174 return X.Iter != Y.Iter;
5175 }
5176};
5177
5178template<typename Derived>
5179template<typename InputIterator>
5181 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5182 bool Uneval) {
5183 for (TemplateArgumentLoc In : llvm::make_range(First, Last)) {
5185 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5186 // Unpack argument packs, which we translate them into separate
5187 // arguments.
5188 // FIXME: We could do much better if we could guarantee that the
5189 // TemplateArgumentLocInfo for the pack expansion would be usable for
5190 // all of the template arguments in the argument pack.
5191 typedef TemplateArgumentLocInventIterator<Derived,
5193 PackLocIterator;
5194
5195 TemplateArgumentListInfo *PackOutput = &Outputs;
5197
5199 PackLocIterator(*this, In.getArgument().pack_begin()),
5200 PackLocIterator(*this, In.getArgument().pack_end()), *PackOutput,
5201 Uneval))
5202 return true;
5203
5204 continue;
5205 }
5206
5207 if (In.getArgument().isPackExpansion()) {
5208 UnexpandedInfo Info;
5209 TemplateArgumentLoc Prepared;
5210 if (getDerived().PreparePackForExpansion(In, Uneval, Prepared, Info))
5211 return true;
5212 if (!Info.Expand) {
5213 Outputs.addArgument(Prepared);
5214 continue;
5215 }
5216
5217 // The transform has determined that we should perform an elementwise
5218 // expansion of the pattern. Do so.
5219 std::optional<ForgetSubstitutionRAII> ForgetSubst;
5221 ForgetSubst.emplace(getDerived());
5222 for (unsigned I = 0; I != *Info.NumExpansions; ++I) {
5223 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5224
5226 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5227 return true;
5228
5229 if (Out.getArgument().containsUnexpandedParameterPack()) {
5230 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5231 Info.OrigNumExpansions);
5232 if (Out.getArgument().isNull())
5233 return true;
5234 }
5235
5236 Outputs.addArgument(Out);
5237 }
5238
5239 // If we're supposed to retain a pack expansion, do so by temporarily
5240 // forgetting the partially-substituted parameter pack.
5241 if (Info.RetainExpansion) {
5242 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5243
5245 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5246 return true;
5247
5248 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5249 Info.OrigNumExpansions);
5250 if (Out.getArgument().isNull())
5251 return true;
5252
5253 Outputs.addArgument(Out);
5254 }
5255
5256 continue;
5257 }
5258
5259 // The simple case:
5260 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5261 return true;
5262
5263 Outputs.addArgument(Out);
5264 }
5265
5266 return false;
5267}
5268
5269template <typename Derived>
5270template <typename InputIterator>
5272 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5273 bool Uneval) {
5274
5275 // [C++26][temp.constr.normal]
5276 // any non-dependent concept template argument
5277 // is substituted into the constraint-expression of C.
5278 auto isNonDependentConceptArgument = [](const TemplateArgument &Arg) {
5279 return !Arg.isDependent() && Arg.isConceptOrConceptTemplateParameter();
5280 };
5281
5282 for (; First != Last; ++First) {
5285
5286 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5287 typedef TemplateArgumentLocInventIterator<Derived,
5289 PackLocIterator;
5291 PackLocIterator(*this, In.getArgument().pack_begin()),
5292 PackLocIterator(*this, In.getArgument().pack_end()), Outputs,
5293 Uneval))
5294 return true;
5295 continue;
5296 }
5297
5298 if (!isNonDependentConceptArgument(In.getArgument())) {
5299 Outputs.addArgument(In);
5300 continue;
5301 }
5302
5303 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5304 return true;
5305
5306 Outputs.addArgument(Out);
5307 }
5308
5309 return false;
5310}
5311
5312// FIXME: Find ways to reduce code duplication for pack expansions.
5313template <typename Derived>
5315 bool Uneval,
5317 UnexpandedInfo &Info) {
5318 auto ComputeInfo = [this](TemplateArgumentLoc Arg,
5319 bool IsLateExpansionAttempt, UnexpandedInfo &Info,
5320 TemplateArgumentLoc &Pattern) {
5321 assert(Arg.getArgument().isPackExpansion());
5322 // We have a pack expansion, for which we will be substituting into the
5323 // pattern.
5324 Pattern = getSema().getTemplateArgumentPackExpansionPattern(
5325 Arg, Info.Ellipsis, Info.OrigNumExpansions);
5327 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5328 if (IsLateExpansionAttempt) {
5329 // Request expansion only when there is an opportunity to expand a pack
5330 // that required a substituion first.
5331 bool SawPackTypes =
5332 llvm::any_of(Unexpanded, [](UnexpandedParameterPack P) {
5333 return P.first.dyn_cast<const SubstBuiltinTemplatePackType *>();
5334 });
5335 if (!SawPackTypes) {
5336 Info.Expand = false;
5337 return false;
5338 }
5339 }
5340 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5341
5342 // Determine whether the set of unexpanded parameter packs can and
5343 // should be expanded.
5344 Info.Expand = true;
5345 Info.RetainExpansion = false;
5346 Info.NumExpansions = Info.OrigNumExpansions;
5347 return getDerived().TryExpandParameterPacks(
5348 Info.Ellipsis, Pattern.getSourceRange(), Unexpanded,
5349 /*FailOnPackProducingTemplates=*/false, Info.Expand,
5350 Info.RetainExpansion, Info.NumExpansions);
5351 };
5352
5353 TemplateArgumentLoc Pattern;
5354 if (ComputeInfo(In, false, Info, Pattern))
5355 return true;
5356
5357 if (Info.Expand) {
5358 Out = Pattern;
5359 return false;
5360 }
5361
5362 // The transform has determined that we should perform a simple
5363 // transformation on the pack expansion, producing another pack
5364 // expansion.
5365 TemplateArgumentLoc OutPattern;
5366 std::optional<Sema::ArgPackSubstIndexRAII> SubstIndex(
5367 std::in_place, getSema(), std::nullopt);
5368 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5369 return true;
5370
5371 Out = getDerived().RebuildPackExpansion(OutPattern, Info.Ellipsis,
5372 Info.NumExpansions);
5373 if (Out.getArgument().isNull())
5374 return true;
5375 SubstIndex.reset();
5376
5377 if (!OutPattern.getArgument().containsUnexpandedParameterPack())
5378 return false;
5379
5380 // Some packs will learn their length after substitution, e.g.
5381 // __builtin_dedup_pack<T,int> has size 1 or 2, depending on the substitution
5382 // value of `T`.
5383 //
5384 // We only expand after we know sizes of all packs, check if this is the case
5385 // or not. However, we avoid a full template substitution and only do
5386 // expanstions after this point.
5387
5388 // E.g. when substituting template arguments of tuple with {T -> int} in the
5389 // following example:
5390 // template <class T>
5391 // struct TupleWithInt {
5392 // using type = std::tuple<__builtin_dedup_pack<T, int>...>;
5393 // };
5394 // TupleWithInt<int>::type y;
5395 // At this point we will see the `__builtin_dedup_pack<int, int>` with a known
5396 // length and run `ComputeInfo()` to provide the necessary information to our
5397 // caller.
5398 //
5399 // Note that we may still have situations where builtin is not going to be
5400 // expanded. For example:
5401 // template <class T>
5402 // struct Foo {
5403 // template <class U> using tuple_with_t =
5404 // std::tuple<__builtin_dedup_pack<T, U, int>...>; using type =
5405 // tuple_with_t<short>;
5406 // }
5407 // Because the substitution into `type` happens in dependent context, `type`
5408 // will be `tuple<builtin_dedup_pack<T, short, int>...>` after substitution
5409 // and the caller will not be able to expand it.
5410 ForgetSubstitutionRAII ForgetSubst(getDerived());
5411 if (ComputeInfo(Out, true, Info, OutPattern))
5412 return true;
5413 if (!Info.Expand)
5414 return false;
5415 Out = OutPattern;
5416 Info.ExpandUnderForgetSubstitions = true;
5417 return false;
5418}
5419
5420//===----------------------------------------------------------------------===//
5421// Type transformation
5422//===----------------------------------------------------------------------===//
5423
5424template<typename Derived>
5427 return T;
5428
5429 // Temporary workaround. All of these transformations should
5430 // eventually turn into transformations on TypeLocs.
5431 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5433
5434 TypeSourceInfo *NewTSI = getDerived().TransformType(TSI);
5435
5436 if (!NewTSI)
5437 return QualType();
5438
5439 return NewTSI->getType();
5440}
5441
5442template <typename Derived>
5444 // Refine the base location to the type's location.
5445 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5448 return TSI;
5449
5450 TypeLocBuilder TLB;
5451
5452 TypeLoc TL = TSI->getTypeLoc();
5453 TLB.reserve(TL.getFullDataSize());
5454
5455 QualType Result = getDerived().TransformType(TLB, TL);
5456 if (Result.isNull())
5457 return nullptr;
5458
5459 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5460}
5461
5462template<typename Derived>
5465 switch (T.getTypeLocClass()) {
5466#define ABSTRACT_TYPELOC(CLASS, PARENT)
5467#define TYPELOC(CLASS, PARENT) \
5468 case TypeLoc::CLASS: \
5469 return getDerived().Transform##CLASS##Type(TLB, \
5470 T.castAs<CLASS##TypeLoc>());
5471#include "clang/AST/TypeLocNodes.def"
5472 }
5473
5474 llvm_unreachable("unhandled type loc!");
5475}
5476
5477template<typename Derived>
5479 if (!isa<DependentNameType>(T))
5480 return TransformType(T);
5481
5483 return T;
5484 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5486 TypeSourceInfo *NewTSI = getDerived().TransformTypeWithDeducedTST(TSI);
5487 return NewTSI ? NewTSI->getType() : QualType();
5488}
5489
5490template <typename Derived>
5493 if (!isa<DependentNameType>(TSI->getType()))
5494 return TransformType(TSI);
5495
5496 // Refine the base location to the type's location.
5497 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5500 return TSI;
5501
5502 TypeLocBuilder TLB;
5503
5504 TypeLoc TL = TSI->getTypeLoc();
5505 TLB.reserve(TL.getFullDataSize());
5506
5507 auto QTL = TL.getAs<QualifiedTypeLoc>();
5508 if (QTL)
5509 TL = QTL.getUnqualifiedLoc();
5510
5511 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5512
5513 QualType Result = getDerived().TransformDependentNameType(
5514 TLB, DNTL, /*DeducedTSTContext*/true);
5515 if (Result.isNull())
5516 return nullptr;
5517
5518 if (QTL) {
5519 Result = getDerived().RebuildQualifiedType(Result, QTL);
5520 if (Result.isNull())
5521 return nullptr;
5523 }
5524
5525 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5526}
5527
5528template<typename Derived>
5531 QualifiedTypeLoc T) {
5533 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5534 auto SuppressObjCLifetime =
5536 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5537 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5538 SuppressObjCLifetime);
5539 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5540 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5541 TLB, STTP, SuppressObjCLifetime);
5542 } else {
5543 Result = getDerived().TransformType(TLB, UnqualTL);
5544 }
5545
5546 if (Result.isNull())
5547 return QualType();
5548
5549 Result = getDerived().RebuildQualifiedType(Result, T);
5550
5551 if (Result.isNull())
5552 return QualType();
5553
5554 // RebuildQualifiedType might have updated the type, but not in a way
5555 // that invalidates the TypeLoc. (There's no location information for
5556 // qualifiers.)
5558
5559 return Result;
5560}
5561
5562template <typename Derived>
5564 QualifiedTypeLoc TL) {
5565
5566 SourceLocation Loc = TL.getBeginLoc();
5567 Qualifiers Quals = TL.getType().getLocalQualifiers();
5568
5569 if ((T.getAddressSpace() != LangAS::Default &&
5570 Quals.getAddressSpace() != LangAS::Default) &&
5571 T.getAddressSpace() != Quals.getAddressSpace()) {
5572 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5573 << TL.getType() << T;
5574 return QualType();
5575 }
5576
5577 PointerAuthQualifier LocalPointerAuth = Quals.getPointerAuth();
5578 if (LocalPointerAuth.isPresent()) {
5579 if (T.getPointerAuth().isPresent()) {
5580 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_redundant) << TL.getType();
5581 return QualType();
5582 }
5583 if (!T->isDependentType()) {
5584 if (!T->isSignableType(SemaRef.getASTContext())) {
5585 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_invalid_target) << T;
5586 return QualType();
5587 }
5588 }
5589 }
5590 // C++ [dcl.fct]p7:
5591 // [When] adding cv-qualifications on top of the function type [...] the
5592 // cv-qualifiers are ignored.
5593 if (T->isFunctionType()) {
5594 T = SemaRef.getASTContext().getAddrSpaceQualType(T,
5595 Quals.getAddressSpace());
5596 return T;
5597 }
5598
5599 // C++ [dcl.ref]p1:
5600 // when the cv-qualifiers are introduced through the use of a typedef-name
5601 // or decltype-specifier [...] the cv-qualifiers are ignored.
5602 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5603 // applied to a reference type.
5604 if (T->isReferenceType()) {
5605 // The only qualifier that applies to a reference type is restrict.
5606 if (!Quals.hasRestrict())
5607 return T;
5609 }
5610
5611 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5612 // resulting type.
5613 if (Quals.hasObjCLifetime()) {
5614 if (!T->isObjCLifetimeType() && !T->isDependentType())
5615 Quals.removeObjCLifetime();
5616 else if (T.getObjCLifetime()) {
5617 // Objective-C ARC:
5618 // A lifetime qualifier applied to a substituted template parameter
5619 // overrides the lifetime qualifier from the template argument.
5620 const AutoType *AutoTy;
5621 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5622 // 'auto' types behave the same way as template parameters.
5623 QualType Deduced = AutoTy->getDeducedType();
5624 Qualifiers Qs = Deduced.getQualifiers();
5625 Qs.removeObjCLifetime();
5626 Deduced =
5627 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5628 T = SemaRef.Context.getAutoType(AutoTy->getDeducedKind(), Deduced,
5629 AutoTy->getKeyword(),
5630 AutoTy->getTypeConstraintConcept(),
5631 AutoTy->getTypeConstraintArguments());
5632 } else {
5633 // Otherwise, complain about the addition of a qualifier to an
5634 // already-qualified type.
5635 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5636 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5637 Quals.removeObjCLifetime();
5638 }
5639 }
5640 }
5641
5642 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5643}
5644
5645template <typename Derived>
5646QualType TreeTransform<Derived>::TransformTypeInObjectScope(
5647 TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType,
5648 NamedDecl *FirstQualifierInScope) {
5649 assert(!getDerived().AlreadyTransformed(TL.getType()));
5650
5651 switch (TL.getTypeLocClass()) {
5652 case TypeLoc::TemplateSpecialization:
5653 return getDerived().TransformTemplateSpecializationType(
5654 TLB, TL.castAs<TemplateSpecializationTypeLoc>(), ObjectType,
5655 FirstQualifierInScope, /*AllowInjectedClassName=*/true);
5656 case TypeLoc::DependentName:
5657 return getDerived().TransformDependentNameType(
5658 TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
5659 ObjectType, FirstQualifierInScope);
5660 default:
5661 // Any dependent canonical type can appear here, through type alias
5662 // templates.
5663 return getDerived().TransformType(TLB, TL);
5664 }
5665}
5666
5667template <class TyLoc> static inline
5669 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5670 NewT.setNameLoc(T.getNameLoc());
5671 return T.getType();
5672}
5673
5674template<typename Derived>
5675QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5676 BuiltinTypeLoc T) {
5677 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5678 NewT.setBuiltinLoc(T.getBuiltinLoc());
5679 if (T.needsExtraLocalData())
5680 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5681 return T.getType();
5682}
5683
5684template<typename Derived>
5686 ComplexTypeLoc T) {
5687 // FIXME: recurse?
5688 return TransformTypeSpecType(TLB, T);
5689}
5690
5691template <typename Derived>
5693 AdjustedTypeLoc TL) {
5694 // Adjustments applied during transformation are handled elsewhere.
5695 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5696}
5697
5698template<typename Derived>
5700 DecayedTypeLoc TL) {
5701 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5702 if (OriginalType.isNull())
5703 return QualType();
5704
5705 QualType Result = TL.getType();
5706 if (getDerived().AlwaysRebuild() ||
5707 OriginalType != TL.getOriginalLoc().getType())
5708 Result = SemaRef.Context.getDecayedType(OriginalType);
5709 TLB.push<DecayedTypeLoc>(Result);
5710 // Nothing to set for DecayedTypeLoc.
5711 return Result;
5712}
5713
5714template <typename Derived>
5718 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5719 if (OriginalType.isNull())
5720 return QualType();
5721
5722 QualType Result = TL.getType();
5723 if (getDerived().AlwaysRebuild() ||
5724 OriginalType != TL.getElementLoc().getType())
5725 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5726 TLB.push<ArrayParameterTypeLoc>(Result);
5727 // Nothing to set for ArrayParameterTypeLoc.
5728 return Result;
5729}
5730
5731template<typename Derived>
5733 PointerTypeLoc TL) {
5734 QualType PointeeType
5735 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5736 if (PointeeType.isNull())
5737 return QualType();
5738
5739 QualType Result = TL.getType();
5740 if (PointeeType->getAs<ObjCObjectType>()) {
5741 // A dependent pointer type 'T *' has is being transformed such
5742 // that an Objective-C class type is being replaced for 'T'. The
5743 // resulting pointer type is an ObjCObjectPointerType, not a
5744 // PointerType.
5745 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5746
5748 NewT.setStarLoc(TL.getStarLoc());
5749 return Result;
5750 }
5751
5752 if (getDerived().AlwaysRebuild() ||
5753 PointeeType != TL.getPointeeLoc().getType()) {
5754 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5755 if (Result.isNull())
5756 return QualType();
5757 }
5758
5759 // Objective-C ARC can add lifetime qualifiers to the type that we're
5760 // pointing to.
5761 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5762
5763 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5764 NewT.setSigilLoc(TL.getSigilLoc());
5765 return Result;
5766}
5767
5768template<typename Derived>
5772 QualType PointeeType
5773 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5774 if (PointeeType.isNull())
5775 return QualType();
5776
5777 QualType Result = TL.getType();
5778 if (getDerived().AlwaysRebuild() ||
5779 PointeeType != TL.getPointeeLoc().getType()) {
5780 Result = getDerived().RebuildBlockPointerType(PointeeType,
5781 TL.getSigilLoc());
5782 if (Result.isNull())
5783 return QualType();
5784 }
5785
5787 NewT.setSigilLoc(TL.getSigilLoc());
5788 return Result;
5789}
5790
5791/// Transforms a reference type. Note that somewhat paradoxically we
5792/// don't care whether the type itself is an l-value type or an r-value
5793/// type; we only care if the type was *written* as an l-value type
5794/// or an r-value type.
5795template<typename Derived>
5798 ReferenceTypeLoc TL) {
5799 const ReferenceType *T = TL.getTypePtr();
5800
5801 // Note that this works with the pointee-as-written.
5802 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5803 if (PointeeType.isNull())
5804 return QualType();
5805
5806 QualType Result = TL.getType();
5807 if (getDerived().AlwaysRebuild() ||
5808 PointeeType != T->getPointeeTypeAsWritten()) {
5809 Result = getDerived().RebuildReferenceType(PointeeType,
5810 T->isSpelledAsLValue(),
5811 TL.getSigilLoc());
5812 if (Result.isNull())
5813 return QualType();
5814 }
5815
5816 // Objective-C ARC can add lifetime qualifiers to the type that we're
5817 // referring to.
5820
5821 // r-value references can be rebuilt as l-value references.
5822 ReferenceTypeLoc NewTL;
5824 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5825 else
5826 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5827 NewTL.setSigilLoc(TL.getSigilLoc());
5828
5829 return Result;
5830}
5831
5832template<typename Derived>
5836 return TransformReferenceType(TLB, TL);
5837}
5838
5839template<typename Derived>
5840QualType
5841TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5842 RValueReferenceTypeLoc TL) {
5843 return TransformReferenceType(TLB, TL);
5844}
5845
5846template<typename Derived>
5850 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5851 if (PointeeType.isNull())
5852 return QualType();
5853
5854 const MemberPointerType *T = TL.getTypePtr();
5855
5856 NestedNameSpecifierLoc OldQualifierLoc = TL.getQualifierLoc();
5857 NestedNameSpecifierLoc NewQualifierLoc =
5858 getDerived().TransformNestedNameSpecifierLoc(OldQualifierLoc);
5859 if (!NewQualifierLoc)
5860 return QualType();
5861
5862 CXXRecordDecl *OldCls = T->getMostRecentCXXRecordDecl(), *NewCls = nullptr;
5863 if (OldCls) {
5864 NewCls = cast_or_null<CXXRecordDecl>(
5865 getDerived().TransformDecl(TL.getStarLoc(), OldCls));
5866 if (!NewCls)
5867 return QualType();
5868 }
5869
5870 QualType Result = TL.getType();
5871 if (getDerived().AlwaysRebuild() || PointeeType != T->getPointeeType() ||
5872 NewQualifierLoc.getNestedNameSpecifier() !=
5873 OldQualifierLoc.getNestedNameSpecifier() ||
5874 NewCls != OldCls) {
5875 CXXScopeSpec SS;
5876 SS.Adopt(NewQualifierLoc);
5877 Result = getDerived().RebuildMemberPointerType(PointeeType, SS, NewCls,
5878 TL.getStarLoc());
5879 if (Result.isNull())
5880 return QualType();
5881 }
5882
5883 // If we had to adjust the pointee type when building a member pointer, make
5884 // sure to push TypeLoc info for it.
5885 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5886 if (MPT && PointeeType != MPT->getPointeeType()) {
5887 assert(isa<AdjustedType>(MPT->getPointeeType()));
5888 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5889 }
5890
5892 NewTL.setSigilLoc(TL.getSigilLoc());
5893 NewTL.setQualifierLoc(NewQualifierLoc);
5894
5895 return Result;
5896}
5897
5898template<typename Derived>
5902 const ConstantArrayType *T = TL.getTypePtr();
5903 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5904 if (ElementType.isNull())
5905 return QualType();
5906
5907 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5908 Expr *OldSize = TL.getSizeExpr();
5909 if (!OldSize)
5910 OldSize = const_cast<Expr*>(T->getSizeExpr());
5911 Expr *NewSize = nullptr;
5912 if (OldSize) {
5915 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5916 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5917 }
5918
5919 QualType Result = TL.getType();
5920 if (getDerived().AlwaysRebuild() ||
5921 ElementType != T->getElementType() ||
5922 (T->getSizeExpr() && NewSize != OldSize)) {
5923 Result = getDerived().RebuildConstantArrayType(ElementType,
5924 T->getSizeModifier(),
5925 T->getSize(), NewSize,
5926 T->getIndexTypeCVRQualifiers(),
5927 TL.getBracketsRange());
5928 if (Result.isNull())
5929 return QualType();
5930 }
5931
5932 // We might have either a ConstantArrayType or a VariableArrayType now:
5933 // a ConstantArrayType is allowed to have an element type which is a
5934 // VariableArrayType if the type is dependent. Fortunately, all array
5935 // types have the same location layout.
5936 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5937 NewTL.setLBracketLoc(TL.getLBracketLoc());
5938 NewTL.setRBracketLoc(TL.getRBracketLoc());
5939 NewTL.setSizeExpr(NewSize);
5940
5941 return Result;
5942}
5943
5944template<typename Derived>
5946 TypeLocBuilder &TLB,
5948 const IncompleteArrayType *T = TL.getTypePtr();
5949 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5950 if (ElementType.isNull())
5951 return QualType();
5952
5953 QualType Result = TL.getType();
5954 if (getDerived().AlwaysRebuild() ||
5955 ElementType != T->getElementType()) {
5956 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5957 T->getSizeModifier(),
5958 T->getIndexTypeCVRQualifiers(),
5959 TL.getBracketsRange());
5960 if (Result.isNull())
5961 return QualType();
5962 }
5963
5965 NewTL.setLBracketLoc(TL.getLBracketLoc());
5966 NewTL.setRBracketLoc(TL.getRBracketLoc());
5967 NewTL.setSizeExpr(nullptr);
5968
5969 return Result;
5970}
5971
5972template<typename Derived>
5976 const VariableArrayType *T = TL.getTypePtr();
5977 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5978 if (ElementType.isNull())
5979 return QualType();
5980
5981 ExprResult SizeResult;
5982 {
5985 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5986 }
5987 if (SizeResult.isInvalid())
5988 return QualType();
5989 SizeResult =
5990 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5991 if (SizeResult.isInvalid())
5992 return QualType();
5993
5994 Expr *Size = SizeResult.get();
5995
5996 QualType Result = TL.getType();
5997 if (getDerived().AlwaysRebuild() ||
5998 ElementType != T->getElementType() ||
5999 Size != T->getSizeExpr()) {
6000 Result = getDerived().RebuildVariableArrayType(ElementType,
6001 T->getSizeModifier(),
6002 Size,
6003 T->getIndexTypeCVRQualifiers(),
6004 TL.getBracketsRange());
6005 if (Result.isNull())
6006 return QualType();
6007 }
6008
6009 // We might have constant size array now, but fortunately it has the same
6010 // location layout.
6011 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6012 NewTL.setLBracketLoc(TL.getLBracketLoc());
6013 NewTL.setRBracketLoc(TL.getRBracketLoc());
6014 NewTL.setSizeExpr(Size);
6015
6016 return Result;
6017}
6018
6019template<typename Derived>
6023 const DependentSizedArrayType *T = TL.getTypePtr();
6024 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6025 if (ElementType.isNull())
6026 return QualType();
6027
6028 // Array bounds are constant expressions.
6031
6032 // If we have a VLA then it won't be a constant.
6033 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
6034
6035 // Prefer the expression from the TypeLoc; the other may have been uniqued.
6036 Expr *origSize = TL.getSizeExpr();
6037 if (!origSize) origSize = T->getSizeExpr();
6038
6039 ExprResult sizeResult
6040 = getDerived().TransformExpr(origSize);
6041 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
6042 if (sizeResult.isInvalid())
6043 return QualType();
6044
6045 Expr *size = sizeResult.get();
6046
6047 QualType Result = TL.getType();
6048 if (getDerived().AlwaysRebuild() ||
6049 ElementType != T->getElementType() ||
6050 size != origSize) {
6051 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
6052 T->getSizeModifier(),
6053 size,
6054 T->getIndexTypeCVRQualifiers(),
6055 TL.getBracketsRange());
6056 if (Result.isNull())
6057 return QualType();
6058 }
6059
6060 // We might have any sort of array type now, but fortunately they
6061 // all have the same location layout.
6062 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6063 NewTL.setLBracketLoc(TL.getLBracketLoc());
6064 NewTL.setRBracketLoc(TL.getRBracketLoc());
6065 NewTL.setSizeExpr(size);
6066
6067 return Result;
6068}
6069
6070template <typename Derived>
6073 const DependentVectorType *T = TL.getTypePtr();
6074 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6075 if (ElementType.isNull())
6076 return QualType();
6077
6080
6081 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6082 Size = SemaRef.ActOnConstantExpression(Size);
6083 if (Size.isInvalid())
6084 return QualType();
6085
6086 QualType Result = TL.getType();
6087 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6088 Size.get() != T->getSizeExpr()) {
6089 Result = getDerived().RebuildDependentVectorType(
6090 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
6091 if (Result.isNull())
6092 return QualType();
6093 }
6094
6095 // Result might be dependent or not.
6098 TLB.push<DependentVectorTypeLoc>(Result);
6099 NewTL.setNameLoc(TL.getNameLoc());
6100 } else {
6101 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6102 NewTL.setNameLoc(TL.getNameLoc());
6103 }
6104
6105 return Result;
6106}
6107
6108template<typename Derived>
6110 TypeLocBuilder &TLB,
6112 const DependentSizedExtVectorType *T = TL.getTypePtr();
6113
6114 // FIXME: ext vector locs should be nested
6115 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6116 if (ElementType.isNull())
6117 return QualType();
6118
6119 // Vector sizes are constant expressions.
6122
6123 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6124 Size = SemaRef.ActOnConstantExpression(Size);
6125 if (Size.isInvalid())
6126 return QualType();
6127
6128 QualType Result = TL.getType();
6129 if (getDerived().AlwaysRebuild() ||
6130 ElementType != T->getElementType() ||
6131 Size.get() != T->getSizeExpr()) {
6132 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
6133 Size.get(),
6134 T->getAttributeLoc());
6135 if (Result.isNull())
6136 return QualType();
6137 }
6138
6139 // Result might be dependent or not.
6143 NewTL.setNameLoc(TL.getNameLoc());
6144 } else {
6145 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6146 NewTL.setNameLoc(TL.getNameLoc());
6147 }
6148
6149 return Result;
6150}
6151
6152template <typename Derived>
6156 const ConstantMatrixType *T = TL.getTypePtr();
6157 QualType ElementType = getDerived().TransformType(T->getElementType());
6158 if (ElementType.isNull())
6159 return QualType();
6160
6161 QualType Result = TL.getType();
6162 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
6163 Result = getDerived().RebuildConstantMatrixType(
6164 ElementType, T->getNumRows(), T->getNumColumns());
6165 if (Result.isNull())
6166 return QualType();
6167 }
6168
6170 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6171 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6172 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
6173 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
6174
6175 return Result;
6176}
6177
6178template <typename Derived>
6181 const DependentSizedMatrixType *T = TL.getTypePtr();
6182
6183 QualType ElementType = getDerived().TransformType(T->getElementType());
6184 if (ElementType.isNull()) {
6185 return QualType();
6186 }
6187
6188 // Matrix dimensions are constant expressions.
6191
6192 Expr *origRows = TL.getAttrRowOperand();
6193 if (!origRows)
6194 origRows = T->getRowExpr();
6195 Expr *origColumns = TL.getAttrColumnOperand();
6196 if (!origColumns)
6197 origColumns = T->getColumnExpr();
6198
6199 ExprResult rowResult = getDerived().TransformExpr(origRows);
6200 rowResult = SemaRef.ActOnConstantExpression(rowResult);
6201 if (rowResult.isInvalid())
6202 return QualType();
6203
6204 ExprResult columnResult = getDerived().TransformExpr(origColumns);
6205 columnResult = SemaRef.ActOnConstantExpression(columnResult);
6206 if (columnResult.isInvalid())
6207 return QualType();
6208
6209 Expr *rows = rowResult.get();
6210 Expr *columns = columnResult.get();
6211
6212 QualType Result = TL.getType();
6213 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6214 rows != origRows || columns != origColumns) {
6215 Result = getDerived().RebuildDependentSizedMatrixType(
6216 ElementType, rows, columns, T->getAttributeLoc());
6217
6218 if (Result.isNull())
6219 return QualType();
6220 }
6221
6222 // We might have any sort of matrix type now, but fortunately they
6223 // all have the same location layout.
6224 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
6225 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6226 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6227 NewTL.setAttrRowOperand(rows);
6228 NewTL.setAttrColumnOperand(columns);
6229 return Result;
6230}
6231
6232template <typename Derived>
6235 const DependentAddressSpaceType *T = TL.getTypePtr();
6236
6237 QualType pointeeType =
6238 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
6239
6240 if (pointeeType.isNull())
6241 return QualType();
6242
6243 // Address spaces are constant expressions.
6246
6247 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
6248 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
6249 if (AddrSpace.isInvalid())
6250 return QualType();
6251
6252 QualType Result = TL.getType();
6253 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
6254 AddrSpace.get() != T->getAddrSpaceExpr()) {
6255 Result = getDerived().RebuildDependentAddressSpaceType(
6256 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6257 if (Result.isNull())
6258 return QualType();
6259 }
6260
6261 // Result might be dependent or not.
6265
6266 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6267 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6268 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6269
6270 } else {
6271 TLB.TypeWasModifiedSafely(Result);
6272 }
6273
6274 return Result;
6275}
6276
6277template <typename Derived>
6279 VectorTypeLoc TL) {
6280 const VectorType *T = TL.getTypePtr();
6281 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6282 if (ElementType.isNull())
6283 return QualType();
6284
6285 QualType Result = TL.getType();
6286 if (getDerived().AlwaysRebuild() ||
6287 ElementType != T->getElementType()) {
6288 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6289 T->getVectorKind());
6290 if (Result.isNull())
6291 return QualType();
6292 }
6293
6294 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6295 NewTL.setNameLoc(TL.getNameLoc());
6296
6297 return Result;
6298}
6299
6300template<typename Derived>
6302 ExtVectorTypeLoc TL) {
6303 const VectorType *T = TL.getTypePtr();
6304 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6305 if (ElementType.isNull())
6306 return QualType();
6307
6308 QualType Result = TL.getType();
6309 if (getDerived().AlwaysRebuild() ||
6310 ElementType != T->getElementType()) {
6311 Result = getDerived().RebuildExtVectorType(ElementType,
6312 T->getNumElements(),
6313 /*FIXME*/ SourceLocation());
6314 if (Result.isNull())
6315 return QualType();
6316 }
6317
6318 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6319 NewTL.setNameLoc(TL.getNameLoc());
6320
6321 return Result;
6322}
6323
6324template <typename Derived>
6326 ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions,
6327 bool ExpectParameterPack) {
6328 TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
6329 TypeSourceInfo *NewTSI = nullptr;
6330
6331 if (NumExpansions && isa<PackExpansionType>(OldTSI->getType())) {
6332 // If we're substituting into a pack expansion type and we know the
6333 // length we want to expand to, just substitute for the pattern.
6334 TypeLoc OldTL = OldTSI->getTypeLoc();
6335 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6336
6337 TypeLocBuilder TLB;
6338 TypeLoc NewTL = OldTSI->getTypeLoc();
6339 TLB.reserve(NewTL.getFullDataSize());
6340
6341 QualType Result = getDerived().TransformType(TLB,
6342 OldExpansionTL.getPatternLoc());
6343 if (Result.isNull())
6344 return nullptr;
6345
6347 OldExpansionTL.getPatternLoc().getSourceRange(),
6348 OldExpansionTL.getEllipsisLoc(),
6349 NumExpansions);
6350 if (Result.isNull())
6351 return nullptr;
6352
6353 PackExpansionTypeLoc NewExpansionTL
6354 = TLB.push<PackExpansionTypeLoc>(Result);
6355 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6356 NewTSI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6357 } else
6358 NewTSI = getDerived().TransformType(OldTSI);
6359 if (!NewTSI)
6360 return nullptr;
6361
6362 if (NewTSI == OldTSI && indexAdjustment == 0)
6363 return OldParm;
6364
6366 SemaRef.Context, OldParm->getDeclContext(), OldParm->getInnerLocStart(),
6367 OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
6368 NewTSI, OldParm->getStorageClass(),
6369 /* DefArg */ nullptr);
6370 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6371 OldParm->getFunctionScopeIndex() + indexAdjustment);
6372 getDerived().transformedLocalDecl(OldParm, {newParm});
6373 return newParm;
6374}
6375
6376template <typename Derived>
6379 const QualType *ParamTypes,
6380 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6381 SmallVectorImpl<QualType> &OutParamTypes,
6384 unsigned *LastParamTransformed) {
6385 int indexAdjustment = 0;
6386
6387 unsigned NumParams = Params.size();
6388 for (unsigned i = 0; i != NumParams; ++i) {
6389 if (LastParamTransformed)
6390 *LastParamTransformed = i;
6391 if (ParmVarDecl *OldParm = Params[i]) {
6392 assert(OldParm->getFunctionScopeIndex() == i);
6393
6394 UnsignedOrNone NumExpansions = std::nullopt;
6395 ParmVarDecl *NewParm = nullptr;
6396 if (OldParm->isParameterPack()) {
6397 // We have a function parameter pack that may need to be expanded.
6399
6400 // Find the parameter packs that could be expanded.
6401 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6403 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6404 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6405
6406 // Determine whether we should expand the parameter packs.
6407 bool ShouldExpand = false;
6408 bool RetainExpansion = false;
6409 UnsignedOrNone OrigNumExpansions = std::nullopt;
6410 if (Unexpanded.size() > 0) {
6411 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6412 NumExpansions = OrigNumExpansions;
6414 ExpansionTL.getEllipsisLoc(), Pattern.getSourceRange(),
6415 Unexpanded, /*FailOnPackProducingTemplates=*/true,
6416 ShouldExpand, RetainExpansion, NumExpansions)) {
6417 return true;
6418 }
6419 } else {
6420#ifndef NDEBUG
6421 const AutoType *AT =
6422 Pattern.getType().getTypePtr()->getContainedAutoType();
6423 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6424 "Could not find parameter packs or undeduced auto type!");
6425#endif
6426 }
6427
6428 if (ShouldExpand) {
6429 // Expand the function parameter pack into multiple, separate
6430 // parameters.
6431 getDerived().ExpandingFunctionParameterPack(OldParm);
6432 for (unsigned I = 0; I != *NumExpansions; ++I) {
6433 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6434 ParmVarDecl *NewParm
6435 = getDerived().TransformFunctionTypeParam(OldParm,
6436 indexAdjustment++,
6437 OrigNumExpansions,
6438 /*ExpectParameterPack=*/false);
6439 if (!NewParm)
6440 return true;
6441
6442 if (ParamInfos)
6443 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6444 OutParamTypes.push_back(NewParm->getType());
6445 if (PVars)
6446 PVars->push_back(NewParm);
6447 }
6448
6449 // If we're supposed to retain a pack expansion, do so by temporarily
6450 // forgetting the partially-substituted parameter pack.
6451 if (RetainExpansion) {
6452 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6453 ParmVarDecl *NewParm
6454 = getDerived().TransformFunctionTypeParam(OldParm,
6455 indexAdjustment++,
6456 OrigNumExpansions,
6457 /*ExpectParameterPack=*/false);
6458 if (!NewParm)
6459 return true;
6460
6461 if (ParamInfos)
6462 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6463 OutParamTypes.push_back(NewParm->getType());
6464 if (PVars)
6465 PVars->push_back(NewParm);
6466 }
6467
6468 // The next parameter should have the same adjustment as the
6469 // last thing we pushed, but we post-incremented indexAdjustment
6470 // on every push. Also, if we push nothing, the adjustment should
6471 // go down by one.
6472 indexAdjustment--;
6473
6474 // We're done with the pack expansion.
6475 continue;
6476 }
6477
6478 // We'll substitute the parameter now without expanding the pack
6479 // expansion.
6480 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6481 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6482 indexAdjustment,
6483 NumExpansions,
6484 /*ExpectParameterPack=*/true);
6485 assert(NewParm->isParameterPack() &&
6486 "Parameter pack no longer a parameter pack after "
6487 "transformation.");
6488 } else {
6489 NewParm = getDerived().TransformFunctionTypeParam(
6490 OldParm, indexAdjustment, std::nullopt,
6491 /*ExpectParameterPack=*/false);
6492 }
6493
6494 if (!NewParm)
6495 return true;
6496
6497 if (ParamInfos)
6498 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6499 OutParamTypes.push_back(NewParm->getType());
6500 if (PVars)
6501 PVars->push_back(NewParm);
6502 continue;
6503 }
6504
6505 // Deal with the possibility that we don't have a parameter
6506 // declaration for this parameter.
6507 assert(ParamTypes);
6508 QualType OldType = ParamTypes[i];
6509 bool IsPackExpansion = false;
6510 UnsignedOrNone NumExpansions = std::nullopt;
6511 QualType NewType;
6512 if (const PackExpansionType *Expansion
6513 = dyn_cast<PackExpansionType>(OldType)) {
6514 // We have a function parameter pack that may need to be expanded.
6515 QualType Pattern = Expansion->getPattern();
6517 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6518
6519 // Determine whether we should expand the parameter packs.
6520 bool ShouldExpand = false;
6521 bool RetainExpansion = false;
6523 Loc, SourceRange(), Unexpanded,
6524 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
6525 RetainExpansion, NumExpansions)) {
6526 return true;
6527 }
6528
6529 if (ShouldExpand) {
6530 // Expand the function parameter pack into multiple, separate
6531 // parameters.
6532 for (unsigned I = 0; I != *NumExpansions; ++I) {
6533 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6534 QualType NewType = getDerived().TransformType(Pattern);
6535 if (NewType.isNull())
6536 return true;
6537
6538 if (NewType->containsUnexpandedParameterPack()) {
6539 NewType = getSema().getASTContext().getPackExpansionType(
6540 NewType, std::nullopt);
6541
6542 if (NewType.isNull())
6543 return true;
6544 }
6545
6546 if (ParamInfos)
6547 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6548 OutParamTypes.push_back(NewType);
6549 if (PVars)
6550 PVars->push_back(nullptr);
6551 }
6552
6553 // We're done with the pack expansion.
6554 continue;
6555 }
6556
6557 // If we're supposed to retain a pack expansion, do so by temporarily
6558 // forgetting the partially-substituted parameter pack.
6559 if (RetainExpansion) {
6560 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6561 QualType NewType = getDerived().TransformType(Pattern);
6562 if (NewType.isNull())
6563 return true;
6564
6565 if (ParamInfos)
6566 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6567 OutParamTypes.push_back(NewType);
6568 if (PVars)
6569 PVars->push_back(nullptr);
6570 }
6571
6572 // We'll substitute the parameter now without expanding the pack
6573 // expansion.
6574 OldType = Expansion->getPattern();
6575 IsPackExpansion = true;
6576 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6577 NewType = getDerived().TransformType(OldType);
6578 } else {
6579 NewType = getDerived().TransformType(OldType);
6580 }
6581
6582 if (NewType.isNull())
6583 return true;
6584
6585 if (IsPackExpansion)
6586 NewType = getSema().Context.getPackExpansionType(NewType,
6587 NumExpansions);
6588
6589 if (ParamInfos)
6590 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6591 OutParamTypes.push_back(NewType);
6592 if (PVars)
6593 PVars->push_back(nullptr);
6594 }
6595
6596#ifndef NDEBUG
6597 if (PVars) {
6598 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6599 if (ParmVarDecl *parm = (*PVars)[i])
6600 assert(parm->getFunctionScopeIndex() == i);
6601 }
6602#endif
6603
6604 return false;
6605}
6606
6607template<typename Derived>
6611 SmallVector<QualType, 4> ExceptionStorage;
6612 return getDerived().TransformFunctionProtoType(
6613 TLB, TL, nullptr, Qualifiers(),
6614 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6615 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6616 ExceptionStorage, Changed);
6617 });
6618}
6619
6620template<typename Derived> template<typename Fn>
6622 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6623 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6624
6625 // Transform the parameters and return type.
6626 //
6627 // We are required to instantiate the params and return type in source order.
6628 // When the function has a trailing return type, we instantiate the
6629 // parameters before the return type, since the return type can then refer
6630 // to the parameters themselves (via decltype, sizeof, etc.).
6631 //
6632 SmallVector<QualType, 4> ParamTypes;
6634 Sema::ExtParameterInfoBuilder ExtParamInfos;
6635 const FunctionProtoType *T = TL.getTypePtr();
6636
6637 QualType ResultType;
6638
6639 if (T->hasTrailingReturn()) {
6641 TL.getBeginLoc(), TL.getParams(),
6643 T->getExtParameterInfosOrNull(),
6644 ParamTypes, &ParamDecls, ExtParamInfos))
6645 return QualType();
6646
6647 {
6648 // C++11 [expr.prim.general]p3:
6649 // If a declaration declares a member function or member function
6650 // template of a class X, the expression this is a prvalue of type
6651 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6652 // and the end of the function-definition, member-declarator, or
6653 // declarator.
6654 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6655 Sema::CXXThisScopeRAII ThisScope(
6656 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6657
6658 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6659 if (ResultType.isNull())
6660 return QualType();
6661 }
6662 }
6663 else {
6664 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6665 if (ResultType.isNull())
6666 return QualType();
6667
6669 TL.getBeginLoc(), TL.getParams(),
6671 T->getExtParameterInfosOrNull(),
6672 ParamTypes, &ParamDecls, ExtParamInfos))
6673 return QualType();
6674 }
6675
6676 FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
6677
6678 bool EPIChanged = false;
6679 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6680 return QualType();
6681
6682 // Handle extended parameter information.
6683 if (auto NewExtParamInfos =
6684 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6685 if (!EPI.ExtParameterInfos ||
6687 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6688 EPIChanged = true;
6689 }
6690 EPI.ExtParameterInfos = NewExtParamInfos;
6691 } else if (EPI.ExtParameterInfos) {
6692 EPIChanged = true;
6693 EPI.ExtParameterInfos = nullptr;
6694 }
6695
6696 // Transform any function effects with unevaluated conditions.
6697 // Hold this set in a local for the rest of this function, since EPI
6698 // may need to hold a FunctionEffectsRef pointing into it.
6699 std::optional<FunctionEffectSet> NewFX;
6700 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6701 NewFX.emplace();
6704
6705 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6706 FunctionEffectWithCondition NewEC = PrevEC;
6707 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6708 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6709 if (NewExpr.isInvalid())
6710 return QualType();
6711 std::optional<FunctionEffectMode> Mode =
6712 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6713 if (!Mode)
6714 return QualType();
6715
6716 // The condition expression has been transformed, and re-evaluated.
6717 // It may or may not have become constant.
6718 switch (*Mode) {
6720 NewEC.Cond = {};
6721 break;
6723 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6724 NewEC.Cond = {};
6725 break;
6727 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6728 break;
6730 llvm_unreachable(
6731 "FunctionEffectMode::None shouldn't be possible here");
6732 }
6733 }
6734 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6735 TL.getBeginLoc())) {
6737 NewFX->insert(NewEC, Errs);
6738 assert(Errs.empty());
6739 }
6740 }
6741 EPI.FunctionEffects = *NewFX;
6742 EPIChanged = true;
6743 }
6744
6745 QualType Result = TL.getType();
6746 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6747 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6748 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6749 if (Result.isNull())
6750 return QualType();
6751 }
6752
6755 NewTL.setLParenLoc(TL.getLParenLoc());
6756 NewTL.setRParenLoc(TL.getRParenLoc());
6759 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6760 NewTL.setParam(i, ParamDecls[i]);
6761
6762 return Result;
6763}
6764
6765template<typename Derived>
6768 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6769 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6770
6771 // Instantiate a dynamic noexcept expression, if any.
6772 if (isComputedNoexcept(ESI.Type)) {
6773 // Update this scrope because ContextDecl in Sema will be used in
6774 // TransformExpr.
6775 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6776 Sema::CXXThisScopeRAII ThisScope(
6777 SemaRef, Method ? Method->getParent() : nullptr,
6778 Method ? Method->getMethodQualifiers() : Qualifiers{},
6779 Method != nullptr);
6782 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6783 if (NoexceptExpr.isInvalid())
6784 return true;
6785
6787 NoexceptExpr =
6788 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6789 if (NoexceptExpr.isInvalid())
6790 return true;
6791
6792 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6793 Changed = true;
6794 ESI.NoexceptExpr = NoexceptExpr.get();
6795 ESI.Type = EST;
6796 }
6797
6798 if (ESI.Type != EST_Dynamic)
6799 return false;
6800
6801 // Instantiate a dynamic exception specification's type.
6802 for (QualType T : ESI.Exceptions) {
6803 if (const PackExpansionType *PackExpansion =
6804 T->getAs<PackExpansionType>()) {
6805 Changed = true;
6806
6807 // We have a pack expansion. Instantiate it.
6809 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6810 Unexpanded);
6811 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6812
6813 // Determine whether the set of unexpanded parameter packs can and
6814 // should
6815 // be expanded.
6816 bool Expand = false;
6817 bool RetainExpansion = false;
6818 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
6819 // FIXME: Track the location of the ellipsis (and track source location
6820 // information for the types in the exception specification in general).
6822 Loc, SourceRange(), Unexpanded,
6823 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
6824 NumExpansions))
6825 return true;
6826
6827 if (!Expand) {
6828 // We can't expand this pack expansion into separate arguments yet;
6829 // just substitute into the pattern and create a new pack expansion
6830 // type.
6831 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6832 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6833 if (U.isNull())
6834 return true;
6835
6836 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6837 Exceptions.push_back(U);
6838 continue;
6839 }
6840
6841 // Substitute into the pack expansion pattern for each slice of the
6842 // pack.
6843 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6844 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
6845
6846 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6847 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6848 return true;
6849
6850 Exceptions.push_back(U);
6851 }
6852 } else {
6853 QualType U = getDerived().TransformType(T);
6854 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6855 return true;
6856 if (T != U)
6857 Changed = true;
6858
6859 Exceptions.push_back(U);
6860 }
6861 }
6862
6863 ESI.Exceptions = Exceptions;
6864 if (ESI.Exceptions.empty())
6865 ESI.Type = EST_DynamicNone;
6866 return false;
6867}
6868
6869template<typename Derived>
6871 TypeLocBuilder &TLB,
6873 const FunctionNoProtoType *T = TL.getTypePtr();
6874 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6875 if (ResultType.isNull())
6876 return QualType();
6877
6878 QualType Result = TL.getType();
6879 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6880 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6881
6884 NewTL.setLParenLoc(TL.getLParenLoc());
6885 NewTL.setRParenLoc(TL.getRParenLoc());
6887
6888 return Result;
6889}
6890
6891template <typename Derived>
6892QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6893 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6894
6895 const UnresolvedUsingType *T = TL.getTypePtr();
6896 bool Changed = false;
6897
6898 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6899 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6900 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6901 if (!QualifierLoc)
6902 return QualType();
6903 Changed |= QualifierLoc != OldQualifierLoc;
6904 }
6905
6906 auto *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6907 if (!D)
6908 return QualType();
6909 Changed |= D != T->getDecl();
6910
6911 QualType Result = TL.getType();
6912 if (getDerived().AlwaysRebuild() || Changed) {
6913 Result = getDerived().RebuildUnresolvedUsingType(
6914 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TL.getNameLoc(),
6915 D);
6916 if (Result.isNull())
6917 return QualType();
6918 }
6919
6921 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6922 QualifierLoc, TL.getNameLoc());
6923 else
6924 TLB.push<UnresolvedUsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6925 QualifierLoc, TL.getNameLoc());
6926 return Result;
6927}
6928
6929template <typename Derived>
6931 UsingTypeLoc TL) {
6932 const UsingType *T = TL.getTypePtr();
6933 bool Changed = false;
6934
6935 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6936 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6937 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6938 if (!QualifierLoc)
6939 return QualType();
6940 Changed |= QualifierLoc != OldQualifierLoc;
6941 }
6942
6943 auto *D = cast_or_null<UsingShadowDecl>(
6944 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6945 if (!D)
6946 return QualType();
6947 Changed |= D != T->getDecl();
6948
6949 QualType UnderlyingType = getDerived().TransformType(T->desugar());
6950 if (UnderlyingType.isNull())
6951 return QualType();
6952 Changed |= UnderlyingType != T->desugar();
6953
6954 QualType Result = TL.getType();
6955 if (getDerived().AlwaysRebuild() || Changed) {
6956 Result = getDerived().RebuildUsingType(
6957 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), D,
6958 UnderlyingType);
6959 if (Result.isNull())
6960 return QualType();
6961 }
6962 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(), QualifierLoc,
6963 TL.getNameLoc());
6964 return Result;
6965}
6966
6967template<typename Derived>
6969 TypedefTypeLoc TL) {
6970 const TypedefType *T = TL.getTypePtr();
6971 bool Changed = false;
6972
6973 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6974 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6975 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6976 if (!QualifierLoc)
6977 return QualType();
6978 Changed |= QualifierLoc != OldQualifierLoc;
6979 }
6980
6981 auto *Typedef = cast_or_null<TypedefNameDecl>(
6982 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6983 if (!Typedef)
6984 return QualType();
6985 Changed |= Typedef != T->getDecl();
6986
6987 // FIXME: Transform the UnderlyingType if different from decl.
6988
6989 QualType Result = TL.getType();
6990 if (getDerived().AlwaysRebuild() || Changed) {
6991 Result = getDerived().RebuildTypedefType(
6992 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), Typedef);
6993 if (Result.isNull())
6994 return QualType();
6995 }
6996
6997 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6998 QualifierLoc, TL.getNameLoc());
6999 return Result;
7000}
7001
7002template<typename Derived>
7004 TypeOfExprTypeLoc TL) {
7005 // typeof expressions are not potentially evaluated contexts
7009
7010 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
7011 if (E.isInvalid())
7012 return QualType();
7013
7014 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
7015 if (E.isInvalid())
7016 return QualType();
7017
7018 QualType Result = TL.getType();
7020 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
7021 Result =
7022 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
7023 if (Result.isNull())
7024 return QualType();
7025 }
7026
7027 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
7028 NewTL.setTypeofLoc(TL.getTypeofLoc());
7029 NewTL.setLParenLoc(TL.getLParenLoc());
7030 NewTL.setRParenLoc(TL.getRParenLoc());
7031
7032 return Result;
7033}
7034
7035template<typename Derived>
7037 TypeOfTypeLoc TL) {
7038 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
7039 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
7040 if (!New_Under_TI)
7041 return QualType();
7042
7043 QualType Result = TL.getType();
7044 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
7045 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
7046 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
7047 if (Result.isNull())
7048 return QualType();
7049 }
7050
7051 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
7052 NewTL.setTypeofLoc(TL.getTypeofLoc());
7053 NewTL.setLParenLoc(TL.getLParenLoc());
7054 NewTL.setRParenLoc(TL.getRParenLoc());
7055 NewTL.setUnmodifiedTInfo(New_Under_TI);
7056
7057 return Result;
7058}
7059
7060template<typename Derived>
7062 DecltypeTypeLoc TL) {
7063 const DecltypeType *T = TL.getTypePtr();
7064
7065 // decltype expressions are not potentially evaluated contexts
7069
7070 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
7071 if (E.isInvalid())
7072 return QualType();
7073
7074 E = getSema().ActOnDecltypeExpression(E.get());
7075 if (E.isInvalid())
7076 return QualType();
7077
7078 QualType Result = TL.getType();
7079 if (getDerived().AlwaysRebuild() ||
7080 E.get() != T->getUnderlyingExpr()) {
7081 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
7082 if (Result.isNull())
7083 return QualType();
7084 }
7085 else E.get();
7086
7087 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
7088 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
7089 NewTL.setRParenLoc(TL.getRParenLoc());
7090 return Result;
7091}
7092
7093template <typename Derived>
7097 // Transform the index
7098 ExprResult IndexExpr;
7099 {
7100 EnterExpressionEvaluationContext ConstantContext(
7102
7103 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
7104 if (IndexExpr.isInvalid())
7105 return QualType();
7106 }
7107 QualType Pattern = TL.getPattern();
7108
7109 const PackIndexingType *PIT = TL.getTypePtr();
7110 SmallVector<QualType, 5> SubtitutedTypes;
7111 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
7112
7113 bool NotYetExpanded = Types.empty();
7114 bool FullySubstituted = true;
7115
7116 if (Types.empty() && !PIT->expandsToEmptyPack())
7117 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
7118
7119 for (QualType T : Types) {
7120 if (!T->containsUnexpandedParameterPack()) {
7121 QualType Transformed = getDerived().TransformType(T);
7122 if (Transformed.isNull())
7123 return QualType();
7124 SubtitutedTypes.push_back(Transformed);
7125 continue;
7126 }
7127
7129 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
7130 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7131 // Determine whether the set of unexpanded parameter packs can and should
7132 // be expanded.
7133 bool ShouldExpand = true;
7134 bool RetainExpansion = false;
7135 UnsignedOrNone NumExpansions = std::nullopt;
7136 if (getDerived().TryExpandParameterPacks(
7137 TL.getEllipsisLoc(), SourceRange(), Unexpanded,
7138 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
7139 RetainExpansion, NumExpansions))
7140 return QualType();
7141 if (!ShouldExpand) {
7142 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7143 // FIXME: should we keep TypeLoc for individual expansions in
7144 // PackIndexingTypeLoc?
7145 TypeSourceInfo *TI =
7146 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
7147 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
7148 if (Pack.isNull())
7149 return QualType();
7150 if (NotYetExpanded) {
7151 FullySubstituted = false;
7152 QualType Out = getDerived().RebuildPackIndexingType(
7153 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7154 FullySubstituted);
7155 if (Out.isNull())
7156 return QualType();
7157
7159 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7160 return Out;
7161 }
7162 SubtitutedTypes.push_back(Pack);
7163 continue;
7164 }
7165 for (unsigned I = 0; I != *NumExpansions; ++I) {
7166 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
7167 QualType Out = getDerived().TransformType(T);
7168 if (Out.isNull())
7169 return QualType();
7170 SubtitutedTypes.push_back(Out);
7171 FullySubstituted &= !Out->containsUnexpandedParameterPack();
7172 }
7173 // If we're supposed to retain a pack expansion, do so by temporarily
7174 // forgetting the partially-substituted parameter pack.
7175 if (RetainExpansion) {
7176 FullySubstituted = false;
7177 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
7178 QualType Out = getDerived().TransformType(T);
7179 if (Out.isNull())
7180 return QualType();
7181 SubtitutedTypes.push_back(Out);
7182 }
7183 }
7184
7185 // A pack indexing type can appear in a larger pack expansion,
7186 // e.g. `Pack...[pack_of_indexes]...`
7187 // so we need to temporarily disable substitution of pack elements
7188 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7189 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
7190
7191 QualType Out = getDerived().RebuildPackIndexingType(
7192 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7193 FullySubstituted, SubtitutedTypes);
7194 if (Out.isNull())
7195 return Out;
7196
7198 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7199 return Out;
7200}
7201
7202template<typename Derived>
7204 TypeLocBuilder &TLB,
7206 QualType Result = TL.getType();
7207 TypeSourceInfo *NewBaseTSI = TL.getUnderlyingTInfo();
7208 if (Result->isDependentType()) {
7209 const UnaryTransformType *T = TL.getTypePtr();
7210
7211 NewBaseTSI = getDerived().TransformType(TL.getUnderlyingTInfo());
7212 if (!NewBaseTSI)
7213 return QualType();
7214 QualType NewBase = NewBaseTSI->getType();
7215
7216 Result = getDerived().RebuildUnaryTransformType(NewBase,
7217 T->getUTTKind(),
7218 TL.getKWLoc());
7219 if (Result.isNull())
7220 return QualType();
7221 }
7222
7224 NewTL.setKWLoc(TL.getKWLoc());
7225 NewTL.setParensRange(TL.getParensRange());
7226 NewTL.setUnderlyingTInfo(NewBaseTSI);
7227 return Result;
7228}
7229
7230template<typename Derived>
7233 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
7234
7235 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7236 TemplateName TemplateName = getDerived().TransformTemplateName(
7237 QualifierLoc, /*TemplateKELoc=*/SourceLocation(), T->getTemplateName(),
7238 TL.getTemplateNameLoc());
7239 if (TemplateName.isNull())
7240 return QualType();
7241
7242 QualType OldDeduced = T->getDeducedType();
7243 QualType NewDeduced;
7244 if (!OldDeduced.isNull()) {
7245 NewDeduced = getDerived().TransformType(OldDeduced);
7246 if (NewDeduced.isNull())
7247 return QualType();
7248 }
7249
7250 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
7251 NewDeduced.isNull() ? DeducedKind::Undeduced : DeducedKind::Deduced,
7252 NewDeduced, T->getKeyword(), TemplateName);
7253 if (Result.isNull())
7254 return QualType();
7255
7256 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7257 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7258 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7259 NewTL.setQualifierLoc(QualifierLoc);
7260 return Result;
7261}
7262
7263template <typename Derived>
7265 TagTypeLoc TL) {
7266 const TagType *T = TL.getTypePtr();
7267
7268 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7269 if (QualifierLoc) {
7270 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7271 if (!QualifierLoc)
7272 return QualType();
7273 }
7274
7275 auto *TD = cast_or_null<TagDecl>(
7276 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7277 if (!TD)
7278 return QualType();
7279
7280 QualType Result = TL.getType();
7281 if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() ||
7282 TD != T->getDecl()) {
7283 if (T->isCanonicalUnqualified())
7284 Result = getDerived().RebuildCanonicalTagType(TD);
7285 else
7286 Result = getDerived().RebuildTagType(
7287 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TD);
7288 if (Result.isNull())
7289 return QualType();
7290 }
7291
7292 TagTypeLoc NewTL = TLB.push<TagTypeLoc>(Result);
7294 NewTL.setQualifierLoc(QualifierLoc);
7295 NewTL.setNameLoc(TL.getNameLoc());
7296
7297 return Result;
7298}
7299
7300template <typename Derived>
7302 EnumTypeLoc TL) {
7303 return getDerived().TransformTagType(TLB, TL);
7304}
7305
7306template <typename Derived>
7307QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
7308 RecordTypeLoc TL) {
7309 return getDerived().TransformTagType(TLB, TL);
7310}
7311
7312template<typename Derived>
7314 TypeLocBuilder &TLB,
7316 return getDerived().TransformTagType(TLB, TL);
7317}
7318
7319template<typename Derived>
7321 TypeLocBuilder &TLB,
7323 return getDerived().TransformTemplateTypeParmType(
7324 TLB, TL,
7325 /*SuppressObjCLifetime=*/false);
7326}
7327
7328template <typename Derived>
7330 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7331 return TransformTypeSpecType(TLB, TL);
7332}
7333
7334template<typename Derived>
7335QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7336 TypeLocBuilder &TLB,
7337 SubstTemplateTypeParmTypeLoc TL) {
7338 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7339
7340 Decl *NewReplaced =
7341 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7342
7343 // Substitute into the replacement type, which itself might involve something
7344 // that needs to be transformed. This only tends to occur with default
7345 // template arguments of template template parameters.
7346 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7347 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7348 if (Replacement.isNull())
7349 return QualType();
7350
7351 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7352 Replacement, NewReplaced, T->getIndex(), T->getPackIndex(),
7353 T->getFinal());
7354
7355 // Propagate type-source information.
7356 SubstTemplateTypeParmTypeLoc NewTL
7357 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7358 NewTL.setNameLoc(TL.getNameLoc());
7359 return Result;
7360
7361}
7362template <typename Derived>
7365 return TransformTypeSpecType(TLB, TL);
7366}
7367
7368template<typename Derived>
7370 TypeLocBuilder &TLB,
7372 return getDerived().TransformSubstTemplateTypeParmPackType(
7373 TLB, TL, /*SuppressObjCLifetime=*/false);
7374}
7375
7376template <typename Derived>
7379 return TransformTypeSpecType(TLB, TL);
7380}
7381
7382template<typename Derived>
7383QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
7384 AtomicTypeLoc TL) {
7385 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7386 if (ValueType.isNull())
7387 return QualType();
7388
7389 QualType Result = TL.getType();
7390 if (getDerived().AlwaysRebuild() ||
7391 ValueType != TL.getValueLoc().getType()) {
7392 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7393 if (Result.isNull())
7394 return QualType();
7395 }
7396
7397 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7398 NewTL.setKWLoc(TL.getKWLoc());
7399 NewTL.setLParenLoc(TL.getLParenLoc());
7400 NewTL.setRParenLoc(TL.getRParenLoc());
7401
7402 return Result;
7403}
7404
7405template <typename Derived>
7407 PipeTypeLoc TL) {
7408 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7409 if (ValueType.isNull())
7410 return QualType();
7411
7412 QualType Result = TL.getType();
7413 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7414 const PipeType *PT = Result->castAs<PipeType>();
7415 bool isReadPipe = PT->isReadOnly();
7416 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7417 if (Result.isNull())
7418 return QualType();
7419 }
7420
7421 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7422 NewTL.setKWLoc(TL.getKWLoc());
7423
7424 return Result;
7425}
7426
7427template <typename Derived>
7429 BitIntTypeLoc TL) {
7430 const BitIntType *EIT = TL.getTypePtr();
7431 QualType Result = TL.getType();
7432
7433 if (getDerived().AlwaysRebuild()) {
7434 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7435 EIT->getNumBits(), TL.getNameLoc());
7436 if (Result.isNull())
7437 return QualType();
7438 }
7439
7440 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7441 NewTL.setNameLoc(TL.getNameLoc());
7442 return Result;
7443}
7444
7445template <typename Derived>
7448 const DependentBitIntType *EIT = TL.getTypePtr();
7449
7452 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7453 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7454
7455 if (BitsExpr.isInvalid())
7456 return QualType();
7457
7458 QualType Result = TL.getType();
7459
7460 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7461 Result = getDerived().RebuildDependentBitIntType(
7462 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7463
7464 if (Result.isNull())
7465 return QualType();
7466 }
7467
7470 NewTL.setNameLoc(TL.getNameLoc());
7471 } else {
7472 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7473 NewTL.setNameLoc(TL.getNameLoc());
7474 }
7475 return Result;
7476}
7477
7478template <typename Derived>
7481 llvm_unreachable("This type does not need to be transformed.");
7482}
7483
7484 /// Simple iterator that traverses the template arguments in a
7485 /// container that provides a \c getArgLoc() member function.
7486 ///
7487 /// This iterator is intended to be used with the iterator form of
7488 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7489 template<typename ArgLocContainer>
7491 ArgLocContainer *Container;
7492 unsigned Index;
7493
7494 public:
7497 typedef int difference_type;
7498 typedef std::input_iterator_tag iterator_category;
7499
7500 class pointer {
7502
7503 public:
7504 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7505
7507 return &Arg;
7508 }
7509 };
7510
7511
7513
7514 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7515 unsigned Index)
7516 : Container(&Container), Index(Index) { }
7517
7519 ++Index;
7520 return *this;
7521 }
7522
7525 ++(*this);
7526 return Old;
7527 }
7528
7530 return Container->getArgLoc(Index);
7531 }
7532
7534 return pointer(Container->getArgLoc(Index));
7535 }
7536
7539 return X.Container == Y.Container && X.Index == Y.Index;
7540 }
7541
7544 return !(X == Y);
7545 }
7546 };
7547
7548template<typename Derived>
7549QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7550 AutoTypeLoc TL) {
7551 const AutoType *T = TL.getTypePtr();
7552 QualType OldDeduced = T->getDeducedType();
7553 QualType NewDeduced;
7554 if (!OldDeduced.isNull()) {
7555 NewDeduced = getDerived().TransformType(OldDeduced);
7556 if (NewDeduced.isNull())
7557 return QualType();
7558 }
7559
7560 ConceptDecl *NewCD = nullptr;
7561 TemplateArgumentListInfo NewTemplateArgs;
7562 NestedNameSpecifierLoc NewNestedNameSpec;
7563 if (T->isConstrained()) {
7564 assert(TL.getConceptReference());
7565 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7566 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7567
7568 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7569 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7571 if (getDerived().TransformTemplateArguments(
7572 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7573 NewTemplateArgs))
7574 return QualType();
7575
7576 if (TL.getNestedNameSpecifierLoc()) {
7577 NewNestedNameSpec
7578 = getDerived().TransformNestedNameSpecifierLoc(
7579 TL.getNestedNameSpecifierLoc());
7580 if (!NewNestedNameSpec)
7581 return QualType();
7582 }
7583 }
7584
7585 QualType Result = TL.getType();
7586 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7587 T->isDependentType() || T->isConstrained()) {
7588 // FIXME: Maybe don't rebuild if all template arguments are the same.
7590 NewArgList.reserve(NewTemplateArgs.size());
7591 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7592 NewArgList.push_back(ArgLoc.getArgument());
7593 Result = getDerived().RebuildAutoType(
7594 NewDeduced.isNull() ? DeducedKind::Undeduced : DeducedKind::Deduced,
7595 NewDeduced, T->getKeyword(), NewCD, NewArgList);
7596 if (Result.isNull())
7597 return QualType();
7598 }
7599
7600 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7601 NewTL.setNameLoc(TL.getNameLoc());
7602 NewTL.setRParenLoc(TL.getRParenLoc());
7603 NewTL.setConceptReference(nullptr);
7604
7605 if (T->isConstrained()) {
7607 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7608 TL.getConceptNameLoc(),
7609 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7610 auto *CR = ConceptReference::Create(
7611 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7612 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7613 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7614 NewTL.setConceptReference(CR);
7615 }
7616
7617 return Result;
7618}
7619
7620template <typename Derived>
7623 return getDerived().TransformTemplateSpecializationType(
7624 TLB, TL, /*ObjectType=*/QualType(), /*FirstQualifierInScope=*/nullptr,
7625 /*AllowInjectedClassName=*/false);
7626}
7627
7628template <typename Derived>
7631 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
7632 const TemplateSpecializationType *T = TL.getTypePtr();
7633
7634 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7635 TemplateName Template = getDerived().TransformTemplateName(
7636 QualifierLoc, TL.getTemplateKeywordLoc(), T->getTemplateName(),
7637 TL.getTemplateNameLoc(), ObjectType, FirstQualifierInScope,
7638 AllowInjectedClassName);
7639 if (Template.isNull())
7640 return QualType();
7641
7642 TemplateArgumentListInfo NewTemplateArgs;
7643 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7644 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7646 ArgIterator;
7647 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7648 ArgIterator(TL, TL.getNumArgs()),
7649 NewTemplateArgs))
7650 return QualType();
7651
7652 // This needs to be rebuilt if either the arguments changed, or if the
7653 // original template changed. If the template changed, and even if the
7654 // arguments didn't change, these arguments might not correspond to their
7655 // respective parameters, therefore needing conversions.
7656 QualType Result = getDerived().RebuildTemplateSpecializationType(
7657 TL.getTypePtr()->getKeyword(), Template, TL.getTemplateNameLoc(),
7658 NewTemplateArgs);
7659
7660 if (!Result.isNull()) {
7662 TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getTemplateKeywordLoc(),
7663 TL.getTemplateNameLoc(), NewTemplateArgs);
7664 }
7665
7666 return Result;
7667}
7668
7669template <typename Derived>
7671 AttributedTypeLoc TL) {
7672 const AttributedType *oldType = TL.getTypePtr();
7673 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7674 if (modifiedType.isNull())
7675 return QualType();
7676
7677 // HLSL: re-validate matrix-layout markers after substitution. If the
7678 // post-substitution type is no longer a matrix, diagnose now.
7679 if (SemaRef.getLangOpts().HLSL &&
7681 oldType->getAttrKind(), modifiedType,
7682 TL.getAttr() ? TL.getAttr()->getLocation()
7683 : TL.getModifiedLoc().getBeginLoc()))
7684 return QualType();
7685
7686 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7687 const Attr *oldAttr = TL.getAttr();
7688 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7689 if (oldAttr && !newAttr)
7690 return QualType();
7691
7692 QualType result = TL.getType();
7693
7694 // FIXME: dependent operand expressions?
7695 if (getDerived().AlwaysRebuild() ||
7696 modifiedType != oldType->getModifiedType()) {
7697 // If the equivalent type is equal to the modified type, we don't want to
7698 // transform it as well because:
7699 //
7700 // 1. The transformation would yield the same result and is therefore
7701 // superfluous, and
7702 //
7703 // 2. Transforming the same type twice can cause problems, e.g. if it
7704 // is a FunctionProtoType, we may end up instantiating the function
7705 // parameters twice, which causes an assertion since the parameters
7706 // are already bound to their counterparts in the template for this
7707 // instantiation.
7708 //
7709 QualType equivalentType = modifiedType;
7710 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7711 TypeLocBuilder AuxiliaryTLB;
7712 AuxiliaryTLB.reserve(TL.getFullDataSize());
7713 equivalentType =
7714 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7715 if (equivalentType.isNull())
7716 return QualType();
7717 }
7718
7719 // Check whether we can add nullability; it is only represented as
7720 // type sugar, and therefore cannot be diagnosed in any other way.
7721 if (auto nullability = oldType->getImmediateNullability()) {
7722 if (!modifiedType->canHaveNullability()) {
7723 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7724 : TL.getModifiedLoc().getBeginLoc()),
7725 diag::err_nullability_nonpointer)
7726 << DiagNullabilityKind(*nullability, false) << modifiedType;
7727 return QualType();
7728 }
7729 }
7730
7731 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7732 modifiedType,
7733 equivalentType,
7734 TL.getAttr());
7735 }
7736
7737 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7738 newTL.setAttr(newAttr);
7739 return result;
7740}
7741
7742template <typename Derived>
7745 const CountAttributedType *OldTy = TL.getTypePtr();
7746 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7747 if (InnerTy.isNull())
7748 return QualType();
7749
7750 Expr *OldCount = TL.getCountExpr();
7751 Expr *NewCount = nullptr;
7752 if (OldCount) {
7753 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7754 if (CountResult.isInvalid())
7755 return QualType();
7756 NewCount = CountResult.get();
7757 }
7758
7759 QualType Result = TL.getType();
7760 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7761 OldCount != NewCount) {
7762 // Currently, CountAttributedType can only wrap incomplete array types.
7764 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7765 }
7766
7767 TLB.push<CountAttributedTypeLoc>(Result);
7768 return Result;
7769}
7770
7771template <typename Derived>
7774 // The BTFTagAttributedType is available for C only.
7775 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7776}
7777
7778template <typename Derived>
7781 const OverflowBehaviorType *OldTy = TL.getTypePtr();
7782 QualType InnerTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7783 if (InnerTy.isNull())
7784 return QualType();
7785
7786 QualType Result = TL.getType();
7787 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->getUnderlyingType()) {
7788 Result = SemaRef.Context.getOverflowBehaviorType(OldTy->getBehaviorKind(),
7789 InnerTy);
7790 if (Result.isNull())
7791 return QualType();
7792 }
7793
7795 NewTL.initializeLocal(SemaRef.Context, TL.getAttrLoc());
7796 return Result;
7797}
7798
7799template <typename Derived>
7802
7803 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7804
7805 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7806 if (WrappedTy.isNull())
7807 return QualType();
7808
7809 QualType ContainedTy = QualType();
7810 QualType OldContainedTy = oldType->getContainedType();
7811 TypeSourceInfo *ContainedTSI = nullptr;
7812 if (!OldContainedTy.isNull()) {
7813 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7814 if (!oldContainedTSI)
7815 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7816 OldContainedTy, SourceLocation());
7817 ContainedTSI = getDerived().TransformType(oldContainedTSI);
7818 if (!ContainedTSI)
7819 return QualType();
7820 ContainedTy = ContainedTSI->getType();
7821 }
7822
7823 QualType Result = TL.getType();
7824 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7825 ContainedTy != oldType->getContainedType()) {
7827 WrappedTy, ContainedTy, oldType->getAttrs());
7828 }
7829
7832 NewTL.setSourceRange(TL.getLocalSourceRange());
7833 NewTL.setContainedTypeSourceInfo(ContainedTSI);
7834 return Result;
7835}
7836
7837template <typename Derived>
7840 // No transformations needed.
7841 return TL.getType();
7842}
7843
7844template<typename Derived>
7847 ParenTypeLoc TL) {
7848 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7849 if (Inner.isNull())
7850 return QualType();
7851
7852 QualType Result = TL.getType();
7853 if (getDerived().AlwaysRebuild() ||
7854 Inner != TL.getInnerLoc().getType()) {
7855 Result = getDerived().RebuildParenType(Inner);
7856 if (Result.isNull())
7857 return QualType();
7858 }
7859
7860 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7861 NewTL.setLParenLoc(TL.getLParenLoc());
7862 NewTL.setRParenLoc(TL.getRParenLoc());
7863 return Result;
7864}
7865
7866template <typename Derived>
7870 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7871 if (Inner.isNull())
7872 return QualType();
7873
7874 QualType Result = TL.getType();
7875 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7876 Result =
7877 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7878 if (Result.isNull())
7879 return QualType();
7880 }
7881
7883 NewTL.setExpansionLoc(TL.getExpansionLoc());
7884 return Result;
7885}
7886
7887template<typename Derived>
7888QualType TreeTransform<Derived>::TransformDependentNameType(
7890 return TransformDependentNameType(TLB, TL, false);
7891}
7892
7893template <typename Derived>
7894QualType TreeTransform<Derived>::TransformDependentNameType(
7895 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext,
7896 QualType ObjectType, NamedDecl *UnqualLookup) {
7897 const DependentNameType *T = TL.getTypePtr();
7898
7899 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7900 if (QualifierLoc) {
7901 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
7902 QualifierLoc, ObjectType, UnqualLookup);
7903 if (!QualifierLoc)
7904 return QualType();
7905 } else {
7906 assert((ObjectType.isNull() && !UnqualLookup) &&
7907 "must be transformed by TransformNestedNameSpecifierLoc");
7908 }
7909
7911 = getDerived().RebuildDependentNameType(T->getKeyword(),
7912 TL.getElaboratedKeywordLoc(),
7913 QualifierLoc,
7914 T->getIdentifier(),
7915 TL.getNameLoc(),
7916 DeducedTSTContext);
7917 if (Result.isNull())
7918 return QualType();
7919
7920 if (isa<TagType>(Result)) {
7921 auto NewTL = TLB.push<TagTypeLoc>(Result);
7922 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7923 NewTL.setQualifierLoc(QualifierLoc);
7924 NewTL.setNameLoc(TL.getNameLoc());
7926 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7927 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7928 NewTL.setTemplateNameLoc(TL.getNameLoc());
7929 NewTL.setQualifierLoc(QualifierLoc);
7930 } else if (isa<TypedefType>(Result)) {
7931 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7932 QualifierLoc, TL.getNameLoc());
7933 } else if (isa<UnresolvedUsingType>(Result)) {
7934 auto NewTL = TLB.push<UnresolvedUsingTypeLoc>(Result);
7935 NewTL.set(TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getNameLoc());
7936 } else {
7937 auto NewTL = TLB.push<DependentNameTypeLoc>(Result);
7938 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7939 NewTL.setQualifierLoc(QualifierLoc);
7940 NewTL.setNameLoc(TL.getNameLoc());
7941 }
7942 return Result;
7943}
7944
7945template<typename Derived>
7948 QualType Pattern
7949 = getDerived().TransformType(TLB, TL.getPatternLoc());
7950 if (Pattern.isNull())
7951 return QualType();
7952
7953 QualType Result = TL.getType();
7954 if (getDerived().AlwaysRebuild() ||
7955 Pattern != TL.getPatternLoc().getType()) {
7956 Result = getDerived().RebuildPackExpansionType(Pattern,
7957 TL.getPatternLoc().getSourceRange(),
7958 TL.getEllipsisLoc(),
7959 TL.getTypePtr()->getNumExpansions());
7960 if (Result.isNull())
7961 return QualType();
7962 }
7963
7965 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7966 return Result;
7967}
7968
7969template<typename Derived>
7973 // ObjCInterfaceType is never dependent.
7974 TLB.pushFullCopy(TL);
7975 return TL.getType();
7976}
7977
7978template<typename Derived>
7982 const ObjCTypeParamType *T = TL.getTypePtr();
7983 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7984 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7985 if (!OTP)
7986 return QualType();
7987
7988 QualType Result = TL.getType();
7989 if (getDerived().AlwaysRebuild() ||
7990 OTP != T->getDecl()) {
7991 Result = getDerived().RebuildObjCTypeParamType(
7992 OTP, TL.getProtocolLAngleLoc(),
7993 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7994 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7995 if (Result.isNull())
7996 return QualType();
7997 }
7998
8000 if (TL.getNumProtocols()) {
8001 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8002 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8003 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
8004 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8005 }
8006 return Result;
8007}
8008
8009template<typename Derived>
8012 ObjCObjectTypeLoc TL) {
8013 // Transform base type.
8014 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
8015 if (BaseType.isNull())
8016 return QualType();
8017
8018 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
8019
8020 // Transform type arguments.
8021 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
8022 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
8023 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
8024 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
8025 QualType TypeArg = TypeArgInfo->getType();
8026 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
8027 AnyChanged = true;
8028
8029 // We have a pack expansion. Instantiate it.
8030 const auto *PackExpansion = PackExpansionLoc.getType()
8031 ->castAs<PackExpansionType>();
8033 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
8034 Unexpanded);
8035 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
8036
8037 // Determine whether the set of unexpanded parameter packs can
8038 // and should be expanded.
8039 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
8040 bool Expand = false;
8041 bool RetainExpansion = false;
8042 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
8043 if (getDerived().TryExpandParameterPacks(
8044 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
8045 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
8046 RetainExpansion, NumExpansions))
8047 return QualType();
8048
8049 if (!Expand) {
8050 // We can't expand this pack expansion into separate arguments yet;
8051 // just substitute into the pattern and create a new pack expansion
8052 // type.
8053 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
8054
8055 TypeLocBuilder TypeArgBuilder;
8056 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8057 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
8058 PatternLoc);
8059 if (NewPatternType.isNull())
8060 return QualType();
8061
8062 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
8063 NewPatternType, NumExpansions);
8064 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
8065 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
8066 NewTypeArgInfos.push_back(
8067 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
8068 continue;
8069 }
8070
8071 // Substitute into the pack expansion pattern for each slice of the
8072 // pack.
8073 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
8074 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
8075
8076 TypeLocBuilder TypeArgBuilder;
8077 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8078
8079 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
8080 PatternLoc);
8081 if (NewTypeArg.isNull())
8082 return QualType();
8083
8084 NewTypeArgInfos.push_back(
8085 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8086 }
8087
8088 continue;
8089 }
8090
8091 TypeLocBuilder TypeArgBuilder;
8092 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
8093 QualType NewTypeArg =
8094 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
8095 if (NewTypeArg.isNull())
8096 return QualType();
8097
8098 // If nothing changed, just keep the old TypeSourceInfo.
8099 if (NewTypeArg == TypeArg) {
8100 NewTypeArgInfos.push_back(TypeArgInfo);
8101 continue;
8102 }
8103
8104 NewTypeArgInfos.push_back(
8105 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8106 AnyChanged = true;
8107 }
8108
8109 QualType Result = TL.getType();
8110 if (getDerived().AlwaysRebuild() || AnyChanged) {
8111 // Rebuild the type.
8112 Result = getDerived().RebuildObjCObjectType(
8113 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
8114 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
8115 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8116 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8117
8118 if (Result.isNull())
8119 return QualType();
8120 }
8121
8122 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
8123 NewT.setHasBaseTypeAsWritten(true);
8124 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
8125 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
8126 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
8127 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
8128 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8129 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8130 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
8131 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8132 return Result;
8133}
8134
8135template<typename Derived>
8139 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8140 if (PointeeType.isNull())
8141 return QualType();
8142
8143 QualType Result = TL.getType();
8144 if (getDerived().AlwaysRebuild() ||
8145 PointeeType != TL.getPointeeLoc().getType()) {
8146 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8147 TL.getStarLoc());
8148 if (Result.isNull())
8149 return QualType();
8150 }
8151
8153 NewT.setStarLoc(TL.getStarLoc());
8154 return Result;
8155}
8156
8157//===----------------------------------------------------------------------===//
8158// Statement transformation
8159//===----------------------------------------------------------------------===//
8160template<typename Derived>
8163 return S;
8164}
8165
8166template<typename Derived>
8169 return getDerived().TransformCompoundStmt(S, false);
8170}
8171
8172template<typename Derived>
8175 bool IsStmtExpr) {
8176 Sema::CompoundScopeRAII CompoundScope(getSema());
8177 Sema::FPFeaturesStateRAII FPSave(getSema());
8178 if (S->hasStoredFPFeatures())
8179 getSema().resetFPOptions(
8180 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8181
8182 bool SubStmtInvalid = false;
8183 bool SubStmtChanged = false;
8184 SmallVector<Stmt*, 8> Statements;
8185 for (auto *B : S->body()) {
8186 StmtResult Result = getDerived().TransformStmt(
8187 B, IsStmtExpr && B == S->body_back() ? StmtDiscardKind::StmtExprResult
8188 : StmtDiscardKind::Discarded);
8189
8190 if (Result.isInvalid()) {
8191 // Immediately fail if this was a DeclStmt, since it's very
8192 // likely that this will cause problems for future statements.
8193 if (isa<DeclStmt>(B))
8194 return StmtError();
8195
8196 // Otherwise, just keep processing substatements and fail later.
8197 SubStmtInvalid = true;
8198 continue;
8199 }
8200
8201 SubStmtChanged = SubStmtChanged || Result.get() != B;
8202 Statements.push_back(Result.getAs<Stmt>());
8203 }
8204
8205 if (SubStmtInvalid)
8206 return StmtError();
8207
8208 if (!getDerived().AlwaysRebuild() &&
8209 !SubStmtChanged)
8210 return S;
8211
8212 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8213 Statements,
8214 S->getRBracLoc(),
8215 IsStmtExpr);
8216}
8217
8218template<typename Derived>
8221 ExprResult LHS, RHS;
8222 {
8225
8226 // Transform the left-hand case value.
8227 LHS = getDerived().TransformExpr(S->getLHS());
8228 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8229 if (LHS.isInvalid())
8230 return StmtError();
8231
8232 // Transform the right-hand case value (for the GNU case-range extension).
8233 RHS = getDerived().TransformExpr(S->getRHS());
8234 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8235 if (RHS.isInvalid())
8236 return StmtError();
8237 }
8238
8239 // Build the case statement.
8240 // Case statements are always rebuilt so that they will attached to their
8241 // transformed switch statement.
8242 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8243 LHS.get(),
8244 S->getEllipsisLoc(),
8245 RHS.get(),
8246 S->getColonLoc());
8247 if (Case.isInvalid())
8248 return StmtError();
8249
8250 // Transform the statement following the case
8251 StmtResult SubStmt =
8252 getDerived().TransformStmt(S->getSubStmt());
8253 if (SubStmt.isInvalid())
8254 return StmtError();
8255
8256 // Attach the body to the case statement
8257 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8258}
8259
8260template <typename Derived>
8262 // Transform the statement following the default case
8263 StmtResult SubStmt =
8264 getDerived().TransformStmt(S->getSubStmt());
8265 if (SubStmt.isInvalid())
8266 return StmtError();
8267
8268 // Default statements are always rebuilt
8269 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8270 SubStmt.get());
8271}
8272
8273template<typename Derived>
8276 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8277 if (SubStmt.isInvalid())
8278 return StmtError();
8279
8280 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8281 S->getDecl());
8282 if (!LD)
8283 return StmtError();
8284
8285 // If we're transforming "in-place" (we're not creating new local
8286 // declarations), assume we're replacing the old label statement
8287 // and clear out the reference to it.
8288 if (LD == S->getDecl())
8289 S->getDecl()->setStmt(nullptr);
8290
8291 // FIXME: Pass the real colon location in.
8292 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8294 SubStmt.get());
8295}
8296
8297template <typename Derived>
8299 if (!R)
8300 return R;
8301
8302 switch (R->getKind()) {
8303// Transform attributes by calling TransformXXXAttr.
8304#define ATTR(X) \
8305 case attr::X: \
8306 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8307#include "clang/Basic/AttrList.inc"
8308 }
8309 return R;
8310}
8311
8312template <typename Derived>
8314 const Stmt *InstS,
8315 const Attr *R) {
8316 if (!R)
8317 return R;
8318
8319 switch (R->getKind()) {
8320// Transform attributes by calling TransformStmtXXXAttr.
8321#define ATTR(X) \
8322 case attr::X: \
8323 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8324#include "clang/Basic/AttrList.inc"
8325 }
8326 return TransformAttr(R);
8327}
8328
8329template <typename Derived>
8332 StmtDiscardKind SDK) {
8333 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8334 if (SubStmt.isInvalid())
8335 return StmtError();
8336
8337 bool AttrsChanged = false;
8339
8340 // Visit attributes and keep track if any are transformed.
8341 for (const auto *I : S->getAttrs()) {
8342 const Attr *R =
8343 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8344 AttrsChanged |= (I != R);
8345 if (R)
8346 Attrs.push_back(R);
8347 }
8348
8349 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8350 return S;
8351
8352 // If transforming the attributes failed for all of the attributes in the
8353 // statement, don't make an AttributedStmt without attributes.
8354 if (Attrs.empty())
8355 return SubStmt;
8356
8357 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8358 SubStmt.get());
8359}
8360
8361template<typename Derived>
8364 // Transform the initialization statement
8365 StmtResult Init = getDerived().TransformStmt(S->getInit());
8366 if (Init.isInvalid())
8367 return StmtError();
8368
8370 if (!S->isConsteval()) {
8371 // Transform the condition
8372 Cond = getDerived().TransformCondition(
8373 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8374 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8376 if (Cond.isInvalid())
8377 return StmtError();
8378 }
8379
8380 // If this is a constexpr if, determine which arm we should instantiate.
8381 std::optional<bool> ConstexprConditionValue;
8382 if (S->isConstexpr())
8383 ConstexprConditionValue = Cond.getKnownValue();
8384
8385 // Transform the "then" branch.
8386 StmtResult Then;
8387 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8391 S->isNonNegatedConsteval());
8392
8393 Then = getDerived().TransformStmt(S->getThen());
8394 if (Then.isInvalid())
8395 return StmtError();
8396 } else {
8397 // Discarded branch is replaced with empty CompoundStmt so we can keep
8398 // proper source location for start and end of original branch, so
8399 // subsequent transformations like CoverageMapping work properly
8400 Then = new (getSema().Context)
8401 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8402 }
8403
8404 // Transform the "else" branch.
8405 StmtResult Else;
8406 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8410 S->isNegatedConsteval());
8411
8412 Else = getDerived().TransformStmt(S->getElse());
8413 if (Else.isInvalid())
8414 return StmtError();
8415 } else if (S->getElse() && ConstexprConditionValue &&
8416 *ConstexprConditionValue) {
8417 // Same thing here as with <then> branch, we are discarding it, we can't
8418 // replace it with NULL nor NullStmt as we need to keep for source location
8419 // range, for CoverageMapping
8420 Else = new (getSema().Context)
8421 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8422 }
8423
8424 if (!getDerived().AlwaysRebuild() &&
8425 Init.get() == S->getInit() &&
8426 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8427 Then.get() == S->getThen() &&
8428 Else.get() == S->getElse())
8429 return S;
8430
8431 return getDerived().RebuildIfStmt(
8432 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8433 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8434}
8435
8436template<typename Derived>
8439 // Transform the initialization statement
8440 StmtResult Init = getDerived().TransformStmt(S->getInit());
8441 if (Init.isInvalid())
8442 return StmtError();
8443
8444 // Transform the condition.
8445 Sema::ConditionResult Cond = getDerived().TransformCondition(
8446 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8448 if (Cond.isInvalid())
8449 return StmtError();
8450
8451 // Rebuild the switch statement.
8453 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8454 Init.get(), Cond, S->getRParenLoc());
8455 if (Switch.isInvalid())
8456 return StmtError();
8457
8458 // Transform the body of the switch statement.
8459 StmtResult Body = getDerived().TransformStmt(S->getBody());
8460 if (Body.isInvalid())
8461 return StmtError();
8462
8463 // Complete the switch statement.
8464 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8465 Body.get());
8466}
8467
8468template<typename Derived>
8471 // Transform the condition
8472 Sema::ConditionResult Cond = getDerived().TransformCondition(
8473 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8475 if (Cond.isInvalid())
8476 return StmtError();
8477
8478 // OpenACC Restricts a while-loop inside of certain construct/clause
8479 // combinations, so diagnose that here in OpenACC mode.
8481 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8482
8483 // Transform the body
8484 StmtResult Body = getDerived().TransformStmt(S->getBody());
8485 if (Body.isInvalid())
8486 return StmtError();
8487
8488 if (!getDerived().AlwaysRebuild() &&
8489 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8490 Body.get() == S->getBody())
8491 return Owned(S);
8492
8493 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8494 Cond, S->getRParenLoc(), Body.get());
8495}
8496
8497template<typename Derived>
8500 // OpenACC Restricts a do-loop inside of certain construct/clause
8501 // combinations, so diagnose that here in OpenACC mode.
8503 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8504
8505 // Transform the body
8506 StmtResult Body = getDerived().TransformStmt(S->getBody());
8507 if (Body.isInvalid())
8508 return StmtError();
8509
8510 // Transform the condition
8511 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8512 if (Cond.isInvalid())
8513 return StmtError();
8514
8515 if (!getDerived().AlwaysRebuild() &&
8516 Cond.get() == S->getCond() &&
8517 Body.get() == S->getBody())
8518 return S;
8519
8520 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8521 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8522 S->getRParenLoc());
8523}
8524
8525template<typename Derived>
8528 if (getSema().getLangOpts().OpenMP)
8529 getSema().OpenMP().startOpenMPLoop();
8530
8531 // Transform the initialization statement
8532 StmtResult Init = getDerived().TransformStmt(S->getInit());
8533 if (Init.isInvalid())
8534 return StmtError();
8535
8536 // In OpenMP loop region loop control variable must be captured and be
8537 // private. Perform analysis of first part (if any).
8538 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8539 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8540 Init.get());
8541
8542 // Transform the condition
8543 Sema::ConditionResult Cond = getDerived().TransformCondition(
8544 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8546 if (Cond.isInvalid())
8547 return StmtError();
8548
8549 // Transform the increment
8550 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8551 if (Inc.isInvalid())
8552 return StmtError();
8553
8554 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8555 if (S->getInc() && !FullInc.get())
8556 return StmtError();
8557
8558 // OpenACC Restricts a for-loop inside of certain construct/clause
8559 // combinations, so diagnose that here in OpenACC mode.
8561 SemaRef.OpenACC().ActOnForStmtBegin(
8562 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8563 Cond.get().second, S->getInc(), Inc.get());
8564
8565 // Transform the body
8566 StmtResult Body = getDerived().TransformStmt(S->getBody());
8567 if (Body.isInvalid())
8568 return StmtError();
8569
8570 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8571
8572 if (!getDerived().AlwaysRebuild() &&
8573 Init.get() == S->getInit() &&
8574 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8575 Inc.get() == S->getInc() &&
8576 Body.get() == S->getBody())
8577 return S;
8578
8579 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8580 Init.get(), Cond, FullInc,
8581 S->getRParenLoc(), Body.get());
8582}
8583
8584template<typename Derived>
8587 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8588 S->getLabel());
8589 if (!LD)
8590 return StmtError();
8591
8592 // Goto statements must always be rebuilt, to resolve the label.
8593 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8594 cast<LabelDecl>(LD));
8595}
8596
8597template<typename Derived>
8600 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8601 if (Target.isInvalid())
8602 return StmtError();
8603 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8604
8605 if (!getDerived().AlwaysRebuild() &&
8606 Target.get() == S->getTarget())
8607 return S;
8608
8609 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8610 Target.get());
8611}
8612
8613template<typename Derived>
8616 if (!S->hasLabelTarget())
8617 return S;
8618
8619 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8620 S->getLabelDecl());
8621 if (!LD)
8622 return StmtError();
8623
8624 return new (SemaRef.Context)
8625 ContinueStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8626}
8627
8628template<typename Derived>
8631 if (!S->hasLabelTarget())
8632 return S;
8633
8634 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8635 S->getLabelDecl());
8636 if (!LD)
8637 return StmtError();
8638
8639 return new (SemaRef.Context)
8640 BreakStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8641}
8642
8643template <typename Derived>
8645 StmtResult Result = getDerived().TransformStmt(S->getBody());
8646 if (!Result.isUsable())
8647 return StmtError();
8648 return DeferStmt::Create(getSema().Context, S->getDeferLoc(), Result.get());
8649}
8650
8651template<typename Derived>
8654 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8655 /*NotCopyInit*/false);
8656 if (Result.isInvalid())
8657 return StmtError();
8658
8659 // FIXME: We always rebuild the return statement because there is no way
8660 // to tell whether the return type of the function has changed.
8661 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8662}
8663
8664template<typename Derived>
8667 bool DeclChanged = false;
8669 LambdaScopeInfo *LSI = getSema().getCurLambda();
8670 for (auto *D : S->decls()) {
8671 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8672 if (!Transformed)
8673 return StmtError();
8674
8675 if (Transformed != D)
8676 DeclChanged = true;
8677
8678 if (LSI) {
8679 if (auto *TD = dyn_cast<TypeDecl>(Transformed)) {
8680 if (auto *TN = dyn_cast<TypedefNameDecl>(TD)) {
8681 LSI->ContainsUnexpandedParameterPack |=
8682 TN->getUnderlyingType()->containsUnexpandedParameterPack();
8683 } else {
8684 LSI->ContainsUnexpandedParameterPack |=
8685 getSema()
8686 .getASTContext()
8687 .getTypeDeclType(TD)
8688 ->containsUnexpandedParameterPack();
8689 }
8690 }
8691 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8692 LSI->ContainsUnexpandedParameterPack |=
8693 VD->getType()->containsUnexpandedParameterPack();
8694 }
8695
8696 Decls.push_back(Transformed);
8697 }
8698
8699 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8700 return S;
8701
8702 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8703}
8704
8705template<typename Derived>
8708
8709 SmallVector<Expr*, 8> Constraints;
8712
8713 SmallVector<Expr*, 8> Clobbers;
8714
8715 bool ExprsChanged = false;
8716
8717 auto RebuildString = [&](Expr *E) {
8718 ExprResult Result = getDerived().TransformExpr(E);
8719 if (!Result.isUsable())
8720 return Result;
8721 if (Result.get() != E) {
8722 ExprsChanged = true;
8723 Result = SemaRef.ActOnGCCAsmStmtString(Result.get(), /*ForLabel=*/false);
8724 }
8725 return Result;
8726 };
8727
8728 // Go through the outputs.
8729 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8730 Names.push_back(S->getOutputIdentifier(I));
8731
8732 ExprResult Result = RebuildString(S->getOutputConstraintExpr(I));
8733 if (Result.isInvalid())
8734 return StmtError();
8735
8736 Constraints.push_back(Result.get());
8737
8738 // Transform the output expr.
8739 Expr *OutputExpr = S->getOutputExpr(I);
8740 Result = getDerived().TransformExpr(OutputExpr);
8741 if (Result.isInvalid())
8742 return StmtError();
8743
8744 ExprsChanged |= Result.get() != OutputExpr;
8745
8746 Exprs.push_back(Result.get());
8747 }
8748
8749 // Go through the inputs.
8750 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8751 Names.push_back(S->getInputIdentifier(I));
8752
8753 ExprResult Result = RebuildString(S->getInputConstraintExpr(I));
8754 if (Result.isInvalid())
8755 return StmtError();
8756
8757 Constraints.push_back(Result.get());
8758
8759 // Transform the input expr.
8760 Expr *InputExpr = S->getInputExpr(I);
8761 Result = getDerived().TransformExpr(InputExpr);
8762 if (Result.isInvalid())
8763 return StmtError();
8764
8765 ExprsChanged |= Result.get() != InputExpr;
8766
8767 Exprs.push_back(Result.get());
8768 }
8769
8770 // Go through the Labels.
8771 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8772 Names.push_back(S->getLabelIdentifier(I));
8773
8774 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8775 if (Result.isInvalid())
8776 return StmtError();
8777 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8778 Exprs.push_back(Result.get());
8779 }
8780
8781 // Go through the clobbers.
8782 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) {
8783 ExprResult Result = RebuildString(S->getClobberExpr(I));
8784 if (Result.isInvalid())
8785 return StmtError();
8786 Clobbers.push_back(Result.get());
8787 }
8788
8789 ExprResult AsmString = RebuildString(S->getAsmStringExpr());
8790 if (AsmString.isInvalid())
8791 return StmtError();
8792
8793 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8794 return S;
8795
8796 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8797 S->isVolatile(), S->getNumOutputs(),
8798 S->getNumInputs(), Names.data(),
8799 Constraints, Exprs, AsmString.get(),
8800 Clobbers, S->getNumLabels(),
8801 S->getRParenLoc());
8802}
8803
8804template<typename Derived>
8807 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8808
8809 bool HadError = false, HadChange = false;
8810
8811 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8812 SmallVector<Expr*, 8> TransformedExprs;
8813 TransformedExprs.reserve(SrcExprs.size());
8814 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8815 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8816 if (!Result.isUsable()) {
8817 HadError = true;
8818 } else {
8819 HadChange |= (Result.get() != SrcExprs[i]);
8820 TransformedExprs.push_back(Result.get());
8821 }
8822 }
8823
8824 if (HadError) return StmtError();
8825 if (!HadChange && !getDerived().AlwaysRebuild())
8826 return Owned(S);
8827
8828 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8829 AsmToks, S->getAsmString(),
8830 S->getNumOutputs(), S->getNumInputs(),
8831 S->getAllConstraints(), S->getClobbers(),
8832 TransformedExprs, S->getEndLoc());
8833}
8834
8835// C++ Coroutines
8836template<typename Derived>
8839 auto *ScopeInfo = SemaRef.getCurFunction();
8840 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8841 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8842 ScopeInfo->NeedsCoroutineSuspends &&
8843 ScopeInfo->CoroutineSuspends.first == nullptr &&
8844 ScopeInfo->CoroutineSuspends.second == nullptr &&
8845 "expected clean scope info");
8846
8847 // Set that we have (possibly-invalid) suspend points before we do anything
8848 // that may fail.
8849 ScopeInfo->setNeedsCoroutineSuspends(false);
8850
8851 // We re-build the coroutine promise object (and the coroutine parameters its
8852 // type and constructor depend on) based on the types used in our current
8853 // function. We must do so, and set it on the current FunctionScopeInfo,
8854 // before attempting to transform the other parts of the coroutine body
8855 // statement, such as the implicit suspend statements (because those
8856 // statements reference the FunctionScopeInfo::CoroutinePromise).
8857 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8858 return StmtError();
8859 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8860 if (!Promise)
8861 return StmtError();
8862 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8863 ScopeInfo->CoroutinePromise = Promise;
8864
8865 // Transform the implicit coroutine statements constructed using dependent
8866 // types during the previous parse: initial and final suspensions, the return
8867 // object, and others. We also transform the coroutine function's body.
8868 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8869 if (InitSuspend.isInvalid())
8870 return StmtError();
8871 StmtResult FinalSuspend =
8872 getDerived().TransformStmt(S->getFinalSuspendStmt());
8873 if (FinalSuspend.isInvalid() ||
8874 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8875 return StmtError();
8876 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8877 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8878
8879 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8880 if (BodyRes.isInvalid())
8881 return StmtError();
8882
8883 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8884 if (Builder.isInvalid())
8885 return StmtError();
8886
8887 Expr *ReturnObject = S->getReturnValueInit();
8888 assert(ReturnObject && "the return object is expected to be valid");
8889 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8890 /*NoCopyInit*/ false);
8891 if (Res.isInvalid())
8892 return StmtError();
8893 Builder.ReturnValue = Res.get();
8894
8895 // If during the previous parse the coroutine still had a dependent promise
8896 // statement, we may need to build some implicit coroutine statements
8897 // (such as exception and fallthrough handlers) for the first time.
8898 if (S->hasDependentPromiseType()) {
8899 // We can only build these statements, however, if the current promise type
8900 // is not dependent.
8901 if (!Promise->getType()->isDependentType()) {
8902 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8903 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8904 "these nodes should not have been built yet");
8905 if (!Builder.buildDependentStatements())
8906 return StmtError();
8907 }
8908 } else {
8909 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8910 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8911 if (Res.isInvalid())
8912 return StmtError();
8913 Builder.OnFallthrough = Res.get();
8914 }
8915
8916 if (auto *OnException = S->getExceptionHandler()) {
8917 StmtResult Res = getDerived().TransformStmt(OnException);
8918 if (Res.isInvalid())
8919 return StmtError();
8920 Builder.OnException = Res.get();
8921 }
8922
8923 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8924 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8925 if (Res.isInvalid())
8926 return StmtError();
8927 Builder.ReturnStmtOnAllocFailure = Res.get();
8928 }
8929
8930 // Transform any additional statements we may have already built
8931 assert(S->getAllocate() && S->getDeallocate() &&
8932 "allocation and deallocation calls must already be built");
8933 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8934 if (AllocRes.isInvalid())
8935 return StmtError();
8936 Builder.Allocate = AllocRes.get();
8937
8938 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8939 if (DeallocRes.isInvalid())
8940 return StmtError();
8941 Builder.Deallocate = DeallocRes.get();
8942
8943 if (auto *ResultDecl = S->getResultDecl()) {
8944 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8945 if (Res.isInvalid())
8946 return StmtError();
8947 Builder.ResultDecl = Res.get();
8948 }
8949
8950 if (auto *ReturnStmt = S->getReturnStmt()) {
8951 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8952 if (Res.isInvalid())
8953 return StmtError();
8954 Builder.ReturnStmt = Res.get();
8955 }
8956 }
8957
8958 return getDerived().RebuildCoroutineBodyStmt(Builder);
8959}
8960
8961template<typename Derived>
8964 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8965 /*NotCopyInit*/false);
8966 if (Result.isInvalid())
8967 return StmtError();
8968
8969 // Always rebuild; we don't know if this needs to be injected into a new
8970 // context or if the promise type has changed.
8971 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8972 S->isImplicit());
8973}
8974
8975template <typename Derived>
8977 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8978 /*NotCopyInit*/ false);
8979 if (Operand.isInvalid())
8980 return ExprError();
8981
8982 // Rebuild the common-expr from the operand rather than transforming it
8983 // separately.
8984
8985 // FIXME: getCurScope() should not be used during template instantiation.
8986 // We should pick up the set of unqualified lookup results for operator
8987 // co_await during the initial parse.
8988 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8989 getSema().getCurScope(), E->getKeywordLoc());
8990
8991 // Always rebuild; we don't know if this needs to be injected into a new
8992 // context or if the promise type has changed.
8993 return getDerived().RebuildCoawaitExpr(
8994 E->getKeywordLoc(), Operand.get(),
8995 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8996}
8997
8998template <typename Derived>
9001 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
9002 /*NotCopyInit*/ false);
9003 if (OperandResult.isInvalid())
9004 return ExprError();
9005
9006 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
9007 E->getOperatorCoawaitLookup());
9008
9009 if (LookupResult.isInvalid())
9010 return ExprError();
9011
9012 // Always rebuild; we don't know if this needs to be injected into a new
9013 // context or if the promise type has changed.
9014 return getDerived().RebuildDependentCoawaitExpr(
9015 E->getKeywordLoc(), OperandResult.get(),
9017}
9018
9019template<typename Derived>
9022 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
9023 /*NotCopyInit*/false);
9024 if (Result.isInvalid())
9025 return ExprError();
9026
9027 // Always rebuild; we don't know if this needs to be injected into a new
9028 // context or if the promise type has changed.
9029 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
9030}
9031
9032// Objective-C Statements.
9033
9034template<typename Derived>
9037 // Transform the body of the @try.
9038 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
9039 if (TryBody.isInvalid())
9040 return StmtError();
9041
9042 // Transform the @catch statements (if present).
9043 bool AnyCatchChanged = false;
9044 SmallVector<Stmt*, 8> CatchStmts;
9045 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
9046 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
9047 if (Catch.isInvalid())
9048 return StmtError();
9049 if (Catch.get() != S->getCatchStmt(I))
9050 AnyCatchChanged = true;
9051 CatchStmts.push_back(Catch.get());
9052 }
9053
9054 // Transform the @finally statement (if present).
9055 StmtResult Finally;
9056 if (S->getFinallyStmt()) {
9057 Finally = getDerived().TransformStmt(S->getFinallyStmt());
9058 if (Finally.isInvalid())
9059 return StmtError();
9060 }
9061
9062 // If nothing changed, just retain this statement.
9063 if (!getDerived().AlwaysRebuild() &&
9064 TryBody.get() == S->getTryBody() &&
9065 !AnyCatchChanged &&
9066 Finally.get() == S->getFinallyStmt())
9067 return S;
9068
9069 // Build a new statement.
9070 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
9071 CatchStmts, Finally.get());
9072}
9073
9074template<typename Derived>
9077 // Transform the @catch parameter, if there is one.
9078 VarDecl *Var = nullptr;
9079 if (VarDecl *FromVar = S->getCatchParamDecl()) {
9080 TypeSourceInfo *TSInfo = nullptr;
9081 if (FromVar->getTypeSourceInfo()) {
9082 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
9083 if (!TSInfo)
9084 return StmtError();
9085 }
9086
9087 QualType T;
9088 if (TSInfo)
9089 T = TSInfo->getType();
9090 else {
9091 T = getDerived().TransformType(FromVar->getType());
9092 if (T.isNull())
9093 return StmtError();
9094 }
9095
9096 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
9097 if (!Var)
9098 return StmtError();
9099 }
9100
9101 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
9102 if (Body.isInvalid())
9103 return StmtError();
9104
9105 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
9106 S->getRParenLoc(),
9107 Var, Body.get());
9108}
9109
9110template<typename Derived>
9113 // Transform the body.
9114 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
9115 if (Body.isInvalid())
9116 return StmtError();
9117
9118 // If nothing changed, just retain this statement.
9119 if (!getDerived().AlwaysRebuild() &&
9120 Body.get() == S->getFinallyBody())
9121 return S;
9122
9123 // Build a new statement.
9124 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
9125 Body.get());
9126}
9127
9128template<typename Derived>
9132 if (S->getThrowExpr()) {
9133 Operand = getDerived().TransformExpr(S->getThrowExpr());
9134 if (Operand.isInvalid())
9135 return StmtError();
9136 }
9137
9138 if (!getDerived().AlwaysRebuild() &&
9139 Operand.get() == S->getThrowExpr())
9140 return S;
9141
9142 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
9143}
9144
9145template<typename Derived>
9149 // Transform the object we are locking.
9150 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
9151 if (Object.isInvalid())
9152 return StmtError();
9153 Object =
9154 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
9155 Object.get());
9156 if (Object.isInvalid())
9157 return StmtError();
9158
9159 // Transform the body.
9160 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
9161 if (Body.isInvalid())
9162 return StmtError();
9163
9164 // If nothing change, just retain the current statement.
9165 if (!getDerived().AlwaysRebuild() &&
9166 Object.get() == S->getSynchExpr() &&
9167 Body.get() == S->getSynchBody())
9168 return S;
9169
9170 // Build a new statement.
9171 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
9172 Object.get(), Body.get());
9173}
9174
9175template<typename Derived>
9179 // Transform the body.
9180 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
9181 if (Body.isInvalid())
9182 return StmtError();
9183
9184 // If nothing changed, just retain this statement.
9185 if (!getDerived().AlwaysRebuild() &&
9186 Body.get() == S->getSubStmt())
9187 return S;
9188
9189 // Build a new statement.
9190 return getDerived().RebuildObjCAutoreleasePoolStmt(
9191 S->getAtLoc(), Body.get());
9192}
9193
9194template<typename Derived>
9198 // Transform the element statement.
9199 StmtResult Element = getDerived().TransformStmt(
9200 S->getElement(), StmtDiscardKind::NotDiscarded);
9201 if (Element.isInvalid())
9202 return StmtError();
9203
9204 // Transform the collection expression.
9205 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9206 if (Collection.isInvalid())
9207 return StmtError();
9208
9209 // Transform the body.
9210 StmtResult Body = getDerived().TransformStmt(S->getBody());
9211 if (Body.isInvalid())
9212 return StmtError();
9213
9214 // If nothing changed, just retain this statement.
9215 if (!getDerived().AlwaysRebuild() &&
9216 Element.get() == S->getElement() &&
9217 Collection.get() == S->getCollection() &&
9218 Body.get() == S->getBody())
9219 return S;
9220
9221 // Build a new statement.
9222 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9223 Element.get(),
9224 Collection.get(),
9225 S->getRParenLoc(),
9226 Body.get());
9227}
9228
9229template <typename Derived>
9231 // Transform the exception declaration, if any.
9232 VarDecl *Var = nullptr;
9233 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9234 TypeSourceInfo *T =
9235 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9236 if (!T)
9237 return StmtError();
9238
9239 Var = getDerived().RebuildExceptionDecl(
9240 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9241 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9242 if (!Var || Var->isInvalidDecl())
9243 return StmtError();
9244 }
9245
9246 // Transform the actual exception handler.
9247 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9248 if (Handler.isInvalid())
9249 return StmtError();
9250
9251 if (!getDerived().AlwaysRebuild() && !Var &&
9252 Handler.get() == S->getHandlerBlock())
9253 return S;
9254
9255 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9256}
9257
9258template <typename Derived>
9260 // Transform the try block itself.
9261 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9262 if (TryBlock.isInvalid())
9263 return StmtError();
9264
9265 // Transform the handlers.
9266 bool HandlerChanged = false;
9267 SmallVector<Stmt *, 8> Handlers;
9268 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9269 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9270 if (Handler.isInvalid())
9271 return StmtError();
9272
9273 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9274 Handlers.push_back(Handler.getAs<Stmt>());
9275 }
9276
9277 getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
9278
9279 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9280 !HandlerChanged)
9281 return S;
9282
9283 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9284 Handlers);
9285}
9286
9287template<typename Derived>
9290 EnterExpressionEvaluationContext ForRangeInitContext(
9292 /*LambdaContextDecl=*/nullptr,
9294 getSema().getLangOpts().CPlusPlus23);
9295
9296 // P2718R0 - Lifetime extension in range-based for loops.
9297 if (getSema().getLangOpts().CPlusPlus23) {
9298 auto &LastRecord = getSema().currentEvaluationContext();
9299 LastRecord.InLifetimeExtendingContext = true;
9300 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9301 }
9303 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9304 if (Init.isInvalid())
9305 return StmtError();
9306
9307 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9308 if (Range.isInvalid())
9309 return StmtError();
9310
9311 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9312 assert(getSema().getLangOpts().CPlusPlus23 ||
9313 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9314 auto ForRangeLifetimeExtendTemps =
9315 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9316
9317 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9318 if (Begin.isInvalid())
9319 return StmtError();
9320 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9321 if (End.isInvalid())
9322 return StmtError();
9323
9324 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9325 if (Cond.isInvalid())
9326 return StmtError();
9327 if (Cond.get())
9328 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9329 if (Cond.isInvalid())
9330 return StmtError();
9331 if (Cond.get())
9332 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9333
9334 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9335 if (Inc.isInvalid())
9336 return StmtError();
9337 if (Inc.get())
9338 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9339
9340 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9341 if (LoopVar.isInvalid())
9342 return StmtError();
9343
9344 StmtResult NewStmt = S;
9345 if (getDerived().AlwaysRebuild() ||
9346 Init.get() != S->getInit() ||
9347 Range.get() != S->getRangeStmt() ||
9348 Begin.get() != S->getBeginStmt() ||
9349 End.get() != S->getEndStmt() ||
9350 Cond.get() != S->getCond() ||
9351 Inc.get() != S->getInc() ||
9352 LoopVar.get() != S->getLoopVarStmt()) {
9353 NewStmt = getDerived().RebuildCXXForRangeStmt(
9354 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9355 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9356 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9357 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9358 // Might not have attached any initializer to the loop variable.
9359 getSema().ActOnInitializerError(
9360 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9361 return StmtError();
9362 }
9363 }
9364
9365 // OpenACC Restricts a while-loop inside of certain construct/clause
9366 // combinations, so diagnose that here in OpenACC mode.
9368 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9369
9370 StmtResult Body = getDerived().TransformStmt(S->getBody());
9371 if (Body.isInvalid())
9372 return StmtError();
9373
9374 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9375
9376 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9377 // it now so we have a new statement to attach the body to.
9378 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9379 NewStmt = getDerived().RebuildCXXForRangeStmt(
9380 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9381 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9382 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9383 if (NewStmt.isInvalid())
9384 return StmtError();
9385 }
9386
9387 if (NewStmt.get() == S)
9388 return S;
9389
9390 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9391}
9392
9393template<typename Derived>
9397 // Transform the nested-name-specifier, if any.
9398 NestedNameSpecifierLoc QualifierLoc;
9399 if (S->getQualifierLoc()) {
9400 QualifierLoc
9401 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9402 if (!QualifierLoc)
9403 return StmtError();
9404 }
9405
9406 // Transform the declaration name.
9407 DeclarationNameInfo NameInfo = S->getNameInfo();
9408 if (NameInfo.getName()) {
9409 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9410 if (!NameInfo.getName())
9411 return StmtError();
9412 }
9413
9414 // Check whether anything changed.
9415 if (!getDerived().AlwaysRebuild() &&
9416 QualifierLoc == S->getQualifierLoc() &&
9417 NameInfo.getName() == S->getNameInfo().getName())
9418 return S;
9419
9420 // Determine whether this name exists, if we can.
9421 CXXScopeSpec SS;
9422 SS.Adopt(QualifierLoc);
9423 bool Dependent = false;
9424 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9426 if (S->isIfExists())
9427 break;
9428
9429 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9430
9432 if (S->isIfNotExists())
9433 break;
9434
9435 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9436
9438 Dependent = true;
9439 break;
9440
9442 return StmtError();
9443 }
9444
9445 // We need to continue with the instantiation, so do so now.
9446 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9447 if (SubStmt.isInvalid())
9448 return StmtError();
9449
9450 // If we have resolved the name, just transform to the substatement.
9451 if (!Dependent)
9452 return SubStmt;
9453
9454 // The name is still dependent, so build a dependent expression again.
9455 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9456 S->isIfExists(),
9457 QualifierLoc,
9458 NameInfo,
9459 SubStmt.get());
9460}
9461
9462template<typename Derived>
9465 NestedNameSpecifierLoc QualifierLoc;
9466 if (E->getQualifierLoc()) {
9467 QualifierLoc
9468 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9469 if (!QualifierLoc)
9470 return ExprError();
9471 }
9472
9473 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9474 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9475 if (!PD)
9476 return ExprError();
9477
9478 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9479 if (Base.isInvalid())
9480 return ExprError();
9481
9482 return new (SemaRef.getASTContext())
9483 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9485 QualifierLoc, E->getMemberLoc());
9486}
9487
9488template <typename Derived>
9491 auto BaseRes = getDerived().TransformExpr(E->getBase());
9492 if (BaseRes.isInvalid())
9493 return ExprError();
9494 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9495 if (IdxRes.isInvalid())
9496 return ExprError();
9497
9498 if (!getDerived().AlwaysRebuild() &&
9499 BaseRes.get() == E->getBase() &&
9500 IdxRes.get() == E->getIdx())
9501 return E;
9502
9503 return getDerived().RebuildArraySubscriptExpr(
9504 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9505}
9506
9507template <typename Derived>
9509 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9510 if (TryBlock.isInvalid())
9511 return StmtError();
9512
9513 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9514 if (Handler.isInvalid())
9515 return StmtError();
9516
9517 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9518 Handler.get() == S->getHandler())
9519 return S;
9520
9521 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9522 TryBlock.get(), Handler.get());
9523}
9524
9525template <typename Derived>
9527 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9528 if (Block.isInvalid())
9529 return StmtError();
9530
9531 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9532}
9533
9534template <typename Derived>
9536 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9537 if (FilterExpr.isInvalid())
9538 return StmtError();
9539
9540 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9541 if (Block.isInvalid())
9542 return StmtError();
9543
9544 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9545 Block.get());
9546}
9547
9548template <typename Derived>
9550 if (isa<SEHFinallyStmt>(Handler))
9551 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9552 else
9553 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9554}
9555
9556template<typename Derived>
9559 return S;
9560}
9561
9562//===----------------------------------------------------------------------===//
9563// OpenMP directive transformation
9564//===----------------------------------------------------------------------===//
9565
9566template <typename Derived>
9567StmtResult
9568TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9569 // OMPCanonicalLoops are eliminated during transformation, since they will be
9570 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9571 // after transformation.
9572 return getDerived().TransformStmt(L->getLoopStmt());
9573}
9574
9575template <typename Derived>
9578
9579 // Transform the clauses
9581 ArrayRef<OMPClause *> Clauses = D->clauses();
9582 TClauses.reserve(Clauses.size());
9583 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9584 I != E; ++I) {
9585 if (*I) {
9586 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9587 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9588 getDerived().getSema().OpenMP().EndOpenMPClause();
9589 if (Clause)
9590 TClauses.push_back(Clause);
9591 } else {
9592 TClauses.push_back(nullptr);
9593 }
9594 }
9595 StmtResult AssociatedStmt;
9596 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9597 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9598 D->getDirectiveKind(),
9599 /*CurScope=*/nullptr);
9600 StmtResult Body;
9601 {
9602 Sema::CompoundScopeRAII CompoundScope(getSema());
9603 Stmt *CS;
9604 if (D->getDirectiveKind() == OMPD_atomic ||
9605 D->getDirectiveKind() == OMPD_critical ||
9606 D->getDirectiveKind() == OMPD_section ||
9607 D->getDirectiveKind() == OMPD_master)
9608 CS = D->getAssociatedStmt();
9609 else
9610 CS = D->getRawStmt();
9611 Body = getDerived().TransformStmt(CS);
9612 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9613 getSema().getLangOpts().OpenMPIRBuilder)
9614 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9615 }
9616 AssociatedStmt =
9617 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9618 if (AssociatedStmt.isInvalid()) {
9619 return StmtError();
9620 }
9621 }
9622 if (TClauses.size() != Clauses.size()) {
9623 return StmtError();
9624 }
9625
9626 // Transform directive name for 'omp critical' directive.
9627 DeclarationNameInfo DirName;
9628 if (D->getDirectiveKind() == OMPD_critical) {
9629 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9630 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9631 }
9632 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9633 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9634 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9635 } else if (D->getDirectiveKind() == OMPD_cancel) {
9636 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9637 }
9638
9639 return getDerived().RebuildOMPExecutableDirective(
9640 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9641 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
9642}
9643
9644/// This is mostly the same as above, but allows 'informational' class
9645/// directives when rebuilding the stmt. It still takes an
9646/// OMPExecutableDirective-type argument because we're reusing that as the
9647/// superclass for the 'assume' directive at present, instead of defining a
9648/// mostly-identical OMPInformationalDirective parent class.
9649template <typename Derived>
9652
9653 // Transform the clauses
9655 ArrayRef<OMPClause *> Clauses = D->clauses();
9656 TClauses.reserve(Clauses.size());
9657 for (OMPClause *C : Clauses) {
9658 if (C) {
9659 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
9660 OMPClause *Clause = getDerived().TransformOMPClause(C);
9661 getDerived().getSema().OpenMP().EndOpenMPClause();
9662 if (Clause)
9663 TClauses.push_back(Clause);
9664 } else {
9665 TClauses.push_back(nullptr);
9666 }
9667 }
9668 StmtResult AssociatedStmt;
9669 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9670 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9671 D->getDirectiveKind(),
9672 /*CurScope=*/nullptr);
9673 StmtResult Body;
9674 {
9675 Sema::CompoundScopeRAII CompoundScope(getSema());
9676 assert(D->getDirectiveKind() == OMPD_assume &&
9677 "Unexpected informational directive");
9678 Stmt *CS = D->getAssociatedStmt();
9679 Body = getDerived().TransformStmt(CS);
9680 }
9681 AssociatedStmt =
9682 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9683 if (AssociatedStmt.isInvalid())
9684 return StmtError();
9685 }
9686 if (TClauses.size() != Clauses.size())
9687 return StmtError();
9688
9689 DeclarationNameInfo DirName;
9690
9691 return getDerived().RebuildOMPInformationalDirective(
9692 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
9693 D->getBeginLoc(), D->getEndLoc());
9694}
9695
9696template <typename Derived>
9699 // TODO: Fix This
9700 unsigned OMPVersion = getDerived().getSema().getLangOpts().OpenMP;
9701 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9702 << getOpenMPDirectiveName(D->getDirectiveKind(), OMPVersion);
9703 return StmtError();
9704}
9705
9706template <typename Derived>
9707StmtResult
9708TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9709 DeclarationNameInfo DirName;
9710 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9711 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
9712 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9713 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9714 return Res;
9715}
9716
9717template <typename Derived>
9720 DeclarationNameInfo DirName;
9721 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9722 OMPD_simd, DirName, nullptr, D->getBeginLoc());
9723 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9724 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9725 return Res;
9726}
9727
9728template <typename Derived>
9731 DeclarationNameInfo DirName;
9732 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9733 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9734 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9735 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9736 return Res;
9737}
9738
9739template <typename Derived>
9742 DeclarationNameInfo DirName;
9743 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9744 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9745 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9746 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9747 return Res;
9748}
9749
9750template <typename Derived>
9753 DeclarationNameInfo DirName;
9754 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9755 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9756 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9757 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9758 return Res;
9759}
9760
9761template <typename Derived>
9764 DeclarationNameInfo DirName;
9765 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9766 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9767 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9768 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9769 return Res;
9770}
9771
9772template <typename Derived>
9774 OMPInterchangeDirective *D) {
9775 DeclarationNameInfo DirName;
9776 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9777 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9778 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9779 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9780 return Res;
9781}
9782
9783template <typename Derived>
9786 DeclarationNameInfo DirName;
9787 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9788 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9789 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9790 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9791 return Res;
9792}
9793
9794template <typename Derived>
9797 DeclarationNameInfo DirName;
9798 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9799 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9800 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9801 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9802 return Res;
9803}
9804
9805template <typename Derived>
9808 DeclarationNameInfo DirName;
9809 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9810 OMPD_for, DirName, nullptr, D->getBeginLoc());
9811 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9812 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9813 return Res;
9814}
9815
9816template <typename Derived>
9819 DeclarationNameInfo DirName;
9820 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9821 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
9822 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9823 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9824 return Res;
9825}
9826
9827template <typename Derived>
9830 DeclarationNameInfo DirName;
9831 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9832 OMPD_sections, DirName, nullptr, D->getBeginLoc());
9833 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9834 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9835 return Res;
9836}
9837
9838template <typename Derived>
9841 DeclarationNameInfo DirName;
9842 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9843 OMPD_section, DirName, nullptr, D->getBeginLoc());
9844 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9845 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9846 return Res;
9847}
9848
9849template <typename Derived>
9852 DeclarationNameInfo DirName;
9853 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9854 OMPD_scope, DirName, nullptr, D->getBeginLoc());
9855 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9856 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9857 return Res;
9858}
9859
9860template <typename Derived>
9863 DeclarationNameInfo DirName;
9864 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9865 OMPD_single, DirName, nullptr, D->getBeginLoc());
9866 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9867 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9868 return Res;
9869}
9870
9871template <typename Derived>
9874 DeclarationNameInfo DirName;
9875 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9876 OMPD_master, DirName, nullptr, D->getBeginLoc());
9877 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9878 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9879 return Res;
9880}
9881
9882template <typename Derived>
9885 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9886 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
9887 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9888 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9889 return Res;
9890}
9891
9892template <typename Derived>
9894 OMPParallelForDirective *D) {
9895 DeclarationNameInfo DirName;
9896 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9897 OMPD_parallel_for, DirName, nullptr, D->getBeginLoc());
9898 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9899 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9900 return Res;
9901}
9902
9903template <typename Derived>
9905 OMPParallelForSimdDirective *D) {
9906 DeclarationNameInfo DirName;
9907 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9908 OMPD_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9909 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9910 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9911 return Res;
9912}
9913
9914template <typename Derived>
9916 OMPParallelMasterDirective *D) {
9917 DeclarationNameInfo DirName;
9918 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9919 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
9920 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9921 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9922 return Res;
9923}
9924
9925template <typename Derived>
9927 OMPParallelMaskedDirective *D) {
9928 DeclarationNameInfo DirName;
9929 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9930 OMPD_parallel_masked, DirName, nullptr, D->getBeginLoc());
9931 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9932 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9933 return Res;
9934}
9935
9936template <typename Derived>
9938 OMPParallelSectionsDirective *D) {
9939 DeclarationNameInfo DirName;
9940 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9941 OMPD_parallel_sections, DirName, nullptr, D->getBeginLoc());
9942 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9943 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9944 return Res;
9945}
9946
9947template <typename Derived>
9950 DeclarationNameInfo DirName;
9951 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9952 OMPD_task, DirName, nullptr, D->getBeginLoc());
9953 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9954 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9955 return Res;
9956}
9957
9958template <typename Derived>
9960 OMPTaskyieldDirective *D) {
9961 DeclarationNameInfo DirName;
9962 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9963 OMPD_taskyield, DirName, nullptr, D->getBeginLoc());
9964 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9965 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9966 return Res;
9967}
9968
9969template <typename Derived>
9972 DeclarationNameInfo DirName;
9973 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9974 OMPD_barrier, DirName, nullptr, D->getBeginLoc());
9975 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9976 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9977 return Res;
9978}
9979
9980template <typename Derived>
9983 DeclarationNameInfo DirName;
9984 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9985 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
9986 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9987 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9988 return Res;
9989}
9990
9991template <typename Derived>
9994 DeclarationNameInfo DirName;
9995 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9996 OMPD_assume, DirName, nullptr, D->getBeginLoc());
9997 StmtResult Res = getDerived().TransformOMPInformationalDirective(D);
9998 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9999 return Res;
10000}
10001
10002template <typename Derived>
10005 DeclarationNameInfo DirName;
10006 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10007 OMPD_error, DirName, nullptr, D->getBeginLoc());
10008 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10009 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10010 return Res;
10011}
10012
10013template <typename Derived>
10015 OMPTaskgroupDirective *D) {
10016 DeclarationNameInfo DirName;
10017 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10018 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
10019 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10020 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10021 return Res;
10022}
10023
10024template <typename Derived>
10027 DeclarationNameInfo DirName;
10028 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10029 OMPD_flush, DirName, nullptr, D->getBeginLoc());
10030 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10031 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10032 return Res;
10033}
10034
10035template <typename Derived>
10038 DeclarationNameInfo DirName;
10039 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10040 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
10041 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10042 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10043 return Res;
10044}
10045
10046template <typename Derived>
10049 DeclarationNameInfo DirName;
10050 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10051 OMPD_scan, DirName, nullptr, D->getBeginLoc());
10052 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10053 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10054 return Res;
10055}
10056
10057template <typename Derived>
10060 DeclarationNameInfo DirName;
10061 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10062 OMPD_ordered, DirName, nullptr, D->getBeginLoc());
10063 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10064 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10065 return Res;
10066}
10067
10068template <typename Derived>
10071 DeclarationNameInfo DirName;
10072 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10073 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
10074 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10075 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10076 return Res;
10077}
10078
10079template <typename Derived>
10082 DeclarationNameInfo DirName;
10083 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10084 OMPD_target, DirName, nullptr, D->getBeginLoc());
10085 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10086 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10087 return Res;
10088}
10089
10090template <typename Derived>
10092 OMPTargetDataDirective *D) {
10093 DeclarationNameInfo DirName;
10094 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10095 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
10096 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10097 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10098 return Res;
10099}
10100
10101template <typename Derived>
10103 OMPTargetEnterDataDirective *D) {
10104 DeclarationNameInfo DirName;
10105 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10106 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
10107 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10108 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10109 return Res;
10110}
10111
10112template <typename Derived>
10114 OMPTargetExitDataDirective *D) {
10115 DeclarationNameInfo DirName;
10116 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10117 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
10118 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10119 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10120 return Res;
10121}
10122
10123template <typename Derived>
10125 OMPTargetParallelDirective *D) {
10126 DeclarationNameInfo DirName;
10127 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10128 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
10129 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10130 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10131 return Res;
10132}
10133
10134template <typename Derived>
10136 OMPTargetParallelForDirective *D) {
10137 DeclarationNameInfo DirName;
10138 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10139 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
10140 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10141 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10142 return Res;
10143}
10144
10145template <typename Derived>
10147 OMPTargetUpdateDirective *D) {
10148 DeclarationNameInfo DirName;
10149 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10150 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
10151 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10152 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10153 return Res;
10154}
10155
10156template <typename Derived>
10159 DeclarationNameInfo DirName;
10160 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10161 OMPD_teams, DirName, nullptr, D->getBeginLoc());
10162 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10163 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10164 return Res;
10165}
10166
10167template <typename Derived>
10169 OMPCancellationPointDirective *D) {
10170 DeclarationNameInfo DirName;
10171 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10172 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
10173 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10174 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10175 return Res;
10176}
10177
10178template <typename Derived>
10181 DeclarationNameInfo DirName;
10182 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10183 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
10184 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10185 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10186 return Res;
10187}
10188
10189template <typename Derived>
10192 DeclarationNameInfo DirName;
10193 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10194 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
10195 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10196 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10197 return Res;
10198}
10199
10200template <typename Derived>
10202 OMPTaskLoopSimdDirective *D) {
10203 DeclarationNameInfo DirName;
10204 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10205 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10206 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10207 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10208 return Res;
10209}
10210
10211template <typename Derived>
10213 OMPMasterTaskLoopDirective *D) {
10214 DeclarationNameInfo DirName;
10215 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10216 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
10217 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10218 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10219 return Res;
10220}
10221
10222template <typename Derived>
10224 OMPMaskedTaskLoopDirective *D) {
10225 DeclarationNameInfo DirName;
10226 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10227 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10228 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10229 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10230 return Res;
10231}
10232
10233template <typename Derived>
10235 OMPMasterTaskLoopSimdDirective *D) {
10236 DeclarationNameInfo DirName;
10237 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10238 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10239 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10240 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10241 return Res;
10242}
10243
10244template <typename Derived>
10246 OMPMaskedTaskLoopSimdDirective *D) {
10247 DeclarationNameInfo DirName;
10248 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10249 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10250 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10251 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10252 return Res;
10253}
10254
10255template <typename Derived>
10257 OMPParallelMasterTaskLoopDirective *D) {
10258 DeclarationNameInfo DirName;
10259 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10260 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10261 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10262 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10263 return Res;
10264}
10265
10266template <typename Derived>
10268 OMPParallelMaskedTaskLoopDirective *D) {
10269 DeclarationNameInfo DirName;
10270 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10271 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10272 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10273 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10274 return Res;
10275}
10276
10277template <typename Derived>
10280 OMPParallelMasterTaskLoopSimdDirective *D) {
10281 DeclarationNameInfo DirName;
10282 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10283 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10284 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10285 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10286 return Res;
10287}
10288
10289template <typename Derived>
10292 OMPParallelMaskedTaskLoopSimdDirective *D) {
10293 DeclarationNameInfo DirName;
10294 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10295 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10296 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10297 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10298 return Res;
10299}
10300
10301template <typename Derived>
10303 OMPDistributeDirective *D) {
10304 DeclarationNameInfo DirName;
10305 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10306 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10307 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10308 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10309 return Res;
10310}
10311
10312template <typename Derived>
10314 OMPDistributeParallelForDirective *D) {
10315 DeclarationNameInfo DirName;
10316 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10317 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10318 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10319 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10320 return Res;
10321}
10322
10323template <typename Derived>
10326 OMPDistributeParallelForSimdDirective *D) {
10327 DeclarationNameInfo DirName;
10328 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10329 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10330 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10331 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10332 return Res;
10333}
10334
10335template <typename Derived>
10337 OMPDistributeSimdDirective *D) {
10338 DeclarationNameInfo DirName;
10339 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10340 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
10341 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10342 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10343 return Res;
10344}
10345
10346template <typename Derived>
10348 OMPTargetParallelForSimdDirective *D) {
10349 DeclarationNameInfo DirName;
10350 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10351 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10352 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10353 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10354 return Res;
10355}
10356
10357template <typename Derived>
10359 OMPTargetSimdDirective *D) {
10360 DeclarationNameInfo DirName;
10361 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10362 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
10363 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10364 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10365 return Res;
10366}
10367
10368template <typename Derived>
10370 OMPTeamsDistributeDirective *D) {
10371 DeclarationNameInfo DirName;
10372 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10373 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10374 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10375 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10376 return Res;
10377}
10378
10379template <typename Derived>
10381 OMPTeamsDistributeSimdDirective *D) {
10382 DeclarationNameInfo DirName;
10383 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10384 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10385 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10386 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10387 return Res;
10388}
10389
10390template <typename Derived>
10392 OMPTeamsDistributeParallelForSimdDirective *D) {
10393 DeclarationNameInfo DirName;
10394 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10395 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10396 D->getBeginLoc());
10397 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10398 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10399 return Res;
10400}
10401
10402template <typename Derived>
10404 OMPTeamsDistributeParallelForDirective *D) {
10405 DeclarationNameInfo DirName;
10406 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10407 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10408 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10409 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10410 return Res;
10411}
10412
10413template <typename Derived>
10415 OMPTargetTeamsDirective *D) {
10416 DeclarationNameInfo DirName;
10417 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10418 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10419 auto Res = getDerived().TransformOMPExecutableDirective(D);
10420 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10421 return Res;
10422}
10423
10424template <typename Derived>
10426 OMPTargetTeamsDistributeDirective *D) {
10427 DeclarationNameInfo DirName;
10428 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10429 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10430 auto Res = getDerived().TransformOMPExecutableDirective(D);
10431 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10432 return Res;
10433}
10434
10435template <typename Derived>
10438 OMPTargetTeamsDistributeParallelForDirective *D) {
10439 DeclarationNameInfo DirName;
10440 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10441 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10442 D->getBeginLoc());
10443 auto Res = getDerived().TransformOMPExecutableDirective(D);
10444 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10445 return Res;
10446}
10447
10448template <typename Derived>
10451 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10452 DeclarationNameInfo DirName;
10453 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10454 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10455 D->getBeginLoc());
10456 auto Res = getDerived().TransformOMPExecutableDirective(D);
10457 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10458 return Res;
10459}
10460
10461template <typename Derived>
10464 OMPTargetTeamsDistributeSimdDirective *D) {
10465 DeclarationNameInfo DirName;
10466 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10467 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10468 auto Res = getDerived().TransformOMPExecutableDirective(D);
10469 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10470 return Res;
10471}
10472
10473template <typename Derived>
10476 DeclarationNameInfo DirName;
10477 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10478 OMPD_interop, 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>
10487 DeclarationNameInfo DirName;
10488 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10489 OMPD_dispatch, 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>
10498 DeclarationNameInfo DirName;
10499 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10500 OMPD_masked, 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 OMPGenericLoopDirective *D) {
10509 DeclarationNameInfo DirName;
10510 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10511 OMPD_loop, 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 OMPTeamsGenericLoopDirective *D) {
10520 DeclarationNameInfo DirName;
10521 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10522 OMPD_teams_loop, 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>
10530 OMPTargetTeamsGenericLoopDirective *D) {
10531 DeclarationNameInfo DirName;
10532 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10533 OMPD_target_teams_loop, 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 OMPParallelGenericLoopDirective *D) {
10542 DeclarationNameInfo DirName;
10543 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10544 OMPD_parallel_loop, 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 OMPTargetParallelGenericLoopDirective *D) {
10554 DeclarationNameInfo DirName;
10555 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10556 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10557 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10558 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10559 return Res;
10560}
10561
10562//===----------------------------------------------------------------------===//
10563// OpenMP clause transformation
10564//===----------------------------------------------------------------------===//
10565template <typename Derived>
10567 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10568 if (Cond.isInvalid())
10569 return nullptr;
10570 return getDerived().RebuildOMPIfClause(
10571 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10572 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10573}
10574
10575template <typename Derived>
10577 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10578 if (Cond.isInvalid())
10579 return nullptr;
10580 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10581 C->getLParenLoc(), C->getEndLoc());
10582}
10583
10584template <typename Derived>
10585OMPClause *
10587 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
10588 if (NumThreads.isInvalid())
10589 return nullptr;
10590 return getDerived().RebuildOMPNumThreadsClause(
10591 C->getModifier(), NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(),
10592 C->getModifierLoc(), C->getEndLoc());
10593}
10594
10595template <typename Derived>
10596OMPClause *
10598 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10599 if (E.isInvalid())
10600 return nullptr;
10601 return getDerived().RebuildOMPSafelenClause(
10602 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10603}
10604
10605template <typename Derived>
10606OMPClause *
10608 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10609 if (E.isInvalid())
10610 return nullptr;
10611 return getDerived().RebuildOMPAllocatorClause(
10612 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10613}
10614
10615template <typename Derived>
10616OMPClause *
10618 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
10619 if (E.isInvalid())
10620 return nullptr;
10621 return getDerived().RebuildOMPSimdlenClause(
10622 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10623}
10624
10625template <typename Derived>
10627 SmallVector<Expr *, 4> TransformedSizes;
10628 TransformedSizes.reserve(C->getNumSizes());
10629 bool Changed = false;
10630 for (Expr *E : C->getSizesRefs()) {
10631 if (!E) {
10632 TransformedSizes.push_back(nullptr);
10633 continue;
10634 }
10635
10636 ExprResult T = getDerived().TransformExpr(E);
10637 if (T.isInvalid())
10638 return nullptr;
10639 if (E != T.get())
10640 Changed = true;
10641 TransformedSizes.push_back(T.get());
10642 }
10643
10644 if (!Changed && !getDerived().AlwaysRebuild())
10645 return C;
10646 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
10647 C->getLParenLoc(), C->getEndLoc());
10648}
10649
10650template <typename Derived>
10651OMPClause *
10653 SmallVector<Expr *, 4> TransformedCounts;
10654 TransformedCounts.reserve(C->getNumCounts());
10655 for (Expr *E : C->getCountsRefs()) {
10656 if (!E) {
10657 TransformedCounts.push_back(nullptr);
10658 continue;
10659 }
10660
10661 ExprResult T = getDerived().TransformExpr(E);
10662 if (T.isInvalid())
10663 return nullptr;
10664 TransformedCounts.push_back(T.get());
10665 }
10666
10667 return RebuildOMPCountsClause(TransformedCounts, C->getBeginLoc(),
10668 C->getLParenLoc(), C->getEndLoc(),
10669 C->getOmpFillIndex(), C->getOmpFillLoc());
10670}
10671
10672template <typename Derived>
10673OMPClause *
10675 SmallVector<Expr *> TransformedArgs;
10676 TransformedArgs.reserve(C->getNumLoops());
10677 bool Changed = false;
10678 for (Expr *E : C->getArgsRefs()) {
10679 if (!E) {
10680 TransformedArgs.push_back(nullptr);
10681 continue;
10682 }
10683
10684 ExprResult T = getDerived().TransformExpr(E);
10685 if (T.isInvalid())
10686 return nullptr;
10687 if (E != T.get())
10688 Changed = true;
10689 TransformedArgs.push_back(T.get());
10690 }
10691
10692 if (!Changed && !getDerived().AlwaysRebuild())
10693 return C;
10694 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
10695 C->getLParenLoc(), C->getEndLoc());
10696}
10697
10698template <typename Derived>
10700 if (!getDerived().AlwaysRebuild())
10701 return C;
10702 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10703}
10704
10705template <typename Derived>
10706OMPClause *
10708 ExprResult T = getDerived().TransformExpr(C->getFactor());
10709 if (T.isInvalid())
10710 return nullptr;
10711 Expr *Factor = T.get();
10712 bool Changed = Factor != C->getFactor();
10713
10714 if (!Changed && !getDerived().AlwaysRebuild())
10715 return C;
10716 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10717 C->getEndLoc());
10718}
10719
10720template <typename Derived>
10721OMPClause *
10723 ExprResult F = getDerived().TransformExpr(C->getFirst());
10724 if (F.isInvalid())
10725 return nullptr;
10726
10727 ExprResult Cn = getDerived().TransformExpr(C->getCount());
10728 if (Cn.isInvalid())
10729 return nullptr;
10730
10731 Expr *First = F.get();
10732 Expr *Count = Cn.get();
10733
10734 bool Changed = (First != C->getFirst()) || (Count != C->getCount());
10735
10736 // If no changes and AlwaysRebuild() is false, return the original clause
10737 if (!Changed && !getDerived().AlwaysRebuild())
10738 return C;
10739
10740 return RebuildOMPLoopRangeClause(First, Count, C->getBeginLoc(),
10741 C->getLParenLoc(), C->getFirstLoc(),
10742 C->getCountLoc(), C->getEndLoc());
10743}
10744
10745template <typename Derived>
10746OMPClause *
10748 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10749 if (E.isInvalid())
10750 return nullptr;
10751 return getDerived().RebuildOMPCollapseClause(
10752 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10753}
10754
10755template <typename Derived>
10756OMPClause *
10758 return getDerived().RebuildOMPDefaultClause(
10759 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getDefaultVC(),
10760 C->getDefaultVCLoc(), C->getBeginLoc(), C->getLParenLoc(),
10761 C->getEndLoc());
10762}
10763
10764template <typename Derived>
10765OMPClause *
10767 // No need to rebuild this clause, no template-dependent parameters.
10768 return C;
10769}
10770
10771template <typename Derived>
10772OMPClause *
10774 Expr *Impex = C->getImpexType();
10775 ExprResult TransformedImpex = getDerived().TransformExpr(Impex);
10776
10777 if (TransformedImpex.isInvalid())
10778 return nullptr;
10779
10780 return getDerived().RebuildOMPTransparentClause(
10781 TransformedImpex.get(), C->getBeginLoc(), C->getLParenLoc(),
10782 C->getEndLoc());
10783}
10784
10785template <typename Derived>
10786OMPClause *
10788 return getDerived().RebuildOMPProcBindClause(
10789 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10790 C->getLParenLoc(), C->getEndLoc());
10791}
10792
10793template <typename Derived>
10794OMPClause *
10796 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10797 if (E.isInvalid())
10798 return nullptr;
10799 return getDerived().RebuildOMPScheduleClause(
10800 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10801 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10802 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10803 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10804}
10805
10806template <typename Derived>
10807OMPClause *
10809 ExprResult E;
10810 if (auto *Num = C->getNumForLoops()) {
10811 E = getDerived().TransformExpr(Num);
10812 if (E.isInvalid())
10813 return nullptr;
10814 }
10815 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10816 C->getLParenLoc(), E.get());
10817}
10818
10819template <typename Derived>
10820OMPClause *
10822 ExprResult E;
10823 if (Expr *Evt = C->getEventHandler()) {
10824 E = getDerived().TransformExpr(Evt);
10825 if (E.isInvalid())
10826 return nullptr;
10827 }
10828 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10829 C->getLParenLoc(), C->getEndLoc());
10830}
10831
10832template <typename Derived>
10833OMPClause *
10836 if (auto *Condition = C->getCondition()) {
10837 Cond = getDerived().TransformExpr(Condition);
10838 if (Cond.isInvalid())
10839 return nullptr;
10840 }
10841 return getDerived().RebuildOMPNowaitClause(Cond.get(), C->getBeginLoc(),
10842 C->getLParenLoc(), C->getEndLoc());
10843}
10844
10845template <typename Derived>
10846OMPClause *
10848 // No need to rebuild this clause, no template-dependent parameters.
10849 return C;
10850}
10851
10852template <typename Derived>
10853OMPClause *
10855 // No need to rebuild this clause, no template-dependent parameters.
10856 return C;
10857}
10858
10859template <typename Derived>
10861 // No need to rebuild this clause, no template-dependent parameters.
10862 return C;
10863}
10864
10865template <typename Derived>
10867 // No need to rebuild this clause, no template-dependent parameters.
10868 return C;
10869}
10870
10871template <typename Derived>
10872OMPClause *
10874 // No need to rebuild this clause, no template-dependent parameters.
10875 return C;
10876}
10877
10878template <typename Derived>
10879OMPClause *
10881 // No need to rebuild this clause, no template-dependent parameters.
10882 return C;
10883}
10884
10885template <typename Derived>
10886OMPClause *
10888 // No need to rebuild this clause, no template-dependent parameters.
10889 return C;
10890}
10891
10892template <typename Derived>
10894 // No need to rebuild this clause, no template-dependent parameters.
10895 return C;
10896}
10897
10898template <typename Derived>
10899OMPClause *
10901 return C;
10902}
10903
10904template <typename Derived>
10906 ExprResult E = getDerived().TransformExpr(C->getExpr());
10907 if (E.isInvalid())
10908 return nullptr;
10909 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
10910 C->getLParenLoc(), C->getEndLoc());
10911}
10912
10913template <typename Derived>
10914OMPClause *
10916 return C;
10917}
10918
10919template <typename Derived>
10920OMPClause *
10922 return C;
10923}
10924template <typename Derived>
10926 OMPNoOpenMPRoutinesClause *C) {
10927 return C;
10928}
10929template <typename Derived>
10931 OMPNoOpenMPConstructsClause *C) {
10932 return C;
10933}
10934template <typename Derived>
10936 OMPNoParallelismClause *C) {
10937 return C;
10938}
10939
10940template <typename Derived>
10941OMPClause *
10943 // No need to rebuild this clause, no template-dependent parameters.
10944 return C;
10945}
10946
10947template <typename Derived>
10948OMPClause *
10950 // No need to rebuild this clause, no template-dependent parameters.
10951 return C;
10952}
10953
10954template <typename Derived>
10955OMPClause *
10957 // No need to rebuild this clause, no template-dependent parameters.
10958 return C;
10959}
10960
10961template <typename Derived>
10962OMPClause *
10964 // No need to rebuild this clause, no template-dependent parameters.
10965 return C;
10966}
10967
10968template <typename Derived>
10969OMPClause *
10971 // No need to rebuild this clause, no template-dependent parameters.
10972 return C;
10973}
10974
10975template <typename Derived>
10977 // No need to rebuild this clause, no template-dependent parameters.
10978 return C;
10979}
10980
10981template <typename Derived>
10982OMPClause *
10984 // No need to rebuild this clause, no template-dependent parameters.
10985 return C;
10986}
10987
10988template <typename Derived>
10990 // No need to rebuild this clause, no template-dependent parameters.
10991 return C;
10992}
10993
10994template <typename Derived>
10995OMPClause *
10997 // No need to rebuild this clause, no template-dependent parameters.
10998 return C;
10999}
11000
11001template <typename Derived>
11003 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
11004 if (IVR.isInvalid())
11005 return nullptr;
11006
11007 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
11008 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
11009 for (Expr *E : llvm::drop_begin(C->varlist())) {
11010 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
11011 if (ER.isInvalid())
11012 return nullptr;
11013 InteropInfo.PreferTypes.push_back(ER.get());
11014 }
11015 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
11016 C->getBeginLoc(), C->getLParenLoc(),
11017 C->getVarLoc(), C->getEndLoc());
11018}
11019
11020template <typename Derived>
11022 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
11023 if (ER.isInvalid())
11024 return nullptr;
11025 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
11026 C->getLParenLoc(), C->getVarLoc(),
11027 C->getEndLoc());
11028}
11029
11030template <typename Derived>
11031OMPClause *
11033 ExprResult ER;
11034 if (Expr *IV = C->getInteropVar()) {
11035 ER = getDerived().TransformExpr(IV);
11036 if (ER.isInvalid())
11037 return nullptr;
11038 }
11039 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
11040 C->getLParenLoc(), C->getVarLoc(),
11041 C->getEndLoc());
11042}
11043
11044template <typename Derived>
11045OMPClause *
11047 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11048 if (Cond.isInvalid())
11049 return nullptr;
11050 return getDerived().RebuildOMPNovariantsClause(
11051 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11052}
11053
11054template <typename Derived>
11055OMPClause *
11057 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11058 if (Cond.isInvalid())
11059 return nullptr;
11060 return getDerived().RebuildOMPNocontextClause(
11061 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11062}
11063
11064template <typename Derived>
11065OMPClause *
11067 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
11068 if (ThreadID.isInvalid())
11069 return nullptr;
11070 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
11071 C->getLParenLoc(), C->getEndLoc());
11072}
11073
11074template <typename Derived>
11076 ExprResult E = getDerived().TransformExpr(C->getAlignment());
11077 if (E.isInvalid())
11078 return nullptr;
11079 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
11080 C->getLParenLoc(), C->getEndLoc());
11081}
11082
11083template <typename Derived>
11085 OMPUnifiedAddressClause *C) {
11086 llvm_unreachable("unified_address clause cannot appear in dependent context");
11087}
11088
11089template <typename Derived>
11091 OMPUnifiedSharedMemoryClause *C) {
11092 llvm_unreachable(
11093 "unified_shared_memory clause cannot appear in dependent context");
11094}
11095
11096template <typename Derived>
11098 OMPReverseOffloadClause *C) {
11099 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
11100}
11101
11102template <typename Derived>
11104 OMPDynamicAllocatorsClause *C) {
11105 llvm_unreachable(
11106 "dynamic_allocators clause cannot appear in dependent context");
11107}
11108
11109template <typename Derived>
11111 OMPAtomicDefaultMemOrderClause *C) {
11112 llvm_unreachable(
11113 "atomic_default_mem_order clause cannot appear in dependent context");
11114}
11115
11116template <typename Derived>
11117OMPClause *
11119 llvm_unreachable("self_maps clause cannot appear in dependent context");
11120}
11121
11122template <typename Derived>
11124 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
11125 C->getBeginLoc(), C->getLParenLoc(),
11126 C->getEndLoc());
11127}
11128
11129template <typename Derived>
11130OMPClause *
11132 return getDerived().RebuildOMPSeverityClause(
11133 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
11134 C->getLParenLoc(), C->getEndLoc());
11135}
11136
11137template <typename Derived>
11138OMPClause *
11140 ExprResult E = getDerived().TransformExpr(C->getMessageString());
11141 if (E.isInvalid())
11142 return nullptr;
11143 return getDerived().RebuildOMPMessageClause(
11144 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11145}
11146
11147template <typename Derived>
11148OMPClause *
11151 Vars.reserve(C->varlist_size());
11152 for (auto *VE : C->varlist()) {
11153 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11154 if (EVar.isInvalid())
11155 return nullptr;
11156 Vars.push_back(EVar.get());
11157 }
11158 return getDerived().RebuildOMPPrivateClause(
11159 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11160}
11161
11162template <typename Derived>
11164 OMPFirstprivateClause *C) {
11166 Vars.reserve(C->varlist_size());
11167 for (auto *VE : C->varlist()) {
11168 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11169 if (EVar.isInvalid())
11170 return nullptr;
11171 Vars.push_back(EVar.get());
11172 }
11173 return getDerived().RebuildOMPFirstprivateClause(
11174 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11175}
11176
11177template <typename Derived>
11178OMPClause *
11181 Vars.reserve(C->varlist_size());
11182 for (auto *VE : C->varlist()) {
11183 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11184 if (EVar.isInvalid())
11185 return nullptr;
11186 Vars.push_back(EVar.get());
11187 }
11188 return getDerived().RebuildOMPLastprivateClause(
11189 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11190 C->getLParenLoc(), C->getEndLoc());
11191}
11192
11193template <typename Derived>
11194OMPClause *
11197 Vars.reserve(C->varlist_size());
11198 for (auto *VE : C->varlist()) {
11199 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11200 if (EVar.isInvalid())
11201 return nullptr;
11202 Vars.push_back(EVar.get());
11203 }
11204 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11205 C->getLParenLoc(), C->getEndLoc());
11206}
11207
11208template <typename Derived>
11209OMPClause *
11212 Vars.reserve(C->varlist_size());
11213 for (auto *VE : C->varlist()) {
11214 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11215 if (EVar.isInvalid())
11216 return nullptr;
11217 Vars.push_back(EVar.get());
11218 }
11219 CXXScopeSpec ReductionIdScopeSpec;
11220 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11221
11222 DeclarationNameInfo NameInfo = C->getNameInfo();
11223 if (NameInfo.getName()) {
11224 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11225 if (!NameInfo.getName())
11226 return nullptr;
11227 }
11228 // Build a list of all UDR decls with the same names ranged by the Scopes.
11229 // The Scope boundary is a duplication of the previous decl.
11230 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11231 for (auto *E : C->reduction_ops()) {
11232 // Transform all the decls.
11233 if (E) {
11234 auto *ULE = cast<UnresolvedLookupExpr>(E);
11235 UnresolvedSet<8> Decls;
11236 for (auto *D : ULE->decls()) {
11237 NamedDecl *InstD =
11238 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11239 Decls.addDecl(InstD, InstD->getAccess());
11240 }
11241 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11242 SemaRef.Context, /*NamingClass=*/nullptr,
11243 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11244 /*ADL=*/true, Decls.begin(), Decls.end(),
11245 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11246 } else
11247 UnresolvedReductions.push_back(nullptr);
11248 }
11249 return getDerived().RebuildOMPReductionClause(
11250 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11251 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11252 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11253}
11254
11255template <typename Derived>
11257 OMPTaskReductionClause *C) {
11259 Vars.reserve(C->varlist_size());
11260 for (auto *VE : C->varlist()) {
11261 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11262 if (EVar.isInvalid())
11263 return nullptr;
11264 Vars.push_back(EVar.get());
11265 }
11266 CXXScopeSpec ReductionIdScopeSpec;
11267 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11268
11269 DeclarationNameInfo NameInfo = C->getNameInfo();
11270 if (NameInfo.getName()) {
11271 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11272 if (!NameInfo.getName())
11273 return nullptr;
11274 }
11275 // Build a list of all UDR decls with the same names ranged by the Scopes.
11276 // The Scope boundary is a duplication of the previous decl.
11277 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11278 for (auto *E : C->reduction_ops()) {
11279 // Transform all the decls.
11280 if (E) {
11281 auto *ULE = cast<UnresolvedLookupExpr>(E);
11282 UnresolvedSet<8> Decls;
11283 for (auto *D : ULE->decls()) {
11284 NamedDecl *InstD =
11285 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11286 Decls.addDecl(InstD, InstD->getAccess());
11287 }
11288 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11289 SemaRef.Context, /*NamingClass=*/nullptr,
11290 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11291 /*ADL=*/true, Decls.begin(), Decls.end(),
11292 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11293 } else
11294 UnresolvedReductions.push_back(nullptr);
11295 }
11296 return getDerived().RebuildOMPTaskReductionClause(
11297 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11298 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11299}
11300
11301template <typename Derived>
11302OMPClause *
11305 Vars.reserve(C->varlist_size());
11306 for (auto *VE : C->varlist()) {
11307 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11308 if (EVar.isInvalid())
11309 return nullptr;
11310 Vars.push_back(EVar.get());
11311 }
11312 CXXScopeSpec ReductionIdScopeSpec;
11313 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11314
11315 DeclarationNameInfo NameInfo = C->getNameInfo();
11316 if (NameInfo.getName()) {
11317 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11318 if (!NameInfo.getName())
11319 return nullptr;
11320 }
11321 // Build a list of all UDR decls with the same names ranged by the Scopes.
11322 // The Scope boundary is a duplication of the previous decl.
11323 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11324 for (auto *E : C->reduction_ops()) {
11325 // Transform all the decls.
11326 if (E) {
11327 auto *ULE = cast<UnresolvedLookupExpr>(E);
11328 UnresolvedSet<8> Decls;
11329 for (auto *D : ULE->decls()) {
11330 NamedDecl *InstD =
11331 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11332 Decls.addDecl(InstD, InstD->getAccess());
11333 }
11334 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11335 SemaRef.Context, /*NamingClass=*/nullptr,
11336 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11337 /*ADL=*/true, Decls.begin(), Decls.end(),
11338 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11339 } else
11340 UnresolvedReductions.push_back(nullptr);
11341 }
11342 return getDerived().RebuildOMPInReductionClause(
11343 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11344 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11345}
11346
11347template <typename Derived>
11348OMPClause *
11351 Vars.reserve(C->varlist_size());
11352 for (auto *VE : C->varlist()) {
11353 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11354 if (EVar.isInvalid())
11355 return nullptr;
11356 Vars.push_back(EVar.get());
11357 }
11358 ExprResult Step = getDerived().TransformExpr(C->getStep());
11359 if (Step.isInvalid())
11360 return nullptr;
11361 return getDerived().RebuildOMPLinearClause(
11362 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11363 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11364 C->getEndLoc());
11365}
11366
11367template <typename Derived>
11368OMPClause *
11371 Vars.reserve(C->varlist_size());
11372 for (auto *VE : C->varlist()) {
11373 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11374 if (EVar.isInvalid())
11375 return nullptr;
11376 Vars.push_back(EVar.get());
11377 }
11378 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11379 if (Alignment.isInvalid())
11380 return nullptr;
11381 return getDerived().RebuildOMPAlignedClause(
11382 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11383 C->getColonLoc(), C->getEndLoc());
11384}
11385
11386template <typename Derived>
11387OMPClause *
11390 Vars.reserve(C->varlist_size());
11391 for (auto *VE : C->varlist()) {
11392 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11393 if (EVar.isInvalid())
11394 return nullptr;
11395 Vars.push_back(EVar.get());
11396 }
11397 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11398 C->getLParenLoc(), C->getEndLoc());
11399}
11400
11401template <typename Derived>
11402OMPClause *
11405 Vars.reserve(C->varlist_size());
11406 for (auto *VE : C->varlist()) {
11407 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11408 if (EVar.isInvalid())
11409 return nullptr;
11410 Vars.push_back(EVar.get());
11411 }
11412 return getDerived().RebuildOMPCopyprivateClause(
11413 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11414}
11415
11416template <typename Derived>
11419 Vars.reserve(C->varlist_size());
11420 for (auto *VE : C->varlist()) {
11421 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11422 if (EVar.isInvalid())
11423 return nullptr;
11424 Vars.push_back(EVar.get());
11425 }
11426 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11427 C->getLParenLoc(), C->getEndLoc());
11428}
11429
11430template <typename Derived>
11431OMPClause *
11433 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11434 if (E.isInvalid())
11435 return nullptr;
11436 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11437 C->getLParenLoc(), C->getEndLoc());
11438}
11439
11440template <typename Derived>
11441OMPClause *
11444 Expr *DepModifier = C->getModifier();
11445 if (DepModifier) {
11446 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11447 if (DepModRes.isInvalid())
11448 return nullptr;
11449 DepModifier = DepModRes.get();
11450 }
11451 Vars.reserve(C->varlist_size());
11452 for (auto *VE : C->varlist()) {
11453 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11454 if (EVar.isInvalid())
11455 return nullptr;
11456 Vars.push_back(EVar.get());
11457 }
11458 return getDerived().RebuildOMPDependClause(
11459 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11460 C->getOmpAllMemoryLoc()},
11461 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11462}
11463
11464template <typename Derived>
11465OMPClause *
11467 ExprResult E = getDerived().TransformExpr(C->getDevice());
11468 if (E.isInvalid())
11469 return nullptr;
11470 return getDerived().RebuildOMPDeviceClause(
11471 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11472 C->getModifierLoc(), C->getEndLoc());
11473}
11474
11475template <typename Derived, class T>
11478 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11479 DeclarationNameInfo &MapperIdInfo,
11480 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11481 // Transform expressions in the list.
11482 Vars.reserve(C->varlist_size());
11483 for (auto *VE : C->varlist()) {
11484 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11485 if (EVar.isInvalid())
11486 return true;
11487 Vars.push_back(EVar.get());
11488 }
11489 // Transform mapper scope specifier and identifier.
11490 NestedNameSpecifierLoc QualifierLoc;
11491 if (C->getMapperQualifierLoc()) {
11492 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11493 C->getMapperQualifierLoc());
11494 if (!QualifierLoc)
11495 return true;
11496 }
11497 MapperIdScopeSpec.Adopt(QualifierLoc);
11498 MapperIdInfo = C->getMapperIdInfo();
11499 if (MapperIdInfo.getName()) {
11500 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11501 if (!MapperIdInfo.getName())
11502 return true;
11503 }
11504 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11505 // the previous user-defined mapper lookup in dependent environment.
11506 for (auto *E : C->mapperlists()) {
11507 // Transform all the decls.
11508 if (E) {
11509 auto *ULE = cast<UnresolvedLookupExpr>(E);
11510 UnresolvedSet<8> Decls;
11511 for (auto *D : ULE->decls()) {
11512 NamedDecl *InstD =
11513 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11514 Decls.addDecl(InstD, InstD->getAccess());
11515 }
11516 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11517 TT.getSema().Context, /*NamingClass=*/nullptr,
11518 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11519 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11520 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11521 } else {
11522 UnresolvedMappers.push_back(nullptr);
11523 }
11524 }
11525 return false;
11526}
11527
11528template <typename Derived>
11529OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11530 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11532 Expr *IteratorModifier = C->getIteratorModifier();
11533 if (IteratorModifier) {
11534 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11535 if (MapModRes.isInvalid())
11536 return nullptr;
11537 IteratorModifier = MapModRes.get();
11538 }
11539 CXXScopeSpec MapperIdScopeSpec;
11540 DeclarationNameInfo MapperIdInfo;
11541 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11543 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11544 return nullptr;
11545 return getDerived().RebuildOMPMapClause(
11546 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11547 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11548 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11549}
11550
11551template <typename Derived>
11552OMPClause *
11554 Expr *Allocator = C->getAllocator();
11555 if (Allocator) {
11556 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11557 if (AllocatorRes.isInvalid())
11558 return nullptr;
11559 Allocator = AllocatorRes.get();
11560 }
11561 Expr *Alignment = C->getAlignment();
11562 if (Alignment) {
11563 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11564 if (AlignmentRes.isInvalid())
11565 return nullptr;
11566 Alignment = AlignmentRes.get();
11567 }
11569 Vars.reserve(C->varlist_size());
11570 for (auto *VE : C->varlist()) {
11571 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11572 if (EVar.isInvalid())
11573 return nullptr;
11574 Vars.push_back(EVar.get());
11575 }
11576 return getDerived().RebuildOMPAllocateClause(
11577 Allocator, Alignment, C->getFirstAllocateModifier(),
11578 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11579 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11580 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11581}
11582
11583template <typename Derived>
11584OMPClause *
11587 Vars.reserve(C->varlist_size());
11588 for (auto *VE : C->varlist()) {
11589 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11590 if (EVar.isInvalid())
11591 return nullptr;
11592 Vars.push_back(EVar.get());
11593 }
11594 return getDerived().RebuildOMPNumTeamsClause(
11595 Vars, C->getBeginLoc(), 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().RebuildOMPThreadLimitClause(
11610 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11611}
11612
11613template <typename Derived>
11614OMPClause *
11616 ExprResult E = getDerived().TransformExpr(C->getPriority());
11617 if (E.isInvalid())
11618 return nullptr;
11619 return getDerived().RebuildOMPPriorityClause(
11620 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11621}
11622
11623template <typename Derived>
11624OMPClause *
11626 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11627 if (E.isInvalid())
11628 return nullptr;
11629 return getDerived().RebuildOMPGrainsizeClause(
11630 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11631 C->getModifierLoc(), C->getEndLoc());
11632}
11633
11634template <typename Derived>
11635OMPClause *
11637 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11638 if (E.isInvalid())
11639 return nullptr;
11640 return getDerived().RebuildOMPNumTasksClause(
11641 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11642 C->getModifierLoc(), C->getEndLoc());
11643}
11644
11645template <typename Derived>
11647 ExprResult E = getDerived().TransformExpr(C->getHint());
11648 if (E.isInvalid())
11649 return nullptr;
11650 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11651 C->getLParenLoc(), C->getEndLoc());
11652}
11653
11654template <typename Derived>
11656 OMPDistScheduleClause *C) {
11657 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11658 if (E.isInvalid())
11659 return nullptr;
11660 return getDerived().RebuildOMPDistScheduleClause(
11661 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11662 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11663}
11664
11665template <typename Derived>
11666OMPClause *
11668 // Rebuild Defaultmap Clause since we need to invoke the checking of
11669 // defaultmap(none:variable-category) after template initialization.
11670 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11671 C->getDefaultmapKind(),
11672 C->getBeginLoc(),
11673 C->getLParenLoc(),
11674 C->getDefaultmapModifierLoc(),
11675 C->getDefaultmapKindLoc(),
11676 C->getEndLoc());
11677}
11678
11679template <typename Derived>
11681 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11683 Expr *IteratorModifier = C->getIteratorModifier();
11684 if (IteratorModifier) {
11685 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11686 if (MapModRes.isInvalid())
11687 return nullptr;
11688 IteratorModifier = MapModRes.get();
11689 }
11690 CXXScopeSpec MapperIdScopeSpec;
11691 DeclarationNameInfo MapperIdInfo;
11692 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11694 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11695 return nullptr;
11696 return getDerived().RebuildOMPToClause(
11697 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11698 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11699 UnresolvedMappers);
11700}
11701
11702template <typename Derived>
11704 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11706 Expr *IteratorModifier = C->getIteratorModifier();
11707 if (IteratorModifier) {
11708 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11709 if (MapModRes.isInvalid())
11710 return nullptr;
11711 IteratorModifier = MapModRes.get();
11712 }
11713 CXXScopeSpec MapperIdScopeSpec;
11714 DeclarationNameInfo MapperIdInfo;
11715 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11717 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11718 return nullptr;
11719 return getDerived().RebuildOMPFromClause(
11720 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11721 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11722 UnresolvedMappers);
11723}
11724
11725template <typename Derived>
11727 OMPUseDevicePtrClause *C) {
11729 Vars.reserve(C->varlist_size());
11730 for (auto *VE : C->varlist()) {
11731 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11732 if (EVar.isInvalid())
11733 return nullptr;
11734 Vars.push_back(EVar.get());
11735 }
11736 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11737 return getDerived().RebuildOMPUseDevicePtrClause(
11738 Vars, Locs, C->getFallbackModifier(), C->getFallbackModifierLoc());
11739}
11740
11741template <typename Derived>
11743 OMPUseDeviceAddrClause *C) {
11745 Vars.reserve(C->varlist_size());
11746 for (auto *VE : C->varlist()) {
11747 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11748 if (EVar.isInvalid())
11749 return nullptr;
11750 Vars.push_back(EVar.get());
11751 }
11752 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11753 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11754}
11755
11756template <typename Derived>
11757OMPClause *
11760 Vars.reserve(C->varlist_size());
11761 for (auto *VE : C->varlist()) {
11762 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11763 if (EVar.isInvalid())
11764 return nullptr;
11765 Vars.push_back(EVar.get());
11766 }
11767 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11768 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11769}
11770
11771template <typename Derived>
11773 OMPHasDeviceAddrClause *C) {
11775 Vars.reserve(C->varlist_size());
11776 for (auto *VE : C->varlist()) {
11777 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11778 if (EVar.isInvalid())
11779 return nullptr;
11780 Vars.push_back(EVar.get());
11781 }
11782 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11783 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11784}
11785
11786template <typename Derived>
11787OMPClause *
11790 Vars.reserve(C->varlist_size());
11791 for (auto *VE : C->varlist()) {
11792 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11793 if (EVar.isInvalid())
11794 return nullptr;
11795 Vars.push_back(EVar.get());
11796 }
11797 return getDerived().RebuildOMPNontemporalClause(
11798 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11799}
11800
11801template <typename Derived>
11802OMPClause *
11805 Vars.reserve(C->varlist_size());
11806 for (auto *VE : C->varlist()) {
11807 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11808 if (EVar.isInvalid())
11809 return nullptr;
11810 Vars.push_back(EVar.get());
11811 }
11812 return getDerived().RebuildOMPInclusiveClause(
11813 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11814}
11815
11816template <typename Derived>
11817OMPClause *
11820 Vars.reserve(C->varlist_size());
11821 for (auto *VE : C->varlist()) {
11822 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11823 if (EVar.isInvalid())
11824 return nullptr;
11825 Vars.push_back(EVar.get());
11826 }
11827 return getDerived().RebuildOMPExclusiveClause(
11828 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11829}
11830
11831template <typename Derived>
11833 OMPUsesAllocatorsClause *C) {
11835 Data.reserve(C->getNumberOfAllocators());
11836 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11837 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11838 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11839 if (Allocator.isInvalid())
11840 continue;
11841 ExprResult AllocatorTraits;
11842 if (Expr *AT = D.AllocatorTraits) {
11843 AllocatorTraits = getDerived().TransformExpr(AT);
11844 if (AllocatorTraits.isInvalid())
11845 continue;
11846 }
11847 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11848 NewD.Allocator = Allocator.get();
11849 NewD.AllocatorTraits = AllocatorTraits.get();
11850 NewD.LParenLoc = D.LParenLoc;
11851 NewD.RParenLoc = D.RParenLoc;
11852 }
11853 return getDerived().RebuildOMPUsesAllocatorsClause(
11854 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11855}
11856
11857template <typename Derived>
11858OMPClause *
11860 SmallVector<Expr *, 4> Locators;
11861 Locators.reserve(C->varlist_size());
11862 ExprResult ModifierRes;
11863 if (Expr *Modifier = C->getModifier()) {
11864 ModifierRes = getDerived().TransformExpr(Modifier);
11865 if (ModifierRes.isInvalid())
11866 return nullptr;
11867 }
11868 for (Expr *E : C->varlist()) {
11869 ExprResult Locator = getDerived().TransformExpr(E);
11870 if (Locator.isInvalid())
11871 continue;
11872 Locators.push_back(Locator.get());
11873 }
11874 return getDerived().RebuildOMPAffinityClause(
11875 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11876 ModifierRes.get(), Locators);
11877}
11878
11879template <typename Derived>
11881 return getDerived().RebuildOMPOrderClause(
11882 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11883 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11884}
11885
11886template <typename Derived>
11888 return getDerived().RebuildOMPBindClause(
11889 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11890 C->getLParenLoc(), C->getEndLoc());
11891}
11892
11893template <typename Derived>
11895 OMPXDynCGroupMemClause *C) {
11896 ExprResult Size = getDerived().TransformExpr(C->getSize());
11897 if (Size.isInvalid())
11898 return nullptr;
11899 return getDerived().RebuildOMPXDynCGroupMemClause(
11900 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11901}
11902
11903template <typename Derived>
11905 OMPDynGroupprivateClause *C) {
11906 ExprResult Size = getDerived().TransformExpr(C->getSize());
11907 if (Size.isInvalid())
11908 return nullptr;
11909 return getDerived().RebuildOMPDynGroupprivateClause(
11910 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
11911 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
11912 C->getDynGroupprivateModifierLoc(),
11913 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
11914}
11915
11916template <typename Derived>
11917OMPClause *
11920 Vars.reserve(C->varlist_size());
11921 for (auto *VE : C->varlist()) {
11922 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11923 if (EVar.isInvalid())
11924 return nullptr;
11925 Vars.push_back(EVar.get());
11926 }
11927 return getDerived().RebuildOMPDoacrossClause(
11928 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11929 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11930}
11931
11932template <typename Derived>
11933OMPClause *
11936 for (auto *A : C->getAttrs())
11937 NewAttrs.push_back(getDerived().TransformAttr(A));
11938 return getDerived().RebuildOMPXAttributeClause(
11939 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11940}
11941
11942template <typename Derived>
11944 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11945}
11946
11947//===----------------------------------------------------------------------===//
11948// OpenACC transformation
11949//===----------------------------------------------------------------------===//
11950namespace {
11951template <typename Derived>
11952class OpenACCClauseTransform final
11953 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11954 TreeTransform<Derived> &Self;
11955 ArrayRef<const OpenACCClause *> ExistingClauses;
11956 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11957 OpenACCClause *NewClause = nullptr;
11958
11959 ExprResult VisitVar(Expr *VarRef) {
11960 ExprResult Res = Self.TransformExpr(VarRef);
11961
11962 if (!Res.isUsable())
11963 return Res;
11964
11965 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11966 ParsedClause.getClauseKind(),
11967 Res.get());
11968
11969 return Res;
11970 }
11971
11972 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11973 llvm::SmallVector<Expr *> InstantiatedVarList;
11974 for (Expr *CurVar : VarList) {
11975 ExprResult VarRef = VisitVar(CurVar);
11976
11977 if (VarRef.isUsable())
11978 InstantiatedVarList.push_back(VarRef.get());
11979 }
11980
11981 return InstantiatedVarList;
11982 }
11983
11984public:
11985 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11986 ArrayRef<const OpenACCClause *> ExistingClauses,
11987 SemaOpenACC::OpenACCParsedClause &PC)
11988 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
11989
11990 OpenACCClause *CreatedClause() const { return NewClause; }
11991
11992#define VISIT_CLAUSE(CLAUSE_NAME) \
11993 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11994#include "clang/Basic/OpenACCClauses.def"
11995};
11996
11997template <typename Derived>
11998void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11999 const OpenACCDefaultClause &C) {
12000 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
12001
12002 NewClause = OpenACCDefaultClause::Create(
12003 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
12004 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12005 ParsedClause.getEndLoc());
12006}
12007
12008template <typename Derived>
12009void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
12010 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12011 assert(Cond && "If constructed with invalid Condition");
12012 Sema::ConditionResult Res = Self.TransformCondition(
12013 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
12014
12015 if (Res.isInvalid() || !Res.get().second)
12016 return;
12017
12018 ParsedClause.setConditionDetails(Res.get().second);
12019
12020 NewClause = OpenACCIfClause::Create(
12021 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12022 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12023 ParsedClause.getEndLoc());
12024}
12025
12026template <typename Derived>
12027void OpenACCClauseTransform<Derived>::VisitSelfClause(
12028 const OpenACCSelfClause &C) {
12029
12030 // If this is an 'update' 'self' clause, this is actually a var list instead.
12031 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
12032 llvm::SmallVector<Expr *> InstantiatedVarList;
12033 for (Expr *CurVar : C.getVarList()) {
12034 ExprResult Res = Self.TransformExpr(CurVar);
12035
12036 if (!Res.isUsable())
12037 continue;
12038
12039 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
12040 ParsedClause.getClauseKind(),
12041 Res.get());
12042
12043 if (Res.isUsable())
12044 InstantiatedVarList.push_back(Res.get());
12045 }
12046
12047 ParsedClause.setVarListDetails(InstantiatedVarList,
12049
12050 NewClause = OpenACCSelfClause::Create(
12051 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12052 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12053 ParsedClause.getEndLoc());
12054 } else {
12055
12056 if (C.hasConditionExpr()) {
12057 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12059 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
12061
12062 if (Res.isInvalid() || !Res.get().second)
12063 return;
12064
12065 ParsedClause.setConditionDetails(Res.get().second);
12066 }
12067
12068 NewClause = OpenACCSelfClause::Create(
12069 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12070 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12071 ParsedClause.getEndLoc());
12072 }
12073}
12074
12075template <typename Derived>
12076void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
12077 const OpenACCNumGangsClause &C) {
12078 llvm::SmallVector<Expr *> InstantiatedIntExprs;
12079
12080 for (Expr *CurIntExpr : C.getIntExprs()) {
12081 ExprResult Res = Self.TransformExpr(CurIntExpr);
12082
12083 if (!Res.isUsable())
12084 return;
12085
12086 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12087 C.getClauseKind(),
12088 C.getBeginLoc(), Res.get());
12089 if (!Res.isUsable())
12090 return;
12091
12092 InstantiatedIntExprs.push_back(Res.get());
12093 }
12094
12095 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
12097 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12098 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12099 ParsedClause.getEndLoc());
12100}
12101
12102template <typename Derived>
12103void OpenACCClauseTransform<Derived>::VisitPrivateClause(
12104 const OpenACCPrivateClause &C) {
12105 llvm::SmallVector<Expr *> InstantiatedVarList;
12107
12108 for (const auto [RefExpr, InitRecipe] :
12109 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12110 ExprResult VarRef = VisitVar(RefExpr);
12111
12112 if (VarRef.isUsable()) {
12113 InstantiatedVarList.push_back(VarRef.get());
12114
12115 // We only have to create a new one if it is dependent, and Sema won't
12116 // make one of these unless the type is non-dependent.
12117 if (InitRecipe.isSet())
12118 InitRecipes.push_back(InitRecipe);
12119 else
12120 InitRecipes.push_back(
12121 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
12122 }
12123 }
12124 ParsedClause.setVarListDetails(InstantiatedVarList,
12126
12127 NewClause = OpenACCPrivateClause::Create(
12128 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12129 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12130 ParsedClause.getEndLoc());
12131}
12132
12133template <typename Derived>
12134void OpenACCClauseTransform<Derived>::VisitHostClause(
12135 const OpenACCHostClause &C) {
12136 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12138
12139 NewClause = OpenACCHostClause::Create(
12140 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12141 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12142 ParsedClause.getEndLoc());
12143}
12144
12145template <typename Derived>
12146void OpenACCClauseTransform<Derived>::VisitDeviceClause(
12147 const OpenACCDeviceClause &C) {
12148 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12150
12151 NewClause = OpenACCDeviceClause::Create(
12152 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12153 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12154 ParsedClause.getEndLoc());
12155}
12156
12157template <typename Derived>
12158void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
12160 llvm::SmallVector<Expr *> InstantiatedVarList;
12162
12163 for (const auto [RefExpr, InitRecipe] :
12164 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12165 ExprResult VarRef = VisitVar(RefExpr);
12166
12167 if (VarRef.isUsable()) {
12168 InstantiatedVarList.push_back(VarRef.get());
12169
12170 // We only have to create a new one if it is dependent, and Sema won't
12171 // make one of these unless the type is non-dependent.
12172 if (InitRecipe.isSet())
12173 InitRecipes.push_back(InitRecipe);
12174 else
12175 InitRecipes.push_back(
12176 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12177 VarRef.get()));
12178 }
12179 }
12180 ParsedClause.setVarListDetails(InstantiatedVarList,
12182
12184 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12185 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12186 ParsedClause.getEndLoc());
12187}
12188
12189template <typename Derived>
12190void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12191 const OpenACCNoCreateClause &C) {
12192 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12194
12196 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12197 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12198 ParsedClause.getEndLoc());
12199}
12200
12201template <typename Derived>
12202void OpenACCClauseTransform<Derived>::VisitPresentClause(
12203 const OpenACCPresentClause &C) {
12204 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12206
12207 NewClause = OpenACCPresentClause::Create(
12208 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12209 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12210 ParsedClause.getEndLoc());
12211}
12212
12213template <typename Derived>
12214void OpenACCClauseTransform<Derived>::VisitCopyClause(
12215 const OpenACCCopyClause &C) {
12216 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12217 C.getModifierList());
12218
12219 NewClause = OpenACCCopyClause::Create(
12220 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12221 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12222 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12223 ParsedClause.getEndLoc());
12224}
12225
12226template <typename Derived>
12227void OpenACCClauseTransform<Derived>::VisitLinkClause(
12228 const OpenACCLinkClause &C) {
12229 llvm_unreachable("link clause not valid unless a decl transform");
12230}
12231
12232template <typename Derived>
12233void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12235 llvm_unreachable("device_resident clause not valid unless a decl transform");
12236}
12237template <typename Derived>
12238void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12239 const OpenACCNoHostClause &C) {
12240 llvm_unreachable("nohost clause not valid unless a decl transform");
12241}
12242template <typename Derived>
12243void OpenACCClauseTransform<Derived>::VisitBindClause(
12244 const OpenACCBindClause &C) {
12245 llvm_unreachable("bind clause not valid unless a decl transform");
12246}
12247
12248template <typename Derived>
12249void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12250 const OpenACCCopyInClause &C) {
12251 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12252 C.getModifierList());
12253
12254 NewClause = OpenACCCopyInClause::Create(
12255 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12256 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12257 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12258 ParsedClause.getEndLoc());
12259}
12260
12261template <typename Derived>
12262void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12263 const OpenACCCopyOutClause &C) {
12264 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12265 C.getModifierList());
12266
12267 NewClause = OpenACCCopyOutClause::Create(
12268 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12269 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12270 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12271 ParsedClause.getEndLoc());
12272}
12273
12274template <typename Derived>
12275void OpenACCClauseTransform<Derived>::VisitCreateClause(
12276 const OpenACCCreateClause &C) {
12277 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12278 C.getModifierList());
12279
12280 NewClause = OpenACCCreateClause::Create(
12281 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12282 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12283 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12284 ParsedClause.getEndLoc());
12285}
12286template <typename Derived>
12287void OpenACCClauseTransform<Derived>::VisitAttachClause(
12288 const OpenACCAttachClause &C) {
12289 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12290
12291 // Ensure each var is a pointer type.
12292 llvm::erase_if(VarList, [&](Expr *E) {
12293 return Self.getSema().OpenACC().CheckVarIsPointerType(
12295 });
12296
12297 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12298 NewClause = OpenACCAttachClause::Create(
12299 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12300 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12301 ParsedClause.getEndLoc());
12302}
12303
12304template <typename Derived>
12305void OpenACCClauseTransform<Derived>::VisitDetachClause(
12306 const OpenACCDetachClause &C) {
12307 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12308
12309 // Ensure each var is a pointer type.
12310 llvm::erase_if(VarList, [&](Expr *E) {
12311 return Self.getSema().OpenACC().CheckVarIsPointerType(
12313 });
12314
12315 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12316 NewClause = OpenACCDetachClause::Create(
12317 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12318 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12319 ParsedClause.getEndLoc());
12320}
12321
12322template <typename Derived>
12323void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12324 const OpenACCDeleteClause &C) {
12325 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12327 NewClause = OpenACCDeleteClause::Create(
12328 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12329 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12330 ParsedClause.getEndLoc());
12331}
12332
12333template <typename Derived>
12334void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12335 const OpenACCUseDeviceClause &C) {
12336 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12339 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12340 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12341 ParsedClause.getEndLoc());
12342}
12343
12344template <typename Derived>
12345void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12346 const OpenACCDevicePtrClause &C) {
12347 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12348
12349 // Ensure each var is a pointer type.
12350 llvm::erase_if(VarList, [&](Expr *E) {
12351 return Self.getSema().OpenACC().CheckVarIsPointerType(
12353 });
12354
12355 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12357 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12358 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12359 ParsedClause.getEndLoc());
12360}
12361
12362template <typename Derived>
12363void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12364 const OpenACCNumWorkersClause &C) {
12365 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12366 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12367
12368 ExprResult Res = Self.TransformExpr(IntExpr);
12369 if (!Res.isUsable())
12370 return;
12371
12372 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12373 C.getClauseKind(),
12374 C.getBeginLoc(), Res.get());
12375 if (!Res.isUsable())
12376 return;
12377
12378 ParsedClause.setIntExprDetails(Res.get());
12380 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12381 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12382 ParsedClause.getEndLoc());
12383}
12384
12385template <typename Derived>
12386void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12387 const OpenACCDeviceNumClause &C) {
12388 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12389 assert(IntExpr && "device_num clause constructed with invalid int expr");
12390
12391 ExprResult Res = Self.TransformExpr(IntExpr);
12392 if (!Res.isUsable())
12393 return;
12394
12395 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12396 C.getClauseKind(),
12397 C.getBeginLoc(), Res.get());
12398 if (!Res.isUsable())
12399 return;
12400
12401 ParsedClause.setIntExprDetails(Res.get());
12403 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12404 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12405 ParsedClause.getEndLoc());
12406}
12407
12408template <typename Derived>
12409void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12411 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12412 assert(IntExpr && "default_async clause constructed with invalid int expr");
12413
12414 ExprResult Res = Self.TransformExpr(IntExpr);
12415 if (!Res.isUsable())
12416 return;
12417
12418 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12419 C.getClauseKind(),
12420 C.getBeginLoc(), Res.get());
12421 if (!Res.isUsable())
12422 return;
12423
12424 ParsedClause.setIntExprDetails(Res.get());
12426 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12427 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12428 ParsedClause.getEndLoc());
12429}
12430
12431template <typename Derived>
12432void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12434 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12435 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12436
12437 ExprResult Res = Self.TransformExpr(IntExpr);
12438 if (!Res.isUsable())
12439 return;
12440
12441 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12442 C.getClauseKind(),
12443 C.getBeginLoc(), Res.get());
12444 if (!Res.isUsable())
12445 return;
12446
12447 ParsedClause.setIntExprDetails(Res.get());
12449 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12450 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12451 ParsedClause.getEndLoc());
12452}
12453
12454template <typename Derived>
12455void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12456 const OpenACCAsyncClause &C) {
12457 if (C.hasIntExpr()) {
12458 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12459 if (!Res.isUsable())
12460 return;
12461
12462 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12463 C.getClauseKind(),
12464 C.getBeginLoc(), Res.get());
12465 if (!Res.isUsable())
12466 return;
12467 ParsedClause.setIntExprDetails(Res.get());
12468 }
12469
12470 NewClause = OpenACCAsyncClause::Create(
12471 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12472 ParsedClause.getLParenLoc(),
12473 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12474 : nullptr,
12475 ParsedClause.getEndLoc());
12476}
12477
12478template <typename Derived>
12479void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12480 const OpenACCWorkerClause &C) {
12481 if (C.hasIntExpr()) {
12482 // restrictions on this expression are all "does it exist in certain
12483 // situations" that are not possible to be dependent, so the only check we
12484 // have is that it transforms, and is an int expression.
12485 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12486 if (!Res.isUsable())
12487 return;
12488
12489 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12490 C.getClauseKind(),
12491 C.getBeginLoc(), Res.get());
12492 if (!Res.isUsable())
12493 return;
12494 ParsedClause.setIntExprDetails(Res.get());
12495 }
12496
12497 NewClause = OpenACCWorkerClause::Create(
12498 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12499 ParsedClause.getLParenLoc(),
12500 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12501 : nullptr,
12502 ParsedClause.getEndLoc());
12503}
12504
12505template <typename Derived>
12506void OpenACCClauseTransform<Derived>::VisitVectorClause(
12507 const OpenACCVectorClause &C) {
12508 if (C.hasIntExpr()) {
12509 // restrictions on this expression are all "does it exist in certain
12510 // situations" that are not possible to be dependent, so the only check we
12511 // have is that it transforms, and is an int expression.
12512 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12513 if (!Res.isUsable())
12514 return;
12515
12516 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12517 C.getClauseKind(),
12518 C.getBeginLoc(), Res.get());
12519 if (!Res.isUsable())
12520 return;
12521 ParsedClause.setIntExprDetails(Res.get());
12522 }
12523
12524 NewClause = OpenACCVectorClause::Create(
12525 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12526 ParsedClause.getLParenLoc(),
12527 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12528 : nullptr,
12529 ParsedClause.getEndLoc());
12530}
12531
12532template <typename Derived>
12533void OpenACCClauseTransform<Derived>::VisitWaitClause(
12534 const OpenACCWaitClause &C) {
12535 if (C.hasExprs()) {
12536 Expr *DevNumExpr = nullptr;
12537 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12538
12539 // Instantiate devnum expr if it exists.
12540 if (C.getDevNumExpr()) {
12541 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12542 if (!Res.isUsable())
12543 return;
12544 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12545 C.getClauseKind(),
12546 C.getBeginLoc(), Res.get());
12547 if (!Res.isUsable())
12548 return;
12549
12550 DevNumExpr = Res.get();
12551 }
12552
12553 // Instantiate queue ids.
12554 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12555 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12556 if (!Res.isUsable())
12557 return;
12558 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12559 C.getClauseKind(),
12560 C.getBeginLoc(), Res.get());
12561 if (!Res.isUsable())
12562 return;
12563
12564 InstantiatedQueueIdExprs.push_back(Res.get());
12565 }
12566
12567 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12568 std::move(InstantiatedQueueIdExprs));
12569 }
12570
12571 NewClause = OpenACCWaitClause::Create(
12572 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12573 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12574 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12575 ParsedClause.getEndLoc());
12576}
12577
12578template <typename Derived>
12579void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12580 const OpenACCDeviceTypeClause &C) {
12581 // Nothing to transform here, just create a new version of 'C'.
12583 Self.getSema().getASTContext(), C.getClauseKind(),
12584 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12585 C.getArchitectures(), ParsedClause.getEndLoc());
12586}
12587
12588template <typename Derived>
12589void OpenACCClauseTransform<Derived>::VisitAutoClause(
12590 const OpenACCAutoClause &C) {
12591 // Nothing to do, so just create a new node.
12592 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12593 ParsedClause.getBeginLoc(),
12594 ParsedClause.getEndLoc());
12595}
12596
12597template <typename Derived>
12598void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12599 const OpenACCIndependentClause &C) {
12600 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12601 ParsedClause.getBeginLoc(),
12602 ParsedClause.getEndLoc());
12603}
12604
12605template <typename Derived>
12606void OpenACCClauseTransform<Derived>::VisitSeqClause(
12607 const OpenACCSeqClause &C) {
12608 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12609 ParsedClause.getBeginLoc(),
12610 ParsedClause.getEndLoc());
12611}
12612template <typename Derived>
12613void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12614 const OpenACCFinalizeClause &C) {
12615 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12616 ParsedClause.getBeginLoc(),
12617 ParsedClause.getEndLoc());
12618}
12619
12620template <typename Derived>
12621void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12622 const OpenACCIfPresentClause &C) {
12623 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12624 ParsedClause.getBeginLoc(),
12625 ParsedClause.getEndLoc());
12626}
12627
12628template <typename Derived>
12629void OpenACCClauseTransform<Derived>::VisitReductionClause(
12630 const OpenACCReductionClause &C) {
12631 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12632 SmallVector<Expr *> ValidVars;
12634
12635 for (const auto [Var, OrigRecipe] :
12636 llvm::zip(TransformedVars, C.getRecipes())) {
12637 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12638 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12639 if (Res.isUsable()) {
12640 ValidVars.push_back(Res.get());
12641
12642 if (OrigRecipe.isSet())
12643 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
12644 else
12645 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
12646 C.getReductionOp(), Res.get()));
12647 }
12648 }
12649
12650 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12651 ExistingClauses, ParsedClause.getDirectiveKind(),
12652 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12653 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
12654}
12655
12656template <typename Derived>
12657void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12658 const OpenACCCollapseClause &C) {
12659 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12660 assert(LoopCount && "collapse clause constructed with invalid loop count");
12661
12662 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12663
12664 if (!NewLoopCount.isUsable())
12665 return;
12666
12667 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12668 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12669 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12670
12671 // FIXME: It isn't clear whether this is properly tested here, we should
12672 // probably see if we can come up with a test for this.
12673 if (!NewLoopCount.isUsable())
12674 return;
12675
12676 NewLoopCount =
12677 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12678
12679 // FIXME: It isn't clear whether this is properly tested here, we should
12680 // probably see if we can come up with a test for this.
12681 if (!NewLoopCount.isUsable())
12682 return;
12683
12684 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12686 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12687 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12688 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12689}
12690
12691template <typename Derived>
12692void OpenACCClauseTransform<Derived>::VisitTileClause(
12693 const OpenACCTileClause &C) {
12694
12695 llvm::SmallVector<Expr *> TransformedExprs;
12696
12697 for (Expr *E : C.getSizeExprs()) {
12698 ExprResult NewSizeExpr = Self.TransformExpr(E);
12699
12700 if (!NewSizeExpr.isUsable())
12701 return;
12702
12703 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12704 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12705 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12706
12707 // FIXME: It isn't clear whether this is properly tested here, we should
12708 // probably see if we can come up with a test for this.
12709 if (!NewSizeExpr.isUsable())
12710 return;
12711
12712 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12713
12714 if (!NewSizeExpr.isUsable())
12715 return;
12716 TransformedExprs.push_back(NewSizeExpr.get());
12717 }
12718
12719 ParsedClause.setIntExprDetails(TransformedExprs);
12720 NewClause = OpenACCTileClause::Create(
12721 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12722 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12723 ParsedClause.getEndLoc());
12724}
12725template <typename Derived>
12726void OpenACCClauseTransform<Derived>::VisitGangClause(
12727 const OpenACCGangClause &C) {
12728 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12729 llvm::SmallVector<Expr *> TransformedIntExprs;
12730
12731 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12732 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12733 if (!ER.isUsable())
12734 continue;
12735
12736 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12737 ParsedClause.getDirectiveKind(),
12738 C.getExpr(I).first, ER.get());
12739 if (!ER.isUsable())
12740 continue;
12741 TransformedGangKinds.push_back(C.getExpr(I).first);
12742 TransformedIntExprs.push_back(ER.get());
12743 }
12744
12745 NewClause = Self.getSema().OpenACC().CheckGangClause(
12746 ParsedClause.getDirectiveKind(), ExistingClauses,
12747 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12748 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12749}
12750} // namespace
12751template <typename Derived>
12752OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12753 ArrayRef<const OpenACCClause *> ExistingClauses,
12754 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12755
12757 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12758 ParsedClause.setEndLoc(OldClause->getEndLoc());
12759
12760 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12761 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12762
12763 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12764 ParsedClause};
12765 Transform.Visit(OldClause);
12766
12767 return Transform.CreatedClause();
12768}
12769
12770template <typename Derived>
12772TreeTransform<Derived>::TransformOpenACCClauseList(
12774 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12775 for (const auto *Clause : OldClauses) {
12776 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12777 TransformedClauses, DirKind, Clause))
12778 TransformedClauses.push_back(TransformedClause);
12779 }
12780 return TransformedClauses;
12781}
12782
12783template <typename Derived>
12786 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12787
12788 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12789 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12790 C->clauses());
12791
12792 if (getSema().OpenACC().ActOnStartStmtDirective(
12793 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12794 return StmtError();
12795
12796 // Transform Structured Block.
12797 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12798 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12799 C->clauses(), TransformedClauses);
12800 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12801 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12802 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12803
12804 return getDerived().RebuildOpenACCComputeConstruct(
12805 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12806 C->getEndLoc(), TransformedClauses, StrBlock);
12807}
12808
12809template <typename Derived>
12812
12813 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12814
12815 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12816 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12817 C->clauses());
12818
12819 if (getSema().OpenACC().ActOnStartStmtDirective(
12820 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12821 return StmtError();
12822
12823 // Transform Loop.
12824 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12825 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12826 C->clauses(), TransformedClauses);
12827 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12828 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12829 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12830
12831 return getDerived().RebuildOpenACCLoopConstruct(
12832 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12833 TransformedClauses, Loop);
12834}
12835
12836template <typename Derived>
12838 OpenACCCombinedConstruct *C) {
12839 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12840
12841 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12842 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12843 C->clauses());
12844
12845 if (getSema().OpenACC().ActOnStartStmtDirective(
12846 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12847 return StmtError();
12848
12849 // Transform Loop.
12850 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12851 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12852 C->clauses(), TransformedClauses);
12853 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12854 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12855 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12856
12857 return getDerived().RebuildOpenACCCombinedConstruct(
12858 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12859 C->getEndLoc(), TransformedClauses, Loop);
12860}
12861
12862template <typename Derived>
12865 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12866
12867 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12868 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12869 C->clauses());
12870 if (getSema().OpenACC().ActOnStartStmtDirective(
12871 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12872 return StmtError();
12873
12874 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12875 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12876 C->clauses(), TransformedClauses);
12877 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12878 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12879 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12880
12881 return getDerived().RebuildOpenACCDataConstruct(
12882 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12883 TransformedClauses, StrBlock);
12884}
12885
12886template <typename Derived>
12888 OpenACCEnterDataConstruct *C) {
12889 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12890
12891 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12892 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12893 C->clauses());
12894 if (getSema().OpenACC().ActOnStartStmtDirective(
12895 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12896 return StmtError();
12897
12898 return getDerived().RebuildOpenACCEnterDataConstruct(
12899 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12900 TransformedClauses);
12901}
12902
12903template <typename Derived>
12905 OpenACCExitDataConstruct *C) {
12906 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12907
12908 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12909 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12910 C->clauses());
12911 if (getSema().OpenACC().ActOnStartStmtDirective(
12912 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12913 return StmtError();
12914
12915 return getDerived().RebuildOpenACCExitDataConstruct(
12916 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12917 TransformedClauses);
12918}
12919
12920template <typename Derived>
12922 OpenACCHostDataConstruct *C) {
12923 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12924
12925 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12926 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12927 C->clauses());
12928 if (getSema().OpenACC().ActOnStartStmtDirective(
12929 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12930 return StmtError();
12931
12932 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12933 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12934 C->clauses(), TransformedClauses);
12935 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12936 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12937 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12938
12939 return getDerived().RebuildOpenACCHostDataConstruct(
12940 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12941 TransformedClauses, StrBlock);
12942}
12943
12944template <typename Derived>
12947 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12948
12949 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12950 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12951 C->clauses());
12952 if (getSema().OpenACC().ActOnStartStmtDirective(
12953 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12954 return StmtError();
12955
12956 return getDerived().RebuildOpenACCInitConstruct(
12957 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12958 TransformedClauses);
12959}
12960
12961template <typename Derived>
12963 OpenACCShutdownConstruct *C) {
12964 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12965
12966 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12967 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12968 C->clauses());
12969 if (getSema().OpenACC().ActOnStartStmtDirective(
12970 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12971 return StmtError();
12972
12973 return getDerived().RebuildOpenACCShutdownConstruct(
12974 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12975 TransformedClauses);
12976}
12977template <typename Derived>
12980 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12981
12982 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12983 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12984 C->clauses());
12985 if (getSema().OpenACC().ActOnStartStmtDirective(
12986 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12987 return StmtError();
12988
12989 return getDerived().RebuildOpenACCSetConstruct(
12990 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12991 TransformedClauses);
12992}
12993
12994template <typename Derived>
12996 OpenACCUpdateConstruct *C) {
12997 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12998
12999 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13000 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13001 C->clauses());
13002 if (getSema().OpenACC().ActOnStartStmtDirective(
13003 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13004 return StmtError();
13005
13006 return getDerived().RebuildOpenACCUpdateConstruct(
13007 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13008 TransformedClauses);
13009}
13010
13011template <typename Derived>
13014 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13015
13016 ExprResult DevNumExpr;
13017 if (C->hasDevNumExpr()) {
13018 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
13019
13020 if (DevNumExpr.isUsable())
13021 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
13023 C->getBeginLoc(), DevNumExpr.get());
13024 }
13025
13026 llvm::SmallVector<Expr *> QueueIdExprs;
13027
13028 for (Expr *QE : C->getQueueIdExprs()) {
13029 assert(QE && "Null queue id expr?");
13030 ExprResult NewEQ = getDerived().TransformExpr(QE);
13031
13032 if (!NewEQ.isUsable())
13033 break;
13034 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
13036 C->getBeginLoc(), NewEQ.get());
13037 if (NewEQ.isUsable())
13038 QueueIdExprs.push_back(NewEQ.get());
13039 }
13040
13041 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13042 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13043 C->clauses());
13044
13045 if (getSema().OpenACC().ActOnStartStmtDirective(
13046 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13047 return StmtError();
13048
13049 return getDerived().RebuildOpenACCWaitConstruct(
13050 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13051 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
13052 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
13053}
13054template <typename Derived>
13056 OpenACCCacheConstruct *C) {
13057 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13058
13059 llvm::SmallVector<Expr *> TransformedVarList;
13060 for (Expr *Var : C->getVarList()) {
13061 assert(Var && "Null var listexpr?");
13062
13063 ExprResult NewVar = getDerived().TransformExpr(Var);
13064
13065 if (!NewVar.isUsable())
13066 break;
13067
13068 NewVar = getSema().OpenACC().ActOnVar(
13069 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
13070 if (!NewVar.isUsable())
13071 break;
13072
13073 TransformedVarList.push_back(NewVar.get());
13074 }
13075
13076 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13077 C->getBeginLoc(), {}))
13078 return StmtError();
13079
13080 return getDerived().RebuildOpenACCCacheConstruct(
13081 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13082 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
13083 C->getEndLoc());
13084}
13085
13086template <typename Derived>
13088 OpenACCAtomicConstruct *C) {
13089 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13090
13091 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13092 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13093 C->clauses());
13094
13095 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13096 C->getBeginLoc(), {}))
13097 return StmtError();
13098
13099 // Transform Associated Stmt.
13100 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13101 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
13102
13103 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
13104 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
13105 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
13106 AssocStmt);
13107
13108 return getDerived().RebuildOpenACCAtomicConstruct(
13109 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
13110 C->getEndLoc(), TransformedClauses, AssocStmt);
13111}
13112
13113template <typename Derived>
13116 if (getDerived().AlwaysRebuild())
13117 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
13118 // Nothing can ever change, so there is never anything to transform.
13119 return E;
13120}
13121
13122//===----------------------------------------------------------------------===//
13123// Expression transformation
13124//===----------------------------------------------------------------------===//
13125template<typename Derived>
13128 return TransformExpr(E->getSubExpr());
13129}
13130
13131template <typename Derived>
13134 if (!E->isTypeDependent())
13135 return E;
13136
13137 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
13138
13139 if (!NewT)
13140 return ExprError();
13141
13142 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
13143 return E;
13144
13145 return getDerived().RebuildSYCLUniqueStableNameExpr(
13146 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
13147}
13148
13149template <typename Derived>
13152 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
13153 const auto *SKEPAttr = FD->template getAttr<SYCLKernelEntryPointAttr>();
13154 if (!SKEPAttr || SKEPAttr->isInvalidAttr())
13155 return StmtError();
13156
13157 ExprResult IdExpr = getDerived().TransformExpr(S->getKernelLaunchIdExpr());
13158 if (IdExpr.isInvalid())
13159 return StmtError();
13160
13161 StmtResult Body = getDerived().TransformStmt(S->getOriginalStmt());
13162 if (Body.isInvalid())
13163 return StmtError();
13164
13166 cast<FunctionDecl>(SemaRef.CurContext), cast<CompoundStmt>(Body.get()),
13167 IdExpr.get());
13168 if (SR.isInvalid())
13169 return StmtError();
13170
13171 return SR;
13172}
13173
13174template <typename Derived>
13176 // TODO(reflection): Implement its transform
13177 assert(false && "not implemented yet");
13178 return ExprError();
13179}
13180
13181template<typename Derived>
13184 if (!E->isTypeDependent())
13185 return E;
13186
13187 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13188 E->getIdentKind());
13189}
13190
13191template<typename Derived>
13194 NestedNameSpecifierLoc QualifierLoc;
13195 if (E->getQualifierLoc()) {
13196 QualifierLoc
13197 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13198 if (!QualifierLoc)
13199 return ExprError();
13200 }
13201
13202 ValueDecl *ND
13203 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13204 E->getDecl()));
13205 if (!ND || ND->isInvalidDecl())
13206 return ExprError();
13207
13208 NamedDecl *Found = ND;
13209 if (E->getFoundDecl() != E->getDecl()) {
13210 Found = cast_or_null<NamedDecl>(
13211 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13212 if (!Found)
13213 return ExprError();
13214 }
13215
13216 DeclarationNameInfo NameInfo = E->getNameInfo();
13217 if (NameInfo.getName()) {
13218 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13219 if (!NameInfo.getName())
13220 return ExprError();
13221 }
13222
13223 if (!getDerived().AlwaysRebuild() &&
13224 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13225 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13226 Found == E->getFoundDecl() &&
13227 NameInfo.getName() == E->getDecl()->getDeclName() &&
13228 !E->hasExplicitTemplateArgs()) {
13229
13230 // Mark it referenced in the new context regardless.
13231 // FIXME: this is a bit instantiation-specific.
13232 SemaRef.MarkDeclRefReferenced(E);
13233
13234 return E;
13235 }
13236
13237 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13238 if (E->hasExplicitTemplateArgs()) {
13239 TemplateArgs = &TransArgs;
13240 TransArgs.setLAngleLoc(E->getLAngleLoc());
13241 TransArgs.setRAngleLoc(E->getRAngleLoc());
13242 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13243 E->getNumTemplateArgs(),
13244 TransArgs))
13245 return ExprError();
13246 }
13247
13248 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13249 Found, TemplateArgs);
13250}
13251
13252template<typename Derived>
13255 return E;
13256}
13257
13258template <typename Derived>
13260 FixedPointLiteral *E) {
13261 return E;
13262}
13263
13264template<typename Derived>
13267 return E;
13268}
13269
13270template<typename Derived>
13273 return E;
13274}
13275
13276template<typename Derived>
13279 return E;
13280}
13281
13282template<typename Derived>
13285 return E;
13286}
13287
13288template<typename Derived>
13291 return getDerived().TransformCallExpr(E);
13292}
13293
13294template<typename Derived>
13297 ExprResult ControllingExpr;
13298 TypeSourceInfo *ControllingType = nullptr;
13299 if (E->isExprPredicate())
13300 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13301 else
13302 ControllingType = getDerived().TransformType(E->getControllingType());
13303
13304 if (ControllingExpr.isInvalid() && !ControllingType)
13305 return ExprError();
13306
13307 SmallVector<Expr *, 4> AssocExprs;
13309 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13310 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13311 if (TSI) {
13312 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13313 if (!AssocType)
13314 return ExprError();
13315 AssocTypes.push_back(AssocType);
13316 } else {
13317 AssocTypes.push_back(nullptr);
13318 }
13319
13320 ExprResult AssocExpr =
13321 getDerived().TransformExpr(Assoc.getAssociationExpr());
13322 if (AssocExpr.isInvalid())
13323 return ExprError();
13324 AssocExprs.push_back(AssocExpr.get());
13325 }
13326
13327 if (!ControllingType)
13328 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13329 E->getDefaultLoc(),
13330 E->getRParenLoc(),
13331 ControllingExpr.get(),
13332 AssocTypes,
13333 AssocExprs);
13334 return getDerived().RebuildGenericSelectionExpr(
13335 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13336 ControllingType, AssocTypes, AssocExprs);
13337}
13338
13339template<typename Derived>
13342 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13343 if (SubExpr.isInvalid())
13344 return ExprError();
13345
13346 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13347 return E;
13348
13349 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13350 E->getRParen());
13351}
13352
13353/// The operand of a unary address-of operator has special rules: it's
13354/// allowed to refer to a non-static member of a class even if there's no 'this'
13355/// object available.
13356template<typename Derived>
13359 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13360 return getDerived().TransformDependentScopeDeclRefExpr(
13361 DRE, /*IsAddressOfOperand=*/true, nullptr);
13362 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13363 return getDerived().TransformUnresolvedLookupExpr(
13364 ULE, /*IsAddressOfOperand=*/true);
13365 else
13366 return getDerived().TransformExpr(E);
13367}
13368
13369template<typename Derived>
13372 ExprResult SubExpr;
13373 if (E->getOpcode() == UO_AddrOf)
13374 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13375 else
13376 SubExpr = TransformExpr(E->getSubExpr());
13377 if (SubExpr.isInvalid())
13378 return ExprError();
13379
13380 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13381 return E;
13382
13383 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13384 E->getOpcode(),
13385 SubExpr.get());
13386}
13387
13388template<typename Derived>
13390TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13391 // Transform the type.
13392 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13393 if (!Type)
13394 return ExprError();
13395
13396 // Transform all of the components into components similar to what the
13397 // parser uses.
13398 // FIXME: It would be slightly more efficient in the non-dependent case to
13399 // just map FieldDecls, rather than requiring the rebuilder to look for
13400 // the fields again. However, __builtin_offsetof is rare enough in
13401 // template code that we don't care.
13402 bool ExprChanged = false;
13403 typedef Sema::OffsetOfComponent Component;
13404 SmallVector<Component, 4> Components;
13405 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13406 const OffsetOfNode &ON = E->getComponent(I);
13407 Component Comp;
13408 Comp.isBrackets = true;
13409 Comp.LocStart = ON.getSourceRange().getBegin();
13410 Comp.LocEnd = ON.getSourceRange().getEnd();
13411 switch (ON.getKind()) {
13412 case OffsetOfNode::Array: {
13413 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13414 ExprResult Index = getDerived().TransformExpr(FromIndex);
13415 if (Index.isInvalid())
13416 return ExprError();
13417
13418 ExprChanged = ExprChanged || Index.get() != FromIndex;
13419 Comp.isBrackets = true;
13420 Comp.U.E = Index.get();
13421 break;
13422 }
13423
13426 Comp.isBrackets = false;
13427 Comp.U.IdentInfo = ON.getFieldName();
13428 if (!Comp.U.IdentInfo)
13429 continue;
13430
13431 break;
13432
13433 case OffsetOfNode::Base:
13434 // Will be recomputed during the rebuild.
13435 continue;
13436 }
13437
13438 Components.push_back(Comp);
13439 }
13440
13441 // If nothing changed, retain the existing expression.
13442 if (!getDerived().AlwaysRebuild() &&
13443 Type == E->getTypeSourceInfo() &&
13444 !ExprChanged)
13445 return E;
13446
13447 // Build a new offsetof expression.
13448 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13449 Components, E->getRParenLoc());
13450}
13451
13452template<typename Derived>
13455 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13456 "opaque value expression requires transformation");
13457 return E;
13458}
13459
13460template <typename Derived>
13463 bool Changed = false;
13464 for (Expr *C : E->subExpressions()) {
13465 ExprResult NewC = getDerived().TransformExpr(C);
13466 if (NewC.isInvalid())
13467 return ExprError();
13468 Children.push_back(NewC.get());
13469
13470 Changed |= NewC.get() != C;
13471 }
13472 if (!getDerived().AlwaysRebuild() && !Changed)
13473 return E;
13474 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13475 Children, E->getType());
13476}
13477
13478template<typename Derived>
13481 // Rebuild the syntactic form. The original syntactic form has
13482 // opaque-value expressions in it, so strip those away and rebuild
13483 // the result. This is a really awful way of doing this, but the
13484 // better solution (rebuilding the semantic expressions and
13485 // rebinding OVEs as necessary) doesn't work; we'd need
13486 // TreeTransform to not strip away implicit conversions.
13487 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13488 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13489 if (result.isInvalid()) return ExprError();
13490
13491 // If that gives us a pseudo-object result back, the pseudo-object
13492 // expression must have been an lvalue-to-rvalue conversion which we
13493 // should reapply.
13494 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13495 result = SemaRef.PseudoObject().checkRValue(result.get());
13496
13497 return result;
13498}
13499
13500template<typename Derived>
13504 if (E->isArgumentType()) {
13505 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13506
13507 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13508 if (!NewT)
13509 return ExprError();
13510
13511 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13512 return E;
13513
13514 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13515 E->getKind(),
13516 E->getSourceRange());
13517 }
13518
13519 // C++0x [expr.sizeof]p1:
13520 // The operand is either an expression, which is an unevaluated operand
13521 // [...]
13525
13526 // Try to recover if we have something like sizeof(T::X) where X is a type.
13527 // Notably, there must be *exactly* one set of parens if X is a type.
13528 TypeSourceInfo *RecoveryTSI = nullptr;
13529 ExprResult SubExpr;
13530 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13531 if (auto *DRE =
13532 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13533 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13534 PE, DRE, false, &RecoveryTSI);
13535 else
13536 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13537
13538 if (RecoveryTSI) {
13539 return getDerived().RebuildUnaryExprOrTypeTrait(
13540 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13541 } else if (SubExpr.isInvalid())
13542 return ExprError();
13543
13544 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13545 return E;
13546
13547 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13548 E->getOperatorLoc(),
13549 E->getKind(),
13550 E->getSourceRange());
13551}
13552
13553template<typename Derived>
13556 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13557 if (LHS.isInvalid())
13558 return ExprError();
13559
13560 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13561 if (RHS.isInvalid())
13562 return ExprError();
13563
13564
13565 if (!getDerived().AlwaysRebuild() &&
13566 LHS.get() == E->getLHS() &&
13567 RHS.get() == E->getRHS())
13568 return E;
13569
13570 return getDerived().RebuildArraySubscriptExpr(
13571 LHS.get(),
13572 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13573}
13574
13575template <typename Derived>
13578 ExprResult Base = getDerived().TransformExpr(E->getBase());
13579 if (Base.isInvalid())
13580 return ExprError();
13581
13582 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13583 if (RowIdx.isInvalid())
13584 return ExprError();
13585
13586 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13587 RowIdx.get() == E->getRowIdx())
13588 return E;
13589
13590 return getDerived().RebuildMatrixSingleSubscriptExpr(Base.get(), RowIdx.get(),
13591 E->getRBracketLoc());
13592}
13593
13594template <typename Derived>
13597 ExprResult Base = getDerived().TransformExpr(E->getBase());
13598 if (Base.isInvalid())
13599 return ExprError();
13600
13601 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13602 if (RowIdx.isInvalid())
13603 return ExprError();
13604
13605 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13606 if (ColumnIdx.isInvalid())
13607 return ExprError();
13608
13609 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13610 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13611 return E;
13612
13613 return getDerived().RebuildMatrixSubscriptExpr(
13614 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13615}
13616
13617template <typename Derived>
13620 ExprResult Base = getDerived().TransformExpr(E->getBase());
13621 if (Base.isInvalid())
13622 return ExprError();
13623
13624 ExprResult LowerBound;
13625 if (E->getLowerBound()) {
13626 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13627 if (LowerBound.isInvalid())
13628 return ExprError();
13629 }
13630
13631 ExprResult Length;
13632 if (E->getLength()) {
13633 Length = getDerived().TransformExpr(E->getLength());
13634 if (Length.isInvalid())
13635 return ExprError();
13636 }
13637
13638 ExprResult Stride;
13639 if (E->isOMPArraySection()) {
13640 if (Expr *Str = E->getStride()) {
13641 Stride = getDerived().TransformExpr(Str);
13642 if (Stride.isInvalid())
13643 return ExprError();
13644 }
13645 }
13646
13647 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13648 LowerBound.get() == E->getLowerBound() &&
13649 Length.get() == E->getLength() &&
13650 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13651 return E;
13652
13653 return getDerived().RebuildArraySectionExpr(
13654 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13655 LowerBound.get(), E->getColonLocFirst(),
13656 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13657 Length.get(), Stride.get(), E->getRBracketLoc());
13658}
13659
13660template <typename Derived>
13663 ExprResult Base = getDerived().TransformExpr(E->getBase());
13664 if (Base.isInvalid())
13665 return ExprError();
13666
13668 bool ErrorFound = false;
13669 for (Expr *Dim : E->getDimensions()) {
13670 ExprResult DimRes = getDerived().TransformExpr(Dim);
13671 if (DimRes.isInvalid()) {
13672 ErrorFound = true;
13673 continue;
13674 }
13675 Dims.push_back(DimRes.get());
13676 }
13677
13678 if (ErrorFound)
13679 return ExprError();
13680 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13681 E->getRParenLoc(), Dims,
13682 E->getBracketsRanges());
13683}
13684
13685template <typename Derived>
13688 unsigned NumIterators = E->numOfIterators();
13690
13691 bool ErrorFound = false;
13692 bool NeedToRebuild = getDerived().AlwaysRebuild();
13693 for (unsigned I = 0; I < NumIterators; ++I) {
13694 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13695 Data[I].DeclIdent = D->getIdentifier();
13696 Data[I].DeclIdentLoc = D->getLocation();
13697 if (D->getLocation() == D->getBeginLoc()) {
13698 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13699 "Implicit type must be int.");
13700 } else {
13701 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13702 QualType DeclTy = getDerived().TransformType(D->getType());
13703 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13704 }
13705 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13706 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13707 ExprResult End = getDerived().TransformExpr(Range.End);
13708 ExprResult Step = getDerived().TransformExpr(Range.Step);
13709 ErrorFound = ErrorFound ||
13710 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13711 !Data[I].Type.get().isNull())) ||
13712 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13713 if (ErrorFound)
13714 continue;
13715 Data[I].Range.Begin = Begin.get();
13716 Data[I].Range.End = End.get();
13717 Data[I].Range.Step = Step.get();
13718 Data[I].AssignLoc = E->getAssignLoc(I);
13719 Data[I].ColonLoc = E->getColonLoc(I);
13720 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13721 NeedToRebuild =
13722 NeedToRebuild ||
13723 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13724 D->getType().getTypePtrOrNull()) ||
13725 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13726 Range.Step != Data[I].Range.Step;
13727 }
13728 if (ErrorFound)
13729 return ExprError();
13730 if (!NeedToRebuild)
13731 return E;
13732
13733 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13734 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13735 if (!Res.isUsable())
13736 return Res;
13737 auto *IE = cast<OMPIteratorExpr>(Res.get());
13738 for (unsigned I = 0; I < NumIterators; ++I)
13739 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13740 IE->getIteratorDecl(I));
13741 return Res;
13742}
13743
13744template<typename Derived>
13747 // Transform the callee.
13748 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13749 if (Callee.isInvalid())
13750 return ExprError();
13751
13752 // Transform arguments.
13753 bool ArgChanged = false;
13755 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13756 &ArgChanged))
13757 return ExprError();
13758
13759 if (!getDerived().AlwaysRebuild() &&
13760 Callee.get() == E->getCallee() &&
13761 !ArgChanged)
13762 return SemaRef.MaybeBindToTemporary(E);
13763
13764 // FIXME: Wrong source location information for the '('.
13765 SourceLocation FakeLParenLoc
13766 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13767
13768 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13769 if (E->hasStoredFPFeatures()) {
13770 FPOptionsOverride NewOverrides = E->getFPFeatures();
13771 getSema().CurFPFeatures =
13772 NewOverrides.applyOverrides(getSema().getLangOpts());
13773 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13774 }
13775
13776 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13777 Args,
13778 E->getRParenLoc());
13779}
13780
13781template<typename Derived>
13784 ExprResult Base = getDerived().TransformExpr(E->getBase());
13785 if (Base.isInvalid())
13786 return ExprError();
13787
13788 NestedNameSpecifierLoc QualifierLoc;
13789 if (E->hasQualifier()) {
13790 QualifierLoc
13791 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13792
13793 if (!QualifierLoc)
13794 return ExprError();
13795 }
13796 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13797
13799 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13800 E->getMemberDecl()));
13801 if (!Member)
13802 return ExprError();
13803
13804 NamedDecl *FoundDecl = E->getFoundDecl();
13805 if (FoundDecl == E->getMemberDecl()) {
13806 FoundDecl = Member;
13807 } else {
13808 FoundDecl = cast_or_null<NamedDecl>(
13809 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13810 if (!FoundDecl)
13811 return ExprError();
13812 }
13813
13814 if (!getDerived().AlwaysRebuild() &&
13815 Base.get() == E->getBase() &&
13816 QualifierLoc == E->getQualifierLoc() &&
13817 Member == E->getMemberDecl() &&
13818 FoundDecl == E->getFoundDecl() &&
13819 !E->hasExplicitTemplateArgs()) {
13820
13821 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13822 // for Openmp where the field need to be privatizized in the case.
13823 if (!(isa<CXXThisExpr>(E->getBase()) &&
13824 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13826 // Mark it referenced in the new context regardless.
13827 // FIXME: this is a bit instantiation-specific.
13828 SemaRef.MarkMemberReferenced(E);
13829 return E;
13830 }
13831 }
13832
13833 TemplateArgumentListInfo TransArgs;
13834 if (E->hasExplicitTemplateArgs()) {
13835 TransArgs.setLAngleLoc(E->getLAngleLoc());
13836 TransArgs.setRAngleLoc(E->getRAngleLoc());
13837 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13838 E->getNumTemplateArgs(),
13839 TransArgs))
13840 return ExprError();
13841 }
13842
13843 // FIXME: Bogus source location for the operator
13844 SourceLocation FakeOperatorLoc =
13845 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13846
13847 // FIXME: to do this check properly, we will need to preserve the
13848 // first-qualifier-in-scope here, just in case we had a dependent
13849 // base (and therefore couldn't do the check) and a
13850 // nested-name-qualifier (and therefore could do the lookup).
13851 NamedDecl *FirstQualifierInScope = nullptr;
13852 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13853 if (MemberNameInfo.getName()) {
13854 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13855 if (!MemberNameInfo.getName())
13856 return ExprError();
13857 }
13858
13859 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13860 E->isArrow(),
13861 QualifierLoc,
13862 TemplateKWLoc,
13863 MemberNameInfo,
13864 Member,
13865 FoundDecl,
13866 (E->hasExplicitTemplateArgs()
13867 ? &TransArgs : nullptr),
13868 FirstQualifierInScope);
13869}
13870
13871template<typename Derived>
13874 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13875 if (LHS.isInvalid())
13876 return ExprError();
13877
13878 ExprResult RHS =
13879 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13880 if (RHS.isInvalid())
13881 return ExprError();
13882
13883 if (!getDerived().AlwaysRebuild() &&
13884 LHS.get() == E->getLHS() &&
13885 RHS.get() == E->getRHS())
13886 return E;
13887
13888 if (E->isCompoundAssignmentOp())
13889 // FPFeatures has already been established from trailing storage
13890 return getDerived().RebuildBinaryOperator(
13891 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13892 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13893 FPOptionsOverride NewOverrides(E->getFPFeatures());
13894 getSema().CurFPFeatures =
13895 NewOverrides.applyOverrides(getSema().getLangOpts());
13896 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13897 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13898 LHS.get(), RHS.get());
13899}
13900
13901template <typename Derived>
13904 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13905
13906 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13907 if (LHS.isInvalid())
13908 return ExprError();
13909
13910 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13911 if (RHS.isInvalid())
13912 return ExprError();
13913
13914 // Extract the already-resolved callee declarations so that we can restrict
13915 // ourselves to using them as the unqualified lookup results when rebuilding.
13916 UnresolvedSet<2> UnqualLookups;
13917 bool ChangedAnyLookups = false;
13918 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13919 const_cast<Expr *>(Decomp.InnerBinOp)};
13920 for (Expr *PossibleBinOp : PossibleBinOps) {
13921 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13922 if (!Op)
13923 continue;
13924 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13925 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13926 continue;
13927
13928 // Transform the callee in case we built a call to a local extern
13929 // declaration.
13930 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13931 E->getOperatorLoc(), Callee->getFoundDecl()));
13932 if (!Found)
13933 return ExprError();
13934 if (Found != Callee->getFoundDecl())
13935 ChangedAnyLookups = true;
13936 UnqualLookups.addDecl(Found);
13937 }
13938
13939 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13940 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13941 // Mark all functions used in the rewrite as referenced. Note that when
13942 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13943 // function calls, and/or there might be a user-defined conversion sequence
13944 // applied to the operands of the <.
13945 // FIXME: this is a bit instantiation-specific.
13946 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13947 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13948 return E;
13949 }
13950
13951 return getDerived().RebuildCXXRewrittenBinaryOperator(
13952 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13953}
13954
13955template<typename Derived>
13959 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13960 FPOptionsOverride NewOverrides(E->getFPFeatures());
13961 getSema().CurFPFeatures =
13962 NewOverrides.applyOverrides(getSema().getLangOpts());
13963 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13964 return getDerived().TransformBinaryOperator(E);
13965}
13966
13967template<typename Derived>
13970 // Just rebuild the common and RHS expressions and see whether we
13971 // get any changes.
13972
13973 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13974 if (commonExpr.isInvalid())
13975 return ExprError();
13976
13977 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13978 if (rhs.isInvalid())
13979 return ExprError();
13980
13981 if (!getDerived().AlwaysRebuild() &&
13982 commonExpr.get() == e->getCommon() &&
13983 rhs.get() == e->getFalseExpr())
13984 return e;
13985
13986 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13987 e->getQuestionLoc(),
13988 nullptr,
13989 e->getColonLoc(),
13990 rhs.get());
13991}
13992
13993template<typename Derived>
13996 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13997 if (Cond.isInvalid())
13998 return ExprError();
13999
14000 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14001 if (LHS.isInvalid())
14002 return ExprError();
14003
14004 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14005 if (RHS.isInvalid())
14006 return ExprError();
14007
14008 if (!getDerived().AlwaysRebuild() &&
14009 Cond.get() == E->getCond() &&
14010 LHS.get() == E->getLHS() &&
14011 RHS.get() == E->getRHS())
14012 return E;
14013
14014 return getDerived().RebuildConditionalOperator(Cond.get(),
14015 E->getQuestionLoc(),
14016 LHS.get(),
14017 E->getColonLoc(),
14018 RHS.get());
14019}
14020
14021template<typename Derived>
14024 // Implicit casts are eliminated during transformation, since they
14025 // will be recomputed by semantic analysis after transformation.
14026 return getDerived().TransformExpr(E->getSubExprAsWritten());
14027}
14028
14029template<typename Derived>
14032 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14033 if (!Type)
14034 return ExprError();
14035
14036 ExprResult SubExpr
14037 = getDerived().TransformExpr(E->getSubExprAsWritten());
14038 if (SubExpr.isInvalid())
14039 return ExprError();
14040
14041 if (!getDerived().AlwaysRebuild() &&
14042 Type == E->getTypeInfoAsWritten() &&
14043 SubExpr.get() == E->getSubExpr())
14044 return E;
14045
14046 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
14047 Type,
14048 E->getRParenLoc(),
14049 SubExpr.get());
14050}
14051
14052template<typename Derived>
14055 TypeSourceInfo *OldT = E->getTypeSourceInfo();
14056 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
14057 if (!NewT)
14058 return ExprError();
14059
14060 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
14061 if (Init.isInvalid())
14062 return ExprError();
14063
14064 if (!getDerived().AlwaysRebuild() &&
14065 OldT == NewT &&
14066 Init.get() == E->getInitializer())
14067 return SemaRef.MaybeBindToTemporary(E);
14068
14069 // Note: the expression type doesn't necessarily match the
14070 // type-as-written, but that's okay, because it should always be
14071 // derivable from the initializer.
14072
14073 return getDerived().RebuildCompoundLiteralExpr(
14074 E->getLParenLoc(), NewT,
14075 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
14076}
14077
14078template<typename Derived>
14081 ExprResult Base = getDerived().TransformExpr(E->getBase());
14082 if (Base.isInvalid())
14083 return ExprError();
14084
14085 if (!getDerived().AlwaysRebuild() &&
14086 Base.get() == E->getBase())
14087 return E;
14088
14089 // FIXME: Bad source location
14090 SourceLocation FakeOperatorLoc =
14091 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14092 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14093 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
14094 E->getAccessor());
14095}
14096
14097template <typename Derived>
14100 ExprResult Base = getDerived().TransformExpr(E->getBase());
14101 if (Base.isInvalid())
14102 return ExprError();
14103
14104 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase())
14105 return E;
14106
14107 // FIXME: Bad source location
14108 SourceLocation FakeOperatorLoc =
14109 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14110 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14111 Base.get(), FakeOperatorLoc, /*isArrow*/ false, E->getAccessorLoc(),
14112 E->getAccessor());
14113}
14114
14115template<typename Derived>
14118 if (InitListExpr *Syntactic = E->getSyntacticForm())
14119 E = Syntactic;
14120
14121 bool InitChanged = false;
14122
14125
14127 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
14128 Inits, &InitChanged))
14129 return ExprError();
14130
14131 if (!getDerived().AlwaysRebuild() && !InitChanged) {
14132 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
14133 // in some cases. We can't reuse it in general, because the syntactic and
14134 // semantic forms are linked, and we can't know that semantic form will
14135 // match even if the syntactic form does.
14136 }
14137
14138 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
14139 E->getRBraceLoc(), E->isExplicit());
14140}
14141
14142template<typename Derived>
14145 Designation Desig;
14146
14147 // transform the initializer value
14148 ExprResult Init = getDerived().TransformExpr(E->getInit());
14149 if (Init.isInvalid())
14150 return ExprError();
14151
14152 // transform the designators.
14153 SmallVector<Expr*, 4> ArrayExprs;
14154 bool ExprChanged = false;
14155 for (const DesignatedInitExpr::Designator &D : E->designators()) {
14156 if (D.isFieldDesignator()) {
14157 if (D.getFieldDecl()) {
14158 FieldDecl *Field = cast_or_null<FieldDecl>(
14159 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
14160 if (Field != D.getFieldDecl())
14161 // Rebuild the expression when the transformed FieldDecl is
14162 // different to the already assigned FieldDecl.
14163 ExprChanged = true;
14164 if (Field->isAnonymousStructOrUnion())
14165 continue;
14166 } else {
14167 // Ensure that the designator expression is rebuilt when there isn't
14168 // a resolved FieldDecl in the designator as we don't want to assign
14169 // a FieldDecl to a pattern designator that will be instantiated again.
14170 ExprChanged = true;
14171 }
14172 Desig.AddDesignator(Designator::CreateFieldDesignator(
14173 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
14174 continue;
14175 }
14176
14177 if (D.isArrayDesignator()) {
14178 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
14179 if (Index.isInvalid())
14180 return ExprError();
14181
14182 Desig.AddDesignator(
14183 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
14184
14185 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
14186 ArrayExprs.push_back(Index.get());
14187 continue;
14188 }
14189
14190 assert(D.isArrayRangeDesignator() && "New kind of designator?");
14191 ExprResult Start
14192 = getDerived().TransformExpr(E->getArrayRangeStart(D));
14193 if (Start.isInvalid())
14194 return ExprError();
14195
14196 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
14197 if (End.isInvalid())
14198 return ExprError();
14199
14200 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
14201 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
14202
14203 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
14204 End.get() != E->getArrayRangeEnd(D);
14205
14206 ArrayExprs.push_back(Start.get());
14207 ArrayExprs.push_back(End.get());
14208 }
14209
14210 if (!getDerived().AlwaysRebuild() &&
14211 Init.get() == E->getInit() &&
14212 !ExprChanged)
14213 return E;
14214
14215 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14216 E->getEqualOrColonLoc(),
14217 E->usesGNUSyntax(), Init.get());
14218}
14219
14220// Seems that if TransformInitListExpr() only works on the syntactic form of an
14221// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14222template<typename Derived>
14226 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14227 "initializer");
14228 return ExprError();
14229}
14230
14231template<typename Derived>
14234 NoInitExpr *E) {
14235 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14236 return ExprError();
14237}
14238
14239template<typename Derived>
14242 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14243 return ExprError();
14244}
14245
14246template<typename Derived>
14249 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14250 return ExprError();
14251}
14252
14253template<typename Derived>
14257 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14258
14259 // FIXME: Will we ever have proper type location here? Will we actually
14260 // need to transform the type?
14261 QualType T = getDerived().TransformType(E->getType());
14262 if (T.isNull())
14263 return ExprError();
14264
14265 if (!getDerived().AlwaysRebuild() &&
14266 T == E->getType())
14267 return E;
14268
14269 return getDerived().RebuildImplicitValueInitExpr(T);
14270}
14271
14272template<typename Derived>
14275 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14276 if (!TInfo)
14277 return ExprError();
14278
14279 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14280 if (SubExpr.isInvalid())
14281 return ExprError();
14282
14283 if (!getDerived().AlwaysRebuild() &&
14284 TInfo == E->getWrittenTypeInfo() &&
14285 SubExpr.get() == E->getSubExpr())
14286 return E;
14287
14288 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14289 TInfo, E->getRParenLoc());
14290}
14291
14292template<typename Derived>
14295 bool ArgumentChanged = false;
14297 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14298 &ArgumentChanged))
14299 return ExprError();
14300
14301 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14302 Inits,
14303 E->getRParenLoc());
14304}
14305
14306/// Transform an address-of-label expression.
14307///
14308/// By default, the transformation of an address-of-label expression always
14309/// rebuilds the expression, so that the label identifier can be resolved to
14310/// the corresponding label statement by semantic analysis.
14311template<typename Derived>
14314 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14315 E->getLabel());
14316 if (!LD)
14317 return ExprError();
14318
14319 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14320 cast<LabelDecl>(LD));
14321}
14322
14323template<typename Derived>
14326 SemaRef.ActOnStartStmtExpr();
14327 StmtResult SubStmt
14328 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14329 if (SubStmt.isInvalid()) {
14330 SemaRef.ActOnStmtExprError();
14331 return ExprError();
14332 }
14333
14334 unsigned OldDepth = E->getTemplateDepth();
14335 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14336
14337 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14338 SubStmt.get() == E->getSubStmt()) {
14339 // Calling this an 'error' is unintuitive, but it does the right thing.
14340 SemaRef.ActOnStmtExprError();
14341 return SemaRef.MaybeBindToTemporary(E);
14342 }
14343
14344 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14345 E->getRParenLoc(), NewDepth);
14346}
14347
14348template<typename Derived>
14351 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14352 if (Cond.isInvalid())
14353 return ExprError();
14354
14355 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14356 if (LHS.isInvalid())
14357 return ExprError();
14358
14359 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14360 if (RHS.isInvalid())
14361 return ExprError();
14362
14363 if (!getDerived().AlwaysRebuild() &&
14364 Cond.get() == E->getCond() &&
14365 LHS.get() == E->getLHS() &&
14366 RHS.get() == E->getRHS())
14367 return E;
14368
14369 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14370 Cond.get(), LHS.get(), RHS.get(),
14371 E->getRParenLoc());
14372}
14373
14374template<typename Derived>
14377 return E;
14378}
14379
14380template<typename Derived>
14383 switch (E->getOperator()) {
14384 case OO_New:
14385 case OO_Delete:
14386 case OO_Array_New:
14387 case OO_Array_Delete:
14388 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14389
14390 case OO_Subscript:
14391 case OO_Call: {
14392 // This is a call to an object's operator().
14393 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14394
14395 // Transform the object itself.
14396 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14397 if (Object.isInvalid())
14398 return ExprError();
14399
14400 // FIXME: Poor location information. Also, if the location for the end of
14401 // the token is within a macro expansion, getLocForEndOfToken() will return
14402 // an invalid source location. If that happens and we have an otherwise
14403 // valid end location, use the valid one instead of the invalid one.
14404 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14405 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14406 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14407 FakeLParenLoc = EndLoc;
14408
14409 // Transform the call arguments.
14411 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14412 Args))
14413 return ExprError();
14414
14415 if (E->getOperator() == OO_Subscript)
14416 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14417 Args, E->getEndLoc());
14418
14419 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14420 E->getEndLoc());
14421 }
14422
14423#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14424 case OO_##Name: \
14425 break;
14426
14427#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14428#include "clang/Basic/OperatorKinds.def"
14429
14430 case OO_Conditional:
14431 llvm_unreachable("conditional operator is not actually overloadable");
14432
14433 case OO_None:
14435 llvm_unreachable("not an overloaded operator?");
14436 }
14437
14439 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14440 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14441 else
14442 First = getDerived().TransformExpr(E->getArg(0));
14443 if (First.isInvalid())
14444 return ExprError();
14445
14446 ExprResult Second;
14447 if (E->getNumArgs() == 2) {
14448 Second =
14449 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14450 if (Second.isInvalid())
14451 return ExprError();
14452 }
14453
14454 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14455 FPOptionsOverride NewOverrides(E->getFPFeatures());
14456 getSema().CurFPFeatures =
14457 NewOverrides.applyOverrides(getSema().getLangOpts());
14458 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14459
14460 Expr *Callee = E->getCallee();
14461 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14462 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14464 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14465 return ExprError();
14466
14467 return getDerived().RebuildCXXOperatorCallExpr(
14468 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14469 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14470 }
14471
14472 UnresolvedSet<1> Functions;
14473 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14474 Callee = ICE->getSubExprAsWritten();
14475 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14476 ValueDecl *VD = cast_or_null<ValueDecl>(
14477 getDerived().TransformDecl(DR->getLocation(), DR));
14478 if (!VD)
14479 return ExprError();
14480
14481 if (!isa<CXXMethodDecl>(VD))
14482 Functions.addDecl(VD);
14483
14484 return getDerived().RebuildCXXOperatorCallExpr(
14485 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14486 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14487}
14488
14489template<typename Derived>
14492 return getDerived().TransformCallExpr(E);
14493}
14494
14495template <typename Derived>
14497 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14498 getSema().CurContext != E->getParentContext();
14499
14500 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14501 return E;
14502
14503 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14504 E->getBeginLoc(), E->getEndLoc(),
14505 getSema().CurContext);
14506}
14507
14508template <typename Derived>
14510 return E;
14511}
14512
14513template<typename Derived>
14516 // Transform the callee.
14517 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14518 if (Callee.isInvalid())
14519 return ExprError();
14520
14521 // Transform exec config.
14522 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14523 if (EC.isInvalid())
14524 return ExprError();
14525
14526 // Transform arguments.
14527 bool ArgChanged = false;
14529 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14530 &ArgChanged))
14531 return ExprError();
14532
14533 if (!getDerived().AlwaysRebuild() &&
14534 Callee.get() == E->getCallee() &&
14535 !ArgChanged)
14536 return SemaRef.MaybeBindToTemporary(E);
14537
14538 // FIXME: Wrong source location information for the '('.
14539 SourceLocation FakeLParenLoc
14540 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14541 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14542 Args,
14543 E->getRParenLoc(), EC.get());
14544}
14545
14546template<typename Derived>
14549 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14550 if (!Type)
14551 return ExprError();
14552
14553 ExprResult SubExpr
14554 = getDerived().TransformExpr(E->getSubExprAsWritten());
14555 if (SubExpr.isInvalid())
14556 return ExprError();
14557
14558 if (!getDerived().AlwaysRebuild() &&
14559 Type == E->getTypeInfoAsWritten() &&
14560 SubExpr.get() == E->getSubExpr())
14561 return E;
14562 return getDerived().RebuildCXXNamedCastExpr(
14565 // FIXME. this should be '(' location
14566 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14567}
14568
14569template<typename Derived>
14572 TypeSourceInfo *TSI =
14573 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14574 if (!TSI)
14575 return ExprError();
14576
14577 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14578 if (Sub.isInvalid())
14579 return ExprError();
14580
14581 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14582 Sub.get(), BCE->getEndLoc());
14583}
14584
14585template<typename Derived>
14587TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14588 return getDerived().TransformCXXNamedCastExpr(E);
14589}
14590
14591template<typename Derived>
14594 return getDerived().TransformCXXNamedCastExpr(E);
14595}
14596
14597template<typename Derived>
14601 return getDerived().TransformCXXNamedCastExpr(E);
14602}
14603
14604template<typename Derived>
14607 return getDerived().TransformCXXNamedCastExpr(E);
14608}
14609
14610template<typename Derived>
14613 return getDerived().TransformCXXNamedCastExpr(E);
14614}
14615
14616template<typename Derived>
14621 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14622 if (!Type)
14623 return ExprError();
14624
14625 ExprResult SubExpr
14626 = getDerived().TransformExpr(E->getSubExprAsWritten());
14627 if (SubExpr.isInvalid())
14628 return ExprError();
14629
14630 if (!getDerived().AlwaysRebuild() &&
14631 Type == E->getTypeInfoAsWritten() &&
14632 SubExpr.get() == E->getSubExpr())
14633 return E;
14634
14635 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14636 E->getLParenLoc(),
14637 SubExpr.get(),
14638 E->getRParenLoc(),
14639 E->isListInitialization());
14640}
14641
14642template<typename Derived>
14645 if (E->isTypeOperand()) {
14646 TypeSourceInfo *TInfo
14647 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14648 if (!TInfo)
14649 return ExprError();
14650
14651 if (!getDerived().AlwaysRebuild() &&
14652 TInfo == E->getTypeOperandSourceInfo())
14653 return E;
14654
14655 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14656 TInfo, E->getEndLoc());
14657 }
14658
14659 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14660 // type. We must not unilaterally enter unevaluated context here, as then
14661 // semantic processing can re-transform an already transformed operand.
14662 Expr *Op = E->getExprOperand();
14664 if (E->isGLValue()) {
14665 QualType OpType = Op->getType();
14666 if (auto *RD = OpType->getAsCXXRecordDecl()) {
14667 if (SemaRef.RequireCompleteType(E->getBeginLoc(), OpType,
14668 diag::err_incomplete_typeid))
14669 return ExprError();
14670
14671 if (RD->isPolymorphic())
14672 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14673 }
14674 }
14675
14678
14679 ExprResult SubExpr = getDerived().TransformExpr(Op);
14680 if (SubExpr.isInvalid())
14681 return ExprError();
14682
14683 if (!getDerived().AlwaysRebuild() &&
14684 SubExpr.get() == E->getExprOperand())
14685 return E;
14686
14687 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14688 SubExpr.get(), E->getEndLoc());
14689}
14690
14691template<typename Derived>
14694 if (E->isTypeOperand()) {
14695 TypeSourceInfo *TInfo
14696 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14697 if (!TInfo)
14698 return ExprError();
14699
14700 if (!getDerived().AlwaysRebuild() &&
14701 TInfo == E->getTypeOperandSourceInfo())
14702 return E;
14703
14704 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14705 TInfo, E->getEndLoc());
14706 }
14707
14710
14711 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14712 if (SubExpr.isInvalid())
14713 return ExprError();
14714
14715 if (!getDerived().AlwaysRebuild() &&
14716 SubExpr.get() == E->getExprOperand())
14717 return E;
14718
14719 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14720 SubExpr.get(), E->getEndLoc());
14721}
14722
14723template<typename Derived>
14726 return E;
14727}
14728
14729template<typename Derived>
14733 return E;
14734}
14735
14736template<typename Derived>
14739
14740 // In lambdas, the qualifiers of the type depends of where in
14741 // the call operator `this` appear, and we do not have a good way to
14742 // rebuild this information, so we transform the type.
14743 //
14744 // In other contexts, the type of `this` may be overrided
14745 // for type deduction, so we need to recompute it.
14746 //
14747 // Always recompute the type if we're in the body of a lambda, and
14748 // 'this' is dependent on a lambda's explicit object parameter; we
14749 // also need to always rebuild the expression in this case to clear
14750 // the flag.
14751 QualType T = [&]() {
14752 auto &S = getSema();
14753 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14754 return S.getCurrentThisType();
14755 if (S.getCurLambda())
14756 return getDerived().TransformType(E->getType());
14757 return S.getCurrentThisType();
14758 }();
14759
14760 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14761 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14762 // Mark it referenced in the new context regardless.
14763 // FIXME: this is a bit instantiation-specific.
14764 getSema().MarkThisReferenced(E);
14765 return E;
14766 }
14767
14768 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14769}
14770
14771template<typename Derived>
14774 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14775 if (SubExpr.isInvalid())
14776 return ExprError();
14777
14778 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14779
14780 if (!getDerived().AlwaysRebuild() &&
14781 SubExpr.get() == E->getSubExpr())
14782 return E;
14783
14784 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14785 E->isThrownVariableInScope());
14786}
14787
14788template<typename Derived>
14791 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14792 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14793 if (!Param)
14794 return ExprError();
14795
14796 ExprResult InitRes;
14797 if (E->hasRewrittenInit()) {
14798 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14799 if (InitRes.isInvalid())
14800 return ExprError();
14801 }
14802
14803 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14804 E->getUsedContext() == SemaRef.CurContext &&
14805 InitRes.get() == E->getRewrittenExpr())
14806 return E;
14807
14808 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14809 InitRes.get());
14810}
14811
14812template<typename Derived>
14815 FieldDecl *Field = cast_or_null<FieldDecl>(
14816 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14817 if (!Field)
14818 return ExprError();
14819
14820 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14821 E->getUsedContext() == SemaRef.CurContext)
14822 return E;
14823
14824 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14825}
14826
14827template<typename Derived>
14831 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14832 if (!T)
14833 return ExprError();
14834
14835 if (!getDerived().AlwaysRebuild() &&
14836 T == E->getTypeSourceInfo())
14837 return E;
14838
14839 return getDerived().RebuildCXXScalarValueInitExpr(T,
14840 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14841 E->getRParenLoc());
14842}
14843
14844template<typename Derived>
14847 // Transform the type that we're allocating
14848 TypeSourceInfo *AllocTypeInfo =
14849 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14850 if (!AllocTypeInfo)
14851 return ExprError();
14852
14853 // Transform the size of the array we're allocating (if any).
14854 std::optional<Expr *> ArraySize;
14855 if (E->isArray()) {
14856 ExprResult NewArraySize;
14857 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14858 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14859 if (NewArraySize.isInvalid())
14860 return ExprError();
14861 }
14862 ArraySize = NewArraySize.get();
14863 }
14864
14865 // Transform the placement arguments (if any).
14866 bool ArgumentChanged = false;
14867 SmallVector<Expr*, 8> PlacementArgs;
14868 if (getDerived().TransformExprs(E->getPlacementArgs(),
14869 E->getNumPlacementArgs(), true,
14870 PlacementArgs, &ArgumentChanged))
14871 return ExprError();
14872
14873 // Transform the initializer (if any).
14874 Expr *OldInit = E->getInitializer();
14875 ExprResult NewInit;
14876 if (OldInit)
14877 NewInit = getDerived().TransformInitializer(OldInit, true);
14878 if (NewInit.isInvalid())
14879 return ExprError();
14880
14881 // Transform new operator and delete operator.
14882 FunctionDecl *OperatorNew = nullptr;
14883 if (E->getOperatorNew()) {
14884 OperatorNew = cast_or_null<FunctionDecl>(
14885 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14886 if (!OperatorNew)
14887 return ExprError();
14888 }
14889
14890 FunctionDecl *OperatorDelete = nullptr;
14891 if (E->getOperatorDelete()) {
14892 OperatorDelete = cast_or_null<FunctionDecl>(
14893 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14894 if (!OperatorDelete)
14895 return ExprError();
14896 }
14897
14898 if (!getDerived().AlwaysRebuild() &&
14899 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14900 ArraySize == E->getArraySize() &&
14901 NewInit.get() == OldInit &&
14902 OperatorNew == E->getOperatorNew() &&
14903 OperatorDelete == E->getOperatorDelete() &&
14904 !ArgumentChanged) {
14905 // Mark any declarations we need as referenced.
14906 // FIXME: instantiation-specific.
14907 if (OperatorNew)
14908 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14909 if (OperatorDelete)
14910 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14911
14912 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14913 QualType ElementType
14914 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14915 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14917 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14918 }
14919 }
14920
14921 return E;
14922 }
14923
14924 QualType AllocType = AllocTypeInfo->getType();
14925 if (!ArraySize) {
14926 // If no array size was specified, but the new expression was
14927 // instantiated with an array type (e.g., "new T" where T is
14928 // instantiated with "int[4]"), extract the outer bound from the
14929 // array type as our array size. We do this with constant and
14930 // dependently-sized array types.
14931 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14932 if (!ArrayT) {
14933 // Do nothing
14934 } else if (const ConstantArrayType *ConsArrayT
14935 = dyn_cast<ConstantArrayType>(ArrayT)) {
14936 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14937 SemaRef.Context.getSizeType(),
14938 /*FIXME:*/ E->getBeginLoc());
14939 AllocType = ConsArrayT->getElementType();
14940 } else if (const DependentSizedArrayType *DepArrayT
14941 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14942 if (DepArrayT->getSizeExpr()) {
14943 ArraySize = DepArrayT->getSizeExpr();
14944 AllocType = DepArrayT->getElementType();
14945 }
14946 }
14947 }
14948
14949 return getDerived().RebuildCXXNewExpr(
14950 E->getBeginLoc(), E->isGlobalNew(),
14951 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14952 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14953 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14954}
14955
14956template<typename Derived>
14959 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14960 if (Operand.isInvalid())
14961 return ExprError();
14962
14963 // Transform the delete operator, if known.
14964 FunctionDecl *OperatorDelete = nullptr;
14965 if (E->getOperatorDelete()) {
14966 OperatorDelete = cast_or_null<FunctionDecl>(
14967 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14968 if (!OperatorDelete)
14969 return ExprError();
14970 }
14971
14972 if (!getDerived().AlwaysRebuild() &&
14973 Operand.get() == E->getArgument() &&
14974 OperatorDelete == E->getOperatorDelete()) {
14975 // Mark any declarations we need as referenced.
14976 // FIXME: instantiation-specific.
14977 if (OperatorDelete)
14978 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14979
14980 if (!E->getArgument()->isTypeDependent()) {
14982 E->getDestroyedType());
14983 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14984 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14985 SemaRef.LookupDestructor(Record));
14986 }
14987
14988 return E;
14989 }
14990
14991 return getDerived().RebuildCXXDeleteExpr(
14992 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14993}
14994
14995template<typename Derived>
14999 ExprResult Base = getDerived().TransformExpr(E->getBase());
15000 if (Base.isInvalid())
15001 return ExprError();
15002
15003 ParsedType ObjectTypePtr;
15004 bool MayBePseudoDestructor = false;
15005 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
15006 E->getOperatorLoc(),
15007 E->isArrow()? tok::arrow : tok::period,
15008 ObjectTypePtr,
15009 MayBePseudoDestructor);
15010 if (Base.isInvalid())
15011 return ExprError();
15012
15013 QualType ObjectType = ObjectTypePtr.get();
15014 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
15015 if (QualifierLoc) {
15016 QualifierLoc
15017 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
15018 if (!QualifierLoc)
15019 return ExprError();
15020 }
15021 CXXScopeSpec SS;
15022 SS.Adopt(QualifierLoc);
15023
15025 if (E->getDestroyedTypeInfo()) {
15026 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
15027 E->getDestroyedTypeInfo(), ObjectType,
15028 /*FirstQualifierInScope=*/nullptr);
15029 if (!DestroyedTypeInfo)
15030 return ExprError();
15031 Destroyed = DestroyedTypeInfo;
15032 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
15033 // We aren't likely to be able to resolve the identifier down to a type
15034 // now anyway, so just retain the identifier.
15035 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
15036 E->getDestroyedTypeLoc());
15037 } else {
15038 // Look for a destructor known with the given name.
15039 ParsedType T = SemaRef.getDestructorName(
15040 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
15041 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
15042 if (!T)
15043 return ExprError();
15044
15045 Destroyed
15047 E->getDestroyedTypeLoc());
15048 }
15049
15050 TypeSourceInfo *ScopeTypeInfo = nullptr;
15051 if (E->getScopeTypeInfo()) {
15052 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
15053 E->getScopeTypeInfo(), ObjectType, nullptr);
15054 if (!ScopeTypeInfo)
15055 return ExprError();
15056 }
15057
15058 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
15059 E->getOperatorLoc(),
15060 E->isArrow(),
15061 SS,
15062 ScopeTypeInfo,
15063 E->getColonColonLoc(),
15064 E->getTildeLoc(),
15065 Destroyed);
15066}
15067
15068template <typename Derived>
15070 bool RequiresADL,
15071 LookupResult &R) {
15072 // Transform all the decls.
15073 bool AllEmptyPacks = true;
15074 for (auto *OldD : Old->decls()) {
15075 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
15076 if (!InstD) {
15077 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
15078 // This can happen because of dependent hiding.
15079 if (isa<UsingShadowDecl>(OldD))
15080 continue;
15081 else {
15082 R.clear();
15083 return true;
15084 }
15085 }
15086
15087 // Expand using pack declarations.
15088 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
15089 ArrayRef<NamedDecl*> Decls = SingleDecl;
15090 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
15091 Decls = UPD->expansions();
15092
15093 // Expand using declarations.
15094 for (auto *D : Decls) {
15095 if (auto *UD = dyn_cast<UsingDecl>(D)) {
15096 for (auto *SD : UD->shadows())
15097 R.addDecl(SD);
15098 } else {
15099 R.addDecl(D);
15100 }
15101 }
15102
15103 AllEmptyPacks &= Decls.empty();
15104 }
15105
15106 // C++ [temp.res]/8.4.2:
15107 // The program is ill-formed, no diagnostic required, if [...] lookup for
15108 // a name in the template definition found a using-declaration, but the
15109 // lookup in the corresponding scope in the instantiation odoes not find
15110 // any declarations because the using-declaration was a pack expansion and
15111 // the corresponding pack is empty
15112 if (AllEmptyPacks && !RequiresADL) {
15113 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
15114 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
15115 return true;
15116 }
15117
15118 // Resolve a kind, but don't do any further analysis. If it's
15119 // ambiguous, the callee needs to deal with it.
15120 R.resolveKind();
15121
15122 if (Old->hasTemplateKeyword() && !R.empty()) {
15123 NamedDecl *FoundDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
15124 getSema().FilterAcceptableTemplateNames(R,
15125 /*AllowFunctionTemplates=*/true,
15126 /*AllowDependent=*/true);
15127 if (R.empty()) {
15128 // If a 'template' keyword was used, a lookup that finds only non-template
15129 // names is an error.
15130 getSema().Diag(R.getNameLoc(),
15131 diag::err_template_kw_refers_to_non_template)
15132 << R.getLookupName() << Old->getQualifierLoc().getSourceRange()
15133 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
15134 getSema().Diag(FoundDecl->getLocation(),
15135 diag::note_template_kw_refers_to_non_template)
15136 << R.getLookupName();
15137 return true;
15138 }
15139 }
15140
15141 return false;
15142}
15143
15144template <typename Derived>
15149
15150template <typename Derived>
15153 bool IsAddressOfOperand) {
15154 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
15156
15157 // Transform the declaration set.
15158 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
15159 return ExprError();
15160
15161 // Rebuild the nested-name qualifier, if present.
15162 CXXScopeSpec SS;
15163 if (Old->getQualifierLoc()) {
15164 NestedNameSpecifierLoc QualifierLoc
15165 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
15166 if (!QualifierLoc)
15167 return ExprError();
15168
15169 SS.Adopt(QualifierLoc);
15170 }
15171
15172 if (Old->getNamingClass()) {
15173 CXXRecordDecl *NamingClass
15174 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
15175 Old->getNameLoc(),
15176 Old->getNamingClass()));
15177 if (!NamingClass) {
15178 R.clear();
15179 return ExprError();
15180 }
15181
15182 R.setNamingClass(NamingClass);
15183 }
15184
15185 // Rebuild the template arguments, if any.
15186 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
15187 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
15188 if (Old->hasExplicitTemplateArgs() &&
15189 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15190 Old->getNumTemplateArgs(),
15191 TransArgs)) {
15192 R.clear();
15193 return ExprError();
15194 }
15195
15196 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
15197 // a non-static data member is named in an unevaluated operand, or when
15198 // a member is named in a dependent class scope function template explicit
15199 // specialization that is neither declared static nor with an explicit object
15200 // parameter.
15201 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
15202 return SemaRef.BuildPossibleImplicitMemberExpr(
15203 SS, TemplateKWLoc, R,
15204 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
15205 /*S=*/nullptr);
15206
15207 // If we have neither explicit template arguments, nor the template keyword,
15208 // it's a normal declaration name or member reference.
15209 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
15210 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
15211
15212 // If we have template arguments, then rebuild the template-id expression.
15213 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
15214 Old->requiresADL(), &TransArgs);
15215}
15216
15217template<typename Derived>
15220 bool ArgChanged = false;
15222 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15223 TypeSourceInfo *From = E->getArg(I);
15224 TypeLoc FromTL = From->getTypeLoc();
15225 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15226 TypeLocBuilder TLB;
15227 TLB.reserve(FromTL.getFullDataSize());
15228 QualType To = getDerived().TransformType(TLB, FromTL);
15229 if (To.isNull())
15230 return ExprError();
15231
15232 if (To == From->getType())
15233 Args.push_back(From);
15234 else {
15235 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15236 ArgChanged = true;
15237 }
15238 continue;
15239 }
15240
15241 ArgChanged = true;
15242
15243 // We have a pack expansion. Instantiate it.
15244 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15245 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15247 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15248
15249 // Determine whether the set of unexpanded parameter packs can and should
15250 // be expanded.
15251 bool Expand = true;
15252 bool RetainExpansion = false;
15253 UnsignedOrNone OrigNumExpansions =
15254 ExpansionTL.getTypePtr()->getNumExpansions();
15255 UnsignedOrNone NumExpansions = OrigNumExpansions;
15256 if (getDerived().TryExpandParameterPacks(
15257 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15258 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15259 RetainExpansion, NumExpansions))
15260 return ExprError();
15261
15262 if (!Expand) {
15263 // The transform has determined that we should perform a simple
15264 // transformation on the pack expansion, producing another pack
15265 // expansion.
15266 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15267
15268 TypeLocBuilder TLB;
15269 TLB.reserve(From->getTypeLoc().getFullDataSize());
15270
15271 QualType To = getDerived().TransformType(TLB, PatternTL);
15272 if (To.isNull())
15273 return ExprError();
15274
15275 To = getDerived().RebuildPackExpansionType(To,
15276 PatternTL.getSourceRange(),
15277 ExpansionTL.getEllipsisLoc(),
15278 NumExpansions);
15279 if (To.isNull())
15280 return ExprError();
15281
15282 PackExpansionTypeLoc ToExpansionTL
15283 = TLB.push<PackExpansionTypeLoc>(To);
15284 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15285 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15286 continue;
15287 }
15288
15289 // Expand the pack expansion by substituting for each argument in the
15290 // pack(s).
15291 for (unsigned I = 0; I != *NumExpansions; ++I) {
15292 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15293 TypeLocBuilder TLB;
15294 TLB.reserve(PatternTL.getFullDataSize());
15295 QualType To = getDerived().TransformType(TLB, PatternTL);
15296 if (To.isNull())
15297 return ExprError();
15298
15299 if (To->containsUnexpandedParameterPack()) {
15300 To = getDerived().RebuildPackExpansionType(To,
15301 PatternTL.getSourceRange(),
15302 ExpansionTL.getEllipsisLoc(),
15303 NumExpansions);
15304 if (To.isNull())
15305 return ExprError();
15306
15307 PackExpansionTypeLoc ToExpansionTL
15308 = TLB.push<PackExpansionTypeLoc>(To);
15309 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15310 }
15311
15312 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15313 }
15314
15315 if (!RetainExpansion)
15316 continue;
15317
15318 // If we're supposed to retain a pack expansion, do so by temporarily
15319 // forgetting the partially-substituted parameter pack.
15320 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15321
15322 TypeLocBuilder TLB;
15323 TLB.reserve(From->getTypeLoc().getFullDataSize());
15324
15325 QualType To = getDerived().TransformType(TLB, PatternTL);
15326 if (To.isNull())
15327 return ExprError();
15328
15329 To = getDerived().RebuildPackExpansionType(To,
15330 PatternTL.getSourceRange(),
15331 ExpansionTL.getEllipsisLoc(),
15332 NumExpansions);
15333 if (To.isNull())
15334 return ExprError();
15335
15336 PackExpansionTypeLoc ToExpansionTL
15337 = TLB.push<PackExpansionTypeLoc>(To);
15338 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15339 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15340 }
15341
15342 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15343 return E;
15344
15345 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15346 E->getEndLoc());
15347}
15348
15349template<typename Derived>
15353 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15354 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15355 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15356 Old->NumTemplateArgs, TransArgs))
15357 return ExprError();
15358
15359 return getDerived().RebuildConceptSpecializationExpr(
15360 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15361 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15362 &TransArgs);
15363}
15364
15365template<typename Derived>
15368 SmallVector<ParmVarDecl*, 4> TransParams;
15369 SmallVector<QualType, 4> TransParamTypes;
15370 Sema::ExtParameterInfoBuilder ExtParamInfos;
15371
15372 // C++2a [expr.prim.req]p2
15373 // Expressions appearing within a requirement-body are unevaluated operands.
15377
15379 getSema().Context, getSema().CurContext,
15380 E->getBody()->getBeginLoc());
15381
15382 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15383
15384 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15385 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15386 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15387
15388 for (ParmVarDecl *Param : TransParams)
15389 if (Param)
15390 Param->setDeclContext(Body);
15391
15392 // On failure to transform, TransformRequiresTypeParams returns an expression
15393 // in the event that the transformation of the type params failed in some way.
15394 // It is expected that this will result in a 'not satisfied' Requires clause
15395 // when instantiating.
15396 if (!TypeParamResult.isUnset())
15397 return TypeParamResult;
15398
15400 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15401 TransReqs))
15402 return ExprError();
15403
15404 for (concepts::Requirement *Req : TransReqs) {
15405 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15406 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15407 ER->getReturnTypeRequirement()
15408 .getTypeConstraintTemplateParameterList()->getParam(0)
15409 ->setDeclContext(Body);
15410 }
15411 }
15412 }
15413
15414 return getDerived().RebuildRequiresExpr(
15415 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15416 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15417}
15418
15419template<typename Derived>
15423 for (concepts::Requirement *Req : Reqs) {
15424 concepts::Requirement *TransReq = nullptr;
15425 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15426 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15427 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15428 TransReq = getDerived().TransformExprRequirement(ExprReq);
15429 else
15430 TransReq = getDerived().TransformNestedRequirement(
15432 if (!TransReq)
15433 return true;
15434 Transformed.push_back(TransReq);
15435 }
15436 return false;
15437}
15438
15439template<typename Derived>
15443 if (Req->isSubstitutionFailure()) {
15444 if (getDerived().AlwaysRebuild())
15445 return getDerived().RebuildTypeRequirement(
15447 return Req;
15448 }
15449 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15450 if (!TransType)
15451 return nullptr;
15452 return getDerived().RebuildTypeRequirement(TransType);
15453}
15454
15455template<typename Derived>
15458 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15459 if (Req->isExprSubstitutionFailure())
15460 TransExpr = Req->getExprSubstitutionDiagnostic();
15461 else {
15462 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15463 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15464 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15465 if (TransExprRes.isInvalid())
15466 return nullptr;
15467 TransExpr = TransExprRes.get();
15468 }
15469
15470 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15471 const auto &RetReq = Req->getReturnTypeRequirement();
15472 if (RetReq.isEmpty())
15473 TransRetReq.emplace();
15474 else if (RetReq.isSubstitutionFailure())
15475 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15476 else if (RetReq.isTypeConstraint()) {
15477 TemplateParameterList *OrigTPL =
15478 RetReq.getTypeConstraintTemplateParameterList();
15480 getDerived().TransformTemplateParameterList(OrigTPL);
15481 if (!TPL)
15482 return nullptr;
15483 TransRetReq.emplace(TPL);
15484 }
15485 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15486 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15487 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15488 Req->getNoexceptLoc(),
15489 std::move(*TransRetReq));
15490 return getDerived().RebuildExprRequirement(
15492 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15493}
15494
15495template<typename Derived>
15499 if (Req->hasInvalidConstraint()) {
15500 if (getDerived().AlwaysRebuild())
15501 return getDerived().RebuildNestedRequirement(
15503 return Req;
15504 }
15505 ExprResult TransConstraint =
15506 getDerived().TransformExpr(Req->getConstraintExpr());
15507 if (TransConstraint.isInvalid())
15508 return nullptr;
15509 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15510}
15511
15512template<typename Derived>
15515 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15516 if (!T)
15517 return ExprError();
15518
15519 if (!getDerived().AlwaysRebuild() &&
15520 T == E->getQueriedTypeSourceInfo())
15521 return E;
15522
15523 ExprResult SubExpr;
15524 {
15527 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15528 if (SubExpr.isInvalid())
15529 return ExprError();
15530 }
15531
15532 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15533 SubExpr.get(), E->getEndLoc());
15534}
15535
15536template<typename Derived>
15539 ExprResult SubExpr;
15540 {
15543 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15544 if (SubExpr.isInvalid())
15545 return ExprError();
15546
15547 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15548 return E;
15549 }
15550
15551 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15552 SubExpr.get(), E->getEndLoc());
15553}
15554
15555template <typename Derived>
15557 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15558 TypeSourceInfo **RecoveryTSI) {
15559 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15560 DRE, AddrTaken, RecoveryTSI);
15561
15562 // Propagate both errors and recovered types, which return ExprEmpty.
15563 if (!NewDRE.isUsable())
15564 return NewDRE;
15565
15566 // We got an expr, wrap it up in parens.
15567 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15568 return PE;
15569 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15570 PE->getRParen());
15571}
15572
15573template <typename Derived>
15579
15580template <typename Derived>
15582 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15583 TypeSourceInfo **RecoveryTSI) {
15584 assert(E->getQualifierLoc());
15585 NestedNameSpecifierLoc QualifierLoc =
15586 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15587 if (!QualifierLoc)
15588 return ExprError();
15589 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15590
15591 // TODO: If this is a conversion-function-id, verify that the
15592 // destination type name (if present) resolves the same way after
15593 // instantiation as it did in the local scope.
15594
15595 DeclarationNameInfo NameInfo =
15596 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15597 if (!NameInfo.getName())
15598 return ExprError();
15599
15600 if (!E->hasExplicitTemplateArgs()) {
15601 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15602 // Note: it is sufficient to compare the Name component of NameInfo:
15603 // if name has not changed, DNLoc has not changed either.
15604 NameInfo.getName() == E->getDeclName())
15605 return E;
15606
15607 return getDerived().RebuildDependentScopeDeclRefExpr(
15608 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15609 IsAddressOfOperand, RecoveryTSI);
15610 }
15611
15612 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15613 if (getDerived().TransformTemplateArguments(
15614 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15615 return ExprError();
15616
15617 return getDerived().RebuildDependentScopeDeclRefExpr(
15618 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15619 RecoveryTSI);
15620}
15621
15622template<typename Derived>
15625 // CXXConstructExprs other than for list-initialization and
15626 // CXXTemporaryObjectExpr are always implicit, so when we have
15627 // a 1-argument construction we just transform that argument.
15628 if (getDerived().AllowSkippingCXXConstructExpr() &&
15629 ((E->getNumArgs() == 1 ||
15630 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15631 (!getDerived().DropCallArgument(E->getArg(0))) &&
15632 !E->isListInitialization()))
15633 return getDerived().TransformInitializer(E->getArg(0),
15634 /*DirectInit*/ false);
15635
15636 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15637
15638 QualType T = getDerived().TransformType(E->getType());
15639 if (T.isNull())
15640 return ExprError();
15641
15642 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15643 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15644 if (!Constructor)
15645 return ExprError();
15646
15647 bool ArgumentChanged = false;
15649 {
15652 E->isListInitialization());
15653 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15654 &ArgumentChanged))
15655 return ExprError();
15656 }
15657
15658 if (!getDerived().AlwaysRebuild() &&
15659 T == E->getType() &&
15660 Constructor == E->getConstructor() &&
15661 !ArgumentChanged) {
15662 // Mark the constructor as referenced.
15663 // FIXME: Instantiation-specific
15664 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15665 return E;
15666 }
15667
15668 return getDerived().RebuildCXXConstructExpr(
15669 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15670 E->hadMultipleCandidates(), E->isListInitialization(),
15671 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15672 E->getConstructionKind(), E->getParenOrBraceRange());
15673}
15674
15675template<typename Derived>
15678 QualType T = getDerived().TransformType(E->getType());
15679 if (T.isNull())
15680 return ExprError();
15681
15682 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15683 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15684 if (!Constructor)
15685 return ExprError();
15686
15687 if (!getDerived().AlwaysRebuild() &&
15688 T == E->getType() &&
15689 Constructor == E->getConstructor()) {
15690 // Mark the constructor as referenced.
15691 // FIXME: Instantiation-specific
15692 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15693 return E;
15694 }
15695
15696 return getDerived().RebuildCXXInheritedCtorInitExpr(
15697 T, E->getLocation(), Constructor,
15698 E->constructsVBase(), E->inheritedFromVBase());
15699}
15700
15701/// Transform a C++ temporary-binding expression.
15702///
15703/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15704/// transform the subexpression and return that.
15705template<typename Derived>
15708 if (auto *Dtor = E->getTemporary()->getDestructor())
15709 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15710 const_cast<CXXDestructorDecl *>(Dtor));
15711 return getDerived().TransformExpr(E->getSubExpr());
15712}
15713
15714/// Transform a C++ expression that contains cleanups that should
15715/// be run after the expression is evaluated.
15716///
15717/// Since ExprWithCleanups nodes are implicitly generated, we
15718/// just transform the subexpression and return that.
15719template<typename Derived>
15722 return getDerived().TransformExpr(E->getSubExpr());
15723}
15724
15725template<typename Derived>
15729 TypeSourceInfo *T =
15730 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15731 if (!T)
15732 return ExprError();
15733
15734 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15735 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15736 if (!Constructor)
15737 return ExprError();
15738
15739 bool ArgumentChanged = false;
15741 Args.reserve(E->getNumArgs());
15742 {
15745 E->isListInitialization());
15746 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15747 &ArgumentChanged))
15748 return ExprError();
15749
15750 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15751 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc(),
15752 /*IsExplicit=*/true);
15753 if (Res.isInvalid())
15754 return ExprError();
15755 Args = {Res.get()};
15756 }
15757 }
15758
15759 if (!getDerived().AlwaysRebuild() &&
15760 T == E->getTypeSourceInfo() &&
15761 Constructor == E->getConstructor() &&
15762 !ArgumentChanged) {
15763 // FIXME: Instantiation-specific
15764 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15765 return SemaRef.MaybeBindToTemporary(E);
15766 }
15767
15768 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15769 return getDerived().RebuildCXXTemporaryObjectExpr(
15770 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15771}
15772
15773template<typename Derived>
15776 // Transform any init-capture expressions before entering the scope of the
15777 // lambda body, because they are not semantically within that scope.
15778 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15779 struct TransformedInitCapture {
15780 // The location of the ... if the result is retaining a pack expansion.
15781 SourceLocation EllipsisLoc;
15782 // Zero or more expansions of the init-capture.
15783 SmallVector<InitCaptureInfoTy, 4> Expansions;
15784 };
15786 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15787 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15788 CEnd = E->capture_end();
15789 C != CEnd; ++C) {
15790 if (!E->isInitCapture(C))
15791 continue;
15792
15793 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15794 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15795
15796 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15797 UnsignedOrNone NumExpansions) {
15798 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15799 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15800
15801 if (NewExprInitResult.isInvalid()) {
15802 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15803 return;
15804 }
15805 Expr *NewExprInit = NewExprInitResult.get();
15806
15807 QualType NewInitCaptureType =
15808 getSema().buildLambdaInitCaptureInitialization(
15809 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15810 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15811 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15813 NewExprInit);
15814 Result.Expansions.push_back(
15815 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15816 };
15817
15818 // If this is an init-capture pack, consider expanding the pack now.
15819 if (OldVD->isParameterPack()) {
15820 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15821 ->getTypeLoc()
15824 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15825
15826 // Determine whether the set of unexpanded parameter packs can and should
15827 // be expanded.
15828 bool Expand = true;
15829 bool RetainExpansion = false;
15830 UnsignedOrNone OrigNumExpansions =
15831 ExpansionTL.getTypePtr()->getNumExpansions();
15832 UnsignedOrNone NumExpansions = OrigNumExpansions;
15833 if (getDerived().TryExpandParameterPacks(
15834 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15835 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15836 RetainExpansion, NumExpansions))
15837 return ExprError();
15838 assert(!RetainExpansion && "Should not need to retain expansion after a "
15839 "capture since it cannot be extended");
15840 if (Expand) {
15841 for (unsigned I = 0; I != *NumExpansions; ++I) {
15842 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15843 SubstInitCapture(SourceLocation(), std::nullopt);
15844 }
15845 } else {
15846 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15847 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15848 }
15849 } else {
15850 SubstInitCapture(SourceLocation(), std::nullopt);
15851 }
15852 }
15853
15854 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15855 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15856
15857 // Create the local class that will describe the lambda.
15858
15859 // FIXME: DependencyKind below is wrong when substituting inside a templated
15860 // context that isn't a DeclContext (such as a variable template), or when
15861 // substituting an unevaluated lambda inside of a function's parameter's type
15862 // - as parameter types are not instantiated from within a function's DC. We
15863 // use evaluation contexts to distinguish the function parameter case.
15866 DeclContext *DC = getSema().CurContext;
15867 // A RequiresExprBodyDecl is not interesting for dependencies.
15868 // For the following case,
15869 //
15870 // template <typename>
15871 // concept C = requires { [] {}; };
15872 //
15873 // template <class F>
15874 // struct Widget;
15875 //
15876 // template <C F>
15877 // struct Widget<F> {};
15878 //
15879 // While we are substituting Widget<F>, the parent of DC would be
15880 // the template specialization itself. Thus, the lambda expression
15881 // will be deemed as dependent even if there are no dependent template
15882 // arguments.
15883 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15884 while (DC->isRequiresExprBody())
15885 DC = DC->getParent();
15886 if ((getSema().isUnevaluatedContext() ||
15887 getSema().isConstantEvaluatedContext()) &&
15888 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15889 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
15890 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15891 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15892
15893 CXXRecordDecl *OldClass = E->getLambdaClass();
15894 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15895 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15896 E->getCaptureDefault());
15897 getDerived().transformedLocalDecl(OldClass, {Class});
15898
15899 CXXMethodDecl *NewCallOperator =
15900 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15901
15902 // Enter the scope of the lambda.
15903 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15904 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15905 E->hasExplicitParameters(), E->isMutable());
15906
15907 // Introduce the context of the call operator.
15908 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15909 /*NewThisContext*/false);
15910
15911 bool Invalid = false;
15912
15913 // Transform captures.
15914 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15915 CEnd = E->capture_end();
15916 C != CEnd; ++C) {
15917 // When we hit the first implicit capture, tell Sema that we've finished
15918 // the list of explicit captures.
15919 if (C->isImplicit())
15920 break;
15921
15922 // Capturing 'this' is trivial.
15923 if (C->capturesThis()) {
15924 // If this is a lambda that is part of a default member initialiser
15925 // and which we're instantiating outside the class that 'this' is
15926 // supposed to refer to, adjust the type of 'this' accordingly.
15927 //
15928 // Otherwise, leave the type of 'this' as-is.
15929 Sema::CXXThisScopeRAII ThisScope(
15930 getSema(),
15931 dyn_cast_if_present<CXXRecordDecl>(
15932 getSema().getFunctionLevelDeclContext()),
15933 Qualifiers());
15934 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15935 /*BuildAndDiagnose*/ true, nullptr,
15936 C->getCaptureKind() == LCK_StarThis);
15937 continue;
15938 }
15939 // Captured expression will be recaptured during captured variables
15940 // rebuilding.
15941 if (C->capturesVLAType())
15942 continue;
15943
15944 // Rebuild init-captures, including the implied field declaration.
15945 if (E->isInitCapture(C)) {
15946 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15947
15948 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15950
15951 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15952 ExprResult Init = Info.first;
15953 QualType InitQualType = Info.second;
15954 if (Init.isInvalid() || InitQualType.isNull()) {
15955 Invalid = true;
15956 break;
15957 }
15958 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15959 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15960 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15961 getSema().CurContext);
15962 if (!NewVD) {
15963 Invalid = true;
15964 break;
15965 }
15966 NewVDs.push_back(NewVD);
15967 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15968 // Cases we want to tackle:
15969 // ([C(Pack)] {}, ...)
15970 // But rule out cases e.g.
15971 // [...C = Pack()] {}
15972 if (NewC.EllipsisLoc.isInvalid())
15973 LSI->ContainsUnexpandedParameterPack |=
15974 Init.get()->containsUnexpandedParameterPack();
15975 }
15976
15977 if (Invalid)
15978 break;
15979
15980 getDerived().transformedLocalDecl(OldVD, NewVDs);
15981 continue;
15982 }
15983
15984 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15985
15986 // Determine the capture kind for Sema.
15988 : C->getCaptureKind() == LCK_ByCopy
15991 SourceLocation EllipsisLoc;
15992 if (C->isPackExpansion()) {
15993 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15994 bool ShouldExpand = false;
15995 bool RetainExpansion = false;
15996 UnsignedOrNone NumExpansions = std::nullopt;
15997 if (getDerived().TryExpandParameterPacks(
15998 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
15999 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16000 RetainExpansion, NumExpansions)) {
16001 Invalid = true;
16002 continue;
16003 }
16004
16005 if (ShouldExpand) {
16006 // The transform has determined that we should perform an expansion;
16007 // transform and capture each of the arguments.
16008 // expansion of the pattern. Do so.
16009 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
16010 for (unsigned I = 0; I != *NumExpansions; ++I) {
16011 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16012 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
16013 getDerived().TransformDecl(C->getLocation(), Pack));
16014 if (!CapturedVar) {
16015 Invalid = true;
16016 continue;
16017 }
16018
16019 // Capture the transformed variable.
16020 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
16021 }
16022
16023 // FIXME: Retain a pack expansion if RetainExpansion is true.
16024
16025 continue;
16026 }
16027
16028 EllipsisLoc = C->getEllipsisLoc();
16029 }
16030
16031 // Transform the captured variable.
16032 auto *CapturedVar = cast_or_null<ValueDecl>(
16033 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16034 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
16035 Invalid = true;
16036 continue;
16037 }
16038
16039 // This is not an init-capture; however it contains an unexpanded pack e.g.
16040 // ([Pack] {}(), ...)
16041 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
16042 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
16043
16044 // Capture the transformed variable.
16045 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
16046 EllipsisLoc);
16047 }
16048 getSema().finishLambdaExplicitCaptures(LSI);
16049
16050 // Transform the template parameters, and add them to the current
16051 // instantiation scope. The null case is handled correctly.
16052 auto TPL = getDerived().TransformTemplateParameterList(
16053 E->getTemplateParameterList());
16054 LSI->GLTemplateParameterList = TPL;
16055 if (TPL) {
16056 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
16057 TPL);
16058 LSI->ContainsUnexpandedParameterPack |=
16059 TPL->containsUnexpandedParameterPack();
16060 }
16061
16062 TypeLocBuilder NewCallOpTLBuilder;
16063 TypeLoc OldCallOpTypeLoc =
16064 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
16065 QualType NewCallOpType =
16066 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
16067 if (NewCallOpType.isNull())
16068 return ExprError();
16069 LSI->ContainsUnexpandedParameterPack |=
16070 NewCallOpType->containsUnexpandedParameterPack();
16071 TypeSourceInfo *NewCallOpTSI =
16072 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
16073
16074 // The type may be an AttributedType or some other kind of sugar;
16075 // get the actual underlying FunctionProtoType.
16076 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
16077 assert(FPTL && "Not a FunctionProtoType?");
16078
16079 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
16080 // If the concept refers to any outer parameter packs, we track the SubstIndex
16081 // for evaluation.
16082 if (TRC && TRC.ConstraintExpr->containsUnexpandedParameterPack() &&
16083 !TRC.ArgPackSubstIndex)
16085
16086 getSema().CompleteLambdaCallOperator(
16087 NewCallOperator, E->getCallOperator()->getLocation(),
16088 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
16089 E->getCallOperator()->getConstexprKind(),
16090 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
16091 E->hasExplicitResultType());
16092
16093 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
16094 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
16095
16096 {
16097 // Number the lambda for linkage purposes if necessary.
16098 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
16099
16100 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
16101 if (getDerived().ReplacingOriginal()) {
16102 Numbering = OldClass->getLambdaNumbering();
16103 }
16104
16105 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
16106 }
16107
16108 // FIXME: Sema's lambda-building mechanism expects us to push an expression
16109 // evaluation context even if we're not transforming the function body.
16110 getSema().PushExpressionEvaluationContextForFunction(
16112 E->getCallOperator());
16113
16114 StmtResult Body;
16115 {
16116 Sema::NonSFINAEContext _(getSema());
16119 C.PointOfInstantiation = E->getBody()->getBeginLoc();
16120 getSema().pushCodeSynthesisContext(C);
16121
16122 // Instantiate the body of the lambda expression.
16123 Body = Invalid ? StmtError()
16124 : getDerived().TransformLambdaBody(E, E->getBody());
16125
16126 getSema().popCodeSynthesisContext();
16127 }
16128
16129 // ActOnLambda* will pop the function scope for us.
16130 FuncScopeCleanup.disable();
16131
16132 if (Body.isInvalid()) {
16133 SavedContext.pop();
16134 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
16135 /*IsInstantiation=*/true);
16136 return ExprError();
16137 }
16138
16139 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
16140 /*IsInstantiation=*/true,
16141 /*RetainFunctionScopeInfo=*/true);
16142 SavedContext.pop();
16143
16144 // Recompute the dependency of the lambda so that we can defer the lambda call
16145 // construction until after we have all the necessary template arguments. For
16146 // example, given
16147 //
16148 // template <class> struct S {
16149 // template <class U>
16150 // using Type = decltype([](U){}(42.0));
16151 // };
16152 // void foo() {
16153 // using T = S<int>::Type<float>;
16154 // ^~~~~~
16155 // }
16156 //
16157 // We would end up here from instantiating S<int> when ensuring its
16158 // completeness. That would transform the lambda call expression regardless of
16159 // the absence of the corresponding argument for U.
16160 //
16161 // Going ahead with unsubstituted type U makes things worse: we would soon
16162 // compare the argument type (which is float) against the parameter U
16163 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
16164 // error suggesting unmatched types 'U' and 'float'!
16165 //
16166 // That said, everything will be fine if we defer that semantic checking.
16167 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
16168 // dependent. Since the CallExpr's dependency boils down to the lambda's
16169 // dependency in this case, we can harness that by recomputing the dependency
16170 // from the instantiation arguments.
16171 //
16172 // FIXME: Creating the type of a lambda requires us to have a dependency
16173 // value, which happens before its substitution. We update its dependency
16174 // *after* the substitution in case we can't decide the dependency
16175 // so early, e.g. because we want to see if any of the *substituted*
16176 // parameters are dependent.
16177 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
16178 Class->setLambdaDependencyKind(DependencyKind);
16179
16180 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
16181 Body.get()->getEndLoc(), LSI);
16182}
16183
16184template<typename Derived>
16189
16190template<typename Derived>
16193 // Transform captures.
16195 CEnd = E->capture_end();
16196 C != CEnd; ++C) {
16197 // When we hit the first implicit capture, tell Sema that we've finished
16198 // the list of explicit captures.
16199 if (!C->isImplicit())
16200 continue;
16201
16202 // Capturing 'this' is trivial.
16203 if (C->capturesThis()) {
16204 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16205 /*BuildAndDiagnose*/ true, nullptr,
16206 C->getCaptureKind() == LCK_StarThis);
16207 continue;
16208 }
16209 // Captured expression will be recaptured during captured variables
16210 // rebuilding.
16211 if (C->capturesVLAType())
16212 continue;
16213
16214 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16215 assert(!E->isInitCapture(C) && "implicit init-capture?");
16216
16217 // Transform the captured variable.
16218 VarDecl *CapturedVar = cast_or_null<VarDecl>(
16219 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16220 if (!CapturedVar || CapturedVar->isInvalidDecl())
16221 return StmtError();
16222
16223 // Capture the transformed variable.
16224 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16225 }
16226
16227 return S;
16228}
16229
16230template<typename Derived>
16234 TypeSourceInfo *T =
16235 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16236 if (!T)
16237 return ExprError();
16238
16239 bool ArgumentChanged = false;
16241 Args.reserve(E->getNumArgs());
16242 {
16246 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16247 &ArgumentChanged))
16248 return ExprError();
16249 }
16250
16251 if (!getDerived().AlwaysRebuild() &&
16252 T == E->getTypeSourceInfo() &&
16253 !ArgumentChanged)
16254 return E;
16255
16256 // FIXME: we're faking the locations of the commas
16257 return getDerived().RebuildCXXUnresolvedConstructExpr(
16258 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16259}
16260
16261template<typename Derived>
16265 // Transform the base of the expression.
16266 ExprResult Base((Expr*) nullptr);
16267 Expr *OldBase;
16268 QualType BaseType;
16269 QualType ObjectType;
16270 if (!E->isImplicitAccess()) {
16271 OldBase = E->getBase();
16272 Base = getDerived().TransformExpr(OldBase);
16273 if (Base.isInvalid())
16274 return ExprError();
16275
16276 // Start the member reference and compute the object's type.
16277 ParsedType ObjectTy;
16278 bool MayBePseudoDestructor = false;
16279 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16280 E->getOperatorLoc(),
16281 E->isArrow()? tok::arrow : tok::period,
16282 ObjectTy,
16283 MayBePseudoDestructor);
16284 if (Base.isInvalid())
16285 return ExprError();
16286
16287 ObjectType = ObjectTy.get();
16288 BaseType = ((Expr*) Base.get())->getType();
16289 } else {
16290 OldBase = nullptr;
16291 BaseType = getDerived().TransformType(E->getBaseType());
16292 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16293 }
16294
16295 // Transform the first part of the nested-name-specifier that qualifies
16296 // the member name.
16297 NamedDecl *FirstQualifierInScope
16298 = getDerived().TransformFirstQualifierInScope(
16299 E->getFirstQualifierFoundInScope(),
16300 E->getQualifierLoc().getBeginLoc());
16301
16302 NestedNameSpecifierLoc QualifierLoc;
16303 if (E->getQualifier()) {
16304 QualifierLoc
16305 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16306 ObjectType,
16307 FirstQualifierInScope);
16308 if (!QualifierLoc)
16309 return ExprError();
16310 }
16311
16312 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16313
16314 // TODO: If this is a conversion-function-id, verify that the
16315 // destination type name (if present) resolves the same way after
16316 // instantiation as it did in the local scope.
16317
16318 DeclarationNameInfo NameInfo
16319 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16320 if (!NameInfo.getName())
16321 return ExprError();
16322
16323 if (!E->hasExplicitTemplateArgs()) {
16324 // This is a reference to a member without an explicitly-specified
16325 // template argument list. Optimize for this common case.
16326 if (!getDerived().AlwaysRebuild() &&
16327 Base.get() == OldBase &&
16328 BaseType == E->getBaseType() &&
16329 QualifierLoc == E->getQualifierLoc() &&
16330 NameInfo.getName() == E->getMember() &&
16331 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16332 return E;
16333
16334 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16335 BaseType,
16336 E->isArrow(),
16337 E->getOperatorLoc(),
16338 QualifierLoc,
16339 TemplateKWLoc,
16340 FirstQualifierInScope,
16341 NameInfo,
16342 /*TemplateArgs*/nullptr);
16343 }
16344
16345 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16346 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16347 E->getNumTemplateArgs(),
16348 TransArgs))
16349 return ExprError();
16350
16351 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16352 BaseType,
16353 E->isArrow(),
16354 E->getOperatorLoc(),
16355 QualifierLoc,
16356 TemplateKWLoc,
16357 FirstQualifierInScope,
16358 NameInfo,
16359 &TransArgs);
16360}
16361
16362template <typename Derived>
16364 UnresolvedMemberExpr *Old) {
16365 // Transform the base of the expression.
16366 ExprResult Base((Expr *)nullptr);
16367 QualType BaseType;
16368 if (!Old->isImplicitAccess()) {
16369 Base = getDerived().TransformExpr(Old->getBase());
16370 if (Base.isInvalid())
16371 return ExprError();
16372 Base =
16373 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16374 if (Base.isInvalid())
16375 return ExprError();
16376 BaseType = Base.get()->getType();
16377 } else {
16378 BaseType = getDerived().TransformType(Old->getBaseType());
16379 }
16380
16381 NestedNameSpecifierLoc QualifierLoc;
16382 if (Old->getQualifierLoc()) {
16383 QualifierLoc =
16384 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16385 if (!QualifierLoc)
16386 return ExprError();
16387 }
16388
16389 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16390
16391 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16392
16393 // Transform the declaration set.
16394 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16395 return ExprError();
16396
16397 // Determine the naming class.
16398 if (Old->getNamingClass()) {
16399 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16400 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16401 if (!NamingClass)
16402 return ExprError();
16403
16404 R.setNamingClass(NamingClass);
16405 }
16406
16407 TemplateArgumentListInfo TransArgs;
16408 if (Old->hasExplicitTemplateArgs()) {
16409 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16410 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16411 if (getDerived().TransformTemplateArguments(
16412 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16413 return ExprError();
16414 }
16415
16416 // FIXME: to do this check properly, we will need to preserve the
16417 // first-qualifier-in-scope here, just in case we had a dependent
16418 // base (and therefore couldn't do the check) and a
16419 // nested-name-qualifier (and therefore could do the lookup).
16420 NamedDecl *FirstQualifierInScope = nullptr;
16421
16422 return getDerived().RebuildUnresolvedMemberExpr(
16423 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16424 TemplateKWLoc, FirstQualifierInScope, R,
16425 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16426}
16427
16428template<typename Derived>
16433 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16434 if (SubExpr.isInvalid())
16435 return ExprError();
16436
16437 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16438 return E;
16439
16440 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16441}
16442
16443template<typename Derived>
16446 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16447 if (Pattern.isInvalid())
16448 return ExprError();
16449
16450 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16451 return E;
16452
16453 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16454 E->getNumExpansions());
16455}
16456
16457template <typename Derived>
16459 ArrayRef<TemplateArgument> PackArgs) {
16461 for (const TemplateArgument &Arg : PackArgs) {
16462 if (!Arg.isPackExpansion()) {
16463 Result = *Result + 1;
16464 continue;
16465 }
16466
16467 TemplateArgumentLoc ArgLoc;
16468 InventTemplateArgumentLoc(Arg, ArgLoc);
16469
16470 // Find the pattern of the pack expansion.
16471 SourceLocation Ellipsis;
16472 UnsignedOrNone OrigNumExpansions = std::nullopt;
16473 TemplateArgumentLoc Pattern =
16474 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16475 OrigNumExpansions);
16476
16477 // Substitute under the pack expansion. Do not expand the pack (yet).
16478 TemplateArgumentLoc OutPattern;
16479 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16480 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16481 /*Uneval*/ true))
16482 return 1u;
16483
16484 // See if we can determine the number of arguments from the result.
16485 UnsignedOrNone NumExpansions =
16486 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16487 if (!NumExpansions) {
16488 // No: we must be in an alias template expansion, and we're going to
16489 // need to actually expand the packs.
16490 Result = std::nullopt;
16491 break;
16492 }
16493
16494 Result = *Result + *NumExpansions;
16495 }
16496 return Result;
16497}
16498
16499template<typename Derived>
16502 // If E is not value-dependent, then nothing will change when we transform it.
16503 // Note: This is an instantiation-centric view.
16504 if (!E->isValueDependent())
16505 return E;
16506
16509
16511 TemplateArgument ArgStorage;
16512
16513 // Find the argument list to transform.
16514 if (E->isPartiallySubstituted()) {
16515 PackArgs = E->getPartialArguments();
16516 } else if (E->isValueDependent()) {
16517 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16518 bool ShouldExpand = false;
16519 bool RetainExpansion = false;
16520 UnsignedOrNone NumExpansions = std::nullopt;
16521 if (getDerived().TryExpandParameterPacks(
16522 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16523 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16524 RetainExpansion, NumExpansions))
16525 return ExprError();
16526
16527 // If we need to expand the pack, build a template argument from it and
16528 // expand that.
16529 if (ShouldExpand) {
16530 auto *Pack = E->getPack();
16531 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16532 ArgStorage = getSema().Context.getPackExpansionType(
16533 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16534 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16535 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16536 } else {
16537 auto *VD = cast<ValueDecl>(Pack);
16538 ExprResult DRE = getSema().BuildDeclRefExpr(
16539 VD, VD->getType().getNonLValueExprType(getSema().Context),
16540 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16541 E->getPackLoc());
16542 if (DRE.isInvalid())
16543 return ExprError();
16544 ArgStorage = TemplateArgument(
16545 new (getSema().Context)
16546 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16547 /*IsCanonical=*/false);
16548 }
16549 PackArgs = ArgStorage;
16550 }
16551 }
16552
16553 // If we're not expanding the pack, just transform the decl.
16554 if (!PackArgs.size()) {
16555 auto *Pack = cast_or_null<NamedDecl>(
16556 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16557 if (!Pack)
16558 return ExprError();
16559 return getDerived().RebuildSizeOfPackExpr(
16560 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16561 std::nullopt, {});
16562 }
16563
16564 // Try to compute the result without performing a partial substitution.
16566 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16567
16568 // Common case: we could determine the number of expansions without
16569 // substituting.
16570 if (Result)
16571 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16572 E->getPackLoc(),
16573 E->getRParenLoc(), *Result, {});
16574
16575 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16576 E->getPackLoc());
16577 {
16578 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16580 Derived, const TemplateArgument*> PackLocIterator;
16581 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16582 PackLocIterator(*this, PackArgs.end()),
16583 TransformedPackArgs, /*Uneval*/true))
16584 return ExprError();
16585 }
16586
16587 // Check whether we managed to fully-expand the pack.
16588 // FIXME: Is it possible for us to do so and not hit the early exit path?
16590 bool PartialSubstitution = false;
16591 for (auto &Loc : TransformedPackArgs.arguments()) {
16592 Args.push_back(Loc.getArgument());
16593 if (Loc.getArgument().isPackExpansion())
16594 PartialSubstitution = true;
16595 }
16596
16597 if (PartialSubstitution)
16598 return getDerived().RebuildSizeOfPackExpr(
16599 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16600 std::nullopt, Args);
16601
16602 return getDerived().RebuildSizeOfPackExpr(
16603 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16604 /*Length=*/static_cast<unsigned>(Args.size()),
16605 /*PartialArgs=*/{});
16606}
16607
16608template <typename Derived>
16611 if (!E->isValueDependent())
16612 return E;
16613
16614 // Transform the index
16615 ExprResult IndexExpr;
16616 {
16617 EnterExpressionEvaluationContext ConstantContext(
16619 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16620 if (IndexExpr.isInvalid())
16621 return ExprError();
16622 }
16623
16624 SmallVector<Expr *, 5> ExpandedExprs;
16625 bool FullySubstituted = true;
16626 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16627 Expr *Pattern = E->getPackIdExpression();
16629 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16630 Unexpanded);
16631 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16632
16633 // Determine whether the set of unexpanded parameter packs can and should
16634 // be expanded.
16635 bool ShouldExpand = true;
16636 bool RetainExpansion = false;
16637 UnsignedOrNone OrigNumExpansions = std::nullopt,
16638 NumExpansions = std::nullopt;
16639 if (getDerived().TryExpandParameterPacks(
16640 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16641 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16642 RetainExpansion, NumExpansions))
16643 return true;
16644 if (!ShouldExpand) {
16645 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16646 ExprResult Pack = getDerived().TransformExpr(Pattern);
16647 if (Pack.isInvalid())
16648 return ExprError();
16649 return getDerived().RebuildPackIndexingExpr(
16650 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16651 {}, /*FullySubstituted=*/false);
16652 }
16653 for (unsigned I = 0; I != *NumExpansions; ++I) {
16654 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16655 ExprResult Out = getDerived().TransformExpr(Pattern);
16656 if (Out.isInvalid())
16657 return true;
16658 if (Out.get()->containsUnexpandedParameterPack()) {
16659 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16660 OrigNumExpansions);
16661 if (Out.isInvalid())
16662 return true;
16663 FullySubstituted = false;
16664 }
16665 ExpandedExprs.push_back(Out.get());
16666 }
16667 // If we're supposed to retain a pack expansion, do so by temporarily
16668 // forgetting the partially-substituted parameter pack.
16669 if (RetainExpansion) {
16670 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16671
16672 ExprResult Out = getDerived().TransformExpr(Pattern);
16673 if (Out.isInvalid())
16674 return true;
16675
16676 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16677 OrigNumExpansions);
16678 if (Out.isInvalid())
16679 return true;
16680 FullySubstituted = false;
16681 ExpandedExprs.push_back(Out.get());
16682 }
16683 } else if (!E->expandsToEmptyPack()) {
16684 if (getDerived().TransformExprs(E->getExpressions().data(),
16685 E->getExpressions().size(), false,
16686 ExpandedExprs))
16687 return ExprError();
16688 }
16689
16690 return getDerived().RebuildPackIndexingExpr(
16691 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16692 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16693}
16694
16695template <typename Derived>
16698 if (!getSema().ArgPackSubstIndex)
16699 // We aren't expanding the parameter pack, so just return ourselves.
16700 return E;
16701
16702 TemplateArgument Pack = E->getArgumentPack();
16704 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16705 E->getAssociatedDecl(), E->getParameterPack()->getPosition(),
16706 E->getParameterPack()->getType(), E->getParameterPackLocation(), Arg,
16707 SemaRef.getPackIndex(Pack), E->getFinal());
16708}
16709
16710template <typename Derived>
16713 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16714 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16715 if (Replacement.isInvalid())
16716 return true;
16717
16718 Decl *AssociatedDecl =
16719 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16720 if (!AssociatedDecl)
16721 return true;
16722
16723 QualType ParamType = TransformType(E->getParameterType());
16724 if (ParamType.isNull())
16725 return true;
16726
16727 if (Replacement.get() == OrigReplacement &&
16728 AssociatedDecl == E->getAssociatedDecl() &&
16729 ParamType == E->getParameterType())
16730 return E;
16731
16732 if (Replacement.get() != OrigReplacement ||
16733 ParamType != E->getParameterType()) {
16734 auto *Param = cast<NonTypeTemplateParmDecl>(std::get<0>(
16735 getReplacedTemplateParameter(AssociatedDecl, E->getIndex())));
16736 // When transforming the replacement expression previously, all Sema
16737 // specific annotations, such as implicit casts, are discarded. Calling the
16738 // corresponding sema action is necessary to recover those. Otherwise,
16739 // equivalency of the result would be lost.
16740 TemplateArgument SugaredConverted, CanonicalConverted;
16741 Replacement = SemaRef.CheckTemplateArgument(
16742 Param, ParamType, Replacement.get(), SugaredConverted,
16743 CanonicalConverted,
16744 /*StrictCheck=*/false, Sema::CTAK_Specified);
16745 if (Replacement.isInvalid())
16746 return true;
16747 } else {
16748 // Otherwise, the same expression would have been produced.
16749 Replacement = E->getReplacement();
16750 }
16751
16752 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16753 AssociatedDecl, E->getIndex(), ParamType, E->getNameLoc(),
16754 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
16755 E->getPackIndex(), E->getFinal());
16756}
16757
16758template<typename Derived>
16761 // Default behavior is to do nothing with this transformation.
16762 return E;
16763}
16764
16765template<typename Derived>
16769 return getDerived().TransformExpr(E->getSubExpr());
16770}
16771
16772template<typename Derived>
16775 UnresolvedLookupExpr *Callee = nullptr;
16776 if (Expr *OldCallee = E->getCallee()) {
16777 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16778 if (CalleeResult.isInvalid())
16779 return ExprError();
16780 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16781 }
16782
16783 Expr *Pattern = E->getPattern();
16784
16786 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16787 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16788
16789 // Determine whether the set of unexpanded parameter packs can and should
16790 // be expanded.
16791 bool Expand = true;
16792 bool RetainExpansion = false;
16793 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16794 NumExpansions = OrigNumExpansions;
16795 if (getDerived().TryExpandParameterPacks(
16796 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16797 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16798 NumExpansions))
16799 return true;
16800
16801 if (!Expand) {
16802 // Do not expand any packs here, just transform and rebuild a fold
16803 // expression.
16804 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16805
16806 ExprResult LHS =
16807 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16808 if (LHS.isInvalid())
16809 return true;
16810
16811 ExprResult RHS =
16812 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16813 if (RHS.isInvalid())
16814 return true;
16815
16816 if (!getDerived().AlwaysRebuild() &&
16817 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16818 return E;
16819
16820 return getDerived().RebuildCXXFoldExpr(
16821 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16822 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16823 }
16824
16825 // Formally a fold expression expands to nested parenthesized expressions.
16826 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16827 // them.
16828 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16829 SemaRef.Diag(E->getEllipsisLoc(),
16830 clang::diag::err_fold_expression_limit_exceeded)
16831 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16832 << E->getSourceRange();
16833 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16834 return ExprError();
16835 }
16836
16837 // The transform has determined that we should perform an elementwise
16838 // expansion of the pattern. Do so.
16839 ExprResult Result = getDerived().TransformExpr(E->getInit());
16840 if (Result.isInvalid())
16841 return true;
16842 bool LeftFold = E->isLeftFold();
16843
16844 // If we're retaining an expansion for a right fold, it is the innermost
16845 // component and takes the init (if any).
16846 if (!LeftFold && RetainExpansion) {
16847 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16848
16849 ExprResult Out = getDerived().TransformExpr(Pattern);
16850 if (Out.isInvalid())
16851 return true;
16852
16853 Result = getDerived().RebuildCXXFoldExpr(
16854 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16855 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16856 if (Result.isInvalid())
16857 return true;
16858 }
16859
16860 bool WarnedOnComparison = false;
16861 for (unsigned I = 0; I != *NumExpansions; ++I) {
16862 Sema::ArgPackSubstIndexRAII SubstIndex(
16863 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16864 ExprResult Out = getDerived().TransformExpr(Pattern);
16865 if (Out.isInvalid())
16866 return true;
16867
16868 if (Out.get()->containsUnexpandedParameterPack()) {
16869 // We still have a pack; retain a pack expansion for this slice.
16870 Result = getDerived().RebuildCXXFoldExpr(
16871 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16872 E->getOperator(), E->getEllipsisLoc(),
16873 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16874 OrigNumExpansions);
16875 } else if (Result.isUsable()) {
16876 // We've got down to a single element; build a binary operator.
16877 Expr *LHS = LeftFold ? Result.get() : Out.get();
16878 Expr *RHS = LeftFold ? Out.get() : Result.get();
16879 if (Callee) {
16880 UnresolvedSet<16> Functions;
16881 Functions.append(Callee->decls_begin(), Callee->decls_end());
16882 Result = getDerived().RebuildCXXOperatorCallExpr(
16883 BinaryOperator::getOverloadedOperator(E->getOperator()),
16884 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16885 Functions, LHS, RHS);
16886 } else {
16887 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16888 E->getOperator(), LHS, RHS,
16889 /*ForFoldExpresion=*/true);
16890 if (!WarnedOnComparison && Result.isUsable()) {
16891 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16892 BO && BO->isComparisonOp()) {
16893 WarnedOnComparison = true;
16894 SemaRef.Diag(BO->getBeginLoc(),
16895 diag::warn_comparison_in_fold_expression)
16896 << BO->getOpcodeStr();
16897 }
16898 }
16899 }
16900 } else
16901 Result = Out;
16902
16903 if (Result.isInvalid())
16904 return true;
16905 }
16906
16907 // If we're retaining an expansion for a left fold, it is the outermost
16908 // component and takes the complete expansion so far as its init (if any).
16909 if (LeftFold && RetainExpansion) {
16910 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16911
16912 ExprResult Out = getDerived().TransformExpr(Pattern);
16913 if (Out.isInvalid())
16914 return true;
16915
16916 Result = getDerived().RebuildCXXFoldExpr(
16917 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16918 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16919 if (Result.isInvalid())
16920 return true;
16921 }
16922
16923 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16924 PE->setIsProducedByFoldExpansion();
16925
16926 // If we had no init and an empty pack, and we're not retaining an expansion,
16927 // then produce a fallback value or error.
16928 if (Result.isUnset())
16929 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16930 E->getOperator());
16931 return Result;
16932}
16933
16934template <typename Derived>
16937 SmallVector<Expr *, 4> TransformedInits;
16938 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16939
16940 QualType T = getDerived().TransformType(E->getType());
16941
16942 bool ArgChanged = false;
16943
16944 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16945 TransformedInits, &ArgChanged))
16946 return ExprError();
16947
16948 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16949 return E;
16950
16951 return getDerived().RebuildCXXParenListInitExpr(
16952 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16953 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16954}
16955
16956template<typename Derived>
16960 return getDerived().TransformExpr(E->getSubExpr());
16961}
16962
16963template<typename Derived>
16966 return SemaRef.MaybeBindToTemporary(E);
16967}
16968
16969template<typename Derived>
16972 return E;
16973}
16974
16975template<typename Derived>
16978 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16979 if (SubExpr.isInvalid())
16980 return ExprError();
16981
16982 if (!getDerived().AlwaysRebuild() &&
16983 SubExpr.get() == E->getSubExpr())
16984 return E;
16985
16986 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16987}
16988
16989template<typename Derived>
16992 // Transform each of the elements.
16993 SmallVector<Expr *, 8> Elements;
16994 bool ArgChanged = false;
16995 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
16996 /*IsCall=*/false, Elements, &ArgChanged))
16997 return ExprError();
16998
16999 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17000 return SemaRef.MaybeBindToTemporary(E);
17001
17002 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
17003 Elements.data(),
17004 Elements.size());
17005}
17006
17007template<typename Derived>
17011 // Transform each of the elements.
17013 bool ArgChanged = false;
17014 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
17015 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
17016
17017 if (OrigElement.isPackExpansion()) {
17018 // This key/value element is a pack expansion.
17020 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
17021 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
17022 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
17023
17024 // Determine whether the set of unexpanded parameter packs can
17025 // and should be expanded.
17026 bool Expand = true;
17027 bool RetainExpansion = false;
17028 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
17029 UnsignedOrNone NumExpansions = OrigNumExpansions;
17030 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
17031 OrigElement.Value->getEndLoc());
17032 if (getDerived().TryExpandParameterPacks(
17033 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
17034 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
17035 NumExpansions))
17036 return ExprError();
17037
17038 if (!Expand) {
17039 // The transform has determined that we should perform a simple
17040 // transformation on the pack expansion, producing another pack
17041 // expansion.
17042 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
17043 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17044 if (Key.isInvalid())
17045 return ExprError();
17046
17047 if (Key.get() != OrigElement.Key)
17048 ArgChanged = true;
17049
17050 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17051 if (Value.isInvalid())
17052 return ExprError();
17053
17054 if (Value.get() != OrigElement.Value)
17055 ArgChanged = true;
17056
17057 ObjCDictionaryElement Expansion = {
17058 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
17059 };
17060 Elements.push_back(Expansion);
17061 continue;
17062 }
17063
17064 // Record right away that the argument was changed. This needs
17065 // to happen even if the array expands to nothing.
17066 ArgChanged = true;
17067
17068 // The transform has determined that we should perform an elementwise
17069 // expansion of the pattern. Do so.
17070 for (unsigned I = 0; I != *NumExpansions; ++I) {
17071 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
17072 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17073 if (Key.isInvalid())
17074 return ExprError();
17075
17076 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17077 if (Value.isInvalid())
17078 return ExprError();
17079
17080 ObjCDictionaryElement Element = {
17081 Key.get(), Value.get(), SourceLocation(), NumExpansions
17082 };
17083
17084 // If any unexpanded parameter packs remain, we still have a
17085 // pack expansion.
17086 // FIXME: Can this really happen?
17087 if (Key.get()->containsUnexpandedParameterPack() ||
17088 Value.get()->containsUnexpandedParameterPack())
17089 Element.EllipsisLoc = OrigElement.EllipsisLoc;
17090
17091 Elements.push_back(Element);
17092 }
17093
17094 // FIXME: Retain a pack expansion if RetainExpansion is true.
17095
17096 // We've finished with this pack expansion.
17097 continue;
17098 }
17099
17100 // Transform and check key.
17101 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17102 if (Key.isInvalid())
17103 return ExprError();
17104
17105 if (Key.get() != OrigElement.Key)
17106 ArgChanged = true;
17107
17108 // Transform and check value.
17110 = getDerived().TransformExpr(OrigElement.Value);
17111 if (Value.isInvalid())
17112 return ExprError();
17113
17114 if (Value.get() != OrigElement.Value)
17115 ArgChanged = true;
17116
17117 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
17118 std::nullopt};
17119 Elements.push_back(Element);
17120 }
17121
17122 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17123 return SemaRef.MaybeBindToTemporary(E);
17124
17125 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
17126 Elements);
17127}
17128
17129template<typename Derived>
17132 TypeSourceInfo *EncodedTypeInfo
17133 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
17134 if (!EncodedTypeInfo)
17135 return ExprError();
17136
17137 if (!getDerived().AlwaysRebuild() &&
17138 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
17139 return E;
17140
17141 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
17142 EncodedTypeInfo,
17143 E->getRParenLoc());
17144}
17145
17146template<typename Derived>
17149 // This is a kind of implicit conversion, and it needs to get dropped
17150 // and recomputed for the same general reasons that ImplicitCastExprs
17151 // do, as well a more specific one: this expression is only valid when
17152 // it appears *immediately* as an argument expression.
17153 return getDerived().TransformExpr(E->getSubExpr());
17154}
17155
17156template<typename Derived>
17159 TypeSourceInfo *TSInfo
17160 = getDerived().TransformType(E->getTypeInfoAsWritten());
17161 if (!TSInfo)
17162 return ExprError();
17163
17164 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
17165 if (Result.isInvalid())
17166 return ExprError();
17167
17168 if (!getDerived().AlwaysRebuild() &&
17169 TSInfo == E->getTypeInfoAsWritten() &&
17170 Result.get() == E->getSubExpr())
17171 return E;
17172
17173 return SemaRef.ObjC().BuildObjCBridgedCast(
17174 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
17175 Result.get());
17176}
17177
17178template <typename Derived>
17181 return E;
17182}
17183
17184template<typename Derived>
17187 // Transform arguments.
17188 bool ArgChanged = false;
17190 Args.reserve(E->getNumArgs());
17191 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
17192 &ArgChanged))
17193 return ExprError();
17194
17195 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
17196 // Class message: transform the receiver type.
17197 TypeSourceInfo *ReceiverTypeInfo
17198 = getDerived().TransformType(E->getClassReceiverTypeInfo());
17199 if (!ReceiverTypeInfo)
17200 return ExprError();
17201
17202 // If nothing changed, just retain the existing message send.
17203 if (!getDerived().AlwaysRebuild() &&
17204 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
17205 return SemaRef.MaybeBindToTemporary(E);
17206
17207 // Build a new class message send.
17209 E->getSelectorLocs(SelLocs);
17210 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
17211 E->getSelector(),
17212 SelLocs,
17213 E->getMethodDecl(),
17214 E->getLeftLoc(),
17215 Args,
17216 E->getRightLoc());
17217 }
17218 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17219 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17220 if (!E->getMethodDecl())
17221 return ExprError();
17222
17223 // Build a new class message send to 'super'.
17225 E->getSelectorLocs(SelLocs);
17226 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17227 E->getSelector(),
17228 SelLocs,
17229 E->getReceiverType(),
17230 E->getMethodDecl(),
17231 E->getLeftLoc(),
17232 Args,
17233 E->getRightLoc());
17234 }
17235
17236 // Instance message: transform the receiver
17237 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17238 "Only class and instance messages may be instantiated");
17239 ExprResult Receiver
17240 = getDerived().TransformExpr(E->getInstanceReceiver());
17241 if (Receiver.isInvalid())
17242 return ExprError();
17243
17244 // If nothing changed, just retain the existing message send.
17245 if (!getDerived().AlwaysRebuild() &&
17246 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17247 return SemaRef.MaybeBindToTemporary(E);
17248
17249 // Build a new instance message send.
17251 E->getSelectorLocs(SelLocs);
17252 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17253 E->getSelector(),
17254 SelLocs,
17255 E->getMethodDecl(),
17256 E->getLeftLoc(),
17257 Args,
17258 E->getRightLoc());
17259}
17260
17261template<typename Derived>
17264 return E;
17265}
17266
17267template<typename Derived>
17270 return E;
17271}
17272
17273template<typename Derived>
17276 // Transform the base expression.
17277 ExprResult Base = getDerived().TransformExpr(E->getBase());
17278 if (Base.isInvalid())
17279 return ExprError();
17280
17281 // We don't need to transform the ivar; it will never change.
17282
17283 // If nothing changed, just retain the existing expression.
17284 if (!getDerived().AlwaysRebuild() &&
17285 Base.get() == E->getBase())
17286 return E;
17287
17288 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17289 E->getLocation(),
17290 E->isArrow(), E->isFreeIvar());
17291}
17292
17293template<typename Derived>
17296 // 'super' and types never change. Property never changes. Just
17297 // retain the existing expression.
17298 if (!E->isObjectReceiver())
17299 return E;
17300
17301 // Transform the base expression.
17302 ExprResult Base = getDerived().TransformExpr(E->getBase());
17303 if (Base.isInvalid())
17304 return ExprError();
17305
17306 // We don't need to transform the property; it will never change.
17307
17308 // If nothing changed, just retain the existing expression.
17309 if (!getDerived().AlwaysRebuild() &&
17310 Base.get() == E->getBase())
17311 return E;
17312
17313 if (E->isExplicitProperty())
17314 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17315 E->getExplicitProperty(),
17316 E->getLocation());
17317
17318 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17319 SemaRef.Context.PseudoObjectTy,
17320 E->getImplicitPropertyGetter(),
17321 E->getImplicitPropertySetter(),
17322 E->getLocation());
17323}
17324
17325template<typename Derived>
17328 // Transform the base expression.
17329 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17330 if (Base.isInvalid())
17331 return ExprError();
17332
17333 // Transform the key expression.
17334 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17335 if (Key.isInvalid())
17336 return ExprError();
17337
17338 // If nothing changed, just retain the existing expression.
17339 if (!getDerived().AlwaysRebuild() &&
17340 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17341 return E;
17342
17343 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17344 Base.get(), Key.get(),
17345 E->getAtIndexMethodDecl(),
17346 E->setAtIndexMethodDecl());
17347}
17348
17349template<typename Derived>
17352 // Transform the base expression.
17353 ExprResult Base = getDerived().TransformExpr(E->getBase());
17354 if (Base.isInvalid())
17355 return ExprError();
17356
17357 // If nothing changed, just retain the existing expression.
17358 if (!getDerived().AlwaysRebuild() &&
17359 Base.get() == E->getBase())
17360 return E;
17361
17362 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17363 E->getOpLoc(),
17364 E->isArrow());
17365}
17366
17367template<typename Derived>
17370 bool ArgumentChanged = false;
17371 SmallVector<Expr*, 8> SubExprs;
17372 SubExprs.reserve(E->getNumSubExprs());
17373 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17374 SubExprs, &ArgumentChanged))
17375 return ExprError();
17376
17377 if (!getDerived().AlwaysRebuild() &&
17378 !ArgumentChanged)
17379 return E;
17380
17381 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17382 SubExprs,
17383 E->getRParenLoc());
17384}
17385
17386template<typename Derived>
17389 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17390 if (SrcExpr.isInvalid())
17391 return ExprError();
17392
17393 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17394 if (!Type)
17395 return ExprError();
17396
17397 if (!getDerived().AlwaysRebuild() &&
17398 Type == E->getTypeSourceInfo() &&
17399 SrcExpr.get() == E->getSrcExpr())
17400 return E;
17401
17402 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17403 SrcExpr.get(), Type,
17404 E->getRParenLoc());
17405}
17406
17407template<typename Derived>
17410 BlockDecl *oldBlock = E->getBlockDecl();
17411
17412 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17413 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17414
17415 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17416 blockScope->TheDecl->setBlockMissingReturnType(
17417 oldBlock->blockMissingReturnType());
17418
17420 SmallVector<QualType, 4> paramTypes;
17421
17422 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17423
17424 // Parameter substitution.
17425 Sema::ExtParameterInfoBuilder extParamInfos;
17426 if (getDerived().TransformFunctionTypeParams(
17427 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17428 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17429 extParamInfos)) {
17430 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17431 return ExprError();
17432 }
17433
17434 QualType exprResultType =
17435 getDerived().TransformType(exprFunctionType->getReturnType());
17436
17437 auto epi = exprFunctionType->getExtProtoInfo();
17438 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17439
17441 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17442 blockScope->FunctionType = functionType;
17443
17444 // Set the parameters on the block decl.
17445 if (!params.empty())
17446 blockScope->TheDecl->setParams(params);
17447
17448 if (!oldBlock->blockMissingReturnType()) {
17449 blockScope->HasImplicitReturnType = false;
17450 blockScope->ReturnType = exprResultType;
17451 }
17452
17453 // Transform the body
17454 StmtResult body = getDerived().TransformStmt(E->getBody());
17455 if (body.isInvalid()) {
17456 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17457 return ExprError();
17458 }
17459
17460#ifndef NDEBUG
17461 // In builds with assertions, make sure that we captured everything we
17462 // captured before.
17463 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17464 for (const auto &I : oldBlock->captures()) {
17465 VarDecl *oldCapture = I.getVariable();
17466
17467 // Ignore parameter packs.
17468 if (oldCapture->isParameterPack())
17469 continue;
17470
17471 VarDecl *newCapture =
17472 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17473 oldCapture));
17474 assert(blockScope->CaptureMap.count(newCapture));
17475 }
17476
17477 // The this pointer may not be captured by the instantiated block, even when
17478 // it's captured by the original block, if the expression causing the
17479 // capture is in the discarded branch of a constexpr if statement.
17480 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17481 "this pointer isn't captured in the old block");
17482 }
17483#endif
17484
17485 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17486 /*Scope=*/nullptr);
17487}
17488
17489template<typename Derived>
17492 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17493 if (SrcExpr.isInvalid())
17494 return ExprError();
17495
17496 QualType Type = getDerived().TransformType(E->getType());
17497
17498 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17499 E->getRParenLoc());
17500}
17501
17502template<typename Derived>
17505 bool ArgumentChanged = false;
17506 SmallVector<Expr*, 8> SubExprs;
17507 SubExprs.reserve(E->getNumSubExprs());
17508 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17509 SubExprs, &ArgumentChanged))
17510 return ExprError();
17511
17512 if (!getDerived().AlwaysRebuild() &&
17513 !ArgumentChanged)
17514 return E;
17515
17516 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17517 E->getOp(), E->getRParenLoc());
17518}
17519
17520//===----------------------------------------------------------------------===//
17521// Type reconstruction
17522//===----------------------------------------------------------------------===//
17523
17524template<typename Derived>
17527 return SemaRef.BuildPointerType(PointeeType, Star,
17529}
17530
17531template<typename Derived>
17534 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17536}
17537
17538template<typename Derived>
17541 bool WrittenAsLValue,
17542 SourceLocation Sigil) {
17543 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17544 Sigil, getDerived().getBaseEntity());
17545}
17546
17547template <typename Derived>
17549 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17550 SourceLocation Sigil) {
17551 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17553}
17554
17555template<typename Derived>
17557 const ObjCTypeParamDecl *Decl,
17558 SourceLocation ProtocolLAngleLoc,
17560 ArrayRef<SourceLocation> ProtocolLocs,
17561 SourceLocation ProtocolRAngleLoc) {
17562 return SemaRef.ObjC().BuildObjCTypeParamType(
17563 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17564 /*FailOnError=*/true);
17565}
17566
17567template<typename Derived>
17569 QualType BaseType,
17570 SourceLocation Loc,
17571 SourceLocation TypeArgsLAngleLoc,
17573 SourceLocation TypeArgsRAngleLoc,
17574 SourceLocation ProtocolLAngleLoc,
17576 ArrayRef<SourceLocation> ProtocolLocs,
17577 SourceLocation ProtocolRAngleLoc) {
17578 return SemaRef.ObjC().BuildObjCObjectType(
17579 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17580 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17581 /*FailOnError=*/true,
17582 /*Rebuilding=*/true);
17583}
17584
17585template<typename Derived>
17587 QualType PointeeType,
17589 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17590}
17591
17592template <typename Derived>
17594 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17595 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17596 if (SizeExpr || !Size)
17597 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17598 IndexTypeQuals, BracketsRange,
17600
17601 QualType Types[] = {
17602 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17603 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17604 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17605 };
17606 QualType SizeType;
17607 for (const auto &T : Types)
17608 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17609 SizeType = T;
17610 break;
17611 }
17612
17613 // Note that we can return a VariableArrayType here in the case where
17614 // the element type was a dependent VariableArrayType.
17615 IntegerLiteral *ArraySize
17616 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17617 /*FIXME*/BracketsRange.getBegin());
17618 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17619 IndexTypeQuals, BracketsRange,
17621}
17622
17623template <typename Derived>
17625 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17626 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17627 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17628 IndexTypeQuals, BracketsRange);
17629}
17630
17631template <typename Derived>
17633 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17634 SourceRange BracketsRange) {
17635 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17636 IndexTypeQuals, BracketsRange);
17637}
17638
17639template <typename Derived>
17641 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17642 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17643 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17644 SizeExpr,
17645 IndexTypeQuals, BracketsRange);
17646}
17647
17648template <typename Derived>
17650 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17651 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17652 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17653 SizeExpr,
17654 IndexTypeQuals, BracketsRange);
17655}
17656
17657template <typename Derived>
17659 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17660 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17661 AttributeLoc);
17662}
17663
17664template <typename Derived>
17666 unsigned NumElements,
17667 VectorKind VecKind) {
17668 // FIXME: semantic checking!
17669 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17670}
17671
17672template <typename Derived>
17674 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17675 VectorKind VecKind) {
17676 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17677}
17678
17679template<typename Derived>
17681 unsigned NumElements,
17682 SourceLocation AttributeLoc) {
17683 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17684 NumElements, true);
17685 IntegerLiteral *VectorSize
17686 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17687 AttributeLoc);
17688 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17689}
17690
17691template<typename Derived>
17694 Expr *SizeExpr,
17695 SourceLocation AttributeLoc) {
17696 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17697}
17698
17699template <typename Derived>
17701 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17702 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17703 NumColumns);
17704}
17705
17706template <typename Derived>
17708 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17709 SourceLocation AttributeLoc) {
17710 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17711 AttributeLoc);
17712}
17713
17714template <typename Derived>
17716 QualType T, MutableArrayRef<QualType> ParamTypes,
17718 return SemaRef.BuildFunctionType(T, ParamTypes,
17721 EPI);
17722}
17723
17724template<typename Derived>
17726 return SemaRef.Context.getFunctionNoProtoType(T);
17727}
17728
17729template <typename Derived>
17732 SourceLocation NameLoc, Decl *D) {
17733 assert(D && "no decl found");
17734 if (D->isInvalidDecl()) return QualType();
17735
17736 // FIXME: Doesn't account for ObjCInterfaceDecl!
17737 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17738 // A valid resolved using typename pack expansion decl can have multiple
17739 // UsingDecls, but they must each have exactly one type, and it must be
17740 // the same type in every case. But we must have at least one expansion!
17741 if (UPD->expansions().empty()) {
17742 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17743 << UPD->isCXXClassMember() << UPD;
17744 return QualType();
17745 }
17746
17747 // We might still have some unresolved types. Try to pick a resolved type
17748 // if we can. The final instantiation will check that the remaining
17749 // unresolved types instantiate to the type we pick.
17750 QualType FallbackT;
17751 QualType T;
17752 for (auto *E : UPD->expansions()) {
17753 QualType ThisT =
17754 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17755 if (ThisT.isNull())
17756 continue;
17757 if (ThisT->getAs<UnresolvedUsingType>())
17758 FallbackT = ThisT;
17759 else if (T.isNull())
17760 T = ThisT;
17761 else
17762 assert(getSema().Context.hasSameType(ThisT, T) &&
17763 "mismatched resolved types in using pack expansion");
17764 }
17765 return T.isNull() ? FallbackT : T;
17766 }
17767 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17768 assert(Using->hasTypename() &&
17769 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17770
17771 // A valid resolved using typename decl points to exactly one type decl.
17772 assert(++Using->shadow_begin() == Using->shadow_end());
17773
17774 UsingShadowDecl *Shadow = *Using->shadow_begin();
17775 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17776 return QualType();
17777 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17778 }
17780 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17781 return SemaRef.Context.getUnresolvedUsingType(
17783}
17784
17785template <typename Derived>
17787 TypeOfKind Kind) {
17788 return SemaRef.BuildTypeofExprType(E, Kind);
17789}
17790
17791template<typename Derived>
17793 TypeOfKind Kind) {
17794 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17795}
17796
17797template <typename Derived>
17799 return SemaRef.BuildDecltypeType(E);
17800}
17801
17802template <typename Derived>
17804 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17805 SourceLocation EllipsisLoc, bool FullySubstituted,
17806 ArrayRef<QualType> Expansions) {
17807 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17808 FullySubstituted, Expansions);
17809}
17810
17811template<typename Derived>
17813 UnaryTransformType::UTTKind UKind,
17814 SourceLocation Loc) {
17815 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17816}
17817
17818template <typename Derived>
17821 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17822 return SemaRef.CheckTemplateIdType(
17823 Keyword, Template, TemplateNameLoc, TemplateArgs,
17824 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17825}
17826
17827template<typename Derived>
17829 SourceLocation KWLoc) {
17830 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17831}
17832
17833template<typename Derived>
17835 SourceLocation KWLoc,
17836 bool isReadPipe) {
17837 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17838 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17839}
17840
17841template <typename Derived>
17843 unsigned NumBits,
17844 SourceLocation Loc) {
17845 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17846 NumBits, true);
17847 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17848 SemaRef.Context.IntTy, Loc);
17849 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17850}
17851
17852template <typename Derived>
17854 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17855 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17856}
17857
17858template <typename Derived>
17860 bool TemplateKW,
17861 TemplateName Name) {
17862 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17863 Name);
17864}
17865
17866template <typename Derived>
17868 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17869 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17871 TemplateName.setIdentifier(&Name, NameLoc);
17873 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17874 TemplateName, ParsedType::make(ObjectType),
17875 /*EnteringContext=*/false, Template,
17876 AllowInjectedClassName);
17877 return Template.get();
17878}
17879
17880template<typename Derived>
17883 SourceLocation TemplateKWLoc,
17884 OverloadedOperatorKind Operator,
17885 SourceLocation NameLoc,
17886 QualType ObjectType,
17887 bool AllowInjectedClassName) {
17888 UnqualifiedId Name;
17889 // FIXME: Bogus location information.
17890 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17891 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17893 getSema().ActOnTemplateName(
17894 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17895 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17896 return Template.get();
17897}
17898
17899template <typename Derived>
17902 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17903 Expr *Second) {
17904 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17905
17906 if (First->getObjectKind() == OK_ObjCProperty) {
17909 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17910 Opc, First, Second);
17911 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17912 if (Result.isInvalid())
17913 return ExprError();
17914 First = Result.get();
17915 }
17916
17917 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17918 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17919 if (Result.isInvalid())
17920 return ExprError();
17921 Second = Result.get();
17922 }
17923
17924 // Determine whether this should be a builtin operation.
17925 if (Op == OO_Subscript) {
17926 if (!First->getType()->isOverloadableType() &&
17927 !Second->getType()->isOverloadableType())
17928 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17929 OpLoc);
17930 } else if (Op == OO_Arrow) {
17931 // It is possible that the type refers to a RecoveryExpr created earlier
17932 // in the tree transformation.
17933 if (First->getType()->isDependentType())
17934 return ExprError();
17935 // -> is never a builtin operation.
17936 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17937 } else if (Second == nullptr || isPostIncDec) {
17938 if (!First->getType()->isOverloadableType() ||
17939 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17940 // The argument is not of overloadable type, or this is an expression
17941 // of the form &Class::member, so try to create a built-in unary
17942 // operation.
17944 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17945
17946 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17947 }
17948 } else {
17949 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17950 !First->getType()->isOverloadableType() &&
17951 !Second->getType()->isOverloadableType()) {
17952 // Neither of the arguments is type-dependent or has an overloadable
17953 // type, so try to create a built-in binary operation.
17956 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17957 if (Result.isInvalid())
17958 return ExprError();
17959
17960 return Result;
17961 }
17962 }
17963
17964 // Create the overloaded operator invocation for unary operators.
17965 if (!Second || isPostIncDec) {
17967 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17968 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17969 RequiresADL);
17970 }
17971
17972 // Create the overloaded operator invocation for binary operators.
17974 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17975 First, Second, RequiresADL);
17976 if (Result.isInvalid())
17977 return ExprError();
17978
17979 return Result;
17980}
17981
17982template<typename Derived>
17985 SourceLocation OperatorLoc,
17986 bool isArrow,
17987 CXXScopeSpec &SS,
17988 TypeSourceInfo *ScopeType,
17989 SourceLocation CCLoc,
17990 SourceLocation TildeLoc,
17991 PseudoDestructorTypeStorage Destroyed) {
17992 QualType CanonicalBaseType = Base->getType().getCanonicalType();
17993 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
17994 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
17995 (isArrow && isa<PointerType>(CanonicalBaseType) &&
17996 !cast<PointerType>(CanonicalBaseType)
17997 ->getPointeeType()
17998 ->getAsCanonical<RecordType>())) {
17999 // This pseudo-destructor expression is still a pseudo-destructor.
18000 return SemaRef.BuildPseudoDestructorExpr(
18001 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
18002 CCLoc, TildeLoc, Destroyed);
18003 }
18004
18005 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
18006 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
18007 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
18008 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
18009 NameInfo.setNamedTypeInfo(DestroyedType);
18010
18011 // The scope type is now known to be a valid nested name specifier
18012 // component. Tack it on to the nested name specifier.
18013 if (ScopeType) {
18014 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
18015 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
18016 diag::err_expected_class_or_namespace)
18017 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
18018 return ExprError();
18019 }
18020 SS.clear();
18021 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
18022 }
18023
18024 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
18025 return getSema().BuildMemberReferenceExpr(
18026 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
18027 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
18028 /*TemplateArgs*/ nullptr,
18029 /*S*/ nullptr);
18030}
18031
18032template<typename Derived>
18035 SourceLocation Loc = S->getBeginLoc();
18036 CapturedDecl *CD = S->getCapturedDecl();
18037 unsigned NumParams = CD->getNumParams();
18038 unsigned ContextParamPos = CD->getContextParamPosition();
18040 for (unsigned I = 0; I < NumParams; ++I) {
18041 if (I != ContextParamPos) {
18042 Params.push_back(
18043 std::make_pair(
18044 CD->getParam(I)->getName(),
18045 getDerived().TransformType(CD->getParam(I)->getType())));
18046 } else {
18047 Params.push_back(std::make_pair(StringRef(), QualType()));
18048 }
18049 }
18050 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
18051 S->getCapturedRegionKind(), Params);
18052 StmtResult Body;
18053 {
18054 Sema::CompoundScopeRAII CompoundScope(getSema());
18055 Body = getDerived().TransformStmt(S->getCapturedStmt());
18056 }
18057
18058 if (Body.isInvalid()) {
18059 getSema().ActOnCapturedRegionError();
18060 return StmtError();
18061 }
18062
18063 return getSema().ActOnCapturedRegionEnd(Body.get());
18064}
18065
18066template <typename Derived>
18069 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
18070 // function definition or instantiation of a function template specialization
18071 // and will therefore never appear in a dependent context.
18072 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
18073 "context");
18074}
18075
18076template <typename Derived>
18078 // We can transform the base expression and allow argument resolution to fill
18079 // in the rest.
18080 return getDerived().TransformExpr(E->getArgLValue());
18081}
18082
18083} // end namespace clang
18084
18085#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)
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 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>.
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:4553
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:6021
Represents a loop initializing the elements of an array.
Definition Expr.h:5968
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1833
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7219
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2724
Wrapper for source info for arrays.
Definition TypeLoc.h:1777
void setLBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1783
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition ExprCXX.h:3000
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:3038
ArrayTypeTrait getTrait() const
Definition ExprCXX.h:3040
Expr * getDimensionExpression() const
Definition ExprCXX.h:3050
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition ExprCXX.h:3046
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:3037
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3784
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6733
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6928
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2673
Attr - This represents one attribute.
Definition Attr.h:46
Represents an attribute applied to a statement.
Definition Stmt.h:2213
Stmt * getSubStmt()
Definition Stmt.h:2249
SourceLocation getAttrLoc() const
Definition Stmt.h:2244
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2245
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:4456
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4041
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition Expr.cpp:2185
static bool isAssignmentOp(Opcode Opc)
Definition Expr.h:4177
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:2147
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8297
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4678
void setIsVariadic(bool value)
Definition Decl.h:4754
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6672
Wrapper for source info for block pointers.
Definition TypeLoc.h:1526
BreakStmt - This represents a break.
Definition Stmt.h:3145
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5472
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:5491
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:5490
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition Expr.h:3972
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:28
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:586
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:580
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:2620
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:1046
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:3870
Represents a C++ destructor within a class.
Definition DeclCXX.h:2882
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:485
Represents a folding of a pack over an operator.
Definition ExprCXX.h:5032
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition StmtCXX.h:135
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition ExprCXX.h: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:2132
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:4309
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:5141
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:1861
Represents a C++26 reflect expression [expr.reflect].
Definition ExprCXX.h:5504
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:69
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:3744
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition ExprCXX.h:3788
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition ExprCXX.h:3799
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition ExprCXX.h:3782
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition ExprCXX.h:3793
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition ExprCXX.h:3802
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1072
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2946
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:1522
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4950
unsigned getNumParams() const
Definition Decl.h:4988
unsigned getContextParamPosition() const
Definition Decl.h:5017
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4990
This captures a statement into a function.
Definition Stmt.h:3947
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1493
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:4051
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:4142
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition Stmt.cpp:1508
CaseStmt - Represent a case statement.
Definition Stmt.h:1930
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition Expr.cpp:1985
Expr * getSubExpr()
Definition Expr.h:3729
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4851
Represents a 'co_await' expression.
Definition ExprCXX.h:5365
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4303
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3608
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1750
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Stmt.h:1800
body_range body()
Definition Stmt.h:1813
SourceLocation getLBracLoc() const
Definition Stmt.h:1867
bool hasStoredFPFeatures() const
Definition Stmt.h:1797
Stmt * body_back()
Definition Stmt.h:1818
SourceLocation getRBracLoc() const
Definition Stmt.h:1868
Declaration of a C++20 concept.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
Represents the specialization of a concept - evaluates to a prvalue of type bool.
const TypeClass * getTypePtr() const
Definition TypeLoc.h:433
ConditionalOperator - The ?
Definition Expr.h:4394
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3822
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition Expr.h:1085
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4449
ContinueStmt - This represents a continue.
Definition Stmt.h:3129
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4722
Represents a 'co_return' statement in the C++ Coroutines TS.
Definition StmtCXX.h:473
Represents the body of a coroutine.
Definition StmtCXX.h:320
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
Definition TypeBase.h:3498
Represents a 'co_yield' expression.
Definition ExprCXX.h:5446
Wrapper for source info for pointers decayed from arrays and functions.
Definition TypeLoc.h:1474
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:1462
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2122
DeclContextLookupResult lookup_result
Definition DeclBase.h:2590
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addDecl(Decl *D)
Add the declaration D into this context.
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1273
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1641
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:822
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:809
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:1948
void setDecltypeLoc(SourceLocation Loc)
Definition TypeLoc.h:2288
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2513
DeferStmt - This represents a deferred statement.
Definition Stmt.h:3246
static DeferStmt * Create(ASTContext &Context, SourceLocation DeferLoc, Stmt *Body)
Definition Stmt.cpp:1552
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:1998
Represents an extended address space qualifier where the input address space value is dependent.
Definition TypeBase.h:4123
Represents a 'co_await' expression while the type of the promise is dependent.
Definition ExprCXX.h:5397
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2581
A qualified reference to a name whose declaration cannot yet be resolved.
Definition ExprCXX.h:3510
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3584
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition ExprCXX.h:3558
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3576
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition ExprCXX.h:3594
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3568
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3611
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3549
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3604
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3546
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4073
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2096
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4163
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition TypeBase.h:4535
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2068
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4289
Represents a single C99 designator.
Definition Expr.h:5594
Represents a C99 designated initializer expression.
Definition Expr.h:5551
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:208
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
Definition Designator.h:172
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
Definition Designator.h:142
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
Definition Designator.h:115
bool hasErrorOccurred() const
Definition Diagnostic.h:881
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2842
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Definition TypeBase.h:5089
Expr * getCondition() const
Definition TypeBase.h:5096
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:744
Represents a reference to emded data.
Definition Expr.h:5129
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:3953
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition ExprCXX.h:3661
This represents one expression.
Definition Expr.h:112
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition Expr.h:177
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:194
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition Expr.h:454
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3089
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3221
QualType getType() const
Definition Expr.h:144
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition Expr.h:526
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition Expr.h:437
An expression trait intrinsic.
Definition ExprCXX.h:3073
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h:6610
Represents difference between two FPOptions values.
FPOptions applyOverrides(FPOptions Base)
Represents a member of a struct/union/class.
Definition Decl.h:3166
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2898
Represents a function declaration or definition.
Definition Decl.h:2018
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2766
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5337
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4982
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5718
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5704
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5203
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4947
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4841
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5369
param_type_iterator param_type_begin() const
Definition TypeBase.h:5813
unsigned getNumParams() const
Definition TypeLoc.h:1716
SourceLocation getLocalRangeEnd() const
Definition TypeLoc.h:1668
void setLocalRangeBegin(SourceLocation L)
Definition TypeLoc.h:1664
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1680
SourceRange getExceptionSpecRange() const
Definition TypeLoc.h:1696
void setParam(unsigned i, ParmVarDecl *VD)
Definition TypeLoc.h:1723
ArrayRef< ParmVarDecl * > getParams() const
Definition TypeLoc.h:1707
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1688
void setLocalRangeEnd(SourceLocation L)
Definition TypeLoc.h:1672
void setExceptionSpecRange(SourceRange R)
Definition TypeLoc.h:1702
TypeLoc getReturnLoc() const
Definition TypeLoc.h:1725
SourceLocation getLocalRangeBegin() const
Definition TypeLoc.h:1660
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1676
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1684
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4591
This represents a GCC inline-assembly statement extension.
Definition Stmt.h:3456
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition Expr.h:4926
Represents a C11 generic selection.
Definition Expr.h:6182
AssociationTy< false > Association
Definition Expr.h:6415
GotoStmt - This represents a direct goto.
Definition Stmt.h:2979
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:7397
One of these records is kept for each identifier that is lexed.
IfStmt - This represents an if/then/else.
Definition Stmt.h:2269
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition Expr.h:1734
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition Expr.h:3856
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:6057
Represents a C array with an unspecified size.
Definition TypeBase.h:3971
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:3018
const TypeClass * getTypePtr() const
Definition TypeLoc.h:526
Describes an C or C++ initializer list.
Definition Expr.h:5302
InitListExpr * getSyntacticForm() const
Definition Expr.h:5472
Wrapper for source info for injected class names of class templates.
Definition TypeLoc.h:872
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition Expr.cpp:980
Represents the declaration of a label.
Definition Decl.h:524
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2156
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:1370
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1365
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1374
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition ExprCXX.h:2037
Represents the results of name lookup.
Definition Lookup.h:147
This represents a Microsoft inline-assembly statement extension.
Definition Stmt.h:3675
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition StmtCXX.h:253
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4349
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:1383
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4920
MatrixSingleSubscriptExpr - Matrix single subscript expression for the MatrixType extension when you ...
Definition Expr.h:2798
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2868
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2125
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3367
Wrapper for source info for member pointers.
Definition TypeLoc.h:1544
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3715
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition Template.h:76
This represents a decl that may have a name.
Definition Decl.h:274
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition Decl.h:295
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:301
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:340
Represents C++ namespaces and their aliases.
Definition Decl.h:573
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents a place-holder for an object not to be initialized by anything.
Definition Expr.h:5877
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h:1713
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:220
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:1734
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition ExprObjC.h:119
ObjCBoxedExpr - used for generalized expression boxing.
Definition ExprObjC.h:159
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition ExprObjC.h:1674
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition ExprObjC.h:342
ObjCEncodeExpr, used for @encode in Objective-C.
Definition ExprObjC.h:441
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:1613
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:1529
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1952
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:580
An expression that sends a message to the given Objective-C object or class.
Definition ExprObjC.h:971
@ SuperInstance
The receiver is the instance of the superclass object.
Definition ExprObjC.h:985
@ Instance
The receiver is an object instance.
Definition ExprObjC.h:979
@ SuperClass
The receiver is a superclass.
Definition ExprObjC.h:982
@ Class
The receiver is a class.
Definition ExprObjC.h:976
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Wraps an ObjCPointerType with source location information.
Definition TypeLoc.h:1586
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1592
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition TypeLoc.h:1258
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:731
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition ExprObjC.h:648
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition ExprObjC.h:536
ObjCSelectorExpr used for @selector in Objective-C.
Definition ExprObjC.h:486
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition ExprObjC.h:84
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition ExprObjC.h:870
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:578
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition TypeLoc.h:895
@ Array
An index into an array.
Definition Expr.h:2429
@ Identifier
A field in a dependent type, known only by its name.
Definition Expr.h:2433
@ Field
A field.
Definition Expr.h:2431
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition Expr.h:2436
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:1181
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1231
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition Expr.h:2093
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:3132
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition ExprCXX.h:3284
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3266
SourceLocation getNameLoc() const
Gets the location of the name.
Definition ExprCXX.h:3245
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3258
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition ExprCXX.h:3254
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3324
llvm::iterator_range< decls_iterator > decls() const
Definition ExprCXX.h:3231
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3330
DeclarationName getName() const
Gets the name looked up.
Definition ExprCXX.h:3242
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3274
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition ExprCXX.h:3281
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition ExprCXX.h:4363
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2633
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2629
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2645
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2316
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2185
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition Expr.h:2210
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition Expr.h:2214
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1411
Represents a parameter to a function.
Definition Decl.h:1808
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1868
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1841
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:2932
unsigned getFunctionScopeDepth() const
Definition Decl.h:1858
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2725
PipeType - OpenCL20.
Definition TypeBase.h:8263
bool isReadOnly() const
Definition TypeBase.h:8293
Pointer-authentication qualifiers.
Definition TypeBase.h:152
void setSigilLoc(SourceLocation Loc)
Definition TypeLoc.h:1490
TypeLoc getPointeeLoc() const
Definition TypeLoc.h:1494
SourceLocation getSigilLoc() const
Definition TypeLoc.h:1486
Wrapper for source info for pointers.
Definition TypeLoc.h:1513
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3390
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2008
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:6804
A (possibly-)qualified type.
Definition TypeBase.h:937
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition TypeBase.h:1004
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition TypeBase.h:8445
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8477
Represents a template name as written in source code.
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition TypeLoc.h:300
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
void removeObjCLifetime()
Definition TypeBase.h:551
bool hasRestrict() const
Definition TypeBase.h:477
static Qualifiers fromCVRMask(unsigned CVR)
Definition TypeBase.h:435
PointerAuthQualifier getPointerAuth() const
Definition TypeBase.h:603
bool hasObjCLifetime() const
Definition TypeBase.h:544
bool empty() const
Definition TypeBase.h:647
LangAS getAddressSpace() const
Definition TypeBase.h:571
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition Expr.h:7503
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3635
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3651
Represents the body of a requires-expression.
Definition DeclCXX.h:2101
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition DeclCXX.cpp:2402
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:3170
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition Stmt.cpp:1361
Represents a __leave statement.
Definition Stmt.h:3908
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 * ActOnOpenMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' clause.
OMPClause * ActOnOpenMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'shared' clause.
OMPClause * ActOnOpenMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyin' clause.
OMPClause * ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'destroy' clause.
OMPClause * ActOnOpenMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Called on well-formed 'affinity' clause.
OMPClause * ActOnOpenMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' clause.
OMPClause * ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depend' clause.
OMPClause * ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'doacross' clause.
OMPClause * 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 * ActOnOpenMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'in_reduction' clause.
OMPClause * ActOnOpenMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'flush' pseudo clause.
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
OMPClause * ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'message' clause.
OMPClause * ActOnOpenMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'schedule' clause.
OMPClause * ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'simdlen' clause.
OMPClause * 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.
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
OMPClause * ActOnOpenMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_threads' clause.
OMPClause * ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'at' clause.
OMPClause * ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'init' clause.
OMPClause * ActOnOpenMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_addr' clause.
OMPClause * ActOnOpenMPAllocateClause(Expr *Allocator, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocate' clause.
OMPClause * ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'final' clause.
OMPClause * ActOnOpenMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, bool NoDiagnose=false, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'map' clause.
OMPClause * ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_tasks' clause.
OMPClause * ActOnOpenMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'from' clause.
OMPClause * ActOnOpenMPDynGroupprivateClause(OpenMPDynGroupprivateClauseModifier M1, OpenMPDynGroupprivateClauseFallbackModifier M2, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation EndLoc)
Called on a well-formed 'dyn_groupprivate' clause.
void StartOpenMPDSABlock(OpenMPDirectiveKind K, const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc)
Called on start of new data sharing attribute block.
OMPClause * ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'severity' clause.
OMPClause * ActOnOpenMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'to' clause.
OMPClause * ActOnOpenMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind LinKind, SourceLocation LinLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Called on well-formed 'linear' clause.
OMPClause * ActOnOpenMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'defaultmap' clause.
OMPClause * ActOnOpenMPReductionClause(ArrayRef< Expr * > VarList, OpenMPVarListDataTy::OpenMPReductionClauseModifiers Modifiers, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'reduction' clause.
OMPClause * ActOnOpenMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'aligned' clause.
OMPClause * ActOnOpenMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depobj' pseudo clause.
OMPClause * ActOnOpenMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'novariants' clause.
OMPClause * ActOnOpenMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyprivate' clause.
OMPClause * ActOnOpenMPCollapseClause(Expr *NumForLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'collapse' clause.
OMPClause * ActOnOpenMPDefaultClause(llvm::omp::DefaultKind M, SourceLocation MLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCKindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'default' clause.
OMPClause * ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'align' clause.
OMPClause * ActOnOpenMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_attribute' clause.
OMPClause * ActOnOpenMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'exclusive' clause.
OMPClause * ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'if' clause.
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
Given a pseudo-object expression, recreate what it looks like syntactically without the attendant Opa...
ExprResult checkRValue(Expr *E)
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:670
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition SemaSYCL.cpp:153
RAII object used to change the argument pack substitution index within a Sema object.
Definition Sema.h:13685
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8534
A RAII object to enter scope of a compound statement.
Definition Sema.h:1315
A RAII object to temporarily push a declaration context.
Definition Sema.h:3526
A helper class for building up ExtParameterInfos.
Definition Sema.h:13072
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:13091
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13079
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14090
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:868
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:9420
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9428
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9423
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:1533
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:7924
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7926
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7925
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:485
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition Sema.h:1558
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:12067
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:1308
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:936
SemaObjC & ObjC()
Definition Sema.h:1518
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:939
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, bool DoCheckConstraintSatisfaction=true)
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition Sema.cpp:84
const LangOptions & getLangOpts() const
Definition Sema.h:932
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
SemaOpenACC & OpenACC()
Definition Sema.h:1523
@ ReuseLambdaContextDecl
Definition Sema.h:7103
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)
Check whether an expression might be an implicit class member access.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc, bool ListInitialization)
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
SemaHLSL & HLSL()
Definition Sema.h:1483
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
TemplateArgument getPackSubstitutedTemplateArgument(TemplateArgument Arg) const
Definition Sema.h:11867
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:1341
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:11862
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition Sema.cpp:2628
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1446
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 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.
UnsignedOrNone ArgPackSubstIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition Sema.h:13679
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:6813
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6823
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6792
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6818
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:75
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:8403
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc)
Complete a lambda-expression having processed and attached the lambda body.
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition Sema.h:11156
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition SemaStmt.cpp:563
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParen)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition SemaCast.cpp: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:950
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, SourceLocation RParenLoc, MultiExprArg Args, AtomicExpr::AtomicOp Op, AtomicArgumentOrder ArgOrder=AtomicArgumentOrder::API)
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
OpaquePtr< TemplateName > TemplateTy
Definition Sema.h:1300
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static ConditionResult ConditionError()
Definition Sema.h:7910
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:436
SemaPseudoObject & PseudoObject()
Definition Sema.h:1543
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:1299
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition SemaStmt.cpp:568
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition SemaStmt.cpp:532
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Definition Sema.h:8748
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:4646
Represents an expression that computes the length of a parameter pack.
Definition ExprCXX.h:4441
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition ExprCXX.h:4503
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
Definition ExprCXX.h:4526
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Definition ExprCXX.cpp:1716
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition ExprCXX.h:4531
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
Definition ExprCXX.h:4500
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition ExprCXX.h:4506
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition ExprCXX.h:4509
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition Expr.h:5020
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition Expr.h:5080
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:4598
Stmt - This represents one statement.
Definition Stmt.h:86
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.cpp:367
@ NoStmtClass
Definition Stmt.h:89
StmtClass getStmtClass() const
Definition Stmt.h:1503
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:1802
Wrapper for substituted template type parameters.
Definition TypeLoc.h:998
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition ExprCXX.h:4664
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition ExprCXX.h:4754
A structure for storing an already-substituted template template parameter pack.
A structure for storing the information associated with a substituted template template parameter.
Wrapper for substituted template type parameters.
Definition TypeLoc.h:992
SwitchStmt - This represents a 'switch' stmt.
Definition Stmt.h:2519
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3723
SourceLocation getNameLoc() const
Definition TypeLoc.h:822
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:801
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:809
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:816
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:824
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:805
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
const TemplateArgumentLoc * operator->() const
Simple iterator that traverses the template arguments in a container that provides a getArgLoc() memb...
TemplateArgumentLocContainerIterator operator++(int)
friend bool operator!=(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator(ArgLocContainer &Container, unsigned Index)
friend bool operator==(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator & operator++()
const TemplateArgumentLoc * operator->() const
Iterator adaptor that invents template argument location information for each of the template argumen...
TemplateArgumentLocInventIterator & operator++()
std::iterator_traits< InputIterator >::difference_type difference_type
TemplateArgumentLocInventIterator operator++(int)
friend bool operator==(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
TemplateArgumentLocInventIterator(TreeTransform< Derived > &Self, InputIterator Iter)
friend bool operator!=(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
TypeSourceInfo * getTypeSourceInfo() const
Expr * getSourceExpression() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
const TemplateArgument * pack_iterator
Iterator that traverses the elements of a template argument pack.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DeducedTemplateStorage * getAsDeducedTemplateName() const
Retrieve the deduced template info, if any.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
NestedNameSpecifier getQualifier() const
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceLocation getLAngleLoc() const
Definition TypeLoc.h:1907
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:1922
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:1905
SourceLocation getTemplateKeywordLoc() const
Definition TypeLoc.h:1901
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1891
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:1887
Wrapper for template type parameters.
Definition TypeLoc.h:881
The top declaration context.
Definition Decl.h:105
RAII object that temporarily sets the base location and entity used for reporting diagnostics in type...
TemporaryBase(const TemporaryBase &)=delete
TemporaryBase(TreeTransform &Self, SourceLocation Location, DeclarationName Entity)
TemporaryBase & operator=(const TemporaryBase &)=delete
A semantic tree transformation that allows one to transform one abstract syntax tree into another.
ExprResult RebuildObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *object)
Rebuild the operand to an Objective-C @synchronized statement.
OMPClause * RebuildOMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nontemporal' clause.
StmtResult RebuildOpenACCDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
TemplateArgument TransformNamedTemplateTemplateArgument(NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName Name, SourceLocation NameLoc)
ExprResult TransformInitializer(Expr *Init, bool NotCopyInit)
Transform the given initializer.
StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new label statement.
StmtResult RebuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs Args)
StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @autoreleasepool statement.
OMPClause * RebuildOMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP 'dist_schedule' clause.
ExprResult RebuildUnaryOperator(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *SubExpr)
Build a new unary operator expression.
OMPClause * RebuildOMPProcBindClause(ProcBindKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'proc_bind' clause.
ParmVarDecl * TransformFunctionTypeParam(ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack)
Transforms a single function-type parameter.
StmtResult RebuildOMPInformationalDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP informational directive.
ExprResult RebuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Build a new C++11 default-initialization expression.
OMPClause * RebuildOMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'priority' clause.
StmtResult RebuildOpenACCSetConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc, TypeSourceInfo *EncodeTypeInfo, SourceLocation RParenLoc)
Build a new Objective-C @encode expression.
StmtResult RebuildOpenACCCombinedConstruct(OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult Loop)
StmtResult SkipLambdaBody(LambdaExpr *E, Stmt *Body)
Alternative implementation of TransformLambdaBody that skips transforming the body.
StmtResult RebuildOpenACCExitDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
StmtResult RebuildOpenACCShutdownConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
OMPClause * RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocate' clause.
ExprResult RebuildObjCIsaExpr(Expr *BaseArg, SourceLocation IsaLoc, SourceLocation OpLoc, bool IsArrow)
Build a new Objective-C "isa" expression.
StmtResult RebuildObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @finally statement.
SourceLocation getBaseLocation()
Returns the location of the entity being transformed, if that information was not available elsewhere...
ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
Build a new call expression.
ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar, SourceLocation IvarLoc, bool IsArrow, bool IsFreeIvar)
Build a new Objective-C ivar reference expression.
OMPClause * RebuildOMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'at' clause.
StmtResult RebuildCoreturnStmt(SourceLocation CoreturnLoc, Expr *Result, bool IsImplicit)
Build a new co_return statement.
OMPClause * RebuildOMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'in_reduction' clause.
ExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *Init)
Build a new compound literal expression.
ExprResult TransformAddressOfOperand(Expr *E)
The operand of a unary address-of operator has special rules: it's allowed to refer to a non-static m...
ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc, QualType ThisType, bool isImplicit)
Build a new C++ "this" expression.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(expr) expression.
TreeTransform(Sema &SemaRef)
Initializes a new tree transformer.
QualType RebuildDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttributeLoc)
Build a new matrix type given the type and dependently-defined dimensions.
QualType RebuildTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, TagDecl *Tag)
Build a new class/struct/union/enum type.
QualType RebuildUnaryTransformType(QualType BaseType, UnaryTransformType::UTTKind UKind, SourceLocation Loc)
Build a new unary transform type.
ExprResult RebuildObjCPropertyRefExpr(Expr *BaseArg, ObjCPropertyDecl *Property, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
void InventTemplateArgumentLoc(const TemplateArgument &Arg, TemplateArgumentLoc &ArgLoc)
Fakes up a TemplateArgumentLoc for a given TemplateArgument.
OMPClause * RebuildOMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'use' clause.
StmtResult RebuildOpenACCEnterDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL)
Transform the given type-with-location into a new type, collecting location information in the given ...
ExprResult RebuildCXXRewrittenBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opcode, const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS)
Build a new rewritten operator expression.
ExprResult RebuildPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new expression pack expansion.
ExprResult TransformUnresolvedLookupExpr(UnresolvedLookupExpr *E, bool IsAddressOfOperand)
ExprResult RebuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
Build a new expression representing a call to a source location builtin.
TemplateName RebuildTemplateName(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final)
Build a new template name given a template template parameter pack and the.
QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL)
Transforms a reference type.
OMPClause * RebuildOMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'message' clause.
ExprResult RebuildCXXAddrspaceCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
QualType RebuildTypeOfType(QualType Underlying, TypeOfKind Kind)
Build a new typeof(type) type.
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, Expr *SubExpr, TypeSourceInfo *TInfo, SourceLocation RParenLoc)
Build a new va_arg expression.
ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, SourceLocation RParenLoc)
Build a new C++ zero-initialization expression.
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr)
OMPClause * RebuildOMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'thread_limit' clause.
StmtResult RebuildSEHFinallyStmt(SourceLocation Loc, Stmt *Block)
OMPClause * RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'simdlen' clause.
StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
Build a new C++ try statement.
StmtDiscardKind
The reason why the value of a statement is not discarded, if any.
ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, UnresolvedLookupExpr *OpCoawaitLookup, bool IsImplicit)
Build a new co_await expression.
bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, unsigned NumInputs, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
ExprResult RebuildDesignatedInitExpr(Designation &Desig, MultiExprArg ArrayExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Build a new designated initializer expression.
QualType RebuildUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, SourceLocation NameLoc, Decl *D)
Rebuild an unresolved typename type, given the decl that the UnresolvedUsingTypenameDecl was transfor...
OMPClause * RebuildOMPSizesClause(ArrayRef< Expr * > Sizes, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
ExprResult RebuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
Build a new predefined expression.
ExprResult 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.
ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
Build a new template-id expression.
StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc, VarDecl *ExceptionDecl, Stmt *Handler)
Build a new C++ catch statement.
OMPClause * RebuildOMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'destroy' clause.
ExprResult RebuildUnaryExprOrTypeTrait(Expr *SubExpr, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec step expression with an expression argument.
ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new address-of-label expression.
ExprResult RebuildCxxSubscriptExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
OMPClause * RebuildOMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_bare' clause.
const Attr * TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS, const Attr *A)
ExprResult RebuildConditionalOperator(Expr *Cond, SourceLocation QuestionLoc, Expr *LHS, SourceLocation ColonLoc, Expr *RHS)
Build a new conditional operator expression.
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
Attach body to a C++0x range-based for statement.
StmtResult RebuildOpenACCUpdateConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *Object, Stmt *Body)
Build a new Objective-C @synchronized statement.
ExprResult RebuildOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
OMPClause * RebuildOMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'device' clause.
OMPClause * RebuildOMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'has_device_addr' clause.
bool TryExpandParameterPacks(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions)
Determine whether we should expand a pack expansion with the given set of parameter packs into separa...
QualType RebuildDependentSizedExtVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
OMPClause * RebuildOMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_threads' clause.
void RememberPartiallySubstitutedPack(TemplateArgument Arg)
"Remember" the partially-substituted pack template argument after performing an instantiation that mu...
Decl * TransformDefinition(SourceLocation Loc, Decl *D)
Transform the definition of the given declaration.
ExprResult RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, UnresolvedLookupExpr *Lookup)
Build a new co_await expression.
StmtResult RebuildReturnStmt(SourceLocation ReturnLoc, Expr *Result)
Build a new return statement.
QualType TransformTemplateSpecializationType(TypeLocBuilder &TLB, TemplateSpecializationTypeLoc TL, QualType ObjectType, NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName)
TemplateArgument ForgetPartiallySubstitutedPack()
"Forget" about the partially-substituted pack template argument, when performing an instantiation tha...
OMPClause * RebuildOMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nocontext' clause.
ExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ reinterpret_cast expression.
QualType RebuildVectorType(QualType ElementType, unsigned NumElements, VectorKind VecKind)
Build a new vector type given the element type and number of elements.
ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc, TypeSourceInfo *Type, ArrayRef< Sema::OffsetOfComponent > Components, SourceLocation RParenLoc)
Build a new builtin offsetof expression.
QualType RebuildParenType(QualType InnerType)
Build a new parenthesized type.
QualType RebuildAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, ConceptDecl *TypeConstraintConcept, ArrayRef< TemplateArgument > TypeConstraintArgs)
Build a new C++11 auto type.
static StmtResult Owned(Stmt *S)
OMPClause * RebuildOMPPartialClause(Expr *Factor, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'partial' clause.
OMPClause * RebuildOMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP 'schedule' clause.
StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body)
Transform the body of a lambda-expression.
StmtResult RebuildSEHTryStmt(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
OMPClause * RebuildOMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'exclusive' clause.
QualType RebuildDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc)
Build a new DependentAddressSpaceType or return the pointee type variable with the correct address sp...
StmtResult RebuildAttributedStmt(SourceLocation AttrLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Build a new attributed statement.
QualType RebuildMemberPointerType(QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls, SourceLocation Sigil)
Build a new member pointer type given the pointee type and the qualifier it refers into.
ExprResult RebuildConceptSpecializationExpr(NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, TemplateArgumentListInfo *TALI)
OMPClause * RebuildOMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Build a new OpenMP 'defaultmap' clause.
StmtResult RebuildOpenACCCacheConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation ReadOnlyLoc, ArrayRef< Expr * > VarList, SourceLocation RParenLoc, SourceLocation EndLoc)
StmtResult RebuildOpenACCLoopConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult Loop)
ExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr)
Build a new C++ default-argument expression.
OMPClause * RebuildOMPDefaultClause(DefaultKind Kind, SourceLocation KindKwLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'default' clause.
StmtResult RebuildWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, Sema::ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
Build a new while statement.
OMPClause * RebuildOMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_teams' clause.
OMPClause * RebuildOMPDynGroupprivateClause(OpenMPDynGroupprivateClauseModifier M1, OpenMPDynGroupprivateClauseFallbackModifier M2, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation EndLoc)
Build a new OpenMP 'dyn_groupprivate' clause.
ExprResult RebuildImplicitValueInitExpr(QualType T)
Build a new value-initialized expression.
bool TransformFunctionTypeParams(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const QualType *ParamTypes, const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > *PVars, Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed)
Transforms the parameters of a function type into the given vectors.
StmtResult RebuildGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
Build a new inline asm statement.
StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S)
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
Build a new template name given a nested name specifier and the name that is referred to as a templat...
TemplateName RebuildTemplateName(CXXScopeSpec &SS, bool TemplateKW, TemplateName Name)
Build a new template name given a nested name specifier, a flag indicating whether the "template" key...
ExprResult RebuildObjCMessageExpr(Expr *Receiver, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C instance message.
QualType TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB, SubstTemplateTypeParmPackTypeLoc TL, bool SuppressObjCLifetime)
ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool RequiresADL)
Build a new expression that references a declaration.
bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall, SmallVectorImpl< Expr * > &Outputs, bool *ArgChanged=nullptr)
Transform the given list of expressions.
StmtResult TransformSEHHandler(Stmt *Handler)
NestedNameSpecifierLoc TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr)
Transform the given nested-name-specifier with source-location information.
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, OverloadedOperatorKind Operator, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
Build a new template name given a nested name specifier and the overloaded operator name that is refe...
StmtResult RebuildOpenACCHostDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc)
Build a new C++11 decltype type.
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.
ExprResult RebuildParenListExpr(SourceLocation LParenLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new expression list in parentheses.
OMPClause * RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocator' clause.
QualType RebuildDependentSizedArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new dependent-sized array type given the element type, size modifier, size expression,...
NamedDecl * TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc)
Transform the given declaration, which was the first part of a nested-name-specifier in a member acce...
OMPClause * RebuildOMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'inclusive' clause.
StmtResult TransformOMPInformationalDirective(OMPExecutableDirective *S)
This is mostly the same as above, but allows 'informational' class directives when rebuilding the stm...
concepts::ExprRequirement * RebuildExprRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
OMPClause * 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'.
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:2735
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:6280
A container of type source information.
Definition TypeBase.h:8416
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:8427
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:1875
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition TypeBase.h:2465
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition TypeBase.h:9198
bool isObjCObjectPointerType() const
Definition TypeBase.h:8861
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9275
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3568
Wrapper for source info for typedefs.
Definition TypeLoc.h:777
void setTypeofLoc(SourceLocation Loc)
Definition TypeLoc.h:2200
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2628
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2247
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition Expr.h:2292
Expr * getSubExpr() const
Definition Expr.h:2288
Opcode getOpcode() const
Definition Expr.h:2283
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:1420
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2344
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:1035
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3390
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition ExprCXX.h:3464
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition ExprCXX.h:3459
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Definition ExprCXX.cpp:437
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4126
A set of unresolved declarations.
void append(iterator I, iterator E)
A set of unresolved declarations.
Wrapper for source info for unresolved typename using decls.
Definition TypeLoc.h:782
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition TypeBase.h:6085
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:3404
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3468
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:4960
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
QualType getType() const
Definition Decl.h:723
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Definition Decl.cpp:5614
Value()=default
Represents a variable declaration or definition.
Definition Decl.h:924
@ CInit
C-style initialization with assignment.
Definition Decl.h:929
@ CallInit
Call-style initialization (C++98)
Definition Decl.h:932
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1166
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:4028
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2045
Represents a GCC generic vector type.
Definition TypeBase.h:4237
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2707
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
SourceLocation getNoexceptLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
Retains information about a block that is currently being parsed.
Definition ScopeInfo.h:790
bool ContainsUnexpandedParameterPack
Whether this contains an unexpanded parameter pack.
Definition ScopeInfo.h:728
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition ScopeInfo.h:871
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Definition ScopeInfo.h:874
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
VE builtins.
const AstTypeMatcher< FunctionType > functionType
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition Descriptor.h:29
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
Definition Interp.h:1172
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:956
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OpenMPOriginalSharingModifier
OpenMP 6.0 original sharing modifiers.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
OpenACCDirectiveKind
bool isa(CodeGen::Address addr)
Definition Address.h:330
ArrayTypeTrait
Names for the array type traits.
Definition TypeTraits.h:42
@ CPlusPlus23
OpenACCAtomicKind
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition TypeBase.h:1834
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
TryCaptureKind
Definition Sema.h:653
@ 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:604
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
Definition Sema.h:238
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ Detach
'detach' clause, allowed on the 'exit data' construct.
TypeOfKind
The kind of 'typeof' expression we're after.
Definition TypeBase.h:918
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
Definition OpenMPKinds.h:39
OpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
Expr * Cond
};
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
Definition Parser.h:142
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition TypeTraits.h:51
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
ExprResult ExprEmpty()
Definition Ownership.h:272
OpenMPDynGroupprivateClauseFallbackModifier
MutableArrayRef< Expr * > MultiExprArg
Definition Ownership.h:259
StmtResult StmtError()
Definition Ownership.h:266
@ Property
The type of a property.
Definition TypeBase.h:911
@ Result
The result type of a method or function.
Definition TypeBase.h:905
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3781
OptionalUnsigned< unsigned > UnsignedOrNone
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:5993
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:562
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:1807
@ Deduced
The normal deduced case.
Definition TypeBase.h:1814
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
Definition TypeBase.h:1809
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
@ Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition Sema.h:812
@ Exists
The symbol exists.
Definition Sema.h:805
@ Error
An error occurred.
Definition Sema.h:815
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:808
MutableArrayRef< Stmt * > MultiStmtArg
Definition Ownership.h:260
OpenMPNumThreadsClauseModifier
U cast(CodeGen::Address addr)
Definition Address.h:327
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition OpenMPKinds.h:48
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition Ownership.h:230
SourceLocIdentKind
Definition Expr.h:5007
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5968
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5989
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5979
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5986
ActionResult< Expr * > ExprResult
Definition Ownership.h:249
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
TypeTrait
Names for traits that operate specifically on types.
Definition TypeTraits.h:21
@ Parens
New-expression has a C++98 paren-delimited initializer.
Definition ExprCXX.h: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:1992
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)
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:89
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition TypeBase.h:5106
Holds information about the various types of exception specification.
Definition TypeBase.h:5426
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5442
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5428
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5431
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5434
Extra information about a function prototype.
Definition TypeBase.h:5454
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5459
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:3398
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:295
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:13152
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13183
An RAII helper that pops function a function scope on exit.
Definition Sema.h:1330
Keeps information about an identifier in a nested-name-spec.
Definition Sema.h:3326
Location information for a TemplateArgument.
UnsignedOrNone OrigNumExpansions
SourceLocation Ellipsis
UnsignedOrNone NumExpansions