clang 22.0.0git
TreeTransform.h
Go to the documentation of this file.
1//===------- TreeTransform.h - Semantic Tree Transformation -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//===----------------------------------------------------------------------===//
7//
8// This file implements a semantic tree transformation that takes a given
9// AST and rebuilds it, possibly transforming some nodes in the process.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
14#define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
15
17#include "TypeLocBuilder.h"
18#include "clang/AST/Decl.h"
19#include "clang/AST/DeclObjC.h"
21#include "clang/AST/Expr.h"
22#include "clang/AST/ExprCXX.h"
24#include "clang/AST/ExprObjC.h"
27#include "clang/AST/Stmt.h"
28#include "clang/AST/StmtCXX.h"
29#include "clang/AST/StmtObjC.h"
32#include "clang/AST/StmtSYCL.h"
37#include "clang/Sema/Lookup.h"
43#include "clang/Sema/SemaObjC.h"
47#include "clang/Sema/SemaSYCL.h"
48#include "clang/Sema/Template.h"
49#include "llvm/ADT/ArrayRef.h"
50#include "llvm/Support/ErrorHandling.h"
51#include <algorithm>
52#include <optional>
53
54using namespace llvm::omp;
55
56namespace clang {
57using namespace sema;
58
59// This helper class is used to facilitate pack expansion during tree transform.
69
70/// A semantic tree transformation that allows one to transform one
71/// abstract syntax tree into another.
72///
73/// A new tree transformation is defined by creating a new subclass \c X of
74/// \c TreeTransform<X> and then overriding certain operations to provide
75/// behavior specific to that transformation. For example, template
76/// instantiation is implemented as a tree transformation where the
77/// transformation of TemplateTypeParmType nodes involves substituting the
78/// template arguments for their corresponding template parameters; a similar
79/// transformation is performed for non-type template parameters and
80/// template template parameters.
81///
82/// This tree-transformation template uses static polymorphism to allow
83/// subclasses to customize any of its operations. Thus, a subclass can
84/// override any of the transformation or rebuild operators by providing an
85/// operation with the same signature as the default implementation. The
86/// overriding function should not be virtual.
87///
88/// Semantic tree transformations are split into two stages, either of which
89/// can be replaced by a subclass. The "transform" step transforms an AST node
90/// or the parts of an AST node using the various transformation functions,
91/// then passes the pieces on to the "rebuild" step, which constructs a new AST
92/// node of the appropriate kind from the pieces. The default transformation
93/// routines recursively transform the operands to composite AST nodes (e.g.,
94/// the pointee type of a PointerType node) and, if any of those operand nodes
95/// were changed by the transformation, invokes the rebuild operation to create
96/// a new AST node.
97///
98/// Subclasses can customize the transformation at various levels. The
99/// most coarse-grained transformations involve replacing TransformType(),
100/// TransformExpr(), TransformDecl(), TransformNestedNameSpecifierLoc(),
101/// TransformTemplateName(), or TransformTemplateArgument() with entirely
102/// new implementations.
103///
104/// For more fine-grained transformations, subclasses can replace any of the
105/// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
106/// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
107/// replacing TransformTemplateTypeParmType() allows template instantiation
108/// to substitute template arguments for their corresponding template
109/// parameters. Additionally, subclasses can override the \c RebuildXXX
110/// functions to control how AST nodes are rebuilt when their operands change.
111/// By default, \c TreeTransform will invoke semantic analysis to rebuild
112/// AST nodes. However, certain other tree transformations (e.g, cloning) may
113/// be able to use more efficient rebuild steps.
114///
115/// There are a handful of other functions that can be overridden, allowing one
116/// to avoid traversing nodes that don't need any transformation
117/// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
118/// operands have not changed (\c AlwaysRebuild()), and customize the
119/// default locations and entity names used for type-checking
120/// (\c getBaseLocation(), \c getBaseEntity()).
121template<typename Derived>
123 /// Private RAII object that helps us forget and then re-remember
124 /// the template argument corresponding to a partially-substituted parameter
125 /// pack.
126 class ForgetPartiallySubstitutedPackRAII {
127 Derived &Self;
129 // Set the pack expansion index to -1 to avoid pack substitution and
130 // indicate that parameter packs should be instantiated as themselves.
131 Sema::ArgPackSubstIndexRAII ResetPackSubstIndex;
132
133 public:
134 ForgetPartiallySubstitutedPackRAII(Derived &Self)
135 : Self(Self), ResetPackSubstIndex(Self.getSema(), std::nullopt) {
136 Old = Self.ForgetPartiallySubstitutedPack();
137 }
138
139 ~ForgetPartiallySubstitutedPackRAII() {
140 Self.RememberPartiallySubstitutedPack(Old);
141 }
142 };
143
144protected:
146
147 /// The set of local declarations that have been transformed, for
148 /// cases where we are forced to build new declarations within the transformer
149 /// rather than in the subclass (e.g., lambda closure types).
150 llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls;
151
152public:
153 /// Initializes a new tree transformer.
155
156 /// Retrieves a reference to the derived class.
157 Derived &getDerived() { return static_cast<Derived&>(*this); }
158
159 /// Retrieves a reference to the derived class.
160 const Derived &getDerived() const {
161 return static_cast<const Derived&>(*this);
162 }
163
164 static inline ExprResult Owned(Expr *E) { return E; }
165 static inline StmtResult Owned(Stmt *S) { return S; }
166
167 /// Retrieves a reference to the semantic analysis object used for
168 /// this tree transform.
169 Sema &getSema() const { return SemaRef; }
170
171 /// Whether the transformation should always rebuild AST nodes, even
172 /// if none of the children have changed.
173 ///
174 /// Subclasses may override this function to specify when the transformation
175 /// should rebuild all AST nodes.
176 ///
177 /// We must always rebuild all AST nodes when performing variadic template
178 /// pack expansion, in order to avoid violating the AST invariant that each
179 /// statement node appears at most once in its containing declaration.
180 bool AlwaysRebuild() { return static_cast<bool>(SemaRef.ArgPackSubstIndex); }
181
182 /// Whether the transformation is forming an expression or statement that
183 /// replaces the original. In this case, we'll reuse mangling numbers from
184 /// existing lambdas.
185 bool ReplacingOriginal() { return false; }
186
187 /// Wether CXXConstructExpr can be skipped when they are implicit.
188 /// They will be reconstructed when used if needed.
189 /// This is useful when the user that cause rebuilding of the
190 /// CXXConstructExpr is outside of the expression at which the TreeTransform
191 /// started.
192 bool AllowSkippingCXXConstructExpr() { return true; }
193
194 /// Returns the location of the entity being transformed, if that
195 /// information was not available elsewhere in the AST.
196 ///
197 /// By default, returns no source-location information. Subclasses can
198 /// provide an alternative implementation that provides better location
199 /// information.
201
202 /// Returns the name of the entity being transformed, if that
203 /// information was not available elsewhere in the AST.
204 ///
205 /// By default, returns an empty name. Subclasses can provide an alternative
206 /// implementation with a more precise name.
208
209 /// Sets the "base" location and entity when that
210 /// information is known based on another transformation.
211 ///
212 /// By default, the source location and entity are ignored. Subclasses can
213 /// override this function to provide a customized implementation.
215
216 /// RAII object that temporarily sets the base location and entity
217 /// used for reporting diagnostics in types.
219 TreeTransform &Self;
220 SourceLocation OldLocation;
221 DeclarationName OldEntity;
222
223 public:
225 DeclarationName Entity) : Self(Self) {
226 OldLocation = Self.getDerived().getBaseLocation();
227 OldEntity = Self.getDerived().getBaseEntity();
228
229 if (Location.isValid())
230 Self.getDerived().setBase(Location, Entity);
231 }
232
234 Self.getDerived().setBase(OldLocation, OldEntity);
235 }
236 };
237
238 /// Determine whether the given type \p T has already been
239 /// transformed.
240 ///
241 /// Subclasses can provide an alternative implementation of this routine
242 /// to short-circuit evaluation when it is known that a given type will
243 /// not change. For example, template instantiation need not traverse
244 /// non-dependent types.
246 return T.isNull();
247 }
248
249 /// Transform a template parameter depth level.
250 ///
251 /// During a transformation that transforms template parameters, this maps
252 /// an old template parameter depth to a new depth.
253 unsigned TransformTemplateDepth(unsigned Depth) {
254 return Depth;
255 }
256
257 /// Determine whether the given call argument should be dropped, e.g.,
258 /// because it is a default argument.
259 ///
260 /// Subclasses can provide an alternative implementation of this routine to
261 /// determine which kinds of call arguments get dropped. By default,
262 /// CXXDefaultArgument nodes are dropped (prior to transformation).
264 return E->isDefaultArgument();
265 }
266
267 /// Determine whether we should expand a pack expansion with the
268 /// given set of parameter packs into separate arguments by repeatedly
269 /// transforming the pattern.
270 ///
271 /// By default, the transformer never tries to expand pack expansions.
272 /// Subclasses can override this routine to provide different behavior.
273 ///
274 /// \param EllipsisLoc The location of the ellipsis that identifies the
275 /// pack expansion.
276 ///
277 /// \param PatternRange The source range that covers the entire pattern of
278 /// the pack expansion.
279 ///
280 /// \param Unexpanded The set of unexpanded parameter packs within the
281 /// pattern.
282 ///
283 /// \param ShouldExpand Will be set to \c true if the transformer should
284 /// expand the corresponding pack expansions into separate arguments. When
285 /// set, \c NumExpansions must also be set.
286 ///
287 /// \param RetainExpansion Whether the caller should add an unexpanded
288 /// pack expansion after all of the expanded arguments. This is used
289 /// when extending explicitly-specified template argument packs per
290 /// C++0x [temp.arg.explicit]p9.
291 ///
292 /// \param NumExpansions The number of separate arguments that will be in
293 /// the expanded form of the corresponding pack expansion. This is both an
294 /// input and an output parameter, which can be set by the caller if the
295 /// number of expansions is known a priori (e.g., due to a prior substitution)
296 /// and will be set by the callee when the number of expansions is known.
297 /// The callee must set this value when \c ShouldExpand is \c true; it may
298 /// set this value in other cases.
299 ///
300 /// \returns true if an error occurred (e.g., because the parameter packs
301 /// are to be instantiated with arguments of different lengths), false
302 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
303 /// must be set.
305 SourceRange PatternRange,
307 bool FailOnPackProducingTemplates,
308 bool &ShouldExpand, bool &RetainExpansion,
309 UnsignedOrNone &NumExpansions) {
310 ShouldExpand = false;
311 return false;
312 }
313
314 /// "Forget" about the partially-substituted pack template argument,
315 /// when performing an instantiation that must preserve the parameter pack
316 /// use.
317 ///
318 /// This routine is meant to be overridden by the template instantiator.
322
323 /// "Remember" the partially-substituted pack template argument
324 /// after performing an instantiation that must preserve the parameter pack
325 /// use.
326 ///
327 /// This routine is meant to be overridden by the template instantiator.
329
330 /// "Forget" the template substitution to allow transforming the AST without
331 /// any template instantiations. This is used to expand template packs when
332 /// their size is not known in advance (e.g. for builtins that produce type
333 /// packs).
336
337private:
338 struct ForgetSubstitutionRAII {
339 Derived &Self;
341
342 public:
343 ForgetSubstitutionRAII(Derived &Self) : Self(Self) {
344 Old = Self.ForgetSubstitution();
345 }
346
347 ~ForgetSubstitutionRAII() { Self.RememberSubstitution(std::move(Old)); }
348 };
349
350public:
351 /// Note to the derived class when a function parameter pack is
352 /// being expanded.
354
355 /// Transforms the given type into another type.
356 ///
357 /// By default, this routine transforms a type by creating a
358 /// TypeSourceInfo for it and delegating to the appropriate
359 /// function. This is expensive, but we don't mind, because
360 /// this method is deprecated anyway; all users should be
361 /// switched to storing TypeSourceInfos.
362 ///
363 /// \returns the transformed type.
365
366 /// Transforms the given type-with-location into a new
367 /// type-with-location.
368 ///
369 /// By default, this routine transforms a type by delegating to the
370 /// appropriate TransformXXXType to build a new type. Subclasses
371 /// may override this function (to take over all type
372 /// transformations) or some set of the TransformXXXType functions
373 /// to alter the transformation.
375
376 /// Transform the given type-with-location into a new
377 /// type, collecting location information in the given builder
378 /// as necessary.
379 ///
381
382 /// Transform a type that is permitted to produce a
383 /// DeducedTemplateSpecializationType.
384 ///
385 /// This is used in the (relatively rare) contexts where it is acceptable
386 /// for transformation to produce a class template type with deduced
387 /// template arguments.
388 /// @{
391 /// @}
392
393 /// The reason why the value of a statement is not discarded, if any.
399
400 /// Transform the given statement.
401 ///
402 /// By default, this routine transforms a statement by delegating to the
403 /// appropriate TransformXXXStmt function to transform a specific kind of
404 /// statement or the TransformExpr() function to transform an expression.
405 /// Subclasses may override this function to transform statements using some
406 /// other mechanism.
407 ///
408 /// \returns the transformed statement.
411
412 /// Transform the given statement.
413 ///
414 /// By default, this routine transforms a statement by delegating to the
415 /// appropriate TransformOMPXXXClause function to transform a specific kind
416 /// of clause. Subclasses may override this function to transform statements
417 /// using some other mechanism.
418 ///
419 /// \returns the transformed OpenMP clause.
421
422 /// Transform the given attribute.
423 ///
424 /// By default, this routine transforms a statement by delegating to the
425 /// appropriate TransformXXXAttr function to transform a specific kind
426 /// of attribute. Subclasses may override this function to transform
427 /// attributed statements/types using some other mechanism.
428 ///
429 /// \returns the transformed attribute
430 const Attr *TransformAttr(const Attr *S);
431
432 // Transform the given statement attribute.
433 //
434 // Delegates to the appropriate TransformXXXAttr function to transform a
435 // specific kind of statement attribute. Unlike the non-statement taking
436 // version of this, this implements all attributes, not just pragmas.
437 const Attr *TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS,
438 const Attr *A);
439
440 // Transform the specified attribute.
441 //
442 // Subclasses should override the transformation of attributes with a pragma
443 // spelling to transform expressions stored within the attribute.
444 //
445 // \returns the transformed attribute.
446#define ATTR(X) \
447 const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; }
448#include "clang/Basic/AttrList.inc"
449
450 // Transform the specified attribute.
451 //
452 // Subclasses should override the transformation of attributes to do
453 // transformation and checking of statement attributes. By default, this
454 // delegates to the non-statement taking version.
455 //
456 // \returns the transformed attribute.
457#define ATTR(X) \
458 const X##Attr *TransformStmt##X##Attr(const Stmt *, const Stmt *, \
459 const X##Attr *A) { \
460 return getDerived().Transform##X##Attr(A); \
461 }
462#include "clang/Basic/AttrList.inc"
463
464 /// Transform the given expression.
465 ///
466 /// By default, this routine transforms an expression by delegating to the
467 /// appropriate TransformXXXExpr function to build a new expression.
468 /// Subclasses may override this function to transform expressions using some
469 /// other mechanism.
470 ///
471 /// \returns the transformed expression.
473
474 /// Transform the given initializer.
475 ///
476 /// By default, this routine transforms an initializer by stripping off the
477 /// semantic nodes added by initialization, then passing the result to
478 /// TransformExpr or TransformExprs.
479 ///
480 /// \returns the transformed initializer.
482
483 /// Transform the given list of expressions.
484 ///
485 /// This routine transforms a list of expressions by invoking
486 /// \c TransformExpr() for each subexpression. However, it also provides
487 /// support for variadic templates by expanding any pack expansions (if the
488 /// derived class permits such expansion) along the way. When pack expansions
489 /// are present, the number of outputs may not equal the number of inputs.
490 ///
491 /// \param Inputs The set of expressions to be transformed.
492 ///
493 /// \param NumInputs The number of expressions in \c Inputs.
494 ///
495 /// \param IsCall If \c true, then this transform is being performed on
496 /// function-call arguments, and any arguments that should be dropped, will
497 /// be.
498 ///
499 /// \param Outputs The transformed input expressions will be added to this
500 /// vector.
501 ///
502 /// \param ArgChanged If non-NULL, will be set \c true if any argument changed
503 /// due to transformation.
504 ///
505 /// \returns true if an error occurred, false otherwise.
506 bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall,
508 bool *ArgChanged = nullptr);
509
510 /// Transform the given declaration, which is referenced from a type
511 /// or expression.
512 ///
513 /// By default, acts as the identity function on declarations, unless the
514 /// transformer has had to transform the declaration itself. Subclasses
515 /// may override this function to provide alternate behavior.
517 llvm::DenseMap<Decl *, Decl *>::iterator Known
518 = TransformedLocalDecls.find(D);
519 if (Known != TransformedLocalDecls.end())
520 return Known->second;
521
522 return D;
523 }
524
525 /// Transform the specified condition.
526 ///
527 /// By default, this transforms the variable and expression and rebuilds
528 /// the condition.
530 Expr *Expr,
532
533 /// Transform the attributes associated with the given declaration and
534 /// place them on the new declaration.
535 ///
536 /// By default, this operation does nothing. Subclasses may override this
537 /// behavior to transform attributes.
538 void transformAttrs(Decl *Old, Decl *New) { }
539
540 /// Note that a local declaration has been transformed by this
541 /// transformer.
542 ///
543 /// Local declarations are typically transformed via a call to
544 /// TransformDefinition. However, in some cases (e.g., lambda expressions),
545 /// the transformer itself has to transform the declarations. This routine
546 /// can be overridden by a subclass that keeps track of such mappings.
548 assert(New.size() == 1 &&
549 "must override transformedLocalDecl if performing pack expansion");
550 TransformedLocalDecls[Old] = New.front();
551 }
552
553 /// Transform the definition of the given declaration.
554 ///
555 /// By default, invokes TransformDecl() to transform the declaration.
556 /// Subclasses may override this function to provide alternate behavior.
558 return getDerived().TransformDecl(Loc, D);
559 }
560
561 /// Transform the given declaration, which was the first part of a
562 /// nested-name-specifier in a member access expression.
563 ///
564 /// This specific declaration transformation only applies to the first
565 /// identifier in a nested-name-specifier of a member access expression, e.g.,
566 /// the \c T in \c x->T::member
567 ///
568 /// By default, invokes TransformDecl() to transform the declaration.
569 /// Subclasses may override this function to provide alternate behavior.
571 return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D));
572 }
573
574 /// Transform the set of declarations in an OverloadExpr.
575 bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL,
576 LookupResult &R);
577
578 /// Transform the given nested-name-specifier with source-location
579 /// information.
580 ///
581 /// By default, transforms all of the types and declarations within the
582 /// nested-name-specifier. Subclasses may override this function to provide
583 /// alternate behavior.
586 QualType ObjectType = QualType(),
587 NamedDecl *FirstQualifierInScope = nullptr);
588
589 /// Transform the given declaration name.
590 ///
591 /// By default, transforms the types of conversion function, constructor,
592 /// and destructor names and then (if needed) rebuilds the declaration name.
593 /// Identifiers and selectors are returned unmodified. Subclasses may
594 /// override this function to provide alternate behavior.
597
607
608 /// Transform the given template name.
609 ///
610 /// \param SS The nested-name-specifier that qualifies the template
611 /// name. This nested-name-specifier must already have been transformed.
612 ///
613 /// \param Name The template name to transform.
614 ///
615 /// \param NameLoc The source location of the template name.
616 ///
617 /// \param ObjectType If we're translating a template name within a member
618 /// access expression, this is the type of the object whose member template
619 /// is being referenced.
620 ///
621 /// \param FirstQualifierInScope If the first part of a nested-name-specifier
622 /// also refers to a name within the current (lexical) scope, this is the
623 /// declaration it refers to.
624 ///
625 /// By default, transforms the template name by transforming the declarations
626 /// and nested-name-specifiers that occur within the template name.
627 /// Subclasses may override this function to provide alternate behavior.
629 SourceLocation TemplateKWLoc,
630 TemplateName Name, SourceLocation NameLoc,
631 QualType ObjectType = QualType(),
632 NamedDecl *FirstQualifierInScope = nullptr,
633 bool AllowInjectedClassName = false);
634
635 /// Transform the given template argument.
636 ///
637 /// By default, this operation transforms the type, expression, or
638 /// declaration stored within the template argument and constructs a
639 /// new template argument from the transformed result. Subclasses may
640 /// override this function to provide alternate behavior.
641 ///
642 /// Returns true if there was an error.
644 TemplateArgumentLoc &Output,
645 bool Uneval = false);
646
648 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
649 TemplateName Name, SourceLocation NameLoc);
650
651 /// Transform the given set of template arguments.
652 ///
653 /// By default, this operation transforms all of the template arguments
654 /// in the input set using \c TransformTemplateArgument(), and appends
655 /// the transformed arguments to the output list.
656 ///
657 /// Note that this overload of \c TransformTemplateArguments() is merely
658 /// a convenience function. Subclasses that wish to override this behavior
659 /// should override the iterator-based member template version.
660 ///
661 /// \param Inputs The set of template arguments to be transformed.
662 ///
663 /// \param NumInputs The number of template arguments in \p Inputs.
664 ///
665 /// \param Outputs The set of transformed template arguments output by this
666 /// routine.
667 ///
668 /// Returns true if an error occurred.
670 unsigned NumInputs,
672 bool Uneval = false) {
673 return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs,
674 Uneval);
675 }
676
677 /// Transform the given set of template arguments.
678 ///
679 /// By default, this operation transforms all of the template arguments
680 /// in the input set using \c TransformTemplateArgument(), and appends
681 /// the transformed arguments to the output list.
682 ///
683 /// \param First An iterator to the first template argument.
684 ///
685 /// \param Last An iterator one step past the last template argument.
686 ///
687 /// \param Outputs The set of transformed template arguments output by this
688 /// routine.
689 ///
690 /// Returns true if an error occurred.
691 template<typename InputIterator>
693 InputIterator Last,
695 bool Uneval = false);
696
697 template <typename InputIterator>
699 InputIterator Last,
701 bool Uneval = false);
702
703 /// Checks if the argument pack from \p In will need to be expanded and does
704 /// the necessary prework.
705 /// Whether the expansion is needed is captured in Info.Expand.
706 ///
707 /// - When the expansion is required, \p Out will be a template pattern that
708 /// would need to be expanded.
709 /// - When the expansion must not happen, \p Out will be a pack that must be
710 /// returned to the outputs directly.
711 ///
712 /// \return true iff the error occurred
715
716 /// Fakes up a TemplateArgumentLoc for a given TemplateArgument.
718 TemplateArgumentLoc &ArgLoc);
719
720 /// Fakes up a TypeSourceInfo for a type.
722 return SemaRef.Context.getTrivialTypeSourceInfo(T,
724 }
725
726#define ABSTRACT_TYPELOC(CLASS, PARENT)
727#define TYPELOC(CLASS, PARENT) \
728 QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
729#include "clang/AST/TypeLocNodes.def"
730
733 bool SuppressObjCLifetime);
737 bool SuppressObjCLifetime);
738
739 template<typename Fn>
742 CXXRecordDecl *ThisContext,
743 Qualifiers ThisTypeQuals,
745
748 SmallVectorImpl<QualType> &Exceptions,
749 bool &Changed);
750
752
755 QualType ObjectType,
756 NamedDecl *FirstQualifierInScope,
757 bool AllowInjectedClassName);
758
760
761 /// Transforms the parameters of a function type into the
762 /// given vectors.
763 ///
764 /// The result vectors should be kept in sync; null entries in the
765 /// variables vector are acceptable.
766 ///
767 /// LastParamTransformed, if non-null, will be set to the index of the last
768 /// parameter on which transformation was started. In the event of an error,
769 /// this will contain the parameter which failed to instantiate.
770 ///
771 /// Return true on error.
774 const QualType *ParamTypes,
775 const FunctionProtoType::ExtParameterInfo *ParamInfos,
777 Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed);
778
781 const QualType *ParamTypes,
782 const FunctionProtoType::ExtParameterInfo *ParamInfos,
785 return getDerived().TransformFunctionTypeParams(
786 Loc, Params, ParamTypes, ParamInfos, PTypes, PVars, PInfos, nullptr);
787 }
788
789 /// Transforms the parameters of a requires expresison into the given vectors.
790 ///
791 /// The result vectors should be kept in sync; null entries in the
792 /// variables vector are acceptable.
793 ///
794 /// Returns an unset ExprResult on success. Returns an ExprResult the 'not
795 /// satisfied' RequiresExpr if subsitution failed, OR an ExprError, both of
796 /// which are cases where transformation shouldn't continue.
798 SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
804 KWLoc, Params, /*ParamTypes=*/nullptr,
805 /*ParamInfos=*/nullptr, PTypes, &TransParams, PInfos))
806 return ExprError();
807
808 return ExprResult{};
809 }
810
811 /// Transforms a single function-type parameter. Return null
812 /// on error.
813 ///
814 /// \param indexAdjustment - A number to add to the parameter's
815 /// scope index; can be negative
817 int indexAdjustment,
818 UnsignedOrNone NumExpansions,
819 bool ExpectParameterPack);
820
821 /// Transform the body of a lambda-expression.
823 /// Alternative implementation of TransformLambdaBody that skips transforming
824 /// the body.
826
832
834
837
842
844
846 bool IsAddressOfOperand,
847 TypeSourceInfo **RecoveryTSI);
848
850 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
851 TypeSourceInfo **RecoveryTSI);
852
854 bool IsAddressOfOperand);
855
857
859
860// FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
861// amount of stack usage with clang.
862#define STMT(Node, Parent) \
863 LLVM_ATTRIBUTE_NOINLINE \
864 StmtResult Transform##Node(Node *S);
865#define VALUESTMT(Node, Parent) \
866 LLVM_ATTRIBUTE_NOINLINE \
867 StmtResult Transform##Node(Node *S, StmtDiscardKind SDK);
868#define EXPR(Node, Parent) \
869 LLVM_ATTRIBUTE_NOINLINE \
870 ExprResult Transform##Node(Node *E);
871#define ABSTRACT_STMT(Stmt)
872#include "clang/AST/StmtNodes.inc"
873
874#define GEN_CLANG_CLAUSE_CLASS
875#define CLAUSE_CLASS(Enum, Str, Class) \
876 LLVM_ATTRIBUTE_NOINLINE \
877 OMPClause *Transform##Class(Class *S);
878#include "llvm/Frontend/OpenMP/OMP.inc"
879
880 /// Build a new qualified type given its unqualified type and type location.
881 ///
882 /// By default, this routine adds type qualifiers only to types that can
883 /// have qualifiers, and silently suppresses those qualifiers that are not
884 /// permitted. Subclasses may override this routine to provide different
885 /// behavior.
887
888 /// Build a new pointer type given its pointee type.
889 ///
890 /// By default, performs semantic analysis when building the pointer type.
891 /// Subclasses may override this routine to provide different behavior.
893
894 /// Build a new block pointer type given its pointee type.
895 ///
896 /// By default, performs semantic analysis when building the block pointer
897 /// type. Subclasses may override this routine to provide different behavior.
899
900 /// Build a new reference type given the type it references.
901 ///
902 /// By default, performs semantic analysis when building the
903 /// reference type. Subclasses may override this routine to provide
904 /// different behavior.
905 ///
906 /// \param LValue whether the type was written with an lvalue sigil
907 /// or an rvalue sigil.
909 bool LValue,
910 SourceLocation Sigil);
911
912 /// Build a new member pointer type given the pointee type and the
913 /// qualifier it refers into.
914 ///
915 /// By default, performs semantic analysis when building the member pointer
916 /// type. Subclasses may override this routine to provide different behavior.
918 const CXXScopeSpec &SS, CXXRecordDecl *Cls,
919 SourceLocation Sigil);
920
922 SourceLocation ProtocolLAngleLoc,
924 ArrayRef<SourceLocation> ProtocolLocs,
925 SourceLocation ProtocolRAngleLoc);
926
927 /// Build an Objective-C object type.
928 ///
929 /// By default, performs semantic analysis when building the object type.
930 /// Subclasses may override this routine to provide different behavior.
932 SourceLocation Loc,
933 SourceLocation TypeArgsLAngleLoc,
935 SourceLocation TypeArgsRAngleLoc,
936 SourceLocation ProtocolLAngleLoc,
938 ArrayRef<SourceLocation> ProtocolLocs,
939 SourceLocation ProtocolRAngleLoc);
940
941 /// Build a new Objective-C object pointer type given the pointee type.
942 ///
943 /// By default, directly builds the pointer type, with no additional semantic
944 /// analysis.
947
948 /// Build a new array type given the element type, size
949 /// modifier, size of the array (if known), size expression, and index type
950 /// qualifiers.
951 ///
952 /// By default, performs semantic analysis when building the array type.
953 /// Subclasses may override this routine to provide different behavior.
954 /// Also by default, all of the other Rebuild*Array
956 const llvm::APInt *Size, Expr *SizeExpr,
957 unsigned IndexTypeQuals, SourceRange BracketsRange);
958
959 /// Build a new constant array type given the element type, size
960 /// modifier, (known) size of the array, and index type qualifiers.
961 ///
962 /// By default, performs semantic analysis when building the array type.
963 /// Subclasses may override this routine to provide different behavior.
965 ArraySizeModifier SizeMod,
966 const llvm::APInt &Size, Expr *SizeExpr,
967 unsigned IndexTypeQuals,
968 SourceRange BracketsRange);
969
970 /// Build a new incomplete array type given the element type, size
971 /// modifier, and index type qualifiers.
972 ///
973 /// By default, performs semantic analysis when building the array type.
974 /// Subclasses may override this routine to provide different behavior.
976 ArraySizeModifier SizeMod,
977 unsigned IndexTypeQuals,
978 SourceRange BracketsRange);
979
980 /// Build a new variable-length array type given the element type,
981 /// size modifier, size expression, and index type qualifiers.
982 ///
983 /// By default, performs semantic analysis when building the array type.
984 /// Subclasses may override this routine to provide different behavior.
986 ArraySizeModifier SizeMod, Expr *SizeExpr,
987 unsigned IndexTypeQuals,
988 SourceRange BracketsRange);
989
990 /// Build a new dependent-sized array type given the element type,
991 /// size modifier, size expression, and index type qualifiers.
992 ///
993 /// By default, performs semantic analysis when building the array type.
994 /// Subclasses may override this routine to provide different behavior.
996 ArraySizeModifier SizeMod,
997 Expr *SizeExpr,
998 unsigned IndexTypeQuals,
999 SourceRange BracketsRange);
1000
1001 /// Build a new vector type given the element type and
1002 /// number of elements.
1003 ///
1004 /// By default, performs semantic analysis when building the vector type.
1005 /// Subclasses may override this routine to provide different behavior.
1006 QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
1007 VectorKind VecKind);
1008
1009 /// Build a new potentially dependently-sized extended vector type
1010 /// given the element type and number of elements.
1011 ///
1012 /// By default, performs semantic analysis when building the vector type.
1013 /// Subclasses may override this routine to provide different behavior.
1015 SourceLocation AttributeLoc, VectorKind);
1016
1017 /// Build a new extended vector type given the element type and
1018 /// number of elements.
1019 ///
1020 /// By default, performs semantic analysis when building the vector type.
1021 /// Subclasses may override this routine to provide different behavior.
1022 QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
1023 SourceLocation AttributeLoc);
1024
1025 /// Build a new potentially dependently-sized extended vector type
1026 /// given the element type and number of elements.
1027 ///
1028 /// By default, performs semantic analysis when building the vector type.
1029 /// Subclasses may override this routine to provide different behavior.
1031 Expr *SizeExpr,
1032 SourceLocation AttributeLoc);
1033
1034 /// Build a new matrix type given the element type and dimensions.
1035 QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows,
1036 unsigned NumColumns);
1037
1038 /// Build a new matrix type given the type and dependently-defined
1039 /// dimensions.
1041 Expr *ColumnExpr,
1042 SourceLocation AttributeLoc);
1043
1044 /// Build a new DependentAddressSpaceType or return the pointee
1045 /// type variable with the correct address space (retrieved from
1046 /// AddrSpaceExpr) applied to it. The former will be returned in cases
1047 /// where the address space remains dependent.
1048 ///
1049 /// By default, performs semantic analysis when building the type with address
1050 /// space applied. Subclasses may override this routine to provide different
1051 /// behavior.
1053 Expr *AddrSpaceExpr,
1054 SourceLocation AttributeLoc);
1055
1056 /// Build a new function type.
1057 ///
1058 /// By default, performs semantic analysis when building the function type.
1059 /// Subclasses may override this routine to provide different behavior.
1061 MutableArrayRef<QualType> ParamTypes,
1063
1064 /// Build a new unprototyped function type.
1066
1067 /// Rebuild an unresolved typename type, given the decl that
1068 /// the UnresolvedUsingTypenameDecl was transformed to.
1070 NestedNameSpecifier Qualifier,
1071 SourceLocation NameLoc, Decl *D);
1072
1073 /// Build a new type found via an alias.
1076 QualType UnderlyingType) {
1077 return SemaRef.Context.getUsingType(Keyword, Qualifier, D, UnderlyingType);
1078 }
1079
1080 /// Build a new typedef type.
1082 NestedNameSpecifier Qualifier,
1084 return SemaRef.Context.getTypedefType(Keyword, Qualifier, Typedef);
1085 }
1086
1087 /// Build a new MacroDefined type.
1089 const IdentifierInfo *MacroII) {
1090 return SemaRef.Context.getMacroQualifiedType(T, MacroII);
1091 }
1092
1093 /// Build a new class/struct/union/enum type.
1095 NestedNameSpecifier Qualifier, TagDecl *Tag) {
1096 return SemaRef.Context.getTagType(Keyword, Qualifier, Tag,
1097 /*OwnsTag=*/false);
1098 }
1100 return SemaRef.Context.getCanonicalTagType(Tag);
1101 }
1102
1103 /// Build a new typeof(expr) type.
1104 ///
1105 /// By default, performs semantic analysis when building the typeof type.
1106 /// Subclasses may override this routine to provide different behavior.
1108 TypeOfKind Kind);
1109
1110 /// Build a new typeof(type) type.
1111 ///
1112 /// By default, builds a new TypeOfType with the given underlying type.
1114
1115 /// Build a new unary transform type.
1117 UnaryTransformType::UTTKind UKind,
1118 SourceLocation Loc);
1119
1120 /// Build a new C++11 decltype type.
1121 ///
1122 /// By default, performs semantic analysis when building the decltype type.
1123 /// Subclasses may override this routine to provide different behavior.
1125
1127 SourceLocation Loc,
1128 SourceLocation EllipsisLoc,
1129 bool FullySubstituted,
1130 ArrayRef<QualType> Expansions = {});
1131
1132 /// Build a new C++11 auto type.
1133 ///
1134 /// By default, builds a new AutoType with the given deduced type.
1136 ConceptDecl *TypeConstraintConcept,
1137 ArrayRef<TemplateArgument> TypeConstraintArgs) {
1138 // Note, IsDependent is always false here: we implicitly convert an 'auto'
1139 // which has been deduced to a dependent type into an undeduced 'auto', so
1140 // that we'll retry deduction after the transformation.
1141 return SemaRef.Context.getAutoType(Deduced, Keyword,
1142 /*IsDependent*/ false, /*IsPack=*/false,
1143 TypeConstraintConcept,
1144 TypeConstraintArgs);
1145 }
1146
1147 /// By default, builds a new DeducedTemplateSpecializationType with the given
1148 /// deduced type.
1151 return SemaRef.Context.getDeducedTemplateSpecializationType(
1152 Keyword, Template, Deduced, /*IsDependent*/ false);
1153 }
1154
1155 /// Build a new template specialization type.
1156 ///
1157 /// By default, performs semantic analysis when building the template
1158 /// specialization type. Subclasses may override this routine to provide
1159 /// different behavior.
1162 SourceLocation TemplateLoc,
1164
1165 /// Build a new parenthesized type.
1166 ///
1167 /// By default, builds a new ParenType type from the inner type.
1168 /// Subclasses may override this routine to provide different behavior.
1170 return SemaRef.BuildParenType(InnerType);
1171 }
1172
1173 /// Build a new typename type that refers to an identifier.
1174 ///
1175 /// By default, performs semantic analysis when building the typename type
1176 /// (or elaborated type). Subclasses may override this routine to provide
1177 /// different behavior.
1179 SourceLocation KeywordLoc,
1180 NestedNameSpecifierLoc QualifierLoc,
1181 const IdentifierInfo *Id,
1182 SourceLocation IdLoc,
1183 bool DeducedTSTContext) {
1184 CXXScopeSpec SS;
1185 SS.Adopt(QualifierLoc);
1186
1187 if (QualifierLoc.getNestedNameSpecifier().isDependent()) {
1188 // If the name is still dependent, just build a new dependent name type.
1189 if (!SemaRef.computeDeclContext(SS))
1190 return SemaRef.Context.getDependentNameType(Keyword,
1191 QualifierLoc.getNestedNameSpecifier(),
1192 Id);
1193 }
1194
1197 return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1198 *Id, IdLoc, DeducedTSTContext);
1199 }
1200
1202
1203 // We had a dependent elaborated-type-specifier that has been transformed
1204 // into a non-dependent elaborated-type-specifier. Find the tag we're
1205 // referring to.
1207 DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1208 if (!DC)
1209 return QualType();
1210
1211 if (SemaRef.RequireCompleteDeclContext(SS, DC))
1212 return QualType();
1213
1214 TagDecl *Tag = nullptr;
1215 SemaRef.LookupQualifiedName(Result, DC);
1216 switch (Result.getResultKind()) {
1219 break;
1220
1222 Tag = Result.getAsSingle<TagDecl>();
1223 break;
1224
1227 llvm_unreachable("Tag lookup cannot find non-tags");
1228
1230 // Let the LookupResult structure handle ambiguities.
1231 return QualType();
1232 }
1233
1234 if (!Tag) {
1235 // Check where the name exists but isn't a tag type and use that to emit
1236 // better diagnostics.
1238 SemaRef.LookupQualifiedName(Result, DC);
1239 switch (Result.getResultKind()) {
1243 NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1244 NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1245 SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag)
1246 << SomeDecl << NTK << Kind;
1247 SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1248 break;
1249 }
1250 default:
1251 SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1252 << Kind << Id << DC << QualifierLoc.getSourceRange();
1253 break;
1254 }
1255 return QualType();
1256 }
1257 if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1258 IdLoc, Id)) {
1259 SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1260 SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1261 return QualType();
1262 }
1263 return getDerived().RebuildTagType(
1264 Keyword, QualifierLoc.getNestedNameSpecifier(), Tag);
1265 }
1266
1267 /// Build a new pack expansion type.
1268 ///
1269 /// By default, builds a new PackExpansionType type from the given pattern.
1270 /// Subclasses may override this routine to provide different behavior.
1272 SourceLocation EllipsisLoc,
1273 UnsignedOrNone NumExpansions) {
1274 return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1275 NumExpansions);
1276 }
1277
1278 /// Build a new atomic type given its value type.
1279 ///
1280 /// By default, performs semantic analysis when building the atomic type.
1281 /// Subclasses may override this routine to provide different behavior.
1283
1284 /// Build a new pipe type given its value type.
1286 bool isReadPipe);
1287
1288 /// Build a bit-precise int given its value type.
1289 QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits,
1290 SourceLocation Loc);
1291
1292 /// Build a dependent bit-precise int given its value type.
1293 QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
1294 SourceLocation Loc);
1295
1296 /// Build a new template name given a nested name specifier, a flag
1297 /// indicating whether the "template" keyword was provided, and the template
1298 /// that the template name refers to.
1299 ///
1300 /// By default, builds the new template name directly. Subclasses may override
1301 /// this routine to provide different behavior.
1303 TemplateName Name);
1304
1305 /// Build a new template name given a nested name specifier and the
1306 /// name that is referred to as a template.
1307 ///
1308 /// By default, performs semantic analysis to determine whether the name can
1309 /// be resolved to a specific template, then builds the appropriate kind of
1310 /// template name. Subclasses may override this routine to provide different
1311 /// behavior.
1313 SourceLocation TemplateKWLoc,
1314 const IdentifierInfo &Name,
1315 SourceLocation NameLoc, QualType ObjectType,
1316 bool AllowInjectedClassName);
1317
1318 /// Build a new template name given a nested name specifier and the
1319 /// overloaded operator name that is referred to as a template.
1320 ///
1321 /// By default, performs semantic analysis to determine whether the name can
1322 /// be resolved to a specific template, then builds the appropriate kind of
1323 /// template name. Subclasses may override this routine to provide different
1324 /// behavior.
1326 SourceLocation TemplateKWLoc,
1327 OverloadedOperatorKind Operator,
1328 SourceLocation NameLoc, QualType ObjectType,
1329 bool AllowInjectedClassName);
1330
1332 SourceLocation TemplateKWLoc,
1334 SourceLocation NameLoc, QualType ObjectType,
1335 bool AllowInjectedClassName);
1336
1337 /// Build a new template name given a template template parameter pack
1338 /// and the
1339 ///
1340 /// By default, performs semantic analysis to determine whether the name can
1341 /// be resolved to a specific template, then builds the appropriate kind of
1342 /// template name. Subclasses may override this routine to provide different
1343 /// behavior.
1345 Decl *AssociatedDecl, unsigned Index,
1346 bool Final) {
1348 ArgPack, AssociatedDecl, Index, Final);
1349 }
1350
1351 /// Build a new compound statement.
1352 ///
1353 /// By default, performs semantic analysis to build the new statement.
1354 /// Subclasses may override this routine to provide different behavior.
1356 MultiStmtArg Statements,
1357 SourceLocation RBraceLoc,
1358 bool IsStmtExpr) {
1359 return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1360 IsStmtExpr);
1361 }
1362
1363 /// Build a new case statement.
1364 ///
1365 /// By default, performs semantic analysis to build the new statement.
1366 /// Subclasses may override this routine to provide different behavior.
1368 Expr *LHS,
1369 SourceLocation EllipsisLoc,
1370 Expr *RHS,
1371 SourceLocation ColonLoc) {
1372 return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1373 ColonLoc);
1374 }
1375
1376 /// Attach the body to a new case statement.
1377 ///
1378 /// By default, performs semantic analysis to build the new statement.
1379 /// Subclasses may override this routine to provide different behavior.
1381 getSema().ActOnCaseStmtBody(S, Body);
1382 return S;
1383 }
1384
1385 /// Build a new default statement.
1386 ///
1387 /// By default, performs semantic analysis to build the new statement.
1388 /// Subclasses may override this routine to provide different behavior.
1390 SourceLocation ColonLoc,
1391 Stmt *SubStmt) {
1392 return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1393 /*CurScope=*/nullptr);
1394 }
1395
1396 /// Build a new label statement.
1397 ///
1398 /// By default, performs semantic analysis to build the new statement.
1399 /// Subclasses may override this routine to provide different behavior.
1401 SourceLocation ColonLoc, Stmt *SubStmt) {
1402 return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1403 }
1404
1405 /// Build a new attributed statement.
1406 ///
1407 /// By default, performs semantic analysis to build the new statement.
1408 /// Subclasses may override this routine to provide different behavior.
1411 Stmt *SubStmt) {
1412 if (SemaRef.CheckRebuiltStmtAttributes(Attrs))
1413 return StmtError();
1414 return SemaRef.BuildAttributedStmt(AttrLoc, Attrs, SubStmt);
1415 }
1416
1417 /// Build a new "if" statement.
1418 ///
1419 /// By default, performs semantic analysis to build the new statement.
1420 /// Subclasses may override this routine to provide different behavior.
1423 SourceLocation RParenLoc, Stmt *Init, Stmt *Then,
1424 SourceLocation ElseLoc, Stmt *Else) {
1425 return getSema().ActOnIfStmt(IfLoc, Kind, LParenLoc, Init, Cond, RParenLoc,
1426 Then, ElseLoc, Else);
1427 }
1428
1429 /// Start building a new switch statement.
1430 ///
1431 /// By default, performs semantic analysis to build the new statement.
1432 /// Subclasses may override this routine to provide different behavior.
1434 SourceLocation LParenLoc, Stmt *Init,
1436 SourceLocation RParenLoc) {
1437 return getSema().ActOnStartOfSwitchStmt(SwitchLoc, LParenLoc, Init, Cond,
1438 RParenLoc);
1439 }
1440
1441 /// Attach the body to the switch statement.
1442 ///
1443 /// By default, performs semantic analysis to build the new statement.
1444 /// Subclasses may override this routine to provide different behavior.
1446 Stmt *Switch, Stmt *Body) {
1447 return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1448 }
1449
1450 /// Build a new while statement.
1451 ///
1452 /// By default, performs semantic analysis to build the new statement.
1453 /// Subclasses may override this routine to provide different behavior.
1456 SourceLocation RParenLoc, Stmt *Body) {
1457 return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body);
1458 }
1459
1460 /// Build a new do-while statement.
1461 ///
1462 /// By default, performs semantic analysis to build the new statement.
1463 /// Subclasses may override this routine to provide different behavior.
1465 SourceLocation WhileLoc, SourceLocation LParenLoc,
1466 Expr *Cond, SourceLocation RParenLoc) {
1467 return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1468 Cond, RParenLoc);
1469 }
1470
1471 /// Build a new for statement.
1472 ///
1473 /// By default, performs semantic analysis to build the new statement.
1474 /// Subclasses may override this routine to provide different behavior.
1477 Sema::FullExprArg Inc, SourceLocation RParenLoc,
1478 Stmt *Body) {
1479 return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1480 Inc, RParenLoc, Body);
1481 }
1482
1483 /// Build a new goto statement.
1484 ///
1485 /// By default, performs semantic analysis to build the new statement.
1486 /// Subclasses may override this routine to provide different behavior.
1488 LabelDecl *Label) {
1489 return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1490 }
1491
1492 /// Build a new indirect goto statement.
1493 ///
1494 /// By default, performs semantic analysis to build the new statement.
1495 /// Subclasses may override this routine to provide different behavior.
1497 SourceLocation StarLoc,
1498 Expr *Target) {
1499 return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1500 }
1501
1502 /// Build a new return statement.
1503 ///
1504 /// By default, performs semantic analysis to build the new statement.
1505 /// Subclasses may override this routine to provide different behavior.
1507 return getSema().BuildReturnStmt(ReturnLoc, Result);
1508 }
1509
1510 /// Build a new declaration statement.
1511 ///
1512 /// By default, performs semantic analysis to build the new statement.
1513 /// Subclasses may override this routine to provide different behavior.
1515 SourceLocation StartLoc, SourceLocation EndLoc) {
1517 return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1518 }
1519
1520 /// Build a new inline asm statement.
1521 ///
1522 /// By default, performs semantic analysis to build the new statement.
1523 /// Subclasses may override this routine to provide different behavior.
1525 bool IsVolatile, unsigned NumOutputs,
1526 unsigned NumInputs, IdentifierInfo **Names,
1527 MultiExprArg Constraints, MultiExprArg Exprs,
1528 Expr *AsmString, MultiExprArg Clobbers,
1529 unsigned NumLabels,
1530 SourceLocation RParenLoc) {
1531 return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1532 NumInputs, Names, Constraints, Exprs,
1533 AsmString, Clobbers, NumLabels, RParenLoc);
1534 }
1535
1536 /// Build a new MS style inline asm statement.
1537 ///
1538 /// By default, performs semantic analysis to build the new statement.
1539 /// Subclasses may override this routine to provide different behavior.
1541 ArrayRef<Token> AsmToks,
1542 StringRef AsmString,
1543 unsigned NumOutputs, unsigned NumInputs,
1544 ArrayRef<StringRef> Constraints,
1545 ArrayRef<StringRef> Clobbers,
1546 ArrayRef<Expr*> Exprs,
1547 SourceLocation EndLoc) {
1548 return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1549 NumOutputs, NumInputs,
1550 Constraints, Clobbers, Exprs, EndLoc);
1551 }
1552
1553 /// Build a new co_return statement.
1554 ///
1555 /// By default, performs semantic analysis to build the new statement.
1556 /// Subclasses may override this routine to provide different behavior.
1558 bool IsImplicit) {
1559 return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1560 }
1561
1562 /// Build a new co_await expression.
1563 ///
1564 /// By default, performs semantic analysis to build the new expression.
1565 /// Subclasses may override this routine to provide different behavior.
1567 UnresolvedLookupExpr *OpCoawaitLookup,
1568 bool IsImplicit) {
1569 // This function rebuilds a coawait-expr given its operator.
1570 // For an explicit coawait-expr, the rebuild involves the full set
1571 // of transformations performed by BuildUnresolvedCoawaitExpr(),
1572 // including calling await_transform().
1573 // For an implicit coawait-expr, we need to rebuild the "operator
1574 // coawait" but not await_transform(), so use BuildResolvedCoawaitExpr().
1575 // This mirrors how the implicit CoawaitExpr is originally created
1576 // in Sema::ActOnCoroutineBodyStart().
1577 if (IsImplicit) {
1579 CoawaitLoc, Operand, OpCoawaitLookup);
1580 if (Suspend.isInvalid())
1581 return ExprError();
1582 return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Operand,
1583 Suspend.get(), true);
1584 }
1585
1586 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Operand,
1587 OpCoawaitLookup);
1588 }
1589
1590 /// Build a new co_await expression.
1591 ///
1592 /// By default, performs semantic analysis to build the new expression.
1593 /// Subclasses may override this routine to provide different behavior.
1595 Expr *Result,
1596 UnresolvedLookupExpr *Lookup) {
1597 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1598 }
1599
1600 /// Build a new co_yield expression.
1601 ///
1602 /// By default, performs semantic analysis to build the new expression.
1603 /// Subclasses may override this routine to provide different behavior.
1605 return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1606 }
1607
1611
1612 /// Build a new Objective-C \@try statement.
1613 ///
1614 /// By default, performs semantic analysis to build the new statement.
1615 /// Subclasses may override this routine to provide different behavior.
1617 Stmt *TryBody,
1618 MultiStmtArg CatchStmts,
1619 Stmt *Finally) {
1620 return getSema().ObjC().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1621 Finally);
1622 }
1623
1624 /// Rebuild an Objective-C exception declaration.
1625 ///
1626 /// By default, performs semantic analysis to build the new declaration.
1627 /// Subclasses may override this routine to provide different behavior.
1629 TypeSourceInfo *TInfo, QualType T) {
1631 TInfo, T, ExceptionDecl->getInnerLocStart(),
1632 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
1633 }
1634
1635 /// Build a new Objective-C \@catch statement.
1636 ///
1637 /// By default, performs semantic analysis to build the new statement.
1638 /// Subclasses may override this routine to provide different behavior.
1640 SourceLocation RParenLoc,
1641 VarDecl *Var,
1642 Stmt *Body) {
1643 return getSema().ObjC().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, Var, Body);
1644 }
1645
1646 /// Build a new Objective-C \@finally statement.
1647 ///
1648 /// By default, performs semantic analysis to build the new statement.
1649 /// Subclasses may override this routine to provide different behavior.
1651 Stmt *Body) {
1652 return getSema().ObjC().ActOnObjCAtFinallyStmt(AtLoc, Body);
1653 }
1654
1655 /// Build a new Objective-C \@throw statement.
1656 ///
1657 /// By default, performs semantic analysis to build the new statement.
1658 /// Subclasses may override this routine to provide different behavior.
1660 Expr *Operand) {
1661 return getSema().ObjC().BuildObjCAtThrowStmt(AtLoc, Operand);
1662 }
1663
1664 /// Build a new OpenMP Canonical loop.
1665 ///
1666 /// Ensures that the outermost loop in @p LoopStmt is wrapped by a
1667 /// OMPCanonicalLoop.
1669 return getSema().OpenMP().ActOnOpenMPCanonicalLoop(LoopStmt);
1670 }
1671
1672 /// Build a new OpenMP executable directive.
1673 ///
1674 /// By default, performs semantic analysis to build the new statement.
1675 /// Subclasses may override this routine to provide different behavior.
1677 DeclarationNameInfo DirName,
1678 OpenMPDirectiveKind CancelRegion,
1679 ArrayRef<OMPClause *> Clauses,
1680 Stmt *AStmt, SourceLocation StartLoc,
1681 SourceLocation EndLoc) {
1682
1684 Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1685 }
1686
1687 /// Build a new OpenMP informational directive.
1689 DeclarationNameInfo DirName,
1690 ArrayRef<OMPClause *> Clauses,
1691 Stmt *AStmt,
1692 SourceLocation StartLoc,
1693 SourceLocation EndLoc) {
1694
1696 Kind, DirName, Clauses, AStmt, StartLoc, EndLoc);
1697 }
1698
1699 /// Build a new OpenMP 'if' clause.
1700 ///
1701 /// By default, performs semantic analysis to build the new OpenMP clause.
1702 /// Subclasses may override this routine to provide different behavior.
1704 Expr *Condition, SourceLocation StartLoc,
1705 SourceLocation LParenLoc,
1706 SourceLocation NameModifierLoc,
1707 SourceLocation ColonLoc,
1708 SourceLocation EndLoc) {
1710 NameModifier, Condition, StartLoc, LParenLoc, NameModifierLoc, ColonLoc,
1711 EndLoc);
1712 }
1713
1714 /// Build a new OpenMP 'final' clause.
1715 ///
1716 /// By default, performs semantic analysis to build the new OpenMP clause.
1717 /// Subclasses may override this routine to provide different behavior.
1719 SourceLocation LParenLoc,
1720 SourceLocation EndLoc) {
1721 return getSema().OpenMP().ActOnOpenMPFinalClause(Condition, StartLoc,
1722 LParenLoc, EndLoc);
1723 }
1724
1725 /// Build a new OpenMP 'num_threads' clause.
1726 ///
1727 /// By default, performs semantic analysis to build the new OpenMP clause.
1728 /// Subclasses may override this routine to provide different behavior.
1730 Expr *NumThreads,
1731 SourceLocation StartLoc,
1732 SourceLocation LParenLoc,
1733 SourceLocation ModifierLoc,
1734 SourceLocation EndLoc) {
1736 Modifier, NumThreads, StartLoc, LParenLoc, ModifierLoc, EndLoc);
1737 }
1738
1739 /// Build a new OpenMP 'safelen' clause.
1740 ///
1741 /// By default, performs semantic analysis to build the new OpenMP clause.
1742 /// Subclasses may override this routine to provide different behavior.
1744 SourceLocation LParenLoc,
1745 SourceLocation EndLoc) {
1746 return getSema().OpenMP().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc,
1747 EndLoc);
1748 }
1749
1750 /// Build a new OpenMP 'simdlen' clause.
1751 ///
1752 /// By default, performs semantic analysis to build the new OpenMP clause.
1753 /// Subclasses may override this routine to provide different behavior.
1755 SourceLocation LParenLoc,
1756 SourceLocation EndLoc) {
1757 return getSema().OpenMP().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc,
1758 EndLoc);
1759 }
1760
1762 SourceLocation StartLoc,
1763 SourceLocation LParenLoc,
1764 SourceLocation EndLoc) {
1765 return getSema().OpenMP().ActOnOpenMPSizesClause(Sizes, StartLoc, LParenLoc,
1766 EndLoc);
1767 }
1768
1769 /// Build a new OpenMP 'permutation' clause.
1771 SourceLocation StartLoc,
1772 SourceLocation LParenLoc,
1773 SourceLocation EndLoc) {
1774 return getSema().OpenMP().ActOnOpenMPPermutationClause(PermExprs, StartLoc,
1775 LParenLoc, EndLoc);
1776 }
1777
1778 /// Build a new OpenMP 'full' clause.
1780 SourceLocation EndLoc) {
1781 return getSema().OpenMP().ActOnOpenMPFullClause(StartLoc, EndLoc);
1782 }
1783
1784 /// Build a new OpenMP 'partial' clause.
1786 SourceLocation LParenLoc,
1787 SourceLocation EndLoc) {
1788 return getSema().OpenMP().ActOnOpenMPPartialClause(Factor, StartLoc,
1789 LParenLoc, EndLoc);
1790 }
1791
1792 OMPClause *
1794 SourceLocation LParenLoc, SourceLocation FirstLoc,
1795 SourceLocation CountLoc, SourceLocation EndLoc) {
1797 First, Count, StartLoc, LParenLoc, FirstLoc, CountLoc, EndLoc);
1798 }
1799
1800 /// Build a new OpenMP 'allocator' clause.
1801 ///
1802 /// By default, performs semantic analysis to build the new OpenMP clause.
1803 /// Subclasses may override this routine to provide different behavior.
1805 SourceLocation LParenLoc,
1806 SourceLocation EndLoc) {
1807 return getSema().OpenMP().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc,
1808 EndLoc);
1809 }
1810
1811 /// Build a new OpenMP 'collapse' clause.
1812 ///
1813 /// By default, performs semantic analysis to build the new OpenMP clause.
1814 /// Subclasses may override this routine to provide different behavior.
1816 SourceLocation LParenLoc,
1817 SourceLocation EndLoc) {
1818 return getSema().OpenMP().ActOnOpenMPCollapseClause(Num, StartLoc,
1819 LParenLoc, EndLoc);
1820 }
1821
1822 /// Build a new OpenMP 'default' clause.
1823 ///
1824 /// By default, performs semantic analysis to build the new OpenMP clause.
1825 /// Subclasses may override this routine to provide different behavior.
1828 SourceLocation VCLoc,
1829 SourceLocation StartLoc,
1830 SourceLocation LParenLoc,
1831 SourceLocation EndLoc) {
1833 Kind, KindKwLoc, VCKind, VCLoc, StartLoc, LParenLoc, EndLoc);
1834 }
1835
1836 /// Build a new OpenMP 'proc_bind' clause.
1837 ///
1838 /// By default, performs semantic analysis to build the new OpenMP clause.
1839 /// Subclasses may override this routine to provide different behavior.
1841 SourceLocation KindKwLoc,
1842 SourceLocation StartLoc,
1843 SourceLocation LParenLoc,
1844 SourceLocation EndLoc) {
1846 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1847 }
1848
1849 /// Build a new OpenMP 'schedule' clause.
1850 ///
1851 /// By default, performs semantic analysis to build the new OpenMP clause.
1852 /// Subclasses may override this routine to provide different behavior.
1855 OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1856 SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1857 SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1859 M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1860 CommaLoc, EndLoc);
1861 }
1862
1863 /// Build a new OpenMP 'ordered' clause.
1864 ///
1865 /// By default, performs semantic analysis to build the new OpenMP clause.
1866 /// Subclasses may override this routine to provide different behavior.
1868 SourceLocation EndLoc,
1869 SourceLocation LParenLoc, Expr *Num) {
1870 return getSema().OpenMP().ActOnOpenMPOrderedClause(StartLoc, EndLoc,
1871 LParenLoc, Num);
1872 }
1873
1874 /// Build a new OpenMP 'nowait' clause.
1875 ///
1876 /// By default, performs semantic analysis to build the new OpenMP clause.
1877 /// Subclasses may override this routine to provide different behavior.
1879 SourceLocation LParenLoc,
1880 SourceLocation EndLoc) {
1881 return getSema().OpenMP().ActOnOpenMPNowaitClause(StartLoc, EndLoc,
1882 LParenLoc, Condition);
1883 }
1884
1885 /// Build a new OpenMP 'private' 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 StartLoc,
1891 SourceLocation LParenLoc,
1892 SourceLocation EndLoc) {
1893 return getSema().OpenMP().ActOnOpenMPPrivateClause(VarList, StartLoc,
1894 LParenLoc, EndLoc);
1895 }
1896
1897 /// Build a new OpenMP 'firstprivate' clause.
1898 ///
1899 /// By default, performs semantic analysis to build the new OpenMP clause.
1900 /// Subclasses may override this routine to provide different behavior.
1902 SourceLocation StartLoc,
1903 SourceLocation LParenLoc,
1904 SourceLocation EndLoc) {
1905 return getSema().OpenMP().ActOnOpenMPFirstprivateClause(VarList, StartLoc,
1906 LParenLoc, EndLoc);
1907 }
1908
1909 /// Build a new OpenMP 'lastprivate' clause.
1910 ///
1911 /// By default, performs semantic analysis to build the new OpenMP clause.
1912 /// Subclasses may override this routine to provide different behavior.
1915 SourceLocation LPKindLoc,
1916 SourceLocation ColonLoc,
1917 SourceLocation StartLoc,
1918 SourceLocation LParenLoc,
1919 SourceLocation EndLoc) {
1921 VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1922 }
1923
1924 /// Build a new OpenMP 'shared' clause.
1925 ///
1926 /// By default, performs semantic analysis to build the new OpenMP clause.
1927 /// Subclasses may override this routine to provide different behavior.
1929 SourceLocation StartLoc,
1930 SourceLocation LParenLoc,
1931 SourceLocation EndLoc) {
1932 return getSema().OpenMP().ActOnOpenMPSharedClause(VarList, StartLoc,
1933 LParenLoc, EndLoc);
1934 }
1935
1936 /// Build a new OpenMP 'reduction' clause.
1937 ///
1938 /// By default, performs semantic analysis to build the new statement.
1939 /// Subclasses may override this routine to provide different behavior.
1942 OpenMPOriginalSharingModifier OriginalSharingModifier,
1943 SourceLocation StartLoc, SourceLocation LParenLoc,
1944 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1945 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
1946 const DeclarationNameInfo &ReductionId,
1947 ArrayRef<Expr *> UnresolvedReductions) {
1949 VarList, {Modifier, OriginalSharingModifier}, StartLoc, LParenLoc,
1950 ModifierLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, ReductionId,
1951 UnresolvedReductions);
1952 }
1953
1954 /// Build a new OpenMP 'task_reduction' clause.
1955 ///
1956 /// By default, performs semantic analysis to build the new statement.
1957 /// Subclasses may override this routine to provide different behavior.
1959 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1960 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
1961 CXXScopeSpec &ReductionIdScopeSpec,
1962 const DeclarationNameInfo &ReductionId,
1963 ArrayRef<Expr *> UnresolvedReductions) {
1965 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1966 ReductionId, UnresolvedReductions);
1967 }
1968
1969 /// Build a new OpenMP 'in_reduction' clause.
1970 ///
1971 /// By default, performs semantic analysis to build the new statement.
1972 /// Subclasses may override this routine to provide different behavior.
1973 OMPClause *
1975 SourceLocation LParenLoc, SourceLocation ColonLoc,
1976 SourceLocation EndLoc,
1977 CXXScopeSpec &ReductionIdScopeSpec,
1978 const DeclarationNameInfo &ReductionId,
1979 ArrayRef<Expr *> UnresolvedReductions) {
1981 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1982 ReductionId, UnresolvedReductions);
1983 }
1984
1985 /// Build a new OpenMP 'linear' clause.
1986 ///
1987 /// By default, performs semantic analysis to build the new OpenMP clause.
1988 /// Subclasses may override this routine to provide different behavior.
1990 ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc,
1991 SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier,
1992 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1993 SourceLocation StepModifierLoc, SourceLocation EndLoc) {
1995 VarList, Step, StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc,
1996 StepModifierLoc, EndLoc);
1997 }
1998
1999 /// Build a new OpenMP 'aligned' clause.
2000 ///
2001 /// By default, performs semantic analysis to build the new OpenMP clause.
2002 /// Subclasses may override this routine to provide different behavior.
2004 SourceLocation StartLoc,
2005 SourceLocation LParenLoc,
2006 SourceLocation ColonLoc,
2007 SourceLocation EndLoc) {
2009 VarList, Alignment, StartLoc, LParenLoc, ColonLoc, EndLoc);
2010 }
2011
2012 /// Build a new OpenMP 'copyin' clause.
2013 ///
2014 /// By default, performs semantic analysis to build the new OpenMP clause.
2015 /// Subclasses may override this routine to provide different behavior.
2017 SourceLocation StartLoc,
2018 SourceLocation LParenLoc,
2019 SourceLocation EndLoc) {
2020 return getSema().OpenMP().ActOnOpenMPCopyinClause(VarList, StartLoc,
2021 LParenLoc, EndLoc);
2022 }
2023
2024 /// Build a new OpenMP 'copyprivate' clause.
2025 ///
2026 /// By default, performs semantic analysis to build the new OpenMP clause.
2027 /// Subclasses may override this routine to provide different behavior.
2029 SourceLocation StartLoc,
2030 SourceLocation LParenLoc,
2031 SourceLocation EndLoc) {
2032 return getSema().OpenMP().ActOnOpenMPCopyprivateClause(VarList, StartLoc,
2033 LParenLoc, EndLoc);
2034 }
2035
2036 /// Build a new OpenMP 'flush' pseudo clause.
2037 ///
2038 /// By default, performs semantic analysis to build the new OpenMP clause.
2039 /// Subclasses may override this routine to provide different behavior.
2041 SourceLocation StartLoc,
2042 SourceLocation LParenLoc,
2043 SourceLocation EndLoc) {
2044 return getSema().OpenMP().ActOnOpenMPFlushClause(VarList, StartLoc,
2045 LParenLoc, EndLoc);
2046 }
2047
2048 /// Build a new OpenMP 'depobj' pseudo clause.
2049 ///
2050 /// By default, performs semantic analysis to build the new OpenMP clause.
2051 /// Subclasses may override this routine to provide different behavior.
2053 SourceLocation LParenLoc,
2054 SourceLocation EndLoc) {
2055 return getSema().OpenMP().ActOnOpenMPDepobjClause(Depobj, StartLoc,
2056 LParenLoc, EndLoc);
2057 }
2058
2059 /// Build a new OpenMP 'depend' pseudo clause.
2060 ///
2061 /// By default, performs semantic analysis to build the new OpenMP clause.
2062 /// Subclasses may override this routine to provide different behavior.
2064 Expr *DepModifier, ArrayRef<Expr *> VarList,
2065 SourceLocation StartLoc,
2066 SourceLocation LParenLoc,
2067 SourceLocation EndLoc) {
2069 Data, DepModifier, VarList, StartLoc, LParenLoc, EndLoc);
2070 }
2071
2072 /// Build a new OpenMP 'device' clause.
2073 ///
2074 /// By default, performs semantic analysis to build the new statement.
2075 /// Subclasses may override this routine to provide different behavior.
2077 Expr *Device, SourceLocation StartLoc,
2078 SourceLocation LParenLoc,
2079 SourceLocation ModifierLoc,
2080 SourceLocation EndLoc) {
2082 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2083 }
2084
2085 /// Build a new OpenMP 'map' clause.
2086 ///
2087 /// By default, performs semantic analysis to build the new OpenMP clause.
2088 /// Subclasses may override this routine to provide different behavior.
2090 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
2091 ArrayRef<SourceLocation> MapTypeModifiersLoc,
2092 CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId,
2093 OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
2094 SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
2095 const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) {
2097 IteratorModifier, MapTypeModifiers, MapTypeModifiersLoc,
2098 MapperIdScopeSpec, MapperId, MapType, IsMapTypeImplicit, MapLoc,
2099 ColonLoc, VarList, Locs,
2100 /*NoDiagnose=*/false, UnresolvedMappers);
2101 }
2102
2103 /// Build a new OpenMP 'allocate' clause.
2104 ///
2105 /// By default, performs semantic analysis to build the new OpenMP clause.
2106 /// Subclasses may override this routine to provide different behavior.
2107 OMPClause *
2108 RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment,
2109 OpenMPAllocateClauseModifier FirstModifier,
2110 SourceLocation FirstModifierLoc,
2111 OpenMPAllocateClauseModifier SecondModifier,
2112 SourceLocation SecondModifierLoc,
2113 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2114 SourceLocation LParenLoc, SourceLocation ColonLoc,
2115 SourceLocation EndLoc) {
2117 Allocate, Alignment, FirstModifier, FirstModifierLoc, SecondModifier,
2118 SecondModifierLoc, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc);
2119 }
2120
2121 /// Build a new OpenMP 'num_teams' clause.
2122 ///
2123 /// By default, performs semantic analysis to build the new statement.
2124 /// Subclasses may override this routine to provide different behavior.
2126 SourceLocation StartLoc,
2127 SourceLocation LParenLoc,
2128 SourceLocation EndLoc) {
2129 return getSema().OpenMP().ActOnOpenMPNumTeamsClause(VarList, StartLoc,
2130 LParenLoc, EndLoc);
2131 }
2132
2133 /// Build a new OpenMP 'thread_limit' clause.
2134 ///
2135 /// By default, performs semantic analysis to build the new statement.
2136 /// Subclasses may override this routine to provide different behavior.
2138 SourceLocation StartLoc,
2139 SourceLocation LParenLoc,
2140 SourceLocation EndLoc) {
2141 return getSema().OpenMP().ActOnOpenMPThreadLimitClause(VarList, StartLoc,
2142 LParenLoc, EndLoc);
2143 }
2144
2145 /// Build a new OpenMP 'priority' clause.
2146 ///
2147 /// By default, performs semantic analysis to build the new statement.
2148 /// Subclasses may override this routine to provide different behavior.
2150 SourceLocation LParenLoc,
2151 SourceLocation EndLoc) {
2152 return getSema().OpenMP().ActOnOpenMPPriorityClause(Priority, StartLoc,
2153 LParenLoc, EndLoc);
2154 }
2155
2156 /// Build a new OpenMP 'grainsize' clause.
2157 ///
2158 /// By default, performs semantic analysis to build the new statement.
2159 /// Subclasses may override this routine to provide different behavior.
2161 Expr *Device, SourceLocation StartLoc,
2162 SourceLocation LParenLoc,
2163 SourceLocation ModifierLoc,
2164 SourceLocation EndLoc) {
2166 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2167 }
2168
2169 /// Build a new OpenMP 'num_tasks' clause.
2170 ///
2171 /// By default, performs semantic analysis to build the new statement.
2172 /// Subclasses may override this routine to provide different behavior.
2174 Expr *NumTasks, SourceLocation StartLoc,
2175 SourceLocation LParenLoc,
2176 SourceLocation ModifierLoc,
2177 SourceLocation EndLoc) {
2179 Modifier, NumTasks, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2180 }
2181
2182 /// Build a new OpenMP 'hint' clause.
2183 ///
2184 /// By default, performs semantic analysis to build the new statement.
2185 /// Subclasses may override this routine to provide different behavior.
2187 SourceLocation LParenLoc,
2188 SourceLocation EndLoc) {
2189 return getSema().OpenMP().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc,
2190 EndLoc);
2191 }
2192
2193 /// Build a new OpenMP 'detach' clause.
2194 ///
2195 /// By default, performs semantic analysis to build the new statement.
2196 /// Subclasses may override this routine to provide different behavior.
2198 SourceLocation LParenLoc,
2199 SourceLocation EndLoc) {
2200 return getSema().OpenMP().ActOnOpenMPDetachClause(Evt, StartLoc, LParenLoc,
2201 EndLoc);
2202 }
2203
2204 /// Build a new OpenMP 'dist_schedule' clause.
2205 ///
2206 /// By default, performs semantic analysis to build the new OpenMP clause.
2207 /// Subclasses may override this routine to provide different behavior.
2208 OMPClause *
2210 Expr *ChunkSize, SourceLocation StartLoc,
2211 SourceLocation LParenLoc, SourceLocation KindLoc,
2212 SourceLocation CommaLoc, SourceLocation EndLoc) {
2214 Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
2215 }
2216
2217 /// Build a new OpenMP 'to' clause.
2218 ///
2219 /// By default, performs semantic analysis to build the new statement.
2220 /// Subclasses may override this routine to provide different behavior.
2221 OMPClause *
2223 ArrayRef<SourceLocation> MotionModifiersLoc,
2224 CXXScopeSpec &MapperIdScopeSpec,
2225 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2226 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2227 ArrayRef<Expr *> UnresolvedMappers) {
2229 MotionModifiers, MotionModifiersLoc, MapperIdScopeSpec, MapperId,
2230 ColonLoc, VarList, Locs, UnresolvedMappers);
2231 }
2232
2233 /// Build a new OpenMP 'from' clause.
2234 ///
2235 /// By default, performs semantic analysis to build the new statement.
2236 /// Subclasses may override this routine to provide different behavior.
2237 OMPClause *
2239 ArrayRef<SourceLocation> MotionModifiersLoc,
2240 CXXScopeSpec &MapperIdScopeSpec,
2241 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2242 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2243 ArrayRef<Expr *> UnresolvedMappers) {
2245 MotionModifiers, MotionModifiersLoc, MapperIdScopeSpec, MapperId,
2246 ColonLoc, VarList, Locs, UnresolvedMappers);
2247 }
2248
2249 /// Build a new OpenMP 'use_device_ptr' clause.
2250 ///
2251 /// By default, performs semantic analysis to build the new OpenMP clause.
2252 /// Subclasses may override this routine to provide different behavior.
2254 const OMPVarListLocTy &Locs) {
2255 return getSema().OpenMP().ActOnOpenMPUseDevicePtrClause(VarList, Locs);
2256 }
2257
2258 /// Build a new OpenMP 'use_device_addr' clause.
2259 ///
2260 /// By default, performs semantic analysis to build the new OpenMP clause.
2261 /// Subclasses may override this routine to provide different behavior.
2266
2267 /// Build a new OpenMP 'is_device_ptr' clause.
2268 ///
2269 /// By default, performs semantic analysis to build the new OpenMP clause.
2270 /// Subclasses may override this routine to provide different behavior.
2272 const OMPVarListLocTy &Locs) {
2273 return getSema().OpenMP().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
2274 }
2275
2276 /// Build a new OpenMP 'has_device_addr' clause.
2277 ///
2278 /// By default, performs semantic analysis to build the new OpenMP clause.
2279 /// Subclasses may override this routine to provide different behavior.
2284
2285 /// Build a new OpenMP 'defaultmap' clause.
2286 ///
2287 /// By default, performs semantic analysis to build the new OpenMP clause.
2288 /// Subclasses may override this routine to provide different behavior.
2291 SourceLocation StartLoc,
2292 SourceLocation LParenLoc,
2293 SourceLocation MLoc,
2294 SourceLocation KindLoc,
2295 SourceLocation EndLoc) {
2297 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2298 }
2299
2300 /// Build a new OpenMP 'nontemporal' clause.
2301 ///
2302 /// By default, performs semantic analysis to build the new OpenMP clause.
2303 /// Subclasses may override this routine to provide different behavior.
2305 SourceLocation StartLoc,
2306 SourceLocation LParenLoc,
2307 SourceLocation EndLoc) {
2308 return getSema().OpenMP().ActOnOpenMPNontemporalClause(VarList, StartLoc,
2309 LParenLoc, EndLoc);
2310 }
2311
2312 /// Build a new OpenMP 'inclusive' clause.
2313 ///
2314 /// By default, performs semantic analysis to build the new OpenMP clause.
2315 /// Subclasses may override this routine to provide different behavior.
2317 SourceLocation StartLoc,
2318 SourceLocation LParenLoc,
2319 SourceLocation EndLoc) {
2320 return getSema().OpenMP().ActOnOpenMPInclusiveClause(VarList, StartLoc,
2321 LParenLoc, EndLoc);
2322 }
2323
2324 /// Build a new OpenMP 'exclusive' clause.
2325 ///
2326 /// By default, performs semantic analysis to build the new OpenMP clause.
2327 /// Subclasses may override this routine to provide different behavior.
2329 SourceLocation StartLoc,
2330 SourceLocation LParenLoc,
2331 SourceLocation EndLoc) {
2332 return getSema().OpenMP().ActOnOpenMPExclusiveClause(VarList, StartLoc,
2333 LParenLoc, EndLoc);
2334 }
2335
2336 /// Build a new OpenMP 'uses_allocators' clause.
2337 ///
2338 /// By default, performs semantic analysis to build the new OpenMP clause.
2339 /// Subclasses may override this routine to provide different behavior.
2346
2347 /// Build a new OpenMP 'affinity' clause.
2348 ///
2349 /// By default, performs semantic analysis to build the new OpenMP clause.
2350 /// Subclasses may override this routine to provide different behavior.
2352 SourceLocation LParenLoc,
2353 SourceLocation ColonLoc,
2354 SourceLocation EndLoc, Expr *Modifier,
2355 ArrayRef<Expr *> Locators) {
2357 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2358 }
2359
2360 /// Build a new OpenMP 'order' clause.
2361 ///
2362 /// By default, performs semantic analysis to build the new OpenMP clause.
2363 /// Subclasses may override this routine to provide different behavior.
2365 OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc,
2366 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
2367 OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc) {
2369 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2370 }
2371
2372 /// Build a new OpenMP 'init' clause.
2373 ///
2374 /// By default, performs semantic analysis to build the new OpenMP clause.
2375 /// Subclasses may override this routine to provide different behavior.
2377 SourceLocation StartLoc,
2378 SourceLocation LParenLoc,
2379 SourceLocation VarLoc,
2380 SourceLocation EndLoc) {
2382 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2383 }
2384
2385 /// Build a new OpenMP 'use' clause.
2386 ///
2387 /// By default, performs semantic analysis to build the new OpenMP clause.
2388 /// Subclasses may override this routine to provide different behavior.
2390 SourceLocation LParenLoc,
2391 SourceLocation VarLoc, SourceLocation EndLoc) {
2392 return getSema().OpenMP().ActOnOpenMPUseClause(InteropVar, StartLoc,
2393 LParenLoc, VarLoc, EndLoc);
2394 }
2395
2396 /// Build a new OpenMP 'destroy' clause.
2397 ///
2398 /// By default, performs semantic analysis to build the new OpenMP clause.
2399 /// Subclasses may override this routine to provide different behavior.
2401 SourceLocation LParenLoc,
2402 SourceLocation VarLoc,
2403 SourceLocation EndLoc) {
2405 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2406 }
2407
2408 /// Build a new OpenMP 'novariants' clause.
2409 ///
2410 /// By default, performs semantic analysis to build the new OpenMP clause.
2411 /// Subclasses may override this routine to provide different behavior.
2413 SourceLocation StartLoc,
2414 SourceLocation LParenLoc,
2415 SourceLocation EndLoc) {
2417 LParenLoc, EndLoc);
2418 }
2419
2420 /// Build a new OpenMP 'nocontext' clause.
2421 ///
2422 /// By default, performs semantic analysis to build the new OpenMP clause.
2423 /// Subclasses may override this routine to provide different behavior.
2425 SourceLocation LParenLoc,
2426 SourceLocation EndLoc) {
2428 LParenLoc, EndLoc);
2429 }
2430
2431 /// Build a new OpenMP 'filter' clause.
2432 ///
2433 /// By default, performs semantic analysis to build the new OpenMP clause.
2434 /// Subclasses may override this routine to provide different behavior.
2436 SourceLocation LParenLoc,
2437 SourceLocation EndLoc) {
2438 return getSema().OpenMP().ActOnOpenMPFilterClause(ThreadID, StartLoc,
2439 LParenLoc, EndLoc);
2440 }
2441
2442 /// Build a new OpenMP 'bind' clause.
2443 ///
2444 /// By default, performs semantic analysis to build the new OpenMP clause.
2445 /// Subclasses may override this routine to provide different behavior.
2447 SourceLocation KindLoc,
2448 SourceLocation StartLoc,
2449 SourceLocation LParenLoc,
2450 SourceLocation EndLoc) {
2451 return getSema().OpenMP().ActOnOpenMPBindClause(Kind, KindLoc, StartLoc,
2452 LParenLoc, EndLoc);
2453 }
2454
2455 /// Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
2456 ///
2457 /// By default, performs semantic analysis to build the new OpenMP clause.
2458 /// Subclasses may override this routine to provide different behavior.
2460 SourceLocation LParenLoc,
2461 SourceLocation EndLoc) {
2462 return getSema().OpenMP().ActOnOpenMPXDynCGroupMemClause(Size, StartLoc,
2463 LParenLoc, EndLoc);
2464 }
2465
2466 /// Build a new OpenMP 'dyn_groupprivate' clause.
2467 ///
2468 /// By default, performs semantic analysis to build the new OpenMP clause.
2469 /// Subclasses may override this routine to provide different behavior.
2473 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc,
2474 SourceLocation M2Loc, SourceLocation EndLoc) {
2476 M1, M2, Size, StartLoc, LParenLoc, M1Loc, M2Loc, EndLoc);
2477 }
2478
2479 /// Build a new OpenMP 'ompx_attribute' clause.
2480 ///
2481 /// By default, performs semantic analysis to build the new OpenMP clause.
2482 /// Subclasses may override this routine to provide different behavior.
2484 SourceLocation StartLoc,
2485 SourceLocation LParenLoc,
2486 SourceLocation EndLoc) {
2487 return getSema().OpenMP().ActOnOpenMPXAttributeClause(Attrs, StartLoc,
2488 LParenLoc, EndLoc);
2489 }
2490
2491 /// Build a new OpenMP 'ompx_bare' clause.
2492 ///
2493 /// By default, performs semantic analysis to build the new OpenMP clause.
2494 /// Subclasses may override this routine to provide different behavior.
2496 SourceLocation EndLoc) {
2497 return getSema().OpenMP().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2498 }
2499
2500 /// Build a new OpenMP 'align' clause.
2501 ///
2502 /// By default, performs semantic analysis to build the new OpenMP clause.
2503 /// Subclasses may override this routine to provide different behavior.
2505 SourceLocation LParenLoc,
2506 SourceLocation EndLoc) {
2507 return getSema().OpenMP().ActOnOpenMPAlignClause(A, StartLoc, LParenLoc,
2508 EndLoc);
2509 }
2510
2511 /// Build a new OpenMP 'at' clause.
2512 ///
2513 /// By default, performs semantic analysis to build the new OpenMP clause.
2514 /// Subclasses may override this routine to provide different behavior.
2516 SourceLocation StartLoc,
2517 SourceLocation LParenLoc,
2518 SourceLocation EndLoc) {
2519 return getSema().OpenMP().ActOnOpenMPAtClause(Kind, KwLoc, StartLoc,
2520 LParenLoc, EndLoc);
2521 }
2522
2523 /// Build a new OpenMP 'severity' clause.
2524 ///
2525 /// By default, performs semantic analysis to build the new OpenMP clause.
2526 /// Subclasses may override this routine to provide different behavior.
2528 SourceLocation KwLoc,
2529 SourceLocation StartLoc,
2530 SourceLocation LParenLoc,
2531 SourceLocation EndLoc) {
2532 return getSema().OpenMP().ActOnOpenMPSeverityClause(Kind, KwLoc, StartLoc,
2533 LParenLoc, EndLoc);
2534 }
2535
2536 /// Build a new OpenMP 'message' clause.
2537 ///
2538 /// By default, performs semantic analysis to build the new OpenMP clause.
2539 /// Subclasses may override this routine to provide different behavior.
2541 SourceLocation LParenLoc,
2542 SourceLocation EndLoc) {
2543 return getSema().OpenMP().ActOnOpenMPMessageClause(MS, StartLoc, LParenLoc,
2544 EndLoc);
2545 }
2546
2547 /// Build a new OpenMP 'doacross' clause.
2548 ///
2549 /// By default, performs semantic analysis to build the new OpenMP clause.
2550 /// Subclasses may override this routine to provide different behavior.
2551 OMPClause *
2553 SourceLocation DepLoc, SourceLocation ColonLoc,
2554 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2555 SourceLocation LParenLoc, SourceLocation EndLoc) {
2557 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2558 }
2559
2560 /// Build a new OpenMP 'holds' clause.
2562 SourceLocation LParenLoc,
2563 SourceLocation EndLoc) {
2564 return getSema().OpenMP().ActOnOpenMPHoldsClause(A, StartLoc, LParenLoc,
2565 EndLoc);
2566 }
2567
2568 /// Rebuild the operand to an Objective-C \@synchronized statement.
2569 ///
2570 /// By default, performs semantic analysis to build the new statement.
2571 /// Subclasses may override this routine to provide different behavior.
2576
2577 /// Build a new Objective-C \@synchronized statement.
2578 ///
2579 /// By default, performs semantic analysis to build the new statement.
2580 /// Subclasses may override this routine to provide different behavior.
2582 Expr *Object, Stmt *Body) {
2583 return getSema().ObjC().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
2584 }
2585
2586 /// Build a new Objective-C \@autoreleasepool statement.
2587 ///
2588 /// By default, performs semantic analysis to build the new statement.
2589 /// Subclasses may override this routine to provide different behavior.
2594
2595 /// Build a new Objective-C fast enumeration statement.
2596 ///
2597 /// By default, performs semantic analysis to build the new statement.
2598 /// Subclasses may override this routine to provide different behavior.
2600 Stmt *Element,
2601 Expr *Collection,
2602 SourceLocation RParenLoc,
2603 Stmt *Body) {
2605 ForLoc, Element, Collection, RParenLoc);
2606 if (ForEachStmt.isInvalid())
2607 return StmtError();
2608
2609 return getSema().ObjC().FinishObjCForCollectionStmt(ForEachStmt.get(),
2610 Body);
2611 }
2612
2613 /// Build a new C++ exception declaration.
2614 ///
2615 /// By default, performs semantic analysis to build the new decaration.
2616 /// Subclasses may override this routine to provide different behavior.
2619 SourceLocation StartLoc,
2620 SourceLocation IdLoc,
2621 IdentifierInfo *Id) {
2623 StartLoc, IdLoc, Id);
2624 if (Var)
2625 getSema().CurContext->addDecl(Var);
2626 return Var;
2627 }
2628
2629 /// Build a new C++ catch statement.
2630 ///
2631 /// By default, performs semantic analysis to build the new statement.
2632 /// Subclasses may override this routine to provide different behavior.
2634 VarDecl *ExceptionDecl,
2635 Stmt *Handler) {
2636 return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2637 Handler));
2638 }
2639
2640 /// Build a new C++ try statement.
2641 ///
2642 /// By default, performs semantic analysis to build the new statement.
2643 /// Subclasses may override this routine to provide different behavior.
2645 ArrayRef<Stmt *> Handlers) {
2646 return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2647 }
2648
2649 /// Build a new C++0x range-based for statement.
2650 ///
2651 /// By default, performs semantic analysis to build the new statement.
2652 /// Subclasses may override this routine to provide different behavior.
2654 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init,
2655 SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond,
2656 Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc,
2657 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
2658 // If we've just learned that the range is actually an Objective-C
2659 // collection, treat this as an Objective-C fast enumeration loop.
2660 if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2661 if (RangeStmt->isSingleDecl()) {
2662 if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2663 if (RangeVar->isInvalidDecl())
2664 return StmtError();
2665
2666 Expr *RangeExpr = RangeVar->getInit();
2667 if (!RangeExpr->isTypeDependent() &&
2668 RangeExpr->getType()->isObjCObjectPointerType()) {
2669 // FIXME: Support init-statements in Objective-C++20 ranged for
2670 // statement.
2671 if (Init) {
2672 return SemaRef.Diag(Init->getBeginLoc(),
2673 diag::err_objc_for_range_init_stmt)
2674 << Init->getSourceRange();
2675 }
2677 ForLoc, LoopVar, RangeExpr, RParenLoc);
2678 }
2679 }
2680 }
2681 }
2682
2684 ForLoc, CoawaitLoc, Init, ColonLoc, Range, Begin, End, Cond, Inc,
2685 LoopVar, RParenLoc, Sema::BFRK_Rebuild, LifetimeExtendTemps);
2686 }
2687
2688 /// Build a new C++0x range-based for statement.
2689 ///
2690 /// By default, performs semantic analysis to build the new statement.
2691 /// Subclasses may override this routine to provide different behavior.
2693 bool IsIfExists,
2694 NestedNameSpecifierLoc QualifierLoc,
2695 DeclarationNameInfo NameInfo,
2696 Stmt *Nested) {
2697 return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2698 QualifierLoc, NameInfo, Nested);
2699 }
2700
2701 /// Attach body to a C++0x range-based for statement.
2702 ///
2703 /// By default, performs semantic analysis to finish the new statement.
2704 /// Subclasses may override this routine to provide different behavior.
2706 return getSema().FinishCXXForRangeStmt(ForRange, Body);
2707 }
2708
2710 Stmt *TryBlock, Stmt *Handler) {
2711 return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2712 }
2713
2715 Stmt *Block) {
2716 return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2717 }
2718
2720 return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2721 }
2722
2724 SourceLocation LParen,
2725 SourceLocation RParen,
2726 TypeSourceInfo *TSI) {
2727 return getSema().SYCL().BuildUniqueStableNameExpr(OpLoc, LParen, RParen,
2728 TSI);
2729 }
2730
2731 /// Build a new predefined expression.
2732 ///
2733 /// By default, performs semantic analysis to build the new expression.
2734 /// Subclasses may override this routine to provide different behavior.
2738
2739 /// Build a new expression that references a declaration.
2740 ///
2741 /// By default, performs semantic analysis to build the new expression.
2742 /// Subclasses may override this routine to provide different behavior.
2744 LookupResult &R,
2745 bool RequiresADL) {
2746 return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2747 }
2748
2749
2750 /// Build a new expression that references a declaration.
2751 ///
2752 /// By default, performs semantic analysis to build the new expression.
2753 /// Subclasses may override this routine to provide different behavior.
2755 ValueDecl *VD,
2756 const DeclarationNameInfo &NameInfo,
2758 TemplateArgumentListInfo *TemplateArgs) {
2759 CXXScopeSpec SS;
2760 SS.Adopt(QualifierLoc);
2761 return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2762 TemplateArgs);
2763 }
2764
2765 /// Build a new expression in parentheses.
2766 ///
2767 /// By default, performs semantic analysis to build the new expression.
2768 /// Subclasses may override this routine to provide different behavior.
2770 SourceLocation RParen) {
2771 return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2772 }
2773
2774 /// Build a new pseudo-destructor expression.
2775 ///
2776 /// By default, performs semantic analysis to build the new expression.
2777 /// Subclasses may override this routine to provide different behavior.
2779 SourceLocation OperatorLoc,
2780 bool isArrow,
2781 CXXScopeSpec &SS,
2782 TypeSourceInfo *ScopeType,
2783 SourceLocation CCLoc,
2784 SourceLocation TildeLoc,
2785 PseudoDestructorTypeStorage Destroyed);
2786
2787 /// Build a new unary operator expression.
2788 ///
2789 /// By default, performs semantic analysis to build the new expression.
2790 /// Subclasses may override this routine to provide different behavior.
2793 Expr *SubExpr) {
2794 return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2795 }
2796
2797 /// Build a new builtin offsetof expression.
2798 ///
2799 /// By default, performs semantic analysis to build the new expression.
2800 /// Subclasses may override this routine to provide different behavior.
2804 SourceLocation RParenLoc) {
2805 return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2806 RParenLoc);
2807 }
2808
2809 /// Build a new sizeof, alignof or vec_step expression with a
2810 /// type argument.
2811 ///
2812 /// By default, performs semantic analysis to build the new expression.
2813 /// Subclasses may override this routine to provide different behavior.
2815 SourceLocation OpLoc,
2816 UnaryExprOrTypeTrait ExprKind,
2817 SourceRange R) {
2818 return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2819 }
2820
2821 /// Build a new sizeof, alignof or vec step expression with an
2822 /// expression argument.
2823 ///
2824 /// By default, performs semantic analysis to build the new expression.
2825 /// Subclasses may override this routine to provide different behavior.
2827 UnaryExprOrTypeTrait ExprKind,
2828 SourceRange R) {
2830 = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2831 if (Result.isInvalid())
2832 return ExprError();
2833
2834 return Result;
2835 }
2836
2837 /// Build a new array subscript expression.
2838 ///
2839 /// By default, performs semantic analysis to build the new expression.
2840 /// Subclasses may override this routine to provide different behavior.
2842 SourceLocation LBracketLoc,
2843 Expr *RHS,
2844 SourceLocation RBracketLoc) {
2845 return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2846 LBracketLoc, RHS,
2847 RBracketLoc);
2848 }
2849
2850 /// Build a new matrix subscript expression.
2851 ///
2852 /// By default, performs semantic analysis to build the new expression.
2853 /// Subclasses may override this routine to provide different behavior.
2855 Expr *ColumnIdx,
2856 SourceLocation RBracketLoc) {
2857 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2858 RBracketLoc);
2859 }
2860
2861 /// Build a new array section expression.
2862 ///
2863 /// By default, performs semantic analysis to build the new expression.
2864 /// Subclasses may override this routine to provide different behavior.
2866 SourceLocation LBracketLoc,
2867 Expr *LowerBound,
2868 SourceLocation ColonLocFirst,
2869 SourceLocation ColonLocSecond,
2870 Expr *Length, Expr *Stride,
2871 SourceLocation RBracketLoc) {
2872 if (IsOMPArraySection)
2874 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2875 Stride, RBracketLoc);
2876
2877 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2878 "Stride/second colon not allowed for OpenACC");
2879
2881 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2882 }
2883
2884 /// Build a new array shaping expression.
2885 ///
2886 /// By default, performs semantic analysis to build the new expression.
2887 /// Subclasses may override this routine to provide different behavior.
2889 SourceLocation RParenLoc,
2890 ArrayRef<Expr *> Dims,
2891 ArrayRef<SourceRange> BracketsRanges) {
2893 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2894 }
2895
2896 /// Build a new iterator expression.
2897 ///
2898 /// By default, performs semantic analysis to build the new expression.
2899 /// Subclasses may override this routine to provide different behavior.
2902 SourceLocation RLoc,
2905 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2906 }
2907
2908 /// Build a new call expression.
2909 ///
2910 /// By default, performs semantic analysis to build the new expression.
2911 /// Subclasses may override this routine to provide different behavior.
2913 MultiExprArg Args,
2914 SourceLocation RParenLoc,
2915 Expr *ExecConfig = nullptr) {
2916 return getSema().ActOnCallExpr(
2917 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2918 }
2919
2921 MultiExprArg Args,
2922 SourceLocation RParenLoc) {
2924 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2925 }
2926
2927 /// Build a new member access expression.
2928 ///
2929 /// By default, performs semantic analysis to build the new expression.
2930 /// Subclasses may override this routine to provide different behavior.
2932 bool isArrow,
2933 NestedNameSpecifierLoc QualifierLoc,
2934 SourceLocation TemplateKWLoc,
2935 const DeclarationNameInfo &MemberNameInfo,
2937 NamedDecl *FoundDecl,
2938 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2939 NamedDecl *FirstQualifierInScope) {
2941 isArrow);
2942 if (!Member->getDeclName()) {
2943 // We have a reference to an unnamed field. This is always the
2944 // base of an anonymous struct/union member access, i.e. the
2945 // field is always of record type.
2946 assert(Member->getType()->isRecordType() &&
2947 "unnamed member not of record type?");
2948
2949 BaseResult =
2951 QualifierLoc.getNestedNameSpecifier(),
2952 FoundDecl, Member);
2953 if (BaseResult.isInvalid())
2954 return ExprError();
2955 Base = BaseResult.get();
2956
2957 // `TranformMaterializeTemporaryExpr()` removes materialized temporaries
2958 // from the AST, so we need to re-insert them if needed (since
2959 // `BuildFieldRefereneExpr()` doesn't do this).
2960 if (!isArrow && Base->isPRValue()) {
2962 if (BaseResult.isInvalid())
2963 return ExprError();
2964 Base = BaseResult.get();
2965 }
2966
2967 CXXScopeSpec EmptySS;
2969 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
2970 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
2971 MemberNameInfo);
2972 }
2973
2974 CXXScopeSpec SS;
2975 SS.Adopt(QualifierLoc);
2976
2977 Base = BaseResult.get();
2978 if (Base->containsErrors())
2979 return ExprError();
2980
2981 QualType BaseType = Base->getType();
2982
2983 if (isArrow && !BaseType->isPointerType())
2984 return ExprError();
2985
2986 // FIXME: this involves duplicating earlier analysis in a lot of
2987 // cases; we should avoid this when possible.
2988 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
2989 R.addDecl(FoundDecl);
2990 R.resolveKind();
2991
2992 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
2994 if (auto *ThisClass = cast<CXXThisExpr>(Base)
2995 ->getType()
2996 ->getPointeeType()
2997 ->getAsCXXRecordDecl()) {
2998 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
2999 // In unevaluated contexts, an expression supposed to be a member access
3000 // might reference a member in an unrelated class.
3001 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
3002 return getSema().BuildDeclRefExpr(Member, Member->getType(),
3003 VK_LValue, Member->getLocation());
3004 }
3005 }
3006
3007 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
3008 SS, TemplateKWLoc,
3009 FirstQualifierInScope,
3010 R, ExplicitTemplateArgs,
3011 /*S*/nullptr);
3012 }
3013
3014 /// Build a new binary operator expression.
3015 ///
3016 /// By default, performs semantic analysis to build the new expression.
3017 /// Subclasses may override this routine to provide different behavior.
3019 Expr *LHS, Expr *RHS,
3020 bool ForFoldExpression = false) {
3021 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS,
3022 ForFoldExpression);
3023 }
3024
3025 /// Build a new rewritten operator expression.
3026 ///
3027 /// By default, performs semantic analysis to build the new expression.
3028 /// Subclasses may override this routine to provide different behavior.
3030 SourceLocation OpLoc, BinaryOperatorKind Opcode,
3031 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
3032 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
3033 RHS, /*RequiresADL*/false);
3034 }
3035
3036 /// Build a new conditional operator expression.
3037 ///
3038 /// By default, performs semantic analysis to build the new expression.
3039 /// Subclasses may override this routine to provide different behavior.
3041 SourceLocation QuestionLoc,
3042 Expr *LHS,
3043 SourceLocation ColonLoc,
3044 Expr *RHS) {
3045 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
3046 LHS, RHS);
3047 }
3048
3049 /// Build a new C-style cast expression.
3050 ///
3051 /// By default, performs semantic analysis to build the new expression.
3052 /// Subclasses may override this routine to provide different behavior.
3054 TypeSourceInfo *TInfo,
3055 SourceLocation RParenLoc,
3056 Expr *SubExpr) {
3057 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
3058 SubExpr);
3059 }
3060
3061 /// Build a new compound literal expression.
3062 ///
3063 /// By default, performs semantic analysis to build the new expression.
3064 /// Subclasses may override this routine to provide different behavior.
3066 TypeSourceInfo *TInfo,
3067 SourceLocation RParenLoc,
3068 Expr *Init) {
3069 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
3070 Init);
3071 }
3072
3073 /// Build a new extended vector element access expression.
3074 ///
3075 /// By default, performs semantic analysis to build the new expression.
3076 /// Subclasses may override this routine to provide different behavior.
3078 bool IsArrow,
3079 SourceLocation AccessorLoc,
3080 IdentifierInfo &Accessor) {
3081
3082 CXXScopeSpec SS;
3083 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3085 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3086 /*FirstQualifierInScope*/ nullptr, NameInfo,
3087 /* TemplateArgs */ nullptr,
3088 /*S*/ nullptr);
3089 }
3090
3091 /// Build a new initializer list expression.
3092 ///
3093 /// By default, performs semantic analysis to build the new expression.
3094 /// Subclasses may override this routine to provide different behavior.
3096 MultiExprArg Inits,
3097 SourceLocation RBraceLoc) {
3098 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
3099 }
3100
3101 /// Build a new designated initializer expression.
3102 ///
3103 /// By default, performs semantic analysis to build the new expression.
3104 /// Subclasses may override this routine to provide different behavior.
3106 MultiExprArg ArrayExprs,
3107 SourceLocation EqualOrColonLoc,
3108 bool GNUSyntax,
3109 Expr *Init) {
3111 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3112 Init);
3113 if (Result.isInvalid())
3114 return ExprError();
3115
3116 return Result;
3117 }
3118
3119 /// Build a new value-initialized expression.
3120 ///
3121 /// By default, builds the implicit value initialization without performing
3122 /// any semantic analysis. Subclasses may override this routine to provide
3123 /// different behavior.
3127
3128 /// Build a new \c va_arg expression.
3129 ///
3130 /// By default, performs semantic analysis to build the new expression.
3131 /// Subclasses may override this routine to provide different behavior.
3133 Expr *SubExpr, TypeSourceInfo *TInfo,
3134 SourceLocation RParenLoc) {
3135 return getSema().BuildVAArgExpr(BuiltinLoc,
3136 SubExpr, TInfo,
3137 RParenLoc);
3138 }
3139
3140 /// Build a new expression list in parentheses.
3141 ///
3142 /// By default, performs semantic analysis to build the new expression.
3143 /// Subclasses may override this routine to provide different behavior.
3145 MultiExprArg SubExprs,
3146 SourceLocation RParenLoc) {
3147 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3148 }
3149
3151 unsigned NumUserSpecifiedExprs,
3152 SourceLocation InitLoc,
3153 SourceLocation LParenLoc,
3154 SourceLocation RParenLoc) {
3155 return getSema().ActOnCXXParenListInitExpr(Args, T, NumUserSpecifiedExprs,
3156 InitLoc, LParenLoc, RParenLoc);
3157 }
3158
3159 /// Build a new address-of-label expression.
3160 ///
3161 /// By default, performs semantic analysis, using the name of the label
3162 /// rather than attempting to map the label statement itself.
3163 /// Subclasses may override this routine to provide different behavior.
3165 SourceLocation LabelLoc, LabelDecl *Label) {
3166 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3167 }
3168
3169 /// Build a new GNU statement expression.
3170 ///
3171 /// By default, performs semantic analysis to build the new expression.
3172 /// Subclasses may override this routine to provide different behavior.
3174 SourceLocation RParenLoc, unsigned TemplateDepth) {
3175 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3176 TemplateDepth);
3177 }
3178
3179 /// Build a new __builtin_choose_expr expression.
3180 ///
3181 /// By default, performs semantic analysis to build the new expression.
3182 /// Subclasses may override this routine to provide different behavior.
3184 Expr *Cond, Expr *LHS, Expr *RHS,
3185 SourceLocation RParenLoc) {
3186 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3187 Cond, LHS, RHS,
3188 RParenLoc);
3189 }
3190
3191 /// Build a new generic selection expression with an expression predicate.
3192 ///
3193 /// By default, performs semantic analysis to build the new expression.
3194 /// Subclasses may override this routine to provide different behavior.
3196 SourceLocation DefaultLoc,
3197 SourceLocation RParenLoc,
3198 Expr *ControllingExpr,
3200 ArrayRef<Expr *> Exprs) {
3201 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3202 /*PredicateIsExpr=*/true,
3203 ControllingExpr, Types, Exprs);
3204 }
3205
3206 /// Build a new generic selection expression with a type predicate.
3207 ///
3208 /// By default, performs semantic analysis to build the new expression.
3209 /// Subclasses may override this routine to provide different behavior.
3211 SourceLocation DefaultLoc,
3212 SourceLocation RParenLoc,
3213 TypeSourceInfo *ControllingType,
3215 ArrayRef<Expr *> Exprs) {
3216 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3217 /*PredicateIsExpr=*/false,
3218 ControllingType, Types, Exprs);
3219 }
3220
3221 /// Build a new overloaded operator call expression.
3222 ///
3223 /// By default, performs semantic analysis to build the new expression.
3224 /// The semantic analysis provides the behavior of template instantiation,
3225 /// copying with transformations that turn what looks like an overloaded
3226 /// operator call into a use of a builtin operator, performing
3227 /// argument-dependent lookup, etc. Subclasses may override this routine to
3228 /// provide different behavior.
3230 SourceLocation OpLoc,
3231 SourceLocation CalleeLoc,
3232 bool RequiresADL,
3233 const UnresolvedSetImpl &Functions,
3234 Expr *First, Expr *Second);
3235
3236 /// Build a new C++ "named" cast expression, such as static_cast or
3237 /// reinterpret_cast.
3238 ///
3239 /// By default, this routine dispatches to one of the more-specific routines
3240 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3241 /// Subclasses may override this routine to provide different behavior.
3244 SourceLocation LAngleLoc,
3245 TypeSourceInfo *TInfo,
3246 SourceLocation RAngleLoc,
3247 SourceLocation LParenLoc,
3248 Expr *SubExpr,
3249 SourceLocation RParenLoc) {
3250 switch (Class) {
3251 case Stmt::CXXStaticCastExprClass:
3252 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3253 RAngleLoc, LParenLoc,
3254 SubExpr, RParenLoc);
3255
3256 case Stmt::CXXDynamicCastExprClass:
3257 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3258 RAngleLoc, LParenLoc,
3259 SubExpr, RParenLoc);
3260
3261 case Stmt::CXXReinterpretCastExprClass:
3262 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3263 RAngleLoc, LParenLoc,
3264 SubExpr,
3265 RParenLoc);
3266
3267 case Stmt::CXXConstCastExprClass:
3268 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3269 RAngleLoc, LParenLoc,
3270 SubExpr, RParenLoc);
3271
3272 case Stmt::CXXAddrspaceCastExprClass:
3273 return getDerived().RebuildCXXAddrspaceCastExpr(
3274 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3275
3276 default:
3277 llvm_unreachable("Invalid C++ named cast");
3278 }
3279 }
3280
3281 /// Build a new C++ static_cast expression.
3282 ///
3283 /// By default, performs semantic analysis to build the new expression.
3284 /// Subclasses may override this routine to provide different behavior.
3286 SourceLocation LAngleLoc,
3287 TypeSourceInfo *TInfo,
3288 SourceLocation RAngleLoc,
3289 SourceLocation LParenLoc,
3290 Expr *SubExpr,
3291 SourceLocation RParenLoc) {
3292 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3293 TInfo, SubExpr,
3294 SourceRange(LAngleLoc, RAngleLoc),
3295 SourceRange(LParenLoc, RParenLoc));
3296 }
3297
3298 /// Build a new C++ dynamic_cast expression.
3299 ///
3300 /// By default, performs semantic analysis to build the new expression.
3301 /// Subclasses may override this routine to provide different behavior.
3303 SourceLocation LAngleLoc,
3304 TypeSourceInfo *TInfo,
3305 SourceLocation RAngleLoc,
3306 SourceLocation LParenLoc,
3307 Expr *SubExpr,
3308 SourceLocation RParenLoc) {
3309 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3310 TInfo, SubExpr,
3311 SourceRange(LAngleLoc, RAngleLoc),
3312 SourceRange(LParenLoc, RParenLoc));
3313 }
3314
3315 /// Build a new C++ reinterpret_cast expression.
3316 ///
3317 /// By default, performs semantic analysis to build the new expression.
3318 /// Subclasses may override this routine to provide different behavior.
3320 SourceLocation LAngleLoc,
3321 TypeSourceInfo *TInfo,
3322 SourceLocation RAngleLoc,
3323 SourceLocation LParenLoc,
3324 Expr *SubExpr,
3325 SourceLocation RParenLoc) {
3326 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3327 TInfo, SubExpr,
3328 SourceRange(LAngleLoc, RAngleLoc),
3329 SourceRange(LParenLoc, RParenLoc));
3330 }
3331
3332 /// Build a new C++ const_cast expression.
3333 ///
3334 /// By default, performs semantic analysis to build the new expression.
3335 /// Subclasses may override this routine to provide different behavior.
3337 SourceLocation LAngleLoc,
3338 TypeSourceInfo *TInfo,
3339 SourceLocation RAngleLoc,
3340 SourceLocation LParenLoc,
3341 Expr *SubExpr,
3342 SourceLocation RParenLoc) {
3343 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3344 TInfo, SubExpr,
3345 SourceRange(LAngleLoc, RAngleLoc),
3346 SourceRange(LParenLoc, RParenLoc));
3347 }
3348
3351 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3352 SourceLocation LParenLoc, Expr *SubExpr,
3353 SourceLocation RParenLoc) {
3354 return getSema().BuildCXXNamedCast(
3355 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3356 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3357 }
3358
3359 /// Build a new C++ functional-style cast expression.
3360 ///
3361 /// By default, performs semantic analysis to build the new expression.
3362 /// Subclasses may override this routine to provide different behavior.
3364 SourceLocation LParenLoc,
3365 Expr *Sub,
3366 SourceLocation RParenLoc,
3367 bool ListInitialization) {
3368 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3369 // CXXParenListInitExpr. Pass its expanded arguments so that the
3370 // CXXParenListInitExpr can be rebuilt.
3371 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3373 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3374 RParenLoc, ListInitialization);
3375
3376 if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub))
3378 TInfo, LParenLoc, PLE->getInitExprs(), RParenLoc, ListInitialization);
3379
3380 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3381 MultiExprArg(&Sub, 1), RParenLoc,
3382 ListInitialization);
3383 }
3384
3385 /// Build a new C++ __builtin_bit_cast expression.
3386 ///
3387 /// By default, performs semantic analysis to build the new expression.
3388 /// Subclasses may override this routine to provide different behavior.
3390 TypeSourceInfo *TSI, Expr *Sub,
3391 SourceLocation RParenLoc) {
3392 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3393 }
3394
3395 /// Build a new C++ typeid(type) expression.
3396 ///
3397 /// By default, performs semantic analysis to build the new expression.
3398 /// Subclasses may override this routine to provide different behavior.
3400 SourceLocation TypeidLoc,
3401 TypeSourceInfo *Operand,
3402 SourceLocation RParenLoc) {
3403 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3404 RParenLoc);
3405 }
3406
3407
3408 /// Build a new C++ typeid(expr) expression.
3409 ///
3410 /// By default, performs semantic analysis to build the new expression.
3411 /// Subclasses may override this routine to provide different behavior.
3413 SourceLocation TypeidLoc,
3414 Expr *Operand,
3415 SourceLocation RParenLoc) {
3416 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3417 RParenLoc);
3418 }
3419
3420 /// Build a new C++ __uuidof(type) expression.
3421 ///
3422 /// By default, performs semantic analysis to build the new expression.
3423 /// Subclasses may override this routine to provide different behavior.
3425 TypeSourceInfo *Operand,
3426 SourceLocation RParenLoc) {
3427 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3428 }
3429
3430 /// Build a new C++ __uuidof(expr) expression.
3431 ///
3432 /// By default, performs semantic analysis to build the new expression.
3433 /// Subclasses may override this routine to provide different behavior.
3435 Expr *Operand, SourceLocation RParenLoc) {
3436 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3437 }
3438
3439 /// Build a new C++ "this" expression.
3440 ///
3441 /// By default, performs semantic analysis to build a new "this" expression.
3442 /// Subclasses may override this routine to provide different behavior.
3444 QualType ThisType,
3445 bool isImplicit) {
3446 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3447 return ExprError();
3448 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3449 }
3450
3451 /// Build a new C++ throw expression.
3452 ///
3453 /// By default, performs semantic analysis to build the new expression.
3454 /// Subclasses may override this routine to provide different behavior.
3456 bool IsThrownVariableInScope) {
3457 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3458 }
3459
3460 /// Build a new C++ default-argument expression.
3461 ///
3462 /// By default, builds a new default-argument expression, which does not
3463 /// require any semantic analysis. Subclasses may override this routine to
3464 /// provide different behavior.
3466 Expr *RewrittenExpr) {
3467 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3468 RewrittenExpr, getSema().CurContext);
3469 }
3470
3471 /// Build a new C++11 default-initialization expression.
3472 ///
3473 /// By default, builds a new default field initialization expression, which
3474 /// does not require any semantic analysis. Subclasses may override this
3475 /// routine to provide different behavior.
3480
3481 /// Build a new C++ zero-initialization expression.
3482 ///
3483 /// By default, performs semantic analysis to build the new expression.
3484 /// Subclasses may override this routine to provide different behavior.
3486 SourceLocation LParenLoc,
3487 SourceLocation RParenLoc) {
3488 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3489 /*ListInitialization=*/false);
3490 }
3491
3492 /// Build a new C++ "new" expression.
3493 ///
3494 /// By default, performs semantic analysis to build the new expression.
3495 /// Subclasses may override this routine to provide different behavior.
3497 SourceLocation PlacementLParen,
3498 MultiExprArg PlacementArgs,
3499 SourceLocation PlacementRParen,
3500 SourceRange TypeIdParens, QualType AllocatedType,
3501 TypeSourceInfo *AllocatedTypeInfo,
3502 std::optional<Expr *> ArraySize,
3503 SourceRange DirectInitRange, Expr *Initializer) {
3504 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3505 PlacementLParen,
3506 PlacementArgs,
3507 PlacementRParen,
3508 TypeIdParens,
3509 AllocatedType,
3510 AllocatedTypeInfo,
3511 ArraySize,
3512 DirectInitRange,
3513 Initializer);
3514 }
3515
3516 /// Build a new C++ "delete" expression.
3517 ///
3518 /// By default, performs semantic analysis to build the new expression.
3519 /// Subclasses may override this routine to provide different behavior.
3521 bool IsGlobalDelete,
3522 bool IsArrayForm,
3523 Expr *Operand) {
3524 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3525 Operand);
3526 }
3527
3528 /// Build a new type trait expression.
3529 ///
3530 /// By default, performs semantic analysis to build the new expression.
3531 /// Subclasses may override this routine to provide different behavior.
3533 SourceLocation StartLoc,
3535 SourceLocation RParenLoc) {
3536 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3537 }
3538
3539 /// Build a new array type trait expression.
3540 ///
3541 /// By default, performs semantic analysis to build the new expression.
3542 /// Subclasses may override this routine to provide different behavior.
3544 SourceLocation StartLoc,
3545 TypeSourceInfo *TSInfo,
3546 Expr *DimExpr,
3547 SourceLocation RParenLoc) {
3548 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3549 }
3550
3551 /// Build a new expression trait expression.
3552 ///
3553 /// By default, performs semantic analysis to build the new expression.
3554 /// Subclasses may override this routine to provide different behavior.
3556 SourceLocation StartLoc,
3557 Expr *Queried,
3558 SourceLocation RParenLoc) {
3559 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3560 }
3561
3562 /// Build a new (previously unresolved) declaration reference
3563 /// expression.
3564 ///
3565 /// By default, performs semantic analysis to build the new expression.
3566 /// Subclasses may override this routine to provide different behavior.
3568 NestedNameSpecifierLoc QualifierLoc,
3569 SourceLocation TemplateKWLoc,
3570 const DeclarationNameInfo &NameInfo,
3571 const TemplateArgumentListInfo *TemplateArgs,
3572 bool IsAddressOfOperand,
3573 TypeSourceInfo **RecoveryTSI) {
3574 CXXScopeSpec SS;
3575 SS.Adopt(QualifierLoc);
3576
3577 if (TemplateArgs || TemplateKWLoc.isValid())
3579 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3580
3582 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3583 }
3584
3585 /// Build a new template-id expression.
3586 ///
3587 /// By default, performs semantic analysis to build the new expression.
3588 /// Subclasses may override this routine to provide different behavior.
3590 SourceLocation TemplateKWLoc,
3591 LookupResult &R,
3592 bool RequiresADL,
3593 const TemplateArgumentListInfo *TemplateArgs) {
3594 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3595 TemplateArgs);
3596 }
3597
3598 /// Build a new object-construction expression.
3599 ///
3600 /// By default, performs semantic analysis to build the new expression.
3601 /// Subclasses may override this routine to provide different behavior.
3604 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3605 bool ListInitialization, bool StdInitListInitialization,
3606 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3607 SourceRange ParenRange) {
3608 // Reconstruct the constructor we originally found, which might be
3609 // different if this is a call to an inherited constructor.
3610 CXXConstructorDecl *FoundCtor = Constructor;
3611 if (Constructor->isInheritingConstructor())
3612 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3613
3614 SmallVector<Expr *, 8> ConvertedArgs;
3615 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3616 ConvertedArgs))
3617 return ExprError();
3618
3620 IsElidable,
3621 ConvertedArgs,
3622 HadMultipleCandidates,
3623 ListInitialization,
3624 StdInitListInitialization,
3625 RequiresZeroInit, ConstructKind,
3626 ParenRange);
3627 }
3628
3629 /// Build a new implicit construction via inherited constructor
3630 /// expression.
3633 bool ConstructsVBase,
3634 bool InheritedFromVBase) {
3636 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3637 }
3638
3639 /// Build a new object-construction expression.
3640 ///
3641 /// By default, performs semantic analysis to build the new expression.
3642 /// Subclasses may override this routine to provide different behavior.
3644 SourceLocation LParenOrBraceLoc,
3645 MultiExprArg Args,
3646 SourceLocation RParenOrBraceLoc,
3647 bool ListInitialization) {
3649 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3650 }
3651
3652 /// Build a new object-construction expression.
3653 ///
3654 /// By default, performs semantic analysis to build the new expression.
3655 /// Subclasses may override this routine to provide different behavior.
3657 SourceLocation LParenLoc,
3658 MultiExprArg Args,
3659 SourceLocation RParenLoc,
3660 bool ListInitialization) {
3661 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3662 RParenLoc, ListInitialization);
3663 }
3664
3665 /// Build a new member reference expression.
3666 ///
3667 /// By default, performs semantic analysis to build the new expression.
3668 /// Subclasses may override this routine to provide different behavior.
3670 QualType BaseType,
3671 bool IsArrow,
3672 SourceLocation OperatorLoc,
3673 NestedNameSpecifierLoc QualifierLoc,
3674 SourceLocation TemplateKWLoc,
3675 NamedDecl *FirstQualifierInScope,
3676 const DeclarationNameInfo &MemberNameInfo,
3677 const TemplateArgumentListInfo *TemplateArgs) {
3678 CXXScopeSpec SS;
3679 SS.Adopt(QualifierLoc);
3680
3681 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3682 OperatorLoc, IsArrow,
3683 SS, TemplateKWLoc,
3684 FirstQualifierInScope,
3685 MemberNameInfo,
3686 TemplateArgs, /*S*/nullptr);
3687 }
3688
3689 /// Build a new member reference 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 OperatorLoc,
3695 bool IsArrow,
3696 NestedNameSpecifierLoc QualifierLoc,
3697 SourceLocation TemplateKWLoc,
3698 NamedDecl *FirstQualifierInScope,
3699 LookupResult &R,
3700 const TemplateArgumentListInfo *TemplateArgs) {
3701 CXXScopeSpec SS;
3702 SS.Adopt(QualifierLoc);
3703
3704 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3705 OperatorLoc, IsArrow,
3706 SS, TemplateKWLoc,
3707 FirstQualifierInScope,
3708 R, TemplateArgs, /*S*/nullptr);
3709 }
3710
3711 /// Build a new noexcept expression.
3712 ///
3713 /// By default, performs semantic analysis to build the new expression.
3714 /// Subclasses may override this routine to provide different behavior.
3716 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3717 }
3718
3721
3722 /// Build a new expression to compute the length of a parameter pack.
3724 SourceLocation PackLoc,
3725 SourceLocation RParenLoc,
3726 UnsignedOrNone Length,
3727 ArrayRef<TemplateArgument> PartialArgs) {
3728 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3729 RParenLoc, Length, PartialArgs);
3730 }
3731
3733 SourceLocation RSquareLoc,
3734 Expr *PackIdExpression, Expr *IndexExpr,
3735 ArrayRef<Expr *> ExpandedExprs,
3736 bool FullySubstituted = false) {
3737 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3738 IndexExpr, RSquareLoc, ExpandedExprs,
3739 FullySubstituted);
3740 }
3741
3742 /// Build a new expression representing a call to a source location
3743 /// builtin.
3744 ///
3745 /// By default, performs semantic analysis to build the new expression.
3746 /// Subclasses may override this routine to provide different behavior.
3748 SourceLocation BuiltinLoc,
3749 SourceLocation RPLoc,
3750 DeclContext *ParentContext) {
3751 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3752 ParentContext);
3753 }
3754
3756 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3757 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3759 CXXScopeSpec SS;
3760 SS.Adopt(NNS);
3761 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3762 ConceptNameInfo,
3763 FoundDecl,
3764 NamedConcept, TALI);
3765 if (Result.isInvalid())
3766 return ExprError();
3767 return Result;
3768 }
3769
3770 /// \brief Build a new requires expression.
3771 ///
3772 /// By default, performs semantic analysis to build the new expression.
3773 /// Subclasses may override this routine to provide different behavior.
3776 SourceLocation LParenLoc,
3777 ArrayRef<ParmVarDecl *> LocalParameters,
3778 SourceLocation RParenLoc,
3780 SourceLocation ClosingBraceLoc) {
3781 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3782 LocalParameters, RParenLoc, Requirements,
3783 ClosingBraceLoc);
3784 }
3785
3789 return SemaRef.BuildTypeRequirement(SubstDiag);
3790 }
3791
3793 return SemaRef.BuildTypeRequirement(T);
3794 }
3795
3798 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3799 SourceLocation NoexceptLoc,
3801 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3802 std::move(Ret));
3803 }
3804
3806 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3808 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3809 std::move(Ret));
3810 }
3811
3813 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3814 const ASTConstraintSatisfaction &Satisfaction) {
3815 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3816 Satisfaction);
3817 }
3818
3820 return SemaRef.BuildNestedRequirement(Constraint);
3821 }
3822
3823 /// \brief Build a new Objective-C boxed expression.
3824 ///
3825 /// By default, performs semantic analysis to build the new expression.
3826 /// Subclasses may override this routine to provide different behavior.
3828 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3829 }
3830
3831 /// Build a new Objective-C array literal.
3832 ///
3833 /// By default, performs semantic analysis to build the new expression.
3834 /// Subclasses may override this routine to provide different behavior.
3836 Expr **Elements, unsigned NumElements) {
3838 Range, MultiExprArg(Elements, NumElements));
3839 }
3840
3842 Expr *Base, Expr *Key,
3843 ObjCMethodDecl *getterMethod,
3844 ObjCMethodDecl *setterMethod) {
3846 RB, Base, Key, getterMethod, setterMethod);
3847 }
3848
3849 /// Build a new Objective-C dictionary literal.
3850 ///
3851 /// By default, performs semantic analysis to build the new expression.
3852 /// Subclasses may override this routine to provide different behavior.
3857
3858 /// Build a new Objective-C \@encode expression.
3859 ///
3860 /// By default, performs semantic analysis to build the new expression.
3861 /// Subclasses may override this routine to provide different behavior.
3863 TypeSourceInfo *EncodeTypeInfo,
3864 SourceLocation RParenLoc) {
3865 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3866 RParenLoc);
3867 }
3868
3869 /// Build a new Objective-C class message.
3871 Selector Sel,
3872 ArrayRef<SourceLocation> SelectorLocs,
3874 SourceLocation LBracLoc,
3875 MultiExprArg Args,
3876 SourceLocation RBracLoc) {
3877 return SemaRef.ObjC().BuildClassMessage(
3878 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3879 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3880 RBracLoc, Args);
3881 }
3882
3883 /// Build a new Objective-C instance message.
3885 Selector Sel,
3886 ArrayRef<SourceLocation> SelectorLocs,
3888 SourceLocation LBracLoc,
3889 MultiExprArg Args,
3890 SourceLocation RBracLoc) {
3891 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3892 /*SuperLoc=*/SourceLocation(),
3893 Sel, Method, LBracLoc,
3894 SelectorLocs, RBracLoc, Args);
3895 }
3896
3897 /// Build a new Objective-C instance/class message to 'super'.
3899 Selector Sel,
3900 ArrayRef<SourceLocation> SelectorLocs,
3901 QualType SuperType,
3903 SourceLocation LBracLoc,
3904 MultiExprArg Args,
3905 SourceLocation RBracLoc) {
3906 return Method->isInstanceMethod()
3907 ? SemaRef.ObjC().BuildInstanceMessage(
3908 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3909 SelectorLocs, RBracLoc, Args)
3910 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3911 Sel, Method, LBracLoc,
3912 SelectorLocs, RBracLoc, Args);
3913 }
3914
3915 /// Build a new Objective-C ivar reference expression.
3916 ///
3917 /// By default, performs semantic analysis to build the new expression.
3918 /// Subclasses may override this routine to provide different behavior.
3920 SourceLocation IvarLoc,
3921 bool IsArrow, bool IsFreeIvar) {
3922 CXXScopeSpec SS;
3923 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3925 BaseArg, BaseArg->getType(),
3926 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3927 /*FirstQualifierInScope=*/nullptr, NameInfo,
3928 /*TemplateArgs=*/nullptr,
3929 /*S=*/nullptr);
3930 if (IsFreeIvar && Result.isUsable())
3931 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3932 return Result;
3933 }
3934
3935 /// Build a new Objective-C property reference expression.
3936 ///
3937 /// By default, performs semantic analysis to build the new expression.
3938 /// Subclasses may override this routine to provide different behavior.
3941 SourceLocation PropertyLoc) {
3942 CXXScopeSpec SS;
3943 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3944 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3945 /*FIXME:*/PropertyLoc,
3946 /*IsArrow=*/false,
3947 SS, SourceLocation(),
3948 /*FirstQualifierInScope=*/nullptr,
3949 NameInfo,
3950 /*TemplateArgs=*/nullptr,
3951 /*S=*/nullptr);
3952 }
3953
3954 /// Build a new Objective-C property reference expression.
3955 ///
3956 /// By default, performs semantic analysis to build the new expression.
3957 /// Subclasses may override this routine to provide different behavior.
3959 ObjCMethodDecl *Getter,
3960 ObjCMethodDecl *Setter,
3961 SourceLocation PropertyLoc) {
3962 // Since these expressions can only be value-dependent, we do not
3963 // need to perform semantic analysis again.
3964 return Owned(
3965 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3967 PropertyLoc, Base));
3968 }
3969
3970 /// Build a new Objective-C "isa" expression.
3971 ///
3972 /// By default, performs semantic analysis to build the new expression.
3973 /// Subclasses may override this routine to provide different behavior.
3975 SourceLocation OpLoc, bool IsArrow) {
3976 CXXScopeSpec SS;
3977 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
3978 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3979 OpLoc, IsArrow,
3980 SS, SourceLocation(),
3981 /*FirstQualifierInScope=*/nullptr,
3982 NameInfo,
3983 /*TemplateArgs=*/nullptr,
3984 /*S=*/nullptr);
3985 }
3986
3987 /// Build a new shuffle vector expression.
3988 ///
3989 /// By default, performs semantic analysis to build the new expression.
3990 /// Subclasses may override this routine to provide different behavior.
3992 MultiExprArg SubExprs,
3993 SourceLocation RParenLoc) {
3994 // Find the declaration for __builtin_shufflevector
3995 const IdentifierInfo &Name
3996 = SemaRef.Context.Idents.get("__builtin_shufflevector");
3997 TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
3998 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
3999 assert(!Lookup.empty() && "No __builtin_shufflevector?");
4000
4001 // Build a reference to the __builtin_shufflevector builtin
4003 Expr *Callee = new (SemaRef.Context)
4004 DeclRefExpr(SemaRef.Context, Builtin, false,
4005 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
4006 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
4007 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
4008 CK_BuiltinFnToFnPtr).get();
4009
4010 // Build the CallExpr
4011 ExprResult TheCall = CallExpr::Create(
4012 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
4013 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
4015
4016 // Type-check the __builtin_shufflevector expression.
4017 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
4018 }
4019
4020 /// Build a new convert vector expression.
4022 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
4023 SourceLocation RParenLoc) {
4024 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
4025 }
4026
4027 /// Build a new template argument pack expansion.
4028 ///
4029 /// By default, performs semantic analysis to build a new pack expansion
4030 /// for a template argument. Subclasses may override this routine to provide
4031 /// different behavior.
4033 SourceLocation EllipsisLoc,
4034 UnsignedOrNone NumExpansions) {
4035 switch (Pattern.getArgument().getKind()) {
4039 EllipsisLoc, NumExpansions);
4040 if (Result.isInvalid())
4041 return TemplateArgumentLoc();
4042
4044 /*IsCanonical=*/false),
4045 Result.get());
4046 }
4047
4049 return TemplateArgumentLoc(
4050 SemaRef.Context,
4052 NumExpansions),
4053 Pattern.getTemplateKWLoc(), Pattern.getTemplateQualifierLoc(),
4054 Pattern.getTemplateNameLoc(), EllipsisLoc);
4055
4063 llvm_unreachable("Pack expansion pattern has no parameter packs");
4064
4066 if (TypeSourceInfo *Expansion
4067 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4068 EllipsisLoc,
4069 NumExpansions))
4070 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4071 Expansion);
4072 break;
4073 }
4074
4075 return TemplateArgumentLoc();
4076 }
4077
4078 /// Build a new expression pack expansion.
4079 ///
4080 /// By default, performs semantic analysis to build a new pack expansion
4081 /// for an expression. Subclasses may override this routine to provide
4082 /// different behavior.
4084 UnsignedOrNone NumExpansions) {
4085 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4086 }
4087
4088 /// Build a new C++1z fold-expression.
4089 ///
4090 /// By default, performs semantic analysis in order to build a new fold
4091 /// expression.
4093 SourceLocation LParenLoc, Expr *LHS,
4094 BinaryOperatorKind Operator,
4095 SourceLocation EllipsisLoc, Expr *RHS,
4096 SourceLocation RParenLoc,
4097 UnsignedOrNone NumExpansions) {
4098 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4099 EllipsisLoc, RHS, RParenLoc,
4100 NumExpansions);
4101 }
4102
4104 LambdaScopeInfo *LSI) {
4105 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4106 if (Expr *Init = PVD->getInit())
4108 Init->containsUnexpandedParameterPack();
4109 else if (PVD->hasUninstantiatedDefaultArg())
4111 PVD->getUninstantiatedDefaultArg()
4112 ->containsUnexpandedParameterPack();
4113 }
4114 return getSema().BuildLambdaExpr(StartLoc, EndLoc);
4115 }
4116
4117 /// Build an empty C++1z fold-expression with the given operator.
4118 ///
4119 /// By default, produces the fallback value for the fold-expression, or
4120 /// produce an error if there is no fallback value.
4122 BinaryOperatorKind Operator) {
4123 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4124 }
4125
4126 /// Build a new atomic operation expression.
4127 ///
4128 /// By default, performs semantic analysis to build the new expression.
4129 /// Subclasses may override this routine to provide different behavior.
4132 SourceLocation RParenLoc) {
4133 // Use this for all of the locations, since we don't know the difference
4134 // between the call and the expr at this point.
4135 SourceRange Range{BuiltinLoc, RParenLoc};
4136 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4138 }
4139
4141 ArrayRef<Expr *> SubExprs, QualType Type) {
4142 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4143 }
4144
4146 SourceLocation BeginLoc,
4147 SourceLocation DirLoc,
4148 SourceLocation EndLoc,
4150 StmtResult StrBlock) {
4152 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4153 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, StrBlock);
4154 }
4155
4166
4168 SourceLocation BeginLoc,
4169 SourceLocation DirLoc,
4170 SourceLocation EndLoc,
4172 StmtResult Loop) {
4174 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4175 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, Loop);
4176 }
4177
4179 SourceLocation DirLoc,
4180 SourceLocation EndLoc,
4182 StmtResult StrBlock) {
4184 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4186 Clauses, StrBlock);
4187 }
4188
4198
4208
4210 SourceLocation DirLoc,
4211 SourceLocation EndLoc,
4213 StmtResult StrBlock) {
4217 Clauses, StrBlock);
4218 }
4219
4221 SourceLocation DirLoc,
4222 SourceLocation EndLoc,
4223 ArrayRef<OpenACCClause *> Clauses) {
4225 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4227 Clauses, {});
4228 }
4229
4239
4241 SourceLocation DirLoc,
4242 SourceLocation EndLoc,
4243 ArrayRef<OpenACCClause *> Clauses) {
4245 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4247 Clauses, {});
4248 }
4249
4251 SourceLocation DirLoc,
4252 SourceLocation EndLoc,
4253 ArrayRef<OpenACCClause *> Clauses) {
4255 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4257 Clauses, {});
4258 }
4259
4261 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4262 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4263 SourceLocation RParenLoc, SourceLocation EndLoc,
4264 ArrayRef<OpenACCClause *> Clauses) {
4266 Exprs.push_back(DevNumExpr);
4267 llvm::append_range(Exprs, QueueIdExprs);
4269 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4270 Exprs, OpenACCAtomicKind::None, RParenLoc, EndLoc, Clauses, {});
4271 }
4272
4274 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4275 SourceLocation ReadOnlyLoc, ArrayRef<Expr *> VarList,
4276 SourceLocation RParenLoc, SourceLocation EndLoc) {
4278 OpenACCDirectiveKind::Cache, BeginLoc, DirLoc, LParenLoc, ReadOnlyLoc,
4279 VarList, OpenACCAtomicKind::None, RParenLoc, EndLoc, {}, {});
4280 }
4281
4283 SourceLocation DirLoc,
4284 OpenACCAtomicKind AtKind,
4285 SourceLocation EndLoc,
4287 StmtResult AssociatedStmt) {
4289 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4290 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, Clauses,
4291 AssociatedStmt);
4292 }
4293
4297
4298private:
4299 QualType TransformTypeInObjectScope(TypeLocBuilder &TLB, TypeLoc TL,
4300 QualType ObjectType,
4301 NamedDecl *FirstQualifierInScope);
4302
4303 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4304 QualType ObjectType,
4305 NamedDecl *FirstQualifierInScope) {
4306 if (getDerived().AlreadyTransformed(TSInfo->getType()))
4307 return TSInfo;
4308
4309 TypeLocBuilder TLB;
4310 QualType T = TransformTypeInObjectScope(TLB, TSInfo->getTypeLoc(),
4311 ObjectType, FirstQualifierInScope);
4312 if (T.isNull())
4313 return nullptr;
4314 return TLB.getTypeSourceInfo(SemaRef.Context, T);
4315 }
4316
4317 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4318 DependentNameTypeLoc TL,
4319 bool DeducibleTSTContext,
4320 QualType ObjectType = QualType(),
4321 NamedDecl *UnqualLookup = nullptr);
4322
4324 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4326
4327 OpenACCClause *
4328 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4329 OpenACCDirectiveKind DirKind,
4330 const OpenACCClause *OldClause);
4331};
4332
4333template <typename Derived>
4335 if (!S)
4336 return S;
4337
4338 switch (S->getStmtClass()) {
4339 case Stmt::NoStmtClass: break;
4340
4341 // Transform individual statement nodes
4342 // Pass SDK into statements that can produce a value
4343#define STMT(Node, Parent) \
4344 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4345#define VALUESTMT(Node, Parent) \
4346 case Stmt::Node##Class: \
4347 return getDerived().Transform##Node(cast<Node>(S), SDK);
4348#define ABSTRACT_STMT(Node)
4349#define EXPR(Node, Parent)
4350#include "clang/AST/StmtNodes.inc"
4351
4352 // Transform expressions by calling TransformExpr.
4353#define STMT(Node, Parent)
4354#define ABSTRACT_STMT(Stmt)
4355#define EXPR(Node, Parent) case Stmt::Node##Class:
4356#include "clang/AST/StmtNodes.inc"
4357 {
4358 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4359
4361 E = getSema().ActOnStmtExprResult(E);
4362 return getSema().ActOnExprStmt(E, SDK == StmtDiscardKind::Discarded);
4363 }
4364 }
4365
4366 return S;
4367}
4368
4369template<typename Derived>
4371 if (!S)
4372 return S;
4373
4374 switch (S->getClauseKind()) {
4375 default: break;
4376 // Transform individual clause nodes
4377#define GEN_CLANG_CLAUSE_CLASS
4378#define CLAUSE_CLASS(Enum, Str, Class) \
4379 case Enum: \
4380 return getDerived().Transform##Class(cast<Class>(S));
4381#include "llvm/Frontend/OpenMP/OMP.inc"
4382 }
4383
4384 return S;
4385}
4386
4387
4388template<typename Derived>
4390 if (!E)
4391 return E;
4392
4393 switch (E->getStmtClass()) {
4394 case Stmt::NoStmtClass: break;
4395#define STMT(Node, Parent) case Stmt::Node##Class: break;
4396#define ABSTRACT_STMT(Stmt)
4397#define EXPR(Node, Parent) \
4398 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4399#include "clang/AST/StmtNodes.inc"
4400 }
4401
4402 return E;
4403}
4404
4405template<typename Derived>
4407 bool NotCopyInit) {
4408 // Initializers are instantiated like expressions, except that various outer
4409 // layers are stripped.
4410 if (!Init)
4411 return Init;
4412
4413 if (auto *FE = dyn_cast<FullExpr>(Init))
4414 Init = FE->getSubExpr();
4415
4416 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4417 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4418 Init = OVE->getSourceExpr();
4419 }
4420
4421 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4422 Init = MTE->getSubExpr();
4423
4424 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4425 Init = Binder->getSubExpr();
4426
4427 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4428 Init = ICE->getSubExprAsWritten();
4429
4430 if (CXXStdInitializerListExpr *ILE =
4431 dyn_cast<CXXStdInitializerListExpr>(Init))
4432 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4433
4434 // If this is copy-initialization, we only need to reconstruct
4435 // InitListExprs. Other forms of copy-initialization will be a no-op if
4436 // the initializer is already the right type.
4437 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4438 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4439 return getDerived().TransformExpr(Init);
4440
4441 // Revert value-initialization back to empty parens.
4442 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4443 SourceRange Parens = VIE->getSourceRange();
4444 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4445 Parens.getEnd());
4446 }
4447
4448 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4450 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4451 SourceLocation());
4452
4453 // Revert initialization by constructor back to a parenthesized or braced list
4454 // of expressions. Any other form of initializer can just be reused directly.
4455 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4456 return getDerived().TransformExpr(Init);
4457
4458 // If the initialization implicitly converted an initializer list to a
4459 // std::initializer_list object, unwrap the std::initializer_list too.
4460 if (Construct && Construct->isStdInitListInitialization())
4461 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4462
4463 // Enter a list-init context if this was list initialization.
4466 Construct->isListInitialization());
4467
4468 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4469 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4470 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4471 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4472 SmallVector<Expr*, 8> NewArgs;
4473 bool ArgChanged = false;
4474 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4475 /*IsCall*/true, NewArgs, &ArgChanged))
4476 return ExprError();
4477
4478 // If this was list initialization, revert to syntactic list form.
4479 if (Construct->isListInitialization())
4480 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4481 Construct->getEndLoc());
4482
4483 // Build a ParenListExpr to represent anything else.
4485 if (Parens.isInvalid()) {
4486 // This was a variable declaration's initialization for which no initializer
4487 // was specified.
4488 assert(NewArgs.empty() &&
4489 "no parens or braces but have direct init with arguments?");
4490 return ExprEmpty();
4491 }
4492 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4493 Parens.getEnd());
4494}
4495
4496template<typename Derived>
4498 unsigned NumInputs,
4499 bool IsCall,
4500 SmallVectorImpl<Expr *> &Outputs,
4501 bool *ArgChanged) {
4502 for (unsigned I = 0; I != NumInputs; ++I) {
4503 // If requested, drop call arguments that need to be dropped.
4504 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4505 if (ArgChanged)
4506 *ArgChanged = true;
4507
4508 break;
4509 }
4510
4511 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4512 Expr *Pattern = Expansion->getPattern();
4513
4515 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4516 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4517
4518 // Determine whether the set of unexpanded parameter packs can and should
4519 // be expanded.
4520 bool Expand = true;
4521 bool RetainExpansion = false;
4522 UnsignedOrNone OrigNumExpansions = Expansion->getNumExpansions();
4523 UnsignedOrNone NumExpansions = OrigNumExpansions;
4525 Expansion->getEllipsisLoc(), Pattern->getSourceRange(),
4526 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
4527 RetainExpansion, NumExpansions))
4528 return true;
4529
4530 if (!Expand) {
4531 // The transform has determined that we should perform a simple
4532 // transformation on the pack expansion, producing another pack
4533 // expansion.
4534 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
4535 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4536 if (OutPattern.isInvalid())
4537 return true;
4538
4539 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4540 Expansion->getEllipsisLoc(),
4541 NumExpansions);
4542 if (Out.isInvalid())
4543 return true;
4544
4545 if (ArgChanged)
4546 *ArgChanged = true;
4547 Outputs.push_back(Out.get());
4548 continue;
4549 }
4550
4551 // Record right away that the argument was changed. This needs
4552 // to happen even if the array expands to nothing.
4553 if (ArgChanged) *ArgChanged = true;
4554
4555 // The transform has determined that we should perform an elementwise
4556 // expansion of the pattern. Do so.
4557 for (unsigned I = 0; I != *NumExpansions; ++I) {
4558 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
4559 ExprResult Out = getDerived().TransformExpr(Pattern);
4560 if (Out.isInvalid())
4561 return true;
4562
4563 if (Out.get()->containsUnexpandedParameterPack()) {
4564 Out = getDerived().RebuildPackExpansion(
4565 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4566 if (Out.isInvalid())
4567 return true;
4568 }
4569
4570 Outputs.push_back(Out.get());
4571 }
4572
4573 // If we're supposed to retain a pack expansion, do so by temporarily
4574 // forgetting the partially-substituted parameter pack.
4575 if (RetainExpansion) {
4576 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4577
4578 ExprResult Out = getDerived().TransformExpr(Pattern);
4579 if (Out.isInvalid())
4580 return true;
4581
4582 Out = getDerived().RebuildPackExpansion(
4583 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4584 if (Out.isInvalid())
4585 return true;
4586
4587 Outputs.push_back(Out.get());
4588 }
4589
4590 continue;
4591 }
4592
4594 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4595 : getDerived().TransformExpr(Inputs[I]);
4596 if (Result.isInvalid())
4597 return true;
4598
4599 if (Result.get() != Inputs[I] && ArgChanged)
4600 *ArgChanged = true;
4601
4602 Outputs.push_back(Result.get());
4603 }
4604
4605 return false;
4606}
4607
4608template <typename Derived>
4611
4614 /*LambdaContextDecl=*/nullptr,
4616 /*ShouldEnter=*/Kind == Sema::ConditionKind::ConstexprIf);
4617
4618 if (Var) {
4619 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4621
4622 if (!ConditionVar)
4623 return Sema::ConditionError();
4624
4625 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4626 }
4627
4628 if (Expr) {
4629 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4630
4631 if (CondExpr.isInvalid())
4632 return Sema::ConditionError();
4633
4634 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4635 /*MissingOK=*/true);
4636 }
4637
4638 return Sema::ConditionResult();
4639}
4640
4641template <typename Derived>
4643 NestedNameSpecifierLoc NNS, QualType ObjectType,
4644 NamedDecl *FirstQualifierInScope) {
4646
4647 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4648 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4649 Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix)
4650 Qualifiers.push_back(Qualifier);
4651 };
4652 insertNNS(NNS);
4653
4654 CXXScopeSpec SS;
4655 while (!Qualifiers.empty()) {
4656 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4658
4659 switch (QNNS.getKind()) {
4661 llvm_unreachable("unexpected null nested name specifier");
4662
4665 Q.getLocalBeginLoc(), const_cast<NamespaceBaseDecl *>(
4667 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4668 break;
4669 }
4670
4672 // There is no meaningful transformation that one could perform on the
4673 // global scope.
4674 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4675 break;
4676
4678 CXXRecordDecl *RD = cast_or_null<CXXRecordDecl>(
4680 SS.MakeMicrosoftSuper(SemaRef.Context, RD, Q.getBeginLoc(),
4681 Q.getEndLoc());
4682 break;
4683 }
4684
4686 assert(SS.isEmpty());
4687 TypeLoc TL = Q.castAsTypeLoc();
4688
4689 if (auto DNT = TL.getAs<DependentNameTypeLoc>()) {
4690 NestedNameSpecifierLoc QualifierLoc = DNT.getQualifierLoc();
4691 if (QualifierLoc) {
4692 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4693 QualifierLoc, ObjectType, FirstQualifierInScope);
4694 if (!QualifierLoc)
4695 return NestedNameSpecifierLoc();
4696 ObjectType = QualType();
4697 FirstQualifierInScope = nullptr;
4698 }
4699 SS.Adopt(QualifierLoc);
4701 const_cast<IdentifierInfo *>(DNT.getTypePtr()->getIdentifier()),
4702 DNT.getNameLoc(), Q.getLocalEndLoc(), ObjectType);
4703 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo,
4704 false, SS,
4705 FirstQualifierInScope, false))
4706 return NestedNameSpecifierLoc();
4707 return SS.getWithLocInContext(SemaRef.Context);
4708 }
4709
4710 QualType T = TL.getType();
4711 TypeLocBuilder TLB;
4713 T = TransformTypeInObjectScope(TLB, TL, ObjectType,
4714 FirstQualifierInScope);
4715 if (T.isNull())
4716 return NestedNameSpecifierLoc();
4717 TL = TLB.getTypeLocInContext(SemaRef.Context, T);
4718 }
4719
4720 if (T->isDependentType() || T->isRecordType() ||
4721 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4722 if (T->isEnumeralType())
4723 SemaRef.Diag(TL.getBeginLoc(),
4724 diag::warn_cxx98_compat_enum_nested_name_spec);
4725 SS.Make(SemaRef.Context, TL, Q.getLocalEndLoc());
4726 break;
4727 }
4728 // If the nested-name-specifier is an invalid type def, don't emit an
4729 // error because a previous error should have already been emitted.
4731 if (!TTL || !TTL.getDecl()->isInvalidDecl()) {
4732 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4733 << T << SS.getRange();
4734 }
4735 return NestedNameSpecifierLoc();
4736 }
4737 }
4738 }
4739
4740 // Don't rebuild the nested-name-specifier if we don't have to.
4741 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4743 return NNS;
4744
4745 // If we can re-use the source-location data from the original
4746 // nested-name-specifier, do so.
4747 if (SS.location_size() == NNS.getDataLength() &&
4748 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4750
4751 // Allocate new nested-name-specifier location information.
4752 return SS.getWithLocInContext(SemaRef.Context);
4753}
4754
4755template<typename Derived>
4759 DeclarationName Name = NameInfo.getName();
4760 if (!Name)
4761 return DeclarationNameInfo();
4762
4763 switch (Name.getNameKind()) {
4771 return NameInfo;
4772
4774 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4775 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4776 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4777 if (!NewTemplate)
4778 return DeclarationNameInfo();
4779
4780 DeclarationNameInfo NewNameInfo(NameInfo);
4781 NewNameInfo.setName(
4782 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
4783 return NewNameInfo;
4784 }
4785
4789 TypeSourceInfo *NewTInfo;
4790 CanQualType NewCanTy;
4791 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4792 NewTInfo = getDerived().TransformType(OldTInfo);
4793 if (!NewTInfo)
4794 return DeclarationNameInfo();
4795 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4796 }
4797 else {
4798 NewTInfo = nullptr;
4799 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4800 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4801 if (NewT.isNull())
4802 return DeclarationNameInfo();
4803 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4804 }
4805
4806 DeclarationName NewName
4807 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4808 NewCanTy);
4809 DeclarationNameInfo NewNameInfo(NameInfo);
4810 NewNameInfo.setName(NewName);
4811 NewNameInfo.setNamedTypeInfo(NewTInfo);
4812 return NewNameInfo;
4813 }
4814 }
4815
4816 llvm_unreachable("Unknown name kind.");
4817}
4818
4819template <typename Derived>
4821 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4823 QualType ObjectType, bool AllowInjectedClassName) {
4824 if (const IdentifierInfo *II = IO.getIdentifier())
4825 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, *II, NameLoc,
4826 ObjectType, AllowInjectedClassName);
4827 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, IO.getOperator(),
4828 NameLoc, ObjectType,
4829 AllowInjectedClassName);
4830}
4831
4832template <typename Derived>
4834 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
4835 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
4836 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
4838 TemplateName UnderlyingName = QTN->getUnderlyingTemplate();
4839
4840 if (QualifierLoc) {
4841 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4842 QualifierLoc, ObjectType, FirstQualifierInScope);
4843 if (!QualifierLoc)
4844 return TemplateName();
4845 }
4846
4847 NestedNameSpecifierLoc UnderlyingQualifier;
4848 TemplateName NewUnderlyingName = getDerived().TransformTemplateName(
4849 UnderlyingQualifier, TemplateKWLoc, UnderlyingName, NameLoc, ObjectType,
4850 FirstQualifierInScope, AllowInjectedClassName);
4851 if (NewUnderlyingName.isNull())
4852 return TemplateName();
4853 assert(!UnderlyingQualifier && "unexpected qualifier");
4854
4855 if (!getDerived().AlwaysRebuild() &&
4856 QualifierLoc.getNestedNameSpecifier() == QTN->getQualifier() &&
4857 NewUnderlyingName == UnderlyingName)
4858 return Name;
4859 CXXScopeSpec SS;
4860 SS.Adopt(QualifierLoc);
4861 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4862 NewUnderlyingName);
4863 }
4864
4866 if (QualifierLoc) {
4867 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4868 QualifierLoc, ObjectType, FirstQualifierInScope);
4869 if (!QualifierLoc)
4870 return TemplateName();
4871 // The qualifier-in-scope and object type only apply to the leftmost
4872 // entity.
4873 ObjectType = QualType();
4874 }
4875
4876 if (!getDerived().AlwaysRebuild() &&
4877 QualifierLoc.getNestedNameSpecifier() == DTN->getQualifier() &&
4878 ObjectType.isNull())
4879 return Name;
4880
4881 CXXScopeSpec SS;
4882 SS.Adopt(QualifierLoc);
4883 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, DTN->getName(),
4884 NameLoc, ObjectType,
4885 AllowInjectedClassName);
4886 }
4887
4890 assert(!QualifierLoc && "Unexpected qualified SubstTemplateTemplateParm");
4891
4892 NestedNameSpecifierLoc ReplacementQualifierLoc;
4893 TemplateName ReplacementName = S->getReplacement();
4894 if (NestedNameSpecifier Qualifier = ReplacementName.getQualifier()) {
4896 Builder.MakeTrivial(SemaRef.Context, Qualifier, NameLoc);
4897 ReplacementQualifierLoc = Builder.getWithLocInContext(SemaRef.Context);
4898 }
4899
4900 TemplateName NewName = getDerived().TransformTemplateName(
4901 ReplacementQualifierLoc, TemplateKWLoc, ReplacementName, NameLoc,
4902 ObjectType, FirstQualifierInScope, AllowInjectedClassName);
4903 if (NewName.isNull())
4904 return TemplateName();
4905 Decl *AssociatedDecl =
4906 getDerived().TransformDecl(NameLoc, S->getAssociatedDecl());
4907 if (!getDerived().AlwaysRebuild() && NewName == S->getReplacement() &&
4908 AssociatedDecl == S->getAssociatedDecl())
4909 return Name;
4910 return SemaRef.Context.getSubstTemplateTemplateParm(
4911 NewName, AssociatedDecl, S->getIndex(), S->getPackIndex(),
4912 S->getFinal());
4913 }
4914
4915 assert(!Name.getAsDeducedTemplateName() &&
4916 "DeducedTemplateName should not escape partial ordering");
4917
4918 // FIXME: Preserve UsingTemplateName.
4919 if (auto *Template = Name.getAsTemplateDecl()) {
4920 assert(!QualifierLoc && "Unexpected qualifier");
4921 return TemplateName(cast_or_null<TemplateDecl>(
4922 getDerived().TransformDecl(NameLoc, Template)));
4923 }
4924
4927 assert(!QualifierLoc &&
4928 "Unexpected qualified SubstTemplateTemplateParmPack");
4929 return getDerived().RebuildTemplateName(
4930 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4931 SubstPack->getIndex(), SubstPack->getFinal());
4932 }
4933
4934 // These should be getting filtered out before they reach the AST.
4935 llvm_unreachable("overloaded function decl survived to here");
4936}
4937
4938template <typename Derived>
4940 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
4941 TemplateName Name, SourceLocation NameLoc) {
4942 TemplateName TN = getDerived().TransformTemplateName(
4943 QualifierLoc, TemplateKeywordLoc, Name, NameLoc);
4944 if (TN.isNull())
4945 return TemplateArgument();
4946 return TemplateArgument(TN);
4947}
4948
4949template<typename Derived>
4951 const TemplateArgument &Arg,
4952 TemplateArgumentLoc &Output) {
4953 Output = getSema().getTrivialTemplateArgumentLoc(
4954 Arg, QualType(), getDerived().getBaseLocation());
4955}
4956
4957template <typename Derived>
4959 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
4960 bool Uneval) {
4961 const TemplateArgument &Arg = Input.getArgument();
4962 switch (Arg.getKind()) {
4965 llvm_unreachable("Unexpected TemplateArgument");
4966
4971 // Transform a resolved template argument straight to a resolved template
4972 // argument. We get here when substituting into an already-substituted
4973 // template type argument during concept satisfaction checking.
4975 QualType NewT = getDerived().TransformType(T);
4976 if (NewT.isNull())
4977 return true;
4978
4980 ? Arg.getAsDecl()
4981 : nullptr;
4982 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
4984 : nullptr;
4985 if (D && !NewD)
4986 return true;
4987
4988 if (NewT == T && D == NewD)
4989 Output = Input;
4990 else if (Arg.getKind() == TemplateArgument::Integral)
4991 Output = TemplateArgumentLoc(
4992 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
4994 else if (Arg.getKind() == TemplateArgument::NullPtr)
4995 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
4997 else if (Arg.getKind() == TemplateArgument::Declaration)
4998 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
5001 Output = TemplateArgumentLoc(
5002 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
5004 else
5005 llvm_unreachable("unexpected template argument kind");
5006
5007 return false;
5008 }
5009
5011 TypeSourceInfo *TSI = Input.getTypeSourceInfo();
5012 if (!TSI)
5014
5015 TSI = getDerived().TransformType(TSI);
5016 if (!TSI)
5017 return true;
5018
5019 Output = TemplateArgumentLoc(TemplateArgument(TSI->getType()), TSI);
5020 return false;
5021 }
5022
5024 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
5025
5026 TemplateArgument Out = getDerived().TransformNamedTemplateTemplateArgument(
5027 QualifierLoc, Input.getTemplateKWLoc(), Arg.getAsTemplate(),
5028 Input.getTemplateNameLoc());
5029 if (Out.isNull())
5030 return true;
5031 Output = TemplateArgumentLoc(SemaRef.Context, Out, Input.getTemplateKWLoc(),
5032 QualifierLoc, Input.getTemplateNameLoc());
5033 return false;
5034 }
5035
5037 llvm_unreachable("Caller should expand pack expansions");
5038
5040 // Template argument expressions are constant expressions.
5042 getSema(),
5045 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
5047
5048 Expr *InputExpr = Input.getSourceExpression();
5049 if (!InputExpr)
5050 InputExpr = Input.getArgument().getAsExpr();
5051
5052 ExprResult E = getDerived().TransformExpr(InputExpr);
5053 E = SemaRef.ActOnConstantExpression(E);
5054 if (E.isInvalid())
5055 return true;
5056 Output = TemplateArgumentLoc(
5057 TemplateArgument(E.get(), /*IsCanonical=*/false), E.get());
5058 return false;
5059 }
5060 }
5061
5062 // Work around bogus GCC warning
5063 return true;
5064}
5065
5066/// Iterator adaptor that invents template argument location information
5067/// for each of the template arguments in its underlying iterator.
5068template<typename Derived, typename InputIterator>
5071 InputIterator Iter;
5072
5073public:
5076 typedef typename std::iterator_traits<InputIterator>::difference_type
5078 typedef std::input_iterator_tag iterator_category;
5079
5080 class pointer {
5082
5083 public:
5084 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5085
5086 const TemplateArgumentLoc *operator->() const { return &Arg; }
5087 };
5088
5090 InputIterator Iter)
5091 : Self(Self), Iter(Iter) { }
5092
5094 ++Iter;
5095 return *this;
5096 }
5097
5100 ++(*this);
5101 return Old;
5102 }
5103
5106 Self.InventTemplateArgumentLoc(*Iter, Result);
5107 return Result;
5108 }
5109
5110 pointer operator->() const { return pointer(**this); }
5111
5114 return X.Iter == Y.Iter;
5115 }
5116
5119 return X.Iter != Y.Iter;
5120 }
5121};
5122
5123template<typename Derived>
5124template<typename InputIterator>
5126 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5127 bool Uneval) {
5128 for (TemplateArgumentLoc In : llvm::make_range(First, Last)) {
5130 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5131 // Unpack argument packs, which we translate them into separate
5132 // arguments.
5133 // FIXME: We could do much better if we could guarantee that the
5134 // TemplateArgumentLocInfo for the pack expansion would be usable for
5135 // all of the template arguments in the argument pack.
5136 typedef TemplateArgumentLocInventIterator<Derived,
5138 PackLocIterator;
5139
5140 TemplateArgumentListInfo *PackOutput = &Outputs;
5142
5144 PackLocIterator(*this, In.getArgument().pack_begin()),
5145 PackLocIterator(*this, In.getArgument().pack_end()), *PackOutput,
5146 Uneval))
5147 return true;
5148
5149 continue;
5150 }
5151
5152 if (In.getArgument().isPackExpansion()) {
5153 UnexpandedInfo Info;
5154 TemplateArgumentLoc Prepared;
5155 if (PreparePackForExpansion(In, Uneval, Prepared, Info))
5156 return true;
5157 if (!Info.Expand) {
5158 Outputs.addArgument(Prepared);
5159 continue;
5160 }
5161
5162 // The transform has determined that we should perform an elementwise
5163 // expansion of the pattern. Do so.
5164 std::optional<ForgetSubstitutionRAII> ForgetSubst;
5166 ForgetSubst.emplace(getDerived());
5167 for (unsigned I = 0; I != *Info.NumExpansions; ++I) {
5168 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5169
5171 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5172 return true;
5173
5174 if (Out.getArgument().containsUnexpandedParameterPack()) {
5175 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5176 Info.OrigNumExpansions);
5177 if (Out.getArgument().isNull())
5178 return true;
5179 }
5180
5181 Outputs.addArgument(Out);
5182 }
5183
5184 // If we're supposed to retain a pack expansion, do so by temporarily
5185 // forgetting the partially-substituted parameter pack.
5186 if (Info.RetainExpansion) {
5187 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5188
5190 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5191 return true;
5192
5193 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5194 Info.OrigNumExpansions);
5195 if (Out.getArgument().isNull())
5196 return true;
5197
5198 Outputs.addArgument(Out);
5199 }
5200
5201 continue;
5202 }
5203
5204 // The simple case:
5205 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5206 return true;
5207
5208 Outputs.addArgument(Out);
5209 }
5210
5211 return false;
5212}
5213
5214template <typename Derived>
5215template <typename InputIterator>
5217 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5218 bool Uneval) {
5219
5220 // [C++26][temp.constr.normal]
5221 // any non-dependent concept template argument
5222 // is substituted into the constraint-expression of C.
5223 auto isNonDependentConceptArgument = [](const TemplateArgument &Arg) {
5224 return !Arg.isDependent() && Arg.isConceptOrConceptTemplateParameter();
5225 };
5226
5227 for (; First != Last; ++First) {
5230
5231 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5232 typedef TemplateArgumentLocInventIterator<Derived,
5234 PackLocIterator;
5236 PackLocIterator(*this, In.getArgument().pack_begin()),
5237 PackLocIterator(*this, In.getArgument().pack_end()), Outputs,
5238 Uneval))
5239 return true;
5240 continue;
5241 }
5242
5243 if (!isNonDependentConceptArgument(In.getArgument())) {
5244 Outputs.addArgument(In);
5245 continue;
5246 }
5247
5248 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5249 return true;
5250
5251 Outputs.addArgument(Out);
5252 }
5253
5254 return false;
5255}
5256
5257// FIXME: Find ways to reduce code duplication for pack expansions.
5258template <typename Derived>
5260 bool Uneval,
5262 UnexpandedInfo &Info) {
5263 auto ComputeInfo = [this](TemplateArgumentLoc Arg,
5264 bool IsLateExpansionAttempt, UnexpandedInfo &Info,
5265 TemplateArgumentLoc &Pattern) {
5266 assert(Arg.getArgument().isPackExpansion());
5267 // We have a pack expansion, for which we will be substituting into the
5268 // pattern.
5269 Pattern = getSema().getTemplateArgumentPackExpansionPattern(
5270 Arg, Info.Ellipsis, Info.OrigNumExpansions);
5272 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5273 if (IsLateExpansionAttempt) {
5274 // Request expansion only when there is an opportunity to expand a pack
5275 // that required a substituion first.
5276 bool SawPackTypes =
5277 llvm::any_of(Unexpanded, [](UnexpandedParameterPack P) {
5278 return P.first.dyn_cast<const SubstBuiltinTemplatePackType *>();
5279 });
5280 if (!SawPackTypes) {
5281 Info.Expand = false;
5282 return false;
5283 }
5284 }
5285 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5286
5287 // Determine whether the set of unexpanded parameter packs can and
5288 // should be expanded.
5289 Info.Expand = true;
5290 Info.RetainExpansion = false;
5291 Info.NumExpansions = Info.OrigNumExpansions;
5292 return getDerived().TryExpandParameterPacks(
5293 Info.Ellipsis, Pattern.getSourceRange(), Unexpanded,
5294 /*FailOnPackProducingTemplates=*/false, Info.Expand,
5295 Info.RetainExpansion, Info.NumExpansions);
5296 };
5297
5298 TemplateArgumentLoc Pattern;
5299 if (ComputeInfo(In, false, Info, Pattern))
5300 return true;
5301
5302 if (Info.Expand) {
5303 Out = Pattern;
5304 return false;
5305 }
5306
5307 // The transform has determined that we should perform a simple
5308 // transformation on the pack expansion, producing another pack
5309 // expansion.
5310 TemplateArgumentLoc OutPattern;
5311 std::optional<Sema::ArgPackSubstIndexRAII> SubstIndex(
5312 std::in_place, getSema(), std::nullopt);
5313 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5314 return true;
5315
5316 Out = getDerived().RebuildPackExpansion(OutPattern, Info.Ellipsis,
5317 Info.NumExpansions);
5318 if (Out.getArgument().isNull())
5319 return true;
5320 SubstIndex.reset();
5321
5322 if (!OutPattern.getArgument().containsUnexpandedParameterPack())
5323 return false;
5324
5325 // Some packs will learn their length after substitution, e.g.
5326 // __builtin_dedup_pack<T,int> has size 1 or 2, depending on the substitution
5327 // value of `T`.
5328 //
5329 // We only expand after we know sizes of all packs, check if this is the case
5330 // or not. However, we avoid a full template substitution and only do
5331 // expanstions after this point.
5332
5333 // E.g. when substituting template arguments of tuple with {T -> int} in the
5334 // following example:
5335 // template <class T>
5336 // struct TupleWithInt {
5337 // using type = std::tuple<__builtin_dedup_pack<T, int>...>;
5338 // };
5339 // TupleWithInt<int>::type y;
5340 // At this point we will see the `__builtin_dedup_pack<int, int>` with a known
5341 // lenght and run `ComputeInfo()` to provide the necessary information to our
5342 // caller.
5343 //
5344 // Note that we may still have situations where builtin is not going to be
5345 // expanded. For example:
5346 // template <class T>
5347 // struct Foo {
5348 // template <class U> using tuple_with_t =
5349 // std::tuple<__builtin_dedup_pack<T, U, int>...>; using type =
5350 // tuple_with_t<short>;
5351 // }
5352 // Because the substitution into `type` happens in dependent context, `type`
5353 // will be `tuple<builtin_dedup_pack<T, short, int>...>` after substitution
5354 // and the caller will not be able to expand it.
5355 ForgetSubstitutionRAII ForgetSubst(getDerived());
5356 if (ComputeInfo(Out, true, Info, OutPattern))
5357 return true;
5358 if (!Info.Expand)
5359 return false;
5360 Out = OutPattern;
5361 Info.ExpandUnderForgetSubstitions = true;
5362 return false;
5363}
5364
5365//===----------------------------------------------------------------------===//
5366// Type transformation
5367//===----------------------------------------------------------------------===//
5368
5369template<typename Derived>
5372 return T;
5373
5374 // Temporary workaround. All of these transformations should
5375 // eventually turn into transformations on TypeLocs.
5376 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5378
5379 TypeSourceInfo *NewTSI = getDerived().TransformType(TSI);
5380
5381 if (!NewTSI)
5382 return QualType();
5383
5384 return NewTSI->getType();
5385}
5386
5387template <typename Derived>
5389 // Refine the base location to the type's location.
5390 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5393 return TSI;
5394
5395 TypeLocBuilder TLB;
5396
5397 TypeLoc TL = TSI->getTypeLoc();
5398 TLB.reserve(TL.getFullDataSize());
5399
5400 QualType Result = getDerived().TransformType(TLB, TL);
5401 if (Result.isNull())
5402 return nullptr;
5403
5404 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5405}
5406
5407template<typename Derived>
5410 switch (T.getTypeLocClass()) {
5411#define ABSTRACT_TYPELOC(CLASS, PARENT)
5412#define TYPELOC(CLASS, PARENT) \
5413 case TypeLoc::CLASS: \
5414 return getDerived().Transform##CLASS##Type(TLB, \
5415 T.castAs<CLASS##TypeLoc>());
5416#include "clang/AST/TypeLocNodes.def"
5417 }
5418
5419 llvm_unreachable("unhandled type loc!");
5420}
5421
5422template<typename Derived>
5425 return TransformType(T);
5426
5428 return T;
5429 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5431 TypeSourceInfo *NewTSI = getDerived().TransformTypeWithDeducedTST(TSI);
5432 return NewTSI ? NewTSI->getType() : QualType();
5433}
5434
5435template <typename Derived>
5438 if (!isa<DependentNameType>(TSI->getType()))
5439 return TransformType(TSI);
5440
5441 // Refine the base location to the type's location.
5442 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5445 return TSI;
5446
5447 TypeLocBuilder TLB;
5448
5449 TypeLoc TL = TSI->getTypeLoc();
5450 TLB.reserve(TL.getFullDataSize());
5451
5452 auto QTL = TL.getAs<QualifiedTypeLoc>();
5453 if (QTL)
5454 TL = QTL.getUnqualifiedLoc();
5455
5456 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5457
5458 QualType Result = getDerived().TransformDependentNameType(
5459 TLB, DNTL, /*DeducedTSTContext*/true);
5460 if (Result.isNull())
5461 return nullptr;
5462
5463 if (QTL) {
5464 Result = getDerived().RebuildQualifiedType(Result, QTL);
5465 if (Result.isNull())
5466 return nullptr;
5468 }
5469
5470 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5471}
5472
5473template<typename Derived>
5478 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5479 auto SuppressObjCLifetime =
5480 T.getType().getLocalQualifiers().hasObjCLifetime();
5481 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5482 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5483 SuppressObjCLifetime);
5484 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5485 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5486 TLB, STTP, SuppressObjCLifetime);
5487 } else {
5488 Result = getDerived().TransformType(TLB, UnqualTL);
5489 }
5490
5491 if (Result.isNull())
5492 return QualType();
5493
5494 Result = getDerived().RebuildQualifiedType(Result, T);
5495
5496 if (Result.isNull())
5497 return QualType();
5498
5499 // RebuildQualifiedType might have updated the type, but not in a way
5500 // that invalidates the TypeLoc. (There's no location information for
5501 // qualifiers.)
5503
5504 return Result;
5505}
5506
5507template <typename Derived>
5509 QualifiedTypeLoc TL) {
5510
5511 SourceLocation Loc = TL.getBeginLoc();
5512 Qualifiers Quals = TL.getType().getLocalQualifiers();
5513
5514 if ((T.getAddressSpace() != LangAS::Default &&
5515 Quals.getAddressSpace() != LangAS::Default) &&
5516 T.getAddressSpace() != Quals.getAddressSpace()) {
5517 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5518 << TL.getType() << T;
5519 return QualType();
5520 }
5521
5522 PointerAuthQualifier LocalPointerAuth = Quals.getPointerAuth();
5523 if (LocalPointerAuth.isPresent()) {
5524 if (T.getPointerAuth().isPresent()) {
5525 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_redundant) << TL.getType();
5526 return QualType();
5527 }
5528 if (!T->isDependentType()) {
5529 if (!T->isSignableType(SemaRef.getASTContext())) {
5530 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_invalid_target) << T;
5531 return QualType();
5532 }
5533 }
5534 }
5535 // C++ [dcl.fct]p7:
5536 // [When] adding cv-qualifications on top of the function type [...] the
5537 // cv-qualifiers are ignored.
5538 if (T->isFunctionType()) {
5539 T = SemaRef.getASTContext().getAddrSpaceQualType(T,
5540 Quals.getAddressSpace());
5541 return T;
5542 }
5543
5544 // C++ [dcl.ref]p1:
5545 // when the cv-qualifiers are introduced through the use of a typedef-name
5546 // or decltype-specifier [...] the cv-qualifiers are ignored.
5547 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5548 // applied to a reference type.
5549 if (T->isReferenceType()) {
5550 // The only qualifier that applies to a reference type is restrict.
5551 if (!Quals.hasRestrict())
5552 return T;
5554 }
5555
5556 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5557 // resulting type.
5558 if (Quals.hasObjCLifetime()) {
5559 if (!T->isObjCLifetimeType() && !T->isDependentType())
5560 Quals.removeObjCLifetime();
5561 else if (T.getObjCLifetime()) {
5562 // Objective-C ARC:
5563 // A lifetime qualifier applied to a substituted template parameter
5564 // overrides the lifetime qualifier from the template argument.
5565 const AutoType *AutoTy;
5566 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5567 // 'auto' types behave the same way as template parameters.
5568 QualType Deduced = AutoTy->getDeducedType();
5569 Qualifiers Qs = Deduced.getQualifiers();
5570 Qs.removeObjCLifetime();
5571 Deduced =
5572 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5573 T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
5574 AutoTy->isDependentType(),
5575 /*isPack=*/false,
5576 AutoTy->getTypeConstraintConcept(),
5577 AutoTy->getTypeConstraintArguments());
5578 } else {
5579 // Otherwise, complain about the addition of a qualifier to an
5580 // already-qualified type.
5581 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5582 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5583 Quals.removeObjCLifetime();
5584 }
5585 }
5586 }
5587
5588 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5589}
5590
5591template <typename Derived>
5592QualType TreeTransform<Derived>::TransformTypeInObjectScope(
5593 TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType,
5594 NamedDecl *FirstQualifierInScope) {
5595 assert(!getDerived().AlreadyTransformed(TL.getType()));
5596
5597 switch (TL.getTypeLocClass()) {
5598 case TypeLoc::TemplateSpecialization:
5599 return getDerived().TransformTemplateSpecializationType(
5600 TLB, TL.castAs<TemplateSpecializationTypeLoc>(), ObjectType,
5601 FirstQualifierInScope, /*AllowInjectedClassName=*/true);
5602 case TypeLoc::DependentName:
5603 return getDerived().TransformDependentNameType(
5604 TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
5605 ObjectType, FirstQualifierInScope);
5606 default:
5607 // Any dependent canonical type can appear here, through type alias
5608 // templates.
5609 return getDerived().TransformType(TLB, TL);
5610 }
5611}
5612
5613template <class TyLoc> static inline
5615 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5616 NewT.setNameLoc(T.getNameLoc());
5617 return T.getType();
5618}
5619
5620template<typename Derived>
5621QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5622 BuiltinTypeLoc T) {
5623 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5624 NewT.setBuiltinLoc(T.getBuiltinLoc());
5625 if (T.needsExtraLocalData())
5626 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5627 return T.getType();
5628}
5629
5630template<typename Derived>
5632 ComplexTypeLoc T) {
5633 // FIXME: recurse?
5634 return TransformTypeSpecType(TLB, T);
5635}
5636
5637template <typename Derived>
5639 AdjustedTypeLoc TL) {
5640 // Adjustments applied during transformation are handled elsewhere.
5641 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5642}
5643
5644template<typename Derived>
5646 DecayedTypeLoc TL) {
5647 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5648 if (OriginalType.isNull())
5649 return QualType();
5650
5651 QualType Result = TL.getType();
5652 if (getDerived().AlwaysRebuild() ||
5653 OriginalType != TL.getOriginalLoc().getType())
5654 Result = SemaRef.Context.getDecayedType(OriginalType);
5655 TLB.push<DecayedTypeLoc>(Result);
5656 // Nothing to set for DecayedTypeLoc.
5657 return Result;
5658}
5659
5660template <typename Derived>
5664 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5665 if (OriginalType.isNull())
5666 return QualType();
5667
5668 QualType Result = TL.getType();
5669 if (getDerived().AlwaysRebuild() ||
5670 OriginalType != TL.getElementLoc().getType())
5671 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5672 TLB.push<ArrayParameterTypeLoc>(Result);
5673 // Nothing to set for ArrayParameterTypeLoc.
5674 return Result;
5675}
5676
5677template<typename Derived>
5679 PointerTypeLoc TL) {
5680 QualType PointeeType
5681 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5682 if (PointeeType.isNull())
5683 return QualType();
5684
5685 QualType Result = TL.getType();
5686 if (PointeeType->getAs<ObjCObjectType>()) {
5687 // A dependent pointer type 'T *' has is being transformed such
5688 // that an Objective-C class type is being replaced for 'T'. The
5689 // resulting pointer type is an ObjCObjectPointerType, not a
5690 // PointerType.
5691 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5692
5694 NewT.setStarLoc(TL.getStarLoc());
5695 return Result;
5696 }
5697
5698 if (getDerived().AlwaysRebuild() ||
5699 PointeeType != TL.getPointeeLoc().getType()) {
5700 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5701 if (Result.isNull())
5702 return QualType();
5703 }
5704
5705 // Objective-C ARC can add lifetime qualifiers to the type that we're
5706 // pointing to.
5707 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5708
5709 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5710 NewT.setSigilLoc(TL.getSigilLoc());
5711 return Result;
5712}
5713
5714template<typename Derived>
5718 QualType PointeeType
5719 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5720 if (PointeeType.isNull())
5721 return QualType();
5722
5723 QualType Result = TL.getType();
5724 if (getDerived().AlwaysRebuild() ||
5725 PointeeType != TL.getPointeeLoc().getType()) {
5726 Result = getDerived().RebuildBlockPointerType(PointeeType,
5727 TL.getSigilLoc());
5728 if (Result.isNull())
5729 return QualType();
5730 }
5731
5733 NewT.setSigilLoc(TL.getSigilLoc());
5734 return Result;
5735}
5736
5737/// Transforms a reference type. Note that somewhat paradoxically we
5738/// don't care whether the type itself is an l-value type or an r-value
5739/// type; we only care if the type was *written* as an l-value type
5740/// or an r-value type.
5741template<typename Derived>
5744 ReferenceTypeLoc TL) {
5745 const ReferenceType *T = TL.getTypePtr();
5746
5747 // Note that this works with the pointee-as-written.
5748 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5749 if (PointeeType.isNull())
5750 return QualType();
5751
5752 QualType Result = TL.getType();
5753 if (getDerived().AlwaysRebuild() ||
5754 PointeeType != T->getPointeeTypeAsWritten()) {
5755 Result = getDerived().RebuildReferenceType(PointeeType,
5756 T->isSpelledAsLValue(),
5757 TL.getSigilLoc());
5758 if (Result.isNull())
5759 return QualType();
5760 }
5761
5762 // Objective-C ARC can add lifetime qualifiers to the type that we're
5763 // referring to.
5766
5767 // r-value references can be rebuilt as l-value references.
5768 ReferenceTypeLoc NewTL;
5770 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5771 else
5772 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5773 NewTL.setSigilLoc(TL.getSigilLoc());
5774
5775 return Result;
5776}
5777
5778template<typename Derived>
5782 return TransformReferenceType(TLB, TL);
5783}
5784
5785template<typename Derived>
5786QualType
5787TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5788 RValueReferenceTypeLoc TL) {
5789 return TransformReferenceType(TLB, TL);
5790}
5791
5792template<typename Derived>
5796 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5797 if (PointeeType.isNull())
5798 return QualType();
5799
5800 const MemberPointerType *T = TL.getTypePtr();
5801
5802 NestedNameSpecifierLoc OldQualifierLoc = TL.getQualifierLoc();
5803 NestedNameSpecifierLoc NewQualifierLoc =
5804 getDerived().TransformNestedNameSpecifierLoc(OldQualifierLoc);
5805 if (!NewQualifierLoc)
5806 return QualType();
5807
5808 CXXRecordDecl *OldCls = T->getMostRecentCXXRecordDecl(), *NewCls = nullptr;
5809 if (OldCls) {
5810 NewCls = cast_or_null<CXXRecordDecl>(
5811 getDerived().TransformDecl(TL.getStarLoc(), OldCls));
5812 if (!NewCls)
5813 return QualType();
5814 }
5815
5816 QualType Result = TL.getType();
5817 if (getDerived().AlwaysRebuild() || PointeeType != T->getPointeeType() ||
5818 NewQualifierLoc.getNestedNameSpecifier() !=
5819 OldQualifierLoc.getNestedNameSpecifier() ||
5820 NewCls != OldCls) {
5821 CXXScopeSpec SS;
5822 SS.Adopt(NewQualifierLoc);
5823 Result = getDerived().RebuildMemberPointerType(PointeeType, SS, NewCls,
5824 TL.getStarLoc());
5825 if (Result.isNull())
5826 return QualType();
5827 }
5828
5829 // If we had to adjust the pointee type when building a member pointer, make
5830 // sure to push TypeLoc info for it.
5831 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5832 if (MPT && PointeeType != MPT->getPointeeType()) {
5833 assert(isa<AdjustedType>(MPT->getPointeeType()));
5834 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5835 }
5836
5838 NewTL.setSigilLoc(TL.getSigilLoc());
5839 NewTL.setQualifierLoc(NewQualifierLoc);
5840
5841 return Result;
5842}
5843
5844template<typename Derived>
5848 const ConstantArrayType *T = TL.getTypePtr();
5849 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5850 if (ElementType.isNull())
5851 return QualType();
5852
5853 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5854 Expr *OldSize = TL.getSizeExpr();
5855 if (!OldSize)
5856 OldSize = const_cast<Expr*>(T->getSizeExpr());
5857 Expr *NewSize = nullptr;
5858 if (OldSize) {
5861 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5862 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5863 }
5864
5865 QualType Result = TL.getType();
5866 if (getDerived().AlwaysRebuild() ||
5867 ElementType != T->getElementType() ||
5868 (T->getSizeExpr() && NewSize != OldSize)) {
5869 Result = getDerived().RebuildConstantArrayType(ElementType,
5870 T->getSizeModifier(),
5871 T->getSize(), NewSize,
5872 T->getIndexTypeCVRQualifiers(),
5873 TL.getBracketsRange());
5874 if (Result.isNull())
5875 return QualType();
5876 }
5877
5878 // We might have either a ConstantArrayType or a VariableArrayType now:
5879 // a ConstantArrayType is allowed to have an element type which is a
5880 // VariableArrayType if the type is dependent. Fortunately, all array
5881 // types have the same location layout.
5882 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5883 NewTL.setLBracketLoc(TL.getLBracketLoc());
5884 NewTL.setRBracketLoc(TL.getRBracketLoc());
5885 NewTL.setSizeExpr(NewSize);
5886
5887 return Result;
5888}
5889
5890template<typename Derived>
5892 TypeLocBuilder &TLB,
5894 const IncompleteArrayType *T = TL.getTypePtr();
5895 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5896 if (ElementType.isNull())
5897 return QualType();
5898
5899 QualType Result = TL.getType();
5900 if (getDerived().AlwaysRebuild() ||
5901 ElementType != T->getElementType()) {
5902 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5903 T->getSizeModifier(),
5904 T->getIndexTypeCVRQualifiers(),
5905 TL.getBracketsRange());
5906 if (Result.isNull())
5907 return QualType();
5908 }
5909
5911 NewTL.setLBracketLoc(TL.getLBracketLoc());
5912 NewTL.setRBracketLoc(TL.getRBracketLoc());
5913 NewTL.setSizeExpr(nullptr);
5914
5915 return Result;
5916}
5917
5918template<typename Derived>
5922 const VariableArrayType *T = TL.getTypePtr();
5923 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5924 if (ElementType.isNull())
5925 return QualType();
5926
5927 ExprResult SizeResult;
5928 {
5931 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5932 }
5933 if (SizeResult.isInvalid())
5934 return QualType();
5935 SizeResult =
5936 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5937 if (SizeResult.isInvalid())
5938 return QualType();
5939
5940 Expr *Size = SizeResult.get();
5941
5942 QualType Result = TL.getType();
5943 if (getDerived().AlwaysRebuild() ||
5944 ElementType != T->getElementType() ||
5945 Size != T->getSizeExpr()) {
5946 Result = getDerived().RebuildVariableArrayType(ElementType,
5947 T->getSizeModifier(),
5948 Size,
5949 T->getIndexTypeCVRQualifiers(),
5950 TL.getBracketsRange());
5951 if (Result.isNull())
5952 return QualType();
5953 }
5954
5955 // We might have constant size array now, but fortunately it has the same
5956 // location layout.
5957 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5958 NewTL.setLBracketLoc(TL.getLBracketLoc());
5959 NewTL.setRBracketLoc(TL.getRBracketLoc());
5960 NewTL.setSizeExpr(Size);
5961
5962 return Result;
5963}
5964
5965template<typename Derived>
5969 const DependentSizedArrayType *T = TL.getTypePtr();
5970 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5971 if (ElementType.isNull())
5972 return QualType();
5973
5974 // Array bounds are constant expressions.
5977
5978 // If we have a VLA then it won't be a constant.
5979 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
5980
5981 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5982 Expr *origSize = TL.getSizeExpr();
5983 if (!origSize) origSize = T->getSizeExpr();
5984
5985 ExprResult sizeResult
5986 = getDerived().TransformExpr(origSize);
5987 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
5988 if (sizeResult.isInvalid())
5989 return QualType();
5990
5991 Expr *size = sizeResult.get();
5992
5993 QualType Result = TL.getType();
5994 if (getDerived().AlwaysRebuild() ||
5995 ElementType != T->getElementType() ||
5996 size != origSize) {
5997 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
5998 T->getSizeModifier(),
5999 size,
6000 T->getIndexTypeCVRQualifiers(),
6001 TL.getBracketsRange());
6002 if (Result.isNull())
6003 return QualType();
6004 }
6005
6006 // We might have any sort of array type now, but fortunately they
6007 // all have the same location layout.
6008 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6009 NewTL.setLBracketLoc(TL.getLBracketLoc());
6010 NewTL.setRBracketLoc(TL.getRBracketLoc());
6011 NewTL.setSizeExpr(size);
6012
6013 return Result;
6014}
6015
6016template <typename Derived>
6019 const DependentVectorType *T = TL.getTypePtr();
6020 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6021 if (ElementType.isNull())
6022 return QualType();
6023
6026
6027 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6028 Size = SemaRef.ActOnConstantExpression(Size);
6029 if (Size.isInvalid())
6030 return QualType();
6031
6032 QualType Result = TL.getType();
6033 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6034 Size.get() != T->getSizeExpr()) {
6035 Result = getDerived().RebuildDependentVectorType(
6036 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
6037 if (Result.isNull())
6038 return QualType();
6039 }
6040
6041 // Result might be dependent or not.
6044 TLB.push<DependentVectorTypeLoc>(Result);
6045 NewTL.setNameLoc(TL.getNameLoc());
6046 } else {
6047 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6048 NewTL.setNameLoc(TL.getNameLoc());
6049 }
6050
6051 return Result;
6052}
6053
6054template<typename Derived>
6056 TypeLocBuilder &TLB,
6058 const DependentSizedExtVectorType *T = TL.getTypePtr();
6059
6060 // FIXME: ext vector locs should be nested
6061 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6062 if (ElementType.isNull())
6063 return QualType();
6064
6065 // Vector sizes are constant expressions.
6068
6069 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6070 Size = SemaRef.ActOnConstantExpression(Size);
6071 if (Size.isInvalid())
6072 return QualType();
6073
6074 QualType Result = TL.getType();
6075 if (getDerived().AlwaysRebuild() ||
6076 ElementType != T->getElementType() ||
6077 Size.get() != T->getSizeExpr()) {
6078 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
6079 Size.get(),
6080 T->getAttributeLoc());
6081 if (Result.isNull())
6082 return QualType();
6083 }
6084
6085 // Result might be dependent or not.
6089 NewTL.setNameLoc(TL.getNameLoc());
6090 } else {
6091 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6092 NewTL.setNameLoc(TL.getNameLoc());
6093 }
6094
6095 return Result;
6096}
6097
6098template <typename Derived>
6102 const ConstantMatrixType *T = TL.getTypePtr();
6103 QualType ElementType = getDerived().TransformType(T->getElementType());
6104 if (ElementType.isNull())
6105 return QualType();
6106
6107 QualType Result = TL.getType();
6108 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
6109 Result = getDerived().RebuildConstantMatrixType(
6110 ElementType, T->getNumRows(), T->getNumColumns());
6111 if (Result.isNull())
6112 return QualType();
6113 }
6114
6116 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6117 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6118 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
6119 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
6120
6121 return Result;
6122}
6123
6124template <typename Derived>
6127 const DependentSizedMatrixType *T = TL.getTypePtr();
6128
6129 QualType ElementType = getDerived().TransformType(T->getElementType());
6130 if (ElementType.isNull()) {
6131 return QualType();
6132 }
6133
6134 // Matrix dimensions are constant expressions.
6137
6138 Expr *origRows = TL.getAttrRowOperand();
6139 if (!origRows)
6140 origRows = T->getRowExpr();
6141 Expr *origColumns = TL.getAttrColumnOperand();
6142 if (!origColumns)
6143 origColumns = T->getColumnExpr();
6144
6145 ExprResult rowResult = getDerived().TransformExpr(origRows);
6146 rowResult = SemaRef.ActOnConstantExpression(rowResult);
6147 if (rowResult.isInvalid())
6148 return QualType();
6149
6150 ExprResult columnResult = getDerived().TransformExpr(origColumns);
6151 columnResult = SemaRef.ActOnConstantExpression(columnResult);
6152 if (columnResult.isInvalid())
6153 return QualType();
6154
6155 Expr *rows = rowResult.get();
6156 Expr *columns = columnResult.get();
6157
6158 QualType Result = TL.getType();
6159 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6160 rows != origRows || columns != origColumns) {
6161 Result = getDerived().RebuildDependentSizedMatrixType(
6162 ElementType, rows, columns, T->getAttributeLoc());
6163
6164 if (Result.isNull())
6165 return QualType();
6166 }
6167
6168 // We might have any sort of matrix type now, but fortunately they
6169 // all have the same location layout.
6170 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
6171 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6172 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6173 NewTL.setAttrRowOperand(rows);
6174 NewTL.setAttrColumnOperand(columns);
6175 return Result;
6176}
6177
6178template <typename Derived>
6181 const DependentAddressSpaceType *T = TL.getTypePtr();
6182
6183 QualType pointeeType =
6184 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
6185
6186 if (pointeeType.isNull())
6187 return QualType();
6188
6189 // Address spaces are constant expressions.
6192
6193 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
6194 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
6195 if (AddrSpace.isInvalid())
6196 return QualType();
6197
6198 QualType Result = TL.getType();
6199 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
6200 AddrSpace.get() != T->getAddrSpaceExpr()) {
6201 Result = getDerived().RebuildDependentAddressSpaceType(
6202 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6203 if (Result.isNull())
6204 return QualType();
6205 }
6206
6207 // Result might be dependent or not.
6211
6212 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6213 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6214 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6215
6216 } else {
6217 TLB.TypeWasModifiedSafely(Result);
6218 }
6219
6220 return Result;
6221}
6222
6223template <typename Derived>
6225 VectorTypeLoc TL) {
6226 const VectorType *T = TL.getTypePtr();
6227 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6228 if (ElementType.isNull())
6229 return QualType();
6230
6231 QualType Result = TL.getType();
6232 if (getDerived().AlwaysRebuild() ||
6233 ElementType != T->getElementType()) {
6234 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6235 T->getVectorKind());
6236 if (Result.isNull())
6237 return QualType();
6238 }
6239
6240 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6241 NewTL.setNameLoc(TL.getNameLoc());
6242
6243 return Result;
6244}
6245
6246template<typename Derived>
6248 ExtVectorTypeLoc TL) {
6249 const VectorType *T = TL.getTypePtr();
6250 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6251 if (ElementType.isNull())
6252 return QualType();
6253
6254 QualType Result = TL.getType();
6255 if (getDerived().AlwaysRebuild() ||
6256 ElementType != T->getElementType()) {
6257 Result = getDerived().RebuildExtVectorType(ElementType,
6258 T->getNumElements(),
6259 /*FIXME*/ SourceLocation());
6260 if (Result.isNull())
6261 return QualType();
6262 }
6263
6264 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6265 NewTL.setNameLoc(TL.getNameLoc());
6266
6267 return Result;
6268}
6269
6270template <typename Derived>
6272 ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions,
6273 bool ExpectParameterPack) {
6274 TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
6275 TypeSourceInfo *NewTSI = nullptr;
6276
6277 if (NumExpansions && isa<PackExpansionType>(OldTSI->getType())) {
6278 // If we're substituting into a pack expansion type and we know the
6279 // length we want to expand to, just substitute for the pattern.
6280 TypeLoc OldTL = OldTSI->getTypeLoc();
6281 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6282
6283 TypeLocBuilder TLB;
6284 TypeLoc NewTL = OldTSI->getTypeLoc();
6285 TLB.reserve(NewTL.getFullDataSize());
6286
6287 QualType Result = getDerived().TransformType(TLB,
6288 OldExpansionTL.getPatternLoc());
6289 if (Result.isNull())
6290 return nullptr;
6291
6293 OldExpansionTL.getPatternLoc().getSourceRange(),
6294 OldExpansionTL.getEllipsisLoc(),
6295 NumExpansions);
6296 if (Result.isNull())
6297 return nullptr;
6298
6299 PackExpansionTypeLoc NewExpansionTL
6300 = TLB.push<PackExpansionTypeLoc>(Result);
6301 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6302 NewTSI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6303 } else
6304 NewTSI = getDerived().TransformType(OldTSI);
6305 if (!NewTSI)
6306 return nullptr;
6307
6308 if (NewTSI == OldTSI && indexAdjustment == 0)
6309 return OldParm;
6310
6312 SemaRef.Context, OldParm->getDeclContext(), OldParm->getInnerLocStart(),
6313 OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
6314 NewTSI, OldParm->getStorageClass(),
6315 /* DefArg */ nullptr);
6316 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6317 OldParm->getFunctionScopeIndex() + indexAdjustment);
6318 getDerived().transformedLocalDecl(OldParm, {newParm});
6319 return newParm;
6320}
6321
6322template <typename Derived>
6325 const QualType *ParamTypes,
6326 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6327 SmallVectorImpl<QualType> &OutParamTypes,
6330 unsigned *LastParamTransformed) {
6331 int indexAdjustment = 0;
6332
6333 unsigned NumParams = Params.size();
6334 for (unsigned i = 0; i != NumParams; ++i) {
6335 if (LastParamTransformed)
6336 *LastParamTransformed = i;
6337 if (ParmVarDecl *OldParm = Params[i]) {
6338 assert(OldParm->getFunctionScopeIndex() == i);
6339
6340 UnsignedOrNone NumExpansions = std::nullopt;
6341 ParmVarDecl *NewParm = nullptr;
6342 if (OldParm->isParameterPack()) {
6343 // We have a function parameter pack that may need to be expanded.
6345
6346 // Find the parameter packs that could be expanded.
6347 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6349 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6350 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6351
6352 // Determine whether we should expand the parameter packs.
6353 bool ShouldExpand = false;
6354 bool RetainExpansion = false;
6355 UnsignedOrNone OrigNumExpansions = std::nullopt;
6356 if (Unexpanded.size() > 0) {
6357 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6358 NumExpansions = OrigNumExpansions;
6360 ExpansionTL.getEllipsisLoc(), Pattern.getSourceRange(),
6361 Unexpanded, /*FailOnPackProducingTemplates=*/true,
6362 ShouldExpand, RetainExpansion, NumExpansions)) {
6363 return true;
6364 }
6365 } else {
6366#ifndef NDEBUG
6367 const AutoType *AT =
6368 Pattern.getType().getTypePtr()->getContainedAutoType();
6369 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6370 "Could not find parameter packs or undeduced auto type!");
6371#endif
6372 }
6373
6374 if (ShouldExpand) {
6375 // Expand the function parameter pack into multiple, separate
6376 // parameters.
6377 getDerived().ExpandingFunctionParameterPack(OldParm);
6378 for (unsigned I = 0; I != *NumExpansions; ++I) {
6379 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6380 ParmVarDecl *NewParm
6381 = getDerived().TransformFunctionTypeParam(OldParm,
6382 indexAdjustment++,
6383 OrigNumExpansions,
6384 /*ExpectParameterPack=*/false);
6385 if (!NewParm)
6386 return true;
6387
6388 if (ParamInfos)
6389 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6390 OutParamTypes.push_back(NewParm->getType());
6391 if (PVars)
6392 PVars->push_back(NewParm);
6393 }
6394
6395 // If we're supposed to retain a pack expansion, do so by temporarily
6396 // forgetting the partially-substituted parameter pack.
6397 if (RetainExpansion) {
6398 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6399 ParmVarDecl *NewParm
6400 = getDerived().TransformFunctionTypeParam(OldParm,
6401 indexAdjustment++,
6402 OrigNumExpansions,
6403 /*ExpectParameterPack=*/false);
6404 if (!NewParm)
6405 return true;
6406
6407 if (ParamInfos)
6408 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6409 OutParamTypes.push_back(NewParm->getType());
6410 if (PVars)
6411 PVars->push_back(NewParm);
6412 }
6413
6414 // The next parameter should have the same adjustment as the
6415 // last thing we pushed, but we post-incremented indexAdjustment
6416 // on every push. Also, if we push nothing, the adjustment should
6417 // go down by one.
6418 indexAdjustment--;
6419
6420 // We're done with the pack expansion.
6421 continue;
6422 }
6423
6424 // We'll substitute the parameter now without expanding the pack
6425 // expansion.
6426 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6427 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6428 indexAdjustment,
6429 NumExpansions,
6430 /*ExpectParameterPack=*/true);
6431 assert(NewParm->isParameterPack() &&
6432 "Parameter pack no longer a parameter pack after "
6433 "transformation.");
6434 } else {
6435 NewParm = getDerived().TransformFunctionTypeParam(
6436 OldParm, indexAdjustment, std::nullopt,
6437 /*ExpectParameterPack=*/false);
6438 }
6439
6440 if (!NewParm)
6441 return true;
6442
6443 if (ParamInfos)
6444 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6445 OutParamTypes.push_back(NewParm->getType());
6446 if (PVars)
6447 PVars->push_back(NewParm);
6448 continue;
6449 }
6450
6451 // Deal with the possibility that we don't have a parameter
6452 // declaration for this parameter.
6453 assert(ParamTypes);
6454 QualType OldType = ParamTypes[i];
6455 bool IsPackExpansion = false;
6456 UnsignedOrNone NumExpansions = std::nullopt;
6457 QualType NewType;
6458 if (const PackExpansionType *Expansion
6459 = dyn_cast<PackExpansionType>(OldType)) {
6460 // We have a function parameter pack that may need to be expanded.
6461 QualType Pattern = Expansion->getPattern();
6463 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6464
6465 // Determine whether we should expand the parameter packs.
6466 bool ShouldExpand = false;
6467 bool RetainExpansion = false;
6469 Loc, SourceRange(), Unexpanded,
6470 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
6471 RetainExpansion, NumExpansions)) {
6472 return true;
6473 }
6474
6475 if (ShouldExpand) {
6476 // Expand the function parameter pack into multiple, separate
6477 // parameters.
6478 for (unsigned I = 0; I != *NumExpansions; ++I) {
6479 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6480 QualType NewType = getDerived().TransformType(Pattern);
6481 if (NewType.isNull())
6482 return true;
6483
6484 if (NewType->containsUnexpandedParameterPack()) {
6485 NewType = getSema().getASTContext().getPackExpansionType(
6486 NewType, std::nullopt);
6487
6488 if (NewType.isNull())
6489 return true;
6490 }
6491
6492 if (ParamInfos)
6493 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6494 OutParamTypes.push_back(NewType);
6495 if (PVars)
6496 PVars->push_back(nullptr);
6497 }
6498
6499 // We're done with the pack expansion.
6500 continue;
6501 }
6502
6503 // If we're supposed to retain a pack expansion, do so by temporarily
6504 // forgetting the partially-substituted parameter pack.
6505 if (RetainExpansion) {
6506 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6507 QualType NewType = getDerived().TransformType(Pattern);
6508 if (NewType.isNull())
6509 return true;
6510
6511 if (ParamInfos)
6512 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6513 OutParamTypes.push_back(NewType);
6514 if (PVars)
6515 PVars->push_back(nullptr);
6516 }
6517
6518 // We'll substitute the parameter now without expanding the pack
6519 // expansion.
6520 OldType = Expansion->getPattern();
6521 IsPackExpansion = true;
6522 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6523 NewType = getDerived().TransformType(OldType);
6524 } else {
6525 NewType = getDerived().TransformType(OldType);
6526 }
6527
6528 if (NewType.isNull())
6529 return true;
6530
6531 if (IsPackExpansion)
6532 NewType = getSema().Context.getPackExpansionType(NewType,
6533 NumExpansions);
6534
6535 if (ParamInfos)
6536 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6537 OutParamTypes.push_back(NewType);
6538 if (PVars)
6539 PVars->push_back(nullptr);
6540 }
6541
6542#ifndef NDEBUG
6543 if (PVars) {
6544 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6545 if (ParmVarDecl *parm = (*PVars)[i])
6546 assert(parm->getFunctionScopeIndex() == i);
6547 }
6548#endif
6549
6550 return false;
6551}
6552
6553template<typename Derived>
6557 SmallVector<QualType, 4> ExceptionStorage;
6558 return getDerived().TransformFunctionProtoType(
6559 TLB, TL, nullptr, Qualifiers(),
6560 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6561 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6562 ExceptionStorage, Changed);
6563 });
6564}
6565
6566template<typename Derived> template<typename Fn>
6568 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6569 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6570
6571 // Transform the parameters and return type.
6572 //
6573 // We are required to instantiate the params and return type in source order.
6574 // When the function has a trailing return type, we instantiate the
6575 // parameters before the return type, since the return type can then refer
6576 // to the parameters themselves (via decltype, sizeof, etc.).
6577 //
6578 SmallVector<QualType, 4> ParamTypes;
6580 Sema::ExtParameterInfoBuilder ExtParamInfos;
6581 const FunctionProtoType *T = TL.getTypePtr();
6582
6583 QualType ResultType;
6584
6585 if (T->hasTrailingReturn()) {
6587 TL.getBeginLoc(), TL.getParams(),
6589 T->getExtParameterInfosOrNull(),
6590 ParamTypes, &ParamDecls, ExtParamInfos))
6591 return QualType();
6592
6593 {
6594 // C++11 [expr.prim.general]p3:
6595 // If a declaration declares a member function or member function
6596 // template of a class X, the expression this is a prvalue of type
6597 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6598 // and the end of the function-definition, member-declarator, or
6599 // declarator.
6600 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6601 Sema::CXXThisScopeRAII ThisScope(
6602 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6603
6604 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6605 if (ResultType.isNull())
6606 return QualType();
6607 }
6608 }
6609 else {
6610 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6611 if (ResultType.isNull())
6612 return QualType();
6613
6615 TL.getBeginLoc(), TL.getParams(),
6617 T->getExtParameterInfosOrNull(),
6618 ParamTypes, &ParamDecls, ExtParamInfos))
6619 return QualType();
6620 }
6621
6622 FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
6623
6624 bool EPIChanged = false;
6625 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6626 return QualType();
6627
6628 // Handle extended parameter information.
6629 if (auto NewExtParamInfos =
6630 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6631 if (!EPI.ExtParameterInfos ||
6633 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6634 EPIChanged = true;
6635 }
6636 EPI.ExtParameterInfos = NewExtParamInfos;
6637 } else if (EPI.ExtParameterInfos) {
6638 EPIChanged = true;
6639 EPI.ExtParameterInfos = nullptr;
6640 }
6641
6642 // Transform any function effects with unevaluated conditions.
6643 // Hold this set in a local for the rest of this function, since EPI
6644 // may need to hold a FunctionEffectsRef pointing into it.
6645 std::optional<FunctionEffectSet> NewFX;
6646 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6647 NewFX.emplace();
6650
6651 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6652 FunctionEffectWithCondition NewEC = PrevEC;
6653 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6654 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6655 if (NewExpr.isInvalid())
6656 return QualType();
6657 std::optional<FunctionEffectMode> Mode =
6658 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6659 if (!Mode)
6660 return QualType();
6661
6662 // The condition expression has been transformed, and re-evaluated.
6663 // It may or may not have become constant.
6664 switch (*Mode) {
6666 NewEC.Cond = {};
6667 break;
6669 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6670 NewEC.Cond = {};
6671 break;
6673 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6674 break;
6676 llvm_unreachable(
6677 "FunctionEffectMode::None shouldn't be possible here");
6678 }
6679 }
6680 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6681 TL.getBeginLoc())) {
6683 NewFX->insert(NewEC, Errs);
6684 assert(Errs.empty());
6685 }
6686 }
6687 EPI.FunctionEffects = *NewFX;
6688 EPIChanged = true;
6689 }
6690
6691 QualType Result = TL.getType();
6692 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6693 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6694 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6695 if (Result.isNull())
6696 return QualType();
6697 }
6698
6701 NewTL.setLParenLoc(TL.getLParenLoc());
6702 NewTL.setRParenLoc(TL.getRParenLoc());
6705 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6706 NewTL.setParam(i, ParamDecls[i]);
6707
6708 return Result;
6709}
6710
6711template<typename Derived>
6714 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6715 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6716
6717 // Instantiate a dynamic noexcept expression, if any.
6718 if (isComputedNoexcept(ESI.Type)) {
6719 // Update this scrope because ContextDecl in Sema will be used in
6720 // TransformExpr.
6721 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6722 Sema::CXXThisScopeRAII ThisScope(
6723 SemaRef, Method ? Method->getParent() : nullptr,
6724 Method ? Method->getMethodQualifiers() : Qualifiers{},
6725 Method != nullptr);
6728 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6729 if (NoexceptExpr.isInvalid())
6730 return true;
6731
6733 NoexceptExpr =
6734 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6735 if (NoexceptExpr.isInvalid())
6736 return true;
6737
6738 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6739 Changed = true;
6740 ESI.NoexceptExpr = NoexceptExpr.get();
6741 ESI.Type = EST;
6742 }
6743
6744 if (ESI.Type != EST_Dynamic)
6745 return false;
6746
6747 // Instantiate a dynamic exception specification's type.
6748 for (QualType T : ESI.Exceptions) {
6749 if (const PackExpansionType *PackExpansion =
6750 T->getAs<PackExpansionType>()) {
6751 Changed = true;
6752
6753 // We have a pack expansion. Instantiate it.
6755 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6756 Unexpanded);
6757 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6758
6759 // Determine whether the set of unexpanded parameter packs can and
6760 // should
6761 // be expanded.
6762 bool Expand = false;
6763 bool RetainExpansion = false;
6764 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
6765 // FIXME: Track the location of the ellipsis (and track source location
6766 // information for the types in the exception specification in general).
6768 Loc, SourceRange(), Unexpanded,
6769 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
6770 NumExpansions))
6771 return true;
6772
6773 if (!Expand) {
6774 // We can't expand this pack expansion into separate arguments yet;
6775 // just substitute into the pattern and create a new pack expansion
6776 // type.
6777 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6778 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6779 if (U.isNull())
6780 return true;
6781
6782 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6783 Exceptions.push_back(U);
6784 continue;
6785 }
6786
6787 // Substitute into the pack expansion pattern for each slice of the
6788 // pack.
6789 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6790 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
6791
6792 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6793 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6794 return true;
6795
6796 Exceptions.push_back(U);
6797 }
6798 } else {
6799 QualType U = getDerived().TransformType(T);
6800 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6801 return true;
6802 if (T != U)
6803 Changed = true;
6804
6805 Exceptions.push_back(U);
6806 }
6807 }
6808
6809 ESI.Exceptions = Exceptions;
6810 if (ESI.Exceptions.empty())
6811 ESI.Type = EST_DynamicNone;
6812 return false;
6813}
6814
6815template<typename Derived>
6817 TypeLocBuilder &TLB,
6819 const FunctionNoProtoType *T = TL.getTypePtr();
6820 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6821 if (ResultType.isNull())
6822 return QualType();
6823
6824 QualType Result = TL.getType();
6825 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6826 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6827
6830 NewTL.setLParenLoc(TL.getLParenLoc());
6831 NewTL.setRParenLoc(TL.getRParenLoc());
6833
6834 return Result;
6835}
6836
6837template <typename Derived>
6838QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6839 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6840
6841 const UnresolvedUsingType *T = TL.getTypePtr();
6842 bool Changed = false;
6843
6844 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6845 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6846 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6847 if (!QualifierLoc)
6848 return QualType();
6849 Changed |= QualifierLoc != OldQualifierLoc;
6850 }
6851
6852 auto *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6853 if (!D)
6854 return QualType();
6855 Changed |= D != T->getDecl();
6856
6857 QualType Result = TL.getType();
6858 if (getDerived().AlwaysRebuild() || Changed) {
6859 Result = getDerived().RebuildUnresolvedUsingType(
6860 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TL.getNameLoc(),
6861 D);
6862 if (Result.isNull())
6863 return QualType();
6864 }
6865
6867 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6868 QualifierLoc, TL.getNameLoc());
6869 else
6870 TLB.push<UnresolvedUsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6871 QualifierLoc, TL.getNameLoc());
6872 return Result;
6873}
6874
6875template <typename Derived>
6877 UsingTypeLoc TL) {
6878 const UsingType *T = TL.getTypePtr();
6879 bool Changed = false;
6880
6881 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6882 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6883 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6884 if (!QualifierLoc)
6885 return QualType();
6886 Changed |= QualifierLoc != OldQualifierLoc;
6887 }
6888
6889 auto *D = cast_or_null<UsingShadowDecl>(
6890 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6891 if (!D)
6892 return QualType();
6893 Changed |= D != T->getDecl();
6894
6895 QualType UnderlyingType = getDerived().TransformType(T->desugar());
6896 if (UnderlyingType.isNull())
6897 return QualType();
6898 Changed |= UnderlyingType != T->desugar();
6899
6900 QualType Result = TL.getType();
6901 if (getDerived().AlwaysRebuild() || Changed) {
6902 Result = getDerived().RebuildUsingType(
6903 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), D,
6904 UnderlyingType);
6905 if (Result.isNull())
6906 return QualType();
6907 }
6908 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(), QualifierLoc,
6909 TL.getNameLoc());
6910 return Result;
6911}
6912
6913template<typename Derived>
6915 TypedefTypeLoc TL) {
6916 const TypedefType *T = TL.getTypePtr();
6917 bool Changed = false;
6918
6919 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6920 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6921 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6922 if (!QualifierLoc)
6923 return QualType();
6924 Changed |= QualifierLoc != OldQualifierLoc;
6925 }
6926
6927 auto *Typedef = cast_or_null<TypedefNameDecl>(
6928 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6929 if (!Typedef)
6930 return QualType();
6931 Changed |= Typedef != T->getDecl();
6932
6933 // FIXME: Transform the UnderlyingType if different from decl.
6934
6935 QualType Result = TL.getType();
6936 if (getDerived().AlwaysRebuild() || Changed) {
6937 Result = getDerived().RebuildTypedefType(
6938 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), Typedef);
6939 if (Result.isNull())
6940 return QualType();
6941 }
6942
6943 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6944 QualifierLoc, TL.getNameLoc());
6945 return Result;
6946}
6947
6948template<typename Derived>
6950 TypeOfExprTypeLoc TL) {
6951 // typeof expressions are not potentially evaluated contexts
6955
6956 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
6957 if (E.isInvalid())
6958 return QualType();
6959
6960 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
6961 if (E.isInvalid())
6962 return QualType();
6963
6964 QualType Result = TL.getType();
6966 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
6967 Result =
6968 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
6969 if (Result.isNull())
6970 return QualType();
6971 }
6972
6973 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
6974 NewTL.setTypeofLoc(TL.getTypeofLoc());
6975 NewTL.setLParenLoc(TL.getLParenLoc());
6976 NewTL.setRParenLoc(TL.getRParenLoc());
6977
6978 return Result;
6979}
6980
6981template<typename Derived>
6983 TypeOfTypeLoc TL) {
6984 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
6985 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
6986 if (!New_Under_TI)
6987 return QualType();
6988
6989 QualType Result = TL.getType();
6990 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
6991 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
6992 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
6993 if (Result.isNull())
6994 return QualType();
6995 }
6996
6997 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
6998 NewTL.setTypeofLoc(TL.getTypeofLoc());
6999 NewTL.setLParenLoc(TL.getLParenLoc());
7000 NewTL.setRParenLoc(TL.getRParenLoc());
7001 NewTL.setUnmodifiedTInfo(New_Under_TI);
7002
7003 return Result;
7004}
7005
7006template<typename Derived>
7008 DecltypeTypeLoc TL) {
7009 const DecltypeType *T = TL.getTypePtr();
7010
7011 // decltype expressions are not potentially evaluated contexts
7015
7016 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
7017 if (E.isInvalid())
7018 return QualType();
7019
7020 E = getSema().ActOnDecltypeExpression(E.get());
7021 if (E.isInvalid())
7022 return QualType();
7023
7024 QualType Result = TL.getType();
7025 if (getDerived().AlwaysRebuild() ||
7026 E.get() != T->getUnderlyingExpr()) {
7027 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
7028 if (Result.isNull())
7029 return QualType();
7030 }
7031 else E.get();
7032
7033 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
7034 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
7035 NewTL.setRParenLoc(TL.getRParenLoc());
7036 return Result;
7037}
7038
7039template <typename Derived>
7043 // Transform the index
7044 ExprResult IndexExpr;
7045 {
7046 EnterExpressionEvaluationContext ConstantContext(
7048
7049 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
7050 if (IndexExpr.isInvalid())
7051 return QualType();
7052 }
7053 QualType Pattern = TL.getPattern();
7054
7055 const PackIndexingType *PIT = TL.getTypePtr();
7056 SmallVector<QualType, 5> SubtitutedTypes;
7057 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
7058
7059 bool NotYetExpanded = Types.empty();
7060 bool FullySubstituted = true;
7061
7062 if (Types.empty() && !PIT->expandsToEmptyPack())
7063 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
7064
7065 for (QualType T : Types) {
7066 if (!T->containsUnexpandedParameterPack()) {
7067 QualType Transformed = getDerived().TransformType(T);
7068 if (Transformed.isNull())
7069 return QualType();
7070 SubtitutedTypes.push_back(Transformed);
7071 continue;
7072 }
7073
7075 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
7076 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7077 // Determine whether the set of unexpanded parameter packs can and should
7078 // be expanded.
7079 bool ShouldExpand = true;
7080 bool RetainExpansion = false;
7081 UnsignedOrNone NumExpansions = std::nullopt;
7082 if (getDerived().TryExpandParameterPacks(
7083 TL.getEllipsisLoc(), SourceRange(), Unexpanded,
7084 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
7085 RetainExpansion, NumExpansions))
7086 return QualType();
7087 if (!ShouldExpand) {
7088 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7089 // FIXME: should we keep TypeLoc for individual expansions in
7090 // PackIndexingTypeLoc?
7091 TypeSourceInfo *TI =
7092 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
7093 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
7094 if (Pack.isNull())
7095 return QualType();
7096 if (NotYetExpanded) {
7097 FullySubstituted = false;
7098 QualType Out = getDerived().RebuildPackIndexingType(
7099 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7100 FullySubstituted);
7101 if (Out.isNull())
7102 return QualType();
7103
7105 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7106 return Out;
7107 }
7108 SubtitutedTypes.push_back(Pack);
7109 continue;
7110 }
7111 for (unsigned I = 0; I != *NumExpansions; ++I) {
7112 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
7113 QualType Out = getDerived().TransformType(T);
7114 if (Out.isNull())
7115 return QualType();
7116 SubtitutedTypes.push_back(Out);
7117 FullySubstituted &= !Out->containsUnexpandedParameterPack();
7118 }
7119 // If we're supposed to retain a pack expansion, do so by temporarily
7120 // forgetting the partially-substituted parameter pack.
7121 if (RetainExpansion) {
7122 FullySubstituted = false;
7123 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
7124 QualType Out = getDerived().TransformType(T);
7125 if (Out.isNull())
7126 return QualType();
7127 SubtitutedTypes.push_back(Out);
7128 }
7129 }
7130
7131 // A pack indexing type can appear in a larger pack expansion,
7132 // e.g. `Pack...[pack_of_indexes]...`
7133 // so we need to temporarily disable substitution of pack elements
7134 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7135 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
7136
7137 QualType Out = getDerived().RebuildPackIndexingType(
7138 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7139 FullySubstituted, SubtitutedTypes);
7140 if (Out.isNull())
7141 return Out;
7142
7144 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7145 return Out;
7146}
7147
7148template<typename Derived>
7150 TypeLocBuilder &TLB,
7152 QualType Result = TL.getType();
7153 TypeSourceInfo *NewBaseTSI = TL.getUnderlyingTInfo();
7154 if (Result->isDependentType()) {
7155 const UnaryTransformType *T = TL.getTypePtr();
7156
7157 NewBaseTSI = getDerived().TransformType(TL.getUnderlyingTInfo());
7158 if (!NewBaseTSI)
7159 return QualType();
7160 QualType NewBase = NewBaseTSI->getType();
7161
7162 Result = getDerived().RebuildUnaryTransformType(NewBase,
7163 T->getUTTKind(),
7164 TL.getKWLoc());
7165 if (Result.isNull())
7166 return QualType();
7167 }
7168
7170 NewTL.setKWLoc(TL.getKWLoc());
7171 NewTL.setParensRange(TL.getParensRange());
7172 NewTL.setUnderlyingTInfo(NewBaseTSI);
7173 return Result;
7174}
7175
7176template<typename Derived>
7179 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
7180
7181 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7182 TemplateName TemplateName = getDerived().TransformTemplateName(
7183 QualifierLoc, /*TemplateKELoc=*/SourceLocation(), T->getTemplateName(),
7184 TL.getTemplateNameLoc());
7185 if (TemplateName.isNull())
7186 return QualType();
7187
7188 QualType OldDeduced = T->getDeducedType();
7189 QualType NewDeduced;
7190 if (!OldDeduced.isNull()) {
7191 NewDeduced = getDerived().TransformType(OldDeduced);
7192 if (NewDeduced.isNull())
7193 return QualType();
7194 }
7195
7196 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
7197 T->getKeyword(), TemplateName, NewDeduced);
7198 if (Result.isNull())
7199 return QualType();
7200
7201 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7202 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7203 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7204 NewTL.setQualifierLoc(QualifierLoc);
7205 return Result;
7206}
7207
7208template <typename Derived>
7210 TagTypeLoc TL) {
7211 const TagType *T = TL.getTypePtr();
7212
7213 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7214 if (QualifierLoc) {
7215 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7216 if (!QualifierLoc)
7217 return QualType();
7218 }
7219
7220 auto *TD = cast_or_null<TagDecl>(
7221 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7222 if (!TD)
7223 return QualType();
7224
7225 QualType Result = TL.getType();
7226 if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() ||
7227 TD != T->getDecl()) {
7228 if (T->isCanonicalUnqualified())
7229 Result = getDerived().RebuildCanonicalTagType(TD);
7230 else
7231 Result = getDerived().RebuildTagType(
7232 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TD);
7233 if (Result.isNull())
7234 return QualType();
7235 }
7236
7237 TagTypeLoc NewTL = TLB.push<TagTypeLoc>(Result);
7239 NewTL.setQualifierLoc(QualifierLoc);
7240 NewTL.setNameLoc(TL.getNameLoc());
7241
7242 return Result;
7243}
7244
7245template <typename Derived>
7247 EnumTypeLoc TL) {
7248 return getDerived().TransformTagType(TLB, TL);
7249}
7250
7251template <typename Derived>
7252QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
7253 RecordTypeLoc TL) {
7254 return getDerived().TransformTagType(TLB, TL);
7255}
7256
7257template<typename Derived>
7259 TypeLocBuilder &TLB,
7261 return getDerived().TransformTagType(TLB, TL);
7262}
7263
7264template<typename Derived>
7266 TypeLocBuilder &TLB,
7268 return getDerived().TransformTemplateTypeParmType(
7269 TLB, TL,
7270 /*SuppressObjCLifetime=*/false);
7271}
7272
7273template <typename Derived>
7275 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7276 return TransformTypeSpecType(TLB, TL);
7277}
7278
7279template<typename Derived>
7280QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7281 TypeLocBuilder &TLB,
7282 SubstTemplateTypeParmTypeLoc TL) {
7283 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7284
7285 Decl *NewReplaced =
7286 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7287
7288 // Substitute into the replacement type, which itself might involve something
7289 // that needs to be transformed. This only tends to occur with default
7290 // template arguments of template template parameters.
7291 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7292 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7293 if (Replacement.isNull())
7294 return QualType();
7295
7296 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7297 Replacement, NewReplaced, T->getIndex(), T->getPackIndex(),
7298 T->getFinal());
7299
7300 // Propagate type-source information.
7301 SubstTemplateTypeParmTypeLoc NewTL
7302 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7303 NewTL.setNameLoc(TL.getNameLoc());
7304 return Result;
7305
7306}
7307template <typename Derived>
7310 return TransformTypeSpecType(TLB, TL);
7311}
7312
7313template<typename Derived>
7315 TypeLocBuilder &TLB,
7317 return getDerived().TransformSubstTemplateTypeParmPackType(
7318 TLB, TL, /*SuppressObjCLifetime=*/false);
7319}
7320
7321template <typename Derived>
7324 return TransformTypeSpecType(TLB, TL);
7325}
7326
7327template<typename Derived>
7328QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
7329 AtomicTypeLoc TL) {
7330 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7331 if (ValueType.isNull())
7332 return QualType();
7333
7334 QualType Result = TL.getType();
7335 if (getDerived().AlwaysRebuild() ||
7336 ValueType != TL.getValueLoc().getType()) {
7337 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7338 if (Result.isNull())
7339 return QualType();
7340 }
7341
7342 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7343 NewTL.setKWLoc(TL.getKWLoc());
7344 NewTL.setLParenLoc(TL.getLParenLoc());
7345 NewTL.setRParenLoc(TL.getRParenLoc());
7346
7347 return Result;
7348}
7349
7350template <typename Derived>
7352 PipeTypeLoc TL) {
7353 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7354 if (ValueType.isNull())
7355 return QualType();
7356
7357 QualType Result = TL.getType();
7358 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7359 const PipeType *PT = Result->castAs<PipeType>();
7360 bool isReadPipe = PT->isReadOnly();
7361 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7362 if (Result.isNull())
7363 return QualType();
7364 }
7365
7366 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7367 NewTL.setKWLoc(TL.getKWLoc());
7368
7369 return Result;
7370}
7371
7372template <typename Derived>
7374 BitIntTypeLoc TL) {
7375 const BitIntType *EIT = TL.getTypePtr();
7376 QualType Result = TL.getType();
7377
7378 if (getDerived().AlwaysRebuild()) {
7379 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7380 EIT->getNumBits(), TL.getNameLoc());
7381 if (Result.isNull())
7382 return QualType();
7383 }
7384
7385 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7386 NewTL.setNameLoc(TL.getNameLoc());
7387 return Result;
7388}
7389
7390template <typename Derived>
7393 const DependentBitIntType *EIT = TL.getTypePtr();
7394
7397 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7398 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7399
7400 if (BitsExpr.isInvalid())
7401 return QualType();
7402
7403 QualType Result = TL.getType();
7404
7405 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7406 Result = getDerived().RebuildDependentBitIntType(
7407 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7408
7409 if (Result.isNull())
7410 return QualType();
7411 }
7412
7415 NewTL.setNameLoc(TL.getNameLoc());
7416 } else {
7417 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7418 NewTL.setNameLoc(TL.getNameLoc());
7419 }
7420 return Result;
7421}
7422
7423template <typename Derived>
7426 llvm_unreachable("This type does not need to be transformed.");
7427}
7428
7429 /// Simple iterator that traverses the template arguments in a
7430 /// container that provides a \c getArgLoc() member function.
7431 ///
7432 /// This iterator is intended to be used with the iterator form of
7433 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7434 template<typename ArgLocContainer>
7436 ArgLocContainer *Container;
7437 unsigned Index;
7438
7439 public:
7442 typedef int difference_type;
7443 typedef std::input_iterator_tag iterator_category;
7444
7445 class pointer {
7447
7448 public:
7449 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7450
7452 return &Arg;
7453 }
7454 };
7455
7456
7458
7459 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7460 unsigned Index)
7461 : Container(&Container), Index(Index) { }
7462
7464 ++Index;
7465 return *this;
7466 }
7467
7470 ++(*this);
7471 return Old;
7472 }
7473
7475 return Container->getArgLoc(Index);
7476 }
7477
7479 return pointer(Container->getArgLoc(Index));
7480 }
7481
7484 return X.Container == Y.Container && X.Index == Y.Index;
7485 }
7486
7489 return !(X == Y);
7490 }
7491 };
7492
7493template<typename Derived>
7494QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7495 AutoTypeLoc TL) {
7496 const AutoType *T = TL.getTypePtr();
7497 QualType OldDeduced = T->getDeducedType();
7498 QualType NewDeduced;
7499 if (!OldDeduced.isNull()) {
7500 NewDeduced = getDerived().TransformType(OldDeduced);
7501 if (NewDeduced.isNull())
7502 return QualType();
7503 }
7504
7505 ConceptDecl *NewCD = nullptr;
7506 TemplateArgumentListInfo NewTemplateArgs;
7507 NestedNameSpecifierLoc NewNestedNameSpec;
7508 if (T->isConstrained()) {
7509 assert(TL.getConceptReference());
7510 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7511 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7512
7513 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7514 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7516 if (getDerived().TransformTemplateArguments(
7517 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7518 NewTemplateArgs))
7519 return QualType();
7520
7521 if (TL.getNestedNameSpecifierLoc()) {
7522 NewNestedNameSpec
7523 = getDerived().TransformNestedNameSpecifierLoc(
7524 TL.getNestedNameSpecifierLoc());
7525 if (!NewNestedNameSpec)
7526 return QualType();
7527 }
7528 }
7529
7530 QualType Result = TL.getType();
7531 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7532 T->isDependentType() || T->isConstrained()) {
7533 // FIXME: Maybe don't rebuild if all template arguments are the same.
7535 NewArgList.reserve(NewTemplateArgs.size());
7536 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7537 NewArgList.push_back(ArgLoc.getArgument());
7538 Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword(), NewCD,
7539 NewArgList);
7540 if (Result.isNull())
7541 return QualType();
7542 }
7543
7544 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7545 NewTL.setNameLoc(TL.getNameLoc());
7546 NewTL.setRParenLoc(TL.getRParenLoc());
7547 NewTL.setConceptReference(nullptr);
7548
7549 if (T->isConstrained()) {
7551 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7552 TL.getConceptNameLoc(),
7553 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7554 auto *CR = ConceptReference::Create(
7555 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7556 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7557 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7558 NewTL.setConceptReference(CR);
7559 }
7560
7561 return Result;
7562}
7563
7564template <typename Derived>
7567 return getDerived().TransformTemplateSpecializationType(
7568 TLB, TL, /*ObjectType=*/QualType(), /*FirstQualifierInScope=*/nullptr,
7569 /*AllowInjectedClassName=*/false);
7570}
7571
7572template <typename Derived>
7575 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
7576 const TemplateSpecializationType *T = TL.getTypePtr();
7577
7578 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7579 TemplateName Template = getDerived().TransformTemplateName(
7580 QualifierLoc, TL.getTemplateKeywordLoc(), T->getTemplateName(),
7581 TL.getTemplateNameLoc(), ObjectType, FirstQualifierInScope,
7582 AllowInjectedClassName);
7583 if (Template.isNull())
7584 return QualType();
7585
7586 TemplateArgumentListInfo NewTemplateArgs;
7587 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7588 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7590 ArgIterator;
7591 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7592 ArgIterator(TL, TL.getNumArgs()),
7593 NewTemplateArgs))
7594 return QualType();
7595
7596 // This needs to be rebuilt if either the arguments changed, or if the
7597 // original template changed. If the template changed, and even if the
7598 // arguments didn't change, these arguments might not correspond to their
7599 // respective parameters, therefore needing conversions.
7600 QualType Result = getDerived().RebuildTemplateSpecializationType(
7601 TL.getTypePtr()->getKeyword(), Template, TL.getTemplateNameLoc(),
7602 NewTemplateArgs);
7603
7604 if (!Result.isNull()) {
7606 TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getTemplateKeywordLoc(),
7607 TL.getTemplateNameLoc(), NewTemplateArgs);
7608 }
7609
7610 return Result;
7611}
7612
7613template <typename Derived>
7615 AttributedTypeLoc TL) {
7616 const AttributedType *oldType = TL.getTypePtr();
7617 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7618 if (modifiedType.isNull())
7619 return QualType();
7620
7621 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7622 const Attr *oldAttr = TL.getAttr();
7623 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7624 if (oldAttr && !newAttr)
7625 return QualType();
7626
7627 QualType result = TL.getType();
7628
7629 // FIXME: dependent operand expressions?
7630 if (getDerived().AlwaysRebuild() ||
7631 modifiedType != oldType->getModifiedType()) {
7632 // If the equivalent type is equal to the modified type, we don't want to
7633 // transform it as well because:
7634 //
7635 // 1. The transformation would yield the same result and is therefore
7636 // superfluous, and
7637 //
7638 // 2. Transforming the same type twice can cause problems, e.g. if it
7639 // is a FunctionProtoType, we may end up instantiating the function
7640 // parameters twice, which causes an assertion since the parameters
7641 // are already bound to their counterparts in the template for this
7642 // instantiation.
7643 //
7644 QualType equivalentType = modifiedType;
7645 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7646 TypeLocBuilder AuxiliaryTLB;
7647 AuxiliaryTLB.reserve(TL.getFullDataSize());
7648 equivalentType =
7649 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7650 if (equivalentType.isNull())
7651 return QualType();
7652 }
7653
7654 // Check whether we can add nullability; it is only represented as
7655 // type sugar, and therefore cannot be diagnosed in any other way.
7656 if (auto nullability = oldType->getImmediateNullability()) {
7657 if (!modifiedType->canHaveNullability()) {
7658 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7659 : TL.getModifiedLoc().getBeginLoc()),
7660 diag::err_nullability_nonpointer)
7661 << DiagNullabilityKind(*nullability, false) << modifiedType;
7662 return QualType();
7663 }
7664 }
7665
7666 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7667 modifiedType,
7668 equivalentType,
7669 TL.getAttr());
7670 }
7671
7672 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7673 newTL.setAttr(newAttr);
7674 return result;
7675}
7676
7677template <typename Derived>
7680 const CountAttributedType *OldTy = TL.getTypePtr();
7681 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7682 if (InnerTy.isNull())
7683 return QualType();
7684
7685 Expr *OldCount = TL.getCountExpr();
7686 Expr *NewCount = nullptr;
7687 if (OldCount) {
7688 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7689 if (CountResult.isInvalid())
7690 return QualType();
7691 NewCount = CountResult.get();
7692 }
7693
7694 QualType Result = TL.getType();
7695 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7696 OldCount != NewCount) {
7697 // Currently, CountAttributedType can only wrap incomplete array types.
7699 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7700 }
7701
7702 TLB.push<CountAttributedTypeLoc>(Result);
7703 return Result;
7704}
7705
7706template <typename Derived>
7709 // The BTFTagAttributedType is available for C only.
7710 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7711}
7712
7713template <typename Derived>
7716
7717 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7718
7719 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7720 if (WrappedTy.isNull())
7721 return QualType();
7722
7723 QualType ContainedTy = QualType();
7724 QualType OldContainedTy = oldType->getContainedType();
7725 if (!OldContainedTy.isNull()) {
7726 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7727 if (!oldContainedTSI)
7728 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7729 OldContainedTy, SourceLocation());
7730 TypeSourceInfo *ContainedTSI = getDerived().TransformType(oldContainedTSI);
7731 if (!ContainedTSI)
7732 return QualType();
7733 ContainedTy = ContainedTSI->getType();
7734 }
7735
7736 QualType Result = TL.getType();
7737 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7738 ContainedTy != oldType->getContainedType()) {
7740 WrappedTy, ContainedTy, oldType->getAttrs());
7741 }
7742
7744 return Result;
7745}
7746
7747template <typename Derived>
7750 // No transformations needed.
7751 return TL.getType();
7752}
7753
7754template<typename Derived>
7757 ParenTypeLoc TL) {
7758 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7759 if (Inner.isNull())
7760 return QualType();
7761
7762 QualType Result = TL.getType();
7763 if (getDerived().AlwaysRebuild() ||
7764 Inner != TL.getInnerLoc().getType()) {
7765 Result = getDerived().RebuildParenType(Inner);
7766 if (Result.isNull())
7767 return QualType();
7768 }
7769
7770 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7771 NewTL.setLParenLoc(TL.getLParenLoc());
7772 NewTL.setRParenLoc(TL.getRParenLoc());
7773 return Result;
7774}
7775
7776template <typename Derived>
7780 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7781 if (Inner.isNull())
7782 return QualType();
7783
7784 QualType Result = TL.getType();
7785 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7786 Result =
7787 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7788 if (Result.isNull())
7789 return QualType();
7790 }
7791
7793 NewTL.setExpansionLoc(TL.getExpansionLoc());
7794 return Result;
7795}
7796
7797template<typename Derived>
7798QualType TreeTransform<Derived>::TransformDependentNameType(
7800 return TransformDependentNameType(TLB, TL, false);
7801}
7802
7803template <typename Derived>
7804QualType TreeTransform<Derived>::TransformDependentNameType(
7805 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext,
7806 QualType ObjectType, NamedDecl *UnqualLookup) {
7807 const DependentNameType *T = TL.getTypePtr();
7808
7809 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7810 if (QualifierLoc) {
7811 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
7812 QualifierLoc, ObjectType, UnqualLookup);
7813 if (!QualifierLoc)
7814 return QualType();
7815 } else {
7816 assert((ObjectType.isNull() && !UnqualLookup) &&
7817 "must be transformed by TransformNestedNameSpecifierLoc");
7818 }
7819
7821 = getDerived().RebuildDependentNameType(T->getKeyword(),
7822 TL.getElaboratedKeywordLoc(),
7823 QualifierLoc,
7824 T->getIdentifier(),
7825 TL.getNameLoc(),
7826 DeducedTSTContext);
7827 if (Result.isNull())
7828 return QualType();
7829
7830 if (isa<TagType>(Result)) {
7831 auto NewTL = TLB.push<TagTypeLoc>(Result);
7832 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7833 NewTL.setQualifierLoc(QualifierLoc);
7834 NewTL.setNameLoc(TL.getNameLoc());
7836 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7837 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7838 NewTL.setTemplateNameLoc(TL.getNameLoc());
7839 NewTL.setQualifierLoc(QualifierLoc);
7840 } else if (isa<TypedefType>(Result)) {
7841 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7842 QualifierLoc, TL.getNameLoc());
7843 } else if (isa<UnresolvedUsingType>(Result)) {
7844 auto NewTL = TLB.push<UnresolvedUsingTypeLoc>(Result);
7845 NewTL.set(TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getNameLoc());
7846 } else {
7847 auto NewTL = TLB.push<DependentNameTypeLoc>(Result);
7848 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7849 NewTL.setQualifierLoc(QualifierLoc);
7850 NewTL.setNameLoc(TL.getNameLoc());
7851 }
7852 return Result;
7853}
7854
7855template<typename Derived>
7858 QualType Pattern
7859 = getDerived().TransformType(TLB, TL.getPatternLoc());
7860 if (Pattern.isNull())
7861 return QualType();
7862
7863 QualType Result = TL.getType();
7864 if (getDerived().AlwaysRebuild() ||
7865 Pattern != TL.getPatternLoc().getType()) {
7866 Result = getDerived().RebuildPackExpansionType(Pattern,
7867 TL.getPatternLoc().getSourceRange(),
7868 TL.getEllipsisLoc(),
7869 TL.getTypePtr()->getNumExpansions());
7870 if (Result.isNull())
7871 return QualType();
7872 }
7873
7875 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7876 return Result;
7877}
7878
7879template<typename Derived>
7883 // ObjCInterfaceType is never dependent.
7884 TLB.pushFullCopy(TL);
7885 return TL.getType();
7886}
7887
7888template<typename Derived>
7892 const ObjCTypeParamType *T = TL.getTypePtr();
7893 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7894 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7895 if (!OTP)
7896 return QualType();
7897
7898 QualType Result = TL.getType();
7899 if (getDerived().AlwaysRebuild() ||
7900 OTP != T->getDecl()) {
7901 Result = getDerived().RebuildObjCTypeParamType(
7902 OTP, TL.getProtocolLAngleLoc(),
7903 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7904 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7905 if (Result.isNull())
7906 return QualType();
7907 }
7908
7910 if (TL.getNumProtocols()) {
7911 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7912 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7913 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7914 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7915 }
7916 return Result;
7917}
7918
7919template<typename Derived>
7922 ObjCObjectTypeLoc TL) {
7923 // Transform base type.
7924 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
7925 if (BaseType.isNull())
7926 return QualType();
7927
7928 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
7929
7930 // Transform type arguments.
7931 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
7932 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
7933 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
7934 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
7935 QualType TypeArg = TypeArgInfo->getType();
7936 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
7937 AnyChanged = true;
7938
7939 // We have a pack expansion. Instantiate it.
7940 const auto *PackExpansion = PackExpansionLoc.getType()
7941 ->castAs<PackExpansionType>();
7943 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
7944 Unexpanded);
7945 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7946
7947 // Determine whether the set of unexpanded parameter packs can
7948 // and should be expanded.
7949 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
7950 bool Expand = false;
7951 bool RetainExpansion = false;
7952 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
7953 if (getDerived().TryExpandParameterPacks(
7954 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
7955 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
7956 RetainExpansion, NumExpansions))
7957 return QualType();
7958
7959 if (!Expand) {
7960 // We can't expand this pack expansion into separate arguments yet;
7961 // just substitute into the pattern and create a new pack expansion
7962 // type.
7963 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7964
7965 TypeLocBuilder TypeArgBuilder;
7966 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7967 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
7968 PatternLoc);
7969 if (NewPatternType.isNull())
7970 return QualType();
7971
7972 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
7973 NewPatternType, NumExpansions);
7974 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
7975 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
7976 NewTypeArgInfos.push_back(
7977 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
7978 continue;
7979 }
7980
7981 // Substitute into the pack expansion pattern for each slice of the
7982 // pack.
7983 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
7984 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
7985
7986 TypeLocBuilder TypeArgBuilder;
7987 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7988
7989 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
7990 PatternLoc);
7991 if (NewTypeArg.isNull())
7992 return QualType();
7993
7994 NewTypeArgInfos.push_back(
7995 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
7996 }
7997
7998 continue;
7999 }
8000
8001 TypeLocBuilder TypeArgBuilder;
8002 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
8003 QualType NewTypeArg =
8004 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
8005 if (NewTypeArg.isNull())
8006 return QualType();
8007
8008 // If nothing changed, just keep the old TypeSourceInfo.
8009 if (NewTypeArg == TypeArg) {
8010 NewTypeArgInfos.push_back(TypeArgInfo);
8011 continue;
8012 }
8013
8014 NewTypeArgInfos.push_back(
8015 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8016 AnyChanged = true;
8017 }
8018
8019 QualType Result = TL.getType();
8020 if (getDerived().AlwaysRebuild() || AnyChanged) {
8021 // Rebuild the type.
8022 Result = getDerived().RebuildObjCObjectType(
8023 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
8024 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
8025 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8026 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8027
8028 if (Result.isNull())
8029 return QualType();
8030 }
8031
8032 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
8033 NewT.setHasBaseTypeAsWritten(true);
8034 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
8035 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
8036 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
8037 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
8038 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8039 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8040 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
8041 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8042 return Result;
8043}
8044
8045template<typename Derived>
8049 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8050 if (PointeeType.isNull())
8051 return QualType();
8052
8053 QualType Result = TL.getType();
8054 if (getDerived().AlwaysRebuild() ||
8055 PointeeType != TL.getPointeeLoc().getType()) {
8056 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8057 TL.getStarLoc());
8058 if (Result.isNull())
8059 return QualType();
8060 }
8061
8063 NewT.setStarLoc(TL.getStarLoc());
8064 return Result;
8065}
8066
8067//===----------------------------------------------------------------------===//
8068// Statement transformation
8069//===----------------------------------------------------------------------===//
8070template<typename Derived>
8073 return S;
8074}
8075
8076template<typename Derived>
8079 return getDerived().TransformCompoundStmt(S, false);
8080}
8081
8082template<typename Derived>
8085 bool IsStmtExpr) {
8086 Sema::CompoundScopeRAII CompoundScope(getSema());
8087 Sema::FPFeaturesStateRAII FPSave(getSema());
8088 if (S->hasStoredFPFeatures())
8089 getSema().resetFPOptions(
8090 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8091
8092 bool SubStmtInvalid = false;
8093 bool SubStmtChanged = false;
8094 SmallVector<Stmt*, 8> Statements;
8095 for (auto *B : S->body()) {
8096 StmtResult Result = getDerived().TransformStmt(
8097 B, IsStmtExpr && B == S->body_back() ? StmtDiscardKind::StmtExprResult
8098 : StmtDiscardKind::Discarded);
8099
8100 if (Result.isInvalid()) {
8101 // Immediately fail if this was a DeclStmt, since it's very
8102 // likely that this will cause problems for future statements.
8103 if (isa<DeclStmt>(B))
8104 return StmtError();
8105
8106 // Otherwise, just keep processing substatements and fail later.
8107 SubStmtInvalid = true;
8108 continue;
8109 }
8110
8111 SubStmtChanged = SubStmtChanged || Result.get() != B;
8112 Statements.push_back(Result.getAs<Stmt>());
8113 }
8114
8115 if (SubStmtInvalid)
8116 return StmtError();
8117
8118 if (!getDerived().AlwaysRebuild() &&
8119 !SubStmtChanged)
8120 return S;
8121
8122 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8123 Statements,
8124 S->getRBracLoc(),
8125 IsStmtExpr);
8126}
8127
8128template<typename Derived>
8131 ExprResult LHS, RHS;
8132 {
8135
8136 // Transform the left-hand case value.
8137 LHS = getDerived().TransformExpr(S->getLHS());
8138 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8139 if (LHS.isInvalid())
8140 return StmtError();
8141
8142 // Transform the right-hand case value (for the GNU case-range extension).
8143 RHS = getDerived().TransformExpr(S->getRHS());
8144 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8145 if (RHS.isInvalid())
8146 return StmtError();
8147 }
8148
8149 // Build the case statement.
8150 // Case statements are always rebuilt so that they will attached to their
8151 // transformed switch statement.
8152 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8153 LHS.get(),
8154 S->getEllipsisLoc(),
8155 RHS.get(),
8156 S->getColonLoc());
8157 if (Case.isInvalid())
8158 return StmtError();
8159
8160 // Transform the statement following the case
8161 StmtResult SubStmt =
8162 getDerived().TransformStmt(S->getSubStmt());
8163 if (SubStmt.isInvalid())
8164 return StmtError();
8165
8166 // Attach the body to the case statement
8167 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8168}
8169
8170template <typename Derived>
8172 // Transform the statement following the default case
8173 StmtResult SubStmt =
8174 getDerived().TransformStmt(S->getSubStmt());
8175 if (SubStmt.isInvalid())
8176 return StmtError();
8177
8178 // Default statements are always rebuilt
8179 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8180 SubStmt.get());
8181}
8182
8183template<typename Derived>
8186 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8187 if (SubStmt.isInvalid())
8188 return StmtError();
8189
8190 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8191 S->getDecl());
8192 if (!LD)
8193 return StmtError();
8194
8195 // If we're transforming "in-place" (we're not creating new local
8196 // declarations), assume we're replacing the old label statement
8197 // and clear out the reference to it.
8198 if (LD == S->getDecl())
8199 S->getDecl()->setStmt(nullptr);
8200
8201 // FIXME: Pass the real colon location in.
8202 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8204 SubStmt.get());
8205}
8206
8207template <typename Derived>
8209 if (!R)
8210 return R;
8211
8212 switch (R->getKind()) {
8213// Transform attributes by calling TransformXXXAttr.
8214#define ATTR(X) \
8215 case attr::X: \
8216 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8217#include "clang/Basic/AttrList.inc"
8218 }
8219 return R;
8220}
8221
8222template <typename Derived>
8224 const Stmt *InstS,
8225 const Attr *R) {
8226 if (!R)
8227 return R;
8228
8229 switch (R->getKind()) {
8230// Transform attributes by calling TransformStmtXXXAttr.
8231#define ATTR(X) \
8232 case attr::X: \
8233 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8234#include "clang/Basic/AttrList.inc"
8235 }
8236 return TransformAttr(R);
8237}
8238
8239template <typename Derived>
8242 StmtDiscardKind SDK) {
8243 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8244 if (SubStmt.isInvalid())
8245 return StmtError();
8246
8247 bool AttrsChanged = false;
8249
8250 // Visit attributes and keep track if any are transformed.
8251 for (const auto *I : S->getAttrs()) {
8252 const Attr *R =
8253 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8254 AttrsChanged |= (I != R);
8255 if (R)
8256 Attrs.push_back(R);
8257 }
8258
8259 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8260 return S;
8261
8262 // If transforming the attributes failed for all of the attributes in the
8263 // statement, don't make an AttributedStmt without attributes.
8264 if (Attrs.empty())
8265 return SubStmt;
8266
8267 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8268 SubStmt.get());
8269}
8270
8271template<typename Derived>
8274 // Transform the initialization statement
8275 StmtResult Init = getDerived().TransformStmt(S->getInit());
8276 if (Init.isInvalid())
8277 return StmtError();
8278
8280 if (!S->isConsteval()) {
8281 // Transform the condition
8282 Cond = getDerived().TransformCondition(
8283 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8284 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8286 if (Cond.isInvalid())
8287 return StmtError();
8288 }
8289
8290 // If this is a constexpr if, determine which arm we should instantiate.
8291 std::optional<bool> ConstexprConditionValue;
8292 if (S->isConstexpr())
8293 ConstexprConditionValue = Cond.getKnownValue();
8294
8295 // Transform the "then" branch.
8296 StmtResult Then;
8297 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8301 S->isNonNegatedConsteval());
8302
8303 Then = getDerived().TransformStmt(S->getThen());
8304 if (Then.isInvalid())
8305 return StmtError();
8306 } else {
8307 // Discarded branch is replaced with empty CompoundStmt so we can keep
8308 // proper source location for start and end of original branch, so
8309 // subsequent transformations like CoverageMapping work properly
8310 Then = new (getSema().Context)
8311 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8312 }
8313
8314 // Transform the "else" branch.
8315 StmtResult Else;
8316 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8320 S->isNegatedConsteval());
8321
8322 Else = getDerived().TransformStmt(S->getElse());
8323 if (Else.isInvalid())
8324 return StmtError();
8325 } else if (S->getElse() && ConstexprConditionValue &&
8326 *ConstexprConditionValue) {
8327 // Same thing here as with <then> branch, we are discarding it, we can't
8328 // replace it with NULL nor NullStmt as we need to keep for source location
8329 // range, for CoverageMapping
8330 Else = new (getSema().Context)
8331 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8332 }
8333
8334 if (!getDerived().AlwaysRebuild() &&
8335 Init.get() == S->getInit() &&
8336 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8337 Then.get() == S->getThen() &&
8338 Else.get() == S->getElse())
8339 return S;
8340
8341 return getDerived().RebuildIfStmt(
8342 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8343 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8344}
8345
8346template<typename Derived>
8349 // Transform the initialization statement
8350 StmtResult Init = getDerived().TransformStmt(S->getInit());
8351 if (Init.isInvalid())
8352 return StmtError();
8353
8354 // Transform the condition.
8355 Sema::ConditionResult Cond = getDerived().TransformCondition(
8356 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8358 if (Cond.isInvalid())
8359 return StmtError();
8360
8361 // Rebuild the switch statement.
8363 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8364 Init.get(), Cond, S->getRParenLoc());
8365 if (Switch.isInvalid())
8366 return StmtError();
8367
8368 // Transform the body of the switch statement.
8369 StmtResult Body = getDerived().TransformStmt(S->getBody());
8370 if (Body.isInvalid())
8371 return StmtError();
8372
8373 // Complete the switch statement.
8374 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8375 Body.get());
8376}
8377
8378template<typename Derived>
8381 // Transform the condition
8382 Sema::ConditionResult Cond = getDerived().TransformCondition(
8383 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8385 if (Cond.isInvalid())
8386 return StmtError();
8387
8388 // OpenACC Restricts a while-loop inside of certain construct/clause
8389 // combinations, so diagnose that here in OpenACC mode.
8391 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8392
8393 // Transform the body
8394 StmtResult Body = getDerived().TransformStmt(S->getBody());
8395 if (Body.isInvalid())
8396 return StmtError();
8397
8398 if (!getDerived().AlwaysRebuild() &&
8399 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8400 Body.get() == S->getBody())
8401 return Owned(S);
8402
8403 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8404 Cond, S->getRParenLoc(), Body.get());
8405}
8406
8407template<typename Derived>
8410 // OpenACC Restricts a do-loop inside of certain construct/clause
8411 // combinations, so diagnose that here in OpenACC mode.
8413 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8414
8415 // Transform the body
8416 StmtResult Body = getDerived().TransformStmt(S->getBody());
8417 if (Body.isInvalid())
8418 return StmtError();
8419
8420 // Transform the condition
8421 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8422 if (Cond.isInvalid())
8423 return StmtError();
8424
8425 if (!getDerived().AlwaysRebuild() &&
8426 Cond.get() == S->getCond() &&
8427 Body.get() == S->getBody())
8428 return S;
8429
8430 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8431 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8432 S->getRParenLoc());
8433}
8434
8435template<typename Derived>
8438 if (getSema().getLangOpts().OpenMP)
8439 getSema().OpenMP().startOpenMPLoop();
8440
8441 // Transform the initialization statement
8442 StmtResult Init = getDerived().TransformStmt(S->getInit());
8443 if (Init.isInvalid())
8444 return StmtError();
8445
8446 // In OpenMP loop region loop control variable must be captured and be
8447 // private. Perform analysis of first part (if any).
8448 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8449 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8450 Init.get());
8451
8452 // Transform the condition
8453 Sema::ConditionResult Cond = getDerived().TransformCondition(
8454 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8456 if (Cond.isInvalid())
8457 return StmtError();
8458
8459 // Transform the increment
8460 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8461 if (Inc.isInvalid())
8462 return StmtError();
8463
8464 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8465 if (S->getInc() && !FullInc.get())
8466 return StmtError();
8467
8468 // OpenACC Restricts a for-loop inside of certain construct/clause
8469 // combinations, so diagnose that here in OpenACC mode.
8471 SemaRef.OpenACC().ActOnForStmtBegin(
8472 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8473 Cond.get().second, S->getInc(), Inc.get());
8474
8475 // Transform the body
8476 StmtResult Body = getDerived().TransformStmt(S->getBody());
8477 if (Body.isInvalid())
8478 return StmtError();
8479
8480 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8481
8482 if (!getDerived().AlwaysRebuild() &&
8483 Init.get() == S->getInit() &&
8484 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8485 Inc.get() == S->getInc() &&
8486 Body.get() == S->getBody())
8487 return S;
8488
8489 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8490 Init.get(), Cond, FullInc,
8491 S->getRParenLoc(), Body.get());
8492}
8493
8494template<typename Derived>
8497 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8498 S->getLabel());
8499 if (!LD)
8500 return StmtError();
8501
8502 // Goto statements must always be rebuilt, to resolve the label.
8503 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8504 cast<LabelDecl>(LD));
8505}
8506
8507template<typename Derived>
8510 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8511 if (Target.isInvalid())
8512 return StmtError();
8513 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8514
8515 if (!getDerived().AlwaysRebuild() &&
8516 Target.get() == S->getTarget())
8517 return S;
8518
8519 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8520 Target.get());
8521}
8522
8523template<typename Derived>
8526 if (!S->hasLabelTarget())
8527 return S;
8528
8529 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8530 S->getLabelDecl());
8531 if (!LD)
8532 return StmtError();
8533
8534 return new (SemaRef.Context)
8535 ContinueStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8536}
8537
8538template<typename Derived>
8541 if (!S->hasLabelTarget())
8542 return S;
8543
8544 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8545 S->getLabelDecl());
8546 if (!LD)
8547 return StmtError();
8548
8549 return new (SemaRef.Context)
8550 BreakStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8551}
8552
8553template<typename Derived>
8556 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8557 /*NotCopyInit*/false);
8558 if (Result.isInvalid())
8559 return StmtError();
8560
8561 // FIXME: We always rebuild the return statement because there is no way
8562 // to tell whether the return type of the function has changed.
8563 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8564}
8565
8566template<typename Derived>
8569 bool DeclChanged = false;
8571 LambdaScopeInfo *LSI = getSema().getCurLambda();
8572 for (auto *D : S->decls()) {
8573 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8574 if (!Transformed)
8575 return StmtError();
8576
8577 if (Transformed != D)
8578 DeclChanged = true;
8579
8580 if (LSI) {
8581 if (auto *TD = dyn_cast<TypeDecl>(Transformed)) {
8582 if (auto *TN = dyn_cast<TypedefNameDecl>(TD)) {
8583 LSI->ContainsUnexpandedParameterPack |=
8584 TN->getUnderlyingType()->containsUnexpandedParameterPack();
8585 } else {
8586 LSI->ContainsUnexpandedParameterPack |=
8587 getSema()
8588 .getASTContext()
8589 .getTypeDeclType(TD)
8590 ->containsUnexpandedParameterPack();
8591 }
8592 }
8593 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8594 LSI->ContainsUnexpandedParameterPack |=
8595 VD->getType()->containsUnexpandedParameterPack();
8596 }
8597
8598 Decls.push_back(Transformed);
8599 }
8600
8601 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8602 return S;
8603
8604 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8605}
8606
8607template<typename Derived>
8610
8611 SmallVector<Expr*, 8> Constraints;
8614
8615 SmallVector<Expr*, 8> Clobbers;
8616
8617 bool ExprsChanged = false;
8618
8619 auto RebuildString = [&](Expr *E) {
8620 ExprResult Result = getDerived().TransformExpr(E);
8621 if (!Result.isUsable())
8622 return Result;
8623 if (Result.get() != E) {
8624 ExprsChanged = true;
8625 Result = SemaRef.ActOnGCCAsmStmtString(Result.get(), /*ForLabel=*/false);
8626 }
8627 return Result;
8628 };
8629
8630 // Go through the outputs.
8631 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8632 Names.push_back(S->getOutputIdentifier(I));
8633
8634 ExprResult Result = RebuildString(S->getOutputConstraintExpr(I));
8635 if (Result.isInvalid())
8636 return StmtError();
8637
8638 Constraints.push_back(Result.get());
8639
8640 // Transform the output expr.
8641 Expr *OutputExpr = S->getOutputExpr(I);
8642 Result = getDerived().TransformExpr(OutputExpr);
8643 if (Result.isInvalid())
8644 return StmtError();
8645
8646 ExprsChanged |= Result.get() != OutputExpr;
8647
8648 Exprs.push_back(Result.get());
8649 }
8650
8651 // Go through the inputs.
8652 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8653 Names.push_back(S->getInputIdentifier(I));
8654
8655 ExprResult Result = RebuildString(S->getInputConstraintExpr(I));
8656 if (Result.isInvalid())
8657 return StmtError();
8658
8659 Constraints.push_back(Result.get());
8660
8661 // Transform the input expr.
8662 Expr *InputExpr = S->getInputExpr(I);
8663 Result = getDerived().TransformExpr(InputExpr);
8664 if (Result.isInvalid())
8665 return StmtError();
8666
8667 ExprsChanged |= Result.get() != InputExpr;
8668
8669 Exprs.push_back(Result.get());
8670 }
8671
8672 // Go through the Labels.
8673 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8674 Names.push_back(S->getLabelIdentifier(I));
8675
8676 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8677 if (Result.isInvalid())
8678 return StmtError();
8679 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8680 Exprs.push_back(Result.get());
8681 }
8682
8683 // Go through the clobbers.
8684 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) {
8685 ExprResult Result = RebuildString(S->getClobberExpr(I));
8686 if (Result.isInvalid())
8687 return StmtError();
8688 Clobbers.push_back(Result.get());
8689 }
8690
8691 ExprResult AsmString = RebuildString(S->getAsmStringExpr());
8692 if (AsmString.isInvalid())
8693 return StmtError();
8694
8695 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8696 return S;
8697
8698 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8699 S->isVolatile(), S->getNumOutputs(),
8700 S->getNumInputs(), Names.data(),
8701 Constraints, Exprs, AsmString.get(),
8702 Clobbers, S->getNumLabels(),
8703 S->getRParenLoc());
8704}
8705
8706template<typename Derived>
8709 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8710
8711 bool HadError = false, HadChange = false;
8712
8713 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8714 SmallVector<Expr*, 8> TransformedExprs;
8715 TransformedExprs.reserve(SrcExprs.size());
8716 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8717 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8718 if (!Result.isUsable()) {
8719 HadError = true;
8720 } else {
8721 HadChange |= (Result.get() != SrcExprs[i]);
8722 TransformedExprs.push_back(Result.get());
8723 }
8724 }
8725
8726 if (HadError) return StmtError();
8727 if (!HadChange && !getDerived().AlwaysRebuild())
8728 return Owned(S);
8729
8730 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8731 AsmToks, S->getAsmString(),
8732 S->getNumOutputs(), S->getNumInputs(),
8733 S->getAllConstraints(), S->getClobbers(),
8734 TransformedExprs, S->getEndLoc());
8735}
8736
8737// C++ Coroutines
8738template<typename Derived>
8741 auto *ScopeInfo = SemaRef.getCurFunction();
8742 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8743 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8744 ScopeInfo->NeedsCoroutineSuspends &&
8745 ScopeInfo->CoroutineSuspends.first == nullptr &&
8746 ScopeInfo->CoroutineSuspends.second == nullptr &&
8747 "expected clean scope info");
8748
8749 // Set that we have (possibly-invalid) suspend points before we do anything
8750 // that may fail.
8751 ScopeInfo->setNeedsCoroutineSuspends(false);
8752
8753 // We re-build the coroutine promise object (and the coroutine parameters its
8754 // type and constructor depend on) based on the types used in our current
8755 // function. We must do so, and set it on the current FunctionScopeInfo,
8756 // before attempting to transform the other parts of the coroutine body
8757 // statement, such as the implicit suspend statements (because those
8758 // statements reference the FunctionScopeInfo::CoroutinePromise).
8759 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8760 return StmtError();
8761 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8762 if (!Promise)
8763 return StmtError();
8764 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8765 ScopeInfo->CoroutinePromise = Promise;
8766
8767 // Transform the implicit coroutine statements constructed using dependent
8768 // types during the previous parse: initial and final suspensions, the return
8769 // object, and others. We also transform the coroutine function's body.
8770 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8771 if (InitSuspend.isInvalid())
8772 return StmtError();
8773 StmtResult FinalSuspend =
8774 getDerived().TransformStmt(S->getFinalSuspendStmt());
8775 if (FinalSuspend.isInvalid() ||
8776 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8777 return StmtError();
8778 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8779 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8780
8781 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8782 if (BodyRes.isInvalid())
8783 return StmtError();
8784
8785 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8786 if (Builder.isInvalid())
8787 return StmtError();
8788
8789 Expr *ReturnObject = S->getReturnValueInit();
8790 assert(ReturnObject && "the return object is expected to be valid");
8791 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8792 /*NoCopyInit*/ false);
8793 if (Res.isInvalid())
8794 return StmtError();
8795 Builder.ReturnValue = Res.get();
8796
8797 // If during the previous parse the coroutine still had a dependent promise
8798 // statement, we may need to build some implicit coroutine statements
8799 // (such as exception and fallthrough handlers) for the first time.
8800 if (S->hasDependentPromiseType()) {
8801 // We can only build these statements, however, if the current promise type
8802 // is not dependent.
8803 if (!Promise->getType()->isDependentType()) {
8804 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8805 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8806 "these nodes should not have been built yet");
8807 if (!Builder.buildDependentStatements())
8808 return StmtError();
8809 }
8810 } else {
8811 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8812 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8813 if (Res.isInvalid())
8814 return StmtError();
8815 Builder.OnFallthrough = Res.get();
8816 }
8817
8818 if (auto *OnException = S->getExceptionHandler()) {
8819 StmtResult Res = getDerived().TransformStmt(OnException);
8820 if (Res.isInvalid())
8821 return StmtError();
8822 Builder.OnException = Res.get();
8823 }
8824
8825 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8826 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8827 if (Res.isInvalid())
8828 return StmtError();
8829 Builder.ReturnStmtOnAllocFailure = Res.get();
8830 }
8831
8832 // Transform any additional statements we may have already built
8833 assert(S->getAllocate() && S->getDeallocate() &&
8834 "allocation and deallocation calls must already be built");
8835 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8836 if (AllocRes.isInvalid())
8837 return StmtError();
8838 Builder.Allocate = AllocRes.get();
8839
8840 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8841 if (DeallocRes.isInvalid())
8842 return StmtError();
8843 Builder.Deallocate = DeallocRes.get();
8844
8845 if (auto *ResultDecl = S->getResultDecl()) {
8846 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8847 if (Res.isInvalid())
8848 return StmtError();
8849 Builder.ResultDecl = Res.get();
8850 }
8851
8852 if (auto *ReturnStmt = S->getReturnStmt()) {
8853 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8854 if (Res.isInvalid())
8855 return StmtError();
8856 Builder.ReturnStmt = Res.get();
8857 }
8858 }
8859
8860 return getDerived().RebuildCoroutineBodyStmt(Builder);
8861}
8862
8863template<typename Derived>
8866 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8867 /*NotCopyInit*/false);
8868 if (Result.isInvalid())
8869 return StmtError();
8870
8871 // Always rebuild; we don't know if this needs to be injected into a new
8872 // context or if the promise type has changed.
8873 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8874 S->isImplicit());
8875}
8876
8877template <typename Derived>
8879 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8880 /*NotCopyInit*/ false);
8881 if (Operand.isInvalid())
8882 return ExprError();
8883
8884 // Rebuild the common-expr from the operand rather than transforming it
8885 // separately.
8886
8887 // FIXME: getCurScope() should not be used during template instantiation.
8888 // We should pick up the set of unqualified lookup results for operator
8889 // co_await during the initial parse.
8890 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8891 getSema().getCurScope(), E->getKeywordLoc());
8892
8893 // Always rebuild; we don't know if this needs to be injected into a new
8894 // context or if the promise type has changed.
8895 return getDerived().RebuildCoawaitExpr(
8896 E->getKeywordLoc(), Operand.get(),
8897 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8898}
8899
8900template <typename Derived>
8903 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8904 /*NotCopyInit*/ false);
8905 if (OperandResult.isInvalid())
8906 return ExprError();
8907
8908 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8909 E->getOperatorCoawaitLookup());
8910
8911 if (LookupResult.isInvalid())
8912 return ExprError();
8913
8914 // Always rebuild; we don't know if this needs to be injected into a new
8915 // context or if the promise type has changed.
8916 return getDerived().RebuildDependentCoawaitExpr(
8917 E->getKeywordLoc(), OperandResult.get(),
8919}
8920
8921template<typename Derived>
8924 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
8925 /*NotCopyInit*/false);
8926 if (Result.isInvalid())
8927 return ExprError();
8928
8929 // Always rebuild; we don't know if this needs to be injected into a new
8930 // context or if the promise type has changed.
8931 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
8932}
8933
8934// Objective-C Statements.
8935
8936template<typename Derived>
8939 // Transform the body of the @try.
8940 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
8941 if (TryBody.isInvalid())
8942 return StmtError();
8943
8944 // Transform the @catch statements (if present).
8945 bool AnyCatchChanged = false;
8946 SmallVector<Stmt*, 8> CatchStmts;
8947 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
8948 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
8949 if (Catch.isInvalid())
8950 return StmtError();
8951 if (Catch.get() != S->getCatchStmt(I))
8952 AnyCatchChanged = true;
8953 CatchStmts.push_back(Catch.get());
8954 }
8955
8956 // Transform the @finally statement (if present).
8957 StmtResult Finally;
8958 if (S->getFinallyStmt()) {
8959 Finally = getDerived().TransformStmt(S->getFinallyStmt());
8960 if (Finally.isInvalid())
8961 return StmtError();
8962 }
8963
8964 // If nothing changed, just retain this statement.
8965 if (!getDerived().AlwaysRebuild() &&
8966 TryBody.get() == S->getTryBody() &&
8967 !AnyCatchChanged &&
8968 Finally.get() == S->getFinallyStmt())
8969 return S;
8970
8971 // Build a new statement.
8972 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
8973 CatchStmts, Finally.get());
8974}
8975
8976template<typename Derived>
8979 // Transform the @catch parameter, if there is one.
8980 VarDecl *Var = nullptr;
8981 if (VarDecl *FromVar = S->getCatchParamDecl()) {
8982 TypeSourceInfo *TSInfo = nullptr;
8983 if (FromVar->getTypeSourceInfo()) {
8984 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
8985 if (!TSInfo)
8986 return StmtError();
8987 }
8988
8989 QualType T;
8990 if (TSInfo)
8991 T = TSInfo->getType();
8992 else {
8993 T = getDerived().TransformType(FromVar->getType());
8994 if (T.isNull())
8995 return StmtError();
8996 }
8997
8998 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
8999 if (!Var)
9000 return StmtError();
9001 }
9002
9003 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
9004 if (Body.isInvalid())
9005 return StmtError();
9006
9007 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
9008 S->getRParenLoc(),
9009 Var, Body.get());
9010}
9011
9012template<typename Derived>
9015 // Transform the body.
9016 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
9017 if (Body.isInvalid())
9018 return StmtError();
9019
9020 // If nothing changed, just retain this statement.
9021 if (!getDerived().AlwaysRebuild() &&
9022 Body.get() == S->getFinallyBody())
9023 return S;
9024
9025 // Build a new statement.
9026 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
9027 Body.get());
9028}
9029
9030template<typename Derived>
9034 if (S->getThrowExpr()) {
9035 Operand = getDerived().TransformExpr(S->getThrowExpr());
9036 if (Operand.isInvalid())
9037 return StmtError();
9038 }
9039
9040 if (!getDerived().AlwaysRebuild() &&
9041 Operand.get() == S->getThrowExpr())
9042 return S;
9043
9044 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
9045}
9046
9047template<typename Derived>
9051 // Transform the object we are locking.
9052 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
9053 if (Object.isInvalid())
9054 return StmtError();
9055 Object =
9056 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
9057 Object.get());
9058 if (Object.isInvalid())
9059 return StmtError();
9060
9061 // Transform the body.
9062 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
9063 if (Body.isInvalid())
9064 return StmtError();
9065
9066 // If nothing change, just retain the current statement.
9067 if (!getDerived().AlwaysRebuild() &&
9068 Object.get() == S->getSynchExpr() &&
9069 Body.get() == S->getSynchBody())
9070 return S;
9071
9072 // Build a new statement.
9073 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
9074 Object.get(), Body.get());
9075}
9076
9077template<typename Derived>
9081 // Transform the body.
9082 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
9083 if (Body.isInvalid())
9084 return StmtError();
9085
9086 // If nothing changed, just retain this statement.
9087 if (!getDerived().AlwaysRebuild() &&
9088 Body.get() == S->getSubStmt())
9089 return S;
9090
9091 // Build a new statement.
9092 return getDerived().RebuildObjCAutoreleasePoolStmt(
9093 S->getAtLoc(), Body.get());
9094}
9095
9096template<typename Derived>
9100 // Transform the element statement.
9101 StmtResult Element = getDerived().TransformStmt(
9102 S->getElement(), StmtDiscardKind::NotDiscarded);
9103 if (Element.isInvalid())
9104 return StmtError();
9105
9106 // Transform the collection expression.
9107 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9108 if (Collection.isInvalid())
9109 return StmtError();
9110
9111 // Transform the body.
9112 StmtResult Body = getDerived().TransformStmt(S->getBody());
9113 if (Body.isInvalid())
9114 return StmtError();
9115
9116 // If nothing changed, just retain this statement.
9117 if (!getDerived().AlwaysRebuild() &&
9118 Element.get() == S->getElement() &&
9119 Collection.get() == S->getCollection() &&
9120 Body.get() == S->getBody())
9121 return S;
9122
9123 // Build a new statement.
9124 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9125 Element.get(),
9126 Collection.get(),
9127 S->getRParenLoc(),
9128 Body.get());
9129}
9130
9131template <typename Derived>
9133 // Transform the exception declaration, if any.
9134 VarDecl *Var = nullptr;
9135 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9136 TypeSourceInfo *T =
9137 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9138 if (!T)
9139 return StmtError();
9140
9141 Var = getDerived().RebuildExceptionDecl(
9142 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9143 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9144 if (!Var || Var->isInvalidDecl())
9145 return StmtError();
9146 }
9147
9148 // Transform the actual exception handler.
9149 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9150 if (Handler.isInvalid())
9151 return StmtError();
9152
9153 if (!getDerived().AlwaysRebuild() && !Var &&
9154 Handler.get() == S->getHandlerBlock())
9155 return S;
9156
9157 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9158}
9159
9160template <typename Derived>
9162 // Transform the try block itself.
9163 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9164 if (TryBlock.isInvalid())
9165 return StmtError();
9166
9167 // Transform the handlers.
9168 bool HandlerChanged = false;
9169 SmallVector<Stmt *, 8> Handlers;
9170 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9171 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9172 if (Handler.isInvalid())
9173 return StmtError();
9174
9175 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9176 Handlers.push_back(Handler.getAs<Stmt>());
9177 }
9178
9179 getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
9180
9181 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9182 !HandlerChanged)
9183 return S;
9184
9185 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9186 Handlers);
9187}
9188
9189template<typename Derived>
9192 EnterExpressionEvaluationContext ForRangeInitContext(
9194 /*LambdaContextDecl=*/nullptr,
9196 getSema().getLangOpts().CPlusPlus23);
9197
9198 // P2718R0 - Lifetime extension in range-based for loops.
9199 if (getSema().getLangOpts().CPlusPlus23) {
9200 auto &LastRecord = getSema().currentEvaluationContext();
9201 LastRecord.InLifetimeExtendingContext = true;
9202 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9203 }
9205 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9206 if (Init.isInvalid())
9207 return StmtError();
9208
9209 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9210 if (Range.isInvalid())
9211 return StmtError();
9212
9213 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9214 assert(getSema().getLangOpts().CPlusPlus23 ||
9215 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9216 auto ForRangeLifetimeExtendTemps =
9217 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9218
9219 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9220 if (Begin.isInvalid())
9221 return StmtError();
9222 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9223 if (End.isInvalid())
9224 return StmtError();
9225
9226 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9227 if (Cond.isInvalid())
9228 return StmtError();
9229 if (Cond.get())
9230 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9231 if (Cond.isInvalid())
9232 return StmtError();
9233 if (Cond.get())
9234 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9235
9236 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9237 if (Inc.isInvalid())
9238 return StmtError();
9239 if (Inc.get())
9240 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9241
9242 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9243 if (LoopVar.isInvalid())
9244 return StmtError();
9245
9246 StmtResult NewStmt = S;
9247 if (getDerived().AlwaysRebuild() ||
9248 Init.get() != S->getInit() ||
9249 Range.get() != S->getRangeStmt() ||
9250 Begin.get() != S->getBeginStmt() ||
9251 End.get() != S->getEndStmt() ||
9252 Cond.get() != S->getCond() ||
9253 Inc.get() != S->getInc() ||
9254 LoopVar.get() != S->getLoopVarStmt()) {
9255 NewStmt = getDerived().RebuildCXXForRangeStmt(
9256 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9257 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9258 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9259 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9260 // Might not have attached any initializer to the loop variable.
9261 getSema().ActOnInitializerError(
9262 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9263 return StmtError();
9264 }
9265 }
9266
9267 // OpenACC Restricts a while-loop inside of certain construct/clause
9268 // combinations, so diagnose that here in OpenACC mode.
9270 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9271
9272 StmtResult Body = getDerived().TransformStmt(S->getBody());
9273 if (Body.isInvalid())
9274 return StmtError();
9275
9276 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9277
9278 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9279 // it now so we have a new statement to attach the body to.
9280 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9281 NewStmt = getDerived().RebuildCXXForRangeStmt(
9282 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9283 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9284 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9285 if (NewStmt.isInvalid())
9286 return StmtError();
9287 }
9288
9289 if (NewStmt.get() == S)
9290 return S;
9291
9292 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9293}
9294
9295template<typename Derived>
9299 // Transform the nested-name-specifier, if any.
9300 NestedNameSpecifierLoc QualifierLoc;
9301 if (S->getQualifierLoc()) {
9302 QualifierLoc
9303 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9304 if (!QualifierLoc)
9305 return StmtError();
9306 }
9307
9308 // Transform the declaration name.
9309 DeclarationNameInfo NameInfo = S->getNameInfo();
9310 if (NameInfo.getName()) {
9311 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9312 if (!NameInfo.getName())
9313 return StmtError();
9314 }
9315
9316 // Check whether anything changed.
9317 if (!getDerived().AlwaysRebuild() &&
9318 QualifierLoc == S->getQualifierLoc() &&
9319 NameInfo.getName() == S->getNameInfo().getName())
9320 return S;
9321
9322 // Determine whether this name exists, if we can.
9323 CXXScopeSpec SS;
9324 SS.Adopt(QualifierLoc);
9325 bool Dependent = false;
9326 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9328 if (S->isIfExists())
9329 break;
9330
9331 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9332
9334 if (S->isIfNotExists())
9335 break;
9336
9337 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9338
9340 Dependent = true;
9341 break;
9342
9344 return StmtError();
9345 }
9346
9347 // We need to continue with the instantiation, so do so now.
9348 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9349 if (SubStmt.isInvalid())
9350 return StmtError();
9351
9352 // If we have resolved the name, just transform to the substatement.
9353 if (!Dependent)
9354 return SubStmt;
9355
9356 // The name is still dependent, so build a dependent expression again.
9357 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9358 S->isIfExists(),
9359 QualifierLoc,
9360 NameInfo,
9361 SubStmt.get());
9362}
9363
9364template<typename Derived>
9367 NestedNameSpecifierLoc QualifierLoc;
9368 if (E->getQualifierLoc()) {
9369 QualifierLoc
9370 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9371 if (!QualifierLoc)
9372 return ExprError();
9373 }
9374
9375 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9376 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9377 if (!PD)
9378 return ExprError();
9379
9380 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9381 if (Base.isInvalid())
9382 return ExprError();
9383
9384 return new (SemaRef.getASTContext())
9385 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9387 QualifierLoc, E->getMemberLoc());
9388}
9389
9390template <typename Derived>
9393 auto BaseRes = getDerived().TransformExpr(E->getBase());
9394 if (BaseRes.isInvalid())
9395 return ExprError();
9396 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9397 if (IdxRes.isInvalid())
9398 return ExprError();
9399
9400 if (!getDerived().AlwaysRebuild() &&
9401 BaseRes.get() == E->getBase() &&
9402 IdxRes.get() == E->getIdx())
9403 return E;
9404
9405 return getDerived().RebuildArraySubscriptExpr(
9406 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9407}
9408
9409template <typename Derived>
9411 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9412 if (TryBlock.isInvalid())
9413 return StmtError();
9414
9415 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9416 if (Handler.isInvalid())
9417 return StmtError();
9418
9419 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9420 Handler.get() == S->getHandler())
9421 return S;
9422
9423 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9424 TryBlock.get(), Handler.get());
9425}
9426
9427template <typename Derived>
9429 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9430 if (Block.isInvalid())
9431 return StmtError();
9432
9433 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9434}
9435
9436template <typename Derived>
9438 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9439 if (FilterExpr.isInvalid())
9440 return StmtError();
9441
9442 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9443 if (Block.isInvalid())
9444 return StmtError();
9445
9446 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9447 Block.get());
9448}
9449
9450template <typename Derived>
9452 if (isa<SEHFinallyStmt>(Handler))
9453 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9454 else
9455 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9456}
9457
9458template<typename Derived>
9461 return S;
9462}
9463
9464//===----------------------------------------------------------------------===//
9465// OpenMP directive transformation
9466//===----------------------------------------------------------------------===//
9467
9468template <typename Derived>
9469StmtResult
9470TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9471 // OMPCanonicalLoops are eliminated during transformation, since they will be
9472 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9473 // after transformation.
9474 return getDerived().TransformStmt(L->getLoopStmt());
9475}
9476
9477template <typename Derived>
9480
9481 // Transform the clauses
9483 ArrayRef<OMPClause *> Clauses = D->clauses();
9484 TClauses.reserve(Clauses.size());
9485 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9486 I != E; ++I) {
9487 if (*I) {
9488 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9489 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9490 getDerived().getSema().OpenMP().EndOpenMPClause();
9491 if (Clause)
9492 TClauses.push_back(Clause);
9493 } else {
9494 TClauses.push_back(nullptr);
9495 }
9496 }
9497 StmtResult AssociatedStmt;
9498 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9499 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9500 D->getDirectiveKind(),
9501 /*CurScope=*/nullptr);
9502 StmtResult Body;
9503 {
9504 Sema::CompoundScopeRAII CompoundScope(getSema());
9505 Stmt *CS;
9506 if (D->getDirectiveKind() == OMPD_atomic ||
9507 D->getDirectiveKind() == OMPD_critical ||
9508 D->getDirectiveKind() == OMPD_section ||
9509 D->getDirectiveKind() == OMPD_master)
9510 CS = D->getAssociatedStmt();
9511 else
9512 CS = D->getRawStmt();
9513 Body = getDerived().TransformStmt(CS);
9514 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9515 getSema().getLangOpts().OpenMPIRBuilder)
9516 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9517 }
9518 AssociatedStmt =
9519 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9520 if (AssociatedStmt.isInvalid()) {
9521 return StmtError();
9522 }
9523 }
9524 if (TClauses.size() != Clauses.size()) {
9525 return StmtError();
9526 }
9527
9528 // Transform directive name for 'omp critical' directive.
9529 DeclarationNameInfo DirName;
9530 if (D->getDirectiveKind() == OMPD_critical) {
9531 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9532 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9533 }
9534 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9535 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9536 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9537 } else if (D->getDirectiveKind() == OMPD_cancel) {
9538 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9539 }
9540
9541 return getDerived().RebuildOMPExecutableDirective(
9542 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9543 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
9544}
9545
9546/// This is mostly the same as above, but allows 'informational' class
9547/// directives when rebuilding the stmt. It still takes an
9548/// OMPExecutableDirective-type argument because we're reusing that as the
9549/// superclass for the 'assume' directive at present, instead of defining a
9550/// mostly-identical OMPInformationalDirective parent class.
9551template <typename Derived>
9554
9555 // Transform the clauses
9557 ArrayRef<OMPClause *> Clauses = D->clauses();
9558 TClauses.reserve(Clauses.size());
9559 for (OMPClause *C : Clauses) {
9560 if (C) {
9561 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
9562 OMPClause *Clause = getDerived().TransformOMPClause(C);
9563 getDerived().getSema().OpenMP().EndOpenMPClause();
9564 if (Clause)
9565 TClauses.push_back(Clause);
9566 } else {
9567 TClauses.push_back(nullptr);
9568 }
9569 }
9570 StmtResult AssociatedStmt;
9571 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9572 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9573 D->getDirectiveKind(),
9574 /*CurScope=*/nullptr);
9575 StmtResult Body;
9576 {
9577 Sema::CompoundScopeRAII CompoundScope(getSema());
9578 assert(D->getDirectiveKind() == OMPD_assume &&
9579 "Unexpected informational directive");
9580 Stmt *CS = D->getAssociatedStmt();
9581 Body = getDerived().TransformStmt(CS);
9582 }
9583 AssociatedStmt =
9584 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9585 if (AssociatedStmt.isInvalid())
9586 return StmtError();
9587 }
9588 if (TClauses.size() != Clauses.size())
9589 return StmtError();
9590
9591 DeclarationNameInfo DirName;
9592
9593 return getDerived().RebuildOMPInformationalDirective(
9594 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
9595 D->getBeginLoc(), D->getEndLoc());
9596}
9597
9598template <typename Derived>
9601 // TODO: Fix This
9602 unsigned OMPVersion = getDerived().getSema().getLangOpts().OpenMP;
9603 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9604 << getOpenMPDirectiveName(D->getDirectiveKind(), OMPVersion);
9605 return StmtError();
9606}
9607
9608template <typename Derived>
9609StmtResult
9610TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9611 DeclarationNameInfo DirName;
9612 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9613 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
9614 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9615 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9616 return Res;
9617}
9618
9619template <typename Derived>
9622 DeclarationNameInfo DirName;
9623 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9624 OMPD_simd, DirName, nullptr, D->getBeginLoc());
9625 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9626 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9627 return Res;
9628}
9629
9630template <typename Derived>
9633 DeclarationNameInfo DirName;
9634 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9635 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9636 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9637 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9638 return Res;
9639}
9640
9641template <typename Derived>
9644 DeclarationNameInfo DirName;
9645 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9646 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9647 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9648 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9649 return Res;
9650}
9651
9652template <typename Derived>
9655 DeclarationNameInfo DirName;
9656 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9657 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9658 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9659 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9660 return Res;
9661}
9662
9663template <typename Derived>
9666 DeclarationNameInfo DirName;
9667 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9668 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9669 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9670 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9671 return Res;
9672}
9673
9674template <typename Derived>
9676 OMPInterchangeDirective *D) {
9677 DeclarationNameInfo DirName;
9678 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9679 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9680 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9681 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9682 return Res;
9683}
9684
9685template <typename Derived>
9688 DeclarationNameInfo DirName;
9689 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9690 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9691 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9692 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9693 return Res;
9694}
9695
9696template <typename Derived>
9699 DeclarationNameInfo DirName;
9700 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9701 OMPD_for, DirName, nullptr, D->getBeginLoc());
9702 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9703 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9704 return Res;
9705}
9706
9707template <typename Derived>
9710 DeclarationNameInfo DirName;
9711 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9712 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
9713 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9714 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9715 return Res;
9716}
9717
9718template <typename Derived>
9721 DeclarationNameInfo DirName;
9722 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9723 OMPD_sections, DirName, nullptr, D->getBeginLoc());
9724 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9725 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9726 return Res;
9727}
9728
9729template <typename Derived>
9732 DeclarationNameInfo DirName;
9733 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9734 OMPD_section, DirName, nullptr, D->getBeginLoc());
9735 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9736 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9737 return Res;
9738}
9739
9740template <typename Derived>
9743 DeclarationNameInfo DirName;
9744 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9745 OMPD_scope, DirName, nullptr, D->getBeginLoc());
9746 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9747 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9748 return Res;
9749}
9750
9751template <typename Derived>
9754 DeclarationNameInfo DirName;
9755 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9756 OMPD_single, DirName, nullptr, D->getBeginLoc());
9757 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9758 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9759 return Res;
9760}
9761
9762template <typename Derived>
9765 DeclarationNameInfo DirName;
9766 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9767 OMPD_master, DirName, nullptr, D->getBeginLoc());
9768 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9769 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9770 return Res;
9771}
9772
9773template <typename Derived>
9776 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9777 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
9778 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9779 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9780 return Res;
9781}
9782
9783template <typename Derived>
9785 OMPParallelForDirective *D) {
9786 DeclarationNameInfo DirName;
9787 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9788 OMPD_parallel_for, 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>
9796 OMPParallelForSimdDirective *D) {
9797 DeclarationNameInfo DirName;
9798 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9799 OMPD_parallel_for_simd, 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>
9807 OMPParallelMasterDirective *D) {
9808 DeclarationNameInfo DirName;
9809 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9810 OMPD_parallel_master, 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>
9818 OMPParallelMaskedDirective *D) {
9819 DeclarationNameInfo DirName;
9820 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9821 OMPD_parallel_masked, 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>
9829 OMPParallelSectionsDirective *D) {
9830 DeclarationNameInfo DirName;
9831 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9832 OMPD_parallel_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_task, 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>
9851 OMPTaskyieldDirective *D) {
9852 DeclarationNameInfo DirName;
9853 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9854 OMPD_taskyield, 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_barrier, 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_taskwait, 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 DeclarationNameInfo DirName;
9886 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9887 OMPD_assume, DirName, nullptr, D->getBeginLoc());
9888 StmtResult Res = getDerived().TransformOMPInformationalDirective(D);
9889 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9890 return Res;
9891}
9892
9893template <typename Derived>
9896 DeclarationNameInfo DirName;
9897 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9898 OMPD_error, DirName, nullptr, D->getBeginLoc());
9899 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9900 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9901 return Res;
9902}
9903
9904template <typename Derived>
9906 OMPTaskgroupDirective *D) {
9907 DeclarationNameInfo DirName;
9908 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9909 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
9910 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9911 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9912 return Res;
9913}
9914
9915template <typename Derived>
9918 DeclarationNameInfo DirName;
9919 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9920 OMPD_flush, DirName, nullptr, D->getBeginLoc());
9921 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9922 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9923 return Res;
9924}
9925
9926template <typename Derived>
9929 DeclarationNameInfo DirName;
9930 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9931 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
9932 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9933 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9934 return Res;
9935}
9936
9937template <typename Derived>
9940 DeclarationNameInfo DirName;
9941 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9942 OMPD_scan, DirName, nullptr, D->getBeginLoc());
9943 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9944 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9945 return Res;
9946}
9947
9948template <typename Derived>
9951 DeclarationNameInfo DirName;
9952 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9953 OMPD_ordered, DirName, nullptr, D->getBeginLoc());
9954 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9955 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9956 return Res;
9957}
9958
9959template <typename Derived>
9962 DeclarationNameInfo DirName;
9963 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9964 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
9965 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9966 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9967 return Res;
9968}
9969
9970template <typename Derived>
9973 DeclarationNameInfo DirName;
9974 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9975 OMPD_target, DirName, nullptr, D->getBeginLoc());
9976 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9977 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9978 return Res;
9979}
9980
9981template <typename Derived>
9983 OMPTargetDataDirective *D) {
9984 DeclarationNameInfo DirName;
9985 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9986 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
9987 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9988 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9989 return Res;
9990}
9991
9992template <typename Derived>
9994 OMPTargetEnterDataDirective *D) {
9995 DeclarationNameInfo DirName;
9996 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9997 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
9998 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9999 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10000 return Res;
10001}
10002
10003template <typename Derived>
10005 OMPTargetExitDataDirective *D) {
10006 DeclarationNameInfo DirName;
10007 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10008 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
10009 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10010 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10011 return Res;
10012}
10013
10014template <typename Derived>
10016 OMPTargetParallelDirective *D) {
10017 DeclarationNameInfo DirName;
10018 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10019 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
10020 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10021 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10022 return Res;
10023}
10024
10025template <typename Derived>
10027 OMPTargetParallelForDirective *D) {
10028 DeclarationNameInfo DirName;
10029 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10030 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
10031 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10032 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10033 return Res;
10034}
10035
10036template <typename Derived>
10038 OMPTargetUpdateDirective *D) {
10039 DeclarationNameInfo DirName;
10040 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10041 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
10042 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10043 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10044 return Res;
10045}
10046
10047template <typename Derived>
10050 DeclarationNameInfo DirName;
10051 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10052 OMPD_teams, DirName, nullptr, D->getBeginLoc());
10053 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10054 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10055 return Res;
10056}
10057
10058template <typename Derived>
10060 OMPCancellationPointDirective *D) {
10061 DeclarationNameInfo DirName;
10062 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10063 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
10064 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10065 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10066 return Res;
10067}
10068
10069template <typename Derived>
10072 DeclarationNameInfo DirName;
10073 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10074 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
10075 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10076 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10077 return Res;
10078}
10079
10080template <typename Derived>
10083 DeclarationNameInfo DirName;
10084 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10085 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
10086 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10087 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10088 return Res;
10089}
10090
10091template <typename Derived>
10093 OMPTaskLoopSimdDirective *D) {
10094 DeclarationNameInfo DirName;
10095 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10096 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10097 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10098 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10099 return Res;
10100}
10101
10102template <typename Derived>
10104 OMPMasterTaskLoopDirective *D) {
10105 DeclarationNameInfo DirName;
10106 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10107 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
10108 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10109 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10110 return Res;
10111}
10112
10113template <typename Derived>
10115 OMPMaskedTaskLoopDirective *D) {
10116 DeclarationNameInfo DirName;
10117 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10118 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10119 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10120 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10121 return Res;
10122}
10123
10124template <typename Derived>
10126 OMPMasterTaskLoopSimdDirective *D) {
10127 DeclarationNameInfo DirName;
10128 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10129 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10130 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10131 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10132 return Res;
10133}
10134
10135template <typename Derived>
10137 OMPMaskedTaskLoopSimdDirective *D) {
10138 DeclarationNameInfo DirName;
10139 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10140 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10141 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10142 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10143 return Res;
10144}
10145
10146template <typename Derived>
10148 OMPParallelMasterTaskLoopDirective *D) {
10149 DeclarationNameInfo DirName;
10150 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10151 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10152 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10153 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10154 return Res;
10155}
10156
10157template <typename Derived>
10159 OMPParallelMaskedTaskLoopDirective *D) {
10160 DeclarationNameInfo DirName;
10161 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10162 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10163 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10164 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10165 return Res;
10166}
10167
10168template <typename Derived>
10171 OMPParallelMasterTaskLoopSimdDirective *D) {
10172 DeclarationNameInfo DirName;
10173 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10174 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10175 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10176 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10177 return Res;
10178}
10179
10180template <typename Derived>
10183 OMPParallelMaskedTaskLoopSimdDirective *D) {
10184 DeclarationNameInfo DirName;
10185 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10186 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10187 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10188 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10189 return Res;
10190}
10191
10192template <typename Derived>
10194 OMPDistributeDirective *D) {
10195 DeclarationNameInfo DirName;
10196 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10197 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10198 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10199 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10200 return Res;
10201}
10202
10203template <typename Derived>
10205 OMPDistributeParallelForDirective *D) {
10206 DeclarationNameInfo DirName;
10207 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10208 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10209 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10210 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10211 return Res;
10212}
10213
10214template <typename Derived>
10217 OMPDistributeParallelForSimdDirective *D) {
10218 DeclarationNameInfo DirName;
10219 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10220 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10221 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10222 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10223 return Res;
10224}
10225
10226template <typename Derived>
10228 OMPDistributeSimdDirective *D) {
10229 DeclarationNameInfo DirName;
10230 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10231 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
10232 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10233 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10234 return Res;
10235}
10236
10237template <typename Derived>
10239 OMPTargetParallelForSimdDirective *D) {
10240 DeclarationNameInfo DirName;
10241 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10242 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10243 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10244 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10245 return Res;
10246}
10247
10248template <typename Derived>
10250 OMPTargetSimdDirective *D) {
10251 DeclarationNameInfo DirName;
10252 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10253 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
10254 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10255 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10256 return Res;
10257}
10258
10259template <typename Derived>
10261 OMPTeamsDistributeDirective *D) {
10262 DeclarationNameInfo DirName;
10263 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10264 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10265 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10266 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10267 return Res;
10268}
10269
10270template <typename Derived>
10272 OMPTeamsDistributeSimdDirective *D) {
10273 DeclarationNameInfo DirName;
10274 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10275 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10276 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10277 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10278 return Res;
10279}
10280
10281template <typename Derived>
10283 OMPTeamsDistributeParallelForSimdDirective *D) {
10284 DeclarationNameInfo DirName;
10285 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10286 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10287 D->getBeginLoc());
10288 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10289 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10290 return Res;
10291}
10292
10293template <typename Derived>
10295 OMPTeamsDistributeParallelForDirective *D) {
10296 DeclarationNameInfo DirName;
10297 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10298 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10299 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10300 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10301 return Res;
10302}
10303
10304template <typename Derived>
10306 OMPTargetTeamsDirective *D) {
10307 DeclarationNameInfo DirName;
10308 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10309 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10310 auto Res = getDerived().TransformOMPExecutableDirective(D);
10311 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10312 return Res;
10313}
10314
10315template <typename Derived>
10317 OMPTargetTeamsDistributeDirective *D) {
10318 DeclarationNameInfo DirName;
10319 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10320 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10321 auto Res = getDerived().TransformOMPExecutableDirective(D);
10322 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10323 return Res;
10324}
10325
10326template <typename Derived>
10329 OMPTargetTeamsDistributeParallelForDirective *D) {
10330 DeclarationNameInfo DirName;
10331 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10332 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10333 D->getBeginLoc());
10334 auto Res = getDerived().TransformOMPExecutableDirective(D);
10335 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10336 return Res;
10337}
10338
10339template <typename Derived>
10342 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10343 DeclarationNameInfo DirName;
10344 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10345 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10346 D->getBeginLoc());
10347 auto Res = getDerived().TransformOMPExecutableDirective(D);
10348 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10349 return Res;
10350}
10351
10352template <typename Derived>
10355 OMPTargetTeamsDistributeSimdDirective *D) {
10356 DeclarationNameInfo DirName;
10357 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10358 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10359 auto Res = getDerived().TransformOMPExecutableDirective(D);
10360 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10361 return Res;
10362}
10363
10364template <typename Derived>
10367 DeclarationNameInfo DirName;
10368 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10369 OMPD_interop, DirName, nullptr, D->getBeginLoc());
10370 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10371 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10372 return Res;
10373}
10374
10375template <typename Derived>
10378 DeclarationNameInfo DirName;
10379 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10380 OMPD_dispatch, DirName, nullptr, D->getBeginLoc());
10381 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10382 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10383 return Res;
10384}
10385
10386template <typename Derived>
10389 DeclarationNameInfo DirName;
10390 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10391 OMPD_masked, DirName, nullptr, D->getBeginLoc());
10392 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10393 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10394 return Res;
10395}
10396
10397template <typename Derived>
10399 OMPGenericLoopDirective *D) {
10400 DeclarationNameInfo DirName;
10401 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10402 OMPD_loop, DirName, nullptr, D->getBeginLoc());
10403 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10404 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10405 return Res;
10406}
10407
10408template <typename Derived>
10410 OMPTeamsGenericLoopDirective *D) {
10411 DeclarationNameInfo DirName;
10412 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10413 OMPD_teams_loop, DirName, nullptr, D->getBeginLoc());
10414 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10415 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10416 return Res;
10417}
10418
10419template <typename Derived>
10421 OMPTargetTeamsGenericLoopDirective *D) {
10422 DeclarationNameInfo DirName;
10423 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10424 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
10425 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10426 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10427 return Res;
10428}
10429
10430template <typename Derived>
10432 OMPParallelGenericLoopDirective *D) {
10433 DeclarationNameInfo DirName;
10434 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10435 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
10436 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10437 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10438 return Res;
10439}
10440
10441template <typename Derived>
10444 OMPTargetParallelGenericLoopDirective *D) {
10445 DeclarationNameInfo DirName;
10446 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10447 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10448 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10449 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10450 return Res;
10451}
10452
10453//===----------------------------------------------------------------------===//
10454// OpenMP clause transformation
10455//===----------------------------------------------------------------------===//
10456template <typename Derived>
10458 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10459 if (Cond.isInvalid())
10460 return nullptr;
10461 return getDerived().RebuildOMPIfClause(
10462 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10463 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10464}
10465
10466template <typename Derived>
10468 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10469 if (Cond.isInvalid())
10470 return nullptr;
10471 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10472 C->getLParenLoc(), C->getEndLoc());
10473}
10474
10475template <typename Derived>
10476OMPClause *
10478 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
10479 if (NumThreads.isInvalid())
10480 return nullptr;
10481 return getDerived().RebuildOMPNumThreadsClause(
10482 C->getModifier(), NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(),
10483 C->getModifierLoc(), C->getEndLoc());
10484}
10485
10486template <typename Derived>
10487OMPClause *
10489 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10490 if (E.isInvalid())
10491 return nullptr;
10492 return getDerived().RebuildOMPSafelenClause(
10493 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10494}
10495
10496template <typename Derived>
10497OMPClause *
10499 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10500 if (E.isInvalid())
10501 return nullptr;
10502 return getDerived().RebuildOMPAllocatorClause(
10503 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10504}
10505
10506template <typename Derived>
10507OMPClause *
10509 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
10510 if (E.isInvalid())
10511 return nullptr;
10512 return getDerived().RebuildOMPSimdlenClause(
10513 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10514}
10515
10516template <typename Derived>
10518 SmallVector<Expr *, 4> TransformedSizes;
10519 TransformedSizes.reserve(C->getNumSizes());
10520 bool Changed = false;
10521 for (Expr *E : C->getSizesRefs()) {
10522 if (!E) {
10523 TransformedSizes.push_back(nullptr);
10524 continue;
10525 }
10526
10527 ExprResult T = getDerived().TransformExpr(E);
10528 if (T.isInvalid())
10529 return nullptr;
10530 if (E != T.get())
10531 Changed = true;
10532 TransformedSizes.push_back(T.get());
10533 }
10534
10535 if (!Changed && !getDerived().AlwaysRebuild())
10536 return C;
10537 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
10538 C->getLParenLoc(), C->getEndLoc());
10539}
10540
10541template <typename Derived>
10542OMPClause *
10544 SmallVector<Expr *> TransformedArgs;
10545 TransformedArgs.reserve(C->getNumLoops());
10546 bool Changed = false;
10547 for (Expr *E : C->getArgsRefs()) {
10548 if (!E) {
10549 TransformedArgs.push_back(nullptr);
10550 continue;
10551 }
10552
10553 ExprResult T = getDerived().TransformExpr(E);
10554 if (T.isInvalid())
10555 return nullptr;
10556 if (E != T.get())
10557 Changed = true;
10558 TransformedArgs.push_back(T.get());
10559 }
10560
10561 if (!Changed && !getDerived().AlwaysRebuild())
10562 return C;
10563 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
10564 C->getLParenLoc(), C->getEndLoc());
10565}
10566
10567template <typename Derived>
10569 if (!getDerived().AlwaysRebuild())
10570 return C;
10571 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10572}
10573
10574template <typename Derived>
10575OMPClause *
10577 ExprResult T = getDerived().TransformExpr(C->getFactor());
10578 if (T.isInvalid())
10579 return nullptr;
10580 Expr *Factor = T.get();
10581 bool Changed = Factor != C->getFactor();
10582
10583 if (!Changed && !getDerived().AlwaysRebuild())
10584 return C;
10585 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10586 C->getEndLoc());
10587}
10588
10589template <typename Derived>
10590OMPClause *
10592 ExprResult F = getDerived().TransformExpr(C->getFirst());
10593 if (F.isInvalid())
10594 return nullptr;
10595
10596 ExprResult Cn = getDerived().TransformExpr(C->getCount());
10597 if (Cn.isInvalid())
10598 return nullptr;
10599
10600 Expr *First = F.get();
10601 Expr *Count = Cn.get();
10602
10603 bool Changed = (First != C->getFirst()) || (Count != C->getCount());
10604
10605 // If no changes and AlwaysRebuild() is false, return the original clause
10606 if (!Changed && !getDerived().AlwaysRebuild())
10607 return C;
10608
10609 return RebuildOMPLoopRangeClause(First, Count, C->getBeginLoc(),
10610 C->getLParenLoc(), C->getFirstLoc(),
10611 C->getCountLoc(), C->getEndLoc());
10612}
10613
10614template <typename Derived>
10615OMPClause *
10617 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10618 if (E.isInvalid())
10619 return nullptr;
10620 return getDerived().RebuildOMPCollapseClause(
10621 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10622}
10623
10624template <typename Derived>
10625OMPClause *
10627 return getDerived().RebuildOMPDefaultClause(
10628 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getDefaultVC(),
10629 C->getDefaultVCLoc(), C->getBeginLoc(), C->getLParenLoc(),
10630 C->getEndLoc());
10631}
10632
10633template <typename Derived>
10634OMPClause *
10636 // No need to rebuild this clause, no template-dependent parameters.
10637 return C;
10638}
10639
10640template <typename Derived>
10641OMPClause *
10643 return getDerived().RebuildOMPProcBindClause(
10644 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10645 C->getLParenLoc(), C->getEndLoc());
10646}
10647
10648template <typename Derived>
10649OMPClause *
10651 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10652 if (E.isInvalid())
10653 return nullptr;
10654 return getDerived().RebuildOMPScheduleClause(
10655 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10656 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10657 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10658 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10659}
10660
10661template <typename Derived>
10662OMPClause *
10664 ExprResult E;
10665 if (auto *Num = C->getNumForLoops()) {
10666 E = getDerived().TransformExpr(Num);
10667 if (E.isInvalid())
10668 return nullptr;
10669 }
10670 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10671 C->getLParenLoc(), E.get());
10672}
10673
10674template <typename Derived>
10675OMPClause *
10677 ExprResult E;
10678 if (Expr *Evt = C->getEventHandler()) {
10679 E = getDerived().TransformExpr(Evt);
10680 if (E.isInvalid())
10681 return nullptr;
10682 }
10683 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10684 C->getLParenLoc(), C->getEndLoc());
10685}
10686
10687template <typename Derived>
10688OMPClause *
10691 if (auto *Condition = C->getCondition()) {
10692 Cond = getDerived().TransformExpr(Condition);
10693 if (Cond.isInvalid())
10694 return nullptr;
10695 }
10696 return getDerived().RebuildOMPNowaitClause(Cond.get(), C->getBeginLoc(),
10697 C->getLParenLoc(), C->getEndLoc());
10698}
10699
10700template <typename Derived>
10701OMPClause *
10703 // No need to rebuild this clause, no template-dependent parameters.
10704 return C;
10705}
10706
10707template <typename Derived>
10708OMPClause *
10710 // No need to rebuild this clause, no template-dependent parameters.
10711 return C;
10712}
10713
10714template <typename Derived>
10716 // No need to rebuild this clause, no template-dependent parameters.
10717 return C;
10718}
10719
10720template <typename Derived>
10722 // No need to rebuild this clause, no template-dependent parameters.
10723 return C;
10724}
10725
10726template <typename Derived>
10727OMPClause *
10729 // No need to rebuild this clause, no template-dependent parameters.
10730 return C;
10731}
10732
10733template <typename Derived>
10734OMPClause *
10736 // No need to rebuild this clause, no template-dependent parameters.
10737 return C;
10738}
10739
10740template <typename Derived>
10741OMPClause *
10743 // No need to rebuild this clause, no template-dependent parameters.
10744 return C;
10745}
10746
10747template <typename Derived>
10749 // No need to rebuild this clause, no template-dependent parameters.
10750 return C;
10751}
10752
10753template <typename Derived>
10754OMPClause *
10756 return C;
10757}
10758
10759template <typename Derived>
10761 ExprResult E = getDerived().TransformExpr(C->getExpr());
10762 if (E.isInvalid())
10763 return nullptr;
10764 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
10765 C->getLParenLoc(), C->getEndLoc());
10766}
10767
10768template <typename Derived>
10769OMPClause *
10771 return C;
10772}
10773
10774template <typename Derived>
10775OMPClause *
10777 return C;
10778}
10779template <typename Derived>
10782 return C;
10783}
10784template <typename Derived>
10787 return C;
10788}
10789template <typename Derived>
10792 return C;
10793}
10794
10795template <typename Derived>
10796OMPClause *
10798 // No need to rebuild this clause, no template-dependent parameters.
10799 return C;
10800}
10801
10802template <typename Derived>
10803OMPClause *
10805 // No need to rebuild this clause, no template-dependent parameters.
10806 return C;
10807}
10808
10809template <typename Derived>
10810OMPClause *
10812 // No need to rebuild this clause, no template-dependent parameters.
10813 return C;
10814}
10815
10816template <typename Derived>
10817OMPClause *
10819 // No need to rebuild this clause, no template-dependent parameters.
10820 return C;
10821}
10822
10823template <typename Derived>
10824OMPClause *
10826 // No need to rebuild this clause, no template-dependent parameters.
10827 return C;
10828}
10829
10830template <typename Derived>
10832 // No need to rebuild this clause, no template-dependent parameters.
10833 return C;
10834}
10835
10836template <typename Derived>
10837OMPClause *
10839 // No need to rebuild this clause, no template-dependent parameters.
10840 return C;
10841}
10842
10843template <typename Derived>
10845 // No need to rebuild this clause, no template-dependent parameters.
10846 return C;
10847}
10848
10849template <typename Derived>
10850OMPClause *
10852 // No need to rebuild this clause, no template-dependent parameters.
10853 return C;
10854}
10855
10856template <typename Derived>
10858 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
10859 if (IVR.isInvalid())
10860 return nullptr;
10861
10862 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
10863 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
10864 for (Expr *E : llvm::drop_begin(C->varlist())) {
10865 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
10866 if (ER.isInvalid())
10867 return nullptr;
10868 InteropInfo.PreferTypes.push_back(ER.get());
10869 }
10870 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
10871 C->getBeginLoc(), C->getLParenLoc(),
10872 C->getVarLoc(), C->getEndLoc());
10873}
10874
10875template <typename Derived>
10877 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
10878 if (ER.isInvalid())
10879 return nullptr;
10880 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
10881 C->getLParenLoc(), C->getVarLoc(),
10882 C->getEndLoc());
10883}
10884
10885template <typename Derived>
10886OMPClause *
10888 ExprResult ER;
10889 if (Expr *IV = C->getInteropVar()) {
10890 ER = getDerived().TransformExpr(IV);
10891 if (ER.isInvalid())
10892 return nullptr;
10893 }
10894 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
10895 C->getLParenLoc(), C->getVarLoc(),
10896 C->getEndLoc());
10897}
10898
10899template <typename Derived>
10900OMPClause *
10902 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10903 if (Cond.isInvalid())
10904 return nullptr;
10905 return getDerived().RebuildOMPNovariantsClause(
10906 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10907}
10908
10909template <typename Derived>
10910OMPClause *
10912 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10913 if (Cond.isInvalid())
10914 return nullptr;
10915 return getDerived().RebuildOMPNocontextClause(
10916 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10917}
10918
10919template <typename Derived>
10920OMPClause *
10922 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
10923 if (ThreadID.isInvalid())
10924 return nullptr;
10925 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
10926 C->getLParenLoc(), C->getEndLoc());
10927}
10928
10929template <typename Derived>
10931 ExprResult E = getDerived().TransformExpr(C->getAlignment());
10932 if (E.isInvalid())
10933 return nullptr;
10934 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
10935 C->getLParenLoc(), C->getEndLoc());
10936}
10937
10938template <typename Derived>
10941 llvm_unreachable("unified_address clause cannot appear in dependent context");
10942}
10943
10944template <typename Derived>
10947 llvm_unreachable(
10948 "unified_shared_memory clause cannot appear in dependent context");
10949}
10950
10951template <typename Derived>
10954 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
10955}
10956
10957template <typename Derived>
10960 llvm_unreachable(
10961 "dynamic_allocators clause cannot appear in dependent context");
10962}
10963
10964template <typename Derived>
10967 llvm_unreachable(
10968 "atomic_default_mem_order clause cannot appear in dependent context");
10969}
10970
10971template <typename Derived>
10972OMPClause *
10974 llvm_unreachable("self_maps clause cannot appear in dependent context");
10975}
10976
10977template <typename Derived>
10979 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
10980 C->getBeginLoc(), C->getLParenLoc(),
10981 C->getEndLoc());
10982}
10983
10984template <typename Derived>
10985OMPClause *
10987 return getDerived().RebuildOMPSeverityClause(
10988 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
10989 C->getLParenLoc(), C->getEndLoc());
10990}
10991
10992template <typename Derived>
10993OMPClause *
10995 ExprResult E = getDerived().TransformExpr(C->getMessageString());
10996 if (E.isInvalid())
10997 return nullptr;
10998 return getDerived().RebuildOMPMessageClause(
10999 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11000}
11001
11002template <typename Derived>
11003OMPClause *
11006 Vars.reserve(C->varlist_size());
11007 for (auto *VE : C->varlist()) {
11008 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11009 if (EVar.isInvalid())
11010 return nullptr;
11011 Vars.push_back(EVar.get());
11012 }
11013 return getDerived().RebuildOMPPrivateClause(
11014 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11015}
11016
11017template <typename Derived>
11021 Vars.reserve(C->varlist_size());
11022 for (auto *VE : C->varlist()) {
11023 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11024 if (EVar.isInvalid())
11025 return nullptr;
11026 Vars.push_back(EVar.get());
11027 }
11028 return getDerived().RebuildOMPFirstprivateClause(
11029 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11030}
11031
11032template <typename Derived>
11033OMPClause *
11036 Vars.reserve(C->varlist_size());
11037 for (auto *VE : C->varlist()) {
11038 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11039 if (EVar.isInvalid())
11040 return nullptr;
11041 Vars.push_back(EVar.get());
11042 }
11043 return getDerived().RebuildOMPLastprivateClause(
11044 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11045 C->getLParenLoc(), C->getEndLoc());
11046}
11047
11048template <typename Derived>
11049OMPClause *
11052 Vars.reserve(C->varlist_size());
11053 for (auto *VE : C->varlist()) {
11054 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11055 if (EVar.isInvalid())
11056 return nullptr;
11057 Vars.push_back(EVar.get());
11058 }
11059 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11060 C->getLParenLoc(), C->getEndLoc());
11061}
11062
11063template <typename Derived>
11064OMPClause *
11067 Vars.reserve(C->varlist_size());
11068 for (auto *VE : C->varlist()) {
11069 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11070 if (EVar.isInvalid())
11071 return nullptr;
11072 Vars.push_back(EVar.get());
11073 }
11074 CXXScopeSpec ReductionIdScopeSpec;
11075 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11076
11077 DeclarationNameInfo NameInfo = C->getNameInfo();
11078 if (NameInfo.getName()) {
11079 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11080 if (!NameInfo.getName())
11081 return nullptr;
11082 }
11083 // Build a list of all UDR decls with the same names ranged by the Scopes.
11084 // The Scope boundary is a duplication of the previous decl.
11085 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11086 for (auto *E : C->reduction_ops()) {
11087 // Transform all the decls.
11088 if (E) {
11089 auto *ULE = cast<UnresolvedLookupExpr>(E);
11090 UnresolvedSet<8> Decls;
11091 for (auto *D : ULE->decls()) {
11092 NamedDecl *InstD =
11093 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11094 Decls.addDecl(InstD, InstD->getAccess());
11095 }
11096 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11097 SemaRef.Context, /*NamingClass=*/nullptr,
11098 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11099 /*ADL=*/true, Decls.begin(), Decls.end(),
11100 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11101 } else
11102 UnresolvedReductions.push_back(nullptr);
11103 }
11104 return getDerived().RebuildOMPReductionClause(
11105 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11106 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11107 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11108}
11109
11110template <typename Derived>
11114 Vars.reserve(C->varlist_size());
11115 for (auto *VE : C->varlist()) {
11116 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11117 if (EVar.isInvalid())
11118 return nullptr;
11119 Vars.push_back(EVar.get());
11120 }
11121 CXXScopeSpec ReductionIdScopeSpec;
11122 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11123
11124 DeclarationNameInfo NameInfo = C->getNameInfo();
11125 if (NameInfo.getName()) {
11126 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11127 if (!NameInfo.getName())
11128 return nullptr;
11129 }
11130 // Build a list of all UDR decls with the same names ranged by the Scopes.
11131 // The Scope boundary is a duplication of the previous decl.
11132 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11133 for (auto *E : C->reduction_ops()) {
11134 // Transform all the decls.
11135 if (E) {
11136 auto *ULE = cast<UnresolvedLookupExpr>(E);
11137 UnresolvedSet<8> Decls;
11138 for (auto *D : ULE->decls()) {
11139 NamedDecl *InstD =
11140 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11141 Decls.addDecl(InstD, InstD->getAccess());
11142 }
11143 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11144 SemaRef.Context, /*NamingClass=*/nullptr,
11145 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11146 /*ADL=*/true, Decls.begin(), Decls.end(),
11147 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11148 } else
11149 UnresolvedReductions.push_back(nullptr);
11150 }
11151 return getDerived().RebuildOMPTaskReductionClause(
11152 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11153 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11154}
11155
11156template <typename Derived>
11157OMPClause *
11160 Vars.reserve(C->varlist_size());
11161 for (auto *VE : C->varlist()) {
11162 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11163 if (EVar.isInvalid())
11164 return nullptr;
11165 Vars.push_back(EVar.get());
11166 }
11167 CXXScopeSpec ReductionIdScopeSpec;
11168 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11169
11170 DeclarationNameInfo NameInfo = C->getNameInfo();
11171 if (NameInfo.getName()) {
11172 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11173 if (!NameInfo.getName())
11174 return nullptr;
11175 }
11176 // Build a list of all UDR decls with the same names ranged by the Scopes.
11177 // The Scope boundary is a duplication of the previous decl.
11178 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11179 for (auto *E : C->reduction_ops()) {
11180 // Transform all the decls.
11181 if (E) {
11182 auto *ULE = cast<UnresolvedLookupExpr>(E);
11183 UnresolvedSet<8> Decls;
11184 for (auto *D : ULE->decls()) {
11185 NamedDecl *InstD =
11186 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11187 Decls.addDecl(InstD, InstD->getAccess());
11188 }
11189 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11190 SemaRef.Context, /*NamingClass=*/nullptr,
11191 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11192 /*ADL=*/true, Decls.begin(), Decls.end(),
11193 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11194 } else
11195 UnresolvedReductions.push_back(nullptr);
11196 }
11197 return getDerived().RebuildOMPInReductionClause(
11198 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11199 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11200}
11201
11202template <typename Derived>
11203OMPClause *
11206 Vars.reserve(C->varlist_size());
11207 for (auto *VE : C->varlist()) {
11208 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11209 if (EVar.isInvalid())
11210 return nullptr;
11211 Vars.push_back(EVar.get());
11212 }
11213 ExprResult Step = getDerived().TransformExpr(C->getStep());
11214 if (Step.isInvalid())
11215 return nullptr;
11216 return getDerived().RebuildOMPLinearClause(
11217 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11218 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11219 C->getEndLoc());
11220}
11221
11222template <typename Derived>
11223OMPClause *
11226 Vars.reserve(C->varlist_size());
11227 for (auto *VE : C->varlist()) {
11228 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11229 if (EVar.isInvalid())
11230 return nullptr;
11231 Vars.push_back(EVar.get());
11232 }
11233 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11234 if (Alignment.isInvalid())
11235 return nullptr;
11236 return getDerived().RebuildOMPAlignedClause(
11237 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11238 C->getColonLoc(), C->getEndLoc());
11239}
11240
11241template <typename Derived>
11242OMPClause *
11245 Vars.reserve(C->varlist_size());
11246 for (auto *VE : C->varlist()) {
11247 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11248 if (EVar.isInvalid())
11249 return nullptr;
11250 Vars.push_back(EVar.get());
11251 }
11252 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11253 C->getLParenLoc(), C->getEndLoc());
11254}
11255
11256template <typename Derived>
11257OMPClause *
11260 Vars.reserve(C->varlist_size());
11261 for (auto *VE : C->varlist()) {
11262 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11263 if (EVar.isInvalid())
11264 return nullptr;
11265 Vars.push_back(EVar.get());
11266 }
11267 return getDerived().RebuildOMPCopyprivateClause(
11268 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11269}
11270
11271template <typename Derived>
11274 Vars.reserve(C->varlist_size());
11275 for (auto *VE : C->varlist()) {
11276 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11277 if (EVar.isInvalid())
11278 return nullptr;
11279 Vars.push_back(EVar.get());
11280 }
11281 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11282 C->getLParenLoc(), C->getEndLoc());
11283}
11284
11285template <typename Derived>
11286OMPClause *
11288 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11289 if (E.isInvalid())
11290 return nullptr;
11291 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11292 C->getLParenLoc(), C->getEndLoc());
11293}
11294
11295template <typename Derived>
11296OMPClause *
11299 Expr *DepModifier = C->getModifier();
11300 if (DepModifier) {
11301 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11302 if (DepModRes.isInvalid())
11303 return nullptr;
11304 DepModifier = DepModRes.get();
11305 }
11306 Vars.reserve(C->varlist_size());
11307 for (auto *VE : C->varlist()) {
11308 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11309 if (EVar.isInvalid())
11310 return nullptr;
11311 Vars.push_back(EVar.get());
11312 }
11313 return getDerived().RebuildOMPDependClause(
11314 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11315 C->getOmpAllMemoryLoc()},
11316 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11317}
11318
11319template <typename Derived>
11320OMPClause *
11322 ExprResult E = getDerived().TransformExpr(C->getDevice());
11323 if (E.isInvalid())
11324 return nullptr;
11325 return getDerived().RebuildOMPDeviceClause(
11326 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11327 C->getModifierLoc(), C->getEndLoc());
11328}
11329
11330template <typename Derived, class T>
11333 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11334 DeclarationNameInfo &MapperIdInfo,
11335 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11336 // Transform expressions in the list.
11337 Vars.reserve(C->varlist_size());
11338 for (auto *VE : C->varlist()) {
11339 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11340 if (EVar.isInvalid())
11341 return true;
11342 Vars.push_back(EVar.get());
11343 }
11344 // Transform mapper scope specifier and identifier.
11345 NestedNameSpecifierLoc QualifierLoc;
11346 if (C->getMapperQualifierLoc()) {
11347 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11348 C->getMapperQualifierLoc());
11349 if (!QualifierLoc)
11350 return true;
11351 }
11352 MapperIdScopeSpec.Adopt(QualifierLoc);
11353 MapperIdInfo = C->getMapperIdInfo();
11354 if (MapperIdInfo.getName()) {
11355 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11356 if (!MapperIdInfo.getName())
11357 return true;
11358 }
11359 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11360 // the previous user-defined mapper lookup in dependent environment.
11361 for (auto *E : C->mapperlists()) {
11362 // Transform all the decls.
11363 if (E) {
11364 auto *ULE = cast<UnresolvedLookupExpr>(E);
11365 UnresolvedSet<8> Decls;
11366 for (auto *D : ULE->decls()) {
11367 NamedDecl *InstD =
11368 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11369 Decls.addDecl(InstD, InstD->getAccess());
11370 }
11371 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11372 TT.getSema().Context, /*NamingClass=*/nullptr,
11373 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11374 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11375 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11376 } else {
11377 UnresolvedMappers.push_back(nullptr);
11378 }
11379 }
11380 return false;
11381}
11382
11383template <typename Derived>
11384OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11385 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11387 Expr *IteratorModifier = C->getIteratorModifier();
11388 if (IteratorModifier) {
11389 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11390 if (MapModRes.isInvalid())
11391 return nullptr;
11392 IteratorModifier = MapModRes.get();
11393 }
11394 CXXScopeSpec MapperIdScopeSpec;
11395 DeclarationNameInfo MapperIdInfo;
11396 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11398 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11399 return nullptr;
11400 return getDerived().RebuildOMPMapClause(
11401 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11402 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11403 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11404}
11405
11406template <typename Derived>
11407OMPClause *
11409 Expr *Allocator = C->getAllocator();
11410 if (Allocator) {
11411 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11412 if (AllocatorRes.isInvalid())
11413 return nullptr;
11414 Allocator = AllocatorRes.get();
11415 }
11416 Expr *Alignment = C->getAlignment();
11417 if (Alignment) {
11418 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11419 if (AlignmentRes.isInvalid())
11420 return nullptr;
11421 Alignment = AlignmentRes.get();
11422 }
11424 Vars.reserve(C->varlist_size());
11425 for (auto *VE : C->varlist()) {
11426 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11427 if (EVar.isInvalid())
11428 return nullptr;
11429 Vars.push_back(EVar.get());
11430 }
11431 return getDerived().RebuildOMPAllocateClause(
11432 Allocator, Alignment, C->getFirstAllocateModifier(),
11433 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11434 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11435 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11436}
11437
11438template <typename Derived>
11439OMPClause *
11442 Vars.reserve(C->varlist_size());
11443 for (auto *VE : C->varlist()) {
11444 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11445 if (EVar.isInvalid())
11446 return nullptr;
11447 Vars.push_back(EVar.get());
11448 }
11449 return getDerived().RebuildOMPNumTeamsClause(
11450 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11451}
11452
11453template <typename Derived>
11454OMPClause *
11457 Vars.reserve(C->varlist_size());
11458 for (auto *VE : C->varlist()) {
11459 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11460 if (EVar.isInvalid())
11461 return nullptr;
11462 Vars.push_back(EVar.get());
11463 }
11464 return getDerived().RebuildOMPThreadLimitClause(
11465 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11466}
11467
11468template <typename Derived>
11469OMPClause *
11471 ExprResult E = getDerived().TransformExpr(C->getPriority());
11472 if (E.isInvalid())
11473 return nullptr;
11474 return getDerived().RebuildOMPPriorityClause(
11475 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11476}
11477
11478template <typename Derived>
11479OMPClause *
11481 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11482 if (E.isInvalid())
11483 return nullptr;
11484 return getDerived().RebuildOMPGrainsizeClause(
11485 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11486 C->getModifierLoc(), C->getEndLoc());
11487}
11488
11489template <typename Derived>
11490OMPClause *
11492 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11493 if (E.isInvalid())
11494 return nullptr;
11495 return getDerived().RebuildOMPNumTasksClause(
11496 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11497 C->getModifierLoc(), C->getEndLoc());
11498}
11499
11500template <typename Derived>
11502 ExprResult E = getDerived().TransformExpr(C->getHint());
11503 if (E.isInvalid())
11504 return nullptr;
11505 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11506 C->getLParenLoc(), C->getEndLoc());
11507}
11508
11509template <typename Derived>
11512 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11513 if (E.isInvalid())
11514 return nullptr;
11515 return getDerived().RebuildOMPDistScheduleClause(
11516 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11517 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11518}
11519
11520template <typename Derived>
11521OMPClause *
11523 // Rebuild Defaultmap Clause since we need to invoke the checking of
11524 // defaultmap(none:variable-category) after template initialization.
11525 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11526 C->getDefaultmapKind(),
11527 C->getBeginLoc(),
11528 C->getLParenLoc(),
11529 C->getDefaultmapModifierLoc(),
11530 C->getDefaultmapKindLoc(),
11531 C->getEndLoc());
11532}
11533
11534template <typename Derived>
11536 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11538 CXXScopeSpec MapperIdScopeSpec;
11539 DeclarationNameInfo MapperIdInfo;
11540 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11542 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11543 return nullptr;
11544 return getDerived().RebuildOMPToClause(
11545 C->getMotionModifiers(), C->getMotionModifiersLoc(), MapperIdScopeSpec,
11546 MapperIdInfo, C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11547}
11548
11549template <typename Derived>
11551 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11553 CXXScopeSpec MapperIdScopeSpec;
11554 DeclarationNameInfo MapperIdInfo;
11555 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11557 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11558 return nullptr;
11559 return getDerived().RebuildOMPFromClause(
11560 C->getMotionModifiers(), C->getMotionModifiersLoc(), MapperIdScopeSpec,
11561 MapperIdInfo, C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11562}
11563
11564template <typename Derived>
11568 Vars.reserve(C->varlist_size());
11569 for (auto *VE : C->varlist()) {
11570 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11571 if (EVar.isInvalid())
11572 return nullptr;
11573 Vars.push_back(EVar.get());
11574 }
11575 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11576 return getDerived().RebuildOMPUseDevicePtrClause(Vars, Locs);
11577}
11578
11579template <typename Derived>
11583 Vars.reserve(C->varlist_size());
11584 for (auto *VE : C->varlist()) {
11585 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11586 if (EVar.isInvalid())
11587 return nullptr;
11588 Vars.push_back(EVar.get());
11589 }
11590 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11591 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11592}
11593
11594template <typename Derived>
11595OMPClause *
11598 Vars.reserve(C->varlist_size());
11599 for (auto *VE : C->varlist()) {
11600 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11601 if (EVar.isInvalid())
11602 return nullptr;
11603 Vars.push_back(EVar.get());
11604 }
11605 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11606 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11607}
11608
11609template <typename Derived>
11613 Vars.reserve(C->varlist_size());
11614 for (auto *VE : C->varlist()) {
11615 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11616 if (EVar.isInvalid())
11617 return nullptr;
11618 Vars.push_back(EVar.get());
11619 }
11620 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11621 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11622}
11623
11624template <typename Derived>
11625OMPClause *
11628 Vars.reserve(C->varlist_size());
11629 for (auto *VE : C->varlist()) {
11630 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11631 if (EVar.isInvalid())
11632 return nullptr;
11633 Vars.push_back(EVar.get());
11634 }
11635 return getDerived().RebuildOMPNontemporalClause(
11636 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11637}
11638
11639template <typename Derived>
11640OMPClause *
11643 Vars.reserve(C->varlist_size());
11644 for (auto *VE : C->varlist()) {
11645 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11646 if (EVar.isInvalid())
11647 return nullptr;
11648 Vars.push_back(EVar.get());
11649 }
11650 return getDerived().RebuildOMPInclusiveClause(
11651 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11652}
11653
11654template <typename Derived>
11655OMPClause *
11658 Vars.reserve(C->varlist_size());
11659 for (auto *VE : C->varlist()) {
11660 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11661 if (EVar.isInvalid())
11662 return nullptr;
11663 Vars.push_back(EVar.get());
11664 }
11665 return getDerived().RebuildOMPExclusiveClause(
11666 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11667}
11668
11669template <typename Derived>
11673 Data.reserve(C->getNumberOfAllocators());
11674 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11675 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11676 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11677 if (Allocator.isInvalid())
11678 continue;
11679 ExprResult AllocatorTraits;
11680 if (Expr *AT = D.AllocatorTraits) {
11681 AllocatorTraits = getDerived().TransformExpr(AT);
11682 if (AllocatorTraits.isInvalid())
11683 continue;
11684 }
11685 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11686 NewD.Allocator = Allocator.get();
11687 NewD.AllocatorTraits = AllocatorTraits.get();
11688 NewD.LParenLoc = D.LParenLoc;
11689 NewD.RParenLoc = D.RParenLoc;
11690 }
11691 return getDerived().RebuildOMPUsesAllocatorsClause(
11692 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11693}
11694
11695template <typename Derived>
11696OMPClause *
11698 SmallVector<Expr *, 4> Locators;
11699 Locators.reserve(C->varlist_size());
11700 ExprResult ModifierRes;
11701 if (Expr *Modifier = C->getModifier()) {
11702 ModifierRes = getDerived().TransformExpr(Modifier);
11703 if (ModifierRes.isInvalid())
11704 return nullptr;
11705 }
11706 for (Expr *E : C->varlist()) {
11707 ExprResult Locator = getDerived().TransformExpr(E);
11708 if (Locator.isInvalid())
11709 continue;
11710 Locators.push_back(Locator.get());
11711 }
11712 return getDerived().RebuildOMPAffinityClause(
11713 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11714 ModifierRes.get(), Locators);
11715}
11716
11717template <typename Derived>
11719 return getDerived().RebuildOMPOrderClause(
11720 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11721 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11722}
11723
11724template <typename Derived>
11726 return getDerived().RebuildOMPBindClause(
11727 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11728 C->getLParenLoc(), C->getEndLoc());
11729}
11730
11731template <typename Derived>
11734 ExprResult Size = getDerived().TransformExpr(C->getSize());
11735 if (Size.isInvalid())
11736 return nullptr;
11737 return getDerived().RebuildOMPXDynCGroupMemClause(
11738 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11739}
11740
11741template <typename Derived>
11744 ExprResult Size = getDerived().TransformExpr(C->getSize());
11745 if (Size.isInvalid())
11746 return nullptr;
11747 return getDerived().RebuildOMPDynGroupprivateClause(
11748 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
11749 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
11750 C->getDynGroupprivateModifierLoc(),
11751 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
11752}
11753
11754template <typename Derived>
11755OMPClause *
11758 Vars.reserve(C->varlist_size());
11759 for (auto *VE : C->varlist()) {
11760 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11761 if (EVar.isInvalid())
11762 return nullptr;
11763 Vars.push_back(EVar.get());
11764 }
11765 return getDerived().RebuildOMPDoacrossClause(
11766 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11767 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11768}
11769
11770template <typename Derived>
11771OMPClause *
11774 for (auto *A : C->getAttrs())
11775 NewAttrs.push_back(getDerived().TransformAttr(A));
11776 return getDerived().RebuildOMPXAttributeClause(
11777 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11778}
11779
11780template <typename Derived>
11782 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11783}
11784
11785//===----------------------------------------------------------------------===//
11786// OpenACC transformation
11787//===----------------------------------------------------------------------===//
11788namespace {
11789template <typename Derived>
11790class OpenACCClauseTransform final
11791 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11792 TreeTransform<Derived> &Self;
11793 ArrayRef<const OpenACCClause *> ExistingClauses;
11794 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11795 OpenACCClause *NewClause = nullptr;
11796
11797 ExprResult VisitVar(Expr *VarRef) {
11798 ExprResult Res = Self.TransformExpr(VarRef);
11799
11800 if (!Res.isUsable())
11801 return Res;
11802
11803 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11804 ParsedClause.getClauseKind(),
11805 Res.get());
11806
11807 return Res;
11808 }
11809
11810 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11811 llvm::SmallVector<Expr *> InstantiatedVarList;
11812 for (Expr *CurVar : VarList) {
11813 ExprResult VarRef = VisitVar(CurVar);
11814
11815 if (VarRef.isUsable())
11816 InstantiatedVarList.push_back(VarRef.get());
11817 }
11818
11819 return InstantiatedVarList;
11820 }
11821
11822public:
11823 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11824 ArrayRef<const OpenACCClause *> ExistingClauses,
11825 SemaOpenACC::OpenACCParsedClause &PC)
11826 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
11827
11828 OpenACCClause *CreatedClause() const { return NewClause; }
11829
11830#define VISIT_CLAUSE(CLAUSE_NAME) \
11831 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11832#include "clang/Basic/OpenACCClauses.def"
11833};
11834
11835template <typename Derived>
11836void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11837 const OpenACCDefaultClause &C) {
11838 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
11839
11840 NewClause = OpenACCDefaultClause::Create(
11841 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
11842 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11843 ParsedClause.getEndLoc());
11844}
11845
11846template <typename Derived>
11847void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
11848 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11849 assert(Cond && "If constructed with invalid Condition");
11850 Sema::ConditionResult Res = Self.TransformCondition(
11851 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
11852
11853 if (Res.isInvalid() || !Res.get().second)
11854 return;
11855
11856 ParsedClause.setConditionDetails(Res.get().second);
11857
11858 NewClause = OpenACCIfClause::Create(
11859 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11860 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11861 ParsedClause.getEndLoc());
11862}
11863
11864template <typename Derived>
11865void OpenACCClauseTransform<Derived>::VisitSelfClause(
11866 const OpenACCSelfClause &C) {
11867
11868 // If this is an 'update' 'self' clause, this is actually a var list instead.
11869 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
11870 llvm::SmallVector<Expr *> InstantiatedVarList;
11871 for (Expr *CurVar : C.getVarList()) {
11872 ExprResult Res = Self.TransformExpr(CurVar);
11873
11874 if (!Res.isUsable())
11875 continue;
11876
11877 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11878 ParsedClause.getClauseKind(),
11879 Res.get());
11880
11881 if (Res.isUsable())
11882 InstantiatedVarList.push_back(Res.get());
11883 }
11884
11885 ParsedClause.setVarListDetails(InstantiatedVarList,
11887
11888 NewClause = OpenACCSelfClause::Create(
11889 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11890 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11891 ParsedClause.getEndLoc());
11892 } else {
11893
11894 if (C.hasConditionExpr()) {
11895 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11897 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
11899
11900 if (Res.isInvalid() || !Res.get().second)
11901 return;
11902
11903 ParsedClause.setConditionDetails(Res.get().second);
11904 }
11905
11906 NewClause = OpenACCSelfClause::Create(
11907 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11908 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11909 ParsedClause.getEndLoc());
11910 }
11911}
11912
11913template <typename Derived>
11914void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
11915 const OpenACCNumGangsClause &C) {
11916 llvm::SmallVector<Expr *> InstantiatedIntExprs;
11917
11918 for (Expr *CurIntExpr : C.getIntExprs()) {
11919 ExprResult Res = Self.TransformExpr(CurIntExpr);
11920
11921 if (!Res.isUsable())
11922 return;
11923
11924 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
11925 C.getClauseKind(),
11926 C.getBeginLoc(), Res.get());
11927 if (!Res.isUsable())
11928 return;
11929
11930 InstantiatedIntExprs.push_back(Res.get());
11931 }
11932
11933 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
11935 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11936 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
11937 ParsedClause.getEndLoc());
11938}
11939
11940template <typename Derived>
11941void OpenACCClauseTransform<Derived>::VisitPrivateClause(
11942 const OpenACCPrivateClause &C) {
11943 llvm::SmallVector<Expr *> InstantiatedVarList;
11945
11946 for (const auto [RefExpr, InitRecipe] :
11947 llvm::zip(C.getVarList(), C.getInitRecipes())) {
11948 ExprResult VarRef = VisitVar(RefExpr);
11949
11950 if (VarRef.isUsable()) {
11951 InstantiatedVarList.push_back(VarRef.get());
11952
11953 // We only have to create a new one if it is dependent, and Sema won't
11954 // make one of these unless the type is non-dependent.
11955 if (InitRecipe.isSet())
11956 InitRecipes.push_back(InitRecipe);
11957 else
11958 InitRecipes.push_back(
11959 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
11960 }
11961 }
11962 ParsedClause.setVarListDetails(InstantiatedVarList,
11964
11965 NewClause = OpenACCPrivateClause::Create(
11966 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11967 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
11968 ParsedClause.getEndLoc());
11969}
11970
11971template <typename Derived>
11972void OpenACCClauseTransform<Derived>::VisitHostClause(
11973 const OpenACCHostClause &C) {
11974 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11976
11977 NewClause = OpenACCHostClause::Create(
11978 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11979 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11980 ParsedClause.getEndLoc());
11981}
11982
11983template <typename Derived>
11984void OpenACCClauseTransform<Derived>::VisitDeviceClause(
11985 const OpenACCDeviceClause &C) {
11986 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11988
11989 NewClause = OpenACCDeviceClause::Create(
11990 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11991 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11992 ParsedClause.getEndLoc());
11993}
11994
11995template <typename Derived>
11996void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
11998 llvm::SmallVector<Expr *> InstantiatedVarList;
12000
12001 for (const auto [RefExpr, InitRecipe] :
12002 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12003 ExprResult VarRef = VisitVar(RefExpr);
12004
12005 if (VarRef.isUsable()) {
12006 InstantiatedVarList.push_back(VarRef.get());
12007
12008 // We only have to create a new one if it is dependent, and Sema won't
12009 // make one of these unless the type is non-dependent.
12010 if (InitRecipe.isSet())
12011 InitRecipes.push_back(InitRecipe);
12012 else
12013 InitRecipes.push_back(
12014 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12015 VarRef.get()));
12016 }
12017 }
12018 ParsedClause.setVarListDetails(InstantiatedVarList,
12020
12022 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12023 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12024 ParsedClause.getEndLoc());
12025}
12026
12027template <typename Derived>
12028void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12029 const OpenACCNoCreateClause &C) {
12030 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12032
12034 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12035 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12036 ParsedClause.getEndLoc());
12037}
12038
12039template <typename Derived>
12040void OpenACCClauseTransform<Derived>::VisitPresentClause(
12041 const OpenACCPresentClause &C) {
12042 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12044
12045 NewClause = OpenACCPresentClause::Create(
12046 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12047 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12048 ParsedClause.getEndLoc());
12049}
12050
12051template <typename Derived>
12052void OpenACCClauseTransform<Derived>::VisitCopyClause(
12053 const OpenACCCopyClause &C) {
12054 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12055 C.getModifierList());
12056
12057 NewClause = OpenACCCopyClause::Create(
12058 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12059 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12060 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12061 ParsedClause.getEndLoc());
12062}
12063
12064template <typename Derived>
12065void OpenACCClauseTransform<Derived>::VisitLinkClause(
12066 const OpenACCLinkClause &C) {
12067 llvm_unreachable("link clause not valid unless a decl transform");
12068}
12069
12070template <typename Derived>
12071void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12073 llvm_unreachable("device_resident clause not valid unless a decl transform");
12074}
12075template <typename Derived>
12076void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12077 const OpenACCNoHostClause &C) {
12078 llvm_unreachable("nohost clause not valid unless a decl transform");
12079}
12080template <typename Derived>
12081void OpenACCClauseTransform<Derived>::VisitBindClause(
12082 const OpenACCBindClause &C) {
12083 llvm_unreachable("bind clause not valid unless a decl transform");
12084}
12085
12086template <typename Derived>
12087void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12088 const OpenACCCopyInClause &C) {
12089 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12090 C.getModifierList());
12091
12092 NewClause = OpenACCCopyInClause::Create(
12093 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12094 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12095 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12096 ParsedClause.getEndLoc());
12097}
12098
12099template <typename Derived>
12100void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12101 const OpenACCCopyOutClause &C) {
12102 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12103 C.getModifierList());
12104
12105 NewClause = OpenACCCopyOutClause::Create(
12106 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12107 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12108 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12109 ParsedClause.getEndLoc());
12110}
12111
12112template <typename Derived>
12113void OpenACCClauseTransform<Derived>::VisitCreateClause(
12114 const OpenACCCreateClause &C) {
12115 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12116 C.getModifierList());
12117
12118 NewClause = OpenACCCreateClause::Create(
12119 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12120 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12121 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12122 ParsedClause.getEndLoc());
12123}
12124template <typename Derived>
12125void OpenACCClauseTransform<Derived>::VisitAttachClause(
12126 const OpenACCAttachClause &C) {
12127 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12128
12129 // Ensure each var is a pointer type.
12130 llvm::erase_if(VarList, [&](Expr *E) {
12131 return Self.getSema().OpenACC().CheckVarIsPointerType(
12133 });
12134
12135 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12136 NewClause = OpenACCAttachClause::Create(
12137 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12138 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12139 ParsedClause.getEndLoc());
12140}
12141
12142template <typename Derived>
12143void OpenACCClauseTransform<Derived>::VisitDetachClause(
12144 const OpenACCDetachClause &C) {
12145 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12146
12147 // Ensure each var is a pointer type.
12148 llvm::erase_if(VarList, [&](Expr *E) {
12149 return Self.getSema().OpenACC().CheckVarIsPointerType(
12151 });
12152
12153 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12154 NewClause = OpenACCDetachClause::Create(
12155 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12156 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12157 ParsedClause.getEndLoc());
12158}
12159
12160template <typename Derived>
12161void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12162 const OpenACCDeleteClause &C) {
12163 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12165 NewClause = OpenACCDeleteClause::Create(
12166 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12167 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12168 ParsedClause.getEndLoc());
12169}
12170
12171template <typename Derived>
12172void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12173 const OpenACCUseDeviceClause &C) {
12174 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12177 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12178 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12179 ParsedClause.getEndLoc());
12180}
12181
12182template <typename Derived>
12183void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12184 const OpenACCDevicePtrClause &C) {
12185 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12186
12187 // Ensure each var is a pointer type.
12188 llvm::erase_if(VarList, [&](Expr *E) {
12189 return Self.getSema().OpenACC().CheckVarIsPointerType(
12191 });
12192
12193 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12195 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12196 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12197 ParsedClause.getEndLoc());
12198}
12199
12200template <typename Derived>
12201void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12202 const OpenACCNumWorkersClause &C) {
12203 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12204 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12205
12206 ExprResult Res = Self.TransformExpr(IntExpr);
12207 if (!Res.isUsable())
12208 return;
12209
12210 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12211 C.getClauseKind(),
12212 C.getBeginLoc(), Res.get());
12213 if (!Res.isUsable())
12214 return;
12215
12216 ParsedClause.setIntExprDetails(Res.get());
12218 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12219 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12220 ParsedClause.getEndLoc());
12221}
12222
12223template <typename Derived>
12224void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12225 const OpenACCDeviceNumClause &C) {
12226 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12227 assert(IntExpr && "device_num clause constructed with invalid int expr");
12228
12229 ExprResult Res = Self.TransformExpr(IntExpr);
12230 if (!Res.isUsable())
12231 return;
12232
12233 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12234 C.getClauseKind(),
12235 C.getBeginLoc(), Res.get());
12236 if (!Res.isUsable())
12237 return;
12238
12239 ParsedClause.setIntExprDetails(Res.get());
12241 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12242 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12243 ParsedClause.getEndLoc());
12244}
12245
12246template <typename Derived>
12247void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12249 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12250 assert(IntExpr && "default_async clause constructed with invalid int expr");
12251
12252 ExprResult Res = Self.TransformExpr(IntExpr);
12253 if (!Res.isUsable())
12254 return;
12255
12256 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12257 C.getClauseKind(),
12258 C.getBeginLoc(), Res.get());
12259 if (!Res.isUsable())
12260 return;
12261
12262 ParsedClause.setIntExprDetails(Res.get());
12264 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12265 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12266 ParsedClause.getEndLoc());
12267}
12268
12269template <typename Derived>
12270void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12272 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12273 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12274
12275 ExprResult Res = Self.TransformExpr(IntExpr);
12276 if (!Res.isUsable())
12277 return;
12278
12279 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12280 C.getClauseKind(),
12281 C.getBeginLoc(), Res.get());
12282 if (!Res.isUsable())
12283 return;
12284
12285 ParsedClause.setIntExprDetails(Res.get());
12287 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12288 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12289 ParsedClause.getEndLoc());
12290}
12291
12292template <typename Derived>
12293void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12294 const OpenACCAsyncClause &C) {
12295 if (C.hasIntExpr()) {
12296 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12297 if (!Res.isUsable())
12298 return;
12299
12300 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12301 C.getClauseKind(),
12302 C.getBeginLoc(), Res.get());
12303 if (!Res.isUsable())
12304 return;
12305 ParsedClause.setIntExprDetails(Res.get());
12306 }
12307
12308 NewClause = OpenACCAsyncClause::Create(
12309 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12310 ParsedClause.getLParenLoc(),
12311 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12312 : nullptr,
12313 ParsedClause.getEndLoc());
12314}
12315
12316template <typename Derived>
12317void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12318 const OpenACCWorkerClause &C) {
12319 if (C.hasIntExpr()) {
12320 // restrictions on this expression are all "does it exist in certain
12321 // situations" that are not possible to be dependent, so the only check we
12322 // have is that it transforms, and is an int expression.
12323 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12324 if (!Res.isUsable())
12325 return;
12326
12327 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12328 C.getClauseKind(),
12329 C.getBeginLoc(), Res.get());
12330 if (!Res.isUsable())
12331 return;
12332 ParsedClause.setIntExprDetails(Res.get());
12333 }
12334
12335 NewClause = OpenACCWorkerClause::Create(
12336 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12337 ParsedClause.getLParenLoc(),
12338 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12339 : nullptr,
12340 ParsedClause.getEndLoc());
12341}
12342
12343template <typename Derived>
12344void OpenACCClauseTransform<Derived>::VisitVectorClause(
12345 const OpenACCVectorClause &C) {
12346 if (C.hasIntExpr()) {
12347 // restrictions on this expression are all "does it exist in certain
12348 // situations" that are not possible to be dependent, so the only check we
12349 // have is that it transforms, and is an int expression.
12350 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12351 if (!Res.isUsable())
12352 return;
12353
12354 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12355 C.getClauseKind(),
12356 C.getBeginLoc(), Res.get());
12357 if (!Res.isUsable())
12358 return;
12359 ParsedClause.setIntExprDetails(Res.get());
12360 }
12361
12362 NewClause = OpenACCVectorClause::Create(
12363 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12364 ParsedClause.getLParenLoc(),
12365 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12366 : nullptr,
12367 ParsedClause.getEndLoc());
12368}
12369
12370template <typename Derived>
12371void OpenACCClauseTransform<Derived>::VisitWaitClause(
12372 const OpenACCWaitClause &C) {
12373 if (C.hasExprs()) {
12374 Expr *DevNumExpr = nullptr;
12375 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12376
12377 // Instantiate devnum expr if it exists.
12378 if (C.getDevNumExpr()) {
12379 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12380 if (!Res.isUsable())
12381 return;
12382 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12383 C.getClauseKind(),
12384 C.getBeginLoc(), Res.get());
12385 if (!Res.isUsable())
12386 return;
12387
12388 DevNumExpr = Res.get();
12389 }
12390
12391 // Instantiate queue ids.
12392 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12393 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12394 if (!Res.isUsable())
12395 return;
12396 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12397 C.getClauseKind(),
12398 C.getBeginLoc(), Res.get());
12399 if (!Res.isUsable())
12400 return;
12401
12402 InstantiatedQueueIdExprs.push_back(Res.get());
12403 }
12404
12405 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12406 std::move(InstantiatedQueueIdExprs));
12407 }
12408
12409 NewClause = OpenACCWaitClause::Create(
12410 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12411 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12412 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12413 ParsedClause.getEndLoc());
12414}
12415
12416template <typename Derived>
12417void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12418 const OpenACCDeviceTypeClause &C) {
12419 // Nothing to transform here, just create a new version of 'C'.
12421 Self.getSema().getASTContext(), C.getClauseKind(),
12422 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12423 C.getArchitectures(), ParsedClause.getEndLoc());
12424}
12425
12426template <typename Derived>
12427void OpenACCClauseTransform<Derived>::VisitAutoClause(
12428 const OpenACCAutoClause &C) {
12429 // Nothing to do, so just create a new node.
12430 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12431 ParsedClause.getBeginLoc(),
12432 ParsedClause.getEndLoc());
12433}
12434
12435template <typename Derived>
12436void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12437 const OpenACCIndependentClause &C) {
12438 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12439 ParsedClause.getBeginLoc(),
12440 ParsedClause.getEndLoc());
12441}
12442
12443template <typename Derived>
12444void OpenACCClauseTransform<Derived>::VisitSeqClause(
12445 const OpenACCSeqClause &C) {
12446 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12447 ParsedClause.getBeginLoc(),
12448 ParsedClause.getEndLoc());
12449}
12450template <typename Derived>
12451void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12452 const OpenACCFinalizeClause &C) {
12453 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12454 ParsedClause.getBeginLoc(),
12455 ParsedClause.getEndLoc());
12456}
12457
12458template <typename Derived>
12459void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12460 const OpenACCIfPresentClause &C) {
12461 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12462 ParsedClause.getBeginLoc(),
12463 ParsedClause.getEndLoc());
12464}
12465
12466template <typename Derived>
12467void OpenACCClauseTransform<Derived>::VisitReductionClause(
12468 const OpenACCReductionClause &C) {
12469 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12470 SmallVector<Expr *> ValidVars;
12472
12473 for (const auto [Var, OrigRecipe] :
12474 llvm::zip(TransformedVars, C.getRecipes())) {
12475 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12476 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12477 if (Res.isUsable()) {
12478 ValidVars.push_back(Res.get());
12479
12480 if (OrigRecipe.isSet())
12481 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
12482 else
12483 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
12484 C.getReductionOp(), Res.get()));
12485 }
12486 }
12487
12488 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12489 ExistingClauses, ParsedClause.getDirectiveKind(),
12490 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12491 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
12492}
12493
12494template <typename Derived>
12495void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12496 const OpenACCCollapseClause &C) {
12497 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12498 assert(LoopCount && "collapse clause constructed with invalid loop count");
12499
12500 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12501
12502 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12503 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12504 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12505
12506 NewLoopCount =
12507 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12508
12509 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12511 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12512 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12513 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12514}
12515
12516template <typename Derived>
12517void OpenACCClauseTransform<Derived>::VisitTileClause(
12518 const OpenACCTileClause &C) {
12519
12520 llvm::SmallVector<Expr *> TransformedExprs;
12521
12522 for (Expr *E : C.getSizeExprs()) {
12523 ExprResult NewSizeExpr = Self.TransformExpr(E);
12524
12525 if (!NewSizeExpr.isUsable())
12526 return;
12527
12528 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12529 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12530 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12531
12532 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12533
12534 if (!NewSizeExpr.isUsable())
12535 return;
12536 TransformedExprs.push_back(NewSizeExpr.get());
12537 }
12538
12539 ParsedClause.setIntExprDetails(TransformedExprs);
12540 NewClause = OpenACCTileClause::Create(
12541 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12542 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12543 ParsedClause.getEndLoc());
12544}
12545template <typename Derived>
12546void OpenACCClauseTransform<Derived>::VisitGangClause(
12547 const OpenACCGangClause &C) {
12548 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12549 llvm::SmallVector<Expr *> TransformedIntExprs;
12550
12551 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12552 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12553 if (!ER.isUsable())
12554 continue;
12555
12556 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12557 ParsedClause.getDirectiveKind(),
12558 C.getExpr(I).first, ER.get());
12559 if (!ER.isUsable())
12560 continue;
12561 TransformedGangKinds.push_back(C.getExpr(I).first);
12562 TransformedIntExprs.push_back(ER.get());
12563 }
12564
12565 NewClause = Self.getSema().OpenACC().CheckGangClause(
12566 ParsedClause.getDirectiveKind(), ExistingClauses,
12567 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12568 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12569}
12570} // namespace
12571template <typename Derived>
12572OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12573 ArrayRef<const OpenACCClause *> ExistingClauses,
12574 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12575
12577 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12578 ParsedClause.setEndLoc(OldClause->getEndLoc());
12579
12580 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12581 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12582
12583 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12584 ParsedClause};
12585 Transform.Visit(OldClause);
12586
12587 return Transform.CreatedClause();
12588}
12589
12590template <typename Derived>
12592TreeTransform<Derived>::TransformOpenACCClauseList(
12594 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12595 for (const auto *Clause : OldClauses) {
12596 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12597 TransformedClauses, DirKind, Clause))
12598 TransformedClauses.push_back(TransformedClause);
12599 }
12600 return TransformedClauses;
12601}
12602
12603template <typename Derived>
12606 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12607
12608 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12609 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12610 C->clauses());
12611
12612 if (getSema().OpenACC().ActOnStartStmtDirective(
12613 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12614 return StmtError();
12615
12616 // Transform Structured Block.
12617 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12618 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12619 C->clauses(), TransformedClauses);
12620 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12621 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12622 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12623
12624 return getDerived().RebuildOpenACCComputeConstruct(
12625 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12626 C->getEndLoc(), TransformedClauses, StrBlock);
12627}
12628
12629template <typename Derived>
12632
12633 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12634
12635 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12636 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12637 C->clauses());
12638
12639 if (getSema().OpenACC().ActOnStartStmtDirective(
12640 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12641 return StmtError();
12642
12643 // Transform Loop.
12644 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12645 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12646 C->clauses(), TransformedClauses);
12647 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12648 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12649 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12650
12651 return getDerived().RebuildOpenACCLoopConstruct(
12652 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12653 TransformedClauses, Loop);
12654}
12655
12656template <typename Derived>
12658 OpenACCCombinedConstruct *C) {
12659 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12660
12661 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12662 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12663 C->clauses());
12664
12665 if (getSema().OpenACC().ActOnStartStmtDirective(
12666 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12667 return StmtError();
12668
12669 // Transform Loop.
12670 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12671 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12672 C->clauses(), TransformedClauses);
12673 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12674 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12675 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12676
12677 return getDerived().RebuildOpenACCCombinedConstruct(
12678 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12679 C->getEndLoc(), TransformedClauses, Loop);
12680}
12681
12682template <typename Derived>
12685 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12686
12687 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12688 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12689 C->clauses());
12690 if (getSema().OpenACC().ActOnStartStmtDirective(
12691 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12692 return StmtError();
12693
12694 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12695 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12696 C->clauses(), TransformedClauses);
12697 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12698 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12699 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12700
12701 return getDerived().RebuildOpenACCDataConstruct(
12702 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12703 TransformedClauses, StrBlock);
12704}
12705
12706template <typename Derived>
12708 OpenACCEnterDataConstruct *C) {
12709 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12710
12711 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12712 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12713 C->clauses());
12714 if (getSema().OpenACC().ActOnStartStmtDirective(
12715 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12716 return StmtError();
12717
12718 return getDerived().RebuildOpenACCEnterDataConstruct(
12719 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12720 TransformedClauses);
12721}
12722
12723template <typename Derived>
12725 OpenACCExitDataConstruct *C) {
12726 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12727
12728 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12729 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12730 C->clauses());
12731 if (getSema().OpenACC().ActOnStartStmtDirective(
12732 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12733 return StmtError();
12734
12735 return getDerived().RebuildOpenACCExitDataConstruct(
12736 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12737 TransformedClauses);
12738}
12739
12740template <typename Derived>
12742 OpenACCHostDataConstruct *C) {
12743 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12744
12745 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12746 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12747 C->clauses());
12748 if (getSema().OpenACC().ActOnStartStmtDirective(
12749 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12750 return StmtError();
12751
12752 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12753 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12754 C->clauses(), TransformedClauses);
12755 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12756 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12757 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12758
12759 return getDerived().RebuildOpenACCHostDataConstruct(
12760 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12761 TransformedClauses, StrBlock);
12762}
12763
12764template <typename Derived>
12767 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12768
12769 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12770 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12771 C->clauses());
12772 if (getSema().OpenACC().ActOnStartStmtDirective(
12773 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12774 return StmtError();
12775
12776 return getDerived().RebuildOpenACCInitConstruct(
12777 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12778 TransformedClauses);
12779}
12780
12781template <typename Derived>
12783 OpenACCShutdownConstruct *C) {
12784 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12785
12786 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12787 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12788 C->clauses());
12789 if (getSema().OpenACC().ActOnStartStmtDirective(
12790 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12791 return StmtError();
12792
12793 return getDerived().RebuildOpenACCShutdownConstruct(
12794 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12795 TransformedClauses);
12796}
12797template <typename Derived>
12800 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12801
12802 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12803 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12804 C->clauses());
12805 if (getSema().OpenACC().ActOnStartStmtDirective(
12806 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12807 return StmtError();
12808
12809 return getDerived().RebuildOpenACCSetConstruct(
12810 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12811 TransformedClauses);
12812}
12813
12814template <typename Derived>
12816 OpenACCUpdateConstruct *C) {
12817 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12818
12819 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12820 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12821 C->clauses());
12822 if (getSema().OpenACC().ActOnStartStmtDirective(
12823 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12824 return StmtError();
12825
12826 return getDerived().RebuildOpenACCUpdateConstruct(
12827 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12828 TransformedClauses);
12829}
12830
12831template <typename Derived>
12834 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12835
12836 ExprResult DevNumExpr;
12837 if (C->hasDevNumExpr()) {
12838 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
12839
12840 if (DevNumExpr.isUsable())
12841 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
12843 C->getBeginLoc(), DevNumExpr.get());
12844 }
12845
12846 llvm::SmallVector<Expr *> QueueIdExprs;
12847
12848 for (Expr *QE : C->getQueueIdExprs()) {
12849 assert(QE && "Null queue id expr?");
12850 ExprResult NewEQ = getDerived().TransformExpr(QE);
12851
12852 if (!NewEQ.isUsable())
12853 break;
12854 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
12856 C->getBeginLoc(), NewEQ.get());
12857 if (NewEQ.isUsable())
12858 QueueIdExprs.push_back(NewEQ.get());
12859 }
12860
12861 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12862 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12863 C->clauses());
12864
12865 if (getSema().OpenACC().ActOnStartStmtDirective(
12866 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12867 return StmtError();
12868
12869 return getDerived().RebuildOpenACCWaitConstruct(
12870 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12871 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
12872 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
12873}
12874template <typename Derived>
12876 OpenACCCacheConstruct *C) {
12877 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12878
12879 llvm::SmallVector<Expr *> TransformedVarList;
12880 for (Expr *Var : C->getVarList()) {
12881 assert(Var && "Null var listexpr?");
12882
12883 ExprResult NewVar = getDerived().TransformExpr(Var);
12884
12885 if (!NewVar.isUsable())
12886 break;
12887
12888 NewVar = getSema().OpenACC().ActOnVar(
12889 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
12890 if (!NewVar.isUsable())
12891 break;
12892
12893 TransformedVarList.push_back(NewVar.get());
12894 }
12895
12896 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
12897 C->getBeginLoc(), {}))
12898 return StmtError();
12899
12900 return getDerived().RebuildOpenACCCacheConstruct(
12901 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12902 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
12903 C->getEndLoc());
12904}
12905
12906template <typename Derived>
12908 OpenACCAtomicConstruct *C) {
12909 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12910
12911 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12912 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12913 C->clauses());
12914
12915 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
12916 C->getBeginLoc(), {}))
12917 return StmtError();
12918
12919 // Transform Associated Stmt.
12920 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12921 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
12922
12923 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
12924 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
12925 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
12926 AssocStmt);
12927
12928 return getDerived().RebuildOpenACCAtomicConstruct(
12929 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
12930 C->getEndLoc(), TransformedClauses, AssocStmt);
12931}
12932
12933template <typename Derived>
12936 if (getDerived().AlwaysRebuild())
12937 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
12938 // Nothing can ever change, so there is never anything to transform.
12939 return E;
12940}
12941
12942//===----------------------------------------------------------------------===//
12943// Expression transformation
12944//===----------------------------------------------------------------------===//
12945template<typename Derived>
12948 return TransformExpr(E->getSubExpr());
12949}
12950
12951template <typename Derived>
12954 if (!E->isTypeDependent())
12955 return E;
12956
12957 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
12958
12959 if (!NewT)
12960 return ExprError();
12961
12962 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
12963 return E;
12964
12965 return getDerived().RebuildSYCLUniqueStableNameExpr(
12966 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
12967}
12968
12969template<typename Derived>
12972 if (!E->isTypeDependent())
12973 return E;
12974
12975 return getDerived().RebuildPredefinedExpr(E->getLocation(),
12976 E->getIdentKind());
12977}
12978
12979template<typename Derived>
12982 NestedNameSpecifierLoc QualifierLoc;
12983 if (E->getQualifierLoc()) {
12984 QualifierLoc
12985 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
12986 if (!QualifierLoc)
12987 return ExprError();
12988 }
12989
12990 ValueDecl *ND
12991 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
12992 E->getDecl()));
12993 if (!ND || ND->isInvalidDecl())
12994 return ExprError();
12995
12996 NamedDecl *Found = ND;
12997 if (E->getFoundDecl() != E->getDecl()) {
12998 Found = cast_or_null<NamedDecl>(
12999 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13000 if (!Found)
13001 return ExprError();
13002 }
13003
13004 DeclarationNameInfo NameInfo = E->getNameInfo();
13005 if (NameInfo.getName()) {
13006 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13007 if (!NameInfo.getName())
13008 return ExprError();
13009 }
13010
13011 if (!getDerived().AlwaysRebuild() &&
13012 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13013 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13014 Found == E->getFoundDecl() &&
13015 NameInfo.getName() == E->getDecl()->getDeclName() &&
13016 !E->hasExplicitTemplateArgs()) {
13017
13018 // Mark it referenced in the new context regardless.
13019 // FIXME: this is a bit instantiation-specific.
13020 SemaRef.MarkDeclRefReferenced(E);
13021
13022 return E;
13023 }
13024
13025 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13026 if (E->hasExplicitTemplateArgs()) {
13027 TemplateArgs = &TransArgs;
13028 TransArgs.setLAngleLoc(E->getLAngleLoc());
13029 TransArgs.setRAngleLoc(E->getRAngleLoc());
13030 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13031 E->getNumTemplateArgs(),
13032 TransArgs))
13033 return ExprError();
13034 }
13035
13036 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13037 Found, TemplateArgs);
13038}
13039
13040template<typename Derived>
13043 return E;
13044}
13045
13046template <typename Derived>
13048 FixedPointLiteral *E) {
13049 return E;
13050}
13051
13052template<typename Derived>
13055 return E;
13056}
13057
13058template<typename Derived>
13061 return E;
13062}
13063
13064template<typename Derived>
13067 return E;
13068}
13069
13070template<typename Derived>
13073 return E;
13074}
13075
13076template<typename Derived>
13079 return getDerived().TransformCallExpr(E);
13080}
13081
13082template<typename Derived>
13085 ExprResult ControllingExpr;
13086 TypeSourceInfo *ControllingType = nullptr;
13087 if (E->isExprPredicate())
13088 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13089 else
13090 ControllingType = getDerived().TransformType(E->getControllingType());
13091
13092 if (ControllingExpr.isInvalid() && !ControllingType)
13093 return ExprError();
13094
13095 SmallVector<Expr *, 4> AssocExprs;
13097 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13098 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13099 if (TSI) {
13100 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13101 if (!AssocType)
13102 return ExprError();
13103 AssocTypes.push_back(AssocType);
13104 } else {
13105 AssocTypes.push_back(nullptr);
13106 }
13107
13108 ExprResult AssocExpr =
13109 getDerived().TransformExpr(Assoc.getAssociationExpr());
13110 if (AssocExpr.isInvalid())
13111 return ExprError();
13112 AssocExprs.push_back(AssocExpr.get());
13113 }
13114
13115 if (!ControllingType)
13116 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13117 E->getDefaultLoc(),
13118 E->getRParenLoc(),
13119 ControllingExpr.get(),
13120 AssocTypes,
13121 AssocExprs);
13122 return getDerived().RebuildGenericSelectionExpr(
13123 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13124 ControllingType, AssocTypes, AssocExprs);
13125}
13126
13127template<typename Derived>
13130 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13131 if (SubExpr.isInvalid())
13132 return ExprError();
13133
13134 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13135 return E;
13136
13137 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13138 E->getRParen());
13139}
13140
13141/// The operand of a unary address-of operator has special rules: it's
13142/// allowed to refer to a non-static member of a class even if there's no 'this'
13143/// object available.
13144template<typename Derived>
13147 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13148 return getDerived().TransformDependentScopeDeclRefExpr(
13149 DRE, /*IsAddressOfOperand=*/true, nullptr);
13150 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13151 return getDerived().TransformUnresolvedLookupExpr(
13152 ULE, /*IsAddressOfOperand=*/true);
13153 else
13154 return getDerived().TransformExpr(E);
13155}
13156
13157template<typename Derived>
13160 ExprResult SubExpr;
13161 if (E->getOpcode() == UO_AddrOf)
13162 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13163 else
13164 SubExpr = TransformExpr(E->getSubExpr());
13165 if (SubExpr.isInvalid())
13166 return ExprError();
13167
13168 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13169 return E;
13170
13171 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13172 E->getOpcode(),
13173 SubExpr.get());
13174}
13175
13176template<typename Derived>
13178TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13179 // Transform the type.
13180 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13181 if (!Type)
13182 return ExprError();
13183
13184 // Transform all of the components into components similar to what the
13185 // parser uses.
13186 // FIXME: It would be slightly more efficient in the non-dependent case to
13187 // just map FieldDecls, rather than requiring the rebuilder to look for
13188 // the fields again. However, __builtin_offsetof is rare enough in
13189 // template code that we don't care.
13190 bool ExprChanged = false;
13191 typedef Sema::OffsetOfComponent Component;
13192 SmallVector<Component, 4> Components;
13193 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13194 const OffsetOfNode &ON = E->getComponent(I);
13195 Component Comp;
13196 Comp.isBrackets = true;
13197 Comp.LocStart = ON.getSourceRange().getBegin();
13198 Comp.LocEnd = ON.getSourceRange().getEnd();
13199 switch (ON.getKind()) {
13200 case OffsetOfNode::Array: {
13201 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13202 ExprResult Index = getDerived().TransformExpr(FromIndex);
13203 if (Index.isInvalid())
13204 return ExprError();
13205
13206 ExprChanged = ExprChanged || Index.get() != FromIndex;
13207 Comp.isBrackets = true;
13208 Comp.U.E = Index.get();
13209 break;
13210 }
13211
13214 Comp.isBrackets = false;
13215 Comp.U.IdentInfo = ON.getFieldName();
13216 if (!Comp.U.IdentInfo)
13217 continue;
13218
13219 break;
13220
13221 case OffsetOfNode::Base:
13222 // Will be recomputed during the rebuild.
13223 continue;
13224 }
13225
13226 Components.push_back(Comp);
13227 }
13228
13229 // If nothing changed, retain the existing expression.
13230 if (!getDerived().AlwaysRebuild() &&
13231 Type == E->getTypeSourceInfo() &&
13232 !ExprChanged)
13233 return E;
13234
13235 // Build a new offsetof expression.
13236 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13237 Components, E->getRParenLoc());
13238}
13239
13240template<typename Derived>
13243 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13244 "opaque value expression requires transformation");
13245 return E;
13246}
13247
13248template <typename Derived>
13251 bool Changed = false;
13252 for (Expr *C : E->subExpressions()) {
13253 ExprResult NewC = getDerived().TransformExpr(C);
13254 if (NewC.isInvalid())
13255 return ExprError();
13256 Children.push_back(NewC.get());
13257
13258 Changed |= NewC.get() != C;
13259 }
13260 if (!getDerived().AlwaysRebuild() && !Changed)
13261 return E;
13262 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13263 Children, E->getType());
13264}
13265
13266template<typename Derived>
13269 // Rebuild the syntactic form. The original syntactic form has
13270 // opaque-value expressions in it, so strip those away and rebuild
13271 // the result. This is a really awful way of doing this, but the
13272 // better solution (rebuilding the semantic expressions and
13273 // rebinding OVEs as necessary) doesn't work; we'd need
13274 // TreeTransform to not strip away implicit conversions.
13275 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13276 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13277 if (result.isInvalid()) return ExprError();
13278
13279 // If that gives us a pseudo-object result back, the pseudo-object
13280 // expression must have been an lvalue-to-rvalue conversion which we
13281 // should reapply.
13282 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13283 result = SemaRef.PseudoObject().checkRValue(result.get());
13284
13285 return result;
13286}
13287
13288template<typename Derived>
13292 if (E->isArgumentType()) {
13293 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13294
13295 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13296 if (!NewT)
13297 return ExprError();
13298
13299 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13300 return E;
13301
13302 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13303 E->getKind(),
13304 E->getSourceRange());
13305 }
13306
13307 // C++0x [expr.sizeof]p1:
13308 // The operand is either an expression, which is an unevaluated operand
13309 // [...]
13313
13314 // Try to recover if we have something like sizeof(T::X) where X is a type.
13315 // Notably, there must be *exactly* one set of parens if X is a type.
13316 TypeSourceInfo *RecoveryTSI = nullptr;
13317 ExprResult SubExpr;
13318 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13319 if (auto *DRE =
13320 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13321 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13322 PE, DRE, false, &RecoveryTSI);
13323 else
13324 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13325
13326 if (RecoveryTSI) {
13327 return getDerived().RebuildUnaryExprOrTypeTrait(
13328 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13329 } else if (SubExpr.isInvalid())
13330 return ExprError();
13331
13332 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13333 return E;
13334
13335 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13336 E->getOperatorLoc(),
13337 E->getKind(),
13338 E->getSourceRange());
13339}
13340
13341template<typename Derived>
13344 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13345 if (LHS.isInvalid())
13346 return ExprError();
13347
13348 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13349 if (RHS.isInvalid())
13350 return ExprError();
13351
13352
13353 if (!getDerived().AlwaysRebuild() &&
13354 LHS.get() == E->getLHS() &&
13355 RHS.get() == E->getRHS())
13356 return E;
13357
13358 return getDerived().RebuildArraySubscriptExpr(
13359 LHS.get(),
13360 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13361}
13362
13363template <typename Derived>
13366 ExprResult Base = getDerived().TransformExpr(E->getBase());
13367 if (Base.isInvalid())
13368 return ExprError();
13369
13370 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13371 if (RowIdx.isInvalid())
13372 return ExprError();
13373
13374 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13375 if (ColumnIdx.isInvalid())
13376 return ExprError();
13377
13378 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13379 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13380 return E;
13381
13382 return getDerived().RebuildMatrixSubscriptExpr(
13383 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13384}
13385
13386template <typename Derived>
13389 ExprResult Base = getDerived().TransformExpr(E->getBase());
13390 if (Base.isInvalid())
13391 return ExprError();
13392
13393 ExprResult LowerBound;
13394 if (E->getLowerBound()) {
13395 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13396 if (LowerBound.isInvalid())
13397 return ExprError();
13398 }
13399
13400 ExprResult Length;
13401 if (E->getLength()) {
13402 Length = getDerived().TransformExpr(E->getLength());
13403 if (Length.isInvalid())
13404 return ExprError();
13405 }
13406
13407 ExprResult Stride;
13408 if (E->isOMPArraySection()) {
13409 if (Expr *Str = E->getStride()) {
13410 Stride = getDerived().TransformExpr(Str);
13411 if (Stride.isInvalid())
13412 return ExprError();
13413 }
13414 }
13415
13416 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13417 LowerBound.get() == E->getLowerBound() &&
13418 Length.get() == E->getLength() &&
13419 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13420 return E;
13421
13422 return getDerived().RebuildArraySectionExpr(
13423 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13424 LowerBound.get(), E->getColonLocFirst(),
13425 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13426 Length.get(), Stride.get(), E->getRBracketLoc());
13427}
13428
13429template <typename Derived>
13432 ExprResult Base = getDerived().TransformExpr(E->getBase());
13433 if (Base.isInvalid())
13434 return ExprError();
13435
13437 bool ErrorFound = false;
13438 for (Expr *Dim : E->getDimensions()) {
13439 ExprResult DimRes = getDerived().TransformExpr(Dim);
13440 if (DimRes.isInvalid()) {
13441 ErrorFound = true;
13442 continue;
13443 }
13444 Dims.push_back(DimRes.get());
13445 }
13446
13447 if (ErrorFound)
13448 return ExprError();
13449 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13450 E->getRParenLoc(), Dims,
13451 E->getBracketsRanges());
13452}
13453
13454template <typename Derived>
13457 unsigned NumIterators = E->numOfIterators();
13459
13460 bool ErrorFound = false;
13461 bool NeedToRebuild = getDerived().AlwaysRebuild();
13462 for (unsigned I = 0; I < NumIterators; ++I) {
13463 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13464 Data[I].DeclIdent = D->getIdentifier();
13465 Data[I].DeclIdentLoc = D->getLocation();
13466 if (D->getLocation() == D->getBeginLoc()) {
13467 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13468 "Implicit type must be int.");
13469 } else {
13470 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13471 QualType DeclTy = getDerived().TransformType(D->getType());
13472 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13473 }
13474 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13475 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13476 ExprResult End = getDerived().TransformExpr(Range.End);
13477 ExprResult Step = getDerived().TransformExpr(Range.Step);
13478 ErrorFound = ErrorFound ||
13479 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13480 !Data[I].Type.get().isNull())) ||
13481 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13482 if (ErrorFound)
13483 continue;
13484 Data[I].Range.Begin = Begin.get();
13485 Data[I].Range.End = End.get();
13486 Data[I].Range.Step = Step.get();
13487 Data[I].AssignLoc = E->getAssignLoc(I);
13488 Data[I].ColonLoc = E->getColonLoc(I);
13489 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13490 NeedToRebuild =
13491 NeedToRebuild ||
13492 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13493 D->getType().getTypePtrOrNull()) ||
13494 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13495 Range.Step != Data[I].Range.Step;
13496 }
13497 if (ErrorFound)
13498 return ExprError();
13499 if (!NeedToRebuild)
13500 return E;
13501
13502 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13503 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13504 if (!Res.isUsable())
13505 return Res;
13506 auto *IE = cast<OMPIteratorExpr>(Res.get());
13507 for (unsigned I = 0; I < NumIterators; ++I)
13508 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13509 IE->getIteratorDecl(I));
13510 return Res;
13511}
13512
13513template<typename Derived>
13516 // Transform the callee.
13517 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13518 if (Callee.isInvalid())
13519 return ExprError();
13520
13521 // Transform arguments.
13522 bool ArgChanged = false;
13524 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13525 &ArgChanged))
13526 return ExprError();
13527
13528 if (!getDerived().AlwaysRebuild() &&
13529 Callee.get() == E->getCallee() &&
13530 !ArgChanged)
13531 return SemaRef.MaybeBindToTemporary(E);
13532
13533 // FIXME: Wrong source location information for the '('.
13534 SourceLocation FakeLParenLoc
13535 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13536
13537 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13538 if (E->hasStoredFPFeatures()) {
13539 FPOptionsOverride NewOverrides = E->getFPFeatures();
13540 getSema().CurFPFeatures =
13541 NewOverrides.applyOverrides(getSema().getLangOpts());
13542 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13543 }
13544
13545 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13546 Args,
13547 E->getRParenLoc());
13548}
13549
13550template<typename Derived>
13553 ExprResult Base = getDerived().TransformExpr(E->getBase());
13554 if (Base.isInvalid())
13555 return ExprError();
13556
13557 NestedNameSpecifierLoc QualifierLoc;
13558 if (E->hasQualifier()) {
13559 QualifierLoc
13560 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13561
13562 if (!QualifierLoc)
13563 return ExprError();
13564 }
13565 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13566
13568 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13569 E->getMemberDecl()));
13570 if (!Member)
13571 return ExprError();
13572
13573 NamedDecl *FoundDecl = E->getFoundDecl();
13574 if (FoundDecl == E->getMemberDecl()) {
13575 FoundDecl = Member;
13576 } else {
13577 FoundDecl = cast_or_null<NamedDecl>(
13578 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13579 if (!FoundDecl)
13580 return ExprError();
13581 }
13582
13583 if (!getDerived().AlwaysRebuild() &&
13584 Base.get() == E->getBase() &&
13585 QualifierLoc == E->getQualifierLoc() &&
13586 Member == E->getMemberDecl() &&
13587 FoundDecl == E->getFoundDecl() &&
13588 !E->hasExplicitTemplateArgs()) {
13589
13590 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13591 // for Openmp where the field need to be privatizized in the case.
13592 if (!(isa<CXXThisExpr>(E->getBase()) &&
13593 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13595 // Mark it referenced in the new context regardless.
13596 // FIXME: this is a bit instantiation-specific.
13597 SemaRef.MarkMemberReferenced(E);
13598 return E;
13599 }
13600 }
13601
13602 TemplateArgumentListInfo TransArgs;
13603 if (E->hasExplicitTemplateArgs()) {
13604 TransArgs.setLAngleLoc(E->getLAngleLoc());
13605 TransArgs.setRAngleLoc(E->getRAngleLoc());
13606 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13607 E->getNumTemplateArgs(),
13608 TransArgs))
13609 return ExprError();
13610 }
13611
13612 // FIXME: Bogus source location for the operator
13613 SourceLocation FakeOperatorLoc =
13614 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13615
13616 // FIXME: to do this check properly, we will need to preserve the
13617 // first-qualifier-in-scope here, just in case we had a dependent
13618 // base (and therefore couldn't do the check) and a
13619 // nested-name-qualifier (and therefore could do the lookup).
13620 NamedDecl *FirstQualifierInScope = nullptr;
13621 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13622 if (MemberNameInfo.getName()) {
13623 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13624 if (!MemberNameInfo.getName())
13625 return ExprError();
13626 }
13627
13628 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13629 E->isArrow(),
13630 QualifierLoc,
13631 TemplateKWLoc,
13632 MemberNameInfo,
13633 Member,
13634 FoundDecl,
13635 (E->hasExplicitTemplateArgs()
13636 ? &TransArgs : nullptr),
13637 FirstQualifierInScope);
13638}
13639
13640template<typename Derived>
13643 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13644 if (LHS.isInvalid())
13645 return ExprError();
13646
13647 ExprResult RHS =
13648 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13649 if (RHS.isInvalid())
13650 return ExprError();
13651
13652 if (!getDerived().AlwaysRebuild() &&
13653 LHS.get() == E->getLHS() &&
13654 RHS.get() == E->getRHS())
13655 return E;
13656
13657 if (E->isCompoundAssignmentOp())
13658 // FPFeatures has already been established from trailing storage
13659 return getDerived().RebuildBinaryOperator(
13660 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13661 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13662 FPOptionsOverride NewOverrides(E->getFPFeatures());
13663 getSema().CurFPFeatures =
13664 NewOverrides.applyOverrides(getSema().getLangOpts());
13665 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13666 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13667 LHS.get(), RHS.get());
13668}
13669
13670template <typename Derived>
13673 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13674
13675 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13676 if (LHS.isInvalid())
13677 return ExprError();
13678
13679 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13680 if (RHS.isInvalid())
13681 return ExprError();
13682
13683 // Extract the already-resolved callee declarations so that we can restrict
13684 // ourselves to using them as the unqualified lookup results when rebuilding.
13685 UnresolvedSet<2> UnqualLookups;
13686 bool ChangedAnyLookups = false;
13687 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13688 const_cast<Expr *>(Decomp.InnerBinOp)};
13689 for (Expr *PossibleBinOp : PossibleBinOps) {
13690 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13691 if (!Op)
13692 continue;
13693 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13694 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13695 continue;
13696
13697 // Transform the callee in case we built a call to a local extern
13698 // declaration.
13699 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13700 E->getOperatorLoc(), Callee->getFoundDecl()));
13701 if (!Found)
13702 return ExprError();
13703 if (Found != Callee->getFoundDecl())
13704 ChangedAnyLookups = true;
13705 UnqualLookups.addDecl(Found);
13706 }
13707
13708 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13709 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13710 // Mark all functions used in the rewrite as referenced. Note that when
13711 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13712 // function calls, and/or there might be a user-defined conversion sequence
13713 // applied to the operands of the <.
13714 // FIXME: this is a bit instantiation-specific.
13715 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13716 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13717 return E;
13718 }
13719
13720 return getDerived().RebuildCXXRewrittenBinaryOperator(
13721 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13722}
13723
13724template<typename Derived>
13728 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13729 FPOptionsOverride NewOverrides(E->getFPFeatures());
13730 getSema().CurFPFeatures =
13731 NewOverrides.applyOverrides(getSema().getLangOpts());
13732 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13733 return getDerived().TransformBinaryOperator(E);
13734}
13735
13736template<typename Derived>
13739 // Just rebuild the common and RHS expressions and see whether we
13740 // get any changes.
13741
13742 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13743 if (commonExpr.isInvalid())
13744 return ExprError();
13745
13746 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13747 if (rhs.isInvalid())
13748 return ExprError();
13749
13750 if (!getDerived().AlwaysRebuild() &&
13751 commonExpr.get() == e->getCommon() &&
13752 rhs.get() == e->getFalseExpr())
13753 return e;
13754
13755 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13756 e->getQuestionLoc(),
13757 nullptr,
13758 e->getColonLoc(),
13759 rhs.get());
13760}
13761
13762template<typename Derived>
13765 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13766 if (Cond.isInvalid())
13767 return ExprError();
13768
13769 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13770 if (LHS.isInvalid())
13771 return ExprError();
13772
13773 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13774 if (RHS.isInvalid())
13775 return ExprError();
13776
13777 if (!getDerived().AlwaysRebuild() &&
13778 Cond.get() == E->getCond() &&
13779 LHS.get() == E->getLHS() &&
13780 RHS.get() == E->getRHS())
13781 return E;
13782
13783 return getDerived().RebuildConditionalOperator(Cond.get(),
13784 E->getQuestionLoc(),
13785 LHS.get(),
13786 E->getColonLoc(),
13787 RHS.get());
13788}
13789
13790template<typename Derived>
13793 // Implicit casts are eliminated during transformation, since they
13794 // will be recomputed by semantic analysis after transformation.
13795 return getDerived().TransformExpr(E->getSubExprAsWritten());
13796}
13797
13798template<typename Derived>
13801 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
13802 if (!Type)
13803 return ExprError();
13804
13805 ExprResult SubExpr
13806 = getDerived().TransformExpr(E->getSubExprAsWritten());
13807 if (SubExpr.isInvalid())
13808 return ExprError();
13809
13810 if (!getDerived().AlwaysRebuild() &&
13811 Type == E->getTypeInfoAsWritten() &&
13812 SubExpr.get() == E->getSubExpr())
13813 return E;
13814
13815 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
13816 Type,
13817 E->getRParenLoc(),
13818 SubExpr.get());
13819}
13820
13821template<typename Derived>
13824 TypeSourceInfo *OldT = E->getTypeSourceInfo();
13825 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13826 if (!NewT)
13827 return ExprError();
13828
13829 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
13830 if (Init.isInvalid())
13831 return ExprError();
13832
13833 if (!getDerived().AlwaysRebuild() &&
13834 OldT == NewT &&
13835 Init.get() == E->getInitializer())
13836 return SemaRef.MaybeBindToTemporary(E);
13837
13838 // Note: the expression type doesn't necessarily match the
13839 // type-as-written, but that's okay, because it should always be
13840 // derivable from the initializer.
13841
13842 return getDerived().RebuildCompoundLiteralExpr(
13843 E->getLParenLoc(), NewT,
13844 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
13845}
13846
13847template<typename Derived>
13850 ExprResult Base = getDerived().TransformExpr(E->getBase());
13851 if (Base.isInvalid())
13852 return ExprError();
13853
13854 if (!getDerived().AlwaysRebuild() &&
13855 Base.get() == E->getBase())
13856 return E;
13857
13858 // FIXME: Bad source location
13859 SourceLocation FakeOperatorLoc =
13860 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
13861 return getDerived().RebuildExtVectorElementExpr(
13862 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
13863 E->getAccessor());
13864}
13865
13866template<typename Derived>
13869 if (InitListExpr *Syntactic = E->getSyntacticForm())
13870 E = Syntactic;
13871
13872 bool InitChanged = false;
13873
13876
13878 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
13879 Inits, &InitChanged))
13880 return ExprError();
13881
13882 if (!getDerived().AlwaysRebuild() && !InitChanged) {
13883 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
13884 // in some cases. We can't reuse it in general, because the syntactic and
13885 // semantic forms are linked, and we can't know that semantic form will
13886 // match even if the syntactic form does.
13887 }
13888
13889 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
13890 E->getRBraceLoc());
13891}
13892
13893template<typename Derived>
13896 Designation Desig;
13897
13898 // transform the initializer value
13899 ExprResult Init = getDerived().TransformExpr(E->getInit());
13900 if (Init.isInvalid())
13901 return ExprError();
13902
13903 // transform the designators.
13904 SmallVector<Expr*, 4> ArrayExprs;
13905 bool ExprChanged = false;
13906 for (const DesignatedInitExpr::Designator &D : E->designators()) {
13907 if (D.isFieldDesignator()) {
13908 if (D.getFieldDecl()) {
13909 FieldDecl *Field = cast_or_null<FieldDecl>(
13910 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
13911 if (Field != D.getFieldDecl())
13912 // Rebuild the expression when the transformed FieldDecl is
13913 // different to the already assigned FieldDecl.
13914 ExprChanged = true;
13915 if (Field->isAnonymousStructOrUnion())
13916 continue;
13917 } else {
13918 // Ensure that the designator expression is rebuilt when there isn't
13919 // a resolved FieldDecl in the designator as we don't want to assign
13920 // a FieldDecl to a pattern designator that will be instantiated again.
13921 ExprChanged = true;
13922 }
13923 Desig.AddDesignator(Designator::CreateFieldDesignator(
13924 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
13925 continue;
13926 }
13927
13928 if (D.isArrayDesignator()) {
13929 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
13930 if (Index.isInvalid())
13931 return ExprError();
13932
13933 Desig.AddDesignator(
13934 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
13935
13936 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
13937 ArrayExprs.push_back(Index.get());
13938 continue;
13939 }
13940
13941 assert(D.isArrayRangeDesignator() && "New kind of designator?");
13942 ExprResult Start
13943 = getDerived().TransformExpr(E->getArrayRangeStart(D));
13944 if (Start.isInvalid())
13945 return ExprError();
13946
13947 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
13948 if (End.isInvalid())
13949 return ExprError();
13950
13951 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
13952 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
13953
13954 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
13955 End.get() != E->getArrayRangeEnd(D);
13956
13957 ArrayExprs.push_back(Start.get());
13958 ArrayExprs.push_back(End.get());
13959 }
13960
13961 if (!getDerived().AlwaysRebuild() &&
13962 Init.get() == E->getInit() &&
13963 !ExprChanged)
13964 return E;
13965
13966 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
13967 E->getEqualOrColonLoc(),
13968 E->usesGNUSyntax(), Init.get());
13969}
13970
13971// Seems that if TransformInitListExpr() only works on the syntactic form of an
13972// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
13973template<typename Derived>
13977 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
13978 "initializer");
13979 return ExprError();
13980}
13981
13982template<typename Derived>
13985 NoInitExpr *E) {
13986 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
13987 return ExprError();
13988}
13989
13990template<typename Derived>
13993 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
13994 return ExprError();
13995}
13996
13997template<typename Derived>
14000 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14001 return ExprError();
14002}
14003
14004template<typename Derived>
14008 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14009
14010 // FIXME: Will we ever have proper type location here? Will we actually
14011 // need to transform the type?
14012 QualType T = getDerived().TransformType(E->getType());
14013 if (T.isNull())
14014 return ExprError();
14015
14016 if (!getDerived().AlwaysRebuild() &&
14017 T == E->getType())
14018 return E;
14019
14020 return getDerived().RebuildImplicitValueInitExpr(T);
14021}
14022
14023template<typename Derived>
14026 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14027 if (!TInfo)
14028 return ExprError();
14029
14030 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14031 if (SubExpr.isInvalid())
14032 return ExprError();
14033
14034 if (!getDerived().AlwaysRebuild() &&
14035 TInfo == E->getWrittenTypeInfo() &&
14036 SubExpr.get() == E->getSubExpr())
14037 return E;
14038
14039 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14040 TInfo, E->getRParenLoc());
14041}
14042
14043template<typename Derived>
14046 bool ArgumentChanged = false;
14048 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14049 &ArgumentChanged))
14050 return ExprError();
14051
14052 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14053 Inits,
14054 E->getRParenLoc());
14055}
14056
14057/// Transform an address-of-label expression.
14058///
14059/// By default, the transformation of an address-of-label expression always
14060/// rebuilds the expression, so that the label identifier can be resolved to
14061/// the corresponding label statement by semantic analysis.
14062template<typename Derived>
14065 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14066 E->getLabel());
14067 if (!LD)
14068 return ExprError();
14069
14070 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14071 cast<LabelDecl>(LD));
14072}
14073
14074template<typename Derived>
14077 SemaRef.ActOnStartStmtExpr();
14078 StmtResult SubStmt
14079 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14080 if (SubStmt.isInvalid()) {
14081 SemaRef.ActOnStmtExprError();
14082 return ExprError();
14083 }
14084
14085 unsigned OldDepth = E->getTemplateDepth();
14086 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14087
14088 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14089 SubStmt.get() == E->getSubStmt()) {
14090 // Calling this an 'error' is unintuitive, but it does the right thing.
14091 SemaRef.ActOnStmtExprError();
14092 return SemaRef.MaybeBindToTemporary(E);
14093 }
14094
14095 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14096 E->getRParenLoc(), NewDepth);
14097}
14098
14099template<typename Derived>
14102 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14103 if (Cond.isInvalid())
14104 return ExprError();
14105
14106 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14107 if (LHS.isInvalid())
14108 return ExprError();
14109
14110 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14111 if (RHS.isInvalid())
14112 return ExprError();
14113
14114 if (!getDerived().AlwaysRebuild() &&
14115 Cond.get() == E->getCond() &&
14116 LHS.get() == E->getLHS() &&
14117 RHS.get() == E->getRHS())
14118 return E;
14119
14120 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14121 Cond.get(), LHS.get(), RHS.get(),
14122 E->getRParenLoc());
14123}
14124
14125template<typename Derived>
14128 return E;
14129}
14130
14131template<typename Derived>
14134 switch (E->getOperator()) {
14135 case OO_New:
14136 case OO_Delete:
14137 case OO_Array_New:
14138 case OO_Array_Delete:
14139 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14140
14141 case OO_Subscript:
14142 case OO_Call: {
14143 // This is a call to an object's operator().
14144 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14145
14146 // Transform the object itself.
14147 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14148 if (Object.isInvalid())
14149 return ExprError();
14150
14151 // FIXME: Poor location information. Also, if the location for the end of
14152 // the token is within a macro expansion, getLocForEndOfToken() will return
14153 // an invalid source location. If that happens and we have an otherwise
14154 // valid end location, use the valid one instead of the invalid one.
14155 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14156 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14157 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14158 FakeLParenLoc = EndLoc;
14159
14160 // Transform the call arguments.
14162 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14163 Args))
14164 return ExprError();
14165
14166 if (E->getOperator() == OO_Subscript)
14167 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14168 Args, E->getEndLoc());
14169
14170 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14171 E->getEndLoc());
14172 }
14173
14174#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14175 case OO_##Name: \
14176 break;
14177
14178#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14179#include "clang/Basic/OperatorKinds.def"
14180
14181 case OO_Conditional:
14182 llvm_unreachable("conditional operator is not actually overloadable");
14183
14184 case OO_None:
14186 llvm_unreachable("not an overloaded operator?");
14187 }
14188
14190 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14191 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14192 else
14193 First = getDerived().TransformExpr(E->getArg(0));
14194 if (First.isInvalid())
14195 return ExprError();
14196
14197 ExprResult Second;
14198 if (E->getNumArgs() == 2) {
14199 Second =
14200 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14201 if (Second.isInvalid())
14202 return ExprError();
14203 }
14204
14205 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14206 FPOptionsOverride NewOverrides(E->getFPFeatures());
14207 getSema().CurFPFeatures =
14208 NewOverrides.applyOverrides(getSema().getLangOpts());
14209 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14210
14211 Expr *Callee = E->getCallee();
14212 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14213 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14215 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14216 return ExprError();
14217
14218 return getDerived().RebuildCXXOperatorCallExpr(
14219 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14220 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14221 }
14222
14223 UnresolvedSet<1> Functions;
14224 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14225 Callee = ICE->getSubExprAsWritten();
14226 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14227 ValueDecl *VD = cast_or_null<ValueDecl>(
14228 getDerived().TransformDecl(DR->getLocation(), DR));
14229 if (!VD)
14230 return ExprError();
14231
14232 if (!isa<CXXMethodDecl>(VD))
14233 Functions.addDecl(VD);
14234
14235 return getDerived().RebuildCXXOperatorCallExpr(
14236 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14237 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14238}
14239
14240template<typename Derived>
14243 return getDerived().TransformCallExpr(E);
14244}
14245
14246template <typename Derived>
14248 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14249 getSema().CurContext != E->getParentContext();
14250
14251 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14252 return E;
14253
14254 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14255 E->getBeginLoc(), E->getEndLoc(),
14256 getSema().CurContext);
14257}
14258
14259template <typename Derived>
14261 return E;
14262}
14263
14264template<typename Derived>
14267 // Transform the callee.
14268 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14269 if (Callee.isInvalid())
14270 return ExprError();
14271
14272 // Transform exec config.
14273 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14274 if (EC.isInvalid())
14275 return ExprError();
14276
14277 // Transform arguments.
14278 bool ArgChanged = false;
14280 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14281 &ArgChanged))
14282 return ExprError();
14283
14284 if (!getDerived().AlwaysRebuild() &&
14285 Callee.get() == E->getCallee() &&
14286 !ArgChanged)
14287 return SemaRef.MaybeBindToTemporary(E);
14288
14289 // FIXME: Wrong source location information for the '('.
14290 SourceLocation FakeLParenLoc
14291 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14292 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14293 Args,
14294 E->getRParenLoc(), EC.get());
14295}
14296
14297template<typename Derived>
14300 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14301 if (!Type)
14302 return ExprError();
14303
14304 ExprResult SubExpr
14305 = getDerived().TransformExpr(E->getSubExprAsWritten());
14306 if (SubExpr.isInvalid())
14307 return ExprError();
14308
14309 if (!getDerived().AlwaysRebuild() &&
14310 Type == E->getTypeInfoAsWritten() &&
14311 SubExpr.get() == E->getSubExpr())
14312 return E;
14313 return getDerived().RebuildCXXNamedCastExpr(
14316 // FIXME. this should be '(' location
14317 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14318}
14319
14320template<typename Derived>
14323 TypeSourceInfo *TSI =
14324 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14325 if (!TSI)
14326 return ExprError();
14327
14328 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14329 if (Sub.isInvalid())
14330 return ExprError();
14331
14332 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14333 Sub.get(), BCE->getEndLoc());
14334}
14335
14336template<typename Derived>
14338TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14339 return getDerived().TransformCXXNamedCastExpr(E);
14340}
14341
14342template<typename Derived>
14345 return getDerived().TransformCXXNamedCastExpr(E);
14346}
14347
14348template<typename Derived>
14352 return getDerived().TransformCXXNamedCastExpr(E);
14353}
14354
14355template<typename Derived>
14358 return getDerived().TransformCXXNamedCastExpr(E);
14359}
14360
14361template<typename Derived>
14364 return getDerived().TransformCXXNamedCastExpr(E);
14365}
14366
14367template<typename Derived>
14372 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14373 if (!Type)
14374 return ExprError();
14375
14376 ExprResult SubExpr
14377 = getDerived().TransformExpr(E->getSubExprAsWritten());
14378 if (SubExpr.isInvalid())
14379 return ExprError();
14380
14381 if (!getDerived().AlwaysRebuild() &&
14382 Type == E->getTypeInfoAsWritten() &&
14383 SubExpr.get() == E->getSubExpr())
14384 return E;
14385
14386 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14387 E->getLParenLoc(),
14388 SubExpr.get(),
14389 E->getRParenLoc(),
14390 E->isListInitialization());
14391}
14392
14393template<typename Derived>
14396 if (E->isTypeOperand()) {
14397 TypeSourceInfo *TInfo
14398 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14399 if (!TInfo)
14400 return ExprError();
14401
14402 if (!getDerived().AlwaysRebuild() &&
14403 TInfo == E->getTypeOperandSourceInfo())
14404 return E;
14405
14406 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14407 TInfo, E->getEndLoc());
14408 }
14409
14410 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14411 // type. We must not unilaterally enter unevaluated context here, as then
14412 // semantic processing can re-transform an already transformed operand.
14413 Expr *Op = E->getExprOperand();
14415 if (E->isGLValue())
14416 if (auto *RD = Op->getType()->getAsCXXRecordDecl();
14417 RD && RD->isPolymorphic())
14418 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14419
14422
14423 ExprResult SubExpr = getDerived().TransformExpr(Op);
14424 if (SubExpr.isInvalid())
14425 return ExprError();
14426
14427 if (!getDerived().AlwaysRebuild() &&
14428 SubExpr.get() == E->getExprOperand())
14429 return E;
14430
14431 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14432 SubExpr.get(), E->getEndLoc());
14433}
14434
14435template<typename Derived>
14438 if (E->isTypeOperand()) {
14439 TypeSourceInfo *TInfo
14440 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14441 if (!TInfo)
14442 return ExprError();
14443
14444 if (!getDerived().AlwaysRebuild() &&
14445 TInfo == E->getTypeOperandSourceInfo())
14446 return E;
14447
14448 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14449 TInfo, E->getEndLoc());
14450 }
14451
14454
14455 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14456 if (SubExpr.isInvalid())
14457 return ExprError();
14458
14459 if (!getDerived().AlwaysRebuild() &&
14460 SubExpr.get() == E->getExprOperand())
14461 return E;
14462
14463 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14464 SubExpr.get(), E->getEndLoc());
14465}
14466
14467template<typename Derived>
14470 return E;
14471}
14472
14473template<typename Derived>
14477 return E;
14478}
14479
14480template<typename Derived>
14483
14484 // In lambdas, the qualifiers of the type depends of where in
14485 // the call operator `this` appear, and we do not have a good way to
14486 // rebuild this information, so we transform the type.
14487 //
14488 // In other contexts, the type of `this` may be overrided
14489 // for type deduction, so we need to recompute it.
14490 //
14491 // Always recompute the type if we're in the body of a lambda, and
14492 // 'this' is dependent on a lambda's explicit object parameter; we
14493 // also need to always rebuild the expression in this case to clear
14494 // the flag.
14495 QualType T = [&]() {
14496 auto &S = getSema();
14497 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14498 return S.getCurrentThisType();
14499 if (S.getCurLambda())
14500 return getDerived().TransformType(E->getType());
14501 return S.getCurrentThisType();
14502 }();
14503
14504 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14505 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14506 // Mark it referenced in the new context regardless.
14507 // FIXME: this is a bit instantiation-specific.
14508 getSema().MarkThisReferenced(E);
14509 return E;
14510 }
14511
14512 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14513}
14514
14515template<typename Derived>
14518 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14519 if (SubExpr.isInvalid())
14520 return ExprError();
14521
14522 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14523
14524 if (!getDerived().AlwaysRebuild() &&
14525 SubExpr.get() == E->getSubExpr())
14526 return E;
14527
14528 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14529 E->isThrownVariableInScope());
14530}
14531
14532template<typename Derived>
14535 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14536 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14537 if (!Param)
14538 return ExprError();
14539
14540 ExprResult InitRes;
14541 if (E->hasRewrittenInit()) {
14542 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14543 if (InitRes.isInvalid())
14544 return ExprError();
14545 }
14546
14547 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14548 E->getUsedContext() == SemaRef.CurContext &&
14549 InitRes.get() == E->getRewrittenExpr())
14550 return E;
14551
14552 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14553 InitRes.get());
14554}
14555
14556template<typename Derived>
14559 FieldDecl *Field = cast_or_null<FieldDecl>(
14560 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14561 if (!Field)
14562 return ExprError();
14563
14564 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14565 E->getUsedContext() == SemaRef.CurContext)
14566 return E;
14567
14568 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14569}
14570
14571template<typename Derived>
14575 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14576 if (!T)
14577 return ExprError();
14578
14579 if (!getDerived().AlwaysRebuild() &&
14580 T == E->getTypeSourceInfo())
14581 return E;
14582
14583 return getDerived().RebuildCXXScalarValueInitExpr(T,
14584 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14585 E->getRParenLoc());
14586}
14587
14588template<typename Derived>
14591 // Transform the type that we're allocating
14592 TypeSourceInfo *AllocTypeInfo =
14593 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14594 if (!AllocTypeInfo)
14595 return ExprError();
14596
14597 // Transform the size of the array we're allocating (if any).
14598 std::optional<Expr *> ArraySize;
14599 if (E->isArray()) {
14600 ExprResult NewArraySize;
14601 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14602 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14603 if (NewArraySize.isInvalid())
14604 return ExprError();
14605 }
14606 ArraySize = NewArraySize.get();
14607 }
14608
14609 // Transform the placement arguments (if any).
14610 bool ArgumentChanged = false;
14611 SmallVector<Expr*, 8> PlacementArgs;
14612 if (getDerived().TransformExprs(E->getPlacementArgs(),
14613 E->getNumPlacementArgs(), true,
14614 PlacementArgs, &ArgumentChanged))
14615 return ExprError();
14616
14617 // Transform the initializer (if any).
14618 Expr *OldInit = E->getInitializer();
14619 ExprResult NewInit;
14620 if (OldInit)
14621 NewInit = getDerived().TransformInitializer(OldInit, true);
14622 if (NewInit.isInvalid())
14623 return ExprError();
14624
14625 // Transform new operator and delete operator.
14626 FunctionDecl *OperatorNew = nullptr;
14627 if (E->getOperatorNew()) {
14628 OperatorNew = cast_or_null<FunctionDecl>(
14629 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14630 if (!OperatorNew)
14631 return ExprError();
14632 }
14633
14634 FunctionDecl *OperatorDelete = nullptr;
14635 if (E->getOperatorDelete()) {
14636 OperatorDelete = cast_or_null<FunctionDecl>(
14637 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14638 if (!OperatorDelete)
14639 return ExprError();
14640 }
14641
14642 if (!getDerived().AlwaysRebuild() &&
14643 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14644 ArraySize == E->getArraySize() &&
14645 NewInit.get() == OldInit &&
14646 OperatorNew == E->getOperatorNew() &&
14647 OperatorDelete == E->getOperatorDelete() &&
14648 !ArgumentChanged) {
14649 // Mark any declarations we need as referenced.
14650 // FIXME: instantiation-specific.
14651 if (OperatorNew)
14652 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14653 if (OperatorDelete)
14654 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14655
14656 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14657 QualType ElementType
14658 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14659 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14661 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14662 }
14663 }
14664
14665 return E;
14666 }
14667
14668 QualType AllocType = AllocTypeInfo->getType();
14669 if (!ArraySize) {
14670 // If no array size was specified, but the new expression was
14671 // instantiated with an array type (e.g., "new T" where T is
14672 // instantiated with "int[4]"), extract the outer bound from the
14673 // array type as our array size. We do this with constant and
14674 // dependently-sized array types.
14675 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14676 if (!ArrayT) {
14677 // Do nothing
14678 } else if (const ConstantArrayType *ConsArrayT
14679 = dyn_cast<ConstantArrayType>(ArrayT)) {
14680 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14681 SemaRef.Context.getSizeType(),
14682 /*FIXME:*/ E->getBeginLoc());
14683 AllocType = ConsArrayT->getElementType();
14684 } else if (const DependentSizedArrayType *DepArrayT
14685 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14686 if (DepArrayT->getSizeExpr()) {
14687 ArraySize = DepArrayT->getSizeExpr();
14688 AllocType = DepArrayT->getElementType();
14689 }
14690 }
14691 }
14692
14693 return getDerived().RebuildCXXNewExpr(
14694 E->getBeginLoc(), E->isGlobalNew(),
14695 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14696 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14697 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14698}
14699
14700template<typename Derived>
14703 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14704 if (Operand.isInvalid())
14705 return ExprError();
14706
14707 // Transform the delete operator, if known.
14708 FunctionDecl *OperatorDelete = nullptr;
14709 if (E->getOperatorDelete()) {
14710 OperatorDelete = cast_or_null<FunctionDecl>(
14711 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14712 if (!OperatorDelete)
14713 return ExprError();
14714 }
14715
14716 if (!getDerived().AlwaysRebuild() &&
14717 Operand.get() == E->getArgument() &&
14718 OperatorDelete == E->getOperatorDelete()) {
14719 // Mark any declarations we need as referenced.
14720 // FIXME: instantiation-specific.
14721 if (OperatorDelete)
14722 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14723
14724 if (!E->getArgument()->isTypeDependent()) {
14725 QualType Destroyed = SemaRef.Context.getBaseElementType(
14726 E->getDestroyedType());
14727 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14728 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14729 SemaRef.LookupDestructor(Record));
14730 }
14731
14732 return E;
14733 }
14734
14735 return getDerived().RebuildCXXDeleteExpr(
14736 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14737}
14738
14739template<typename Derived>
14743 ExprResult Base = getDerived().TransformExpr(E->getBase());
14744 if (Base.isInvalid())
14745 return ExprError();
14746
14747 ParsedType ObjectTypePtr;
14748 bool MayBePseudoDestructor = false;
14749 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14750 E->getOperatorLoc(),
14751 E->isArrow()? tok::arrow : tok::period,
14752 ObjectTypePtr,
14753 MayBePseudoDestructor);
14754 if (Base.isInvalid())
14755 return ExprError();
14756
14757 QualType ObjectType = ObjectTypePtr.get();
14758 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
14759 if (QualifierLoc) {
14760 QualifierLoc
14761 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
14762 if (!QualifierLoc)
14763 return ExprError();
14764 }
14765 CXXScopeSpec SS;
14766 SS.Adopt(QualifierLoc);
14767
14769 if (E->getDestroyedTypeInfo()) {
14770 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
14771 E->getDestroyedTypeInfo(), ObjectType,
14772 /*FirstQualifierInScope=*/nullptr);
14773 if (!DestroyedTypeInfo)
14774 return ExprError();
14775 Destroyed = DestroyedTypeInfo;
14776 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
14777 // We aren't likely to be able to resolve the identifier down to a type
14778 // now anyway, so just retain the identifier.
14779 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
14780 E->getDestroyedTypeLoc());
14781 } else {
14782 // Look for a destructor known with the given name.
14783 ParsedType T = SemaRef.getDestructorName(
14784 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
14785 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
14786 if (!T)
14787 return ExprError();
14788
14789 Destroyed
14791 E->getDestroyedTypeLoc());
14792 }
14793
14794 TypeSourceInfo *ScopeTypeInfo = nullptr;
14795 if (E->getScopeTypeInfo()) {
14796 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
14797 E->getScopeTypeInfo(), ObjectType, nullptr);
14798 if (!ScopeTypeInfo)
14799 return ExprError();
14800 }
14801
14802 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
14803 E->getOperatorLoc(),
14804 E->isArrow(),
14805 SS,
14806 ScopeTypeInfo,
14807 E->getColonColonLoc(),
14808 E->getTildeLoc(),
14809 Destroyed);
14810}
14811
14812template <typename Derived>
14814 bool RequiresADL,
14815 LookupResult &R) {
14816 // Transform all the decls.
14817 bool AllEmptyPacks = true;
14818 for (auto *OldD : Old->decls()) {
14819 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
14820 if (!InstD) {
14821 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
14822 // This can happen because of dependent hiding.
14823 if (isa<UsingShadowDecl>(OldD))
14824 continue;
14825 else {
14826 R.clear();
14827 return true;
14828 }
14829 }
14830
14831 // Expand using pack declarations.
14832 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
14833 ArrayRef<NamedDecl*> Decls = SingleDecl;
14834 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
14835 Decls = UPD->expansions();
14836
14837 // Expand using declarations.
14838 for (auto *D : Decls) {
14839 if (auto *UD = dyn_cast<UsingDecl>(D)) {
14840 for (auto *SD : UD->shadows())
14841 R.addDecl(SD);
14842 } else {
14843 R.addDecl(D);
14844 }
14845 }
14846
14847 AllEmptyPacks &= Decls.empty();
14848 }
14849
14850 // C++ [temp.res]/8.4.2:
14851 // The program is ill-formed, no diagnostic required, if [...] lookup for
14852 // a name in the template definition found a using-declaration, but the
14853 // lookup in the corresponding scope in the instantiation odoes not find
14854 // any declarations because the using-declaration was a pack expansion and
14855 // the corresponding pack is empty
14856 if (AllEmptyPacks && !RequiresADL) {
14857 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
14858 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
14859 return true;
14860 }
14861
14862 // Resolve a kind, but don't do any further analysis. If it's
14863 // ambiguous, the callee needs to deal with it.
14864 R.resolveKind();
14865
14866 if (Old->hasTemplateKeyword() && !R.empty()) {
14868 getSema().FilterAcceptableTemplateNames(R,
14869 /*AllowFunctionTemplates=*/true,
14870 /*AllowDependent=*/true);
14871 if (R.empty()) {
14872 // If a 'template' keyword was used, a lookup that finds only non-template
14873 // names is an error.
14874 getSema().Diag(R.getNameLoc(),
14875 diag::err_template_kw_refers_to_non_template)
14877 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
14878 getSema().Diag(FoundDecl->getLocation(),
14879 diag::note_template_kw_refers_to_non_template)
14880 << R.getLookupName();
14881 return true;
14882 }
14883 }
14884
14885 return false;
14886}
14887
14888template <typename Derived>
14893
14894template <typename Derived>
14897 bool IsAddressOfOperand) {
14898 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
14900
14901 // Transform the declaration set.
14902 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
14903 return ExprError();
14904
14905 // Rebuild the nested-name qualifier, if present.
14906 CXXScopeSpec SS;
14907 if (Old->getQualifierLoc()) {
14908 NestedNameSpecifierLoc QualifierLoc
14909 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
14910 if (!QualifierLoc)
14911 return ExprError();
14912
14913 SS.Adopt(QualifierLoc);
14914 }
14915
14916 if (Old->getNamingClass()) {
14917 CXXRecordDecl *NamingClass
14918 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
14919 Old->getNameLoc(),
14920 Old->getNamingClass()));
14921 if (!NamingClass) {
14922 R.clear();
14923 return ExprError();
14924 }
14925
14926 R.setNamingClass(NamingClass);
14927 }
14928
14929 // Rebuild the template arguments, if any.
14930 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
14931 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
14932 if (Old->hasExplicitTemplateArgs() &&
14933 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
14934 Old->getNumTemplateArgs(),
14935 TransArgs)) {
14936 R.clear();
14937 return ExprError();
14938 }
14939
14940 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
14941 // a non-static data member is named in an unevaluated operand, or when
14942 // a member is named in a dependent class scope function template explicit
14943 // specialization that is neither declared static nor with an explicit object
14944 // parameter.
14945 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
14946 return SemaRef.BuildPossibleImplicitMemberExpr(
14947 SS, TemplateKWLoc, R,
14948 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
14949 /*S=*/nullptr);
14950
14951 // If we have neither explicit template arguments, nor the template keyword,
14952 // it's a normal declaration name or member reference.
14953 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
14954 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
14955
14956 // If we have template arguments, then rebuild the template-id expression.
14957 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
14958 Old->requiresADL(), &TransArgs);
14959}
14960
14961template<typename Derived>
14964 bool ArgChanged = false;
14966 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
14967 TypeSourceInfo *From = E->getArg(I);
14968 TypeLoc FromTL = From->getTypeLoc();
14969 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
14970 TypeLocBuilder TLB;
14971 TLB.reserve(FromTL.getFullDataSize());
14972 QualType To = getDerived().TransformType(TLB, FromTL);
14973 if (To.isNull())
14974 return ExprError();
14975
14976 if (To == From->getType())
14977 Args.push_back(From);
14978 else {
14979 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
14980 ArgChanged = true;
14981 }
14982 continue;
14983 }
14984
14985 ArgChanged = true;
14986
14987 // We have a pack expansion. Instantiate it.
14988 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
14989 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
14991 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
14992
14993 // Determine whether the set of unexpanded parameter packs can and should
14994 // be expanded.
14995 bool Expand = true;
14996 bool RetainExpansion = false;
14997 UnsignedOrNone OrigNumExpansions =
14998 ExpansionTL.getTypePtr()->getNumExpansions();
14999 UnsignedOrNone NumExpansions = OrigNumExpansions;
15000 if (getDerived().TryExpandParameterPacks(
15001 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15002 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15003 RetainExpansion, NumExpansions))
15004 return ExprError();
15005
15006 if (!Expand) {
15007 // The transform has determined that we should perform a simple
15008 // transformation on the pack expansion, producing another pack
15009 // expansion.
15010 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15011
15012 TypeLocBuilder TLB;
15013 TLB.reserve(From->getTypeLoc().getFullDataSize());
15014
15015 QualType To = getDerived().TransformType(TLB, PatternTL);
15016 if (To.isNull())
15017 return ExprError();
15018
15019 To = getDerived().RebuildPackExpansionType(To,
15020 PatternTL.getSourceRange(),
15021 ExpansionTL.getEllipsisLoc(),
15022 NumExpansions);
15023 if (To.isNull())
15024 return ExprError();
15025
15026 PackExpansionTypeLoc ToExpansionTL
15027 = TLB.push<PackExpansionTypeLoc>(To);
15028 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15029 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15030 continue;
15031 }
15032
15033 // Expand the pack expansion by substituting for each argument in the
15034 // pack(s).
15035 for (unsigned I = 0; I != *NumExpansions; ++I) {
15036 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15037 TypeLocBuilder TLB;
15038 TLB.reserve(PatternTL.getFullDataSize());
15039 QualType To = getDerived().TransformType(TLB, PatternTL);
15040 if (To.isNull())
15041 return ExprError();
15042
15043 if (To->containsUnexpandedParameterPack()) {
15044 To = getDerived().RebuildPackExpansionType(To,
15045 PatternTL.getSourceRange(),
15046 ExpansionTL.getEllipsisLoc(),
15047 NumExpansions);
15048 if (To.isNull())
15049 return ExprError();
15050
15051 PackExpansionTypeLoc ToExpansionTL
15052 = TLB.push<PackExpansionTypeLoc>(To);
15053 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15054 }
15055
15056 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15057 }
15058
15059 if (!RetainExpansion)
15060 continue;
15061
15062 // If we're supposed to retain a pack expansion, do so by temporarily
15063 // forgetting the partially-substituted parameter pack.
15064 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15065
15066 TypeLocBuilder TLB;
15067 TLB.reserve(From->getTypeLoc().getFullDataSize());
15068
15069 QualType To = getDerived().TransformType(TLB, PatternTL);
15070 if (To.isNull())
15071 return ExprError();
15072
15073 To = getDerived().RebuildPackExpansionType(To,
15074 PatternTL.getSourceRange(),
15075 ExpansionTL.getEllipsisLoc(),
15076 NumExpansions);
15077 if (To.isNull())
15078 return ExprError();
15079
15080 PackExpansionTypeLoc ToExpansionTL
15081 = TLB.push<PackExpansionTypeLoc>(To);
15082 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15083 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15084 }
15085
15086 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15087 return E;
15088
15089 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15090 E->getEndLoc());
15091}
15092
15093template<typename Derived>
15097 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15098 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15099 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15100 Old->NumTemplateArgs, TransArgs))
15101 return ExprError();
15102
15103 return getDerived().RebuildConceptSpecializationExpr(
15104 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15105 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15106 &TransArgs);
15107}
15108
15109template<typename Derived>
15112 SmallVector<ParmVarDecl*, 4> TransParams;
15113 SmallVector<QualType, 4> TransParamTypes;
15114 Sema::ExtParameterInfoBuilder ExtParamInfos;
15115
15116 // C++2a [expr.prim.req]p2
15117 // Expressions appearing within a requirement-body are unevaluated operands.
15121
15123 getSema().Context, getSema().CurContext,
15124 E->getBody()->getBeginLoc());
15125
15126 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15127
15128 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15129 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15130 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15131
15132 for (ParmVarDecl *Param : TransParams)
15133 if (Param)
15134 Param->setDeclContext(Body);
15135
15136 // On failure to transform, TransformRequiresTypeParams returns an expression
15137 // in the event that the transformation of the type params failed in some way.
15138 // It is expected that this will result in a 'not satisfied' Requires clause
15139 // when instantiating.
15140 if (!TypeParamResult.isUnset())
15141 return TypeParamResult;
15142
15144 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15145 TransReqs))
15146 return ExprError();
15147
15148 for (concepts::Requirement *Req : TransReqs) {
15149 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15150 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15151 ER->getReturnTypeRequirement()
15152 .getTypeConstraintTemplateParameterList()->getParam(0)
15153 ->setDeclContext(Body);
15154 }
15155 }
15156 }
15157
15158 return getDerived().RebuildRequiresExpr(
15159 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15160 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15161}
15162
15163template<typename Derived>
15167 for (concepts::Requirement *Req : Reqs) {
15168 concepts::Requirement *TransReq = nullptr;
15169 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15170 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15171 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15172 TransReq = getDerived().TransformExprRequirement(ExprReq);
15173 else
15174 TransReq = getDerived().TransformNestedRequirement(
15176 if (!TransReq)
15177 return true;
15178 Transformed.push_back(TransReq);
15179 }
15180 return false;
15181}
15182
15183template<typename Derived>
15187 if (Req->isSubstitutionFailure()) {
15188 if (getDerived().AlwaysRebuild())
15189 return getDerived().RebuildTypeRequirement(
15191 return Req;
15192 }
15193 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15194 if (!TransType)
15195 return nullptr;
15196 return getDerived().RebuildTypeRequirement(TransType);
15197}
15198
15199template<typename Derived>
15202 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15203 if (Req->isExprSubstitutionFailure())
15204 TransExpr = Req->getExprSubstitutionDiagnostic();
15205 else {
15206 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15207 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15208 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15209 if (TransExprRes.isInvalid())
15210 return nullptr;
15211 TransExpr = TransExprRes.get();
15212 }
15213
15214 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15215 const auto &RetReq = Req->getReturnTypeRequirement();
15216 if (RetReq.isEmpty())
15217 TransRetReq.emplace();
15218 else if (RetReq.isSubstitutionFailure())
15219 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15220 else if (RetReq.isTypeConstraint()) {
15221 TemplateParameterList *OrigTPL =
15222 RetReq.getTypeConstraintTemplateParameterList();
15224 getDerived().TransformTemplateParameterList(OrigTPL);
15225 if (!TPL)
15226 return nullptr;
15227 TransRetReq.emplace(TPL);
15228 }
15229 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15230 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15231 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15232 Req->getNoexceptLoc(),
15233 std::move(*TransRetReq));
15234 return getDerived().RebuildExprRequirement(
15236 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15237}
15238
15239template<typename Derived>
15243 if (Req->hasInvalidConstraint()) {
15244 if (getDerived().AlwaysRebuild())
15245 return getDerived().RebuildNestedRequirement(
15247 return Req;
15248 }
15249 ExprResult TransConstraint =
15250 getDerived().TransformExpr(Req->getConstraintExpr());
15251 if (TransConstraint.isInvalid())
15252 return nullptr;
15253 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15254}
15255
15256template<typename Derived>
15259 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15260 if (!T)
15261 return ExprError();
15262
15263 if (!getDerived().AlwaysRebuild() &&
15265 return E;
15266
15267 ExprResult SubExpr;
15268 {
15271 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15272 if (SubExpr.isInvalid())
15273 return ExprError();
15274 }
15275
15276 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15277 SubExpr.get(), E->getEndLoc());
15278}
15279
15280template<typename Derived>
15283 ExprResult SubExpr;
15284 {
15287 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15288 if (SubExpr.isInvalid())
15289 return ExprError();
15290
15291 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15292 return E;
15293 }
15294
15295 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15296 SubExpr.get(), E->getEndLoc());
15297}
15298
15299template <typename Derived>
15301 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15302 TypeSourceInfo **RecoveryTSI) {
15303 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15304 DRE, AddrTaken, RecoveryTSI);
15305
15306 // Propagate both errors and recovered types, which return ExprEmpty.
15307 if (!NewDRE.isUsable())
15308 return NewDRE;
15309
15310 // We got an expr, wrap it up in parens.
15311 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15312 return PE;
15313 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15314 PE->getRParen());
15315}
15316
15317template <typename Derived>
15323
15324template <typename Derived>
15326 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15327 TypeSourceInfo **RecoveryTSI) {
15328 assert(E->getQualifierLoc());
15329 NestedNameSpecifierLoc QualifierLoc =
15330 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15331 if (!QualifierLoc)
15332 return ExprError();
15333 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15334
15335 // TODO: If this is a conversion-function-id, verify that the
15336 // destination type name (if present) resolves the same way after
15337 // instantiation as it did in the local scope.
15338
15339 DeclarationNameInfo NameInfo =
15340 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15341 if (!NameInfo.getName())
15342 return ExprError();
15343
15344 if (!E->hasExplicitTemplateArgs()) {
15345 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15346 // Note: it is sufficient to compare the Name component of NameInfo:
15347 // if name has not changed, DNLoc has not changed either.
15348 NameInfo.getName() == E->getDeclName())
15349 return E;
15350
15351 return getDerived().RebuildDependentScopeDeclRefExpr(
15352 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15353 IsAddressOfOperand, RecoveryTSI);
15354 }
15355
15356 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15357 if (getDerived().TransformTemplateArguments(
15358 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15359 return ExprError();
15360
15361 return getDerived().RebuildDependentScopeDeclRefExpr(
15362 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15363 RecoveryTSI);
15364}
15365
15366template<typename Derived>
15369 // CXXConstructExprs other than for list-initialization and
15370 // CXXTemporaryObjectExpr are always implicit, so when we have
15371 // a 1-argument construction we just transform that argument.
15372 if (getDerived().AllowSkippingCXXConstructExpr() &&
15373 ((E->getNumArgs() == 1 ||
15374 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15375 (!getDerived().DropCallArgument(E->getArg(0))) &&
15376 !E->isListInitialization()))
15377 return getDerived().TransformInitializer(E->getArg(0),
15378 /*DirectInit*/ false);
15379
15380 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15381
15382 QualType T = getDerived().TransformType(E->getType());
15383 if (T.isNull())
15384 return ExprError();
15385
15386 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15387 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15388 if (!Constructor)
15389 return ExprError();
15390
15391 bool ArgumentChanged = false;
15393 {
15396 E->isListInitialization());
15397 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15398 &ArgumentChanged))
15399 return ExprError();
15400 }
15401
15402 if (!getDerived().AlwaysRebuild() &&
15403 T == E->getType() &&
15404 Constructor == E->getConstructor() &&
15405 !ArgumentChanged) {
15406 // Mark the constructor as referenced.
15407 // FIXME: Instantiation-specific
15408 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15409 return E;
15410 }
15411
15412 return getDerived().RebuildCXXConstructExpr(
15413 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15414 E->hadMultipleCandidates(), E->isListInitialization(),
15415 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15416 E->getConstructionKind(), E->getParenOrBraceRange());
15417}
15418
15419template<typename Derived>
15422 QualType T = getDerived().TransformType(E->getType());
15423 if (T.isNull())
15424 return ExprError();
15425
15426 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15427 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15428 if (!Constructor)
15429 return ExprError();
15430
15431 if (!getDerived().AlwaysRebuild() &&
15432 T == E->getType() &&
15433 Constructor == E->getConstructor()) {
15434 // Mark the constructor as referenced.
15435 // FIXME: Instantiation-specific
15436 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15437 return E;
15438 }
15439
15440 return getDerived().RebuildCXXInheritedCtorInitExpr(
15441 T, E->getLocation(), Constructor,
15442 E->constructsVBase(), E->inheritedFromVBase());
15443}
15444
15445/// Transform a C++ temporary-binding expression.
15446///
15447/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15448/// transform the subexpression and return that.
15449template<typename Derived>
15452 if (auto *Dtor = E->getTemporary()->getDestructor())
15453 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15454 const_cast<CXXDestructorDecl *>(Dtor));
15455 return getDerived().TransformExpr(E->getSubExpr());
15456}
15457
15458/// Transform a C++ expression that contains cleanups that should
15459/// be run after the expression is evaluated.
15460///
15461/// Since ExprWithCleanups nodes are implicitly generated, we
15462/// just transform the subexpression and return that.
15463template<typename Derived>
15466 return getDerived().TransformExpr(E->getSubExpr());
15467}
15468
15469template<typename Derived>
15473 TypeSourceInfo *T =
15474 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15475 if (!T)
15476 return ExprError();
15477
15478 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15479 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15480 if (!Constructor)
15481 return ExprError();
15482
15483 bool ArgumentChanged = false;
15485 Args.reserve(E->getNumArgs());
15486 {
15489 E->isListInitialization());
15490 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15491 &ArgumentChanged))
15492 return ExprError();
15493
15494 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15495 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc());
15496 if (Res.isInvalid())
15497 return ExprError();
15498 Args = {Res.get()};
15499 }
15500 }
15501
15502 if (!getDerived().AlwaysRebuild() &&
15503 T == E->getTypeSourceInfo() &&
15504 Constructor == E->getConstructor() &&
15505 !ArgumentChanged) {
15506 // FIXME: Instantiation-specific
15507 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15508 return SemaRef.MaybeBindToTemporary(E);
15509 }
15510
15511 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15512 return getDerived().RebuildCXXTemporaryObjectExpr(
15513 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15514}
15515
15516template<typename Derived>
15519 // Transform any init-capture expressions before entering the scope of the
15520 // lambda body, because they are not semantically within that scope.
15521 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15522 struct TransformedInitCapture {
15523 // The location of the ... if the result is retaining a pack expansion.
15524 SourceLocation EllipsisLoc;
15525 // Zero or more expansions of the init-capture.
15526 SmallVector<InitCaptureInfoTy, 4> Expansions;
15527 };
15529 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15530 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15531 CEnd = E->capture_end();
15532 C != CEnd; ++C) {
15533 if (!E->isInitCapture(C))
15534 continue;
15535
15536 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15537 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15538
15539 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15540 UnsignedOrNone NumExpansions) {
15541 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15542 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15543
15544 if (NewExprInitResult.isInvalid()) {
15545 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15546 return;
15547 }
15548 Expr *NewExprInit = NewExprInitResult.get();
15549
15550 QualType NewInitCaptureType =
15551 getSema().buildLambdaInitCaptureInitialization(
15552 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15553 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15554 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15556 NewExprInit);
15557 Result.Expansions.push_back(
15558 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15559 };
15560
15561 // If this is an init-capture pack, consider expanding the pack now.
15562 if (OldVD->isParameterPack()) {
15563 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15564 ->getTypeLoc()
15567 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15568
15569 // Determine whether the set of unexpanded parameter packs can and should
15570 // be expanded.
15571 bool Expand = true;
15572 bool RetainExpansion = false;
15573 UnsignedOrNone OrigNumExpansions =
15574 ExpansionTL.getTypePtr()->getNumExpansions();
15575 UnsignedOrNone NumExpansions = OrigNumExpansions;
15576 if (getDerived().TryExpandParameterPacks(
15577 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15578 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15579 RetainExpansion, NumExpansions))
15580 return ExprError();
15581 assert(!RetainExpansion && "Should not need to retain expansion after a "
15582 "capture since it cannot be extended");
15583 if (Expand) {
15584 for (unsigned I = 0; I != *NumExpansions; ++I) {
15585 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15586 SubstInitCapture(SourceLocation(), std::nullopt);
15587 }
15588 } else {
15589 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15590 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15591 }
15592 } else {
15593 SubstInitCapture(SourceLocation(), std::nullopt);
15594 }
15595 }
15596
15597 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15598 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15599
15600 // Create the local class that will describe the lambda.
15601
15602 // FIXME: DependencyKind below is wrong when substituting inside a templated
15603 // context that isn't a DeclContext (such as a variable template), or when
15604 // substituting an unevaluated lambda inside of a function's parameter's type
15605 // - as parameter types are not instantiated from within a function's DC. We
15606 // use evaluation contexts to distinguish the function parameter case.
15609 DeclContext *DC = getSema().CurContext;
15610 // A RequiresExprBodyDecl is not interesting for dependencies.
15611 // For the following case,
15612 //
15613 // template <typename>
15614 // concept C = requires { [] {}; };
15615 //
15616 // template <class F>
15617 // struct Widget;
15618 //
15619 // template <C F>
15620 // struct Widget<F> {};
15621 //
15622 // While we are substituting Widget<F>, the parent of DC would be
15623 // the template specialization itself. Thus, the lambda expression
15624 // will be deemed as dependent even if there are no dependent template
15625 // arguments.
15626 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15627 while (DC->isRequiresExprBody())
15628 DC = DC->getParent();
15629 if ((getSema().isUnevaluatedContext() ||
15630 getSema().isConstantEvaluatedContext()) &&
15631 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15632 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15633
15634 CXXRecordDecl *OldClass = E->getLambdaClass();
15635 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15636 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15637 E->getCaptureDefault());
15638 getDerived().transformedLocalDecl(OldClass, {Class});
15639
15640 CXXMethodDecl *NewCallOperator =
15641 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15642
15643 // Enter the scope of the lambda.
15644 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15645 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15646 E->hasExplicitParameters(), E->isMutable());
15647
15648 // Introduce the context of the call operator.
15649 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15650 /*NewThisContext*/false);
15651
15652 bool Invalid = false;
15653
15654 // Transform captures.
15655 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15656 CEnd = E->capture_end();
15657 C != CEnd; ++C) {
15658 // When we hit the first implicit capture, tell Sema that we've finished
15659 // the list of explicit captures.
15660 if (C->isImplicit())
15661 break;
15662
15663 // Capturing 'this' is trivial.
15664 if (C->capturesThis()) {
15665 // If this is a lambda that is part of a default member initialiser
15666 // and which we're instantiating outside the class that 'this' is
15667 // supposed to refer to, adjust the type of 'this' accordingly.
15668 //
15669 // Otherwise, leave the type of 'this' as-is.
15670 Sema::CXXThisScopeRAII ThisScope(
15671 getSema(),
15672 dyn_cast_if_present<CXXRecordDecl>(
15673 getSema().getFunctionLevelDeclContext()),
15674 Qualifiers());
15675 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15676 /*BuildAndDiagnose*/ true, nullptr,
15677 C->getCaptureKind() == LCK_StarThis);
15678 continue;
15679 }
15680 // Captured expression will be recaptured during captured variables
15681 // rebuilding.
15682 if (C->capturesVLAType())
15683 continue;
15684
15685 // Rebuild init-captures, including the implied field declaration.
15686 if (E->isInitCapture(C)) {
15687 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15688
15689 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15691
15692 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15693 ExprResult Init = Info.first;
15694 QualType InitQualType = Info.second;
15695 if (Init.isInvalid() || InitQualType.isNull()) {
15696 Invalid = true;
15697 break;
15698 }
15699 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15700 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15701 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15702 getSema().CurContext);
15703 if (!NewVD) {
15704 Invalid = true;
15705 break;
15706 }
15707 NewVDs.push_back(NewVD);
15708 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15709 // Cases we want to tackle:
15710 // ([C(Pack)] {}, ...)
15711 // But rule out cases e.g.
15712 // [...C = Pack()] {}
15713 if (NewC.EllipsisLoc.isInvalid())
15714 LSI->ContainsUnexpandedParameterPack |=
15715 Init.get()->containsUnexpandedParameterPack();
15716 }
15717
15718 if (Invalid)
15719 break;
15720
15721 getDerived().transformedLocalDecl(OldVD, NewVDs);
15722 continue;
15723 }
15724
15725 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15726
15727 // Determine the capture kind for Sema.
15729 : C->getCaptureKind() == LCK_ByCopy
15732 SourceLocation EllipsisLoc;
15733 if (C->isPackExpansion()) {
15734 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15735 bool ShouldExpand = false;
15736 bool RetainExpansion = false;
15737 UnsignedOrNone NumExpansions = std::nullopt;
15738 if (getDerived().TryExpandParameterPacks(
15739 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
15740 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
15741 RetainExpansion, NumExpansions)) {
15742 Invalid = true;
15743 continue;
15744 }
15745
15746 if (ShouldExpand) {
15747 // The transform has determined that we should perform an expansion;
15748 // transform and capture each of the arguments.
15749 // expansion of the pattern. Do so.
15750 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
15751 for (unsigned I = 0; I != *NumExpansions; ++I) {
15752 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15753 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
15754 getDerived().TransformDecl(C->getLocation(), Pack));
15755 if (!CapturedVar) {
15756 Invalid = true;
15757 continue;
15758 }
15759
15760 // Capture the transformed variable.
15761 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
15762 }
15763
15764 // FIXME: Retain a pack expansion if RetainExpansion is true.
15765
15766 continue;
15767 }
15768
15769 EllipsisLoc = C->getEllipsisLoc();
15770 }
15771
15772 // Transform the captured variable.
15773 auto *CapturedVar = cast_or_null<ValueDecl>(
15774 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15775 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
15776 Invalid = true;
15777 continue;
15778 }
15779
15780 // This is not an init-capture; however it contains an unexpanded pack e.g.
15781 // ([Pack] {}(), ...)
15782 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
15783 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
15784
15785 // Capture the transformed variable.
15786 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
15787 EllipsisLoc);
15788 }
15789 getSema().finishLambdaExplicitCaptures(LSI);
15790
15791 // Transform the template parameters, and add them to the current
15792 // instantiation scope. The null case is handled correctly.
15793 auto TPL = getDerived().TransformTemplateParameterList(
15794 E->getTemplateParameterList());
15795 LSI->GLTemplateParameterList = TPL;
15796 if (TPL) {
15797 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
15798 TPL);
15799 LSI->ContainsUnexpandedParameterPack |=
15800 TPL->containsUnexpandedParameterPack();
15801 }
15802
15803 TypeLocBuilder NewCallOpTLBuilder;
15804 TypeLoc OldCallOpTypeLoc =
15805 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
15806 QualType NewCallOpType =
15807 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
15808 if (NewCallOpType.isNull())
15809 return ExprError();
15810 LSI->ContainsUnexpandedParameterPack |=
15811 NewCallOpType->containsUnexpandedParameterPack();
15812 TypeSourceInfo *NewCallOpTSI =
15813 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
15814
15815 // The type may be an AttributedType or some other kind of sugar;
15816 // get the actual underlying FunctionProtoType.
15817 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
15818 assert(FPTL && "Not a FunctionProtoType?");
15819
15820 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
15821 if (!TRC.ArgPackSubstIndex)
15823
15824 getSema().CompleteLambdaCallOperator(
15825 NewCallOperator, E->getCallOperator()->getLocation(),
15826 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
15827 E->getCallOperator()->getConstexprKind(),
15828 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
15829 E->hasExplicitResultType());
15830
15831 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
15832 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
15833
15834 {
15835 // Number the lambda for linkage purposes if necessary.
15836 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
15837
15838 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
15839 if (getDerived().ReplacingOriginal()) {
15840 Numbering = OldClass->getLambdaNumbering();
15841 }
15842
15843 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
15844 }
15845
15846 // FIXME: Sema's lambda-building mechanism expects us to push an expression
15847 // evaluation context even if we're not transforming the function body.
15848 getSema().PushExpressionEvaluationContextForFunction(
15850 E->getCallOperator());
15851
15852 StmtResult Body;
15853 {
15854 Sema::NonSFINAEContext _(getSema());
15857 C.PointOfInstantiation = E->getBody()->getBeginLoc();
15858 getSema().pushCodeSynthesisContext(C);
15859
15860 // Instantiate the body of the lambda expression.
15861 Body = Invalid ? StmtError()
15862 : getDerived().TransformLambdaBody(E, E->getBody());
15863
15864 getSema().popCodeSynthesisContext();
15865 }
15866
15867 // ActOnLambda* will pop the function scope for us.
15868 FuncScopeCleanup.disable();
15869
15870 if (Body.isInvalid()) {
15871 SavedContext.pop();
15872 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
15873 /*IsInstantiation=*/true);
15874 return ExprError();
15875 }
15876
15877 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
15878 /*IsInstantiation=*/true,
15879 /*RetainFunctionScopeInfo=*/true);
15880 SavedContext.pop();
15881
15882 // Recompute the dependency of the lambda so that we can defer the lambda call
15883 // construction until after we have all the necessary template arguments. For
15884 // example, given
15885 //
15886 // template <class> struct S {
15887 // template <class U>
15888 // using Type = decltype([](U){}(42.0));
15889 // };
15890 // void foo() {
15891 // using T = S<int>::Type<float>;
15892 // ^~~~~~
15893 // }
15894 //
15895 // We would end up here from instantiating S<int> when ensuring its
15896 // completeness. That would transform the lambda call expression regardless of
15897 // the absence of the corresponding argument for U.
15898 //
15899 // Going ahead with unsubstituted type U makes things worse: we would soon
15900 // compare the argument type (which is float) against the parameter U
15901 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
15902 // error suggesting unmatched types 'U' and 'float'!
15903 //
15904 // That said, everything will be fine if we defer that semantic checking.
15905 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
15906 // dependent. Since the CallExpr's dependency boils down to the lambda's
15907 // dependency in this case, we can harness that by recomputing the dependency
15908 // from the instantiation arguments.
15909 //
15910 // FIXME: Creating the type of a lambda requires us to have a dependency
15911 // value, which happens before its substitution. We update its dependency
15912 // *after* the substitution in case we can't decide the dependency
15913 // so early, e.g. because we want to see if any of the *substituted*
15914 // parameters are dependent.
15915 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
15916 Class->setLambdaDependencyKind(DependencyKind);
15917
15918 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
15919 Body.get()->getEndLoc(), LSI);
15920}
15921
15922template<typename Derived>
15927
15928template<typename Derived>
15931 // Transform captures.
15933 CEnd = E->capture_end();
15934 C != CEnd; ++C) {
15935 // When we hit the first implicit capture, tell Sema that we've finished
15936 // the list of explicit captures.
15937 if (!C->isImplicit())
15938 continue;
15939
15940 // Capturing 'this' is trivial.
15941 if (C->capturesThis()) {
15942 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15943 /*BuildAndDiagnose*/ true, nullptr,
15944 C->getCaptureKind() == LCK_StarThis);
15945 continue;
15946 }
15947 // Captured expression will be recaptured during captured variables
15948 // rebuilding.
15949 if (C->capturesVLAType())
15950 continue;
15951
15952 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15953 assert(!E->isInitCapture(C) && "implicit init-capture?");
15954
15955 // Transform the captured variable.
15956 VarDecl *CapturedVar = cast_or_null<VarDecl>(
15957 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15958 if (!CapturedVar || CapturedVar->isInvalidDecl())
15959 return StmtError();
15960
15961 // Capture the transformed variable.
15962 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
15963 }
15964
15965 return S;
15966}
15967
15968template<typename Derived>
15972 TypeSourceInfo *T =
15973 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15974 if (!T)
15975 return ExprError();
15976
15977 bool ArgumentChanged = false;
15979 Args.reserve(E->getNumArgs());
15980 {
15984 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
15985 &ArgumentChanged))
15986 return ExprError();
15987 }
15988
15989 if (!getDerived().AlwaysRebuild() &&
15990 T == E->getTypeSourceInfo() &&
15991 !ArgumentChanged)
15992 return E;
15993
15994 // FIXME: we're faking the locations of the commas
15995 return getDerived().RebuildCXXUnresolvedConstructExpr(
15996 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
15997}
15998
15999template<typename Derived>
16003 // Transform the base of the expression.
16004 ExprResult Base((Expr*) nullptr);
16005 Expr *OldBase;
16006 QualType BaseType;
16007 QualType ObjectType;
16008 if (!E->isImplicitAccess()) {
16009 OldBase = E->getBase();
16010 Base = getDerived().TransformExpr(OldBase);
16011 if (Base.isInvalid())
16012 return ExprError();
16013
16014 // Start the member reference and compute the object's type.
16015 ParsedType ObjectTy;
16016 bool MayBePseudoDestructor = false;
16017 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16018 E->getOperatorLoc(),
16019 E->isArrow()? tok::arrow : tok::period,
16020 ObjectTy,
16021 MayBePseudoDestructor);
16022 if (Base.isInvalid())
16023 return ExprError();
16024
16025 ObjectType = ObjectTy.get();
16026 BaseType = ((Expr*) Base.get())->getType();
16027 } else {
16028 OldBase = nullptr;
16029 BaseType = getDerived().TransformType(E->getBaseType());
16030 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16031 }
16032
16033 // Transform the first part of the nested-name-specifier that qualifies
16034 // the member name.
16035 NamedDecl *FirstQualifierInScope
16036 = getDerived().TransformFirstQualifierInScope(
16037 E->getFirstQualifierFoundInScope(),
16038 E->getQualifierLoc().getBeginLoc());
16039
16040 NestedNameSpecifierLoc QualifierLoc;
16041 if (E->getQualifier()) {
16042 QualifierLoc
16043 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16044 ObjectType,
16045 FirstQualifierInScope);
16046 if (!QualifierLoc)
16047 return ExprError();
16048 }
16049
16050 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16051
16052 // TODO: If this is a conversion-function-id, verify that the
16053 // destination type name (if present) resolves the same way after
16054 // instantiation as it did in the local scope.
16055
16056 DeclarationNameInfo NameInfo
16057 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16058 if (!NameInfo.getName())
16059 return ExprError();
16060
16061 if (!E->hasExplicitTemplateArgs()) {
16062 // This is a reference to a member without an explicitly-specified
16063 // template argument list. Optimize for this common case.
16064 if (!getDerived().AlwaysRebuild() &&
16065 Base.get() == OldBase &&
16066 BaseType == E->getBaseType() &&
16067 QualifierLoc == E->getQualifierLoc() &&
16068 NameInfo.getName() == E->getMember() &&
16069 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16070 return E;
16071
16072 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16073 BaseType,
16074 E->isArrow(),
16075 E->getOperatorLoc(),
16076 QualifierLoc,
16077 TemplateKWLoc,
16078 FirstQualifierInScope,
16079 NameInfo,
16080 /*TemplateArgs*/nullptr);
16081 }
16082
16083 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16084 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16085 E->getNumTemplateArgs(),
16086 TransArgs))
16087 return ExprError();
16088
16089 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16090 BaseType,
16091 E->isArrow(),
16092 E->getOperatorLoc(),
16093 QualifierLoc,
16094 TemplateKWLoc,
16095 FirstQualifierInScope,
16096 NameInfo,
16097 &TransArgs);
16098}
16099
16100template <typename Derived>
16102 UnresolvedMemberExpr *Old) {
16103 // Transform the base of the expression.
16104 ExprResult Base((Expr *)nullptr);
16105 QualType BaseType;
16106 if (!Old->isImplicitAccess()) {
16107 Base = getDerived().TransformExpr(Old->getBase());
16108 if (Base.isInvalid())
16109 return ExprError();
16110 Base =
16111 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16112 if (Base.isInvalid())
16113 return ExprError();
16114 BaseType = Base.get()->getType();
16115 } else {
16116 BaseType = getDerived().TransformType(Old->getBaseType());
16117 }
16118
16119 NestedNameSpecifierLoc QualifierLoc;
16120 if (Old->getQualifierLoc()) {
16121 QualifierLoc =
16122 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16123 if (!QualifierLoc)
16124 return ExprError();
16125 }
16126
16127 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16128
16129 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16130
16131 // Transform the declaration set.
16132 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16133 return ExprError();
16134
16135 // Determine the naming class.
16136 if (Old->getNamingClass()) {
16137 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16138 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16139 if (!NamingClass)
16140 return ExprError();
16141
16142 R.setNamingClass(NamingClass);
16143 }
16144
16145 TemplateArgumentListInfo TransArgs;
16146 if (Old->hasExplicitTemplateArgs()) {
16147 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16148 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16149 if (getDerived().TransformTemplateArguments(
16150 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16151 return ExprError();
16152 }
16153
16154 // FIXME: to do this check properly, we will need to preserve the
16155 // first-qualifier-in-scope here, just in case we had a dependent
16156 // base (and therefore couldn't do the check) and a
16157 // nested-name-qualifier (and therefore could do the lookup).
16158 NamedDecl *FirstQualifierInScope = nullptr;
16159
16160 return getDerived().RebuildUnresolvedMemberExpr(
16161 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16162 TemplateKWLoc, FirstQualifierInScope, R,
16163 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16164}
16165
16166template<typename Derived>
16171 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16172 if (SubExpr.isInvalid())
16173 return ExprError();
16174
16175 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16176 return E;
16177
16178 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16179}
16180
16181template<typename Derived>
16184 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16185 if (Pattern.isInvalid())
16186 return ExprError();
16187
16188 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16189 return E;
16190
16191 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16192 E->getNumExpansions());
16193}
16194
16195template <typename Derived>
16197 ArrayRef<TemplateArgument> PackArgs) {
16199 for (const TemplateArgument &Arg : PackArgs) {
16200 if (!Arg.isPackExpansion()) {
16201 Result = *Result + 1;
16202 continue;
16203 }
16204
16205 TemplateArgumentLoc ArgLoc;
16206 InventTemplateArgumentLoc(Arg, ArgLoc);
16207
16208 // Find the pattern of the pack expansion.
16209 SourceLocation Ellipsis;
16210 UnsignedOrNone OrigNumExpansions = std::nullopt;
16211 TemplateArgumentLoc Pattern =
16212 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16213 OrigNumExpansions);
16214
16215 // Substitute under the pack expansion. Do not expand the pack (yet).
16216 TemplateArgumentLoc OutPattern;
16217 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16218 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16219 /*Uneval*/ true))
16220 return 1u;
16221
16222 // See if we can determine the number of arguments from the result.
16223 UnsignedOrNone NumExpansions =
16224 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16225 if (!NumExpansions) {
16226 // No: we must be in an alias template expansion, and we're going to
16227 // need to actually expand the packs.
16228 Result = std::nullopt;
16229 break;
16230 }
16231
16232 Result = *Result + *NumExpansions;
16233 }
16234 return Result;
16235}
16236
16237template<typename Derived>
16240 // If E is not value-dependent, then nothing will change when we transform it.
16241 // Note: This is an instantiation-centric view.
16242 if (!E->isValueDependent())
16243 return E;
16244
16247
16249 TemplateArgument ArgStorage;
16250
16251 // Find the argument list to transform.
16252 if (E->isPartiallySubstituted()) {
16253 PackArgs = E->getPartialArguments();
16254 } else if (E->isValueDependent()) {
16255 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16256 bool ShouldExpand = false;
16257 bool RetainExpansion = false;
16258 UnsignedOrNone NumExpansions = std::nullopt;
16259 if (getDerived().TryExpandParameterPacks(
16260 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16261 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16262 RetainExpansion, NumExpansions))
16263 return ExprError();
16264
16265 // If we need to expand the pack, build a template argument from it and
16266 // expand that.
16267 if (ShouldExpand) {
16268 auto *Pack = E->getPack();
16269 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16270 ArgStorage = getSema().Context.getPackExpansionType(
16271 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16272 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16273 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16274 } else {
16275 auto *VD = cast<ValueDecl>(Pack);
16276 ExprResult DRE = getSema().BuildDeclRefExpr(
16277 VD, VD->getType().getNonLValueExprType(getSema().Context),
16278 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16279 E->getPackLoc());
16280 if (DRE.isInvalid())
16281 return ExprError();
16282 ArgStorage = TemplateArgument(
16283 new (getSema().Context)
16284 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16285 /*IsCanonical=*/false);
16286 }
16287 PackArgs = ArgStorage;
16288 }
16289 }
16290
16291 // If we're not expanding the pack, just transform the decl.
16292 if (!PackArgs.size()) {
16293 auto *Pack = cast_or_null<NamedDecl>(
16294 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16295 if (!Pack)
16296 return ExprError();
16297 return getDerived().RebuildSizeOfPackExpr(
16298 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16299 std::nullopt, {});
16300 }
16301
16302 // Try to compute the result without performing a partial substitution.
16304 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16305
16306 // Common case: we could determine the number of expansions without
16307 // substituting.
16308 if (Result)
16309 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16310 E->getPackLoc(),
16311 E->getRParenLoc(), *Result, {});
16312
16313 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16314 E->getPackLoc());
16315 {
16316 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16318 Derived, const TemplateArgument*> PackLocIterator;
16319 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16320 PackLocIterator(*this, PackArgs.end()),
16321 TransformedPackArgs, /*Uneval*/true))
16322 return ExprError();
16323 }
16324
16325 // Check whether we managed to fully-expand the pack.
16326 // FIXME: Is it possible for us to do so and not hit the early exit path?
16328 bool PartialSubstitution = false;
16329 for (auto &Loc : TransformedPackArgs.arguments()) {
16330 Args.push_back(Loc.getArgument());
16331 if (Loc.getArgument().isPackExpansion())
16332 PartialSubstitution = true;
16333 }
16334
16335 if (PartialSubstitution)
16336 return getDerived().RebuildSizeOfPackExpr(
16337 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16338 std::nullopt, Args);
16339
16340 return getDerived().RebuildSizeOfPackExpr(
16341 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16342 /*Length=*/static_cast<unsigned>(Args.size()),
16343 /*PartialArgs=*/{});
16344}
16345
16346template <typename Derived>
16349 if (!E->isValueDependent())
16350 return E;
16351
16352 // Transform the index
16353 ExprResult IndexExpr;
16354 {
16355 EnterExpressionEvaluationContext ConstantContext(
16357 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16358 if (IndexExpr.isInvalid())
16359 return ExprError();
16360 }
16361
16362 SmallVector<Expr *, 5> ExpandedExprs;
16363 bool FullySubstituted = true;
16364 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16365 Expr *Pattern = E->getPackIdExpression();
16367 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16368 Unexpanded);
16369 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16370
16371 // Determine whether the set of unexpanded parameter packs can and should
16372 // be expanded.
16373 bool ShouldExpand = true;
16374 bool RetainExpansion = false;
16375 UnsignedOrNone OrigNumExpansions = std::nullopt,
16376 NumExpansions = std::nullopt;
16377 if (getDerived().TryExpandParameterPacks(
16378 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16379 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16380 RetainExpansion, NumExpansions))
16381 return true;
16382 if (!ShouldExpand) {
16383 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16384 ExprResult Pack = getDerived().TransformExpr(Pattern);
16385 if (Pack.isInvalid())
16386 return ExprError();
16387 return getDerived().RebuildPackIndexingExpr(
16388 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16389 {}, /*FullySubstituted=*/false);
16390 }
16391 for (unsigned I = 0; I != *NumExpansions; ++I) {
16392 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16393 ExprResult Out = getDerived().TransformExpr(Pattern);
16394 if (Out.isInvalid())
16395 return true;
16396 if (Out.get()->containsUnexpandedParameterPack()) {
16397 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16398 OrigNumExpansions);
16399 if (Out.isInvalid())
16400 return true;
16401 FullySubstituted = false;
16402 }
16403 ExpandedExprs.push_back(Out.get());
16404 }
16405 // If we're supposed to retain a pack expansion, do so by temporarily
16406 // forgetting the partially-substituted parameter pack.
16407 if (RetainExpansion) {
16408 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16409
16410 ExprResult Out = getDerived().TransformExpr(Pattern);
16411 if (Out.isInvalid())
16412 return true;
16413
16414 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16415 OrigNumExpansions);
16416 if (Out.isInvalid())
16417 return true;
16418 FullySubstituted = false;
16419 ExpandedExprs.push_back(Out.get());
16420 }
16421 } else if (!E->expandsToEmptyPack()) {
16422 if (getDerived().TransformExprs(E->getExpressions().data(),
16423 E->getExpressions().size(), false,
16424 ExpandedExprs))
16425 return ExprError();
16426 }
16427
16428 return getDerived().RebuildPackIndexingExpr(
16429 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16430 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16431}
16432
16433template <typename Derived>
16436 if (!getSema().ArgPackSubstIndex)
16437 // We aren't expanding the parameter pack, so just return ourselves.
16438 return E;
16439
16440 TemplateArgument Pack = E->getArgumentPack();
16442 return SemaRef.BuildSubstNonTypeTemplateParmExpr(
16443 E->getAssociatedDecl(), E->getParameterPack(),
16444 E->getParameterPackLocation(), Arg, SemaRef.getPackIndex(Pack),
16445 E->getFinal());
16446}
16447
16448template <typename Derived>
16451 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16452 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16453 if (Replacement.isInvalid())
16454 return true;
16455
16456 Decl *AssociatedDecl =
16457 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16458 if (!AssociatedDecl)
16459 return true;
16460
16461 if (Replacement.get() == OrigReplacement &&
16462 AssociatedDecl == E->getAssociatedDecl())
16463 return E;
16464
16465 auto getParamAndType = [E](Decl *AssociatedDecl)
16466 -> std::tuple<NonTypeTemplateParmDecl *, QualType> {
16467 auto [PDecl, Arg] =
16468 getReplacedTemplateParameter(AssociatedDecl, E->getIndex());
16469 auto *Param = cast<NonTypeTemplateParmDecl>(PDecl);
16470 if (Arg.isNull())
16471 return {Param, Param->getType()};
16472 if (UnsignedOrNone PackIndex = E->getPackIndex())
16473 Arg = Arg.getPackAsArray()[*PackIndex];
16474 return {Param, Arg.getNonTypeTemplateArgumentType()};
16475 };
16476
16477 // If the replacement expression did not change, and the parameter type
16478 // did not change, we can skip the semantic action because it would
16479 // produce the same result anyway.
16480 if (auto [Param, ParamType] = getParamAndType(AssociatedDecl);
16481 !SemaRef.Context.hasSameType(
16482 ParamType, std::get<1>(getParamAndType(E->getAssociatedDecl()))) ||
16483 Replacement.get() != OrigReplacement) {
16484 // When transforming the replacement expression previously, all Sema
16485 // specific annotations, such as implicit casts, are discarded. Calling the
16486 // corresponding sema action is necessary to recover those. Otherwise,
16487 // equivalency of the result would be lost.
16488 TemplateArgument SugaredConverted, CanonicalConverted;
16489 Replacement = SemaRef.CheckTemplateArgument(
16490 Param, ParamType, Replacement.get(), SugaredConverted,
16491 CanonicalConverted,
16492 /*StrictCheck=*/false, Sema::CTAK_Specified);
16493 if (Replacement.isInvalid())
16494 return true;
16495 } else {
16496 // Otherwise, the same expression would have been produced.
16497 Replacement = E->getReplacement();
16498 }
16499
16500 return new (SemaRef.Context) SubstNonTypeTemplateParmExpr(
16501 Replacement.get()->getType(), Replacement.get()->getValueKind(),
16502 E->getNameLoc(), Replacement.get(), AssociatedDecl, E->getIndex(),
16503 E->getPackIndex(), E->isReferenceParameter(), E->getFinal());
16504}
16505
16506template<typename Derived>
16509 // Default behavior is to do nothing with this transformation.
16510 return E;
16511}
16512
16513template<typename Derived>
16517 return getDerived().TransformExpr(E->getSubExpr());
16518}
16519
16520template<typename Derived>
16523 UnresolvedLookupExpr *Callee = nullptr;
16524 if (Expr *OldCallee = E->getCallee()) {
16525 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16526 if (CalleeResult.isInvalid())
16527 return ExprError();
16528 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16529 }
16530
16531 Expr *Pattern = E->getPattern();
16532
16534 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16535 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16536
16537 // Determine whether the set of unexpanded parameter packs can and should
16538 // be expanded.
16539 bool Expand = true;
16540 bool RetainExpansion = false;
16541 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16542 NumExpansions = OrigNumExpansions;
16543 if (getDerived().TryExpandParameterPacks(
16544 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16545 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16546 NumExpansions))
16547 return true;
16548
16549 if (!Expand) {
16550 // Do not expand any packs here, just transform and rebuild a fold
16551 // expression.
16552 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16553
16554 ExprResult LHS =
16555 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16556 if (LHS.isInvalid())
16557 return true;
16558
16559 ExprResult RHS =
16560 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16561 if (RHS.isInvalid())
16562 return true;
16563
16564 if (!getDerived().AlwaysRebuild() &&
16565 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16566 return E;
16567
16568 return getDerived().RebuildCXXFoldExpr(
16569 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16570 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16571 }
16572
16573 // Formally a fold expression expands to nested parenthesized expressions.
16574 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16575 // them.
16576 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16577 SemaRef.Diag(E->getEllipsisLoc(),
16578 clang::diag::err_fold_expression_limit_exceeded)
16579 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16580 << E->getSourceRange();
16581 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16582 return ExprError();
16583 }
16584
16585 // The transform has determined that we should perform an elementwise
16586 // expansion of the pattern. Do so.
16587 ExprResult Result = getDerived().TransformExpr(E->getInit());
16588 if (Result.isInvalid())
16589 return true;
16590 bool LeftFold = E->isLeftFold();
16591
16592 // If we're retaining an expansion for a right fold, it is the innermost
16593 // component and takes the init (if any).
16594 if (!LeftFold && RetainExpansion) {
16595 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16596
16597 ExprResult Out = getDerived().TransformExpr(Pattern);
16598 if (Out.isInvalid())
16599 return true;
16600
16601 Result = getDerived().RebuildCXXFoldExpr(
16602 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16603 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16604 if (Result.isInvalid())
16605 return true;
16606 }
16607
16608 bool WarnedOnComparison = false;
16609 for (unsigned I = 0; I != *NumExpansions; ++I) {
16610 Sema::ArgPackSubstIndexRAII SubstIndex(
16611 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16612 ExprResult Out = getDerived().TransformExpr(Pattern);
16613 if (Out.isInvalid())
16614 return true;
16615
16616 if (Out.get()->containsUnexpandedParameterPack()) {
16617 // We still have a pack; retain a pack expansion for this slice.
16618 Result = getDerived().RebuildCXXFoldExpr(
16619 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16620 E->getOperator(), E->getEllipsisLoc(),
16621 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16622 OrigNumExpansions);
16623 } else if (Result.isUsable()) {
16624 // We've got down to a single element; build a binary operator.
16625 Expr *LHS = LeftFold ? Result.get() : Out.get();
16626 Expr *RHS = LeftFold ? Out.get() : Result.get();
16627 if (Callee) {
16628 UnresolvedSet<16> Functions;
16629 Functions.append(Callee->decls_begin(), Callee->decls_end());
16630 Result = getDerived().RebuildCXXOperatorCallExpr(
16631 BinaryOperator::getOverloadedOperator(E->getOperator()),
16632 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16633 Functions, LHS, RHS);
16634 } else {
16635 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16636 E->getOperator(), LHS, RHS,
16637 /*ForFoldExpresion=*/true);
16638 if (!WarnedOnComparison && Result.isUsable()) {
16639 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16640 BO && BO->isComparisonOp()) {
16641 WarnedOnComparison = true;
16642 SemaRef.Diag(BO->getBeginLoc(),
16643 diag::warn_comparison_in_fold_expression)
16644 << BO->getOpcodeStr();
16645 }
16646 }
16647 }
16648 } else
16649 Result = Out;
16650
16651 if (Result.isInvalid())
16652 return true;
16653 }
16654
16655 // If we're retaining an expansion for a left fold, it is the outermost
16656 // component and takes the complete expansion so far as its init (if any).
16657 if (LeftFold && RetainExpansion) {
16658 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16659
16660 ExprResult Out = getDerived().TransformExpr(Pattern);
16661 if (Out.isInvalid())
16662 return true;
16663
16664 Result = getDerived().RebuildCXXFoldExpr(
16665 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16666 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16667 if (Result.isInvalid())
16668 return true;
16669 }
16670
16671 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16672 PE->setIsProducedByFoldExpansion();
16673
16674 // If we had no init and an empty pack, and we're not retaining an expansion,
16675 // then produce a fallback value or error.
16676 if (Result.isUnset())
16677 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16678 E->getOperator());
16679 return Result;
16680}
16681
16682template <typename Derived>
16685 SmallVector<Expr *, 4> TransformedInits;
16686 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16687
16688 QualType T = getDerived().TransformType(E->getType());
16689
16690 bool ArgChanged = false;
16691
16692 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16693 TransformedInits, &ArgChanged))
16694 return ExprError();
16695
16696 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16697 return E;
16698
16699 return getDerived().RebuildCXXParenListInitExpr(
16700 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16701 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16702}
16703
16704template<typename Derived>
16708 return getDerived().TransformExpr(E->getSubExpr());
16709}
16710
16711template<typename Derived>
16714 return SemaRef.MaybeBindToTemporary(E);
16715}
16716
16717template<typename Derived>
16720 return E;
16721}
16722
16723template<typename Derived>
16726 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16727 if (SubExpr.isInvalid())
16728 return ExprError();
16729
16730 if (!getDerived().AlwaysRebuild() &&
16731 SubExpr.get() == E->getSubExpr())
16732 return E;
16733
16734 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16735}
16736
16737template<typename Derived>
16740 // Transform each of the elements.
16741 SmallVector<Expr *, 8> Elements;
16742 bool ArgChanged = false;
16743 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
16744 /*IsCall=*/false, Elements, &ArgChanged))
16745 return ExprError();
16746
16747 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16748 return SemaRef.MaybeBindToTemporary(E);
16749
16750 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
16751 Elements.data(),
16752 Elements.size());
16753}
16754
16755template<typename Derived>
16759 // Transform each of the elements.
16761 bool ArgChanged = false;
16762 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
16763 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
16764
16765 if (OrigElement.isPackExpansion()) {
16766 // This key/value element is a pack expansion.
16768 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
16769 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
16770 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16771
16772 // Determine whether the set of unexpanded parameter packs can
16773 // and should be expanded.
16774 bool Expand = true;
16775 bool RetainExpansion = false;
16776 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
16777 UnsignedOrNone NumExpansions = OrigNumExpansions;
16778 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
16779 OrigElement.Value->getEndLoc());
16780 if (getDerived().TryExpandParameterPacks(
16781 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
16782 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16783 NumExpansions))
16784 return ExprError();
16785
16786 if (!Expand) {
16787 // The transform has determined that we should perform a simple
16788 // transformation on the pack expansion, producing another pack
16789 // expansion.
16790 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16791 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16792 if (Key.isInvalid())
16793 return ExprError();
16794
16795 if (Key.get() != OrigElement.Key)
16796 ArgChanged = true;
16797
16798 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16799 if (Value.isInvalid())
16800 return ExprError();
16801
16802 if (Value.get() != OrigElement.Value)
16803 ArgChanged = true;
16804
16805 ObjCDictionaryElement Expansion = {
16806 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
16807 };
16808 Elements.push_back(Expansion);
16809 continue;
16810 }
16811
16812 // Record right away that the argument was changed. This needs
16813 // to happen even if the array expands to nothing.
16814 ArgChanged = true;
16815
16816 // The transform has determined that we should perform an elementwise
16817 // expansion of the pattern. Do so.
16818 for (unsigned I = 0; I != *NumExpansions; ++I) {
16819 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16820 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16821 if (Key.isInvalid())
16822 return ExprError();
16823
16824 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16825 if (Value.isInvalid())
16826 return ExprError();
16827
16828 ObjCDictionaryElement Element = {
16829 Key.get(), Value.get(), SourceLocation(), NumExpansions
16830 };
16831
16832 // If any unexpanded parameter packs remain, we still have a
16833 // pack expansion.
16834 // FIXME: Can this really happen?
16835 if (Key.get()->containsUnexpandedParameterPack() ||
16836 Value.get()->containsUnexpandedParameterPack())
16837 Element.EllipsisLoc = OrigElement.EllipsisLoc;
16838
16839 Elements.push_back(Element);
16840 }
16841
16842 // FIXME: Retain a pack expansion if RetainExpansion is true.
16843
16844 // We've finished with this pack expansion.
16845 continue;
16846 }
16847
16848 // Transform and check key.
16849 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16850 if (Key.isInvalid())
16851 return ExprError();
16852
16853 if (Key.get() != OrigElement.Key)
16854 ArgChanged = true;
16855
16856 // Transform and check value.
16858 = getDerived().TransformExpr(OrigElement.Value);
16859 if (Value.isInvalid())
16860 return ExprError();
16861
16862 if (Value.get() != OrigElement.Value)
16863 ArgChanged = true;
16864
16865 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
16866 std::nullopt};
16867 Elements.push_back(Element);
16868 }
16869
16870 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16871 return SemaRef.MaybeBindToTemporary(E);
16872
16873 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
16874 Elements);
16875}
16876
16877template<typename Derived>
16880 TypeSourceInfo *EncodedTypeInfo
16881 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
16882 if (!EncodedTypeInfo)
16883 return ExprError();
16884
16885 if (!getDerived().AlwaysRebuild() &&
16886 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
16887 return E;
16888
16889 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
16890 EncodedTypeInfo,
16891 E->getRParenLoc());
16892}
16893
16894template<typename Derived>
16897 // This is a kind of implicit conversion, and it needs to get dropped
16898 // and recomputed for the same general reasons that ImplicitCastExprs
16899 // do, as well a more specific one: this expression is only valid when
16900 // it appears *immediately* as an argument expression.
16901 return getDerived().TransformExpr(E->getSubExpr());
16902}
16903
16904template<typename Derived>
16907 TypeSourceInfo *TSInfo
16908 = getDerived().TransformType(E->getTypeInfoAsWritten());
16909 if (!TSInfo)
16910 return ExprError();
16911
16912 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
16913 if (Result.isInvalid())
16914 return ExprError();
16915
16916 if (!getDerived().AlwaysRebuild() &&
16917 TSInfo == E->getTypeInfoAsWritten() &&
16918 Result.get() == E->getSubExpr())
16919 return E;
16920
16921 return SemaRef.ObjC().BuildObjCBridgedCast(
16922 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
16923 Result.get());
16924}
16925
16926template <typename Derived>
16929 return E;
16930}
16931
16932template<typename Derived>
16935 // Transform arguments.
16936 bool ArgChanged = false;
16938 Args.reserve(E->getNumArgs());
16939 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
16940 &ArgChanged))
16941 return ExprError();
16942
16943 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
16944 // Class message: transform the receiver type.
16945 TypeSourceInfo *ReceiverTypeInfo
16946 = getDerived().TransformType(E->getClassReceiverTypeInfo());
16947 if (!ReceiverTypeInfo)
16948 return ExprError();
16949
16950 // If nothing changed, just retain the existing message send.
16951 if (!getDerived().AlwaysRebuild() &&
16952 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
16953 return SemaRef.MaybeBindToTemporary(E);
16954
16955 // Build a new class message send.
16957 E->getSelectorLocs(SelLocs);
16958 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
16959 E->getSelector(),
16960 SelLocs,
16961 E->getMethodDecl(),
16962 E->getLeftLoc(),
16963 Args,
16964 E->getRightLoc());
16965 }
16966 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
16967 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
16968 if (!E->getMethodDecl())
16969 return ExprError();
16970
16971 // Build a new class message send to 'super'.
16973 E->getSelectorLocs(SelLocs);
16974 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
16975 E->getSelector(),
16976 SelLocs,
16977 E->getReceiverType(),
16978 E->getMethodDecl(),
16979 E->getLeftLoc(),
16980 Args,
16981 E->getRightLoc());
16982 }
16983
16984 // Instance message: transform the receiver
16985 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
16986 "Only class and instance messages may be instantiated");
16987 ExprResult Receiver
16988 = getDerived().TransformExpr(E->getInstanceReceiver());
16989 if (Receiver.isInvalid())
16990 return ExprError();
16991
16992 // If nothing changed, just retain the existing message send.
16993 if (!getDerived().AlwaysRebuild() &&
16994 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
16995 return SemaRef.MaybeBindToTemporary(E);
16996
16997 // Build a new instance message send.
16999 E->getSelectorLocs(SelLocs);
17000 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17001 E->getSelector(),
17002 SelLocs,
17003 E->getMethodDecl(),
17004 E->getLeftLoc(),
17005 Args,
17006 E->getRightLoc());
17007}
17008
17009template<typename Derived>
17012 return E;
17013}
17014
17015template<typename Derived>
17018 return E;
17019}
17020
17021template<typename Derived>
17024 // Transform the base expression.
17025 ExprResult Base = getDerived().TransformExpr(E->getBase());
17026 if (Base.isInvalid())
17027 return ExprError();
17028
17029 // We don't need to transform the ivar; it will never change.
17030
17031 // If nothing changed, just retain the existing expression.
17032 if (!getDerived().AlwaysRebuild() &&
17033 Base.get() == E->getBase())
17034 return E;
17035
17036 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17037 E->getLocation(),
17038 E->isArrow(), E->isFreeIvar());
17039}
17040
17041template<typename Derived>
17044 // 'super' and types never change. Property never changes. Just
17045 // retain the existing expression.
17046 if (!E->isObjectReceiver())
17047 return E;
17048
17049 // Transform the base expression.
17050 ExprResult Base = getDerived().TransformExpr(E->getBase());
17051 if (Base.isInvalid())
17052 return ExprError();
17053
17054 // We don't need to transform the property; it will never change.
17055
17056 // If nothing changed, just retain the existing expression.
17057 if (!getDerived().AlwaysRebuild() &&
17058 Base.get() == E->getBase())
17059 return E;
17060
17061 if (E->isExplicitProperty())
17062 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17063 E->getExplicitProperty(),
17064 E->getLocation());
17065
17066 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17067 SemaRef.Context.PseudoObjectTy,
17068 E->getImplicitPropertyGetter(),
17069 E->getImplicitPropertySetter(),
17070 E->getLocation());
17071}
17072
17073template<typename Derived>
17076 // Transform the base expression.
17077 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17078 if (Base.isInvalid())
17079 return ExprError();
17080
17081 // Transform the key expression.
17082 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17083 if (Key.isInvalid())
17084 return ExprError();
17085
17086 // If nothing changed, just retain the existing expression.
17087 if (!getDerived().AlwaysRebuild() &&
17088 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17089 return E;
17090
17091 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17092 Base.get(), Key.get(),
17093 E->getAtIndexMethodDecl(),
17094 E->setAtIndexMethodDecl());
17095}
17096
17097template<typename Derived>
17100 // Transform the base expression.
17101 ExprResult Base = getDerived().TransformExpr(E->getBase());
17102 if (Base.isInvalid())
17103 return ExprError();
17104
17105 // If nothing changed, just retain the existing expression.
17106 if (!getDerived().AlwaysRebuild() &&
17107 Base.get() == E->getBase())
17108 return E;
17109
17110 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17111 E->getOpLoc(),
17112 E->isArrow());
17113}
17114
17115template<typename Derived>
17118 bool ArgumentChanged = false;
17119 SmallVector<Expr*, 8> SubExprs;
17120 SubExprs.reserve(E->getNumSubExprs());
17121 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17122 SubExprs, &ArgumentChanged))
17123 return ExprError();
17124
17125 if (!getDerived().AlwaysRebuild() &&
17126 !ArgumentChanged)
17127 return E;
17128
17129 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17130 SubExprs,
17131 E->getRParenLoc());
17132}
17133
17134template<typename Derived>
17137 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17138 if (SrcExpr.isInvalid())
17139 return ExprError();
17140
17141 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17142 if (!Type)
17143 return ExprError();
17144
17145 if (!getDerived().AlwaysRebuild() &&
17146 Type == E->getTypeSourceInfo() &&
17147 SrcExpr.get() == E->getSrcExpr())
17148 return E;
17149
17150 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17151 SrcExpr.get(), Type,
17152 E->getRParenLoc());
17153}
17154
17155template<typename Derived>
17158 BlockDecl *oldBlock = E->getBlockDecl();
17159
17160 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17161 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17162
17163 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17164 blockScope->TheDecl->setBlockMissingReturnType(
17165 oldBlock->blockMissingReturnType());
17166
17168 SmallVector<QualType, 4> paramTypes;
17169
17170 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17171
17172 // Parameter substitution.
17173 Sema::ExtParameterInfoBuilder extParamInfos;
17174 if (getDerived().TransformFunctionTypeParams(
17175 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17176 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17177 extParamInfos)) {
17178 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17179 return ExprError();
17180 }
17181
17182 QualType exprResultType =
17183 getDerived().TransformType(exprFunctionType->getReturnType());
17184
17185 auto epi = exprFunctionType->getExtProtoInfo();
17186 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17187
17189 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17190 blockScope->FunctionType = functionType;
17191
17192 // Set the parameters on the block decl.
17193 if (!params.empty())
17194 blockScope->TheDecl->setParams(params);
17195
17196 if (!oldBlock->blockMissingReturnType()) {
17197 blockScope->HasImplicitReturnType = false;
17198 blockScope->ReturnType = exprResultType;
17199 }
17200
17201 // Transform the body
17202 StmtResult body = getDerived().TransformStmt(E->getBody());
17203 if (body.isInvalid()) {
17204 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17205 return ExprError();
17206 }
17207
17208#ifndef NDEBUG
17209 // In builds with assertions, make sure that we captured everything we
17210 // captured before.
17211 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17212 for (const auto &I : oldBlock->captures()) {
17213 VarDecl *oldCapture = I.getVariable();
17214
17215 // Ignore parameter packs.
17216 if (oldCapture->isParameterPack())
17217 continue;
17218
17219 VarDecl *newCapture =
17220 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17221 oldCapture));
17222 assert(blockScope->CaptureMap.count(newCapture));
17223 }
17224
17225 // The this pointer may not be captured by the instantiated block, even when
17226 // it's captured by the original block, if the expression causing the
17227 // capture is in the discarded branch of a constexpr if statement.
17228 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17229 "this pointer isn't captured in the old block");
17230 }
17231#endif
17232
17233 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17234 /*Scope=*/nullptr);
17235}
17236
17237template<typename Derived>
17240 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17241 if (SrcExpr.isInvalid())
17242 return ExprError();
17243
17244 QualType Type = getDerived().TransformType(E->getType());
17245
17246 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17247 E->getRParenLoc());
17248}
17249
17250template<typename Derived>
17253 bool ArgumentChanged = false;
17254 SmallVector<Expr*, 8> SubExprs;
17255 SubExprs.reserve(E->getNumSubExprs());
17256 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17257 SubExprs, &ArgumentChanged))
17258 return ExprError();
17259
17260 if (!getDerived().AlwaysRebuild() &&
17261 !ArgumentChanged)
17262 return E;
17263
17264 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17265 E->getOp(), E->getRParenLoc());
17266}
17267
17268//===----------------------------------------------------------------------===//
17269// Type reconstruction
17270//===----------------------------------------------------------------------===//
17271
17272template<typename Derived>
17275 return SemaRef.BuildPointerType(PointeeType, Star,
17277}
17278
17279template<typename Derived>
17282 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17284}
17285
17286template<typename Derived>
17289 bool WrittenAsLValue,
17290 SourceLocation Sigil) {
17291 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17292 Sigil, getDerived().getBaseEntity());
17293}
17294
17295template <typename Derived>
17297 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17298 SourceLocation Sigil) {
17299 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17301}
17302
17303template<typename Derived>
17305 const ObjCTypeParamDecl *Decl,
17306 SourceLocation ProtocolLAngleLoc,
17308 ArrayRef<SourceLocation> ProtocolLocs,
17309 SourceLocation ProtocolRAngleLoc) {
17310 return SemaRef.ObjC().BuildObjCTypeParamType(
17311 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17312 /*FailOnError=*/true);
17313}
17314
17315template<typename Derived>
17317 QualType BaseType,
17318 SourceLocation Loc,
17319 SourceLocation TypeArgsLAngleLoc,
17321 SourceLocation TypeArgsRAngleLoc,
17322 SourceLocation ProtocolLAngleLoc,
17324 ArrayRef<SourceLocation> ProtocolLocs,
17325 SourceLocation ProtocolRAngleLoc) {
17326 return SemaRef.ObjC().BuildObjCObjectType(
17327 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17328 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17329 /*FailOnError=*/true,
17330 /*Rebuilding=*/true);
17331}
17332
17333template<typename Derived>
17335 QualType PointeeType,
17337 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17338}
17339
17340template <typename Derived>
17342 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17343 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17344 if (SizeExpr || !Size)
17345 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17346 IndexTypeQuals, BracketsRange,
17348
17349 QualType Types[] = {
17350 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17351 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17352 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17353 };
17354 QualType SizeType;
17355 for (const auto &T : Types)
17356 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17357 SizeType = T;
17358 break;
17359 }
17360
17361 // Note that we can return a VariableArrayType here in the case where
17362 // the element type was a dependent VariableArrayType.
17363 IntegerLiteral *ArraySize
17364 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17365 /*FIXME*/BracketsRange.getBegin());
17366 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17367 IndexTypeQuals, BracketsRange,
17369}
17370
17371template <typename Derived>
17373 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17374 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17375 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17376 IndexTypeQuals, BracketsRange);
17377}
17378
17379template <typename Derived>
17381 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17382 SourceRange BracketsRange) {
17383 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17384 IndexTypeQuals, BracketsRange);
17385}
17386
17387template <typename Derived>
17389 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17390 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17391 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17392 SizeExpr,
17393 IndexTypeQuals, BracketsRange);
17394}
17395
17396template <typename Derived>
17398 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17399 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17400 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17401 SizeExpr,
17402 IndexTypeQuals, BracketsRange);
17403}
17404
17405template <typename Derived>
17407 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17408 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17409 AttributeLoc);
17410}
17411
17412template <typename Derived>
17414 unsigned NumElements,
17415 VectorKind VecKind) {
17416 // FIXME: semantic checking!
17417 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17418}
17419
17420template <typename Derived>
17422 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17423 VectorKind VecKind) {
17424 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17425}
17426
17427template<typename Derived>
17429 unsigned NumElements,
17430 SourceLocation AttributeLoc) {
17431 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17432 NumElements, true);
17433 IntegerLiteral *VectorSize
17434 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17435 AttributeLoc);
17436 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17437}
17438
17439template<typename Derived>
17442 Expr *SizeExpr,
17443 SourceLocation AttributeLoc) {
17444 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17445}
17446
17447template <typename Derived>
17449 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17450 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17451 NumColumns);
17452}
17453
17454template <typename Derived>
17456 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17457 SourceLocation AttributeLoc) {
17458 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17459 AttributeLoc);
17460}
17461
17462template <typename Derived>
17466 return SemaRef.BuildFunctionType(T, ParamTypes,
17469 EPI);
17470}
17471
17472template<typename Derived>
17474 return SemaRef.Context.getFunctionNoProtoType(T);
17475}
17476
17477template <typename Derived>
17480 SourceLocation NameLoc, Decl *D) {
17481 assert(D && "no decl found");
17482 if (D->isInvalidDecl()) return QualType();
17483
17484 // FIXME: Doesn't account for ObjCInterfaceDecl!
17485 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17486 // A valid resolved using typename pack expansion decl can have multiple
17487 // UsingDecls, but they must each have exactly one type, and it must be
17488 // the same type in every case. But we must have at least one expansion!
17489 if (UPD->expansions().empty()) {
17490 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17491 << UPD->isCXXClassMember() << UPD;
17492 return QualType();
17493 }
17494
17495 // We might still have some unresolved types. Try to pick a resolved type
17496 // if we can. The final instantiation will check that the remaining
17497 // unresolved types instantiate to the type we pick.
17498 QualType FallbackT;
17499 QualType T;
17500 for (auto *E : UPD->expansions()) {
17501 QualType ThisT =
17502 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17503 if (ThisT.isNull())
17504 continue;
17505 if (ThisT->getAs<UnresolvedUsingType>())
17506 FallbackT = ThisT;
17507 else if (T.isNull())
17508 T = ThisT;
17509 else
17510 assert(getSema().Context.hasSameType(ThisT, T) &&
17511 "mismatched resolved types in using pack expansion");
17512 }
17513 return T.isNull() ? FallbackT : T;
17514 }
17515 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17516 assert(Using->hasTypename() &&
17517 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17518
17519 // A valid resolved using typename decl points to exactly one type decl.
17520 assert(++Using->shadow_begin() == Using->shadow_end());
17521
17522 UsingShadowDecl *Shadow = *Using->shadow_begin();
17523 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17524 return QualType();
17525 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17526 }
17528 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17529 return SemaRef.Context.getUnresolvedUsingType(
17531}
17532
17533template <typename Derived>
17535 TypeOfKind Kind) {
17536 return SemaRef.BuildTypeofExprType(E, Kind);
17537}
17538
17539template<typename Derived>
17541 TypeOfKind Kind) {
17542 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17543}
17544
17545template <typename Derived>
17547 return SemaRef.BuildDecltypeType(E);
17548}
17549
17550template <typename Derived>
17552 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17553 SourceLocation EllipsisLoc, bool FullySubstituted,
17554 ArrayRef<QualType> Expansions) {
17555 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17556 FullySubstituted, Expansions);
17557}
17558
17559template<typename Derived>
17561 UnaryTransformType::UTTKind UKind,
17562 SourceLocation Loc) {
17563 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17564}
17565
17566template <typename Derived>
17569 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17570 return SemaRef.CheckTemplateIdType(
17571 Keyword, Template, TemplateNameLoc, TemplateArgs,
17572 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17573}
17574
17575template<typename Derived>
17577 SourceLocation KWLoc) {
17578 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17579}
17580
17581template<typename Derived>
17583 SourceLocation KWLoc,
17584 bool isReadPipe) {
17585 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17586 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17587}
17588
17589template <typename Derived>
17591 unsigned NumBits,
17592 SourceLocation Loc) {
17593 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17594 NumBits, true);
17595 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17596 SemaRef.Context.IntTy, Loc);
17597 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17598}
17599
17600template <typename Derived>
17602 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17603 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17604}
17605
17606template <typename Derived>
17608 bool TemplateKW,
17609 TemplateName Name) {
17610 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17611 Name);
17612}
17613
17614template <typename Derived>
17616 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17617 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17619 TemplateName.setIdentifier(&Name, NameLoc);
17621 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17622 TemplateName, ParsedType::make(ObjectType),
17623 /*EnteringContext=*/false, Template,
17624 AllowInjectedClassName);
17625 return Template.get();
17626}
17627
17628template<typename Derived>
17631 SourceLocation TemplateKWLoc,
17632 OverloadedOperatorKind Operator,
17633 SourceLocation NameLoc,
17634 QualType ObjectType,
17635 bool AllowInjectedClassName) {
17636 UnqualifiedId Name;
17637 // FIXME: Bogus location information.
17638 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17639 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17641 getSema().ActOnTemplateName(
17642 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17643 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17644 return Template.get();
17645}
17646
17647template <typename Derived>
17650 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17651 Expr *Second) {
17652 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17653
17654 if (First->getObjectKind() == OK_ObjCProperty) {
17657 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17658 Opc, First, Second);
17659 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17660 if (Result.isInvalid())
17661 return ExprError();
17662 First = Result.get();
17663 }
17664
17665 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17666 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17667 if (Result.isInvalid())
17668 return ExprError();
17669 Second = Result.get();
17670 }
17671
17672 // Determine whether this should be a builtin operation.
17673 if (Op == OO_Subscript) {
17674 if (!First->getType()->isOverloadableType() &&
17675 !Second->getType()->isOverloadableType())
17676 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17677 OpLoc);
17678 } else if (Op == OO_Arrow) {
17679 // It is possible that the type refers to a RecoveryExpr created earlier
17680 // in the tree transformation.
17681 if (First->getType()->isDependentType())
17682 return ExprError();
17683 // -> is never a builtin operation.
17684 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17685 } else if (Second == nullptr || isPostIncDec) {
17686 if (!First->getType()->isOverloadableType() ||
17687 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17688 // The argument is not of overloadable type, or this is an expression
17689 // of the form &Class::member, so try to create a built-in unary
17690 // operation.
17692 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17693
17694 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17695 }
17696 } else {
17697 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17698 !First->getType()->isOverloadableType() &&
17699 !Second->getType()->isOverloadableType()) {
17700 // Neither of the arguments is type-dependent or has an overloadable
17701 // type, so try to create a built-in binary operation.
17704 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17705 if (Result.isInvalid())
17706 return ExprError();
17707
17708 return Result;
17709 }
17710 }
17711
17712 // Create the overloaded operator invocation for unary operators.
17713 if (!Second || isPostIncDec) {
17715 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17716 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17717 RequiresADL);
17718 }
17719
17720 // Create the overloaded operator invocation for binary operators.
17722 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17723 First, Second, RequiresADL);
17724 if (Result.isInvalid())
17725 return ExprError();
17726
17727 return Result;
17728}
17729
17730template<typename Derived>
17733 SourceLocation OperatorLoc,
17734 bool isArrow,
17735 CXXScopeSpec &SS,
17736 TypeSourceInfo *ScopeType,
17737 SourceLocation CCLoc,
17738 SourceLocation TildeLoc,
17739 PseudoDestructorTypeStorage Destroyed) {
17740 QualType CanonicalBaseType = Base->getType().getCanonicalType();
17741 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
17742 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
17743 (isArrow && isa<PointerType>(CanonicalBaseType) &&
17744 !cast<PointerType>(CanonicalBaseType)
17745 ->getPointeeType()
17746 ->getAsCanonical<RecordType>())) {
17747 // This pseudo-destructor expression is still a pseudo-destructor.
17748 return SemaRef.BuildPseudoDestructorExpr(
17749 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
17750 CCLoc, TildeLoc, Destroyed);
17751 }
17752
17753 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
17754 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
17755 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
17756 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
17757 NameInfo.setNamedTypeInfo(DestroyedType);
17758
17759 // The scope type is now known to be a valid nested name specifier
17760 // component. Tack it on to the nested name specifier.
17761 if (ScopeType) {
17762 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
17763 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
17764 diag::err_expected_class_or_namespace)
17765 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
17766 return ExprError();
17767 }
17768 SS.clear();
17769 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
17770 }
17771
17772 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
17773 return getSema().BuildMemberReferenceExpr(
17774 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
17775 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
17776 /*TemplateArgs*/ nullptr,
17777 /*S*/ nullptr);
17778}
17779
17780template<typename Derived>
17783 SourceLocation Loc = S->getBeginLoc();
17784 CapturedDecl *CD = S->getCapturedDecl();
17785 unsigned NumParams = CD->getNumParams();
17786 unsigned ContextParamPos = CD->getContextParamPosition();
17788 for (unsigned I = 0; I < NumParams; ++I) {
17789 if (I != ContextParamPos) {
17790 Params.push_back(
17791 std::make_pair(
17792 CD->getParam(I)->getName(),
17793 getDerived().TransformType(CD->getParam(I)->getType())));
17794 } else {
17795 Params.push_back(std::make_pair(StringRef(), QualType()));
17796 }
17797 }
17798 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
17799 S->getCapturedRegionKind(), Params);
17800 StmtResult Body;
17801 {
17802 Sema::CompoundScopeRAII CompoundScope(getSema());
17803 Body = getDerived().TransformStmt(S->getCapturedStmt());
17804 }
17805
17806 if (Body.isInvalid()) {
17807 getSema().ActOnCapturedRegionError();
17808 return StmtError();
17809 }
17810
17811 return getSema().ActOnCapturedRegionEnd(Body.get());
17812}
17813
17814template <typename Derived>
17817 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
17818 // function definition or instantiation of a function template specialization
17819 // and will therefore never appear in a dependent context.
17820 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
17821 "context");
17822}
17823
17824template <typename Derived>
17826 // We can transform the base expression and allow argument resolution to fill
17827 // in the rest.
17828 return getDerived().TransformExpr(E->getArgLValue());
17829}
17830
17831} // end namespace clang
17832
17833#endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
static Decl::Kind getKind(const Decl *D)
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
TokenType getType() const
Returns the token's type, e.g.
SmallVector< AnnotatedLine *, 1 > Children
If this token starts a block, this contains all the unwrapped lines in it.
#define X(type, name)
Definition Value.h:97
llvm::MachO::Record Record
Definition MachO.h:31
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenACC constructs and clauses.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis for expressions involving.
This file declares semantic analysis for SYCL constructs.
static bool PreparePackForExpansion(Sema &S, const CXXBaseSpecifier &Base, const MultiLevelTemplateArgumentList &TemplateArgs, TypeSourceInfo *&Out, UnexpandedInfo &Info)
Defines the Objective-C statement AST node classes.
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
static QualType getPointeeType(const MemRegion *R)
This represents 'pragma omp metadirective' directive.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType IntTy
CanQualType PseudoObjectTy
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
QualType getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
PtrTy get() const
Definition Ownership.h:171
bool isInvalid() const
Definition Ownership.h:167
bool isUsable() const
Definition Ownership.h:169
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition Expr.h:4484
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:5955
Represents a loop initializing the elements of an array.
Definition Expr.h:5902
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1804
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7105
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2721
Wrapper for source info for arrays.
Definition TypeLoc.h:1748
void setLBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1754
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition ExprCXX.h:2998
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:3036
ArrayTypeTrait getTrait() const
Definition ExprCXX.h:3038
Expr * getDimensionExpression() const
Definition ExprCXX.h:3048
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition ExprCXX.h:3044
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:3035
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3722
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6619
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6814
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2644
Attr - This represents one attribute.
Definition Attr.h:45
attr::Kind getKind() const
Definition Attr.h:91
Represents an attribute applied to a statement.
Definition Stmt.h:2183
Stmt * getSubStmt()
Definition Stmt.h:2219
SourceLocation getAttrLoc() const
Definition Stmt.h:2214
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2215
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:4387
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:3972
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition Expr.cpp:2178
static bool isAssignmentOp(Opcode Opc)
Definition Expr.h:4108
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:2140
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8130
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4654
void setIsVariadic(bool value)
Definition Decl.h:4730
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6558
Wrapper for source info for block pointers.
Definition TypeLoc.h:1497
BreakStmt - This represents a break.
Definition Stmt.h:3115
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5478
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:5497
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:5496
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition Expr.h:3903
Represents a call to a CUDA kernel function.
Definition ExprCXX.h:234
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition ExprCXX.h:604
Represents binding an expression to a temporary.
Definition ExprCXX.h:1494
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition ExprCXX.h:723
CXXCatchStmt - This represents a C++ catch block.
Definition StmtCXX.h:28
A C++ const_cast expression (C++ [expr.const.cast]).
Definition ExprCXX.h:566
Represents a call to a C++ constructor.
Definition ExprCXX.h:1549
SourceRange getParenOrBraceRange() const
Definition ExprCXX.h:1730
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition ExprCXX.h:1692
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition ExprCXX.h:1642
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:581
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:575
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition ExprCXX.h:1631
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition ExprCXX.h:1689
Represents a C++ constructor within a class.
Definition DeclCXX.h:2604
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1271
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition ExprCXX.cpp:1039
A use of a default initializer in a constructor or in aggregate initialization.
Definition ExprCXX.h:1378
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2628
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition ExprCXX.h:3872
Represents a C++ destructor within a class.
Definition DeclCXX.h:2869
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:481
Represents a folding of a pack over an operator.
Definition ExprCXX.h:5034
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:1833
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition ExprCXX.h:1753
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:179
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2129
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition ExprCXX.h:375
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition ExprCXX.h:406
SourceRange getAngleBrackets() const LLVM_READONLY
Definition ExprCXX.h:413
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition ExprCXX.h:409
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition ExprCXX.h:2357
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition ExprCXX.h:4311
The null pointer literal (C++11 [lex.nullptr])
Definition ExprCXX.h:768
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:84
Represents a list-initialization with parenthesis.
Definition ExprCXX.h:5143
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition ExprCXX.h:2747
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
unsigned getLambdaDependencyKind() const
Definition DeclCXX.h:1854
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition ExprCXX.h:526
A rewritten comparison expression that was originally written using operator syntax.
Definition ExprCXX.h:286
An expression "T()" which creates an rvalue of a non-class type T.
Definition ExprCXX.h:2198
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:73
void Make(ASTContext &Context, TypeLoc TL, SourceLocation ColonColonLoc)
Make a nested-name-specifier of the form 'type::'.
Definition DeclSpec.cpp:51
char * location_data() const
Retrieve the data associated with the source-location information.
Definition DeclSpec.h:206
SourceRange getRange() const
Definition DeclSpec.h:79
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition DeclSpec.cpp:75
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition DeclSpec.h:94
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition DeclSpec.cpp:123
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition DeclSpec.h:210
void Extend(ASTContext &Context, NamespaceBaseDecl *Namespace, SourceLocation NamespaceLoc, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'name...
Definition DeclSpec.cpp:62
void MakeMicrosoftSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition DeclSpec.cpp:85
bool isEmpty() const
No scope specifier.
Definition DeclSpec.h:178
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition DeclSpec.cpp:103
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition ExprCXX.h:800
Represents a C++ functional cast expression that builds a temporary object.
Definition ExprCXX.h:1901
Represents the this expression in C++.
Definition ExprCXX.h:1155
A C++ throw-expression (C++ [except.throw]).
Definition ExprCXX.h:1209
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:69
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition ExprCXX.h:848
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition ExprCXX.h:3746
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition ExprCXX.h:3790
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition ExprCXX.h:3801
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition ExprCXX.h:3784
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition ExprCXX.h:3795
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition ExprCXX.h:3804
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1069
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2877
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
Definition Expr.cpp:1516
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4926
unsigned getNumParams() const
Definition Decl.h:4964
unsigned getContextParamPosition() const
Definition Decl.h:4993
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4966
This captures a statement into a function.
Definition Stmt.h:3866
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1455
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:3970
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:4061
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition Stmt.cpp:1470
CaseStmt - Represent a case statement.
Definition Stmt.h:1900
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition Expr.cpp:1978
Expr * getSubExpr()
Definition Expr.h:3660
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4782
Represents a 'co_await' expression.
Definition ExprCXX.h:5371
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4234
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3539
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1720
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Stmt.h:1770
body_range body()
Definition Stmt.h:1783
SourceLocation getLBracLoc() const
Definition Stmt.h:1837
bool hasStoredFPFeatures() const
Definition Stmt.h:1767
Stmt * body_back()
Definition Stmt.h:1788
SourceLocation getRBracLoc() const
Definition Stmt.h:1838
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:4325
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3760
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition Expr.h:1082
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4373
ContinueStmt - This represents a continue.
Definition Stmt.h:3099
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4653
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:3436
Represents a 'co_yield' expression.
Definition ExprCXX.h:5452
Wrapper for source info for pointers decayed from arrays and functions.
Definition TypeLoc.h:1445
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1449
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2109
DeclContextLookupResult lookup_result
Definition DeclBase.h:2577
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addDecl(Decl *D)
Add the declaration D into this context.
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1270
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1611
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
bool isInvalidDecl() const
Definition DeclBase.h:588
SourceLocation getLocation() const
Definition DeclBase.h:439
DeclContext * getDeclContext()
Definition DeclBase.h:448
AccessSpecifier getAccess() const
Definition DeclBase.h:507
The name of a declaration.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition Decl.h:822
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:809
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:1874
void setDecltypeLoc(SourceLocation Loc)
Definition TypeLoc.h:2259
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2484
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:1969
Represents an extended address space qualifier where the input address space value is dependent.
Definition TypeBase.h:4061
Represents a 'co_await' expression while the type of the promise is dependent.
Definition ExprCXX.h:5403
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2552
A qualified reference to a name whose declaration cannot yet be resolved.
Definition ExprCXX.h:3512
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3586
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition ExprCXX.h:3560
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3578
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition ExprCXX.h:3596
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3570
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3613
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3551
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3606
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3548
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4011
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2067
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4101
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition TypeBase.h:4420
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2039
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4227
Represents a single C99 designator.
Definition Expr.h:5528
Represents a C99 designated initializer expression.
Definition Expr.h:5485
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:208
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
Definition Designator.h:172
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
Definition Designator.h:142
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
Definition Designator.h:115
bool hasErrorOccurred() const
Definition Diagnostic.h:872
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2812
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Definition TypeBase.h:4974
Expr * getCondition() const
Definition TypeBase.h:4981
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:744
Represents a reference to emded data.
Definition Expr.h:5060
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:3884
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition ExprCXX.h:3663
This represents one expression.
Definition Expr.h:112
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition Expr.h:177
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:194
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition Expr.h:451
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3080
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3212
QualType getType() const
Definition Expr.h:144
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition Expr.h:523
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition Expr.h:434
An expression trait intrinsic.
Definition ExprCXX.h:3071
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h:6498
Represents difference between two FPOptions values.
FPOptions applyOverrides(FPOptions Base)
Represents a member of a struct/union/class.
Definition Decl.h:3160
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2868
Represents a function declaration or definition.
Definition Decl.h:2000
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2774
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5222
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4867
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5521
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5507
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5088
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4832
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4843
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5254
param_type_iterator param_type_begin() const
Definition TypeBase.h:5698
unsigned getNumParams() const
Definition TypeLoc.h:1687
SourceLocation getLocalRangeEnd() const
Definition TypeLoc.h:1639
void setLocalRangeBegin(SourceLocation L)
Definition TypeLoc.h:1635
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1651
SourceRange getExceptionSpecRange() const
Definition TypeLoc.h:1667
void setParam(unsigned i, ParmVarDecl *VD)
Definition TypeLoc.h:1694
ArrayRef< ParmVarDecl * > getParams() const
Definition TypeLoc.h:1678
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1659
void setLocalRangeEnd(SourceLocation L)
Definition TypeLoc.h:1643
void setExceptionSpecRange(SourceRange R)
Definition TypeLoc.h:1673
TypeLoc getReturnLoc() const
Definition TypeLoc.h:1696
SourceLocation getLocalRangeBegin() const
Definition TypeLoc.h:1631
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1647
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1655
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4476
This represents a GCC inline-assembly statement extension.
Definition Stmt.h:3375
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition Expr.h:4857
Represents a C11 generic selection.
Definition Expr.h:6112
AssociationTy< false > Association
Definition Expr.h:6343
GotoStmt - This represents a direct goto.
Definition Stmt.h:2949
Type source information for HLSL attributed resource type.
Definition TypeLoc.h:1085
This class represents temporary values used to represent inout and out arguments in HLSL.
Definition Expr.h:7283
One of these records is kept for each identifier that is lexed.
IfStmt - This represents an if/then/else.
Definition Stmt.h:2239
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition Expr.h:1731
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition Expr.h:3787
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:5991
Represents a C array with an unspecified size.
Definition TypeBase.h:3909
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:2988
const TypeClass * getTypePtr() const
Definition TypeLoc.h:526
Describes an C or C++ initializer list.
Definition Expr.h:5233
InitListExpr * getSyntacticForm() const
Definition Expr.h:5406
Wrapper for source info for injected class names of class templates.
Definition TypeLoc.h:872
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition Expr.cpp:974
Represents the declaration of a label.
Definition Decl.h:524
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2126
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition ExprCXX.h:1970
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition ExprCXX.cpp:1363
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1358
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1367
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition ExprCXX.h:2035
Represents the results of name lookup.
Definition Lookup.h:147
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
Definition Lookup.h:607
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition Lookup.h:475
bool empty() const
Return true if no decls were found.
Definition Lookup.h:362
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Definition Lookup.h:666
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition Lookup.h:576
DeclarationName getLookupName() const
Gets the name to look up.
Definition Lookup.h:265
This represents a Microsoft inline-assembly statement extension.
Definition Stmt.h:3594
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition StmtCXX.h:253
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4340
A member reference to an MSPropertyDecl.
Definition ExprCXX.h:936
MS property subscript expression.
Definition ExprCXX.h:1007
void setExpansionLoc(SourceLocation Loc)
Definition TypeLoc.h:1354
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4922
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2799
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2096
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3298
Wrapper for source info for member pointers.
Definition TypeLoc.h:1515
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3653
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition Template.h:76
This represents a decl that may have a name.
Definition Decl.h:274
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition Decl.h:487
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition Decl.h:295
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:301
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:340
Represents C++ namespaces and their aliases.
Definition Decl.h:573
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents a place-holder for an object not to be initialized by anything.
Definition Expr.h:5811
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h:1683
This represents the 'absent' clause in the 'pragma omp assume' directive.
This represents 'acq_rel' clause in the 'pragma omp atomic|flush' directives.
This represents 'acquire' clause in the 'pragma omp atomic|flush' directives.
This represents clause 'affinity' in the 'pragma omp task'-based directives.
This represents the 'align' clause in the 'pragma omp allocate' directive.
This represents clause 'aligned' in the 'pragma omp ...' directives.
This represents clause 'allocate' in the 'pragma omp ...' directives.
This represents 'allocator' clause in the 'pragma omp ...' directive.
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
Definition ExprOpenMP.h:24
This represents 'at' clause in the 'pragma omp error' directive.
This represents 'atomic_default_mem_order' clause in the 'pragma omp requires' directive.
This represents 'bind' clause in the 'pragma omp ...' directives.
This represents 'capture' clause in the 'pragma omp atomic' directive.
This is a basic class for representing single OpenMP clause.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
This represents 'collapse' clause in the 'pragma omp ...' directive.
This represents 'compare' clause in the 'pragma omp atomic' directive.
This represents the 'contains' clause in the 'pragma omp assume' directive.
This represents clause 'copyin' in the 'pragma omp ...' directives.
This represents clause 'copyprivate' in the 'pragma omp ...' directives.
This represents 'default' clause in the 'pragma omp ...' directive.
This represents 'defaultmap' clause in the 'pragma omp ...' directive.
This represents implicit clause 'depend' for the 'pragma omp task' directive.
This represents implicit clause 'depobj' for the 'pragma omp depobj' directive.
This represents 'destroy' clause in the 'pragma omp depobj' directive or the 'pragma omp interop' dir...
This represents 'detach' clause in the 'pragma omp task' directive.
This represents 'device' clause in the 'pragma omp ...' directive.
This represents 'dist_schedule' clause in the 'pragma omp ...' directive.
This represents the 'doacross' clause for the 'pragma omp ordered' directive.
This represents 'dyn_groupprivate' clause in 'pragma omp target ...' and 'pragma omp teams ....
This represents 'dynamic_allocators' clause in the 'pragma omp requires' directive.
This represents clause 'exclusive' in the 'pragma omp scan' directive.
This represents 'fail' clause in the 'pragma omp atomic' directive.
This represents 'filter' clause in the 'pragma omp ...' directive.
This represents 'final' clause in the 'pragma omp ...' directive.
This represents clause 'firstprivate' in the 'pragma omp ...' directives.
This represents implicit clause 'flush' for the 'pragma omp flush' directive.
This represents clause 'from' in the 'pragma omp ...' directives.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
This represents 'grainsize' clause in the 'pragma omp ...' directive.
This represents clause 'has_device_ptr' in the 'pragma omp ...' directives.
This represents 'hint' clause in the 'pragma omp ...' directive.
This represents the 'holds' clause in the 'pragma omp assume' directive.
This represents 'if' clause in the 'pragma omp ...' directive.
This represents clause 'in_reduction' in the 'pragma omp task' directives.
This represents clause 'inclusive' in the 'pragma omp scan' directive.
This represents the 'init' clause in 'pragma omp ...' directives.
This represents clause 'is_device_ptr' in the 'pragma omp ...' directives.
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
Definition ExprOpenMP.h:151
This represents clause 'lastprivate' in the 'pragma omp ...' directives.
This represents clause 'linear' in the 'pragma omp ...' directives.
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
This represents clauses with a list of expressions that are mappable.
This represents 'mergeable' clause in the 'pragma omp ...' directive.
This represents the 'message' clause in the 'pragma omp error' and the 'pragma omp parallel' directiv...
This represents the 'no_openmp' clause in the 'pragma omp assume' directive.
This represents the 'no_openmp_constructs' clause in the.
This represents the 'no_openmp_routines' clause in the 'pragma omp assume' directive.
This represents the 'no_parallelism' clause in the 'pragma omp assume' directive.
This represents 'nocontext' clause in the 'pragma omp ...' directive.
This represents 'nogroup' clause in the 'pragma omp ...' directive.
This represents clause 'nontemporal' in the 'pragma omp ...' directives.
This represents 'novariants' clause in the 'pragma omp ...' directive.
This represents 'nowait' clause in the 'pragma omp ...' directive.
This represents 'num_tasks' clause in the 'pragma omp ...' directive.
This represents 'num_teams' clause in the 'pragma omp ...' directive.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
This represents 'order' clause in the 'pragma omp ...' directive.
This represents 'ordered' clause in the 'pragma omp ...' directive.
Representation of the 'partial' clause of the 'pragma omp unroll' directive.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
This represents 'priority' clause in the 'pragma omp ...' directive.
This represents clause 'private' in the 'pragma omp ...' directives.
This represents 'proc_bind' clause in the 'pragma omp ...' directive.
This represents 'read' clause in the 'pragma omp atomic' directive.
This represents clause 'reduction' in the 'pragma omp ...' directives.
This represents 'relaxed' clause in the 'pragma omp atomic' directives.
This represents 'release' clause in the 'pragma omp atomic|flush' directives.
This represents 'reverse_offload' clause in the 'pragma omp requires' directive.
This represents 'simd' clause in the 'pragma omp ...' directive.
This represents 'safelen' clause in the 'pragma omp ...' directive.
This represents 'schedule' clause in the 'pragma omp ...' directive.
This represents 'self_maps' clause in the 'pragma omp requires' directive.
This represents 'seq_cst' clause in the 'pragma omp atomic|flush' directives.
This represents the 'severity' clause in the 'pragma omp error' and the 'pragma omp parallel' directi...
This represents clause 'shared' in the 'pragma omp ...' directives.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
This represents clause 'task_reduction' in the 'pragma omp taskgroup' directives.
This represents 'thread_limit' clause in the 'pragma omp ...' directive.
This represents 'threads' clause in the 'pragma omp ...' directive.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
This represents clause 'to' in the 'pragma omp ...' directives.
This represents 'unified_address' clause in the 'pragma omp requires' directive.
This represents 'unified_shared_memory' clause in the 'pragma omp requires' directive.
This represents 'untied' clause in the 'pragma omp ...' directive.
This represents 'update' clause in the 'pragma omp atomic' directive.
This represents the 'use' clause in 'pragma omp ...' directives.
This represents clause 'use_device_addr' in the 'pragma omp ...' directives.
This represents clause 'use_device_ptr' in the 'pragma omp ...' directives.
This represents clause 'uses_allocators' in the 'pragma omp target'-based directives.
This represents 'weak' clause in the 'pragma omp atomic' directives.
This represents 'write' clause in the 'pragma omp atomic' directive.
This represents 'ompx_attribute' clause in a directive that might generate an outlined function.
This represents 'ompx_bare' clause in the 'pragma omp target teams ...' directive.
This represents 'ompx_dyn_cgroup_mem' clause in the 'pragma omp target ...' directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition ExprObjC.h:192
Represents Objective-C's @catch statement.
Definition StmtObjC.h:77
Represents Objective-C's @finally statement.
Definition StmtObjC.h:127
Represents Objective-C's @synchronized statement.
Definition StmtObjC.h:303
Represents Objective-C's @throw statement.
Definition StmtObjC.h:358
Represents Objective-C's @try ... @catch ... @finally statement.
Definition StmtObjC.h:167
Represents Objective-C's @autoreleasepool Statement.
Definition StmtObjC.h:394
A runtime availability query.
Definition ExprObjC.h:1703
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition ExprObjC.h:88
ObjCBoxedExpr - used for generalized expression boxing.
Definition ExprObjC.h:128
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition ExprObjC.h:1643
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition ExprObjC.h:308
ObjCEncodeExpr, used for @encode in Objective-C.
Definition ExprObjC.h:409
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:1582
Wrapper for source info for ObjC interfaces.
Definition TypeLoc.h:1274
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition ExprObjC.h:1498
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1952
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:548
An expression that sends a message to the given Objective-C object or class.
Definition ExprObjC.h:940
@ SuperInstance
The receiver is the instance of the superclass object.
Definition ExprObjC.h:954
@ Instance
The receiver is an object instance.
Definition ExprObjC.h:948
@ SuperClass
The receiver is a superclass.
Definition ExprObjC.h:951
@ Class
The receiver is a class.
Definition ExprObjC.h:945
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Wraps an ObjCPointerType with source location information.
Definition TypeLoc.h:1557
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1563
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition TypeLoc.h:1229
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:731
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition ExprObjC.h:616
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition ExprObjC.h:504
ObjCSelectorExpr used for @selector in Objective-C.
Definition ExprObjC.h:454
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition ExprObjC.h:52
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition ExprObjC.h:839
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:578
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition TypeLoc.h:895
@ Array
An index into an array.
Definition Expr.h:2426
@ Identifier
A field in a dependent type, known only by its name.
Definition Expr.h:2430
@ Field
A field.
Definition Expr.h:2428
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition Expr.h:2433
static OpaquePtr make(QualType P)
Definition Ownership.h:61
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition Expr.h:1178
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1228
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition Expr.h:2090
static OpenACCAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCAttachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCAutoClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
This is the base type for all OpenACC Clauses.
Represents a 'collapse' clause on a 'loop' construct.
static OpenACCCollapseClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, bool HasForce, Expr *LoopCount, SourceLocation EndLoc)
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A 'default' clause, has the optional 'none' or 'present' argument.
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCDeleteClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDetachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceNumClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCFinalizeClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCFirstPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCHostClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
An 'if' clause, which has a required condition expression.
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCIfPresentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCIndependentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCNoCreateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCPrivateRecipe > InitRecipes, SourceLocation EndLoc)
A 'self' clause, which has an optional condition expression, or, in the event of an 'update' directiv...
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCTileClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > SizeExprs, SourceLocation EndLoc)
static OpenACCUseDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWaitClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition ExprCXX.h:3130
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition ExprCXX.h:3282
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3264
SourceLocation getNameLoc() const
Gets the location of the name.
Definition ExprCXX.h:3243
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3256
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition ExprCXX.h:3252
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3326
llvm::iterator_range< decls_iterator > decls() const
Definition ExprCXX.h:3229
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3332
DeclarationName getName() const
Gets the name looked up.
Definition ExprCXX.h:3240
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3272
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition ExprCXX.h:3279
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition ExprCXX.h:4365
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2604
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2600
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2616
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2287
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2182
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition Expr.h:2207
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition Expr.h:2211
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1382
Represents a parameter to a function.
Definition Decl.h:1790
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1850
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1823
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition Decl.cpp:2946
unsigned getFunctionScopeDepth() const
Definition Decl.h:1840
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2696
PipeType - OpenCL20.
Definition TypeBase.h:8096
bool isReadOnly() const
Definition TypeBase.h:8126
Pointer-authentication qualifiers.
Definition TypeBase.h:152
void setSigilLoc(SourceLocation Loc)
Definition TypeLoc.h:1461
TypeLoc getPointeeLoc() const
Definition TypeLoc.h:1465
SourceLocation getSigilLoc() const
Definition TypeLoc.h:1457
Wrapper for source info for pointers.
Definition TypeLoc.h:1484
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3328
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2005
Stores the type being destroyed by a pseudo-destructor expression.
Definition ExprCXX.h:2696
const IdentifierInfo * getIdentifier() const
Definition ExprCXX.h:2716
SourceLocation getLocation() const
Definition ExprCXX.h:2720
TypeSourceInfo * getTypeSourceInfo() const
Definition ExprCXX.h:2712
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h:6690
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:8278
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition TypeBase.h:8318
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition TypeBase.h:8372
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8310
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:7389
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3573
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3589
Represents the body of a requires-expression.
Definition DeclCXX.h:2098
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition DeclCXX.cpp:2389
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3140
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition Stmt.cpp:1323
Represents a __leave statement.
Definition Stmt.h:3827
SYCLKernelCallStmt represents the transformation that is applied to the body of a function declared w...
Definition StmtSYCL.h:37
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
Definition SemaObjC.cpp:36
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
Definition SemaObjC.cpp:193
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition SemaObjC.cpp:320
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
Definition SemaObjC.cpp:218
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:213
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition SemaObjC.cpp:238
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition SemaObjC.cpp:282
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Definition SemaObjC.cpp:202
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:329
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
Helper type for the registration/assignment of constructs that need to 'know' about their parent cons...
Helper type to restore the state of various 'loop' constructs when we run into a loop (for,...
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
void ActOnWhileStmt(SourceLocation WhileLoc)
ExprResult ActOnOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
void ActOnDoStmt(SourceLocation DoLoc)
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *OldRangeFor, const Stmt *RangeFor)
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation MiscLoc, ArrayRef< Expr * > Exprs, OpenACCAtomicKind AK, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
void ActOnForStmtEnd(SourceLocation ForLoc, StmtResult Body)
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *First, const Stmt *Second, const Stmt *Third)
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
OMPClause * ActOnOpenMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nocontext' clause.
OMPClause * ActOnOpenMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_dyn_cgroup_mem' clause.
OMPClause * ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'safelen' clause.
OMPClause * ActOnOpenMPHoldsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'holds' clause.
OMPClause * ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'filter' clause.
OMPClause * ActOnOpenMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on well-form 'full' clauses.
OMPClause * ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'detach' clause.
OMPClause * ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'use' clause.
OMPClause * ActOnOpenMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'to' clause.
OMPClause * ActOnOpenMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'private' clause.
OMPClause * ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc=SourceLocation(), Expr *NumForLoops=nullptr)
Called on well-formed 'ordered' clause.
OMPClause * ActOnOpenMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'is_device_ptr' clause.
OMPClause * ActOnOpenMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'has_device_addr' clause.
OMPClause * ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'partial' clauses.
OMPClause * ActOnOpenMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'lastprivate' clause.
OMPClause * ActOnOpenMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'firstprivate' clause.
OMPClause * ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'priority' clause.
OMPClause * ActOnOpenMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'dist_schedule' clause.
OMPClause * 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 * ActOnOpenMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'from' clause.
OMPClause * ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'bind' clause.
OMPClause * ActOnOpenMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' clause.
OMPClause * ActOnOpenMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'shared' clause.
OMPClause * ActOnOpenMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyin' clause.
OMPClause * ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'destroy' clause.
OMPClause * ActOnOpenMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Called on well-formed 'affinity' clause.
OMPClause * ActOnOpenMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' clause.
OMPClause * ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depend' clause.
OMPClause * ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'doacross' clause.
OMPClause * ActOnOpenMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'grainsize' clause.
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
ExprResult ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< OMPIteratorData > Data)
OMPClause * ActOnOpenMPUsesAllocatorClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< UsesAllocatorsData > Data)
Called on well-formed 'uses_allocators' clause.
OMPClause * ActOnOpenMPAllocatorClause(Expr *Allocator, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocator' clause.
OMPClause * ActOnOpenMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'inclusive' clause.
OMPClause * ActOnOpenMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'task_reduction' clause.
OMPClause * ActOnOpenMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Condition)
Called on well-formed 'nowait' clause.
OMPClause * ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, OpenMPOrderClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'order' clause.
OMPClause * ActOnOpenMPSizesClause(ArrayRef< Expr * > SizeExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'sizes' clause.
OMPClause * ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'device' clause.
OMPClause * ActOnOpenMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'in_reduction' clause.
OMPClause * ActOnOpenMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'flush' pseudo clause.
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
OMPClause * ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'message' clause.
OMPClause * ActOnOpenMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'schedule' clause.
OMPClause * ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'simdlen' clause.
OMPClause * ActOnOpenMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_ptr' clause.
OMPClause * ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'proc_bind' clause.
OMPClause * ActOnOpenMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_bare' clause.
StmtResult ActOnOpenMPInformationalDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Process an OpenMP informational directive.
StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt)
Called for syntactical loops (ForStmt or CXXForRangeStmt) associated to an OpenMP loop directive.
OMPClause * ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'hint' clause.
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
OMPClause * ActOnOpenMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_threads' clause.
OMPClause * ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'at' clause.
OMPClause * ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'init' clause.
OMPClause * ActOnOpenMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_addr' clause.
OMPClause * ActOnOpenMPAllocateClause(Expr *Allocator, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocate' clause.
OMPClause * ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'final' clause.
OMPClause * ActOnOpenMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, bool NoDiagnose=false, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'map' clause.
OMPClause * ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_tasks' clause.
OMPClause * 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 * ActOnOpenMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind LinKind, SourceLocation LinLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Called on well-formed 'linear' clause.
OMPClause * ActOnOpenMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'defaultmap' clause.
OMPClause * ActOnOpenMPReductionClause(ArrayRef< Expr * > VarList, OpenMPVarListDataTy::OpenMPReductionClauseModifiers Modifiers, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'reduction' clause.
OMPClause * ActOnOpenMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'aligned' clause.
OMPClause * ActOnOpenMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depobj' pseudo clause.
OMPClause * ActOnOpenMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'novariants' clause.
OMPClause * ActOnOpenMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyprivate' clause.
OMPClause * ActOnOpenMPCollapseClause(Expr *NumForLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'collapse' clause.
OMPClause * ActOnOpenMPDefaultClause(llvm::omp::DefaultKind M, SourceLocation MLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCKindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'default' clause.
OMPClause * ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'align' clause.
OMPClause * ActOnOpenMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_attribute' clause.
OMPClause * ActOnOpenMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'exclusive' clause.
OMPClause * ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'if' clause.
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
Given a pseudo-object expression, recreate what it looks like syntactically without the attendant Opa...
ExprResult checkRValue(Expr *E)
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition SemaSYCL.cpp:143
RAII object used to change the argument pack substitution index within a Sema object.
Definition Sema.h:13584
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8412
A RAII object to enter scope of a compound statement.
Definition Sema.h:1290
A RAII object to temporarily push a declaration context.
Definition Sema.h:3467
A helper class for building up ExtParameterInfos.
Definition Sema.h:12977
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:12996
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:12984
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:13981
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:854
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:9303
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9311
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9306
bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend)
Check that the expression co_await promise.final_suspend() shall not be potentially-throwing.
ExprResult ActOnConstantExpression(ExprResult Res)
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs)
ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E)
SemaOpenMP & OpenMP()
Definition Sema.h:1501
void ActOnStartStmtExpr()
void ActOnStmtExprError()
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt={})
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
VarDecl * buildCoroutinePromise(SourceLocation Loc)
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
Definition Sema.h:7808
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7810
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7809
ExprResult BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP, SourceLocation loc, TemplateArgument Replacement, UnsignedOrNone PackIndex, bool Final)
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:438
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E, bool IsImplicit=false)
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition SemaStmt.cpp:485
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition Sema.h:1526
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition Sema.h:11927
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
ASTContext & Context
Definition Sema.h:1283
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
DiagnosticsEngine & getDiagnostics() const
Definition Sema.h:922
SemaObjC & ObjC()
Definition Sema.h:1486
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool FullySubstituted=false)
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
ASTContext & getASTContext() const
Definition Sema.h:925
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, bool DoCheckConstraintSatisfaction=true)
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition Sema.cpp:83
const LangOptions & getLangOpts() const
Definition Sema.h:918
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
SemaOpenACC & OpenACC()
Definition Sema.h:1491
@ ReuseLambdaContextDecl
Definition Sema.h:6989
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)
Check whether an expression might be an implicit class member access.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc, bool ListInitialization)
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
TemplateArgument getPackSubstitutedTemplateArgument(TemplateArgument Arg) const
Definition Sema.h:11730
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
bool buildCoroutineParameterMoves(SourceLocation Loc)
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a Microsoft __uuidof expression with a type operand.
sema::FunctionScopeInfo * getCurFunction() const
Definition Sema.h:1314
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
UnsignedOrNone getPackIndex(TemplateArgument Pack) const
Definition Sema.h:11725
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition Sema.cpp:2516
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1414
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Create a new AsTypeExpr node (bitcast) from the arguments.
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
UnsignedOrNone ArgPackSubstIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition Sema.h:13578
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:6702
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6712
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6681
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6707
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:75
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition Sema.h:8281
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:11020
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition SemaStmt.cpp:563
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParen)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition SemaCast.cpp:337
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel)
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition SemaStmt.cpp:950
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, SourceLocation RParenLoc, MultiExprArg Args, AtomicExpr::AtomicOp Op, AtomicArgumentOrder ArgOrder=AtomicArgumentOrder::API)
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
OpaquePtr< TemplateName > TemplateTy
Definition Sema.h:1275
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static ConditionResult ConditionError()
Definition Sema.h:7794
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:436
SemaPseudoObject & PseudoObject()
Definition Sema.h:1511
StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
ActOnCXXTryBlock - Takes a try compound-statement and a number of handlers and creates a try statemen...
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition Sema.h:1274
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition SemaStmt.cpp:568
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition SemaStmt.cpp:532
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Definition Sema.h:8621
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:4577
Represents an expression that computes the length of a parameter pack.
Definition ExprCXX.h:4443
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition ExprCXX.h:4505
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
Definition ExprCXX.h:4528
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Definition ExprCXX.cpp:1709
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition ExprCXX.h:4533
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
Definition ExprCXX.h:4502
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition ExprCXX.h:4508
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition ExprCXX.h:4511
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition Expr.h:4951
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition Expr.h:5011
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:4529
Stmt - This represents one statement.
Definition Stmt.h:85
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.cpp:362
@ NoStmtClass
Definition Stmt.h:88
StmtClass getStmtClass() const
Definition Stmt.h:1472
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:338
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1799
Wrapper for substituted template type parameters.
Definition TypeLoc.h:998
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition ExprCXX.h:4666
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition ExprCXX.h:4756
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:2489
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3717
SourceLocation getNameLoc() const
Definition TypeLoc.h:822
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:801
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:809
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:816
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:824
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:805
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
const TemplateArgumentLoc * operator->() const
Simple iterator that traverses the template arguments in a container that provides a getArgLoc() memb...
TemplateArgumentLocContainerIterator operator++(int)
friend bool operator!=(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator(ArgLocContainer &Container, unsigned Index)
friend bool operator==(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator & operator++()
const TemplateArgumentLoc * operator->() const
Iterator adaptor that invents template argument location information for each of the template argumen...
TemplateArgumentLocInventIterator & operator++()
std::iterator_traits< InputIterator >::difference_type difference_type
TemplateArgumentLocInventIterator operator++(int)
friend bool operator==(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
TemplateArgumentLocInventIterator(TreeTransform< Derived > &Self, InputIterator Iter)
friend bool operator!=(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
TypeSourceInfo * getTypeSourceInfo() const
Expr * getSourceExpression() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
const TemplateArgument * pack_iterator
Iterator that traverses the elements of a template argument pack.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DeducedTemplateStorage * getAsDeducedTemplateName() const
Retrieve the deduced template info, if any.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
NestedNameSpecifier getQualifier() const
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceLocation getLAngleLoc() const
Definition TypeLoc.h:1878
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:1893
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:1876
SourceLocation getTemplateKeywordLoc() const
Definition TypeLoc.h:1872
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1862
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:1858
Wrapper for template type parameters.
Definition TypeLoc.h:881
The top declaration context.
Definition Decl.h:105
RAII object that temporarily sets the base location and entity used for reporting diagnostics in type...
TemporaryBase(TreeTransform &Self, SourceLocation Location, DeclarationName Entity)
A semantic tree transformation that allows one to transform one abstract syntax tree into another.
ExprResult RebuildObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *object)
Rebuild the operand to an Objective-C @synchronized statement.
OMPClause * RebuildOMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nontemporal' clause.
StmtResult RebuildOpenACCDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
TemplateArgument TransformNamedTemplateTemplateArgument(NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName Name, SourceLocation NameLoc)
ExprResult TransformInitializer(Expr *Init, bool NotCopyInit)
Transform the given initializer.
StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new label statement.
StmtResult RebuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs Args)
StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @autoreleasepool statement.
OMPClause * RebuildOMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP 'dist_schedule' clause.
ExprResult RebuildUnaryOperator(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *SubExpr)
Build a new unary operator expression.
OMPClause * RebuildOMPProcBindClause(ProcBindKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'proc_bind' clause.
ParmVarDecl * TransformFunctionTypeParam(ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack)
Transforms a single function-type parameter.
StmtResult RebuildOMPInformationalDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP informational directive.
ExprResult RebuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Build a new C++11 default-initialization expression.
OMPClause * RebuildOMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'priority' clause.
StmtResult RebuildOpenACCSetConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc, TypeSourceInfo *EncodeTypeInfo, SourceLocation RParenLoc)
Build a new Objective-C @encode expression.
StmtResult RebuildOpenACCCombinedConstruct(OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult Loop)
StmtResult SkipLambdaBody(LambdaExpr *E, Stmt *Body)
Alternative implementation of TransformLambdaBody that skips transforming the body.
StmtResult RebuildOpenACCExitDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
StmtResult RebuildOpenACCShutdownConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
OMPClause * RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocate' clause.
ExprResult RebuildObjCIsaExpr(Expr *BaseArg, SourceLocation IsaLoc, SourceLocation OpLoc, bool IsArrow)
Build a new Objective-C "isa" expression.
StmtResult RebuildObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @finally statement.
SourceLocation getBaseLocation()
Returns the location of the entity being transformed, if that information was not available elsewhere...
ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
Build a new call expression.
ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar, SourceLocation IvarLoc, bool IsArrow, bool IsFreeIvar)
Build a new Objective-C ivar reference expression.
OMPClause * RebuildOMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'at' clause.
StmtResult RebuildCoreturnStmt(SourceLocation CoreturnLoc, Expr *Result, bool IsImplicit)
Build a new co_return statement.
OMPClause * RebuildOMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'in_reduction' clause.
ExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *Init)
Build a new compound literal expression.
ExprResult TransformAddressOfOperand(Expr *E)
The operand of a unary address-of operator has special rules: it's allowed to refer to a non-static m...
ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc, QualType ThisType, bool isImplicit)
Build a new C++ "this" expression.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(expr) expression.
TreeTransform(Sema &SemaRef)
Initializes a new tree transformer.
QualType RebuildDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttributeLoc)
Build a new matrix type given the type and dependently-defined dimensions.
QualType RebuildTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, TagDecl *Tag)
Build a new class/struct/union/enum type.
QualType RebuildUnaryTransformType(QualType BaseType, UnaryTransformType::UTTKind UKind, SourceLocation Loc)
Build a new unary transform type.
ExprResult RebuildObjCPropertyRefExpr(Expr *BaseArg, ObjCPropertyDecl *Property, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
void InventTemplateArgumentLoc(const TemplateArgument &Arg, TemplateArgumentLoc &ArgLoc)
Fakes up a TemplateArgumentLoc for a given TemplateArgument.
OMPClause * RebuildOMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'use' clause.
StmtResult RebuildOpenACCEnterDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL)
Transform the given type-with-location into a new type, collecting location information in the given ...
ExprResult RebuildCXXRewrittenBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opcode, const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS)
Build a new rewritten operator expression.
QualType RebuildDeducedTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, QualType Deduced)
By default, builds a new DeducedTemplateSpecializationType with the given deduced type.
ExprResult RebuildPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new expression pack expansion.
ExprResult TransformUnresolvedLookupExpr(UnresolvedLookupExpr *E, bool IsAddressOfOperand)
ExprResult RebuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
Build a new expression representing a call to a source location builtin.
TemplateName RebuildTemplateName(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final)
Build a new template name given a template template parameter pack and the.
QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL)
Transforms a reference type.
OMPClause * RebuildOMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'message' clause.
ExprResult RebuildCXXAddrspaceCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
QualType RebuildTypeOfType(QualType Underlying, TypeOfKind Kind)
Build a new typeof(type) type.
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, Expr *SubExpr, TypeSourceInfo *TInfo, SourceLocation RParenLoc)
Build a new va_arg expression.
ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, SourceLocation RParenLoc)
Build a new C++ zero-initialization expression.
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr)
OMPClause * RebuildOMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'thread_limit' clause.
StmtResult RebuildSEHFinallyStmt(SourceLocation Loc, Stmt *Block)
OMPClause * RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'simdlen' clause.
StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
Build a new C++ try statement.
StmtDiscardKind
The reason why the value of a statement is not discarded, if any.
ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, UnresolvedLookupExpr *OpCoawaitLookup, bool IsImplicit)
Build a new co_await expression.
bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, unsigned NumInputs, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
ExprResult RebuildDesignatedInitExpr(Designation &Desig, MultiExprArg ArrayExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Build a new designated initializer expression.
QualType RebuildUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, SourceLocation NameLoc, Decl *D)
Rebuild an unresolved typename type, given the decl that the UnresolvedUsingTypenameDecl was transfor...
OMPClause * RebuildOMPSizesClause(ArrayRef< Expr * > Sizes, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
ExprResult RebuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
Build a new predefined expression.
ExprResult RebuildCXXStaticCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ static_cast expression.
StmtResult RebuildForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *Init, Sema::ConditionResult Cond, Sema::FullExprArg Inc, SourceLocation RParenLoc, Stmt *Body)
Build a new for statement.
StmtResult RebuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Build a new C++0x range-based for statement.
ExprResult RebuildStmtExpr(SourceLocation LParenLoc, Stmt *SubStmt, SourceLocation RParenLoc, unsigned TemplateDepth)
Build a new GNU statement expression.
QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo *Id, SourceLocation IdLoc, bool DeducedTSTContext)
Build a new typename type that refers to an identifier.
Sema & getSema() const
Retrieves a reference to the semantic analysis object used for this tree transform.
ExprResult RebuildShuffleVectorExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new shuffle vector expression.
OMPClause * RebuildOMPNowaitClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nowait' clause.
QualType TransformType(QualType T)
Transforms the given type into another type.
UnsignedOrNone ComputeSizeOfPackExprWithoutSubstitution(ArrayRef< TemplateArgument > PackArgs)
OMPClause * RebuildOMPOrderClause(OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc)
Build a new OpenMP 'order' clause.
QualType RebuildReferenceType(QualType ReferentType, bool LValue, SourceLocation Sigil)
Build a new reference type given the type it references.
ExprResult TransformRequiresTypeParams(SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE, RequiresExprBodyDecl *Body, ArrayRef< ParmVarDecl * > Params, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > &TransParams, Sema::ExtParameterInfoBuilder &PInfos)
Transforms the parameters of a requires expresison into the given vectors.
ExprResult RebuildInitList(SourceLocation LBraceLoc, MultiExprArg Inits, SourceLocation RBraceLoc)
Build a new initializer list expression.
QualType RebuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
StmtResult RebuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Operand)
Build a new Objective-C @throw statement.
OMPClause * RebuildOMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'task_reduction' clause.
StmtResult RebuildOpenACCWaitConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
OMPClause * RebuildOMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'copyin' clause.
QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc, bool isReadPipe)
Build a new pipe type given its value type.
StmtResult RebuildCaseStmt(SourceLocation CaseLoc, Expr *LHS, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation ColonLoc)
Build a new case statement.
ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
Build a new template-id expression.
StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc, VarDecl *ExceptionDecl, Stmt *Handler)
Build a new C++ catch statement.
OMPClause * RebuildOMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'destroy' clause.
ExprResult RebuildUnaryExprOrTypeTrait(Expr *SubExpr, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec step expression with an expression argument.
ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new address-of-label expression.
ExprResult RebuildCxxSubscriptExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
OMPClause * RebuildOMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_bare' clause.
const Attr * TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS, const Attr *A)
ExprResult RebuildConditionalOperator(Expr *Cond, SourceLocation QuestionLoc, Expr *LHS, SourceLocation ColonLoc, Expr *RHS)
Build a new conditional operator expression.
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
Attach body to a C++0x range-based for statement.
StmtResult RebuildOpenACCUpdateConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *Object, Stmt *Body)
Build a new Objective-C @synchronized statement.
ExprResult RebuildOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
OMPClause * RebuildOMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'device' clause.
OMPClause * RebuildOMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'has_device_addr' clause.
bool TryExpandParameterPacks(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions)
Determine whether we should expand a pack expansion with the given set of parameter packs into separa...
QualType RebuildDependentSizedExtVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
OMPClause * RebuildOMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_threads' clause.
void RememberPartiallySubstitutedPack(TemplateArgument Arg)
"Remember" the partially-substituted pack template argument after performing an instantiation that mu...
Decl * TransformDefinition(SourceLocation Loc, Decl *D)
Transform the definition of the given declaration.
OMPClause * RebuildOMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'from' clause.
ExprResult RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, UnresolvedLookupExpr *Lookup)
Build a new co_await expression.
StmtResult RebuildReturnStmt(SourceLocation ReturnLoc, Expr *Result)
Build a new return statement.
QualType TransformTemplateSpecializationType(TypeLocBuilder &TLB, TemplateSpecializationTypeLoc TL, QualType ObjectType, NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName)
TemplateArgument ForgetPartiallySubstitutedPack()
"Forget" about the partially-substituted pack template argument, when performing an instantiation tha...
OMPClause * RebuildOMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nocontext' clause.
ExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ reinterpret_cast expression.
QualType RebuildVectorType(QualType ElementType, unsigned NumElements, VectorKind VecKind)
Build a new vector type given the element type and number of elements.
ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc, TypeSourceInfo *Type, ArrayRef< Sema::OffsetOfComponent > Components, SourceLocation RParenLoc)
Build a new builtin offsetof expression.
QualType RebuildParenType(QualType InnerType)
Build a new parenthesized type.
static StmtResult Owned(Stmt *S)
OMPClause * RebuildOMPPartialClause(Expr *Factor, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'partial' clause.
OMPClause * RebuildOMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP 'schedule' clause.
StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body)
Transform the body of a lambda-expression.
StmtResult RebuildSEHTryStmt(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
OMPClause * RebuildOMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'exclusive' clause.
QualType RebuildDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc)
Build a new DependentAddressSpaceType or return the pointee type variable with the correct address sp...
StmtResult RebuildAttributedStmt(SourceLocation AttrLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Build a new attributed statement.
QualType RebuildMemberPointerType(QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls, SourceLocation Sigil)
Build a new member pointer type given the pointee type and the qualifier it refers into.
ExprResult RebuildConceptSpecializationExpr(NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, TemplateArgumentListInfo *TALI)
OMPClause * RebuildOMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Build a new OpenMP 'defaultmap' clause.
StmtResult RebuildOpenACCCacheConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation ReadOnlyLoc, ArrayRef< Expr * > VarList, SourceLocation RParenLoc, SourceLocation EndLoc)
StmtResult RebuildOpenACCLoopConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult Loop)
ExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr)
Build a new C++ default-argument expression.
OMPClause * RebuildOMPDefaultClause(DefaultKind Kind, SourceLocation KindKwLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'default' clause.
StmtResult RebuildWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, Sema::ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
Build a new while statement.
OMPClause * RebuildOMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_teams' clause.
OMPClause * RebuildOMPDynGroupprivateClause(OpenMPDynGroupprivateClauseModifier M1, OpenMPDynGroupprivateClauseFallbackModifier M2, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation EndLoc)
Build a new OpenMP 'dyn_groupprivate' clause.
ExprResult RebuildImplicitValueInitExpr(QualType T)
Build a new value-initialized expression.
bool TransformFunctionTypeParams(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const QualType *ParamTypes, const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > *PVars, Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed)
Transforms the parameters of a function type into the given vectors.
StmtResult RebuildGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
Build a new inline asm statement.
StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S)
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
Build a new template name given a nested name specifier and the name that is referred to as a templat...
TemplateName RebuildTemplateName(CXXScopeSpec &SS, bool TemplateKW, TemplateName Name)
Build a new template name given a nested name specifier, a flag indicating whether the "template" key...
ExprResult RebuildObjCMessageExpr(Expr *Receiver, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C instance message.
QualType TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB, SubstTemplateTypeParmPackTypeLoc TL, bool SuppressObjCLifetime)
ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool RequiresADL)
Build a new expression that references a declaration.
bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall, SmallVectorImpl< Expr * > &Outputs, bool *ArgChanged=nullptr)
Transform the given list of expressions.
StmtResult TransformSEHHandler(Stmt *Handler)
NestedNameSpecifierLoc TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr)
Transform the given nested-name-specifier with source-location information.
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, OverloadedOperatorKind Operator, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
Build a new template name given a nested name specifier and the overloaded operator name that is refe...
StmtResult RebuildOpenACCHostDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc)
Build a new C++11 decltype type.
OMPClause * RebuildOMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'use_device_ptr' clause.
void ExpandingFunctionParameterPack(ParmVarDecl *Pack)
Note to the derived class when a function parameter pack is being expanded.
void setBase(SourceLocation Loc, DeclarationName Entity)
Sets the "base" location and entity when that information is known based on another transformation.
concepts::TypeRequirement * TransformTypeRequirement(concepts::TypeRequirement *Req)
const Derived & getDerived() const
Retrieves a reference to the derived class.
ExprResult RebuildParenExpr(Expr *SubExpr, SourceLocation LParen, SourceLocation RParen)
Build a new expression in parentheses.
QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new block pointer type given its pointee type.
ExprResult RebuildMemberExpr(Expr *Base, SourceLocation OpLoc, bool isArrow, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, ValueDecl *Member, NamedDecl *FoundDecl, const TemplateArgumentListInfo *ExplicitTemplateArgs, NamedDecl *FirstQualifierInScope)
Build a new member access expression.
OMPClause * RebuildOMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'shared' clause.
ExprResult RebuildCXXConstructExpr(QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor, bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
Build a new object-construction expression.
bool TransformFunctionTypeParams(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const QualType *ParamTypes, const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > *PVars, Sema::ExtParameterInfoBuilder &PInfos)
OMPClause * RebuildOMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'linear' clause.
VarDecl * RebuildExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *Declarator, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Build a new C++ exception declaration.
ExprResult RebuildCXXNoexceptExpr(SourceRange Range, Expr *Arg)
Build a new noexcept expression.
QualType RebuildFunctionProtoType(QualType T, MutableArrayRef< QualType > ParamTypes, const FunctionProtoType::ExtProtoInfo &EPI)
Build a new function type.
ExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS, bool ForFoldExpression=false)
Build a new binary operator expression.
ExprResult RebuildObjCSubscriptRefExpr(SourceLocation RB, Expr *Base, Expr *Key, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
ExprResult RebuildRecoveryExpr(SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< Expr * > SubExprs, QualType Type)
ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, LambdaScopeInfo *LSI)
QualType RebuildIncompleteArrayType(QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new incomplete array type given the element type, size modifier, and index type qualifiers.
CXXRecordDecl::LambdaDependencyKind ComputeLambdaDependency(LambdaScopeInfo *LSI)
ExprResult RebuildPackIndexingExpr(SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpression, Expr *IndexExpr, ArrayRef< Expr * > ExpandedExprs, bool FullySubstituted=false)
StmtResult RebuildOpenACCInitConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, SourceLocation LParenLoc, Expr *Sub, SourceLocation RParenLoc, bool ListInitialization)
Build a new C++ functional-style cast expression.
QualType RebuildCanonicalTagType(TagDecl *Tag)
ExprResult RebuildObjCDictionaryLiteral(SourceRange Range, MutableArrayRef< ObjCDictionaryElement > Elements)
Build a new Objective-C dictionary literal.
StmtResult RebuildIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *Target)
Build a new indirect goto statement.
ExprResult RebuildExtVectorElementExpr(Expr *Base, SourceLocation OpLoc, bool IsArrow, SourceLocation AccessorLoc, IdentifierInfo &Accessor)
Build a new extended vector element access expression.
ExprResult RebuildParenListExpr(SourceLocation LParenLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new expression list in parentheses.
OMPClause * RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocator' clause.
QualType RebuildDependentSizedArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new dependent-sized array type given the element type, size modifier, size expression,...
NamedDecl * TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc)
Transform the given declaration, which was the first part of a nested-name-specifier in a member acce...
OMPClause * RebuildOMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'inclusive' clause.
StmtResult TransformOMPInformationalDirective(OMPExecutableDirective *S)
This is mostly the same as above, but allows 'informational' class directives when rebuilding the stm...
concepts::ExprRequirement * RebuildExprRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
ExprResult RebuildCXXFoldExpr(UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
Build a new C++1z fold-expression.
OMPClause * TransformOMPClause(OMPClause *S)
Transform the given statement.
QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc)
Build a new atomic type given its value type.
ExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *SubExpr)
Build a new C-style cast expression.
QualType RebuildObjCObjectPointerType(QualType PointeeType, SourceLocation Star)
Build a new Objective-C object pointer type given the pointee type.
OMPClause * RebuildOMPLoopRangeClause(Expr *First, Expr *Count, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc)
bool PreparePackForExpansion(TemplateArgumentLoc In, bool Uneval, TemplateArgumentLoc &Out, UnexpandedInfo &Info)
Checks if the argument pack from In will need to be expanded and does the necessary prework.
ExprResult TransformExpr(Expr *E)
Transform the given expression.
bool AlreadyTransformed(QualType T)
Determine whether the given type T has already been transformed.
concepts::TypeRequirement * RebuildTypeRequirement(TypeSourceInfo *T)
ExprResult RebuildOMPIteratorExpr(SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< SemaOpenMP::OMPIteratorData > Data)
Build a new iterator expression.
ExprResult RebuildSYCLUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
OMPClause * RebuildOMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'grainsize' clause.
OMPClause * RebuildOMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
bool TransformTemplateArguments(InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
OMPClause * RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'collapse' clause.
static ExprResult Owned(Expr *E)
ExprResult RebuildCXXUuidofExpr(QualType Type, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(expr) expression.
OMPClause * RebuildOMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_tasks' clause.
OMPClause * RebuildOMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'depobj' pseudo clause.
ExprResult RebuildChooseExpr(SourceLocation BuiltinLoc, Expr *Cond, Expr *LHS, Expr *RHS, SourceLocation RParenLoc)
Build a new __builtin_choose_expr expression.
OMPClause * RebuildOMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'align' clause.
ExprResult RebuildObjCMessageExpr(TypeSourceInfo *ReceiverTypeInfo, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C class message.
bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL, LookupResult &R)
Transform the set of declarations in an OverloadExpr.
QualType RebuildUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, UsingShadowDecl *D, QualType UnderlyingType)
Build a new type found via an alias.
ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, SourceLocation LParenOrBraceLoc, MultiExprArg Args, SourceLocation RParenOrBraceLoc, bool ListInitialization)
Build a new object-construction expression.
StmtResult RebuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init, SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps)
Build a new C++0x range-based for statement.
OMPClause * RebuildOMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Num)
Build a new OpenMP 'ordered' clause.
ExprResult RebuildCoyieldExpr(SourceLocation CoyieldLoc, Expr *Result)
Build a new co_yield expression.
StmtResult TransformStmt(Stmt *S, StmtDiscardKind SDK=StmtDiscardKind::Discarded)
Transform the given statement.
QualType RebuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo * > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build an Objective-C object type.
llvm::DenseMap< Decl *, Decl * > TransformedLocalDecls
OMPClause * RebuildOMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'novariants' clause.
StmtResult RebuildOpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E)
ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocatedType, TypeSourceInfo *AllocatedTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
Build a new C++ "new" expression.
StmtResult RebuildObjCForCollectionStmt(SourceLocation ForLoc, Stmt *Element, Expr *Collection, SourceLocation RParenLoc, Stmt *Body)
Build a new Objective-C fast enumeration statement.
ExprResult RebuildDependentScopeDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
Build a new (previously unresolved) declaration reference expression.
StmtResult RebuildObjCAtTryStmt(SourceLocation AtLoc, Stmt *TryBody, MultiStmtArg CatchStmts, Stmt *Finally)
Build a new Objective-C @try statement.
DeclarationName getBaseEntity()
Returns the name of the entity being transformed, if that information was not available elsewhere in ...
ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, bool ListInitialization)
Build a new object-construction expression.
ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, SourceLocation OpLoc, SourceLocation CalleeLoc, bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First, Expr *Second)
Build a new overloaded operator call expression.
OMPClause * RebuildOMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'use_device_addr' clause.
QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc)
Build a dependent bit-precise int given its value type.
OMPClause * RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'hint' clause.
Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var, Expr *Expr, Sema::ConditionKind Kind)
Transform the specified condition.
OMPClause * RebuildOMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'severity' clause.
OMPClause * RebuildOMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'firstprivate' clause.
StmtResult RebuildMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
Build a new MS style inline asm statement.
VarDecl * RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TInfo, QualType T)
Rebuild an Objective-C exception declaration.
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, IdentifierOrOverloadedOperator IO, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
concepts::NestedRequirement * TransformNestedRequirement(concepts::NestedRequirement *Req)
QualType RebuildConstantArrayType(QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new constant array type given the element type, size modifier, (known) size of the array,...
ExprResult RebuildOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > BracketsRanges)
Build a new array shaping expression.
MultiLevelTemplateArgumentList ForgetSubstitution()
"Forget" the template substitution to allow transforming the AST without any template instantiations.
ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc, bool IsGlobalDelete, bool IsArrayForm, Expr *Operand)
Build a new C++ "delete" expression.
bool TransformExceptionSpec(SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, SmallVectorImpl< QualType > &Exceptions, bool &Changed)
ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait, SourceLocation StartLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParenLoc)
Build a new array type trait expression.
OMPClause * RebuildOMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'is_device_ptr' clause.
QualType RebuildMacroQualifiedType(QualType T, const IdentifierInfo *MacroII)
Build a new MacroDefined type.
concepts::NestedRequirement * RebuildNestedRequirement(Expr *Constraint)
ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length, ArrayRef< TemplateArgument > PartialArgs)
Build a new expression to compute the length of a parameter pack.
ExprResult RebuildMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBracketLoc)
Build a new matrix subscript expression.
ExprResult TransformParenDependentScopeDeclRefExpr(ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
TemplateParameterList * TransformTemplateParameterList(TemplateParameterList *TPL)
void transformAttrs(Decl *Old, Decl *New)
Transform the attributes associated with the given declaration and place them on the new declaration.
QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL)
QualType RebuildTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &Args)
Build a new template specialization type.
Decl * TransformDecl(SourceLocation Loc, Decl *D)
Transform the given declaration, which is referenced from a type or expression.
bool AlwaysRebuild()
Whether the transformation should always rebuild AST nodes, even if none of the children have changed...
ExprResult RebuildObjCMessageExpr(SourceLocation SuperLoc, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, QualType SuperType, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C instance/class message to 'super'.
OMPClause * RebuildOMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'lastprivate' clause.
QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc, VectorKind)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
bool AllowSkippingCXXConstructExpr()
Wether CXXConstructExpr can be skipped when they are implicit.
OMPClause * RebuildOMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'safelen' clause.
StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *Init, Sema::ConditionResult Cond, SourceLocation RParenLoc)
Start building a new switch statement.
StmtResult RebuildDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new default statement.
StmtResult RebuildObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParenLoc, VarDecl *Var, Stmt *Body)
Build a new Objective-C @catch statement.
OMPClause * RebuildOMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'filter' clause.
ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base, SourceLocation OperatorLoc, bool isArrow, CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage Destroyed)
Build a new pseudo-destructor expression.
QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits, SourceLocation Loc)
Build a bit-precise int given its value type.
ExprResult RebuildObjCArrayLiteral(SourceRange Range, Expr **Elements, unsigned NumElements)
Build a new Objective-C array literal.
ExprResult RebuildCXXUuidofExpr(QualType Type, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(type) expression.
ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE, QualType BaseType, SourceLocation OperatorLoc, bool IsArrow, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs)
Build a new member reference expression.
OMPClause * RebuildOMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'bind' clause.
concepts::NestedRequirement * RebuildNestedRequirement(StringRef InvalidConstraintEntity, const ASTConstraintSatisfaction &Satisfaction)
OMPClause * RebuildOMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'copyprivate' clause.
QualType RebuildAutoType(QualType Deduced, AutoTypeKeyword Keyword, ConceptDecl *TypeConstraintConcept, ArrayRef< TemplateArgument > TypeConstraintArgs)
Build a new C++11 auto type.
QualType RebuildPackExpansionType(QualType Pattern, SourceRange PatternRange, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new pack expansion type.
QualType RebuildVariableArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new variable-length array type given the element type, size modifier, size expression,...
ExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ dynamic_cast expression.
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, TypeSourceInfo *ControllingType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
Build a new generic selection expression with a type predicate.
QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new pointer type given its pointee type.
concepts::TypeRequirement * RebuildTypeRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag)
OMPClause * RebuildOMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'permutation' clause.
OMPClause * RebuildOMPUsesAllocatorsClause(ArrayRef< SemaOpenMP::UsesAllocatorsData > Data, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'uses_allocators' clause.
ExprResult RebuildCXXInheritedCtorInitExpr(QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor, bool ConstructsVBase, bool InheritedFromVBase)
Build a new implicit construction via inherited constructor expression.
ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ const_cast expression.
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)
OMPClause * RebuildOMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'to' clause.
StmtResult RebuildDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation LParenLoc, Expr *Cond, SourceLocation RParenLoc)
Build a new do-while statement.
OMPClause * RebuildOMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'if' clause.
StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body)
Attach the body to a new case statement.
ExprResult RebuildTypeTrait(TypeTrait Trait, SourceLocation StartLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
Build a new type trait expression.
ExprResult RebuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Build an empty C++1z fold-expression with the given operator.
QualType TransformTypeWithDeducedTST(QualType T)
Transform a type that is permitted to produce a DeducedTemplateSpecializationType.
OMPClause * RebuildOMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'init' clause.
OMPClause * RebuildOMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'detach' clause.
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, MultiStmtArg Statements, SourceLocation RBraceLoc, bool IsStmtExpr)
Build a new compound statement.
ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, ValueDecl *VD, const DeclarationNameInfo &NameInfo, NamedDecl *Found, TemplateArgumentListInfo *TemplateArgs)
Build a new expression that references a declaration.
QualType RebuildArrayType(QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new array type given the element type, size modifier, size of the array (if known),...
StmtResult RebuildDeclStmt(MutableArrayRef< Decl * > Decls, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new declaration statement.
ExprResult RebuildConvertVectorExpr(SourceLocation BuiltinLoc, Expr *SrcExpr, TypeSourceInfo *DstTInfo, SourceLocation RParenLoc)
Build a new convert vector expression.
QualType RebuildQualifiedType(QualType T, QualifiedTypeLoc TL)
Build a new qualified type given its unqualified type and type location.
OMPClause * RebuildOMPDependClause(OMPDependClause::DependDataTy Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'depend' pseudo clause.
OMPClause * RebuildOMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'aligned' clause.
unsigned TransformTemplateDepth(unsigned Depth)
Transform a template parameter depth level.
QualType RebuildFunctionNoProtoType(QualType ResultType)
Build a new unprototyped function type.
QualType RebuildTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, TypedefNameDecl *Typedef)
Build a new typedef type.
QualType TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, Fn TransformExceptionSpec)
TemplateArgumentLoc RebuildPackExpansion(TemplateArgumentLoc Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new template argument pack expansion.
const Attr * TransformAttr(const Attr *S)
Transform the given attribute.
QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns)
Build a new matrix type given the element type and dimensions.
OMPClause * RebuildOMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'map' clause.
ExprResult RebuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Sub, SourceLocation RParenLoc)
Build a new C++ __builtin_bit_cast expression.
QualType RebuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted, ArrayRef< QualType > Expansions={})
StmtResult RebuildOMPCanonicalLoop(Stmt *LoopStmt)
Build a new OpenMP Canonical loop.
StmtResult RebuildOMPExecutableDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP executable directive.
concepts::ExprRequirement * RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
TypeSourceInfo * TransformType(TypeSourceInfo *TSI)
Transforms the given type-with-location into a new type-with-location.
ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
OMPClause * RebuildOMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP 'full' clause.
StmtResult RebuildSEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
OMPClause * RebuildOMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Build a new OpenMP 'affinity' clause.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(type) expression.
ExprResult RebuildCXXDependentScopeMemberExpr(Expr *BaseE, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Build a new member reference expression.
ExprResult RebuildCXXNamedCastExpr(SourceLocation OpLoc, Stmt::StmtClass Class, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ "named" cast expression, such as static_cast or reinterpret_cast.
StmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Attach the body to the switch statement.
TypeSourceInfo * InventTypeSourceInfo(QualType T)
Fakes up a TypeSourceInfo for a type.
ExprResult RebuildUnaryExprOrTypeTrait(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec_step expression with a type argument.
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
Build a new generic selection expression with an expression predicate.
QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool SuppressObjCLifetime)
Derived & getDerived()
Retrieves a reference to the derived class.
OMPClause * RebuildOMPHoldsClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'holds' clause.
StmtResult RebuildOpenACCAtomicConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, OpenACCAtomicKind AtKind, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssociatedStmt)
ExprResult RebuildArraySectionExpr(bool IsOMPArraySection, Expr *Base, SourceLocation LBracketLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBracketLoc)
Build a new array section expression.
concepts::ExprRequirement * TransformExprRequirement(concepts::ExprRequirement *Req)
QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc, TypeOfKind Kind)
Build a new typeof(expr) type.
bool ReplacingOriginal()
Whether the transformation is forming an expression or statement that replaces the original.
OMPClause * RebuildOMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'flush' pseudo clause.
bool TransformTemplateArgument(const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output, bool Uneval=false)
Transform the given template argument.
ExprResult RebuildArraySubscriptExpr(Expr *LHS, SourceLocation LBracketLoc, Expr *RHS, SourceLocation RBracketLoc)
Build a new array subscript expression.
OMPClause * RebuildOMPReductionClause(ArrayRef< Expr * > VarList, OpenMPReductionClauseModifier Modifier, OpenMPOriginalSharingModifier OriginalSharingModifier, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'reduction' clause.
QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements, SourceLocation AttributeLoc)
Build a new extended vector type given the element type and number of elements.
void transformedLocalDecl(Decl *Old, ArrayRef< Decl * > New)
Note that a local declaration has been transformed by this transformer.
ExprResult RebuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
Build a new Objective-C boxed expression.
ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub, bool IsThrownVariableInScope)
Build a new C++ throw expression.
bool TransformRequiresExprRequirements(ArrayRef< concepts::Requirement * > Reqs, llvm::SmallVectorImpl< concepts::Requirement * > &Transformed)
TemplateName TransformTemplateName(NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc, TemplateName Name, SourceLocation NameLoc, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr, bool AllowInjectedClassName=false)
Transform the given template name.
bool DropCallArgument(Expr *E)
Determine whether the given call argument should be dropped, e.g., because it is a default argument.
StmtResult RebuildGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new goto statement.
OMPClause * RebuildOMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'private' clause.
ExprResult RebuildObjCPropertyRefExpr(Expr *Base, QualType T, ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
ExprResult RebuildRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation ClosingBraceLoc)
Build a new requires expression.
ExprResult RebuildExpressionTrait(ExpressionTrait Trait, SourceLocation StartLoc, Expr *Queried, SourceLocation RParenLoc)
Build a new expression trait expression.
OMPClause * RebuildOMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'doacross' clause.
OMPClause * RebuildOMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'final' clause.
StmtResult RebuildIfStmt(SourceLocation IfLoc, IfStatementKind Kind, SourceLocation LParenLoc, Sema::ConditionResult Cond, SourceLocation RParenLoc, Stmt *Init, Stmt *Then, SourceLocation ElseLoc, Stmt *Else)
Build a new "if" statement.
bool TransformConceptTemplateArguments(InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs, bool Uneval=false)
TypeLoc getTypeLocInContext(ASTContext &Context, QualType T)
Copies the type-location information to the given AST context and returns a TypeLoc referring into th...
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
void TypeWasModifiedSafely(QualType T)
Tell the TypeLocBuilder that the type it is storing has been modified in some safe way that doesn't a...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
Definition TypeLoc.h:59
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition TypeLoc.h:349
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition TypeLoc.h:133
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition TypeLoc.h:89
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition TypeLoc.h:78
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition TypeLoc.h:154
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition TypeLoc.h:165
TypeLocClass getTypeLocClass() const
Definition TypeLoc.h:116
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition TypeLoc.h:2706
SourceLocation getBeginLoc() const
Get the begin source location.
Definition TypeLoc.cpp:193
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Definition TypeBase.h:6165
A container of type source information.
Definition TypeBase.h:8249
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:8260
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:2898
The base class of the type hierarchy.
Definition TypeBase.h:1833
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition TypeBase.h:2782
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition TypeBase.h:2405
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition TypeBase.h:9014
bool isObjCObjectPointerType() const
Definition TypeBase.h:8684
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9091
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3562
Wrapper for source info for typedefs.
Definition TypeLoc.h:777
void setTypeofLoc(SourceLocation Loc)
Definition TypeLoc.h:2171
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2625
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2244
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition Expr.h:2289
Expr * getSubExpr() const
Definition Expr.h:2285
Opcode getOpcode() const
Definition Expr.h:2280
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:1414
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2315
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:998
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3392
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition ExprCXX.h:3466
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition ExprCXX.h:3461
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Definition ExprCXX.cpp:432
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4128
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:5970
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition ExprCXX.h:640
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3395
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3459
Wrapper for source info for types used via transparent aliases.
Definition TypeLoc.h:785
Represents a call to the builtin function __builtin_va_arg.
Definition Expr.h:4891
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:5513
Value()=default
Represents a variable declaration or definition.
Definition Decl.h:926
@ CInit
C-style initialization with assignment.
Definition Decl.h:931
@ CallInit
Call-style initialization (C++98)
Definition Decl.h:934
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1168
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:3966
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2016
Represents a GCC generic vector type.
Definition TypeBase.h:4175
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2677
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
SourceLocation getNoexceptLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
Retains information about a block that is currently being parsed.
Definition ScopeInfo.h:790
bool ContainsUnexpandedParameterPack
Whether this contains an unexpanded parameter pack.
Definition ScopeInfo.h:728
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition ScopeInfo.h:871
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Definition ScopeInfo.h:874
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
VE builtins.
const AstTypeMatcher< FunctionType > functionType
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition Descriptor.h:29
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
Definition Interp.h:960
bool Inc(InterpState &S, CodePtr OpPC, bool CanOverflow)
1) Pops a pointer from the stack 2) Load the value from the pointer 3) Writes the value increased by ...
Definition Interp.h:776
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OpenMPOriginalSharingModifier
OpenMP 6.0 original sharing modifiers.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
OpenACCDirectiveKind
bool isa(CodeGen::Address addr)
Definition Address.h:330
ArrayTypeTrait
Names for the array type traits.
Definition TypeTraits.h:42
@ CPlusPlus23
OpenACCAtomicKind
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition TypeBase.h:1792
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
TryCaptureKind
Definition Sema.h:651
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
Definition Lookup.h:64
@ NotFound
No entity found met the criteria.
Definition Lookup.h:41
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
Definition Lookup.h:54
@ Found
Name lookup found a single declaration that met the criteria.
Definition Lookup.h:50
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
Definition Lookup.h:59
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Definition Lookup.h:46
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
Definition Specifiers.h:39
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:61
CXXConstructionKind
Definition ExprCXX.h:1541
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
Definition Specifiers.h:161
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
Definition Lambda.h:36
@ LCK_ByRef
Capturing by reference.
Definition Lambda.h:37
@ LCK_StarThis
Capturing the *this object by copy.
Definition Lambda.h:35
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition Sema.h:602
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
Definition Sema.h:236
@ 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:3719
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
@ Template
We are parsing a template declaration.
Definition Parser.h:81
ActionResult< CXXBaseSpecifier * > BaseResult
Definition Ownership.h:252
OpenMPGrainsizeClauseModifier
OpenMPNumTasksClauseModifier
TagTypeKind
The kind of a tag type.
Definition TypeBase.h:5878
bool transformOMPMappableExprListClause(TreeTransform< Derived > &TT, OMPMappableExprListClause< T > *C, llvm::SmallVectorImpl< Expr * > &Vars, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperIdInfo, llvm::SmallVectorImpl< Expr * > &UnresolvedMappers)
ExprResult ExprError()
Definition Ownership.h:265
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:560
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
std::tuple< NamedDecl *, TemplateArgument > getReplacedTemplateParameter(Decl *D, unsigned Index)
Internal helper used by Subst* nodes to retrieve a parameter from the AssociatedDecl,...
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
OpenMPAllocateClauseModifier
OpenMP modifiers for 'allocate' clause.
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition OpenMPKinds.h:63
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition OpenMPKinds.h:25
OpenMPDynGroupprivateClauseModifier
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:135
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition Specifiers.h:139
@ Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition Sema.h:798
@ Exists
The symbol exists.
Definition Sema.h:791
@ Error
An error occurred.
Definition Sema.h:801
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:794
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:4938
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5853
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5874
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5864
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5871
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:2247
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Uninstantiated
not instantiated yet
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition Expr.h:1989
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition OpenMPKinds.h:31
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition OpenMPKinds.h:71
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition ASTConcept.h:91
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:89
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition TypeBase.h:4991
Holds information about the various types of exception specification.
Definition TypeBase.h:5311
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5327
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5313
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5316
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5319
Extra information about a function prototype.
Definition TypeBase.h:5339
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5344
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:3275
const NamespaceBaseDecl * Namespace
Iterator range representation begin:end[:step].
Definition ExprOpenMP.h:154
Data for list of allocators.
This structure contains most locations needed for by an OMPVarListClause.
An element in an Objective-C dictionary literal.
Definition ExprObjC.h:261
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:13054
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13085
An RAII helper that pops function a function scope on exit.
Definition Sema.h:1303
Keeps information about an identifier in a nested-name-spec.
Definition Sema.h:3267
Location information for a TemplateArgument.
UnsignedOrNone OrigNumExpansions
SourceLocation Ellipsis
UnsignedOrNone NumExpansions