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 for (OMPInitClause::PrefView P : C->prefs()) {
11009 Expr *NewFr = nullptr;
11010 if (P.Fr) {
11011 ExprResult ER = getDerived().TransformExpr(P.Fr);
11012 if (ER.isInvalid())
11013 return nullptr;
11014 NewFr = ER.get();
11015 }
11016 SmallVector<Expr *, 2> NewAttrs;
11017 NewAttrs.reserve(P.Attrs.size());
11018 for (Expr *A : P.Attrs) {
11019 ExprResult ER = getDerived().TransformExpr(A);
11020 if (ER.isInvalid())
11021 return nullptr;
11022 NewAttrs.push_back(ER.get());
11023 }
11024 InteropInfo.Prefs.emplace_back(NewFr, std::move(NewAttrs));
11025 }
11026 InteropInfo.HasPreferAttrs = C->hasPreferAttrs();
11027 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
11028 C->getBeginLoc(), C->getLParenLoc(),
11029 C->getVarLoc(), C->getEndLoc());
11030}
11031
11032template <typename Derived>
11034 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
11035 if (ER.isInvalid())
11036 return nullptr;
11037 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
11038 C->getLParenLoc(), C->getVarLoc(),
11039 C->getEndLoc());
11040}
11041
11042template <typename Derived>
11043OMPClause *
11045 ExprResult ER;
11046 if (Expr *IV = C->getInteropVar()) {
11047 ER = getDerived().TransformExpr(IV);
11048 if (ER.isInvalid())
11049 return nullptr;
11050 }
11051 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
11052 C->getLParenLoc(), C->getVarLoc(),
11053 C->getEndLoc());
11054}
11055
11056template <typename Derived>
11057OMPClause *
11059 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11060 if (Cond.isInvalid())
11061 return nullptr;
11062 return getDerived().RebuildOMPNovariantsClause(
11063 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11064}
11065
11066template <typename Derived>
11067OMPClause *
11069 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11070 if (Cond.isInvalid())
11071 return nullptr;
11072 return getDerived().RebuildOMPNocontextClause(
11073 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11074}
11075
11076template <typename Derived>
11077OMPClause *
11079 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
11080 if (ThreadID.isInvalid())
11081 return nullptr;
11082 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
11083 C->getLParenLoc(), C->getEndLoc());
11084}
11085
11086template <typename Derived>
11088 ExprResult E = getDerived().TransformExpr(C->getAlignment());
11089 if (E.isInvalid())
11090 return nullptr;
11091 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
11092 C->getLParenLoc(), C->getEndLoc());
11093}
11094
11095template <typename Derived>
11097 OMPUnifiedAddressClause *C) {
11098 llvm_unreachable("unified_address clause cannot appear in dependent context");
11099}
11100
11101template <typename Derived>
11103 OMPUnifiedSharedMemoryClause *C) {
11104 llvm_unreachable(
11105 "unified_shared_memory clause cannot appear in dependent context");
11106}
11107
11108template <typename Derived>
11110 OMPReverseOffloadClause *C) {
11111 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
11112}
11113
11114template <typename Derived>
11116 OMPDynamicAllocatorsClause *C) {
11117 llvm_unreachable(
11118 "dynamic_allocators clause cannot appear in dependent context");
11119}
11120
11121template <typename Derived>
11123 OMPAtomicDefaultMemOrderClause *C) {
11124 llvm_unreachable(
11125 "atomic_default_mem_order clause cannot appear in dependent context");
11126}
11127
11128template <typename Derived>
11129OMPClause *
11131 llvm_unreachable("self_maps clause cannot appear in dependent context");
11132}
11133
11134template <typename Derived>
11136 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
11137 C->getBeginLoc(), C->getLParenLoc(),
11138 C->getEndLoc());
11139}
11140
11141template <typename Derived>
11142OMPClause *
11144 return getDerived().RebuildOMPSeverityClause(
11145 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
11146 C->getLParenLoc(), C->getEndLoc());
11147}
11148
11149template <typename Derived>
11150OMPClause *
11152 ExprResult E = getDerived().TransformExpr(C->getMessageString());
11153 if (E.isInvalid())
11154 return nullptr;
11155 return getDerived().RebuildOMPMessageClause(
11156 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11157}
11158
11159template <typename Derived>
11160OMPClause *
11163 Vars.reserve(C->varlist_size());
11164 for (auto *VE : C->varlist()) {
11165 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11166 if (EVar.isInvalid())
11167 return nullptr;
11168 Vars.push_back(EVar.get());
11169 }
11170 return getDerived().RebuildOMPPrivateClause(
11171 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11172}
11173
11174template <typename Derived>
11176 OMPFirstprivateClause *C) {
11178 Vars.reserve(C->varlist_size());
11179 for (auto *VE : C->varlist()) {
11180 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11181 if (EVar.isInvalid())
11182 return nullptr;
11183 Vars.push_back(EVar.get());
11184 }
11185 return getDerived().RebuildOMPFirstprivateClause(
11186 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11187}
11188
11189template <typename Derived>
11190OMPClause *
11193 Vars.reserve(C->varlist_size());
11194 for (auto *VE : C->varlist()) {
11195 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11196 if (EVar.isInvalid())
11197 return nullptr;
11198 Vars.push_back(EVar.get());
11199 }
11200 return getDerived().RebuildOMPLastprivateClause(
11201 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11202 C->getLParenLoc(), C->getEndLoc());
11203}
11204
11205template <typename Derived>
11206OMPClause *
11209 Vars.reserve(C->varlist_size());
11210 for (auto *VE : C->varlist()) {
11211 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11212 if (EVar.isInvalid())
11213 return nullptr;
11214 Vars.push_back(EVar.get());
11215 }
11216 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11217 C->getLParenLoc(), C->getEndLoc());
11218}
11219
11220template <typename Derived>
11221OMPClause *
11224 Vars.reserve(C->varlist_size());
11225 for (auto *VE : C->varlist()) {
11226 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11227 if (EVar.isInvalid())
11228 return nullptr;
11229 Vars.push_back(EVar.get());
11230 }
11231 CXXScopeSpec ReductionIdScopeSpec;
11232 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11233
11234 DeclarationNameInfo NameInfo = C->getNameInfo();
11235 if (NameInfo.getName()) {
11236 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11237 if (!NameInfo.getName())
11238 return nullptr;
11239 }
11240 // Build a list of all UDR decls with the same names ranged by the Scopes.
11241 // The Scope boundary is a duplication of the previous decl.
11242 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11243 for (auto *E : C->reduction_ops()) {
11244 // Transform all the decls.
11245 if (E) {
11246 auto *ULE = cast<UnresolvedLookupExpr>(E);
11247 UnresolvedSet<8> Decls;
11248 for (auto *D : ULE->decls()) {
11249 NamedDecl *InstD =
11250 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11251 Decls.addDecl(InstD, InstD->getAccess());
11252 }
11253 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11254 SemaRef.Context, /*NamingClass=*/nullptr,
11255 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11256 /*ADL=*/true, Decls.begin(), Decls.end(),
11257 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11258 } else
11259 UnresolvedReductions.push_back(nullptr);
11260 }
11261 return getDerived().RebuildOMPReductionClause(
11262 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11263 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11264 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11265}
11266
11267template <typename Derived>
11269 OMPTaskReductionClause *C) {
11271 Vars.reserve(C->varlist_size());
11272 for (auto *VE : C->varlist()) {
11273 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11274 if (EVar.isInvalid())
11275 return nullptr;
11276 Vars.push_back(EVar.get());
11277 }
11278 CXXScopeSpec ReductionIdScopeSpec;
11279 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11280
11281 DeclarationNameInfo NameInfo = C->getNameInfo();
11282 if (NameInfo.getName()) {
11283 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11284 if (!NameInfo.getName())
11285 return nullptr;
11286 }
11287 // Build a list of all UDR decls with the same names ranged by the Scopes.
11288 // The Scope boundary is a duplication of the previous decl.
11289 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11290 for (auto *E : C->reduction_ops()) {
11291 // Transform all the decls.
11292 if (E) {
11293 auto *ULE = cast<UnresolvedLookupExpr>(E);
11294 UnresolvedSet<8> Decls;
11295 for (auto *D : ULE->decls()) {
11296 NamedDecl *InstD =
11297 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11298 Decls.addDecl(InstD, InstD->getAccess());
11299 }
11300 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11301 SemaRef.Context, /*NamingClass=*/nullptr,
11302 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11303 /*ADL=*/true, Decls.begin(), Decls.end(),
11304 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11305 } else
11306 UnresolvedReductions.push_back(nullptr);
11307 }
11308 return getDerived().RebuildOMPTaskReductionClause(
11309 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11310 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11311}
11312
11313template <typename Derived>
11314OMPClause *
11317 Vars.reserve(C->varlist_size());
11318 for (auto *VE : C->varlist()) {
11319 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11320 if (EVar.isInvalid())
11321 return nullptr;
11322 Vars.push_back(EVar.get());
11323 }
11324 CXXScopeSpec ReductionIdScopeSpec;
11325 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11326
11327 DeclarationNameInfo NameInfo = C->getNameInfo();
11328 if (NameInfo.getName()) {
11329 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11330 if (!NameInfo.getName())
11331 return nullptr;
11332 }
11333 // Build a list of all UDR decls with the same names ranged by the Scopes.
11334 // The Scope boundary is a duplication of the previous decl.
11335 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11336 for (auto *E : C->reduction_ops()) {
11337 // Transform all the decls.
11338 if (E) {
11339 auto *ULE = cast<UnresolvedLookupExpr>(E);
11340 UnresolvedSet<8> Decls;
11341 for (auto *D : ULE->decls()) {
11342 NamedDecl *InstD =
11343 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11344 Decls.addDecl(InstD, InstD->getAccess());
11345 }
11346 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11347 SemaRef.Context, /*NamingClass=*/nullptr,
11348 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11349 /*ADL=*/true, Decls.begin(), Decls.end(),
11350 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11351 } else
11352 UnresolvedReductions.push_back(nullptr);
11353 }
11354 return getDerived().RebuildOMPInReductionClause(
11355 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11356 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11357}
11358
11359template <typename Derived>
11360OMPClause *
11363 Vars.reserve(C->varlist_size());
11364 for (auto *VE : C->varlist()) {
11365 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11366 if (EVar.isInvalid())
11367 return nullptr;
11368 Vars.push_back(EVar.get());
11369 }
11370 ExprResult Step = getDerived().TransformExpr(C->getStep());
11371 if (Step.isInvalid())
11372 return nullptr;
11373 return getDerived().RebuildOMPLinearClause(
11374 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11375 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11376 C->getEndLoc());
11377}
11378
11379template <typename Derived>
11380OMPClause *
11383 Vars.reserve(C->varlist_size());
11384 for (auto *VE : C->varlist()) {
11385 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11386 if (EVar.isInvalid())
11387 return nullptr;
11388 Vars.push_back(EVar.get());
11389 }
11390 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11391 if (Alignment.isInvalid())
11392 return nullptr;
11393 return getDerived().RebuildOMPAlignedClause(
11394 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11395 C->getColonLoc(), C->getEndLoc());
11396}
11397
11398template <typename Derived>
11399OMPClause *
11402 Vars.reserve(C->varlist_size());
11403 for (auto *VE : C->varlist()) {
11404 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11405 if (EVar.isInvalid())
11406 return nullptr;
11407 Vars.push_back(EVar.get());
11408 }
11409 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11410 C->getLParenLoc(), C->getEndLoc());
11411}
11412
11413template <typename Derived>
11414OMPClause *
11417 Vars.reserve(C->varlist_size());
11418 for (auto *VE : C->varlist()) {
11419 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11420 if (EVar.isInvalid())
11421 return nullptr;
11422 Vars.push_back(EVar.get());
11423 }
11424 return getDerived().RebuildOMPCopyprivateClause(
11425 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11426}
11427
11428template <typename Derived>
11431 Vars.reserve(C->varlist_size());
11432 for (auto *VE : C->varlist()) {
11433 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11434 if (EVar.isInvalid())
11435 return nullptr;
11436 Vars.push_back(EVar.get());
11437 }
11438 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11439 C->getLParenLoc(), C->getEndLoc());
11440}
11441
11442template <typename Derived>
11443OMPClause *
11445 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11446 if (E.isInvalid())
11447 return nullptr;
11448 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11449 C->getLParenLoc(), C->getEndLoc());
11450}
11451
11452template <typename Derived>
11453OMPClause *
11456 Expr *DepModifier = C->getModifier();
11457 if (DepModifier) {
11458 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11459 if (DepModRes.isInvalid())
11460 return nullptr;
11461 DepModifier = DepModRes.get();
11462 }
11463 Vars.reserve(C->varlist_size());
11464 for (auto *VE : C->varlist()) {
11465 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11466 if (EVar.isInvalid())
11467 return nullptr;
11468 Vars.push_back(EVar.get());
11469 }
11470 return getDerived().RebuildOMPDependClause(
11471 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11472 C->getOmpAllMemoryLoc()},
11473 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11474}
11475
11476template <typename Derived>
11477OMPClause *
11479 ExprResult E = getDerived().TransformExpr(C->getDevice());
11480 if (E.isInvalid())
11481 return nullptr;
11482 return getDerived().RebuildOMPDeviceClause(
11483 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11484 C->getModifierLoc(), C->getEndLoc());
11485}
11486
11487template <typename Derived, class T>
11490 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11491 DeclarationNameInfo &MapperIdInfo,
11492 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11493 // Transform expressions in the list.
11494 Vars.reserve(C->varlist_size());
11495 for (auto *VE : C->varlist()) {
11496 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11497 if (EVar.isInvalid())
11498 return true;
11499 Vars.push_back(EVar.get());
11500 }
11501 // Transform mapper scope specifier and identifier.
11502 NestedNameSpecifierLoc QualifierLoc;
11503 if (C->getMapperQualifierLoc()) {
11504 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11505 C->getMapperQualifierLoc());
11506 if (!QualifierLoc)
11507 return true;
11508 }
11509 MapperIdScopeSpec.Adopt(QualifierLoc);
11510 MapperIdInfo = C->getMapperIdInfo();
11511 if (MapperIdInfo.getName()) {
11512 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11513 if (!MapperIdInfo.getName())
11514 return true;
11515 }
11516 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11517 // the previous user-defined mapper lookup in dependent environment.
11518 for (auto *E : C->mapperlists()) {
11519 // Transform all the decls.
11520 if (E) {
11521 auto *ULE = cast<UnresolvedLookupExpr>(E);
11522 UnresolvedSet<8> Decls;
11523 for (auto *D : ULE->decls()) {
11524 NamedDecl *InstD =
11525 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11526 Decls.addDecl(InstD, InstD->getAccess());
11527 }
11528 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11529 TT.getSema().Context, /*NamingClass=*/nullptr,
11530 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11531 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11532 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11533 } else {
11534 UnresolvedMappers.push_back(nullptr);
11535 }
11536 }
11537 return false;
11538}
11539
11540template <typename Derived>
11541OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11542 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11544 Expr *IteratorModifier = C->getIteratorModifier();
11545 if (IteratorModifier) {
11546 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11547 if (MapModRes.isInvalid())
11548 return nullptr;
11549 IteratorModifier = MapModRes.get();
11550 }
11551 CXXScopeSpec MapperIdScopeSpec;
11552 DeclarationNameInfo MapperIdInfo;
11553 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11555 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11556 return nullptr;
11557 return getDerived().RebuildOMPMapClause(
11558 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11559 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11560 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11561}
11562
11563template <typename Derived>
11564OMPClause *
11566 Expr *Allocator = C->getAllocator();
11567 if (Allocator) {
11568 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11569 if (AllocatorRes.isInvalid())
11570 return nullptr;
11571 Allocator = AllocatorRes.get();
11572 }
11573 Expr *Alignment = C->getAlignment();
11574 if (Alignment) {
11575 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11576 if (AlignmentRes.isInvalid())
11577 return nullptr;
11578 Alignment = AlignmentRes.get();
11579 }
11581 Vars.reserve(C->varlist_size());
11582 for (auto *VE : C->varlist()) {
11583 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11584 if (EVar.isInvalid())
11585 return nullptr;
11586 Vars.push_back(EVar.get());
11587 }
11588 return getDerived().RebuildOMPAllocateClause(
11589 Allocator, Alignment, C->getFirstAllocateModifier(),
11590 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11591 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11592 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11593}
11594
11595template <typename Derived>
11596OMPClause *
11599 Vars.reserve(C->varlist_size());
11600 for (auto *VE : C->varlist()) {
11601 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11602 if (EVar.isInvalid())
11603 return nullptr;
11604 Vars.push_back(EVar.get());
11605 }
11606 return getDerived().RebuildOMPNumTeamsClause(
11607 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11608}
11609
11610template <typename Derived>
11611OMPClause *
11614 Vars.reserve(C->varlist_size());
11615 for (auto *VE : C->varlist()) {
11616 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11617 if (EVar.isInvalid())
11618 return nullptr;
11619 Vars.push_back(EVar.get());
11620 }
11621 return getDerived().RebuildOMPThreadLimitClause(
11622 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11623}
11624
11625template <typename Derived>
11626OMPClause *
11628 ExprResult E = getDerived().TransformExpr(C->getPriority());
11629 if (E.isInvalid())
11630 return nullptr;
11631 return getDerived().RebuildOMPPriorityClause(
11632 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11633}
11634
11635template <typename Derived>
11636OMPClause *
11638 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11639 if (E.isInvalid())
11640 return nullptr;
11641 return getDerived().RebuildOMPGrainsizeClause(
11642 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11643 C->getModifierLoc(), C->getEndLoc());
11644}
11645
11646template <typename Derived>
11647OMPClause *
11649 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11650 if (E.isInvalid())
11651 return nullptr;
11652 return getDerived().RebuildOMPNumTasksClause(
11653 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11654 C->getModifierLoc(), C->getEndLoc());
11655}
11656
11657template <typename Derived>
11659 ExprResult E = getDerived().TransformExpr(C->getHint());
11660 if (E.isInvalid())
11661 return nullptr;
11662 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11663 C->getLParenLoc(), C->getEndLoc());
11664}
11665
11666template <typename Derived>
11668 OMPDistScheduleClause *C) {
11669 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11670 if (E.isInvalid())
11671 return nullptr;
11672 return getDerived().RebuildOMPDistScheduleClause(
11673 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11674 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11675}
11676
11677template <typename Derived>
11678OMPClause *
11680 // Rebuild Defaultmap Clause since we need to invoke the checking of
11681 // defaultmap(none:variable-category) after template initialization.
11682 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11683 C->getDefaultmapKind(),
11684 C->getBeginLoc(),
11685 C->getLParenLoc(),
11686 C->getDefaultmapModifierLoc(),
11687 C->getDefaultmapKindLoc(),
11688 C->getEndLoc());
11689}
11690
11691template <typename Derived>
11693 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11695 Expr *IteratorModifier = C->getIteratorModifier();
11696 if (IteratorModifier) {
11697 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11698 if (MapModRes.isInvalid())
11699 return nullptr;
11700 IteratorModifier = MapModRes.get();
11701 }
11702 CXXScopeSpec MapperIdScopeSpec;
11703 DeclarationNameInfo MapperIdInfo;
11704 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11706 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11707 return nullptr;
11708 return getDerived().RebuildOMPToClause(
11709 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11710 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11711 UnresolvedMappers);
11712}
11713
11714template <typename Derived>
11716 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11718 Expr *IteratorModifier = C->getIteratorModifier();
11719 if (IteratorModifier) {
11720 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11721 if (MapModRes.isInvalid())
11722 return nullptr;
11723 IteratorModifier = MapModRes.get();
11724 }
11725 CXXScopeSpec MapperIdScopeSpec;
11726 DeclarationNameInfo MapperIdInfo;
11727 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11729 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11730 return nullptr;
11731 return getDerived().RebuildOMPFromClause(
11732 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11733 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11734 UnresolvedMappers);
11735}
11736
11737template <typename Derived>
11739 OMPUseDevicePtrClause *C) {
11741 Vars.reserve(C->varlist_size());
11742 for (auto *VE : C->varlist()) {
11743 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11744 if (EVar.isInvalid())
11745 return nullptr;
11746 Vars.push_back(EVar.get());
11747 }
11748 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11749 return getDerived().RebuildOMPUseDevicePtrClause(
11750 Vars, Locs, C->getFallbackModifier(), C->getFallbackModifierLoc());
11751}
11752
11753template <typename Derived>
11755 OMPUseDeviceAddrClause *C) {
11757 Vars.reserve(C->varlist_size());
11758 for (auto *VE : C->varlist()) {
11759 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11760 if (EVar.isInvalid())
11761 return nullptr;
11762 Vars.push_back(EVar.get());
11763 }
11764 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11765 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11766}
11767
11768template <typename Derived>
11769OMPClause *
11772 Vars.reserve(C->varlist_size());
11773 for (auto *VE : C->varlist()) {
11774 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11775 if (EVar.isInvalid())
11776 return nullptr;
11777 Vars.push_back(EVar.get());
11778 }
11779 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11780 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11781}
11782
11783template <typename Derived>
11785 OMPHasDeviceAddrClause *C) {
11787 Vars.reserve(C->varlist_size());
11788 for (auto *VE : C->varlist()) {
11789 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11790 if (EVar.isInvalid())
11791 return nullptr;
11792 Vars.push_back(EVar.get());
11793 }
11794 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11795 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11796}
11797
11798template <typename Derived>
11799OMPClause *
11802 Vars.reserve(C->varlist_size());
11803 for (auto *VE : C->varlist()) {
11804 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11805 if (EVar.isInvalid())
11806 return nullptr;
11807 Vars.push_back(EVar.get());
11808 }
11809 return getDerived().RebuildOMPNontemporalClause(
11810 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11811}
11812
11813template <typename Derived>
11814OMPClause *
11817 Vars.reserve(C->varlist_size());
11818 for (auto *VE : C->varlist()) {
11819 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11820 if (EVar.isInvalid())
11821 return nullptr;
11822 Vars.push_back(EVar.get());
11823 }
11824 return getDerived().RebuildOMPInclusiveClause(
11825 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11826}
11827
11828template <typename Derived>
11829OMPClause *
11832 Vars.reserve(C->varlist_size());
11833 for (auto *VE : C->varlist()) {
11834 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11835 if (EVar.isInvalid())
11836 return nullptr;
11837 Vars.push_back(EVar.get());
11838 }
11839 return getDerived().RebuildOMPExclusiveClause(
11840 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11841}
11842
11843template <typename Derived>
11845 OMPUsesAllocatorsClause *C) {
11847 Data.reserve(C->getNumberOfAllocators());
11848 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11849 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11850 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11851 if (Allocator.isInvalid())
11852 continue;
11853 ExprResult AllocatorTraits;
11854 if (Expr *AT = D.AllocatorTraits) {
11855 AllocatorTraits = getDerived().TransformExpr(AT);
11856 if (AllocatorTraits.isInvalid())
11857 continue;
11858 }
11859 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11860 NewD.Allocator = Allocator.get();
11861 NewD.AllocatorTraits = AllocatorTraits.get();
11862 NewD.LParenLoc = D.LParenLoc;
11863 NewD.RParenLoc = D.RParenLoc;
11864 }
11865 return getDerived().RebuildOMPUsesAllocatorsClause(
11866 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11867}
11868
11869template <typename Derived>
11870OMPClause *
11872 SmallVector<Expr *, 4> Locators;
11873 Locators.reserve(C->varlist_size());
11874 ExprResult ModifierRes;
11875 if (Expr *Modifier = C->getModifier()) {
11876 ModifierRes = getDerived().TransformExpr(Modifier);
11877 if (ModifierRes.isInvalid())
11878 return nullptr;
11879 }
11880 for (Expr *E : C->varlist()) {
11881 ExprResult Locator = getDerived().TransformExpr(E);
11882 if (Locator.isInvalid())
11883 continue;
11884 Locators.push_back(Locator.get());
11885 }
11886 return getDerived().RebuildOMPAffinityClause(
11887 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11888 ModifierRes.get(), Locators);
11889}
11890
11891template <typename Derived>
11893 return getDerived().RebuildOMPOrderClause(
11894 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11895 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11896}
11897
11898template <typename Derived>
11900 return getDerived().RebuildOMPBindClause(
11901 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11902 C->getLParenLoc(), C->getEndLoc());
11903}
11904
11905template <typename Derived>
11907 OMPXDynCGroupMemClause *C) {
11908 ExprResult Size = getDerived().TransformExpr(C->getSize());
11909 if (Size.isInvalid())
11910 return nullptr;
11911 return getDerived().RebuildOMPXDynCGroupMemClause(
11912 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11913}
11914
11915template <typename Derived>
11917 OMPDynGroupprivateClause *C) {
11918 ExprResult Size = getDerived().TransformExpr(C->getSize());
11919 if (Size.isInvalid())
11920 return nullptr;
11921 return getDerived().RebuildOMPDynGroupprivateClause(
11922 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
11923 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
11924 C->getDynGroupprivateModifierLoc(),
11925 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
11926}
11927
11928template <typename Derived>
11929OMPClause *
11932 Vars.reserve(C->varlist_size());
11933 for (auto *VE : C->varlist()) {
11934 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11935 if (EVar.isInvalid())
11936 return nullptr;
11937 Vars.push_back(EVar.get());
11938 }
11939 return getDerived().RebuildOMPDoacrossClause(
11940 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11941 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11942}
11943
11944template <typename Derived>
11945OMPClause *
11948 for (auto *A : C->getAttrs())
11949 NewAttrs.push_back(getDerived().TransformAttr(A));
11950 return getDerived().RebuildOMPXAttributeClause(
11951 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11952}
11953
11954template <typename Derived>
11956 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11957}
11958
11959//===----------------------------------------------------------------------===//
11960// OpenACC transformation
11961//===----------------------------------------------------------------------===//
11962namespace {
11963template <typename Derived>
11964class OpenACCClauseTransform final
11965 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11966 TreeTransform<Derived> &Self;
11967 ArrayRef<const OpenACCClause *> ExistingClauses;
11968 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11969 OpenACCClause *NewClause = nullptr;
11970
11971 ExprResult VisitVar(Expr *VarRef) {
11972 ExprResult Res = Self.TransformExpr(VarRef);
11973
11974 if (!Res.isUsable())
11975 return Res;
11976
11977 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11978 ParsedClause.getClauseKind(),
11979 Res.get());
11980
11981 return Res;
11982 }
11983
11984 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11985 llvm::SmallVector<Expr *> InstantiatedVarList;
11986 for (Expr *CurVar : VarList) {
11987 ExprResult VarRef = VisitVar(CurVar);
11988
11989 if (VarRef.isUsable())
11990 InstantiatedVarList.push_back(VarRef.get());
11991 }
11992
11993 return InstantiatedVarList;
11994 }
11995
11996public:
11997 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11998 ArrayRef<const OpenACCClause *> ExistingClauses,
11999 SemaOpenACC::OpenACCParsedClause &PC)
12000 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
12001
12002 OpenACCClause *CreatedClause() const { return NewClause; }
12003
12004#define VISIT_CLAUSE(CLAUSE_NAME) \
12005 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
12006#include "clang/Basic/OpenACCClauses.def"
12007};
12008
12009template <typename Derived>
12010void OpenACCClauseTransform<Derived>::VisitDefaultClause(
12011 const OpenACCDefaultClause &C) {
12012 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
12013
12014 NewClause = OpenACCDefaultClause::Create(
12015 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
12016 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12017 ParsedClause.getEndLoc());
12018}
12019
12020template <typename Derived>
12021void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
12022 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12023 assert(Cond && "If constructed with invalid Condition");
12024 Sema::ConditionResult Res = Self.TransformCondition(
12025 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
12026
12027 if (Res.isInvalid() || !Res.get().second)
12028 return;
12029
12030 ParsedClause.setConditionDetails(Res.get().second);
12031
12032 NewClause = OpenACCIfClause::Create(
12033 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12034 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12035 ParsedClause.getEndLoc());
12036}
12037
12038template <typename Derived>
12039void OpenACCClauseTransform<Derived>::VisitSelfClause(
12040 const OpenACCSelfClause &C) {
12041
12042 // If this is an 'update' 'self' clause, this is actually a var list instead.
12043 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
12044 llvm::SmallVector<Expr *> InstantiatedVarList;
12045 for (Expr *CurVar : C.getVarList()) {
12046 ExprResult Res = Self.TransformExpr(CurVar);
12047
12048 if (!Res.isUsable())
12049 continue;
12050
12051 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
12052 ParsedClause.getClauseKind(),
12053 Res.get());
12054
12055 if (Res.isUsable())
12056 InstantiatedVarList.push_back(Res.get());
12057 }
12058
12059 ParsedClause.setVarListDetails(InstantiatedVarList,
12061
12062 NewClause = OpenACCSelfClause::Create(
12063 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12064 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12065 ParsedClause.getEndLoc());
12066 } else {
12067
12068 if (C.hasConditionExpr()) {
12069 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12071 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
12073
12074 if (Res.isInvalid() || !Res.get().second)
12075 return;
12076
12077 ParsedClause.setConditionDetails(Res.get().second);
12078 }
12079
12080 NewClause = OpenACCSelfClause::Create(
12081 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12082 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12083 ParsedClause.getEndLoc());
12084 }
12085}
12086
12087template <typename Derived>
12088void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
12089 const OpenACCNumGangsClause &C) {
12090 llvm::SmallVector<Expr *> InstantiatedIntExprs;
12091
12092 for (Expr *CurIntExpr : C.getIntExprs()) {
12093 ExprResult Res = Self.TransformExpr(CurIntExpr);
12094
12095 if (!Res.isUsable())
12096 return;
12097
12098 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12099 C.getClauseKind(),
12100 C.getBeginLoc(), Res.get());
12101 if (!Res.isUsable())
12102 return;
12103
12104 InstantiatedIntExprs.push_back(Res.get());
12105 }
12106
12107 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
12109 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12110 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12111 ParsedClause.getEndLoc());
12112}
12113
12114template <typename Derived>
12115void OpenACCClauseTransform<Derived>::VisitPrivateClause(
12116 const OpenACCPrivateClause &C) {
12117 llvm::SmallVector<Expr *> InstantiatedVarList;
12119
12120 for (const auto [RefExpr, InitRecipe] :
12121 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12122 ExprResult VarRef = VisitVar(RefExpr);
12123
12124 if (VarRef.isUsable()) {
12125 InstantiatedVarList.push_back(VarRef.get());
12126
12127 // We only have to create a new one if it is dependent, and Sema won't
12128 // make one of these unless the type is non-dependent.
12129 if (InitRecipe.isSet())
12130 InitRecipes.push_back(InitRecipe);
12131 else
12132 InitRecipes.push_back(
12133 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
12134 }
12135 }
12136 ParsedClause.setVarListDetails(InstantiatedVarList,
12138
12139 NewClause = OpenACCPrivateClause::Create(
12140 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12141 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12142 ParsedClause.getEndLoc());
12143}
12144
12145template <typename Derived>
12146void OpenACCClauseTransform<Derived>::VisitHostClause(
12147 const OpenACCHostClause &C) {
12148 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12150
12151 NewClause = OpenACCHostClause::Create(
12152 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12153 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12154 ParsedClause.getEndLoc());
12155}
12156
12157template <typename Derived>
12158void OpenACCClauseTransform<Derived>::VisitDeviceClause(
12159 const OpenACCDeviceClause &C) {
12160 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12162
12163 NewClause = OpenACCDeviceClause::Create(
12164 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12165 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12166 ParsedClause.getEndLoc());
12167}
12168
12169template <typename Derived>
12170void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
12172 llvm::SmallVector<Expr *> InstantiatedVarList;
12174
12175 for (const auto [RefExpr, InitRecipe] :
12176 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12177 ExprResult VarRef = VisitVar(RefExpr);
12178
12179 if (VarRef.isUsable()) {
12180 InstantiatedVarList.push_back(VarRef.get());
12181
12182 // We only have to create a new one if it is dependent, and Sema won't
12183 // make one of these unless the type is non-dependent.
12184 if (InitRecipe.isSet())
12185 InitRecipes.push_back(InitRecipe);
12186 else
12187 InitRecipes.push_back(
12188 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12189 VarRef.get()));
12190 }
12191 }
12192 ParsedClause.setVarListDetails(InstantiatedVarList,
12194
12196 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12197 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12198 ParsedClause.getEndLoc());
12199}
12200
12201template <typename Derived>
12202void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12203 const OpenACCNoCreateClause &C) {
12204 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12206
12208 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12209 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12210 ParsedClause.getEndLoc());
12211}
12212
12213template <typename Derived>
12214void OpenACCClauseTransform<Derived>::VisitPresentClause(
12215 const OpenACCPresentClause &C) {
12216 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12218
12219 NewClause = OpenACCPresentClause::Create(
12220 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12221 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12222 ParsedClause.getEndLoc());
12223}
12224
12225template <typename Derived>
12226void OpenACCClauseTransform<Derived>::VisitCopyClause(
12227 const OpenACCCopyClause &C) {
12228 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12229 C.getModifierList());
12230
12231 NewClause = OpenACCCopyClause::Create(
12232 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12233 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12234 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12235 ParsedClause.getEndLoc());
12236}
12237
12238template <typename Derived>
12239void OpenACCClauseTransform<Derived>::VisitLinkClause(
12240 const OpenACCLinkClause &C) {
12241 llvm_unreachable("link clause not valid unless a decl transform");
12242}
12243
12244template <typename Derived>
12245void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12247 llvm_unreachable("device_resident clause not valid unless a decl transform");
12248}
12249template <typename Derived>
12250void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12251 const OpenACCNoHostClause &C) {
12252 llvm_unreachable("nohost clause not valid unless a decl transform");
12253}
12254template <typename Derived>
12255void OpenACCClauseTransform<Derived>::VisitBindClause(
12256 const OpenACCBindClause &C) {
12257 llvm_unreachable("bind clause not valid unless a decl transform");
12258}
12259
12260template <typename Derived>
12261void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12262 const OpenACCCopyInClause &C) {
12263 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12264 C.getModifierList());
12265
12266 NewClause = OpenACCCopyInClause::Create(
12267 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12268 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12269 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12270 ParsedClause.getEndLoc());
12271}
12272
12273template <typename Derived>
12274void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12275 const OpenACCCopyOutClause &C) {
12276 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12277 C.getModifierList());
12278
12279 NewClause = OpenACCCopyOutClause::Create(
12280 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12281 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12282 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12283 ParsedClause.getEndLoc());
12284}
12285
12286template <typename Derived>
12287void OpenACCClauseTransform<Derived>::VisitCreateClause(
12288 const OpenACCCreateClause &C) {
12289 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12290 C.getModifierList());
12291
12292 NewClause = OpenACCCreateClause::Create(
12293 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12294 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12295 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12296 ParsedClause.getEndLoc());
12297}
12298template <typename Derived>
12299void OpenACCClauseTransform<Derived>::VisitAttachClause(
12300 const OpenACCAttachClause &C) {
12301 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12302
12303 // Ensure each var is a pointer type.
12304 llvm::erase_if(VarList, [&](Expr *E) {
12305 return Self.getSema().OpenACC().CheckVarIsPointerType(
12307 });
12308
12309 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12310 NewClause = OpenACCAttachClause::Create(
12311 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12312 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12313 ParsedClause.getEndLoc());
12314}
12315
12316template <typename Derived>
12317void OpenACCClauseTransform<Derived>::VisitDetachClause(
12318 const OpenACCDetachClause &C) {
12319 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12320
12321 // Ensure each var is a pointer type.
12322 llvm::erase_if(VarList, [&](Expr *E) {
12323 return Self.getSema().OpenACC().CheckVarIsPointerType(
12325 });
12326
12327 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12328 NewClause = OpenACCDetachClause::Create(
12329 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12330 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12331 ParsedClause.getEndLoc());
12332}
12333
12334template <typename Derived>
12335void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12336 const OpenACCDeleteClause &C) {
12337 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12339 NewClause = OpenACCDeleteClause::Create(
12340 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12341 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12342 ParsedClause.getEndLoc());
12343}
12344
12345template <typename Derived>
12346void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12347 const OpenACCUseDeviceClause &C) {
12348 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12351 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12352 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12353 ParsedClause.getEndLoc());
12354}
12355
12356template <typename Derived>
12357void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12358 const OpenACCDevicePtrClause &C) {
12359 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12360
12361 // Ensure each var is a pointer type.
12362 llvm::erase_if(VarList, [&](Expr *E) {
12363 return Self.getSema().OpenACC().CheckVarIsPointerType(
12365 });
12366
12367 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12369 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12370 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12371 ParsedClause.getEndLoc());
12372}
12373
12374template <typename Derived>
12375void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12376 const OpenACCNumWorkersClause &C) {
12377 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12378 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12379
12380 ExprResult Res = Self.TransformExpr(IntExpr);
12381 if (!Res.isUsable())
12382 return;
12383
12384 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12385 C.getClauseKind(),
12386 C.getBeginLoc(), Res.get());
12387 if (!Res.isUsable())
12388 return;
12389
12390 ParsedClause.setIntExprDetails(Res.get());
12392 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12393 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12394 ParsedClause.getEndLoc());
12395}
12396
12397template <typename Derived>
12398void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12399 const OpenACCDeviceNumClause &C) {
12400 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12401 assert(IntExpr && "device_num clause constructed with invalid int expr");
12402
12403 ExprResult Res = Self.TransformExpr(IntExpr);
12404 if (!Res.isUsable())
12405 return;
12406
12407 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12408 C.getClauseKind(),
12409 C.getBeginLoc(), Res.get());
12410 if (!Res.isUsable())
12411 return;
12412
12413 ParsedClause.setIntExprDetails(Res.get());
12415 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12416 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12417 ParsedClause.getEndLoc());
12418}
12419
12420template <typename Derived>
12421void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12423 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12424 assert(IntExpr && "default_async clause constructed with invalid int expr");
12425
12426 ExprResult Res = Self.TransformExpr(IntExpr);
12427 if (!Res.isUsable())
12428 return;
12429
12430 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12431 C.getClauseKind(),
12432 C.getBeginLoc(), Res.get());
12433 if (!Res.isUsable())
12434 return;
12435
12436 ParsedClause.setIntExprDetails(Res.get());
12438 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12439 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12440 ParsedClause.getEndLoc());
12441}
12442
12443template <typename Derived>
12444void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12446 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12447 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12448
12449 ExprResult Res = Self.TransformExpr(IntExpr);
12450 if (!Res.isUsable())
12451 return;
12452
12453 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12454 C.getClauseKind(),
12455 C.getBeginLoc(), Res.get());
12456 if (!Res.isUsable())
12457 return;
12458
12459 ParsedClause.setIntExprDetails(Res.get());
12461 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12462 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12463 ParsedClause.getEndLoc());
12464}
12465
12466template <typename Derived>
12467void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12468 const OpenACCAsyncClause &C) {
12469 if (C.hasIntExpr()) {
12470 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12471 if (!Res.isUsable())
12472 return;
12473
12474 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12475 C.getClauseKind(),
12476 C.getBeginLoc(), Res.get());
12477 if (!Res.isUsable())
12478 return;
12479 ParsedClause.setIntExprDetails(Res.get());
12480 }
12481
12482 NewClause = OpenACCAsyncClause::Create(
12483 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12484 ParsedClause.getLParenLoc(),
12485 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12486 : nullptr,
12487 ParsedClause.getEndLoc());
12488}
12489
12490template <typename Derived>
12491void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12492 const OpenACCWorkerClause &C) {
12493 if (C.hasIntExpr()) {
12494 // restrictions on this expression are all "does it exist in certain
12495 // situations" that are not possible to be dependent, so the only check we
12496 // have is that it transforms, and is an int expression.
12497 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12498 if (!Res.isUsable())
12499 return;
12500
12501 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12502 C.getClauseKind(),
12503 C.getBeginLoc(), Res.get());
12504 if (!Res.isUsable())
12505 return;
12506 ParsedClause.setIntExprDetails(Res.get());
12507 }
12508
12509 NewClause = OpenACCWorkerClause::Create(
12510 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12511 ParsedClause.getLParenLoc(),
12512 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12513 : nullptr,
12514 ParsedClause.getEndLoc());
12515}
12516
12517template <typename Derived>
12518void OpenACCClauseTransform<Derived>::VisitVectorClause(
12519 const OpenACCVectorClause &C) {
12520 if (C.hasIntExpr()) {
12521 // restrictions on this expression are all "does it exist in certain
12522 // situations" that are not possible to be dependent, so the only check we
12523 // have is that it transforms, and is an int expression.
12524 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12525 if (!Res.isUsable())
12526 return;
12527
12528 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12529 C.getClauseKind(),
12530 C.getBeginLoc(), Res.get());
12531 if (!Res.isUsable())
12532 return;
12533 ParsedClause.setIntExprDetails(Res.get());
12534 }
12535
12536 NewClause = OpenACCVectorClause::Create(
12537 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12538 ParsedClause.getLParenLoc(),
12539 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12540 : nullptr,
12541 ParsedClause.getEndLoc());
12542}
12543
12544template <typename Derived>
12545void OpenACCClauseTransform<Derived>::VisitWaitClause(
12546 const OpenACCWaitClause &C) {
12547 if (C.hasExprs()) {
12548 Expr *DevNumExpr = nullptr;
12549 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12550
12551 // Instantiate devnum expr if it exists.
12552 if (C.getDevNumExpr()) {
12553 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12554 if (!Res.isUsable())
12555 return;
12556 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12557 C.getClauseKind(),
12558 C.getBeginLoc(), Res.get());
12559 if (!Res.isUsable())
12560 return;
12561
12562 DevNumExpr = Res.get();
12563 }
12564
12565 // Instantiate queue ids.
12566 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12567 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12568 if (!Res.isUsable())
12569 return;
12570 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12571 C.getClauseKind(),
12572 C.getBeginLoc(), Res.get());
12573 if (!Res.isUsable())
12574 return;
12575
12576 InstantiatedQueueIdExprs.push_back(Res.get());
12577 }
12578
12579 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12580 std::move(InstantiatedQueueIdExprs));
12581 }
12582
12583 NewClause = OpenACCWaitClause::Create(
12584 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12585 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12586 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12587 ParsedClause.getEndLoc());
12588}
12589
12590template <typename Derived>
12591void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12592 const OpenACCDeviceTypeClause &C) {
12593 // Nothing to transform here, just create a new version of 'C'.
12595 Self.getSema().getASTContext(), C.getClauseKind(),
12596 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12597 C.getArchitectures(), ParsedClause.getEndLoc());
12598}
12599
12600template <typename Derived>
12601void OpenACCClauseTransform<Derived>::VisitAutoClause(
12602 const OpenACCAutoClause &C) {
12603 // Nothing to do, so just create a new node.
12604 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12605 ParsedClause.getBeginLoc(),
12606 ParsedClause.getEndLoc());
12607}
12608
12609template <typename Derived>
12610void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12611 const OpenACCIndependentClause &C) {
12612 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12613 ParsedClause.getBeginLoc(),
12614 ParsedClause.getEndLoc());
12615}
12616
12617template <typename Derived>
12618void OpenACCClauseTransform<Derived>::VisitSeqClause(
12619 const OpenACCSeqClause &C) {
12620 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12621 ParsedClause.getBeginLoc(),
12622 ParsedClause.getEndLoc());
12623}
12624template <typename Derived>
12625void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12626 const OpenACCFinalizeClause &C) {
12627 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12628 ParsedClause.getBeginLoc(),
12629 ParsedClause.getEndLoc());
12630}
12631
12632template <typename Derived>
12633void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12634 const OpenACCIfPresentClause &C) {
12635 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12636 ParsedClause.getBeginLoc(),
12637 ParsedClause.getEndLoc());
12638}
12639
12640template <typename Derived>
12641void OpenACCClauseTransform<Derived>::VisitReductionClause(
12642 const OpenACCReductionClause &C) {
12643 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12644 SmallVector<Expr *> ValidVars;
12646
12647 for (const auto [Var, OrigRecipe] :
12648 llvm::zip(TransformedVars, C.getRecipes())) {
12649 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12650 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12651 if (Res.isUsable()) {
12652 ValidVars.push_back(Res.get());
12653
12654 if (OrigRecipe.isSet())
12655 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
12656 else
12657 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
12658 C.getReductionOp(), Res.get()));
12659 }
12660 }
12661
12662 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12663 ExistingClauses, ParsedClause.getDirectiveKind(),
12664 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12665 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
12666}
12667
12668template <typename Derived>
12669void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12670 const OpenACCCollapseClause &C) {
12671 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12672 assert(LoopCount && "collapse clause constructed with invalid loop count");
12673
12674 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12675
12676 if (!NewLoopCount.isUsable())
12677 return;
12678
12679 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12680 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12681 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12682
12683 // FIXME: It isn't clear whether this is properly tested here, we should
12684 // probably see if we can come up with a test for this.
12685 if (!NewLoopCount.isUsable())
12686 return;
12687
12688 NewLoopCount =
12689 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12690
12691 // FIXME: It isn't clear whether this is properly tested here, we should
12692 // probably see if we can come up with a test for this.
12693 if (!NewLoopCount.isUsable())
12694 return;
12695
12696 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12698 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12699 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12700 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12701}
12702
12703template <typename Derived>
12704void OpenACCClauseTransform<Derived>::VisitTileClause(
12705 const OpenACCTileClause &C) {
12706
12707 llvm::SmallVector<Expr *> TransformedExprs;
12708
12709 for (Expr *E : C.getSizeExprs()) {
12710 ExprResult NewSizeExpr = Self.TransformExpr(E);
12711
12712 if (!NewSizeExpr.isUsable())
12713 return;
12714
12715 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12716 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12717 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12718
12719 // FIXME: It isn't clear whether this is properly tested here, we should
12720 // probably see if we can come up with a test for this.
12721 if (!NewSizeExpr.isUsable())
12722 return;
12723
12724 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12725
12726 if (!NewSizeExpr.isUsable())
12727 return;
12728 TransformedExprs.push_back(NewSizeExpr.get());
12729 }
12730
12731 ParsedClause.setIntExprDetails(TransformedExprs);
12732 NewClause = OpenACCTileClause::Create(
12733 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12734 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12735 ParsedClause.getEndLoc());
12736}
12737template <typename Derived>
12738void OpenACCClauseTransform<Derived>::VisitGangClause(
12739 const OpenACCGangClause &C) {
12740 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12741 llvm::SmallVector<Expr *> TransformedIntExprs;
12742
12743 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12744 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12745 if (!ER.isUsable())
12746 continue;
12747
12748 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12749 ParsedClause.getDirectiveKind(),
12750 C.getExpr(I).first, ER.get());
12751 if (!ER.isUsable())
12752 continue;
12753 TransformedGangKinds.push_back(C.getExpr(I).first);
12754 TransformedIntExprs.push_back(ER.get());
12755 }
12756
12757 NewClause = Self.getSema().OpenACC().CheckGangClause(
12758 ParsedClause.getDirectiveKind(), ExistingClauses,
12759 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12760 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12761}
12762} // namespace
12763template <typename Derived>
12764OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12765 ArrayRef<const OpenACCClause *> ExistingClauses,
12766 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12767
12769 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12770 ParsedClause.setEndLoc(OldClause->getEndLoc());
12771
12772 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12773 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12774
12775 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12776 ParsedClause};
12777 Transform.Visit(OldClause);
12778
12779 return Transform.CreatedClause();
12780}
12781
12782template <typename Derived>
12784TreeTransform<Derived>::TransformOpenACCClauseList(
12786 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12787 for (const auto *Clause : OldClauses) {
12788 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12789 TransformedClauses, DirKind, Clause))
12790 TransformedClauses.push_back(TransformedClause);
12791 }
12792 return TransformedClauses;
12793}
12794
12795template <typename Derived>
12798 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12799
12800 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12801 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12802 C->clauses());
12803
12804 if (getSema().OpenACC().ActOnStartStmtDirective(
12805 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12806 return StmtError();
12807
12808 // Transform Structured Block.
12809 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12810 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12811 C->clauses(), TransformedClauses);
12812 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12813 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12814 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12815
12816 return getDerived().RebuildOpenACCComputeConstruct(
12817 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12818 C->getEndLoc(), TransformedClauses, StrBlock);
12819}
12820
12821template <typename Derived>
12824
12825 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12826
12827 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12828 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12829 C->clauses());
12830
12831 if (getSema().OpenACC().ActOnStartStmtDirective(
12832 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12833 return StmtError();
12834
12835 // Transform Loop.
12836 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12837 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12838 C->clauses(), TransformedClauses);
12839 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12840 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12841 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12842
12843 return getDerived().RebuildOpenACCLoopConstruct(
12844 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12845 TransformedClauses, Loop);
12846}
12847
12848template <typename Derived>
12850 OpenACCCombinedConstruct *C) {
12851 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12852
12853 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12854 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12855 C->clauses());
12856
12857 if (getSema().OpenACC().ActOnStartStmtDirective(
12858 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12859 return StmtError();
12860
12861 // Transform Loop.
12862 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12863 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12864 C->clauses(), TransformedClauses);
12865 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12866 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12867 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12868
12869 return getDerived().RebuildOpenACCCombinedConstruct(
12870 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12871 C->getEndLoc(), TransformedClauses, Loop);
12872}
12873
12874template <typename Derived>
12877 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12878
12879 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12880 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12881 C->clauses());
12882 if (getSema().OpenACC().ActOnStartStmtDirective(
12883 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12884 return StmtError();
12885
12886 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12887 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12888 C->clauses(), TransformedClauses);
12889 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12890 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12891 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12892
12893 return getDerived().RebuildOpenACCDataConstruct(
12894 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12895 TransformedClauses, StrBlock);
12896}
12897
12898template <typename Derived>
12900 OpenACCEnterDataConstruct *C) {
12901 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12902
12903 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12904 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12905 C->clauses());
12906 if (getSema().OpenACC().ActOnStartStmtDirective(
12907 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12908 return StmtError();
12909
12910 return getDerived().RebuildOpenACCEnterDataConstruct(
12911 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12912 TransformedClauses);
12913}
12914
12915template <typename Derived>
12917 OpenACCExitDataConstruct *C) {
12918 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12919
12920 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12921 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12922 C->clauses());
12923 if (getSema().OpenACC().ActOnStartStmtDirective(
12924 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12925 return StmtError();
12926
12927 return getDerived().RebuildOpenACCExitDataConstruct(
12928 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12929 TransformedClauses);
12930}
12931
12932template <typename Derived>
12934 OpenACCHostDataConstruct *C) {
12935 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12936
12937 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12938 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12939 C->clauses());
12940 if (getSema().OpenACC().ActOnStartStmtDirective(
12941 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12942 return StmtError();
12943
12944 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12945 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12946 C->clauses(), TransformedClauses);
12947 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12948 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12949 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12950
12951 return getDerived().RebuildOpenACCHostDataConstruct(
12952 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12953 TransformedClauses, StrBlock);
12954}
12955
12956template <typename Derived>
12959 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12960
12961 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12962 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12963 C->clauses());
12964 if (getSema().OpenACC().ActOnStartStmtDirective(
12965 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12966 return StmtError();
12967
12968 return getDerived().RebuildOpenACCInitConstruct(
12969 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12970 TransformedClauses);
12971}
12972
12973template <typename Derived>
12975 OpenACCShutdownConstruct *C) {
12976 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12977
12978 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12979 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12980 C->clauses());
12981 if (getSema().OpenACC().ActOnStartStmtDirective(
12982 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12983 return StmtError();
12984
12985 return getDerived().RebuildOpenACCShutdownConstruct(
12986 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12987 TransformedClauses);
12988}
12989template <typename Derived>
12992 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12993
12994 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12995 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12996 C->clauses());
12997 if (getSema().OpenACC().ActOnStartStmtDirective(
12998 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12999 return StmtError();
13000
13001 return getDerived().RebuildOpenACCSetConstruct(
13002 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13003 TransformedClauses);
13004}
13005
13006template <typename Derived>
13008 OpenACCUpdateConstruct *C) {
13009 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13010
13011 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13012 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13013 C->clauses());
13014 if (getSema().OpenACC().ActOnStartStmtDirective(
13015 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13016 return StmtError();
13017
13018 return getDerived().RebuildOpenACCUpdateConstruct(
13019 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13020 TransformedClauses);
13021}
13022
13023template <typename Derived>
13026 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13027
13028 ExprResult DevNumExpr;
13029 if (C->hasDevNumExpr()) {
13030 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
13031
13032 if (DevNumExpr.isUsable())
13033 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
13035 C->getBeginLoc(), DevNumExpr.get());
13036 }
13037
13038 llvm::SmallVector<Expr *> QueueIdExprs;
13039
13040 for (Expr *QE : C->getQueueIdExprs()) {
13041 assert(QE && "Null queue id expr?");
13042 ExprResult NewEQ = getDerived().TransformExpr(QE);
13043
13044 if (!NewEQ.isUsable())
13045 break;
13046 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
13048 C->getBeginLoc(), NewEQ.get());
13049 if (NewEQ.isUsable())
13050 QueueIdExprs.push_back(NewEQ.get());
13051 }
13052
13053 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13054 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13055 C->clauses());
13056
13057 if (getSema().OpenACC().ActOnStartStmtDirective(
13058 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13059 return StmtError();
13060
13061 return getDerived().RebuildOpenACCWaitConstruct(
13062 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13063 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
13064 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
13065}
13066template <typename Derived>
13068 OpenACCCacheConstruct *C) {
13069 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13070
13071 llvm::SmallVector<Expr *> TransformedVarList;
13072 for (Expr *Var : C->getVarList()) {
13073 assert(Var && "Null var listexpr?");
13074
13075 ExprResult NewVar = getDerived().TransformExpr(Var);
13076
13077 if (!NewVar.isUsable())
13078 break;
13079
13080 NewVar = getSema().OpenACC().ActOnVar(
13081 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
13082 if (!NewVar.isUsable())
13083 break;
13084
13085 TransformedVarList.push_back(NewVar.get());
13086 }
13087
13088 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13089 C->getBeginLoc(), {}))
13090 return StmtError();
13091
13092 return getDerived().RebuildOpenACCCacheConstruct(
13093 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13094 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
13095 C->getEndLoc());
13096}
13097
13098template <typename Derived>
13100 OpenACCAtomicConstruct *C) {
13101 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13102
13103 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13104 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13105 C->clauses());
13106
13107 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13108 C->getBeginLoc(), {}))
13109 return StmtError();
13110
13111 // Transform Associated Stmt.
13112 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13113 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
13114
13115 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
13116 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
13117 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
13118 AssocStmt);
13119
13120 return getDerived().RebuildOpenACCAtomicConstruct(
13121 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
13122 C->getEndLoc(), TransformedClauses, AssocStmt);
13123}
13124
13125template <typename Derived>
13128 if (getDerived().AlwaysRebuild())
13129 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
13130 // Nothing can ever change, so there is never anything to transform.
13131 return E;
13132}
13133
13134//===----------------------------------------------------------------------===//
13135// Expression transformation
13136//===----------------------------------------------------------------------===//
13137template<typename Derived>
13140 return TransformExpr(E->getSubExpr());
13141}
13142
13143template <typename Derived>
13146 if (!E->isTypeDependent())
13147 return E;
13148
13149 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
13150
13151 if (!NewT)
13152 return ExprError();
13153
13154 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
13155 return E;
13156
13157 return getDerived().RebuildSYCLUniqueStableNameExpr(
13158 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
13159}
13160
13161template <typename Derived>
13164 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
13165 const auto *SKEPAttr = FD->template getAttr<SYCLKernelEntryPointAttr>();
13166 if (!SKEPAttr || SKEPAttr->isInvalidAttr())
13167 return StmtError();
13168
13169 ExprResult IdExpr = getDerived().TransformExpr(S->getKernelLaunchIdExpr());
13170 if (IdExpr.isInvalid())
13171 return StmtError();
13172
13173 StmtResult Body = getDerived().TransformStmt(S->getOriginalStmt());
13174 if (Body.isInvalid())
13175 return StmtError();
13176
13178 cast<FunctionDecl>(SemaRef.CurContext), cast<CompoundStmt>(Body.get()),
13179 IdExpr.get());
13180 if (SR.isInvalid())
13181 return StmtError();
13182
13183 return SR;
13184}
13185
13186template <typename Derived>
13188 // TODO(reflection): Implement its transform
13189 assert(false && "not implemented yet");
13190 return ExprError();
13191}
13192
13193template<typename Derived>
13196 if (!E->isTypeDependent())
13197 return E;
13198
13199 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13200 E->getIdentKind());
13201}
13202
13203template<typename Derived>
13206 NestedNameSpecifierLoc QualifierLoc;
13207 if (E->getQualifierLoc()) {
13208 QualifierLoc
13209 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13210 if (!QualifierLoc)
13211 return ExprError();
13212 }
13213
13214 ValueDecl *ND
13215 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13216 E->getDecl()));
13217 if (!ND || ND->isInvalidDecl())
13218 return ExprError();
13219
13220 NamedDecl *Found = ND;
13221 if (E->getFoundDecl() != E->getDecl()) {
13222 Found = cast_or_null<NamedDecl>(
13223 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13224 if (!Found)
13225 return ExprError();
13226 }
13227
13228 DeclarationNameInfo NameInfo = E->getNameInfo();
13229 if (NameInfo.getName()) {
13230 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13231 if (!NameInfo.getName())
13232 return ExprError();
13233 }
13234
13235 if (!getDerived().AlwaysRebuild() &&
13236 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13237 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13238 Found == E->getFoundDecl() &&
13239 NameInfo.getName() == E->getDecl()->getDeclName() &&
13240 !E->hasExplicitTemplateArgs()) {
13241
13242 // Mark it referenced in the new context regardless.
13243 // FIXME: this is a bit instantiation-specific.
13244 SemaRef.MarkDeclRefReferenced(E);
13245
13246 return E;
13247 }
13248
13249 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13250 if (E->hasExplicitTemplateArgs()) {
13251 TemplateArgs = &TransArgs;
13252 TransArgs.setLAngleLoc(E->getLAngleLoc());
13253 TransArgs.setRAngleLoc(E->getRAngleLoc());
13254 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13255 E->getNumTemplateArgs(),
13256 TransArgs))
13257 return ExprError();
13258 }
13259
13260 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13261 Found, TemplateArgs);
13262}
13263
13264template<typename Derived>
13267 return E;
13268}
13269
13270template <typename Derived>
13272 FixedPointLiteral *E) {
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 E;
13292}
13293
13294template<typename Derived>
13297 return E;
13298}
13299
13300template<typename Derived>
13303 return getDerived().TransformCallExpr(E);
13304}
13305
13306template<typename Derived>
13309 ExprResult ControllingExpr;
13310 TypeSourceInfo *ControllingType = nullptr;
13311 if (E->isExprPredicate())
13312 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13313 else
13314 ControllingType = getDerived().TransformType(E->getControllingType());
13315
13316 if (ControllingExpr.isInvalid() && !ControllingType)
13317 return ExprError();
13318
13319 SmallVector<Expr *, 4> AssocExprs;
13321 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13322 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13323 if (TSI) {
13324 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13325 if (!AssocType)
13326 return ExprError();
13327 AssocTypes.push_back(AssocType);
13328 } else {
13329 AssocTypes.push_back(nullptr);
13330 }
13331
13332 ExprResult AssocExpr =
13333 getDerived().TransformExpr(Assoc.getAssociationExpr());
13334 if (AssocExpr.isInvalid())
13335 return ExprError();
13336 AssocExprs.push_back(AssocExpr.get());
13337 }
13338
13339 if (!ControllingType)
13340 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13341 E->getDefaultLoc(),
13342 E->getRParenLoc(),
13343 ControllingExpr.get(),
13344 AssocTypes,
13345 AssocExprs);
13346 return getDerived().RebuildGenericSelectionExpr(
13347 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13348 ControllingType, AssocTypes, AssocExprs);
13349}
13350
13351template<typename Derived>
13354 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13355 if (SubExpr.isInvalid())
13356 return ExprError();
13357
13358 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13359 return E;
13360
13361 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13362 E->getRParen());
13363}
13364
13365/// The operand of a unary address-of operator has special rules: it's
13366/// allowed to refer to a non-static member of a class even if there's no 'this'
13367/// object available.
13368template<typename Derived>
13371 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13372 return getDerived().TransformDependentScopeDeclRefExpr(
13373 DRE, /*IsAddressOfOperand=*/true, nullptr);
13374 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13375 return getDerived().TransformUnresolvedLookupExpr(
13376 ULE, /*IsAddressOfOperand=*/true);
13377 else
13378 return getDerived().TransformExpr(E);
13379}
13380
13381template<typename Derived>
13384 ExprResult SubExpr;
13385 if (E->getOpcode() == UO_AddrOf)
13386 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13387 else
13388 SubExpr = TransformExpr(E->getSubExpr());
13389 if (SubExpr.isInvalid())
13390 return ExprError();
13391
13392 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13393 return E;
13394
13395 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13396 E->getOpcode(),
13397 SubExpr.get());
13398}
13399
13400template<typename Derived>
13402TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13403 // Transform the type.
13404 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13405 if (!Type)
13406 return ExprError();
13407
13408 // Transform all of the components into components similar to what the
13409 // parser uses.
13410 // FIXME: It would be slightly more efficient in the non-dependent case to
13411 // just map FieldDecls, rather than requiring the rebuilder to look for
13412 // the fields again. However, __builtin_offsetof is rare enough in
13413 // template code that we don't care.
13414 bool ExprChanged = false;
13415 typedef Sema::OffsetOfComponent Component;
13416 SmallVector<Component, 4> Components;
13417 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13418 const OffsetOfNode &ON = E->getComponent(I);
13419 Component Comp;
13420 Comp.isBrackets = true;
13421 Comp.LocStart = ON.getSourceRange().getBegin();
13422 Comp.LocEnd = ON.getSourceRange().getEnd();
13423 switch (ON.getKind()) {
13424 case OffsetOfNode::Array: {
13425 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13426 ExprResult Index = getDerived().TransformExpr(FromIndex);
13427 if (Index.isInvalid())
13428 return ExprError();
13429
13430 ExprChanged = ExprChanged || Index.get() != FromIndex;
13431 Comp.isBrackets = true;
13432 Comp.U.E = Index.get();
13433 break;
13434 }
13435
13438 Comp.isBrackets = false;
13439 Comp.U.IdentInfo = ON.getFieldName();
13440 if (!Comp.U.IdentInfo)
13441 continue;
13442
13443 break;
13444
13445 case OffsetOfNode::Base:
13446 // Will be recomputed during the rebuild.
13447 continue;
13448 }
13449
13450 Components.push_back(Comp);
13451 }
13452
13453 // If nothing changed, retain the existing expression.
13454 if (!getDerived().AlwaysRebuild() &&
13455 Type == E->getTypeSourceInfo() &&
13456 !ExprChanged)
13457 return E;
13458
13459 // Build a new offsetof expression.
13460 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13461 Components, E->getRParenLoc());
13462}
13463
13464template<typename Derived>
13467 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13468 "opaque value expression requires transformation");
13469 return E;
13470}
13471
13472template <typename Derived>
13475 bool Changed = false;
13476 for (Expr *C : E->subExpressions()) {
13477 ExprResult NewC = getDerived().TransformExpr(C);
13478 if (NewC.isInvalid())
13479 return ExprError();
13480 Children.push_back(NewC.get());
13481
13482 Changed |= NewC.get() != C;
13483 }
13484 if (!getDerived().AlwaysRebuild() && !Changed)
13485 return E;
13486 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13487 Children, E->getType());
13488}
13489
13490template<typename Derived>
13493 // Rebuild the syntactic form. The original syntactic form has
13494 // opaque-value expressions in it, so strip those away and rebuild
13495 // the result. This is a really awful way of doing this, but the
13496 // better solution (rebuilding the semantic expressions and
13497 // rebinding OVEs as necessary) doesn't work; we'd need
13498 // TreeTransform to not strip away implicit conversions.
13499 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13500 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13501 if (result.isInvalid()) return ExprError();
13502
13503 // If that gives us a pseudo-object result back, the pseudo-object
13504 // expression must have been an lvalue-to-rvalue conversion which we
13505 // should reapply.
13506 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13507 result = SemaRef.PseudoObject().checkRValue(result.get());
13508
13509 return result;
13510}
13511
13512template<typename Derived>
13516 if (E->isArgumentType()) {
13517 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13518
13519 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13520 if (!NewT)
13521 return ExprError();
13522
13523 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13524 return E;
13525
13526 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13527 E->getKind(),
13528 E->getSourceRange());
13529 }
13530
13531 // C++0x [expr.sizeof]p1:
13532 // The operand is either an expression, which is an unevaluated operand
13533 // [...]
13537
13538 // Try to recover if we have something like sizeof(T::X) where X is a type.
13539 // Notably, there must be *exactly* one set of parens if X is a type.
13540 TypeSourceInfo *RecoveryTSI = nullptr;
13541 ExprResult SubExpr;
13542 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13543 if (auto *DRE =
13544 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13545 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13546 PE, DRE, false, &RecoveryTSI);
13547 else
13548 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13549
13550 if (RecoveryTSI) {
13551 return getDerived().RebuildUnaryExprOrTypeTrait(
13552 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13553 } else if (SubExpr.isInvalid())
13554 return ExprError();
13555
13556 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13557 return E;
13558
13559 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13560 E->getOperatorLoc(),
13561 E->getKind(),
13562 E->getSourceRange());
13563}
13564
13565template<typename Derived>
13568 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13569 if (LHS.isInvalid())
13570 return ExprError();
13571
13572 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13573 if (RHS.isInvalid())
13574 return ExprError();
13575
13576
13577 if (!getDerived().AlwaysRebuild() &&
13578 LHS.get() == E->getLHS() &&
13579 RHS.get() == E->getRHS())
13580 return E;
13581
13582 return getDerived().RebuildArraySubscriptExpr(
13583 LHS.get(),
13584 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13585}
13586
13587template <typename Derived>
13590 ExprResult Base = getDerived().TransformExpr(E->getBase());
13591 if (Base.isInvalid())
13592 return ExprError();
13593
13594 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13595 if (RowIdx.isInvalid())
13596 return ExprError();
13597
13598 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13599 RowIdx.get() == E->getRowIdx())
13600 return E;
13601
13602 return getDerived().RebuildMatrixSingleSubscriptExpr(Base.get(), RowIdx.get(),
13603 E->getRBracketLoc());
13604}
13605
13606template <typename Derived>
13609 ExprResult Base = getDerived().TransformExpr(E->getBase());
13610 if (Base.isInvalid())
13611 return ExprError();
13612
13613 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13614 if (RowIdx.isInvalid())
13615 return ExprError();
13616
13617 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13618 if (ColumnIdx.isInvalid())
13619 return ExprError();
13620
13621 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13622 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13623 return E;
13624
13625 return getDerived().RebuildMatrixSubscriptExpr(
13626 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13627}
13628
13629template <typename Derived>
13632 ExprResult Base = getDerived().TransformExpr(E->getBase());
13633 if (Base.isInvalid())
13634 return ExprError();
13635
13636 ExprResult LowerBound;
13637 if (E->getLowerBound()) {
13638 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13639 if (LowerBound.isInvalid())
13640 return ExprError();
13641 }
13642
13643 ExprResult Length;
13644 if (E->getLength()) {
13645 Length = getDerived().TransformExpr(E->getLength());
13646 if (Length.isInvalid())
13647 return ExprError();
13648 }
13649
13650 ExprResult Stride;
13651 if (E->isOMPArraySection()) {
13652 if (Expr *Str = E->getStride()) {
13653 Stride = getDerived().TransformExpr(Str);
13654 if (Stride.isInvalid())
13655 return ExprError();
13656 }
13657 }
13658
13659 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13660 LowerBound.get() == E->getLowerBound() &&
13661 Length.get() == E->getLength() &&
13662 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13663 return E;
13664
13665 return getDerived().RebuildArraySectionExpr(
13666 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13667 LowerBound.get(), E->getColonLocFirst(),
13668 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13669 Length.get(), Stride.get(), E->getRBracketLoc());
13670}
13671
13672template <typename Derived>
13675 ExprResult Base = getDerived().TransformExpr(E->getBase());
13676 if (Base.isInvalid())
13677 return ExprError();
13678
13680 bool ErrorFound = false;
13681 for (Expr *Dim : E->getDimensions()) {
13682 ExprResult DimRes = getDerived().TransformExpr(Dim);
13683 if (DimRes.isInvalid()) {
13684 ErrorFound = true;
13685 continue;
13686 }
13687 Dims.push_back(DimRes.get());
13688 }
13689
13690 if (ErrorFound)
13691 return ExprError();
13692 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13693 E->getRParenLoc(), Dims,
13694 E->getBracketsRanges());
13695}
13696
13697template <typename Derived>
13700 unsigned NumIterators = E->numOfIterators();
13702
13703 bool ErrorFound = false;
13704 bool NeedToRebuild = getDerived().AlwaysRebuild();
13705 for (unsigned I = 0; I < NumIterators; ++I) {
13706 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13707 Data[I].DeclIdent = D->getIdentifier();
13708 Data[I].DeclIdentLoc = D->getLocation();
13709 if (D->getLocation() == D->getBeginLoc()) {
13710 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13711 "Implicit type must be int.");
13712 } else {
13713 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13714 QualType DeclTy = getDerived().TransformType(D->getType());
13715 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13716 }
13717 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13718 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13719 ExprResult End = getDerived().TransformExpr(Range.End);
13720 ExprResult Step = getDerived().TransformExpr(Range.Step);
13721 ErrorFound = ErrorFound ||
13722 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13723 !Data[I].Type.get().isNull())) ||
13724 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13725 if (ErrorFound)
13726 continue;
13727 Data[I].Range.Begin = Begin.get();
13728 Data[I].Range.End = End.get();
13729 Data[I].Range.Step = Step.get();
13730 Data[I].AssignLoc = E->getAssignLoc(I);
13731 Data[I].ColonLoc = E->getColonLoc(I);
13732 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13733 NeedToRebuild =
13734 NeedToRebuild ||
13735 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13736 D->getType().getTypePtrOrNull()) ||
13737 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13738 Range.Step != Data[I].Range.Step;
13739 }
13740 if (ErrorFound)
13741 return ExprError();
13742 if (!NeedToRebuild)
13743 return E;
13744
13745 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13746 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13747 if (!Res.isUsable())
13748 return Res;
13749 auto *IE = cast<OMPIteratorExpr>(Res.get());
13750 for (unsigned I = 0; I < NumIterators; ++I)
13751 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13752 IE->getIteratorDecl(I));
13753 return Res;
13754}
13755
13756template<typename Derived>
13759 // Transform the callee.
13760 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13761 if (Callee.isInvalid())
13762 return ExprError();
13763
13764 // Transform arguments.
13765 bool ArgChanged = false;
13767 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13768 &ArgChanged))
13769 return ExprError();
13770
13771 if (!getDerived().AlwaysRebuild() &&
13772 Callee.get() == E->getCallee() &&
13773 !ArgChanged)
13774 return SemaRef.MaybeBindToTemporary(E);
13775
13776 // FIXME: Wrong source location information for the '('.
13777 SourceLocation FakeLParenLoc
13778 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13779
13780 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13781 if (E->hasStoredFPFeatures()) {
13782 FPOptionsOverride NewOverrides = E->getFPFeatures();
13783 getSema().CurFPFeatures =
13784 NewOverrides.applyOverrides(getSema().getLangOpts());
13785 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13786 }
13787
13788 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13789 Args,
13790 E->getRParenLoc());
13791}
13792
13793template<typename Derived>
13796 ExprResult Base = getDerived().TransformExpr(E->getBase());
13797 if (Base.isInvalid())
13798 return ExprError();
13799
13800 NestedNameSpecifierLoc QualifierLoc;
13801 if (E->hasQualifier()) {
13802 QualifierLoc
13803 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13804
13805 if (!QualifierLoc)
13806 return ExprError();
13807 }
13808 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13809
13811 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13812 E->getMemberDecl()));
13813 if (!Member)
13814 return ExprError();
13815
13816 NamedDecl *FoundDecl = E->getFoundDecl();
13817 if (FoundDecl == E->getMemberDecl()) {
13818 FoundDecl = Member;
13819 } else {
13820 FoundDecl = cast_or_null<NamedDecl>(
13821 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13822 if (!FoundDecl)
13823 return ExprError();
13824 }
13825
13826 if (!getDerived().AlwaysRebuild() &&
13827 Base.get() == E->getBase() &&
13828 QualifierLoc == E->getQualifierLoc() &&
13829 Member == E->getMemberDecl() &&
13830 FoundDecl == E->getFoundDecl() &&
13831 !E->hasExplicitTemplateArgs()) {
13832
13833 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13834 // for Openmp where the field need to be privatizized in the case.
13835 if (!(isa<CXXThisExpr>(E->getBase()) &&
13836 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13838 // Mark it referenced in the new context regardless.
13839 // FIXME: this is a bit instantiation-specific.
13840 SemaRef.MarkMemberReferenced(E);
13841 return E;
13842 }
13843 }
13844
13845 TemplateArgumentListInfo TransArgs;
13846 if (E->hasExplicitTemplateArgs()) {
13847 TransArgs.setLAngleLoc(E->getLAngleLoc());
13848 TransArgs.setRAngleLoc(E->getRAngleLoc());
13849 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13850 E->getNumTemplateArgs(),
13851 TransArgs))
13852 return ExprError();
13853 }
13854
13855 // FIXME: Bogus source location for the operator
13856 SourceLocation FakeOperatorLoc =
13857 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13858
13859 // FIXME: to do this check properly, we will need to preserve the
13860 // first-qualifier-in-scope here, just in case we had a dependent
13861 // base (and therefore couldn't do the check) and a
13862 // nested-name-qualifier (and therefore could do the lookup).
13863 NamedDecl *FirstQualifierInScope = nullptr;
13864 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13865 if (MemberNameInfo.getName()) {
13866 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13867 if (!MemberNameInfo.getName())
13868 return ExprError();
13869 }
13870
13871 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13872 E->isArrow(),
13873 QualifierLoc,
13874 TemplateKWLoc,
13875 MemberNameInfo,
13876 Member,
13877 FoundDecl,
13878 (E->hasExplicitTemplateArgs()
13879 ? &TransArgs : nullptr),
13880 FirstQualifierInScope);
13881}
13882
13883template<typename Derived>
13886 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13887 if (LHS.isInvalid())
13888 return ExprError();
13889
13890 ExprResult RHS =
13891 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13892 if (RHS.isInvalid())
13893 return ExprError();
13894
13895 if (!getDerived().AlwaysRebuild() &&
13896 LHS.get() == E->getLHS() &&
13897 RHS.get() == E->getRHS())
13898 return E;
13899
13900 if (E->isCompoundAssignmentOp())
13901 // FPFeatures has already been established from trailing storage
13902 return getDerived().RebuildBinaryOperator(
13903 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13904 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13905 FPOptionsOverride NewOverrides(E->getFPFeatures());
13906 getSema().CurFPFeatures =
13907 NewOverrides.applyOverrides(getSema().getLangOpts());
13908 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13909 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13910 LHS.get(), RHS.get());
13911}
13912
13913template <typename Derived>
13916 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13917
13918 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13919 if (LHS.isInvalid())
13920 return ExprError();
13921
13922 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13923 if (RHS.isInvalid())
13924 return ExprError();
13925
13926 // Extract the already-resolved callee declarations so that we can restrict
13927 // ourselves to using them as the unqualified lookup results when rebuilding.
13928 UnresolvedSet<2> UnqualLookups;
13929 bool ChangedAnyLookups = false;
13930 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13931 const_cast<Expr *>(Decomp.InnerBinOp)};
13932 for (Expr *PossibleBinOp : PossibleBinOps) {
13933 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13934 if (!Op)
13935 continue;
13936 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13937 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13938 continue;
13939
13940 // Transform the callee in case we built a call to a local extern
13941 // declaration.
13942 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13943 E->getOperatorLoc(), Callee->getFoundDecl()));
13944 if (!Found)
13945 return ExprError();
13946 if (Found != Callee->getFoundDecl())
13947 ChangedAnyLookups = true;
13948 UnqualLookups.addDecl(Found);
13949 }
13950
13951 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13952 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13953 // Mark all functions used in the rewrite as referenced. Note that when
13954 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13955 // function calls, and/or there might be a user-defined conversion sequence
13956 // applied to the operands of the <.
13957 // FIXME: this is a bit instantiation-specific.
13958 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13959 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13960 return E;
13961 }
13962
13963 return getDerived().RebuildCXXRewrittenBinaryOperator(
13964 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13965}
13966
13967template<typename Derived>
13971 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13972 FPOptionsOverride NewOverrides(E->getFPFeatures());
13973 getSema().CurFPFeatures =
13974 NewOverrides.applyOverrides(getSema().getLangOpts());
13975 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13976 return getDerived().TransformBinaryOperator(E);
13977}
13978
13979template<typename Derived>
13982 // Just rebuild the common and RHS expressions and see whether we
13983 // get any changes.
13984
13985 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13986 if (commonExpr.isInvalid())
13987 return ExprError();
13988
13989 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13990 if (rhs.isInvalid())
13991 return ExprError();
13992
13993 if (!getDerived().AlwaysRebuild() &&
13994 commonExpr.get() == e->getCommon() &&
13995 rhs.get() == e->getFalseExpr())
13996 return e;
13997
13998 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13999 e->getQuestionLoc(),
14000 nullptr,
14001 e->getColonLoc(),
14002 rhs.get());
14003}
14004
14005template<typename Derived>
14008 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14009 if (Cond.isInvalid())
14010 return ExprError();
14011
14012 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14013 if (LHS.isInvalid())
14014 return ExprError();
14015
14016 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14017 if (RHS.isInvalid())
14018 return ExprError();
14019
14020 if (!getDerived().AlwaysRebuild() &&
14021 Cond.get() == E->getCond() &&
14022 LHS.get() == E->getLHS() &&
14023 RHS.get() == E->getRHS())
14024 return E;
14025
14026 return getDerived().RebuildConditionalOperator(Cond.get(),
14027 E->getQuestionLoc(),
14028 LHS.get(),
14029 E->getColonLoc(),
14030 RHS.get());
14031}
14032
14033template<typename Derived>
14036 // Implicit casts are eliminated during transformation, since they
14037 // will be recomputed by semantic analysis after transformation.
14038 return getDerived().TransformExpr(E->getSubExprAsWritten());
14039}
14040
14041template<typename Derived>
14044 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14045 if (!Type)
14046 return ExprError();
14047
14048 ExprResult SubExpr
14049 = getDerived().TransformExpr(E->getSubExprAsWritten());
14050 if (SubExpr.isInvalid())
14051 return ExprError();
14052
14053 if (!getDerived().AlwaysRebuild() &&
14054 Type == E->getTypeInfoAsWritten() &&
14055 SubExpr.get() == E->getSubExpr())
14056 return E;
14057
14058 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
14059 Type,
14060 E->getRParenLoc(),
14061 SubExpr.get());
14062}
14063
14064template<typename Derived>
14067 TypeSourceInfo *OldT = E->getTypeSourceInfo();
14068 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
14069 if (!NewT)
14070 return ExprError();
14071
14072 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
14073 if (Init.isInvalid())
14074 return ExprError();
14075
14076 if (!getDerived().AlwaysRebuild() &&
14077 OldT == NewT &&
14078 Init.get() == E->getInitializer())
14079 return SemaRef.MaybeBindToTemporary(E);
14080
14081 // Note: the expression type doesn't necessarily match the
14082 // type-as-written, but that's okay, because it should always be
14083 // derivable from the initializer.
14084
14085 return getDerived().RebuildCompoundLiteralExpr(
14086 E->getLParenLoc(), NewT,
14087 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
14088}
14089
14090template<typename Derived>
14093 ExprResult Base = getDerived().TransformExpr(E->getBase());
14094 if (Base.isInvalid())
14095 return ExprError();
14096
14097 if (!getDerived().AlwaysRebuild() &&
14098 Base.get() == E->getBase())
14099 return E;
14100
14101 // FIXME: Bad source location
14102 SourceLocation FakeOperatorLoc =
14103 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14104 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14105 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
14106 E->getAccessor());
14107}
14108
14109template <typename Derived>
14112 ExprResult Base = getDerived().TransformExpr(E->getBase());
14113 if (Base.isInvalid())
14114 return ExprError();
14115
14116 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase())
14117 return E;
14118
14119 // FIXME: Bad source location
14120 SourceLocation FakeOperatorLoc =
14121 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14122 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14123 Base.get(), FakeOperatorLoc, /*isArrow*/ false, E->getAccessorLoc(),
14124 E->getAccessor());
14125}
14126
14127template<typename Derived>
14130 if (InitListExpr *Syntactic = E->getSyntacticForm())
14131 E = Syntactic;
14132
14133 bool InitChanged = false;
14134
14137
14139 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
14140 Inits, &InitChanged))
14141 return ExprError();
14142
14143 if (!getDerived().AlwaysRebuild() && !InitChanged) {
14144 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
14145 // in some cases. We can't reuse it in general, because the syntactic and
14146 // semantic forms are linked, and we can't know that semantic form will
14147 // match even if the syntactic form does.
14148 }
14149
14150 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
14151 E->getRBraceLoc(), E->isExplicit());
14152}
14153
14154template<typename Derived>
14157 Designation Desig;
14158
14159 // transform the initializer value
14160 ExprResult Init = getDerived().TransformExpr(E->getInit());
14161 if (Init.isInvalid())
14162 return ExprError();
14163
14164 // transform the designators.
14165 SmallVector<Expr*, 4> ArrayExprs;
14166 bool ExprChanged = false;
14167 for (const DesignatedInitExpr::Designator &D : E->designators()) {
14168 if (D.isFieldDesignator()) {
14169 if (D.getFieldDecl()) {
14170 FieldDecl *Field = cast_or_null<FieldDecl>(
14171 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
14172 if (Field != D.getFieldDecl())
14173 // Rebuild the expression when the transformed FieldDecl is
14174 // different to the already assigned FieldDecl.
14175 ExprChanged = true;
14176 if (Field->isAnonymousStructOrUnion())
14177 continue;
14178 } else {
14179 // Ensure that the designator expression is rebuilt when there isn't
14180 // a resolved FieldDecl in the designator as we don't want to assign
14181 // a FieldDecl to a pattern designator that will be instantiated again.
14182 ExprChanged = true;
14183 }
14184 Desig.AddDesignator(Designator::CreateFieldDesignator(
14185 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
14186 continue;
14187 }
14188
14189 if (D.isArrayDesignator()) {
14190 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
14191 if (Index.isInvalid())
14192 return ExprError();
14193
14194 Desig.AddDesignator(
14195 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
14196
14197 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
14198 ArrayExprs.push_back(Index.get());
14199 continue;
14200 }
14201
14202 assert(D.isArrayRangeDesignator() && "New kind of designator?");
14203 ExprResult Start
14204 = getDerived().TransformExpr(E->getArrayRangeStart(D));
14205 if (Start.isInvalid())
14206 return ExprError();
14207
14208 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
14209 if (End.isInvalid())
14210 return ExprError();
14211
14212 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
14213 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
14214
14215 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
14216 End.get() != E->getArrayRangeEnd(D);
14217
14218 ArrayExprs.push_back(Start.get());
14219 ArrayExprs.push_back(End.get());
14220 }
14221
14222 if (!getDerived().AlwaysRebuild() &&
14223 Init.get() == E->getInit() &&
14224 !ExprChanged)
14225 return E;
14226
14227 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14228 E->getEqualOrColonLoc(),
14229 E->usesGNUSyntax(), Init.get());
14230}
14231
14232// Seems that if TransformInitListExpr() only works on the syntactic form of an
14233// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14234template<typename Derived>
14238 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14239 "initializer");
14240 return ExprError();
14241}
14242
14243template<typename Derived>
14246 NoInitExpr *E) {
14247 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14248 return ExprError();
14249}
14250
14251template<typename Derived>
14254 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14255 return ExprError();
14256}
14257
14258template<typename Derived>
14261 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14262 return ExprError();
14263}
14264
14265template<typename Derived>
14269 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14270
14271 // FIXME: Will we ever have proper type location here? Will we actually
14272 // need to transform the type?
14273 QualType T = getDerived().TransformType(E->getType());
14274 if (T.isNull())
14275 return ExprError();
14276
14277 if (!getDerived().AlwaysRebuild() &&
14278 T == E->getType())
14279 return E;
14280
14281 return getDerived().RebuildImplicitValueInitExpr(T);
14282}
14283
14284template<typename Derived>
14287 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14288 if (!TInfo)
14289 return ExprError();
14290
14291 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14292 if (SubExpr.isInvalid())
14293 return ExprError();
14294
14295 if (!getDerived().AlwaysRebuild() &&
14296 TInfo == E->getWrittenTypeInfo() &&
14297 SubExpr.get() == E->getSubExpr())
14298 return E;
14299
14300 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14301 TInfo, E->getRParenLoc());
14302}
14303
14304template<typename Derived>
14307 bool ArgumentChanged = false;
14309 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14310 &ArgumentChanged))
14311 return ExprError();
14312
14313 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14314 Inits,
14315 E->getRParenLoc());
14316}
14317
14318/// Transform an address-of-label expression.
14319///
14320/// By default, the transformation of an address-of-label expression always
14321/// rebuilds the expression, so that the label identifier can be resolved to
14322/// the corresponding label statement by semantic analysis.
14323template<typename Derived>
14326 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14327 E->getLabel());
14328 if (!LD)
14329 return ExprError();
14330
14331 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14332 cast<LabelDecl>(LD));
14333}
14334
14335template<typename Derived>
14338 SemaRef.ActOnStartStmtExpr();
14339 StmtResult SubStmt
14340 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14341 if (SubStmt.isInvalid()) {
14342 SemaRef.ActOnStmtExprError();
14343 return ExprError();
14344 }
14345
14346 unsigned OldDepth = E->getTemplateDepth();
14347 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14348
14349 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14350 SubStmt.get() == E->getSubStmt()) {
14351 // Calling this an 'error' is unintuitive, but it does the right thing.
14352 SemaRef.ActOnStmtExprError();
14353 return SemaRef.MaybeBindToTemporary(E);
14354 }
14355
14356 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14357 E->getRParenLoc(), NewDepth);
14358}
14359
14360template<typename Derived>
14363 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14364 if (Cond.isInvalid())
14365 return ExprError();
14366
14367 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14368 if (LHS.isInvalid())
14369 return ExprError();
14370
14371 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14372 if (RHS.isInvalid())
14373 return ExprError();
14374
14375 if (!getDerived().AlwaysRebuild() &&
14376 Cond.get() == E->getCond() &&
14377 LHS.get() == E->getLHS() &&
14378 RHS.get() == E->getRHS())
14379 return E;
14380
14381 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14382 Cond.get(), LHS.get(), RHS.get(),
14383 E->getRParenLoc());
14384}
14385
14386template<typename Derived>
14389 return E;
14390}
14391
14392template<typename Derived>
14395 switch (E->getOperator()) {
14396 case OO_New:
14397 case OO_Delete:
14398 case OO_Array_New:
14399 case OO_Array_Delete:
14400 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14401
14402 case OO_Subscript:
14403 case OO_Call: {
14404 // This is a call to an object's operator().
14405 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14406
14407 // Transform the object itself.
14408 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14409 if (Object.isInvalid())
14410 return ExprError();
14411
14412 // FIXME: Poor location information. Also, if the location for the end of
14413 // the token is within a macro expansion, getLocForEndOfToken() will return
14414 // an invalid source location. If that happens and we have an otherwise
14415 // valid end location, use the valid one instead of the invalid one.
14416 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14417 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14418 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14419 FakeLParenLoc = EndLoc;
14420
14421 // Transform the call arguments.
14423 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14424 Args))
14425 return ExprError();
14426
14427 if (E->getOperator() == OO_Subscript)
14428 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14429 Args, E->getEndLoc());
14430
14431 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14432 E->getEndLoc());
14433 }
14434
14435#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14436 case OO_##Name: \
14437 break;
14438
14439#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14440#include "clang/Basic/OperatorKinds.def"
14441
14442 case OO_Conditional:
14443 llvm_unreachable("conditional operator is not actually overloadable");
14444
14445 case OO_None:
14447 llvm_unreachable("not an overloaded operator?");
14448 }
14449
14451 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14452 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14453 else
14454 First = getDerived().TransformExpr(E->getArg(0));
14455 if (First.isInvalid())
14456 return ExprError();
14457
14458 ExprResult Second;
14459 if (E->getNumArgs() == 2) {
14460 Second =
14461 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14462 if (Second.isInvalid())
14463 return ExprError();
14464 }
14465
14466 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14467 FPOptionsOverride NewOverrides(E->getFPFeatures());
14468 getSema().CurFPFeatures =
14469 NewOverrides.applyOverrides(getSema().getLangOpts());
14470 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14471
14472 Expr *Callee = E->getCallee();
14473 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14474 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14476 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14477 return ExprError();
14478
14479 return getDerived().RebuildCXXOperatorCallExpr(
14480 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14481 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14482 }
14483
14484 UnresolvedSet<1> Functions;
14485 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14486 Callee = ICE->getSubExprAsWritten();
14487 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14488 ValueDecl *VD = cast_or_null<ValueDecl>(
14489 getDerived().TransformDecl(DR->getLocation(), DR));
14490 if (!VD)
14491 return ExprError();
14492
14493 if (!isa<CXXMethodDecl>(VD))
14494 Functions.addDecl(VD);
14495
14496 return getDerived().RebuildCXXOperatorCallExpr(
14497 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14498 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14499}
14500
14501template<typename Derived>
14504 return getDerived().TransformCallExpr(E);
14505}
14506
14507template <typename Derived>
14509 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14510 getSema().CurContext != E->getParentContext();
14511
14512 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14513 return E;
14514
14515 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14516 E->getBeginLoc(), E->getEndLoc(),
14517 getSema().CurContext);
14518}
14519
14520template <typename Derived>
14522 return E;
14523}
14524
14525template<typename Derived>
14528 // Transform the callee.
14529 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14530 if (Callee.isInvalid())
14531 return ExprError();
14532
14533 // Transform exec config.
14534 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14535 if (EC.isInvalid())
14536 return ExprError();
14537
14538 // Transform arguments.
14539 bool ArgChanged = false;
14541 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14542 &ArgChanged))
14543 return ExprError();
14544
14545 if (!getDerived().AlwaysRebuild() &&
14546 Callee.get() == E->getCallee() &&
14547 !ArgChanged)
14548 return SemaRef.MaybeBindToTemporary(E);
14549
14550 // FIXME: Wrong source location information for the '('.
14551 SourceLocation FakeLParenLoc
14552 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14553 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14554 Args,
14555 E->getRParenLoc(), EC.get());
14556}
14557
14558template<typename Derived>
14561 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14562 if (!Type)
14563 return ExprError();
14564
14565 ExprResult SubExpr
14566 = getDerived().TransformExpr(E->getSubExprAsWritten());
14567 if (SubExpr.isInvalid())
14568 return ExprError();
14569
14570 if (!getDerived().AlwaysRebuild() &&
14571 Type == E->getTypeInfoAsWritten() &&
14572 SubExpr.get() == E->getSubExpr())
14573 return E;
14574 return getDerived().RebuildCXXNamedCastExpr(
14577 // FIXME. this should be '(' location
14578 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14579}
14580
14581template<typename Derived>
14584 TypeSourceInfo *TSI =
14585 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14586 if (!TSI)
14587 return ExprError();
14588
14589 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14590 if (Sub.isInvalid())
14591 return ExprError();
14592
14593 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14594 Sub.get(), BCE->getEndLoc());
14595}
14596
14597template<typename Derived>
14599TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14600 return getDerived().TransformCXXNamedCastExpr(E);
14601}
14602
14603template<typename Derived>
14606 return getDerived().TransformCXXNamedCastExpr(E);
14607}
14608
14609template<typename Derived>
14613 return getDerived().TransformCXXNamedCastExpr(E);
14614}
14615
14616template<typename Derived>
14619 return getDerived().TransformCXXNamedCastExpr(E);
14620}
14621
14622template<typename Derived>
14625 return getDerived().TransformCXXNamedCastExpr(E);
14626}
14627
14628template<typename Derived>
14633 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14634 if (!Type)
14635 return ExprError();
14636
14637 ExprResult SubExpr
14638 = getDerived().TransformExpr(E->getSubExprAsWritten());
14639 if (SubExpr.isInvalid())
14640 return ExprError();
14641
14642 if (!getDerived().AlwaysRebuild() &&
14643 Type == E->getTypeInfoAsWritten() &&
14644 SubExpr.get() == E->getSubExpr())
14645 return E;
14646
14647 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14648 E->getLParenLoc(),
14649 SubExpr.get(),
14650 E->getRParenLoc(),
14651 E->isListInitialization());
14652}
14653
14654template<typename Derived>
14657 if (E->isTypeOperand()) {
14658 TypeSourceInfo *TInfo
14659 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14660 if (!TInfo)
14661 return ExprError();
14662
14663 if (!getDerived().AlwaysRebuild() &&
14664 TInfo == E->getTypeOperandSourceInfo())
14665 return E;
14666
14667 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14668 TInfo, E->getEndLoc());
14669 }
14670
14671 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14672 // type. We must not unilaterally enter unevaluated context here, as then
14673 // semantic processing can re-transform an already transformed operand.
14674 Expr *Op = E->getExprOperand();
14676 if (E->isGLValue()) {
14677 QualType OpType = Op->getType();
14678 if (auto *RD = OpType->getAsCXXRecordDecl()) {
14679 if (SemaRef.RequireCompleteType(E->getBeginLoc(), OpType,
14680 diag::err_incomplete_typeid))
14681 return ExprError();
14682
14683 if (RD->isPolymorphic())
14684 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14685 }
14686 }
14687
14690
14691 ExprResult SubExpr = getDerived().TransformExpr(Op);
14692 if (SubExpr.isInvalid())
14693 return ExprError();
14694
14695 if (!getDerived().AlwaysRebuild() &&
14696 SubExpr.get() == E->getExprOperand())
14697 return E;
14698
14699 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14700 SubExpr.get(), E->getEndLoc());
14701}
14702
14703template<typename Derived>
14706 if (E->isTypeOperand()) {
14707 TypeSourceInfo *TInfo
14708 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14709 if (!TInfo)
14710 return ExprError();
14711
14712 if (!getDerived().AlwaysRebuild() &&
14713 TInfo == E->getTypeOperandSourceInfo())
14714 return E;
14715
14716 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14717 TInfo, E->getEndLoc());
14718 }
14719
14722
14723 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14724 if (SubExpr.isInvalid())
14725 return ExprError();
14726
14727 if (!getDerived().AlwaysRebuild() &&
14728 SubExpr.get() == E->getExprOperand())
14729 return E;
14730
14731 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14732 SubExpr.get(), E->getEndLoc());
14733}
14734
14735template<typename Derived>
14738 return E;
14739}
14740
14741template<typename Derived>
14745 return E;
14746}
14747
14748template<typename Derived>
14751
14752 // In lambdas, the qualifiers of the type depends of where in
14753 // the call operator `this` appear, and we do not have a good way to
14754 // rebuild this information, so we transform the type.
14755 //
14756 // In other contexts, the type of `this` may be overrided
14757 // for type deduction, so we need to recompute it.
14758 //
14759 // Always recompute the type if we're in the body of a lambda, and
14760 // 'this' is dependent on a lambda's explicit object parameter; we
14761 // also need to always rebuild the expression in this case to clear
14762 // the flag.
14763 QualType T = [&]() {
14764 auto &S = getSema();
14765 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14766 return S.getCurrentThisType();
14767 if (S.getCurLambda())
14768 return getDerived().TransformType(E->getType());
14769 return S.getCurrentThisType();
14770 }();
14771
14772 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14773 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14774 // Mark it referenced in the new context regardless.
14775 // FIXME: this is a bit instantiation-specific.
14776 getSema().MarkThisReferenced(E);
14777 return E;
14778 }
14779
14780 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14781}
14782
14783template<typename Derived>
14786 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14787 if (SubExpr.isInvalid())
14788 return ExprError();
14789
14790 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14791
14792 if (!getDerived().AlwaysRebuild() &&
14793 SubExpr.get() == E->getSubExpr())
14794 return E;
14795
14796 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14797 E->isThrownVariableInScope());
14798}
14799
14800template<typename Derived>
14803 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14804 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14805 if (!Param)
14806 return ExprError();
14807
14808 ExprResult InitRes;
14809 if (E->hasRewrittenInit()) {
14810 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14811 if (InitRes.isInvalid())
14812 return ExprError();
14813 }
14814
14815 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14816 E->getUsedContext() == SemaRef.CurContext &&
14817 InitRes.get() == E->getRewrittenExpr())
14818 return E;
14819
14820 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14821 InitRes.get());
14822}
14823
14824template<typename Derived>
14827 FieldDecl *Field = cast_or_null<FieldDecl>(
14828 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14829 if (!Field)
14830 return ExprError();
14831
14832 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14833 E->getUsedContext() == SemaRef.CurContext)
14834 return E;
14835
14836 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14837}
14838
14839template<typename Derived>
14843 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14844 if (!T)
14845 return ExprError();
14846
14847 if (!getDerived().AlwaysRebuild() &&
14848 T == E->getTypeSourceInfo())
14849 return E;
14850
14851 return getDerived().RebuildCXXScalarValueInitExpr(T,
14852 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14853 E->getRParenLoc());
14854}
14855
14856template<typename Derived>
14859 // Transform the type that we're allocating
14860 TypeSourceInfo *AllocTypeInfo =
14861 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14862 if (!AllocTypeInfo)
14863 return ExprError();
14864
14865 // Transform the size of the array we're allocating (if any).
14866 std::optional<Expr *> ArraySize;
14867 if (E->isArray()) {
14868 ExprResult NewArraySize;
14869 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14870 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14871 if (NewArraySize.isInvalid())
14872 return ExprError();
14873 }
14874 ArraySize = NewArraySize.get();
14875 }
14876
14877 // Transform the placement arguments (if any).
14878 bool ArgumentChanged = false;
14879 SmallVector<Expr*, 8> PlacementArgs;
14880 if (getDerived().TransformExprs(E->getPlacementArgs(),
14881 E->getNumPlacementArgs(), true,
14882 PlacementArgs, &ArgumentChanged))
14883 return ExprError();
14884
14885 // Transform the initializer (if any).
14886 Expr *OldInit = E->getInitializer();
14887 ExprResult NewInit;
14888 if (OldInit)
14889 NewInit = getDerived().TransformInitializer(OldInit, true);
14890 if (NewInit.isInvalid())
14891 return ExprError();
14892
14893 // Transform new operator and delete operator.
14894 FunctionDecl *OperatorNew = nullptr;
14895 if (E->getOperatorNew()) {
14896 OperatorNew = cast_or_null<FunctionDecl>(
14897 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14898 if (!OperatorNew)
14899 return ExprError();
14900 }
14901
14902 FunctionDecl *OperatorDelete = nullptr;
14903 if (E->getOperatorDelete()) {
14904 OperatorDelete = cast_or_null<FunctionDecl>(
14905 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14906 if (!OperatorDelete)
14907 return ExprError();
14908 }
14909
14910 if (!getDerived().AlwaysRebuild() &&
14911 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14912 ArraySize == E->getArraySize() &&
14913 NewInit.get() == OldInit &&
14914 OperatorNew == E->getOperatorNew() &&
14915 OperatorDelete == E->getOperatorDelete() &&
14916 !ArgumentChanged) {
14917 // Mark any declarations we need as referenced.
14918 // FIXME: instantiation-specific.
14919 if (OperatorNew)
14920 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14921 if (OperatorDelete)
14922 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14923
14924 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14925 QualType ElementType
14926 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14927 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14929 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14930 }
14931 }
14932
14933 return E;
14934 }
14935
14936 QualType AllocType = AllocTypeInfo->getType();
14937 if (!ArraySize) {
14938 // If no array size was specified, but the new expression was
14939 // instantiated with an array type (e.g., "new T" where T is
14940 // instantiated with "int[4]"), extract the outer bound from the
14941 // array type as our array size. We do this with constant and
14942 // dependently-sized array types.
14943 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14944 if (!ArrayT) {
14945 // Do nothing
14946 } else if (const ConstantArrayType *ConsArrayT
14947 = dyn_cast<ConstantArrayType>(ArrayT)) {
14948 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14949 SemaRef.Context.getSizeType(),
14950 /*FIXME:*/ E->getBeginLoc());
14951 AllocType = ConsArrayT->getElementType();
14952 } else if (const DependentSizedArrayType *DepArrayT
14953 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14954 if (DepArrayT->getSizeExpr()) {
14955 ArraySize = DepArrayT->getSizeExpr();
14956 AllocType = DepArrayT->getElementType();
14957 }
14958 }
14959 }
14960
14961 return getDerived().RebuildCXXNewExpr(
14962 E->getBeginLoc(), E->isGlobalNew(),
14963 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14964 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14965 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14966}
14967
14968template<typename Derived>
14971 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14972 if (Operand.isInvalid())
14973 return ExprError();
14974
14975 // Transform the delete operator, if known.
14976 FunctionDecl *OperatorDelete = nullptr;
14977 if (E->getOperatorDelete()) {
14978 OperatorDelete = cast_or_null<FunctionDecl>(
14979 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14980 if (!OperatorDelete)
14981 return ExprError();
14982 }
14983
14984 if (!getDerived().AlwaysRebuild() &&
14985 Operand.get() == E->getArgument() &&
14986 OperatorDelete == E->getOperatorDelete()) {
14987 // Mark any declarations we need as referenced.
14988 // FIXME: instantiation-specific.
14989 if (OperatorDelete)
14990 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14991
14992 if (!E->getArgument()->isTypeDependent()) {
14994 E->getDestroyedType());
14995 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14996 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14997 SemaRef.LookupDestructor(Record));
14998 }
14999
15000 return E;
15001 }
15002
15003 return getDerived().RebuildCXXDeleteExpr(
15004 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
15005}
15006
15007template<typename Derived>
15011 ExprResult Base = getDerived().TransformExpr(E->getBase());
15012 if (Base.isInvalid())
15013 return ExprError();
15014
15015 ParsedType ObjectTypePtr;
15016 bool MayBePseudoDestructor = false;
15017 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
15018 E->getOperatorLoc(),
15019 E->isArrow()? tok::arrow : tok::period,
15020 ObjectTypePtr,
15021 MayBePseudoDestructor);
15022 if (Base.isInvalid())
15023 return ExprError();
15024
15025 QualType ObjectType = ObjectTypePtr.get();
15026 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
15027 if (QualifierLoc) {
15028 QualifierLoc
15029 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
15030 if (!QualifierLoc)
15031 return ExprError();
15032 }
15033 CXXScopeSpec SS;
15034 SS.Adopt(QualifierLoc);
15035
15037 if (E->getDestroyedTypeInfo()) {
15038 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
15039 E->getDestroyedTypeInfo(), ObjectType,
15040 /*FirstQualifierInScope=*/nullptr);
15041 if (!DestroyedTypeInfo)
15042 return ExprError();
15043 Destroyed = DestroyedTypeInfo;
15044 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
15045 // We aren't likely to be able to resolve the identifier down to a type
15046 // now anyway, so just retain the identifier.
15047 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
15048 E->getDestroyedTypeLoc());
15049 } else {
15050 // Look for a destructor known with the given name.
15051 ParsedType T = SemaRef.getDestructorName(
15052 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
15053 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
15054 if (!T)
15055 return ExprError();
15056
15057 Destroyed
15059 E->getDestroyedTypeLoc());
15060 }
15061
15062 TypeSourceInfo *ScopeTypeInfo = nullptr;
15063 if (E->getScopeTypeInfo()) {
15064 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
15065 E->getScopeTypeInfo(), ObjectType, nullptr);
15066 if (!ScopeTypeInfo)
15067 return ExprError();
15068 }
15069
15070 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
15071 E->getOperatorLoc(),
15072 E->isArrow(),
15073 SS,
15074 ScopeTypeInfo,
15075 E->getColonColonLoc(),
15076 E->getTildeLoc(),
15077 Destroyed);
15078}
15079
15080template <typename Derived>
15082 bool RequiresADL,
15083 LookupResult &R) {
15084 // Transform all the decls.
15085 bool AllEmptyPacks = true;
15086 for (auto *OldD : Old->decls()) {
15087 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
15088 if (!InstD) {
15089 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
15090 // This can happen because of dependent hiding.
15091 if (isa<UsingShadowDecl>(OldD))
15092 continue;
15093 else {
15094 R.clear();
15095 return true;
15096 }
15097 }
15098
15099 // Expand using pack declarations.
15100 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
15101 ArrayRef<NamedDecl*> Decls = SingleDecl;
15102 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
15103 Decls = UPD->expansions();
15104
15105 // Expand using declarations.
15106 for (auto *D : Decls) {
15107 if (auto *UD = dyn_cast<UsingDecl>(D)) {
15108 for (auto *SD : UD->shadows())
15109 R.addDecl(SD);
15110 } else {
15111 R.addDecl(D);
15112 }
15113 }
15114
15115 AllEmptyPacks &= Decls.empty();
15116 }
15117
15118 // C++ [temp.res]/8.4.2:
15119 // The program is ill-formed, no diagnostic required, if [...] lookup for
15120 // a name in the template definition found a using-declaration, but the
15121 // lookup in the corresponding scope in the instantiation odoes not find
15122 // any declarations because the using-declaration was a pack expansion and
15123 // the corresponding pack is empty
15124 if (AllEmptyPacks && !RequiresADL) {
15125 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
15126 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
15127 return true;
15128 }
15129
15130 // Resolve a kind, but don't do any further analysis. If it's
15131 // ambiguous, the callee needs to deal with it.
15132 R.resolveKind();
15133
15134 if (Old->hasTemplateKeyword() && !R.empty()) {
15135 NamedDecl *FoundDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
15136 getSema().FilterAcceptableTemplateNames(R,
15137 /*AllowFunctionTemplates=*/true,
15138 /*AllowDependent=*/true);
15139 if (R.empty()) {
15140 // If a 'template' keyword was used, a lookup that finds only non-template
15141 // names is an error.
15142 getSema().Diag(R.getNameLoc(),
15143 diag::err_template_kw_refers_to_non_template)
15144 << R.getLookupName() << Old->getQualifierLoc().getSourceRange()
15145 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
15146 getSema().Diag(FoundDecl->getLocation(),
15147 diag::note_template_kw_refers_to_non_template)
15148 << R.getLookupName();
15149 return true;
15150 }
15151 }
15152
15153 return false;
15154}
15155
15156template <typename Derived>
15161
15162template <typename Derived>
15165 bool IsAddressOfOperand) {
15166 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
15168
15169 // Transform the declaration set.
15170 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
15171 return ExprError();
15172
15173 // Rebuild the nested-name qualifier, if present.
15174 CXXScopeSpec SS;
15175 if (Old->getQualifierLoc()) {
15176 NestedNameSpecifierLoc QualifierLoc
15177 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
15178 if (!QualifierLoc)
15179 return ExprError();
15180
15181 SS.Adopt(QualifierLoc);
15182 }
15183
15184 if (Old->getNamingClass()) {
15185 CXXRecordDecl *NamingClass
15186 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
15187 Old->getNameLoc(),
15188 Old->getNamingClass()));
15189 if (!NamingClass) {
15190 R.clear();
15191 return ExprError();
15192 }
15193
15194 R.setNamingClass(NamingClass);
15195 }
15196
15197 // Rebuild the template arguments, if any.
15198 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
15199 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
15200 if (Old->hasExplicitTemplateArgs() &&
15201 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15202 Old->getNumTemplateArgs(),
15203 TransArgs)) {
15204 R.clear();
15205 return ExprError();
15206 }
15207
15208 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
15209 // a non-static data member is named in an unevaluated operand, or when
15210 // a member is named in a dependent class scope function template explicit
15211 // specialization that is neither declared static nor with an explicit object
15212 // parameter.
15213 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
15214 return SemaRef.BuildPossibleImplicitMemberExpr(
15215 SS, TemplateKWLoc, R,
15216 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
15217 /*S=*/nullptr);
15218
15219 // If we have neither explicit template arguments, nor the template keyword,
15220 // it's a normal declaration name or member reference.
15221 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
15222 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
15223
15224 // If we have template arguments, then rebuild the template-id expression.
15225 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
15226 Old->requiresADL(), &TransArgs);
15227}
15228
15229template<typename Derived>
15232 bool ArgChanged = false;
15234 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15235 TypeSourceInfo *From = E->getArg(I);
15236 TypeLoc FromTL = From->getTypeLoc();
15237 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15238 TypeLocBuilder TLB;
15239 TLB.reserve(FromTL.getFullDataSize());
15240 QualType To = getDerived().TransformType(TLB, FromTL);
15241 if (To.isNull())
15242 return ExprError();
15243
15244 if (To == From->getType())
15245 Args.push_back(From);
15246 else {
15247 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15248 ArgChanged = true;
15249 }
15250 continue;
15251 }
15252
15253 ArgChanged = true;
15254
15255 // We have a pack expansion. Instantiate it.
15256 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15257 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15259 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15260
15261 // Determine whether the set of unexpanded parameter packs can and should
15262 // be expanded.
15263 bool Expand = true;
15264 bool RetainExpansion = false;
15265 UnsignedOrNone OrigNumExpansions =
15266 ExpansionTL.getTypePtr()->getNumExpansions();
15267 UnsignedOrNone NumExpansions = OrigNumExpansions;
15268 if (getDerived().TryExpandParameterPacks(
15269 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15270 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15271 RetainExpansion, NumExpansions))
15272 return ExprError();
15273
15274 if (!Expand) {
15275 // The transform has determined that we should perform a simple
15276 // transformation on the pack expansion, producing another pack
15277 // expansion.
15278 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15279
15280 TypeLocBuilder TLB;
15281 TLB.reserve(From->getTypeLoc().getFullDataSize());
15282
15283 QualType To = getDerived().TransformType(TLB, PatternTL);
15284 if (To.isNull())
15285 return ExprError();
15286
15287 To = getDerived().RebuildPackExpansionType(To,
15288 PatternTL.getSourceRange(),
15289 ExpansionTL.getEllipsisLoc(),
15290 NumExpansions);
15291 if (To.isNull())
15292 return ExprError();
15293
15294 PackExpansionTypeLoc ToExpansionTL
15295 = TLB.push<PackExpansionTypeLoc>(To);
15296 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15297 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15298 continue;
15299 }
15300
15301 // Expand the pack expansion by substituting for each argument in the
15302 // pack(s).
15303 for (unsigned I = 0; I != *NumExpansions; ++I) {
15304 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15305 TypeLocBuilder TLB;
15306 TLB.reserve(PatternTL.getFullDataSize());
15307 QualType To = getDerived().TransformType(TLB, PatternTL);
15308 if (To.isNull())
15309 return ExprError();
15310
15311 if (To->containsUnexpandedParameterPack()) {
15312 To = getDerived().RebuildPackExpansionType(To,
15313 PatternTL.getSourceRange(),
15314 ExpansionTL.getEllipsisLoc(),
15315 NumExpansions);
15316 if (To.isNull())
15317 return ExprError();
15318
15319 PackExpansionTypeLoc ToExpansionTL
15320 = TLB.push<PackExpansionTypeLoc>(To);
15321 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15322 }
15323
15324 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15325 }
15326
15327 if (!RetainExpansion)
15328 continue;
15329
15330 // If we're supposed to retain a pack expansion, do so by temporarily
15331 // forgetting the partially-substituted parameter pack.
15332 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15333
15334 TypeLocBuilder TLB;
15335 TLB.reserve(From->getTypeLoc().getFullDataSize());
15336
15337 QualType To = getDerived().TransformType(TLB, PatternTL);
15338 if (To.isNull())
15339 return ExprError();
15340
15341 To = getDerived().RebuildPackExpansionType(To,
15342 PatternTL.getSourceRange(),
15343 ExpansionTL.getEllipsisLoc(),
15344 NumExpansions);
15345 if (To.isNull())
15346 return ExprError();
15347
15348 PackExpansionTypeLoc ToExpansionTL
15349 = TLB.push<PackExpansionTypeLoc>(To);
15350 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15351 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15352 }
15353
15354 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15355 return E;
15356
15357 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15358 E->getEndLoc());
15359}
15360
15361template<typename Derived>
15365 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15366 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15367 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15368 Old->NumTemplateArgs, TransArgs))
15369 return ExprError();
15370
15371 return getDerived().RebuildConceptSpecializationExpr(
15372 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15373 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15374 &TransArgs);
15375}
15376
15377template<typename Derived>
15380 SmallVector<ParmVarDecl*, 4> TransParams;
15381 SmallVector<QualType, 4> TransParamTypes;
15382 Sema::ExtParameterInfoBuilder ExtParamInfos;
15383
15384 // C++2a [expr.prim.req]p2
15385 // Expressions appearing within a requirement-body are unevaluated operands.
15389
15391 getSema().Context, getSema().CurContext,
15392 E->getBody()->getBeginLoc());
15393
15394 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15395
15396 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15397 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15398 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15399
15400 for (ParmVarDecl *Param : TransParams)
15401 if (Param)
15402 Param->setDeclContext(Body);
15403
15404 // On failure to transform, TransformRequiresTypeParams returns an expression
15405 // in the event that the transformation of the type params failed in some way.
15406 // It is expected that this will result in a 'not satisfied' Requires clause
15407 // when instantiating.
15408 if (!TypeParamResult.isUnset())
15409 return TypeParamResult;
15410
15412 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15413 TransReqs))
15414 return ExprError();
15415
15416 for (concepts::Requirement *Req : TransReqs) {
15417 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15418 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15419 ER->getReturnTypeRequirement()
15420 .getTypeConstraintTemplateParameterList()->getParam(0)
15421 ->setDeclContext(Body);
15422 }
15423 }
15424 }
15425
15426 return getDerived().RebuildRequiresExpr(
15427 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15428 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15429}
15430
15431template<typename Derived>
15435 for (concepts::Requirement *Req : Reqs) {
15436 concepts::Requirement *TransReq = nullptr;
15437 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15438 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15439 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15440 TransReq = getDerived().TransformExprRequirement(ExprReq);
15441 else
15442 TransReq = getDerived().TransformNestedRequirement(
15444 if (!TransReq)
15445 return true;
15446 Transformed.push_back(TransReq);
15447 }
15448 return false;
15449}
15450
15451template<typename Derived>
15455 if (Req->isSubstitutionFailure()) {
15456 if (getDerived().AlwaysRebuild())
15457 return getDerived().RebuildTypeRequirement(
15459 return Req;
15460 }
15461 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15462 if (!TransType)
15463 return nullptr;
15464 return getDerived().RebuildTypeRequirement(TransType);
15465}
15466
15467template<typename Derived>
15470 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15471 if (Req->isExprSubstitutionFailure())
15472 TransExpr = Req->getExprSubstitutionDiagnostic();
15473 else {
15474 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15475 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15476 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15477 if (TransExprRes.isInvalid())
15478 return nullptr;
15479 TransExpr = TransExprRes.get();
15480 }
15481
15482 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15483 const auto &RetReq = Req->getReturnTypeRequirement();
15484 if (RetReq.isEmpty())
15485 TransRetReq.emplace();
15486 else if (RetReq.isSubstitutionFailure())
15487 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15488 else if (RetReq.isTypeConstraint()) {
15489 TemplateParameterList *OrigTPL =
15490 RetReq.getTypeConstraintTemplateParameterList();
15492 getDerived().TransformTemplateParameterList(OrigTPL);
15493 if (!TPL)
15494 return nullptr;
15495 TransRetReq.emplace(TPL);
15496 }
15497 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15498 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15499 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15500 Req->getNoexceptLoc(),
15501 std::move(*TransRetReq));
15502 return getDerived().RebuildExprRequirement(
15504 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15505}
15506
15507template<typename Derived>
15511 if (Req->hasInvalidConstraint()) {
15512 if (getDerived().AlwaysRebuild())
15513 return getDerived().RebuildNestedRequirement(
15515 return Req;
15516 }
15517 ExprResult TransConstraint =
15518 getDerived().TransformExpr(Req->getConstraintExpr());
15519 if (TransConstraint.isInvalid())
15520 return nullptr;
15521 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15522}
15523
15524template<typename Derived>
15527 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15528 if (!T)
15529 return ExprError();
15530
15531 if (!getDerived().AlwaysRebuild() &&
15532 T == E->getQueriedTypeSourceInfo())
15533 return E;
15534
15535 ExprResult SubExpr;
15536 {
15539 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15540 if (SubExpr.isInvalid())
15541 return ExprError();
15542 }
15543
15544 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15545 SubExpr.get(), E->getEndLoc());
15546}
15547
15548template<typename Derived>
15551 ExprResult SubExpr;
15552 {
15555 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15556 if (SubExpr.isInvalid())
15557 return ExprError();
15558
15559 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15560 return E;
15561 }
15562
15563 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15564 SubExpr.get(), E->getEndLoc());
15565}
15566
15567template <typename Derived>
15569 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15570 TypeSourceInfo **RecoveryTSI) {
15571 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15572 DRE, AddrTaken, RecoveryTSI);
15573
15574 // Propagate both errors and recovered types, which return ExprEmpty.
15575 if (!NewDRE.isUsable())
15576 return NewDRE;
15577
15578 // We got an expr, wrap it up in parens.
15579 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15580 return PE;
15581 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15582 PE->getRParen());
15583}
15584
15585template <typename Derived>
15591
15592template <typename Derived>
15594 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15595 TypeSourceInfo **RecoveryTSI) {
15596 assert(E->getQualifierLoc());
15597 NestedNameSpecifierLoc QualifierLoc =
15598 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15599 if (!QualifierLoc)
15600 return ExprError();
15601 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15602
15603 // TODO: If this is a conversion-function-id, verify that the
15604 // destination type name (if present) resolves the same way after
15605 // instantiation as it did in the local scope.
15606
15607 DeclarationNameInfo NameInfo =
15608 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15609 if (!NameInfo.getName())
15610 return ExprError();
15611
15612 if (!E->hasExplicitTemplateArgs()) {
15613 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15614 // Note: it is sufficient to compare the Name component of NameInfo:
15615 // if name has not changed, DNLoc has not changed either.
15616 NameInfo.getName() == E->getDeclName())
15617 return E;
15618
15619 return getDerived().RebuildDependentScopeDeclRefExpr(
15620 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15621 IsAddressOfOperand, RecoveryTSI);
15622 }
15623
15624 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15625 if (getDerived().TransformTemplateArguments(
15626 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15627 return ExprError();
15628
15629 return getDerived().RebuildDependentScopeDeclRefExpr(
15630 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15631 RecoveryTSI);
15632}
15633
15634template<typename Derived>
15637 // CXXConstructExprs other than for list-initialization and
15638 // CXXTemporaryObjectExpr are always implicit, so when we have
15639 // a 1-argument construction we just transform that argument.
15640 if (getDerived().AllowSkippingCXXConstructExpr() &&
15641 ((E->getNumArgs() == 1 ||
15642 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15643 (!getDerived().DropCallArgument(E->getArg(0))) &&
15644 !E->isListInitialization()))
15645 return getDerived().TransformInitializer(E->getArg(0),
15646 /*DirectInit*/ false);
15647
15648 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15649
15650 QualType T = getDerived().TransformType(E->getType());
15651 if (T.isNull())
15652 return ExprError();
15653
15654 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15655 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15656 if (!Constructor)
15657 return ExprError();
15658
15659 bool ArgumentChanged = false;
15661 {
15664 E->isListInitialization());
15665 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15666 &ArgumentChanged))
15667 return ExprError();
15668 }
15669
15670 if (!getDerived().AlwaysRebuild() &&
15671 T == E->getType() &&
15672 Constructor == E->getConstructor() &&
15673 !ArgumentChanged) {
15674 // Mark the constructor as referenced.
15675 // FIXME: Instantiation-specific
15676 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15677 return E;
15678 }
15679
15680 return getDerived().RebuildCXXConstructExpr(
15681 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15682 E->hadMultipleCandidates(), E->isListInitialization(),
15683 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15684 E->getConstructionKind(), E->getParenOrBraceRange());
15685}
15686
15687template<typename Derived>
15690 QualType T = getDerived().TransformType(E->getType());
15691 if (T.isNull())
15692 return ExprError();
15693
15694 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15695 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15696 if (!Constructor)
15697 return ExprError();
15698
15699 if (!getDerived().AlwaysRebuild() &&
15700 T == E->getType() &&
15701 Constructor == E->getConstructor()) {
15702 // Mark the constructor as referenced.
15703 // FIXME: Instantiation-specific
15704 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15705 return E;
15706 }
15707
15708 return getDerived().RebuildCXXInheritedCtorInitExpr(
15709 T, E->getLocation(), Constructor,
15710 E->constructsVBase(), E->inheritedFromVBase());
15711}
15712
15713/// Transform a C++ temporary-binding expression.
15714///
15715/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15716/// transform the subexpression and return that.
15717template<typename Derived>
15720 if (auto *Dtor = E->getTemporary()->getDestructor())
15721 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15722 const_cast<CXXDestructorDecl *>(Dtor));
15723 return getDerived().TransformExpr(E->getSubExpr());
15724}
15725
15726/// Transform a C++ expression that contains cleanups that should
15727/// be run after the expression is evaluated.
15728///
15729/// Since ExprWithCleanups nodes are implicitly generated, we
15730/// just transform the subexpression and return that.
15731template<typename Derived>
15734 return getDerived().TransformExpr(E->getSubExpr());
15735}
15736
15737template<typename Derived>
15741 TypeSourceInfo *T =
15742 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15743 if (!T)
15744 return ExprError();
15745
15746 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15747 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15748 if (!Constructor)
15749 return ExprError();
15750
15751 bool ArgumentChanged = false;
15753 Args.reserve(E->getNumArgs());
15754 {
15757 E->isListInitialization());
15758 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15759 &ArgumentChanged))
15760 return ExprError();
15761
15762 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15763 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc(),
15764 /*IsExplicit=*/true);
15765 if (Res.isInvalid())
15766 return ExprError();
15767 Args = {Res.get()};
15768 }
15769 }
15770
15771 if (!getDerived().AlwaysRebuild() &&
15772 T == E->getTypeSourceInfo() &&
15773 Constructor == E->getConstructor() &&
15774 !ArgumentChanged) {
15775 // FIXME: Instantiation-specific
15776 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15777 return SemaRef.MaybeBindToTemporary(E);
15778 }
15779
15780 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15781 return getDerived().RebuildCXXTemporaryObjectExpr(
15782 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15783}
15784
15785template<typename Derived>
15788 // Transform any init-capture expressions before entering the scope of the
15789 // lambda body, because they are not semantically within that scope.
15790 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15791 struct TransformedInitCapture {
15792 // The location of the ... if the result is retaining a pack expansion.
15793 SourceLocation EllipsisLoc;
15794 // Zero or more expansions of the init-capture.
15795 SmallVector<InitCaptureInfoTy, 4> Expansions;
15796 };
15798 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15799 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15800 CEnd = E->capture_end();
15801 C != CEnd; ++C) {
15802 if (!E->isInitCapture(C))
15803 continue;
15804
15805 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15806 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15807
15808 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15809 UnsignedOrNone NumExpansions) {
15810 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15811 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15812
15813 if (NewExprInitResult.isInvalid()) {
15814 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15815 return;
15816 }
15817 Expr *NewExprInit = NewExprInitResult.get();
15818
15819 QualType NewInitCaptureType =
15820 getSema().buildLambdaInitCaptureInitialization(
15821 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15822 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15823 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15825 NewExprInit);
15826 Result.Expansions.push_back(
15827 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15828 };
15829
15830 // If this is an init-capture pack, consider expanding the pack now.
15831 if (OldVD->isParameterPack()) {
15832 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15833 ->getTypeLoc()
15836 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15837
15838 // Determine whether the set of unexpanded parameter packs can and should
15839 // be expanded.
15840 bool Expand = true;
15841 bool RetainExpansion = false;
15842 UnsignedOrNone OrigNumExpansions =
15843 ExpansionTL.getTypePtr()->getNumExpansions();
15844 UnsignedOrNone NumExpansions = OrigNumExpansions;
15845 if (getDerived().TryExpandParameterPacks(
15846 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15847 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15848 RetainExpansion, NumExpansions))
15849 return ExprError();
15850 assert(!RetainExpansion && "Should not need to retain expansion after a "
15851 "capture since it cannot be extended");
15852 if (Expand) {
15853 for (unsigned I = 0; I != *NumExpansions; ++I) {
15854 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15855 SubstInitCapture(SourceLocation(), std::nullopt);
15856 }
15857 } else {
15858 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15859 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15860 }
15861 } else {
15862 SubstInitCapture(SourceLocation(), std::nullopt);
15863 }
15864 }
15865
15866 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15867 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15868
15869 // Create the local class that will describe the lambda.
15870
15871 // FIXME: DependencyKind below is wrong when substituting inside a templated
15872 // context that isn't a DeclContext (such as a variable template), or when
15873 // substituting an unevaluated lambda inside of a function's parameter's type
15874 // - as parameter types are not instantiated from within a function's DC. We
15875 // use evaluation contexts to distinguish the function parameter case.
15878 DeclContext *DC = getSema().CurContext;
15879 // A RequiresExprBodyDecl is not interesting for dependencies.
15880 // For the following case,
15881 //
15882 // template <typename>
15883 // concept C = requires { [] {}; };
15884 //
15885 // template <class F>
15886 // struct Widget;
15887 //
15888 // template <C F>
15889 // struct Widget<F> {};
15890 //
15891 // While we are substituting Widget<F>, the parent of DC would be
15892 // the template specialization itself. Thus, the lambda expression
15893 // will be deemed as dependent even if there are no dependent template
15894 // arguments.
15895 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15896 while (DC->isRequiresExprBody())
15897 DC = DC->getParent();
15898 if ((getSema().isUnevaluatedContext() ||
15899 getSema().isConstantEvaluatedContext()) &&
15900 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15901 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
15902 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15903 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15904
15905 CXXRecordDecl *OldClass = E->getLambdaClass();
15906 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15907 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15908 E->getCaptureDefault());
15909 getDerived().transformedLocalDecl(OldClass, {Class});
15910
15911 CXXMethodDecl *NewCallOperator =
15912 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15913
15914 // Enter the scope of the lambda.
15915 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15916 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15917 E->hasExplicitParameters(), E->isMutable());
15918
15919 // Introduce the context of the call operator.
15920 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15921 /*NewThisContext*/false);
15922
15923 bool Invalid = false;
15924
15925 // Transform captures.
15926 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15927 CEnd = E->capture_end();
15928 C != CEnd; ++C) {
15929 // When we hit the first implicit capture, tell Sema that we've finished
15930 // the list of explicit captures.
15931 if (C->isImplicit())
15932 break;
15933
15934 // Capturing 'this' is trivial.
15935 if (C->capturesThis()) {
15936 // If this is a lambda that is part of a default member initialiser
15937 // and which we're instantiating outside the class that 'this' is
15938 // supposed to refer to, adjust the type of 'this' accordingly.
15939 //
15940 // Otherwise, leave the type of 'this' as-is.
15941 Sema::CXXThisScopeRAII ThisScope(
15942 getSema(),
15943 dyn_cast_if_present<CXXRecordDecl>(
15944 getSema().getFunctionLevelDeclContext()),
15945 Qualifiers());
15946 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15947 /*BuildAndDiagnose*/ true, nullptr,
15948 C->getCaptureKind() == LCK_StarThis);
15949 continue;
15950 }
15951 // Captured expression will be recaptured during captured variables
15952 // rebuilding.
15953 if (C->capturesVLAType())
15954 continue;
15955
15956 // Rebuild init-captures, including the implied field declaration.
15957 if (E->isInitCapture(C)) {
15958 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15959
15960 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15962
15963 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15964 ExprResult Init = Info.first;
15965 QualType InitQualType = Info.second;
15966 if (Init.isInvalid() || InitQualType.isNull()) {
15967 Invalid = true;
15968 break;
15969 }
15970 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15971 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15972 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15973 getSema().CurContext);
15974 if (!NewVD) {
15975 Invalid = true;
15976 break;
15977 }
15978 NewVDs.push_back(NewVD);
15979 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15980 // Cases we want to tackle:
15981 // ([C(Pack)] {}, ...)
15982 // But rule out cases e.g.
15983 // [...C = Pack()] {}
15984 if (NewC.EllipsisLoc.isInvalid())
15985 LSI->ContainsUnexpandedParameterPack |=
15986 Init.get()->containsUnexpandedParameterPack();
15987 }
15988
15989 if (Invalid)
15990 break;
15991
15992 getDerived().transformedLocalDecl(OldVD, NewVDs);
15993 continue;
15994 }
15995
15996 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15997
15998 // Determine the capture kind for Sema.
16000 : C->getCaptureKind() == LCK_ByCopy
16003 SourceLocation EllipsisLoc;
16004 if (C->isPackExpansion()) {
16005 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
16006 bool ShouldExpand = false;
16007 bool RetainExpansion = false;
16008 UnsignedOrNone NumExpansions = std::nullopt;
16009 if (getDerived().TryExpandParameterPacks(
16010 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
16011 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16012 RetainExpansion, NumExpansions)) {
16013 Invalid = true;
16014 continue;
16015 }
16016
16017 if (ShouldExpand) {
16018 // The transform has determined that we should perform an expansion;
16019 // transform and capture each of the arguments.
16020 // expansion of the pattern. Do so.
16021 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
16022 for (unsigned I = 0; I != *NumExpansions; ++I) {
16023 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16024 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
16025 getDerived().TransformDecl(C->getLocation(), Pack));
16026 if (!CapturedVar) {
16027 Invalid = true;
16028 continue;
16029 }
16030
16031 // Capture the transformed variable.
16032 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
16033 }
16034
16035 // FIXME: Retain a pack expansion if RetainExpansion is true.
16036
16037 continue;
16038 }
16039
16040 EllipsisLoc = C->getEllipsisLoc();
16041 }
16042
16043 // Transform the captured variable.
16044 auto *CapturedVar = cast_or_null<ValueDecl>(
16045 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16046 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
16047 Invalid = true;
16048 continue;
16049 }
16050
16051 // This is not an init-capture; however it contains an unexpanded pack e.g.
16052 // ([Pack] {}(), ...)
16053 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
16054 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
16055
16056 // Capture the transformed variable.
16057 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
16058 EllipsisLoc);
16059 }
16060 getSema().finishLambdaExplicitCaptures(LSI);
16061
16062 // Transform the template parameters, and add them to the current
16063 // instantiation scope. The null case is handled correctly.
16064 auto TPL = getDerived().TransformTemplateParameterList(
16065 E->getTemplateParameterList());
16066 LSI->GLTemplateParameterList = TPL;
16067 if (TPL) {
16068 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
16069 TPL);
16070 LSI->ContainsUnexpandedParameterPack |=
16071 TPL->containsUnexpandedParameterPack();
16072 }
16073
16074 TypeLocBuilder NewCallOpTLBuilder;
16075 TypeLoc OldCallOpTypeLoc =
16076 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
16077 QualType NewCallOpType =
16078 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
16079 if (NewCallOpType.isNull())
16080 return ExprError();
16081 LSI->ContainsUnexpandedParameterPack |=
16082 NewCallOpType->containsUnexpandedParameterPack();
16083 TypeSourceInfo *NewCallOpTSI =
16084 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
16085
16086 // The type may be an AttributedType or some other kind of sugar;
16087 // get the actual underlying FunctionProtoType.
16088 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
16089 assert(FPTL && "Not a FunctionProtoType?");
16090
16091 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
16092 // If the concept refers to any outer parameter packs, we track the SubstIndex
16093 // for evaluation.
16094 if (TRC && TRC.ConstraintExpr->containsUnexpandedParameterPack() &&
16095 !TRC.ArgPackSubstIndex)
16097
16098 getSema().CompleteLambdaCallOperator(
16099 NewCallOperator, E->getCallOperator()->getLocation(),
16100 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
16101 E->getCallOperator()->getConstexprKind(),
16102 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
16103 E->hasExplicitResultType());
16104
16105 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
16106 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
16107
16108 {
16109 // Number the lambda for linkage purposes if necessary.
16110 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
16111
16112 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
16113 if (getDerived().ReplacingOriginal()) {
16114 Numbering = OldClass->getLambdaNumbering();
16115 }
16116
16117 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
16118 }
16119
16120 // FIXME: Sema's lambda-building mechanism expects us to push an expression
16121 // evaluation context even if we're not transforming the function body.
16122 getSema().PushExpressionEvaluationContextForFunction(
16124 E->getCallOperator());
16125
16126 StmtResult Body;
16127 {
16128 Sema::NonSFINAEContext _(getSema());
16131 C.PointOfInstantiation = E->getBody()->getBeginLoc();
16132 getSema().pushCodeSynthesisContext(C);
16133
16134 // Instantiate the body of the lambda expression.
16135 Body = Invalid ? StmtError()
16136 : getDerived().TransformLambdaBody(E, E->getBody());
16137
16138 getSema().popCodeSynthesisContext();
16139 }
16140
16141 // ActOnLambda* will pop the function scope for us.
16142 FuncScopeCleanup.disable();
16143
16144 if (Body.isInvalid()) {
16145 SavedContext.pop();
16146 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
16147 /*IsInstantiation=*/true);
16148 return ExprError();
16149 }
16150
16151 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
16152 /*IsInstantiation=*/true,
16153 /*RetainFunctionScopeInfo=*/true);
16154 SavedContext.pop();
16155
16156 // Recompute the dependency of the lambda so that we can defer the lambda call
16157 // construction until after we have all the necessary template arguments. For
16158 // example, given
16159 //
16160 // template <class> struct S {
16161 // template <class U>
16162 // using Type = decltype([](U){}(42.0));
16163 // };
16164 // void foo() {
16165 // using T = S<int>::Type<float>;
16166 // ^~~~~~
16167 // }
16168 //
16169 // We would end up here from instantiating S<int> when ensuring its
16170 // completeness. That would transform the lambda call expression regardless of
16171 // the absence of the corresponding argument for U.
16172 //
16173 // Going ahead with unsubstituted type U makes things worse: we would soon
16174 // compare the argument type (which is float) against the parameter U
16175 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
16176 // error suggesting unmatched types 'U' and 'float'!
16177 //
16178 // That said, everything will be fine if we defer that semantic checking.
16179 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
16180 // dependent. Since the CallExpr's dependency boils down to the lambda's
16181 // dependency in this case, we can harness that by recomputing the dependency
16182 // from the instantiation arguments.
16183 //
16184 // FIXME: Creating the type of a lambda requires us to have a dependency
16185 // value, which happens before its substitution. We update its dependency
16186 // *after* the substitution in case we can't decide the dependency
16187 // so early, e.g. because we want to see if any of the *substituted*
16188 // parameters are dependent.
16189 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
16190 Class->setLambdaDependencyKind(DependencyKind);
16191
16192 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
16193 Body.get()->getEndLoc(), LSI);
16194}
16195
16196template<typename Derived>
16201
16202template<typename Derived>
16205 // Transform captures.
16207 CEnd = E->capture_end();
16208 C != CEnd; ++C) {
16209 // When we hit the first implicit capture, tell Sema that we've finished
16210 // the list of explicit captures.
16211 if (!C->isImplicit())
16212 continue;
16213
16214 // Capturing 'this' is trivial.
16215 if (C->capturesThis()) {
16216 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16217 /*BuildAndDiagnose*/ true, nullptr,
16218 C->getCaptureKind() == LCK_StarThis);
16219 continue;
16220 }
16221 // Captured expression will be recaptured during captured variables
16222 // rebuilding.
16223 if (C->capturesVLAType())
16224 continue;
16225
16226 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16227 assert(!E->isInitCapture(C) && "implicit init-capture?");
16228
16229 // Transform the captured variable.
16230 VarDecl *CapturedVar = cast_or_null<VarDecl>(
16231 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16232 if (!CapturedVar || CapturedVar->isInvalidDecl())
16233 return StmtError();
16234
16235 // Capture the transformed variable.
16236 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16237 }
16238
16239 return S;
16240}
16241
16242template<typename Derived>
16246 TypeSourceInfo *T =
16247 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16248 if (!T)
16249 return ExprError();
16250
16251 bool ArgumentChanged = false;
16253 Args.reserve(E->getNumArgs());
16254 {
16258 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16259 &ArgumentChanged))
16260 return ExprError();
16261 }
16262
16263 if (!getDerived().AlwaysRebuild() &&
16264 T == E->getTypeSourceInfo() &&
16265 !ArgumentChanged)
16266 return E;
16267
16268 // FIXME: we're faking the locations of the commas
16269 return getDerived().RebuildCXXUnresolvedConstructExpr(
16270 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16271}
16272
16273template<typename Derived>
16277 // Transform the base of the expression.
16278 ExprResult Base((Expr*) nullptr);
16279 Expr *OldBase;
16280 QualType BaseType;
16281 QualType ObjectType;
16282 if (!E->isImplicitAccess()) {
16283 OldBase = E->getBase();
16284 Base = getDerived().TransformExpr(OldBase);
16285 if (Base.isInvalid())
16286 return ExprError();
16287
16288 // Start the member reference and compute the object's type.
16289 ParsedType ObjectTy;
16290 bool MayBePseudoDestructor = false;
16291 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16292 E->getOperatorLoc(),
16293 E->isArrow()? tok::arrow : tok::period,
16294 ObjectTy,
16295 MayBePseudoDestructor);
16296 if (Base.isInvalid())
16297 return ExprError();
16298
16299 ObjectType = ObjectTy.get();
16300 BaseType = ((Expr*) Base.get())->getType();
16301 } else {
16302 OldBase = nullptr;
16303 BaseType = getDerived().TransformType(E->getBaseType());
16304 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16305 }
16306
16307 // Transform the first part of the nested-name-specifier that qualifies
16308 // the member name.
16309 NamedDecl *FirstQualifierInScope
16310 = getDerived().TransformFirstQualifierInScope(
16311 E->getFirstQualifierFoundInScope(),
16312 E->getQualifierLoc().getBeginLoc());
16313
16314 NestedNameSpecifierLoc QualifierLoc;
16315 if (E->getQualifier()) {
16316 QualifierLoc
16317 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16318 ObjectType,
16319 FirstQualifierInScope);
16320 if (!QualifierLoc)
16321 return ExprError();
16322 }
16323
16324 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16325
16326 // TODO: If this is a conversion-function-id, verify that the
16327 // destination type name (if present) resolves the same way after
16328 // instantiation as it did in the local scope.
16329
16330 DeclarationNameInfo NameInfo
16331 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16332 if (!NameInfo.getName())
16333 return ExprError();
16334
16335 if (!E->hasExplicitTemplateArgs()) {
16336 // This is a reference to a member without an explicitly-specified
16337 // template argument list. Optimize for this common case.
16338 if (!getDerived().AlwaysRebuild() &&
16339 Base.get() == OldBase &&
16340 BaseType == E->getBaseType() &&
16341 QualifierLoc == E->getQualifierLoc() &&
16342 NameInfo.getName() == E->getMember() &&
16343 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16344 return E;
16345
16346 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16347 BaseType,
16348 E->isArrow(),
16349 E->getOperatorLoc(),
16350 QualifierLoc,
16351 TemplateKWLoc,
16352 FirstQualifierInScope,
16353 NameInfo,
16354 /*TemplateArgs*/nullptr);
16355 }
16356
16357 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16358 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16359 E->getNumTemplateArgs(),
16360 TransArgs))
16361 return ExprError();
16362
16363 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16364 BaseType,
16365 E->isArrow(),
16366 E->getOperatorLoc(),
16367 QualifierLoc,
16368 TemplateKWLoc,
16369 FirstQualifierInScope,
16370 NameInfo,
16371 &TransArgs);
16372}
16373
16374template <typename Derived>
16376 UnresolvedMemberExpr *Old) {
16377 // Transform the base of the expression.
16378 ExprResult Base((Expr *)nullptr);
16379 QualType BaseType;
16380 if (!Old->isImplicitAccess()) {
16381 Base = getDerived().TransformExpr(Old->getBase());
16382 if (Base.isInvalid())
16383 return ExprError();
16384 Base =
16385 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16386 if (Base.isInvalid())
16387 return ExprError();
16388 BaseType = Base.get()->getType();
16389 } else {
16390 BaseType = getDerived().TransformType(Old->getBaseType());
16391 }
16392
16393 NestedNameSpecifierLoc QualifierLoc;
16394 if (Old->getQualifierLoc()) {
16395 QualifierLoc =
16396 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16397 if (!QualifierLoc)
16398 return ExprError();
16399 }
16400
16401 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16402
16403 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16404
16405 // Transform the declaration set.
16406 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16407 return ExprError();
16408
16409 // Determine the naming class.
16410 if (Old->getNamingClass()) {
16411 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16412 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16413 if (!NamingClass)
16414 return ExprError();
16415
16416 R.setNamingClass(NamingClass);
16417 }
16418
16419 TemplateArgumentListInfo TransArgs;
16420 if (Old->hasExplicitTemplateArgs()) {
16421 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16422 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16423 if (getDerived().TransformTemplateArguments(
16424 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16425 return ExprError();
16426 }
16427
16428 // FIXME: to do this check properly, we will need to preserve the
16429 // first-qualifier-in-scope here, just in case we had a dependent
16430 // base (and therefore couldn't do the check) and a
16431 // nested-name-qualifier (and therefore could do the lookup).
16432 NamedDecl *FirstQualifierInScope = nullptr;
16433
16434 return getDerived().RebuildUnresolvedMemberExpr(
16435 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16436 TemplateKWLoc, FirstQualifierInScope, R,
16437 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16438}
16439
16440template<typename Derived>
16445 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16446 if (SubExpr.isInvalid())
16447 return ExprError();
16448
16449 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16450 return E;
16451
16452 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16453}
16454
16455template<typename Derived>
16458 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16459 if (Pattern.isInvalid())
16460 return ExprError();
16461
16462 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16463 return E;
16464
16465 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16466 E->getNumExpansions());
16467}
16468
16469template <typename Derived>
16471 ArrayRef<TemplateArgument> PackArgs) {
16473 for (const TemplateArgument &Arg : PackArgs) {
16474 if (!Arg.isPackExpansion()) {
16475 Result = *Result + 1;
16476 continue;
16477 }
16478
16479 TemplateArgumentLoc ArgLoc;
16480 InventTemplateArgumentLoc(Arg, ArgLoc);
16481
16482 // Find the pattern of the pack expansion.
16483 SourceLocation Ellipsis;
16484 UnsignedOrNone OrigNumExpansions = std::nullopt;
16485 TemplateArgumentLoc Pattern =
16486 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16487 OrigNumExpansions);
16488
16489 // Substitute under the pack expansion. Do not expand the pack (yet).
16490 TemplateArgumentLoc OutPattern;
16491 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16492 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16493 /*Uneval*/ true))
16494 return 1u;
16495
16496 // See if we can determine the number of arguments from the result.
16497 UnsignedOrNone NumExpansions =
16498 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16499 if (!NumExpansions) {
16500 // No: we must be in an alias template expansion, and we're going to
16501 // need to actually expand the packs.
16502 Result = std::nullopt;
16503 break;
16504 }
16505
16506 Result = *Result + *NumExpansions;
16507 }
16508 return Result;
16509}
16510
16511template<typename Derived>
16514 // If E is not value-dependent, then nothing will change when we transform it.
16515 // Note: This is an instantiation-centric view.
16516 if (!E->isValueDependent())
16517 return E;
16518
16521
16523 TemplateArgument ArgStorage;
16524
16525 // Find the argument list to transform.
16526 if (E->isPartiallySubstituted()) {
16527 PackArgs = E->getPartialArguments();
16528 } else if (E->isValueDependent()) {
16529 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16530 bool ShouldExpand = false;
16531 bool RetainExpansion = false;
16532 UnsignedOrNone NumExpansions = std::nullopt;
16533 if (getDerived().TryExpandParameterPacks(
16534 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16535 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16536 RetainExpansion, NumExpansions))
16537 return ExprError();
16538
16539 // If we need to expand the pack, build a template argument from it and
16540 // expand that.
16541 if (ShouldExpand) {
16542 auto *Pack = E->getPack();
16543 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16544 ArgStorage = getSema().Context.getPackExpansionType(
16545 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16546 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16547 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16548 } else {
16549 auto *VD = cast<ValueDecl>(Pack);
16550 ExprResult DRE = getSema().BuildDeclRefExpr(
16551 VD, VD->getType().getNonLValueExprType(getSema().Context),
16552 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16553 E->getPackLoc());
16554 if (DRE.isInvalid())
16555 return ExprError();
16556 ArgStorage = TemplateArgument(
16557 new (getSema().Context)
16558 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16559 /*IsCanonical=*/false);
16560 }
16561 PackArgs = ArgStorage;
16562 }
16563 }
16564
16565 // If we're not expanding the pack, just transform the decl.
16566 if (!PackArgs.size()) {
16567 auto *Pack = cast_or_null<NamedDecl>(
16568 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16569 if (!Pack)
16570 return ExprError();
16571 return getDerived().RebuildSizeOfPackExpr(
16572 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16573 std::nullopt, {});
16574 }
16575
16576 // Try to compute the result without performing a partial substitution.
16578 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16579
16580 // Common case: we could determine the number of expansions without
16581 // substituting.
16582 if (Result)
16583 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16584 E->getPackLoc(),
16585 E->getRParenLoc(), *Result, {});
16586
16587 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16588 E->getPackLoc());
16589 {
16590 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16592 Derived, const TemplateArgument*> PackLocIterator;
16593 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16594 PackLocIterator(*this, PackArgs.end()),
16595 TransformedPackArgs, /*Uneval*/true))
16596 return ExprError();
16597 }
16598
16599 // Check whether we managed to fully-expand the pack.
16600 // FIXME: Is it possible for us to do so and not hit the early exit path?
16602 bool PartialSubstitution = false;
16603 for (auto &Loc : TransformedPackArgs.arguments()) {
16604 Args.push_back(Loc.getArgument());
16605 if (Loc.getArgument().isPackExpansion())
16606 PartialSubstitution = true;
16607 }
16608
16609 if (PartialSubstitution)
16610 return getDerived().RebuildSizeOfPackExpr(
16611 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16612 std::nullopt, Args);
16613
16614 return getDerived().RebuildSizeOfPackExpr(
16615 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16616 /*Length=*/static_cast<unsigned>(Args.size()),
16617 /*PartialArgs=*/{});
16618}
16619
16620template <typename Derived>
16623 if (!E->isValueDependent())
16624 return E;
16625
16626 // Transform the index
16627 ExprResult IndexExpr;
16628 {
16629 EnterExpressionEvaluationContext ConstantContext(
16631 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16632 if (IndexExpr.isInvalid())
16633 return ExprError();
16634 }
16635
16636 SmallVector<Expr *, 5> ExpandedExprs;
16637 bool FullySubstituted = true;
16638 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16639 Expr *Pattern = E->getPackIdExpression();
16641 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16642 Unexpanded);
16643 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16644
16645 // Determine whether the set of unexpanded parameter packs can and should
16646 // be expanded.
16647 bool ShouldExpand = true;
16648 bool RetainExpansion = false;
16649 UnsignedOrNone OrigNumExpansions = std::nullopt,
16650 NumExpansions = std::nullopt;
16651 if (getDerived().TryExpandParameterPacks(
16652 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16653 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16654 RetainExpansion, NumExpansions))
16655 return true;
16656 if (!ShouldExpand) {
16657 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16658 ExprResult Pack = getDerived().TransformExpr(Pattern);
16659 if (Pack.isInvalid())
16660 return ExprError();
16661 return getDerived().RebuildPackIndexingExpr(
16662 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16663 {}, /*FullySubstituted=*/false);
16664 }
16665 for (unsigned I = 0; I != *NumExpansions; ++I) {
16666 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16667 ExprResult Out = getDerived().TransformExpr(Pattern);
16668 if (Out.isInvalid())
16669 return true;
16670 if (Out.get()->containsUnexpandedParameterPack()) {
16671 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16672 OrigNumExpansions);
16673 if (Out.isInvalid())
16674 return true;
16675 FullySubstituted = false;
16676 }
16677 ExpandedExprs.push_back(Out.get());
16678 }
16679 // If we're supposed to retain a pack expansion, do so by temporarily
16680 // forgetting the partially-substituted parameter pack.
16681 if (RetainExpansion) {
16682 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16683
16684 ExprResult Out = getDerived().TransformExpr(Pattern);
16685 if (Out.isInvalid())
16686 return true;
16687
16688 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16689 OrigNumExpansions);
16690 if (Out.isInvalid())
16691 return true;
16692 FullySubstituted = false;
16693 ExpandedExprs.push_back(Out.get());
16694 }
16695 } else if (!E->expandsToEmptyPack()) {
16696 if (getDerived().TransformExprs(E->getExpressions().data(),
16697 E->getExpressions().size(), false,
16698 ExpandedExprs))
16699 return ExprError();
16700 }
16701
16702 return getDerived().RebuildPackIndexingExpr(
16703 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16704 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16705}
16706
16707template <typename Derived>
16710 if (!getSema().ArgPackSubstIndex)
16711 // We aren't expanding the parameter pack, so just return ourselves.
16712 return E;
16713
16714 TemplateArgument Pack = E->getArgumentPack();
16716 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16717 E->getAssociatedDecl(), E->getParameterPack()->getPosition(),
16718 E->getParameterPack()->getType(), E->getParameterPackLocation(), Arg,
16719 SemaRef.getPackIndex(Pack), E->getFinal());
16720}
16721
16722template <typename Derived>
16725 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16726
16727 // Insert a constant-evaluated context for the transform.
16728 // Otherwise, when a normalized constraint places the replacement inside
16729 // an unevaluated operand (e.g. decltype), entities it refers to are not
16730 // odr-used, and the constant evaluation performed by CheckTemplateArgument
16731 // below can spuriously fail for otherwise valid replacements,
16732 // e.g. when a call materializes a function parameter of class type whose
16733 // special members were never instantiated.
16734 EnterExpressionEvaluationContext ConstantEvaluated(
16738
16739 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16740 if (Replacement.isInvalid())
16741 return true;
16742
16743 Decl *AssociatedDecl =
16744 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16745 if (!AssociatedDecl)
16746 return true;
16747
16748 QualType ParamType = TransformType(E->getParameterType());
16749 if (ParamType.isNull())
16750 return true;
16751
16752 if (Replacement.get() == OrigReplacement &&
16753 AssociatedDecl == E->getAssociatedDecl() &&
16754 ParamType == E->getParameterType())
16755 return E;
16756
16757 if (Replacement.get() != OrigReplacement ||
16758 ParamType != E->getParameterType()) {
16759 auto *Param = cast<NonTypeTemplateParmDecl>(std::get<0>(
16760 getReplacedTemplateParameter(AssociatedDecl, E->getIndex())));
16761 // When transforming the replacement expression previously, all Sema
16762 // specific annotations, such as implicit casts, are discarded. Calling the
16763 // corresponding sema action is necessary to recover those. Otherwise,
16764 // equivalency of the result would be lost.
16765 TemplateArgument SugaredConverted, CanonicalConverted;
16766 Replacement = SemaRef.CheckTemplateArgument(
16767 Param, ParamType, Replacement.get(), SugaredConverted,
16768 CanonicalConverted,
16769 /*StrictCheck=*/false, Sema::CTAK_Specified);
16770 if (Replacement.isInvalid())
16771 return true;
16772 } else {
16773 // Otherwise, the same expression would have been produced.
16774 Replacement = E->getReplacement();
16775 }
16776
16777 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16778 AssociatedDecl, E->getIndex(), ParamType, E->getNameLoc(),
16779 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
16780 E->getPackIndex(), E->getFinal());
16781}
16782
16783template<typename Derived>
16786 // Default behavior is to do nothing with this transformation.
16787 return E;
16788}
16789
16790template<typename Derived>
16794 return getDerived().TransformExpr(E->getSubExpr());
16795}
16796
16797template<typename Derived>
16800 UnresolvedLookupExpr *Callee = nullptr;
16801 if (Expr *OldCallee = E->getCallee()) {
16802 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16803 if (CalleeResult.isInvalid())
16804 return ExprError();
16805 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16806 }
16807
16808 Expr *Pattern = E->getPattern();
16809
16811 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16812 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16813
16814 // Determine whether the set of unexpanded parameter packs can and should
16815 // be expanded.
16816 bool Expand = true;
16817 bool RetainExpansion = false;
16818 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16819 NumExpansions = OrigNumExpansions;
16820 if (getDerived().TryExpandParameterPacks(
16821 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16822 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16823 NumExpansions))
16824 return true;
16825
16826 if (!Expand) {
16827 // Do not expand any packs here, just transform and rebuild a fold
16828 // expression.
16829 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16830
16831 ExprResult LHS =
16832 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16833 if (LHS.isInvalid())
16834 return true;
16835
16836 ExprResult RHS =
16837 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16838 if (RHS.isInvalid())
16839 return true;
16840
16841 if (!getDerived().AlwaysRebuild() &&
16842 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16843 return E;
16844
16845 return getDerived().RebuildCXXFoldExpr(
16846 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16847 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16848 }
16849
16850 // Formally a fold expression expands to nested parenthesized expressions.
16851 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16852 // them.
16853 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16854 SemaRef.Diag(E->getEllipsisLoc(),
16855 clang::diag::err_fold_expression_limit_exceeded)
16856 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16857 << E->getSourceRange();
16858 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16859 return ExprError();
16860 }
16861
16862 // The transform has determined that we should perform an elementwise
16863 // expansion of the pattern. Do so.
16864 ExprResult Result = getDerived().TransformExpr(E->getInit());
16865 if (Result.isInvalid())
16866 return true;
16867 bool LeftFold = E->isLeftFold();
16868
16869 // If we're retaining an expansion for a right fold, it is the innermost
16870 // component and takes the init (if any).
16871 if (!LeftFold && RetainExpansion) {
16872 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16873
16874 ExprResult Out = getDerived().TransformExpr(Pattern);
16875 if (Out.isInvalid())
16876 return true;
16877
16878 Result = getDerived().RebuildCXXFoldExpr(
16879 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16880 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16881 if (Result.isInvalid())
16882 return true;
16883 }
16884
16885 bool WarnedOnComparison = false;
16886 for (unsigned I = 0; I != *NumExpansions; ++I) {
16887 Sema::ArgPackSubstIndexRAII SubstIndex(
16888 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16889 ExprResult Out = getDerived().TransformExpr(Pattern);
16890 if (Out.isInvalid())
16891 return true;
16892
16893 if (Out.get()->containsUnexpandedParameterPack()) {
16894 // We still have a pack; retain a pack expansion for this slice.
16895 Result = getDerived().RebuildCXXFoldExpr(
16896 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16897 E->getOperator(), E->getEllipsisLoc(),
16898 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16899 OrigNumExpansions);
16900 } else if (Result.isUsable()) {
16901 // We've got down to a single element; build a binary operator.
16902 Expr *LHS = LeftFold ? Result.get() : Out.get();
16903 Expr *RHS = LeftFold ? Out.get() : Result.get();
16904 if (Callee) {
16905 UnresolvedSet<16> Functions;
16906 Functions.append(Callee->decls_begin(), Callee->decls_end());
16907 Result = getDerived().RebuildCXXOperatorCallExpr(
16908 BinaryOperator::getOverloadedOperator(E->getOperator()),
16909 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16910 Functions, LHS, RHS);
16911 } else {
16912 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16913 E->getOperator(), LHS, RHS,
16914 /*ForFoldExpresion=*/true);
16915 if (!WarnedOnComparison && Result.isUsable()) {
16916 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16917 BO && BO->isComparisonOp()) {
16918 WarnedOnComparison = true;
16919 SemaRef.Diag(BO->getBeginLoc(),
16920 diag::warn_comparison_in_fold_expression)
16921 << BO->getOpcodeStr();
16922 }
16923 }
16924 }
16925 } else
16926 Result = Out;
16927
16928 if (Result.isInvalid())
16929 return true;
16930 }
16931
16932 // If we're retaining an expansion for a left fold, it is the outermost
16933 // component and takes the complete expansion so far as its init (if any).
16934 if (LeftFold && RetainExpansion) {
16935 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16936
16937 ExprResult Out = getDerived().TransformExpr(Pattern);
16938 if (Out.isInvalid())
16939 return true;
16940
16941 Result = getDerived().RebuildCXXFoldExpr(
16942 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16943 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16944 if (Result.isInvalid())
16945 return true;
16946 }
16947
16948 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16949 PE->setIsProducedByFoldExpansion();
16950
16951 // If we had no init and an empty pack, and we're not retaining an expansion,
16952 // then produce a fallback value or error.
16953 if (Result.isUnset())
16954 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16955 E->getOperator());
16956 return Result;
16957}
16958
16959template <typename Derived>
16962 SmallVector<Expr *, 4> TransformedInits;
16963 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16964
16965 QualType T = getDerived().TransformType(E->getType());
16966
16967 bool ArgChanged = false;
16968
16969 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16970 TransformedInits, &ArgChanged))
16971 return ExprError();
16972
16973 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16974 return E;
16975
16976 return getDerived().RebuildCXXParenListInitExpr(
16977 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16978 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16979}
16980
16981template<typename Derived>
16985 return getDerived().TransformExpr(E->getSubExpr());
16986}
16987
16988template<typename Derived>
16991 return SemaRef.MaybeBindToTemporary(E);
16992}
16993
16994template<typename Derived>
16997 return E;
16998}
16999
17000template<typename Derived>
17003 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
17004 if (SubExpr.isInvalid())
17005 return ExprError();
17006
17007 if (!getDerived().AlwaysRebuild() &&
17008 SubExpr.get() == E->getSubExpr())
17009 return E;
17010
17011 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
17012}
17013
17014template<typename Derived>
17017 // Transform each of the elements.
17018 SmallVector<Expr *, 8> Elements;
17019 bool ArgChanged = false;
17020 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
17021 /*IsCall=*/false, Elements, &ArgChanged))
17022 return ExprError();
17023
17024 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17025 return SemaRef.MaybeBindToTemporary(E);
17026
17027 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
17028 Elements.data(),
17029 Elements.size());
17030}
17031
17032template<typename Derived>
17036 // Transform each of the elements.
17038 bool ArgChanged = false;
17039 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
17040 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
17041
17042 if (OrigElement.isPackExpansion()) {
17043 // This key/value element is a pack expansion.
17045 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
17046 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
17047 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
17048
17049 // Determine whether the set of unexpanded parameter packs can
17050 // and should be expanded.
17051 bool Expand = true;
17052 bool RetainExpansion = false;
17053 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
17054 UnsignedOrNone NumExpansions = OrigNumExpansions;
17055 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
17056 OrigElement.Value->getEndLoc());
17057 if (getDerived().TryExpandParameterPacks(
17058 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
17059 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
17060 NumExpansions))
17061 return ExprError();
17062
17063 if (!Expand) {
17064 // The transform has determined that we should perform a simple
17065 // transformation on the pack expansion, producing another pack
17066 // expansion.
17067 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
17068 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17069 if (Key.isInvalid())
17070 return ExprError();
17071
17072 if (Key.get() != OrigElement.Key)
17073 ArgChanged = true;
17074
17075 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17076 if (Value.isInvalid())
17077 return ExprError();
17078
17079 if (Value.get() != OrigElement.Value)
17080 ArgChanged = true;
17081
17082 ObjCDictionaryElement Expansion = {
17083 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
17084 };
17085 Elements.push_back(Expansion);
17086 continue;
17087 }
17088
17089 // Record right away that the argument was changed. This needs
17090 // to happen even if the array expands to nothing.
17091 ArgChanged = true;
17092
17093 // The transform has determined that we should perform an elementwise
17094 // expansion of the pattern. Do so.
17095 for (unsigned I = 0; I != *NumExpansions; ++I) {
17096 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
17097 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17098 if (Key.isInvalid())
17099 return ExprError();
17100
17101 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17102 if (Value.isInvalid())
17103 return ExprError();
17104
17105 ObjCDictionaryElement Element = {
17106 Key.get(), Value.get(), SourceLocation(), NumExpansions
17107 };
17108
17109 // If any unexpanded parameter packs remain, we still have a
17110 // pack expansion.
17111 // FIXME: Can this really happen?
17112 if (Key.get()->containsUnexpandedParameterPack() ||
17113 Value.get()->containsUnexpandedParameterPack())
17114 Element.EllipsisLoc = OrigElement.EllipsisLoc;
17115
17116 Elements.push_back(Element);
17117 }
17118
17119 // FIXME: Retain a pack expansion if RetainExpansion is true.
17120
17121 // We've finished with this pack expansion.
17122 continue;
17123 }
17124
17125 // Transform and check key.
17126 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17127 if (Key.isInvalid())
17128 return ExprError();
17129
17130 if (Key.get() != OrigElement.Key)
17131 ArgChanged = true;
17132
17133 // Transform and check value.
17135 = getDerived().TransformExpr(OrigElement.Value);
17136 if (Value.isInvalid())
17137 return ExprError();
17138
17139 if (Value.get() != OrigElement.Value)
17140 ArgChanged = true;
17141
17142 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
17143 std::nullopt};
17144 Elements.push_back(Element);
17145 }
17146
17147 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17148 return SemaRef.MaybeBindToTemporary(E);
17149
17150 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
17151 Elements);
17152}
17153
17154template<typename Derived>
17157 TypeSourceInfo *EncodedTypeInfo
17158 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
17159 if (!EncodedTypeInfo)
17160 return ExprError();
17161
17162 if (!getDerived().AlwaysRebuild() &&
17163 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
17164 return E;
17165
17166 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
17167 EncodedTypeInfo,
17168 E->getRParenLoc());
17169}
17170
17171template<typename Derived>
17174 // This is a kind of implicit conversion, and it needs to get dropped
17175 // and recomputed for the same general reasons that ImplicitCastExprs
17176 // do, as well a more specific one: this expression is only valid when
17177 // it appears *immediately* as an argument expression.
17178 return getDerived().TransformExpr(E->getSubExpr());
17179}
17180
17181template<typename Derived>
17184 TypeSourceInfo *TSInfo
17185 = getDerived().TransformType(E->getTypeInfoAsWritten());
17186 if (!TSInfo)
17187 return ExprError();
17188
17189 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
17190 if (Result.isInvalid())
17191 return ExprError();
17192
17193 if (!getDerived().AlwaysRebuild() &&
17194 TSInfo == E->getTypeInfoAsWritten() &&
17195 Result.get() == E->getSubExpr())
17196 return E;
17197
17198 return SemaRef.ObjC().BuildObjCBridgedCast(
17199 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
17200 Result.get());
17201}
17202
17203template <typename Derived>
17206 return E;
17207}
17208
17209template<typename Derived>
17212 // Transform arguments.
17213 bool ArgChanged = false;
17215 Args.reserve(E->getNumArgs());
17216 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
17217 &ArgChanged))
17218 return ExprError();
17219
17220 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
17221 // Class message: transform the receiver type.
17222 TypeSourceInfo *ReceiverTypeInfo
17223 = getDerived().TransformType(E->getClassReceiverTypeInfo());
17224 if (!ReceiverTypeInfo)
17225 return ExprError();
17226
17227 // If nothing changed, just retain the existing message send.
17228 if (!getDerived().AlwaysRebuild() &&
17229 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
17230 return SemaRef.MaybeBindToTemporary(E);
17231
17232 // Build a new class message send.
17234 E->getSelectorLocs(SelLocs);
17235 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
17236 E->getSelector(),
17237 SelLocs,
17238 E->getMethodDecl(),
17239 E->getLeftLoc(),
17240 Args,
17241 E->getRightLoc());
17242 }
17243 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17244 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17245 if (!E->getMethodDecl())
17246 return ExprError();
17247
17248 // Build a new class message send to 'super'.
17250 E->getSelectorLocs(SelLocs);
17251 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17252 E->getSelector(),
17253 SelLocs,
17254 E->getReceiverType(),
17255 E->getMethodDecl(),
17256 E->getLeftLoc(),
17257 Args,
17258 E->getRightLoc());
17259 }
17260
17261 // Instance message: transform the receiver
17262 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17263 "Only class and instance messages may be instantiated");
17264 ExprResult Receiver
17265 = getDerived().TransformExpr(E->getInstanceReceiver());
17266 if (Receiver.isInvalid())
17267 return ExprError();
17268
17269 // If nothing changed, just retain the existing message send.
17270 if (!getDerived().AlwaysRebuild() &&
17271 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17272 return SemaRef.MaybeBindToTemporary(E);
17273
17274 // Build a new instance message send.
17276 E->getSelectorLocs(SelLocs);
17277 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17278 E->getSelector(),
17279 SelLocs,
17280 E->getMethodDecl(),
17281 E->getLeftLoc(),
17282 Args,
17283 E->getRightLoc());
17284}
17285
17286template<typename Derived>
17289 return E;
17290}
17291
17292template<typename Derived>
17295 return E;
17296}
17297
17298template<typename Derived>
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 ivar; 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 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17314 E->getLocation(),
17315 E->isArrow(), E->isFreeIvar());
17316}
17317
17318template<typename Derived>
17321 // 'super' and types never change. Property never changes. Just
17322 // retain the existing expression.
17323 if (!E->isObjectReceiver())
17324 return E;
17325
17326 // Transform the base expression.
17327 ExprResult Base = getDerived().TransformExpr(E->getBase());
17328 if (Base.isInvalid())
17329 return ExprError();
17330
17331 // We don't need to transform the property; it will never change.
17332
17333 // If nothing changed, just retain the existing expression.
17334 if (!getDerived().AlwaysRebuild() &&
17335 Base.get() == E->getBase())
17336 return E;
17337
17338 if (E->isExplicitProperty())
17339 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17340 E->getExplicitProperty(),
17341 E->getLocation());
17342
17343 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17344 SemaRef.Context.PseudoObjectTy,
17345 E->getImplicitPropertyGetter(),
17346 E->getImplicitPropertySetter(),
17347 E->getLocation());
17348}
17349
17350template<typename Derived>
17353 // Transform the base expression.
17354 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17355 if (Base.isInvalid())
17356 return ExprError();
17357
17358 // Transform the key expression.
17359 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17360 if (Key.isInvalid())
17361 return ExprError();
17362
17363 // If nothing changed, just retain the existing expression.
17364 if (!getDerived().AlwaysRebuild() &&
17365 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17366 return E;
17367
17368 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17369 Base.get(), Key.get(),
17370 E->getAtIndexMethodDecl(),
17371 E->setAtIndexMethodDecl());
17372}
17373
17374template<typename Derived>
17377 // Transform the base expression.
17378 ExprResult Base = getDerived().TransformExpr(E->getBase());
17379 if (Base.isInvalid())
17380 return ExprError();
17381
17382 // If nothing changed, just retain the existing expression.
17383 if (!getDerived().AlwaysRebuild() &&
17384 Base.get() == E->getBase())
17385 return E;
17386
17387 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17388 E->getOpLoc(),
17389 E->isArrow());
17390}
17391
17392template<typename Derived>
17395 bool ArgumentChanged = false;
17396 SmallVector<Expr*, 8> SubExprs;
17397 SubExprs.reserve(E->getNumSubExprs());
17398 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17399 SubExprs, &ArgumentChanged))
17400 return ExprError();
17401
17402 if (!getDerived().AlwaysRebuild() &&
17403 !ArgumentChanged)
17404 return E;
17405
17406 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17407 SubExprs,
17408 E->getRParenLoc());
17409}
17410
17411template<typename Derived>
17414 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17415 if (SrcExpr.isInvalid())
17416 return ExprError();
17417
17418 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17419 if (!Type)
17420 return ExprError();
17421
17422 if (!getDerived().AlwaysRebuild() &&
17423 Type == E->getTypeSourceInfo() &&
17424 SrcExpr.get() == E->getSrcExpr())
17425 return E;
17426
17427 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17428 SrcExpr.get(), Type,
17429 E->getRParenLoc());
17430}
17431
17432template<typename Derived>
17435 BlockDecl *oldBlock = E->getBlockDecl();
17436
17437 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17438 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17439
17440 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17441 blockScope->TheDecl->setBlockMissingReturnType(
17442 oldBlock->blockMissingReturnType());
17443
17445 SmallVector<QualType, 4> paramTypes;
17446
17447 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17448
17449 // Parameter substitution.
17450 Sema::ExtParameterInfoBuilder extParamInfos;
17451 if (getDerived().TransformFunctionTypeParams(
17452 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17453 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17454 extParamInfos)) {
17455 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17456 return ExprError();
17457 }
17458
17459 QualType exprResultType =
17460 getDerived().TransformType(exprFunctionType->getReturnType());
17461
17462 auto epi = exprFunctionType->getExtProtoInfo();
17463 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17464
17466 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17467 blockScope->FunctionType = functionType;
17468
17469 // Set the parameters on the block decl.
17470 if (!params.empty())
17471 blockScope->TheDecl->setParams(params);
17472
17473 if (!oldBlock->blockMissingReturnType()) {
17474 blockScope->HasImplicitReturnType = false;
17475 blockScope->ReturnType = exprResultType;
17476 }
17477
17478 // Transform the body
17479 StmtResult body = getDerived().TransformStmt(E->getBody());
17480 if (body.isInvalid()) {
17481 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17482 return ExprError();
17483 }
17484
17485#ifndef NDEBUG
17486 // In builds with assertions, make sure that we captured everything we
17487 // captured before.
17488 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17489 for (const auto &I : oldBlock->captures()) {
17490 VarDecl *oldCapture = I.getVariable();
17491
17492 // Ignore parameter packs.
17493 if (oldCapture->isParameterPack())
17494 continue;
17495
17496 VarDecl *newCapture =
17497 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17498 oldCapture));
17499 assert(blockScope->CaptureMap.count(newCapture));
17500 }
17501
17502 // The this pointer may not be captured by the instantiated block, even when
17503 // it's captured by the original block, if the expression causing the
17504 // capture is in the discarded branch of a constexpr if statement.
17505 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17506 "this pointer isn't captured in the old block");
17507 }
17508#endif
17509
17510 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17511 /*Scope=*/nullptr);
17512}
17513
17514template<typename Derived>
17517 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17518 if (SrcExpr.isInvalid())
17519 return ExprError();
17520
17521 QualType Type = getDerived().TransformType(E->getType());
17522
17523 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17524 E->getRParenLoc());
17525}
17526
17527template<typename Derived>
17530 bool ArgumentChanged = false;
17531 SmallVector<Expr*, 8> SubExprs;
17532 SubExprs.reserve(E->getNumSubExprs());
17533 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17534 SubExprs, &ArgumentChanged))
17535 return ExprError();
17536
17537 if (!getDerived().AlwaysRebuild() &&
17538 !ArgumentChanged)
17539 return E;
17540
17541 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17542 E->getOp(), E->getRParenLoc());
17543}
17544
17545//===----------------------------------------------------------------------===//
17546// Type reconstruction
17547//===----------------------------------------------------------------------===//
17548
17549template<typename Derived>
17552 return SemaRef.BuildPointerType(PointeeType, Star,
17554}
17555
17556template<typename Derived>
17559 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17561}
17562
17563template<typename Derived>
17566 bool WrittenAsLValue,
17567 SourceLocation Sigil) {
17568 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17569 Sigil, getDerived().getBaseEntity());
17570}
17571
17572template <typename Derived>
17574 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17575 SourceLocation Sigil) {
17576 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17578}
17579
17580template<typename Derived>
17582 const ObjCTypeParamDecl *Decl,
17583 SourceLocation ProtocolLAngleLoc,
17585 ArrayRef<SourceLocation> ProtocolLocs,
17586 SourceLocation ProtocolRAngleLoc) {
17587 return SemaRef.ObjC().BuildObjCTypeParamType(
17588 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17589 /*FailOnError=*/true);
17590}
17591
17592template<typename Derived>
17594 QualType BaseType,
17595 SourceLocation Loc,
17596 SourceLocation TypeArgsLAngleLoc,
17598 SourceLocation TypeArgsRAngleLoc,
17599 SourceLocation ProtocolLAngleLoc,
17601 ArrayRef<SourceLocation> ProtocolLocs,
17602 SourceLocation ProtocolRAngleLoc) {
17603 return SemaRef.ObjC().BuildObjCObjectType(
17604 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17605 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17606 /*FailOnError=*/true,
17607 /*Rebuilding=*/true);
17608}
17609
17610template<typename Derived>
17612 QualType PointeeType,
17614 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17615}
17616
17617template <typename Derived>
17619 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17620 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17621 if (SizeExpr || !Size)
17622 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17623 IndexTypeQuals, BracketsRange,
17625
17626 QualType Types[] = {
17627 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17628 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17629 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17630 };
17631 QualType SizeType;
17632 for (const auto &T : Types)
17633 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17634 SizeType = T;
17635 break;
17636 }
17637
17638 // Note that we can return a VariableArrayType here in the case where
17639 // the element type was a dependent VariableArrayType.
17640 IntegerLiteral *ArraySize
17641 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17642 /*FIXME*/BracketsRange.getBegin());
17643 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17644 IndexTypeQuals, BracketsRange,
17646}
17647
17648template <typename Derived>
17650 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17651 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17652 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17653 IndexTypeQuals, BracketsRange);
17654}
17655
17656template <typename Derived>
17658 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17659 SourceRange BracketsRange) {
17660 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17661 IndexTypeQuals, BracketsRange);
17662}
17663
17664template <typename Derived>
17666 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17667 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17668 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17669 SizeExpr,
17670 IndexTypeQuals, BracketsRange);
17671}
17672
17673template <typename Derived>
17675 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17676 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17677 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17678 SizeExpr,
17679 IndexTypeQuals, BracketsRange);
17680}
17681
17682template <typename Derived>
17684 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17685 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17686 AttributeLoc);
17687}
17688
17689template <typename Derived>
17691 unsigned NumElements,
17692 VectorKind VecKind) {
17693 // FIXME: semantic checking!
17694 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17695}
17696
17697template <typename Derived>
17699 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17700 VectorKind VecKind) {
17701 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17702}
17703
17704template<typename Derived>
17706 unsigned NumElements,
17707 SourceLocation AttributeLoc) {
17708 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17709 NumElements, true);
17710 IntegerLiteral *VectorSize
17711 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17712 AttributeLoc);
17713 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17714}
17715
17716template<typename Derived>
17719 Expr *SizeExpr,
17720 SourceLocation AttributeLoc) {
17721 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17722}
17723
17724template <typename Derived>
17726 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17727 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17728 NumColumns);
17729}
17730
17731template <typename Derived>
17733 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17734 SourceLocation AttributeLoc) {
17735 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17736 AttributeLoc);
17737}
17738
17739template <typename Derived>
17741 QualType T, MutableArrayRef<QualType> ParamTypes,
17743 return SemaRef.BuildFunctionType(T, ParamTypes,
17746 EPI);
17747}
17748
17749template<typename Derived>
17751 return SemaRef.Context.getFunctionNoProtoType(T);
17752}
17753
17754template <typename Derived>
17757 SourceLocation NameLoc, Decl *D) {
17758 assert(D && "no decl found");
17759 if (D->isInvalidDecl()) return QualType();
17760
17761 // FIXME: Doesn't account for ObjCInterfaceDecl!
17762 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17763 // A valid resolved using typename pack expansion decl can have multiple
17764 // UsingDecls, but they must each have exactly one type, and it must be
17765 // the same type in every case. But we must have at least one expansion!
17766 if (UPD->expansions().empty()) {
17767 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17768 << UPD->isCXXClassMember() << UPD;
17769 return QualType();
17770 }
17771
17772 // We might still have some unresolved types. Try to pick a resolved type
17773 // if we can. The final instantiation will check that the remaining
17774 // unresolved types instantiate to the type we pick.
17775 QualType FallbackT;
17776 QualType T;
17777 for (auto *E : UPD->expansions()) {
17778 QualType ThisT =
17779 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17780 if (ThisT.isNull())
17781 continue;
17782 if (ThisT->getAs<UnresolvedUsingType>())
17783 FallbackT = ThisT;
17784 else if (T.isNull())
17785 T = ThisT;
17786 else
17787 assert(getSema().Context.hasSameType(ThisT, T) &&
17788 "mismatched resolved types in using pack expansion");
17789 }
17790 return T.isNull() ? FallbackT : T;
17791 }
17792 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17793 assert(Using->hasTypename() &&
17794 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17795
17796 // A valid resolved using typename decl points to exactly one type decl.
17797 assert(++Using->shadow_begin() == Using->shadow_end());
17798
17799 UsingShadowDecl *Shadow = *Using->shadow_begin();
17800 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17801 return QualType();
17802 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17803 }
17805 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17806 return SemaRef.Context.getUnresolvedUsingType(
17808}
17809
17810template <typename Derived>
17812 TypeOfKind Kind) {
17813 return SemaRef.BuildTypeofExprType(E, Kind);
17814}
17815
17816template<typename Derived>
17818 TypeOfKind Kind) {
17819 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17820}
17821
17822template <typename Derived>
17824 return SemaRef.BuildDecltypeType(E);
17825}
17826
17827template <typename Derived>
17829 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17830 SourceLocation EllipsisLoc, bool FullySubstituted,
17831 ArrayRef<QualType> Expansions) {
17832 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17833 FullySubstituted, Expansions);
17834}
17835
17836template<typename Derived>
17838 UnaryTransformType::UTTKind UKind,
17839 SourceLocation Loc) {
17840 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17841}
17842
17843template <typename Derived>
17846 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17847 return SemaRef.CheckTemplateIdType(
17848 Keyword, Template, TemplateNameLoc, TemplateArgs,
17849 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17850}
17851
17852template<typename Derived>
17854 SourceLocation KWLoc) {
17855 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17856}
17857
17858template<typename Derived>
17860 SourceLocation KWLoc,
17861 bool isReadPipe) {
17862 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17863 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17864}
17865
17866template <typename Derived>
17868 unsigned NumBits,
17869 SourceLocation Loc) {
17870 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17871 NumBits, true);
17872 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17873 SemaRef.Context.IntTy, Loc);
17874 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17875}
17876
17877template <typename Derived>
17879 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17880 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17881}
17882
17883template <typename Derived>
17885 bool TemplateKW,
17886 TemplateName Name) {
17887 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17888 Name);
17889}
17890
17891template <typename Derived>
17893 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17894 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17896 TemplateName.setIdentifier(&Name, NameLoc);
17898 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17899 TemplateName, ParsedType::make(ObjectType),
17900 /*EnteringContext=*/false, Template,
17901 AllowInjectedClassName);
17902 return Template.get();
17903}
17904
17905template<typename Derived>
17908 SourceLocation TemplateKWLoc,
17909 OverloadedOperatorKind Operator,
17910 SourceLocation NameLoc,
17911 QualType ObjectType,
17912 bool AllowInjectedClassName) {
17913 UnqualifiedId Name;
17914 // FIXME: Bogus location information.
17915 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17916 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17918 getSema().ActOnTemplateName(
17919 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17920 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17921 return Template.get();
17922}
17923
17924template <typename Derived>
17927 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17928 Expr *Second) {
17929 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17930
17931 if (First->getObjectKind() == OK_ObjCProperty) {
17934 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17935 Opc, First, Second);
17936 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17937 if (Result.isInvalid())
17938 return ExprError();
17939 First = Result.get();
17940 }
17941
17942 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17943 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17944 if (Result.isInvalid())
17945 return ExprError();
17946 Second = Result.get();
17947 }
17948
17949 // Determine whether this should be a builtin operation.
17950 if (Op == OO_Subscript) {
17951 if (!First->getType()->isOverloadableType() &&
17952 !Second->getType()->isOverloadableType())
17953 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17954 OpLoc);
17955 } else if (Op == OO_Arrow) {
17956 // It is possible that the type refers to a RecoveryExpr created earlier
17957 // in the tree transformation.
17958 if (First->getType()->isDependentType())
17959 return ExprError();
17960 // -> is never a builtin operation.
17961 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17962 } else if (Second == nullptr || isPostIncDec) {
17963 if (!First->getType()->isOverloadableType() ||
17964 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17965 // The argument is not of overloadable type, or this is an expression
17966 // of the form &Class::member, so try to create a built-in unary
17967 // operation.
17969 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17970
17971 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17972 }
17973 } else {
17974 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17975 !First->getType()->isOverloadableType() &&
17976 !Second->getType()->isOverloadableType()) {
17977 // Neither of the arguments is type-dependent or has an overloadable
17978 // type, so try to create a built-in binary operation.
17981 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17982 if (Result.isInvalid())
17983 return ExprError();
17984
17985 return Result;
17986 }
17987 }
17988
17989 // Create the overloaded operator invocation for unary operators.
17990 if (!Second || isPostIncDec) {
17992 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17993 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17994 RequiresADL);
17995 }
17996
17997 // Create the overloaded operator invocation for binary operators.
17999 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
18000 First, Second, RequiresADL);
18001 if (Result.isInvalid())
18002 return ExprError();
18003
18004 return Result;
18005}
18006
18007template<typename Derived>
18010 SourceLocation OperatorLoc,
18011 bool isArrow,
18012 CXXScopeSpec &SS,
18013 TypeSourceInfo *ScopeType,
18014 SourceLocation CCLoc,
18015 SourceLocation TildeLoc,
18016 PseudoDestructorTypeStorage Destroyed) {
18017 QualType CanonicalBaseType = Base->getType().getCanonicalType();
18018 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
18019 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
18020 (isArrow && isa<PointerType>(CanonicalBaseType) &&
18021 !cast<PointerType>(CanonicalBaseType)
18022 ->getPointeeType()
18023 ->getAsCanonical<RecordType>())) {
18024 // This pseudo-destructor expression is still a pseudo-destructor.
18025 return SemaRef.BuildPseudoDestructorExpr(
18026 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
18027 CCLoc, TildeLoc, Destroyed);
18028 }
18029
18030 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
18031 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
18032 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
18033 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
18034 NameInfo.setNamedTypeInfo(DestroyedType);
18035
18036 // The scope type is now known to be a valid nested name specifier
18037 // component. Tack it on to the nested name specifier.
18038 if (ScopeType) {
18039 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
18040 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
18041 diag::err_expected_class_or_namespace)
18042 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
18043 return ExprError();
18044 }
18045 SS.clear();
18046 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
18047 }
18048
18049 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
18050 return getSema().BuildMemberReferenceExpr(
18051 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
18052 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
18053 /*TemplateArgs*/ nullptr,
18054 /*S*/ nullptr);
18055}
18056
18057template<typename Derived>
18060 SourceLocation Loc = S->getBeginLoc();
18061 CapturedDecl *CD = S->getCapturedDecl();
18062 unsigned NumParams = CD->getNumParams();
18063 unsigned ContextParamPos = CD->getContextParamPosition();
18065 for (unsigned I = 0; I < NumParams; ++I) {
18066 if (I != ContextParamPos) {
18067 Params.push_back(
18068 std::make_pair(
18069 CD->getParam(I)->getName(),
18070 getDerived().TransformType(CD->getParam(I)->getType())));
18071 } else {
18072 Params.push_back(std::make_pair(StringRef(), QualType()));
18073 }
18074 }
18075 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
18076 S->getCapturedRegionKind(), Params);
18077 StmtResult Body;
18078 {
18079 Sema::CompoundScopeRAII CompoundScope(getSema());
18080 Body = getDerived().TransformStmt(S->getCapturedStmt());
18081 }
18082
18083 if (Body.isInvalid()) {
18084 getSema().ActOnCapturedRegionError();
18085 return StmtError();
18086 }
18087
18088 return getSema().ActOnCapturedRegionEnd(Body.get());
18089}
18090
18091template <typename Derived>
18094 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
18095 // function definition or instantiation of a function template specialization
18096 // and will therefore never appear in a dependent context.
18097 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
18098 "context");
18099}
18100
18101template <typename Derived>
18103 // We can transform the base expression and allow argument resolution to fill
18104 // in the rest.
18105 return getDerived().TransformExpr(E->getArgLValue());
18106}
18107
18108} // end namespace clang
18109
18110#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:4556
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:6024
Represents a loop initializing the elements of an array.
Definition Expr.h:5971
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:7222
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2727
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:3786
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6736
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6931
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:4459
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4044
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition Expr.cpp:2187
static bool isAssignmentOp(Opcode Opc)
Definition Expr.h:4180
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:2149
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8299
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4703
void setIsVariadic(bool value)
Definition Decl.h:4779
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6675
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:3975
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:2633
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:2895
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:2145
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:1874
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:2949
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:1523
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4975
unsigned getNumParams() const
Definition Decl.h:5013
unsigned getContextParamPosition() const
Definition Decl.h:5042
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5015
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:1986
Expr * getSubExpr()
Definition Expr.h:3732
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4854
Represents a 'co_await' expression.
Definition ExprCXX.h:5365
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4306
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3611
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:4397
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3824
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition Expr.h:1088
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4451
ContinueStmt - This represents a continue.
Definition Stmt.h:3129
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4725
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:3500
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:1466
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2126
DeclContextLookupResult lookup_result
Definition DeclBase.h:2594
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:1276
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:1952
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:4125
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:4075
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2096
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4165
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition TypeBase.h:4537
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2068
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4291
Represents a single C99 designator.
Definition Expr.h:5597
Represents a C99 designated initializer expression.
Definition Expr.h:5554
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:5091
Expr * getCondition() const
Definition TypeBase.h:5098
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:744
Represents a reference to emded data.
Definition Expr.h:5132
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:3956
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:3091
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3223
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:6613
Represents difference between two FPOptions values.
FPOptions applyOverrides(FPOptions Base)
Represents a member of a struct/union/class.
Definition Decl.h:3191
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2898
Represents a function declaration or definition.
Definition Decl.h:2027
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2801
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5339
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4984
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5742
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5728
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5205
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4949
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:5371
param_type_iterator param_type_begin() const
Definition TypeBase.h:5815
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:4593
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:4929
Represents a C11 generic selection.
Definition Expr.h:6185
AssociationTy< false > Association
Definition Expr.h:6418
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:7400
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:1737
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition Expr.h:3859
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:6060
Represents a C array with an unspecified size.
Definition TypeBase.h:3973
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:5305
InitListExpr * getSyntacticForm() const
Definition Expr.h:5475
Wrapper for source info for injected class names of class templates.
Definition TypeLoc.h:872
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition Expr.cpp:981
Represents the declaration of a label.
Definition Decl.h: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:4362
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:2801
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2871
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2125
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3370
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:3717
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:5880
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:2432
@ Identifier
A field in a dependent type, known only by its name.
Definition Expr.h:2436
@ Field
A field.
Definition Expr.h:2434
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition Expr.h:2439
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:1184
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1234
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition Expr.h:2096
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:2188
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition Expr.h:2213
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition Expr.h:2217
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1411
Represents a parameter to a function.
Definition Decl.h:1817
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1877
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1850
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:2934
unsigned getFunctionScopeDepth() const
Definition Decl.h:1867
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2725
PipeType - OpenCL20.
Definition TypeBase.h:8265
bool isReadOnly() const
Definition TypeBase.h:8295
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:3392
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2011
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:6807
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:8447
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8479
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:7506
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3637
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3653
Represents the body of a requires-expression.
Definition DeclCXX.h:2114
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition DeclCXX.cpp:2403
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:13749
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:13119
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:13138
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13126
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14154
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:486
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:12066
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:11868
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:11863
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:13743
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:76
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition Sema.h: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:564
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:951
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:437
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:569
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition SemaStmt.cpp:533
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:4649
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:5023
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition Expr.h:5083
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:4601
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:1805
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:3748
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:6282
A container of type source information.
Definition TypeBase.h:8418
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:8429
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:9200
bool isObjCObjectPointerType() const
Definition TypeBase.h:8863
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9277
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3593
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:2631
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2250
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition Expr.h:2295
Expr * getSubExpr() const
Definition Expr.h:2291
Opcode getOpcode() const
Definition Expr.h:2286
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:1421
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2344
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:1039
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h: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:6087
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:3417
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3481
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:4963
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:5590
Value()=default
Represents a variable declaration or definition.
Definition Decl.h:932
@ CInit
C-style initialization with assignment.
Definition Decl.h:937
@ CallInit
Call-style initialization (C++98)
Definition Decl.h:940
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1174
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:4030
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2045
Represents a GCC generic vector type.
Definition TypeBase.h:4239
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:786
bool ContainsUnexpandedParameterPack
Whether this contains an unexpanded parameter pack.
Definition ScopeInfo.h:724
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition ScopeInfo.h:867
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Definition ScopeInfo.h:870
@ 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:1180
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:964
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:3783
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:5995
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:5010
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5970
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5991
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5981
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5988
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:1995
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:5108
Holds information about the various types of exception specification.
Definition TypeBase.h:5428
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5444
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5430
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5433
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5436
Extra information about a function prototype.
Definition TypeBase.h:5456
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5461
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:3402
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:13199
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13230
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