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 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2225 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2226 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2227 ArrayRef<Expr *> UnresolvedMappers) {
2229 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2230 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2231 UnresolvedMappers);
2232 }
2233
2234 /// Build a new OpenMP 'from' clause.
2235 ///
2236 /// By default, performs semantic analysis to build the new statement.
2237 /// Subclasses may override this routine to provide different behavior.
2238 OMPClause *
2240 ArrayRef<SourceLocation> MotionModifiersLoc,
2241 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2242 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2243 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2244 ArrayRef<Expr *> UnresolvedMappers) {
2246 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2247 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2248 UnresolvedMappers);
2249 }
2250
2251 /// Build a new OpenMP 'use_device_ptr' clause.
2252 ///
2253 /// By default, performs semantic analysis to build the new OpenMP clause.
2254 /// Subclasses may override this routine to provide different behavior.
2256 const OMPVarListLocTy &Locs) {
2257 return getSema().OpenMP().ActOnOpenMPUseDevicePtrClause(VarList, Locs);
2258 }
2259
2260 /// Build a new OpenMP 'use_device_addr' clause.
2261 ///
2262 /// By default, performs semantic analysis to build the new OpenMP clause.
2263 /// Subclasses may override this routine to provide different behavior.
2268
2269 /// Build a new OpenMP 'is_device_ptr' clause.
2270 ///
2271 /// By default, performs semantic analysis to build the new OpenMP clause.
2272 /// Subclasses may override this routine to provide different behavior.
2274 const OMPVarListLocTy &Locs) {
2275 return getSema().OpenMP().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
2276 }
2277
2278 /// Build a new OpenMP 'has_device_addr' clause.
2279 ///
2280 /// By default, performs semantic analysis to build the new OpenMP clause.
2281 /// Subclasses may override this routine to provide different behavior.
2286
2287 /// Build a new OpenMP 'defaultmap' clause.
2288 ///
2289 /// By default, performs semantic analysis to build the new OpenMP clause.
2290 /// Subclasses may override this routine to provide different behavior.
2293 SourceLocation StartLoc,
2294 SourceLocation LParenLoc,
2295 SourceLocation MLoc,
2296 SourceLocation KindLoc,
2297 SourceLocation EndLoc) {
2299 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2300 }
2301
2302 /// Build a new OpenMP 'nontemporal' clause.
2303 ///
2304 /// By default, performs semantic analysis to build the new OpenMP clause.
2305 /// Subclasses may override this routine to provide different behavior.
2307 SourceLocation StartLoc,
2308 SourceLocation LParenLoc,
2309 SourceLocation EndLoc) {
2310 return getSema().OpenMP().ActOnOpenMPNontemporalClause(VarList, StartLoc,
2311 LParenLoc, EndLoc);
2312 }
2313
2314 /// Build a new OpenMP 'inclusive' clause.
2315 ///
2316 /// By default, performs semantic analysis to build the new OpenMP clause.
2317 /// Subclasses may override this routine to provide different behavior.
2319 SourceLocation StartLoc,
2320 SourceLocation LParenLoc,
2321 SourceLocation EndLoc) {
2322 return getSema().OpenMP().ActOnOpenMPInclusiveClause(VarList, StartLoc,
2323 LParenLoc, EndLoc);
2324 }
2325
2326 /// Build a new OpenMP 'exclusive' clause.
2327 ///
2328 /// By default, performs semantic analysis to build the new OpenMP clause.
2329 /// Subclasses may override this routine to provide different behavior.
2331 SourceLocation StartLoc,
2332 SourceLocation LParenLoc,
2333 SourceLocation EndLoc) {
2334 return getSema().OpenMP().ActOnOpenMPExclusiveClause(VarList, StartLoc,
2335 LParenLoc, EndLoc);
2336 }
2337
2338 /// Build a new OpenMP 'uses_allocators' clause.
2339 ///
2340 /// By default, performs semantic analysis to build the new OpenMP clause.
2341 /// Subclasses may override this routine to provide different behavior.
2348
2349 /// Build a new OpenMP 'affinity' clause.
2350 ///
2351 /// By default, performs semantic analysis to build the new OpenMP clause.
2352 /// Subclasses may override this routine to provide different behavior.
2354 SourceLocation LParenLoc,
2355 SourceLocation ColonLoc,
2356 SourceLocation EndLoc, Expr *Modifier,
2357 ArrayRef<Expr *> Locators) {
2359 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2360 }
2361
2362 /// Build a new OpenMP 'order' clause.
2363 ///
2364 /// By default, performs semantic analysis to build the new OpenMP clause.
2365 /// Subclasses may override this routine to provide different behavior.
2367 OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc,
2368 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
2369 OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc) {
2371 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2372 }
2373
2374 /// Build a new OpenMP 'init' clause.
2375 ///
2376 /// By default, performs semantic analysis to build the new OpenMP clause.
2377 /// Subclasses may override this routine to provide different behavior.
2379 SourceLocation StartLoc,
2380 SourceLocation LParenLoc,
2381 SourceLocation VarLoc,
2382 SourceLocation EndLoc) {
2384 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2385 }
2386
2387 /// Build a new OpenMP 'use' clause.
2388 ///
2389 /// By default, performs semantic analysis to build the new OpenMP clause.
2390 /// Subclasses may override this routine to provide different behavior.
2392 SourceLocation LParenLoc,
2393 SourceLocation VarLoc, SourceLocation EndLoc) {
2394 return getSema().OpenMP().ActOnOpenMPUseClause(InteropVar, StartLoc,
2395 LParenLoc, VarLoc, EndLoc);
2396 }
2397
2398 /// Build a new OpenMP 'destroy' clause.
2399 ///
2400 /// By default, performs semantic analysis to build the new OpenMP clause.
2401 /// Subclasses may override this routine to provide different behavior.
2403 SourceLocation LParenLoc,
2404 SourceLocation VarLoc,
2405 SourceLocation EndLoc) {
2407 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2408 }
2409
2410 /// Build a new OpenMP 'novariants' clause.
2411 ///
2412 /// By default, performs semantic analysis to build the new OpenMP clause.
2413 /// Subclasses may override this routine to provide different behavior.
2415 SourceLocation StartLoc,
2416 SourceLocation LParenLoc,
2417 SourceLocation EndLoc) {
2419 LParenLoc, EndLoc);
2420 }
2421
2422 /// Build a new OpenMP 'nocontext' clause.
2423 ///
2424 /// By default, performs semantic analysis to build the new OpenMP clause.
2425 /// Subclasses may override this routine to provide different behavior.
2427 SourceLocation LParenLoc,
2428 SourceLocation EndLoc) {
2430 LParenLoc, EndLoc);
2431 }
2432
2433 /// Build a new OpenMP 'filter' clause.
2434 ///
2435 /// By default, performs semantic analysis to build the new OpenMP clause.
2436 /// Subclasses may override this routine to provide different behavior.
2438 SourceLocation LParenLoc,
2439 SourceLocation EndLoc) {
2440 return getSema().OpenMP().ActOnOpenMPFilterClause(ThreadID, StartLoc,
2441 LParenLoc, EndLoc);
2442 }
2443
2444 /// Build a new OpenMP 'bind' clause.
2445 ///
2446 /// By default, performs semantic analysis to build the new OpenMP clause.
2447 /// Subclasses may override this routine to provide different behavior.
2449 SourceLocation KindLoc,
2450 SourceLocation StartLoc,
2451 SourceLocation LParenLoc,
2452 SourceLocation EndLoc) {
2453 return getSema().OpenMP().ActOnOpenMPBindClause(Kind, KindLoc, StartLoc,
2454 LParenLoc, EndLoc);
2455 }
2456
2457 /// Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
2458 ///
2459 /// By default, performs semantic analysis to build the new OpenMP clause.
2460 /// Subclasses may override this routine to provide different behavior.
2462 SourceLocation LParenLoc,
2463 SourceLocation EndLoc) {
2464 return getSema().OpenMP().ActOnOpenMPXDynCGroupMemClause(Size, StartLoc,
2465 LParenLoc, EndLoc);
2466 }
2467
2468 /// Build a new OpenMP 'dyn_groupprivate' clause.
2469 ///
2470 /// By default, performs semantic analysis to build the new OpenMP clause.
2471 /// Subclasses may override this routine to provide different behavior.
2475 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc,
2476 SourceLocation M2Loc, SourceLocation EndLoc) {
2478 M1, M2, Size, StartLoc, LParenLoc, M1Loc, M2Loc, EndLoc);
2479 }
2480
2481 /// Build a new OpenMP 'ompx_attribute' clause.
2482 ///
2483 /// By default, performs semantic analysis to build the new OpenMP clause.
2484 /// Subclasses may override this routine to provide different behavior.
2486 SourceLocation StartLoc,
2487 SourceLocation LParenLoc,
2488 SourceLocation EndLoc) {
2489 return getSema().OpenMP().ActOnOpenMPXAttributeClause(Attrs, StartLoc,
2490 LParenLoc, EndLoc);
2491 }
2492
2493 /// Build a new OpenMP 'ompx_bare' clause.
2494 ///
2495 /// By default, performs semantic analysis to build the new OpenMP clause.
2496 /// Subclasses may override this routine to provide different behavior.
2498 SourceLocation EndLoc) {
2499 return getSema().OpenMP().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2500 }
2501
2502 /// Build a new OpenMP 'align' clause.
2503 ///
2504 /// By default, performs semantic analysis to build the new OpenMP clause.
2505 /// Subclasses may override this routine to provide different behavior.
2507 SourceLocation LParenLoc,
2508 SourceLocation EndLoc) {
2509 return getSema().OpenMP().ActOnOpenMPAlignClause(A, StartLoc, LParenLoc,
2510 EndLoc);
2511 }
2512
2513 /// Build a new OpenMP 'at' clause.
2514 ///
2515 /// By default, performs semantic analysis to build the new OpenMP clause.
2516 /// Subclasses may override this routine to provide different behavior.
2518 SourceLocation StartLoc,
2519 SourceLocation LParenLoc,
2520 SourceLocation EndLoc) {
2521 return getSema().OpenMP().ActOnOpenMPAtClause(Kind, KwLoc, StartLoc,
2522 LParenLoc, EndLoc);
2523 }
2524
2525 /// Build a new OpenMP 'severity' clause.
2526 ///
2527 /// By default, performs semantic analysis to build the new OpenMP clause.
2528 /// Subclasses may override this routine to provide different behavior.
2530 SourceLocation KwLoc,
2531 SourceLocation StartLoc,
2532 SourceLocation LParenLoc,
2533 SourceLocation EndLoc) {
2534 return getSema().OpenMP().ActOnOpenMPSeverityClause(Kind, KwLoc, StartLoc,
2535 LParenLoc, EndLoc);
2536 }
2537
2538 /// Build a new OpenMP 'message' clause.
2539 ///
2540 /// By default, performs semantic analysis to build the new OpenMP clause.
2541 /// Subclasses may override this routine to provide different behavior.
2543 SourceLocation LParenLoc,
2544 SourceLocation EndLoc) {
2545 return getSema().OpenMP().ActOnOpenMPMessageClause(MS, StartLoc, LParenLoc,
2546 EndLoc);
2547 }
2548
2549 /// Build a new OpenMP 'doacross' clause.
2550 ///
2551 /// By default, performs semantic analysis to build the new OpenMP clause.
2552 /// Subclasses may override this routine to provide different behavior.
2553 OMPClause *
2555 SourceLocation DepLoc, SourceLocation ColonLoc,
2556 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2557 SourceLocation LParenLoc, SourceLocation EndLoc) {
2559 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2560 }
2561
2562 /// Build a new OpenMP 'holds' clause.
2564 SourceLocation LParenLoc,
2565 SourceLocation EndLoc) {
2566 return getSema().OpenMP().ActOnOpenMPHoldsClause(A, StartLoc, LParenLoc,
2567 EndLoc);
2568 }
2569
2570 /// Rebuild the operand to an Objective-C \@synchronized statement.
2571 ///
2572 /// By default, performs semantic analysis to build the new statement.
2573 /// Subclasses may override this routine to provide different behavior.
2578
2579 /// Build a new Objective-C \@synchronized statement.
2580 ///
2581 /// By default, performs semantic analysis to build the new statement.
2582 /// Subclasses may override this routine to provide different behavior.
2584 Expr *Object, Stmt *Body) {
2585 return getSema().ObjC().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
2586 }
2587
2588 /// Build a new Objective-C \@autoreleasepool statement.
2589 ///
2590 /// By default, performs semantic analysis to build the new statement.
2591 /// Subclasses may override this routine to provide different behavior.
2596
2597 /// Build a new Objective-C fast enumeration statement.
2598 ///
2599 /// By default, performs semantic analysis to build the new statement.
2600 /// Subclasses may override this routine to provide different behavior.
2602 Stmt *Element,
2603 Expr *Collection,
2604 SourceLocation RParenLoc,
2605 Stmt *Body) {
2607 ForLoc, Element, Collection, RParenLoc);
2608 if (ForEachStmt.isInvalid())
2609 return StmtError();
2610
2611 return getSema().ObjC().FinishObjCForCollectionStmt(ForEachStmt.get(),
2612 Body);
2613 }
2614
2615 /// Build a new C++ exception declaration.
2616 ///
2617 /// By default, performs semantic analysis to build the new decaration.
2618 /// Subclasses may override this routine to provide different behavior.
2621 SourceLocation StartLoc,
2622 SourceLocation IdLoc,
2623 IdentifierInfo *Id) {
2625 StartLoc, IdLoc, Id);
2626 if (Var)
2627 getSema().CurContext->addDecl(Var);
2628 return Var;
2629 }
2630
2631 /// Build a new C++ catch statement.
2632 ///
2633 /// By default, performs semantic analysis to build the new statement.
2634 /// Subclasses may override this routine to provide different behavior.
2636 VarDecl *ExceptionDecl,
2637 Stmt *Handler) {
2638 return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2639 Handler));
2640 }
2641
2642 /// Build a new C++ try statement.
2643 ///
2644 /// By default, performs semantic analysis to build the new statement.
2645 /// Subclasses may override this routine to provide different behavior.
2647 ArrayRef<Stmt *> Handlers) {
2648 return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2649 }
2650
2651 /// Build a new C++0x range-based for statement.
2652 ///
2653 /// By default, performs semantic analysis to build the new statement.
2654 /// Subclasses may override this routine to provide different behavior.
2656 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init,
2657 SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond,
2658 Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc,
2659 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
2660 // If we've just learned that the range is actually an Objective-C
2661 // collection, treat this as an Objective-C fast enumeration loop.
2662 if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2663 if (RangeStmt->isSingleDecl()) {
2664 if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2665 if (RangeVar->isInvalidDecl())
2666 return StmtError();
2667
2668 Expr *RangeExpr = RangeVar->getInit();
2669 if (!RangeExpr->isTypeDependent() &&
2670 RangeExpr->getType()->isObjCObjectPointerType()) {
2671 // FIXME: Support init-statements in Objective-C++20 ranged for
2672 // statement.
2673 if (Init) {
2674 return SemaRef.Diag(Init->getBeginLoc(),
2675 diag::err_objc_for_range_init_stmt)
2676 << Init->getSourceRange();
2677 }
2679 ForLoc, LoopVar, RangeExpr, RParenLoc);
2680 }
2681 }
2682 }
2683 }
2684
2686 ForLoc, CoawaitLoc, Init, ColonLoc, Range, Begin, End, Cond, Inc,
2687 LoopVar, RParenLoc, Sema::BFRK_Rebuild, LifetimeExtendTemps);
2688 }
2689
2690 /// Build a new C++0x range-based for statement.
2691 ///
2692 /// By default, performs semantic analysis to build the new statement.
2693 /// Subclasses may override this routine to provide different behavior.
2695 bool IsIfExists,
2696 NestedNameSpecifierLoc QualifierLoc,
2697 DeclarationNameInfo NameInfo,
2698 Stmt *Nested) {
2699 return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2700 QualifierLoc, NameInfo, Nested);
2701 }
2702
2703 /// Attach body to a C++0x range-based for statement.
2704 ///
2705 /// By default, performs semantic analysis to finish the new statement.
2706 /// Subclasses may override this routine to provide different behavior.
2708 return getSema().FinishCXXForRangeStmt(ForRange, Body);
2709 }
2710
2712 Stmt *TryBlock, Stmt *Handler) {
2713 return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2714 }
2715
2717 Stmt *Block) {
2718 return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2719 }
2720
2722 return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2723 }
2724
2726 SourceLocation LParen,
2727 SourceLocation RParen,
2728 TypeSourceInfo *TSI) {
2729 return getSema().SYCL().BuildUniqueStableNameExpr(OpLoc, LParen, RParen,
2730 TSI);
2731 }
2732
2733 /// Build a new predefined expression.
2734 ///
2735 /// By default, performs semantic analysis to build the new expression.
2736 /// Subclasses may override this routine to provide different behavior.
2740
2741 /// Build a new expression that references a declaration.
2742 ///
2743 /// By default, performs semantic analysis to build the new expression.
2744 /// Subclasses may override this routine to provide different behavior.
2746 LookupResult &R,
2747 bool RequiresADL) {
2748 return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2749 }
2750
2751
2752 /// Build a new expression that references a declaration.
2753 ///
2754 /// By default, performs semantic analysis to build the new expression.
2755 /// Subclasses may override this routine to provide different behavior.
2757 ValueDecl *VD,
2758 const DeclarationNameInfo &NameInfo,
2760 TemplateArgumentListInfo *TemplateArgs) {
2761 CXXScopeSpec SS;
2762 SS.Adopt(QualifierLoc);
2763 return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2764 TemplateArgs);
2765 }
2766
2767 /// Build a new expression in parentheses.
2768 ///
2769 /// By default, performs semantic analysis to build the new expression.
2770 /// Subclasses may override this routine to provide different behavior.
2772 SourceLocation RParen) {
2773 return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2774 }
2775
2776 /// Build a new pseudo-destructor expression.
2777 ///
2778 /// By default, performs semantic analysis to build the new expression.
2779 /// Subclasses may override this routine to provide different behavior.
2781 SourceLocation OperatorLoc,
2782 bool isArrow,
2783 CXXScopeSpec &SS,
2784 TypeSourceInfo *ScopeType,
2785 SourceLocation CCLoc,
2786 SourceLocation TildeLoc,
2787 PseudoDestructorTypeStorage Destroyed);
2788
2789 /// Build a new unary operator expression.
2790 ///
2791 /// By default, performs semantic analysis to build the new expression.
2792 /// Subclasses may override this routine to provide different behavior.
2795 Expr *SubExpr) {
2796 return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2797 }
2798
2799 /// Build a new builtin offsetof expression.
2800 ///
2801 /// By default, performs semantic analysis to build the new expression.
2802 /// Subclasses may override this routine to provide different behavior.
2806 SourceLocation RParenLoc) {
2807 return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2808 RParenLoc);
2809 }
2810
2811 /// Build a new sizeof, alignof or vec_step expression with a
2812 /// type argument.
2813 ///
2814 /// By default, performs semantic analysis to build the new expression.
2815 /// Subclasses may override this routine to provide different behavior.
2817 SourceLocation OpLoc,
2818 UnaryExprOrTypeTrait ExprKind,
2819 SourceRange R) {
2820 return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2821 }
2822
2823 /// Build a new sizeof, alignof or vec step expression with an
2824 /// expression argument.
2825 ///
2826 /// By default, performs semantic analysis to build the new expression.
2827 /// Subclasses may override this routine to provide different behavior.
2829 UnaryExprOrTypeTrait ExprKind,
2830 SourceRange R) {
2832 = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2833 if (Result.isInvalid())
2834 return ExprError();
2835
2836 return Result;
2837 }
2838
2839 /// Build a new array subscript expression.
2840 ///
2841 /// By default, performs semantic analysis to build the new expression.
2842 /// Subclasses may override this routine to provide different behavior.
2844 SourceLocation LBracketLoc,
2845 Expr *RHS,
2846 SourceLocation RBracketLoc) {
2847 return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2848 LBracketLoc, RHS,
2849 RBracketLoc);
2850 }
2851
2852 /// Build a new matrix subscript expression.
2853 ///
2854 /// By default, performs semantic analysis to build the new expression.
2855 /// Subclasses may override this routine to provide different behavior.
2857 Expr *ColumnIdx,
2858 SourceLocation RBracketLoc) {
2859 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2860 RBracketLoc);
2861 }
2862
2863 /// Build a new array section expression.
2864 ///
2865 /// By default, performs semantic analysis to build the new expression.
2866 /// Subclasses may override this routine to provide different behavior.
2868 SourceLocation LBracketLoc,
2869 Expr *LowerBound,
2870 SourceLocation ColonLocFirst,
2871 SourceLocation ColonLocSecond,
2872 Expr *Length, Expr *Stride,
2873 SourceLocation RBracketLoc) {
2874 if (IsOMPArraySection)
2876 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2877 Stride, RBracketLoc);
2878
2879 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2880 "Stride/second colon not allowed for OpenACC");
2881
2883 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2884 }
2885
2886 /// Build a new array shaping expression.
2887 ///
2888 /// By default, performs semantic analysis to build the new expression.
2889 /// Subclasses may override this routine to provide different behavior.
2891 SourceLocation RParenLoc,
2892 ArrayRef<Expr *> Dims,
2893 ArrayRef<SourceRange> BracketsRanges) {
2895 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2896 }
2897
2898 /// Build a new iterator expression.
2899 ///
2900 /// By default, performs semantic analysis to build the new expression.
2901 /// Subclasses may override this routine to provide different behavior.
2904 SourceLocation RLoc,
2907 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2908 }
2909
2910 /// Build a new call expression.
2911 ///
2912 /// By default, performs semantic analysis to build the new expression.
2913 /// Subclasses may override this routine to provide different behavior.
2915 MultiExprArg Args,
2916 SourceLocation RParenLoc,
2917 Expr *ExecConfig = nullptr) {
2918 return getSema().ActOnCallExpr(
2919 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2920 }
2921
2923 MultiExprArg Args,
2924 SourceLocation RParenLoc) {
2926 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2927 }
2928
2929 /// Build a new member access expression.
2930 ///
2931 /// By default, performs semantic analysis to build the new expression.
2932 /// Subclasses may override this routine to provide different behavior.
2934 bool isArrow,
2935 NestedNameSpecifierLoc QualifierLoc,
2936 SourceLocation TemplateKWLoc,
2937 const DeclarationNameInfo &MemberNameInfo,
2939 NamedDecl *FoundDecl,
2940 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2941 NamedDecl *FirstQualifierInScope) {
2943 isArrow);
2944 if (!Member->getDeclName()) {
2945 // We have a reference to an unnamed field. This is always the
2946 // base of an anonymous struct/union member access, i.e. the
2947 // field is always of record type.
2948 assert(Member->getType()->isRecordType() &&
2949 "unnamed member not of record type?");
2950
2951 BaseResult =
2953 QualifierLoc.getNestedNameSpecifier(),
2954 FoundDecl, Member);
2955 if (BaseResult.isInvalid())
2956 return ExprError();
2957 Base = BaseResult.get();
2958
2959 // `TranformMaterializeTemporaryExpr()` removes materialized temporaries
2960 // from the AST, so we need to re-insert them if needed (since
2961 // `BuildFieldRefereneExpr()` doesn't do this).
2962 if (!isArrow && Base->isPRValue()) {
2964 if (BaseResult.isInvalid())
2965 return ExprError();
2966 Base = BaseResult.get();
2967 }
2968
2969 CXXScopeSpec EmptySS;
2971 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
2972 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
2973 MemberNameInfo);
2974 }
2975
2976 CXXScopeSpec SS;
2977 SS.Adopt(QualifierLoc);
2978
2979 Base = BaseResult.get();
2980 if (Base->containsErrors())
2981 return ExprError();
2982
2983 QualType BaseType = Base->getType();
2984
2985 if (isArrow && !BaseType->isPointerType())
2986 return ExprError();
2987
2988 // FIXME: this involves duplicating earlier analysis in a lot of
2989 // cases; we should avoid this when possible.
2990 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
2991 R.addDecl(FoundDecl);
2992 R.resolveKind();
2993
2994 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
2996 if (auto *ThisClass = cast<CXXThisExpr>(Base)
2997 ->getType()
2998 ->getPointeeType()
2999 ->getAsCXXRecordDecl()) {
3000 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
3001 // In unevaluated contexts, an expression supposed to be a member access
3002 // might reference a member in an unrelated class.
3003 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
3004 return getSema().BuildDeclRefExpr(Member, Member->getType(),
3005 VK_LValue, Member->getLocation());
3006 }
3007 }
3008
3009 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
3010 SS, TemplateKWLoc,
3011 FirstQualifierInScope,
3012 R, ExplicitTemplateArgs,
3013 /*S*/nullptr);
3014 }
3015
3016 /// Build a new binary operator expression.
3017 ///
3018 /// By default, performs semantic analysis to build the new expression.
3019 /// Subclasses may override this routine to provide different behavior.
3021 Expr *LHS, Expr *RHS,
3022 bool ForFoldExpression = false) {
3023 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS,
3024 ForFoldExpression);
3025 }
3026
3027 /// Build a new rewritten operator expression.
3028 ///
3029 /// By default, performs semantic analysis to build the new expression.
3030 /// Subclasses may override this routine to provide different behavior.
3032 SourceLocation OpLoc, BinaryOperatorKind Opcode,
3033 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
3034 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
3035 RHS, /*RequiresADL*/false);
3036 }
3037
3038 /// Build a new conditional operator expression.
3039 ///
3040 /// By default, performs semantic analysis to build the new expression.
3041 /// Subclasses may override this routine to provide different behavior.
3043 SourceLocation QuestionLoc,
3044 Expr *LHS,
3045 SourceLocation ColonLoc,
3046 Expr *RHS) {
3047 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
3048 LHS, RHS);
3049 }
3050
3051 /// Build a new C-style cast expression.
3052 ///
3053 /// By default, performs semantic analysis to build the new expression.
3054 /// Subclasses may override this routine to provide different behavior.
3056 TypeSourceInfo *TInfo,
3057 SourceLocation RParenLoc,
3058 Expr *SubExpr) {
3059 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
3060 SubExpr);
3061 }
3062
3063 /// Build a new compound literal expression.
3064 ///
3065 /// By default, performs semantic analysis to build the new expression.
3066 /// Subclasses may override this routine to provide different behavior.
3068 TypeSourceInfo *TInfo,
3069 SourceLocation RParenLoc,
3070 Expr *Init) {
3071 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
3072 Init);
3073 }
3074
3075 /// Build a new extended vector element access expression.
3076 ///
3077 /// By default, performs semantic analysis to build the new expression.
3078 /// Subclasses may override this routine to provide different behavior.
3080 bool IsArrow,
3081 SourceLocation AccessorLoc,
3082 IdentifierInfo &Accessor) {
3083
3084 CXXScopeSpec SS;
3085 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3087 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3088 /*FirstQualifierInScope*/ nullptr, NameInfo,
3089 /* TemplateArgs */ nullptr,
3090 /*S*/ nullptr);
3091 }
3092
3093 /// Build a new initializer list expression.
3094 ///
3095 /// By default, performs semantic analysis to build the new expression.
3096 /// Subclasses may override this routine to provide different behavior.
3098 MultiExprArg Inits,
3099 SourceLocation RBraceLoc) {
3100 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
3101 }
3102
3103 /// Build a new designated initializer expression.
3104 ///
3105 /// By default, performs semantic analysis to build the new expression.
3106 /// Subclasses may override this routine to provide different behavior.
3108 MultiExprArg ArrayExprs,
3109 SourceLocation EqualOrColonLoc,
3110 bool GNUSyntax,
3111 Expr *Init) {
3113 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3114 Init);
3115 if (Result.isInvalid())
3116 return ExprError();
3117
3118 return Result;
3119 }
3120
3121 /// Build a new value-initialized expression.
3122 ///
3123 /// By default, builds the implicit value initialization without performing
3124 /// any semantic analysis. Subclasses may override this routine to provide
3125 /// different behavior.
3129
3130 /// Build a new \c va_arg expression.
3131 ///
3132 /// By default, performs semantic analysis to build the new expression.
3133 /// Subclasses may override this routine to provide different behavior.
3135 Expr *SubExpr, TypeSourceInfo *TInfo,
3136 SourceLocation RParenLoc) {
3137 return getSema().BuildVAArgExpr(BuiltinLoc,
3138 SubExpr, TInfo,
3139 RParenLoc);
3140 }
3141
3142 /// Build a new expression list in parentheses.
3143 ///
3144 /// By default, performs semantic analysis to build the new expression.
3145 /// Subclasses may override this routine to provide different behavior.
3147 MultiExprArg SubExprs,
3148 SourceLocation RParenLoc) {
3149 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3150 }
3151
3153 unsigned NumUserSpecifiedExprs,
3154 SourceLocation InitLoc,
3155 SourceLocation LParenLoc,
3156 SourceLocation RParenLoc) {
3157 return getSema().ActOnCXXParenListInitExpr(Args, T, NumUserSpecifiedExprs,
3158 InitLoc, LParenLoc, RParenLoc);
3159 }
3160
3161 /// Build a new address-of-label expression.
3162 ///
3163 /// By default, performs semantic analysis, using the name of the label
3164 /// rather than attempting to map the label statement itself.
3165 /// Subclasses may override this routine to provide different behavior.
3167 SourceLocation LabelLoc, LabelDecl *Label) {
3168 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3169 }
3170
3171 /// Build a new GNU statement expression.
3172 ///
3173 /// By default, performs semantic analysis to build the new expression.
3174 /// Subclasses may override this routine to provide different behavior.
3176 SourceLocation RParenLoc, unsigned TemplateDepth) {
3177 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3178 TemplateDepth);
3179 }
3180
3181 /// Build a new __builtin_choose_expr expression.
3182 ///
3183 /// By default, performs semantic analysis to build the new expression.
3184 /// Subclasses may override this routine to provide different behavior.
3186 Expr *Cond, Expr *LHS, Expr *RHS,
3187 SourceLocation RParenLoc) {
3188 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3189 Cond, LHS, RHS,
3190 RParenLoc);
3191 }
3192
3193 /// Build a new generic selection expression with an expression predicate.
3194 ///
3195 /// By default, performs semantic analysis to build the new expression.
3196 /// Subclasses may override this routine to provide different behavior.
3198 SourceLocation DefaultLoc,
3199 SourceLocation RParenLoc,
3200 Expr *ControllingExpr,
3202 ArrayRef<Expr *> Exprs) {
3203 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3204 /*PredicateIsExpr=*/true,
3205 ControllingExpr, Types, Exprs);
3206 }
3207
3208 /// Build a new generic selection expression with a type predicate.
3209 ///
3210 /// By default, performs semantic analysis to build the new expression.
3211 /// Subclasses may override this routine to provide different behavior.
3213 SourceLocation DefaultLoc,
3214 SourceLocation RParenLoc,
3215 TypeSourceInfo *ControllingType,
3217 ArrayRef<Expr *> Exprs) {
3218 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3219 /*PredicateIsExpr=*/false,
3220 ControllingType, Types, Exprs);
3221 }
3222
3223 /// Build a new overloaded operator call expression.
3224 ///
3225 /// By default, performs semantic analysis to build the new expression.
3226 /// The semantic analysis provides the behavior of template instantiation,
3227 /// copying with transformations that turn what looks like an overloaded
3228 /// operator call into a use of a builtin operator, performing
3229 /// argument-dependent lookup, etc. Subclasses may override this routine to
3230 /// provide different behavior.
3232 SourceLocation OpLoc,
3233 SourceLocation CalleeLoc,
3234 bool RequiresADL,
3235 const UnresolvedSetImpl &Functions,
3236 Expr *First, Expr *Second);
3237
3238 /// Build a new C++ "named" cast expression, such as static_cast or
3239 /// reinterpret_cast.
3240 ///
3241 /// By default, this routine dispatches to one of the more-specific routines
3242 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3243 /// Subclasses may override this routine to provide different behavior.
3246 SourceLocation LAngleLoc,
3247 TypeSourceInfo *TInfo,
3248 SourceLocation RAngleLoc,
3249 SourceLocation LParenLoc,
3250 Expr *SubExpr,
3251 SourceLocation RParenLoc) {
3252 switch (Class) {
3253 case Stmt::CXXStaticCastExprClass:
3254 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3255 RAngleLoc, LParenLoc,
3256 SubExpr, RParenLoc);
3257
3258 case Stmt::CXXDynamicCastExprClass:
3259 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3260 RAngleLoc, LParenLoc,
3261 SubExpr, RParenLoc);
3262
3263 case Stmt::CXXReinterpretCastExprClass:
3264 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3265 RAngleLoc, LParenLoc,
3266 SubExpr,
3267 RParenLoc);
3268
3269 case Stmt::CXXConstCastExprClass:
3270 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3271 RAngleLoc, LParenLoc,
3272 SubExpr, RParenLoc);
3273
3274 case Stmt::CXXAddrspaceCastExprClass:
3275 return getDerived().RebuildCXXAddrspaceCastExpr(
3276 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3277
3278 default:
3279 llvm_unreachable("Invalid C++ named cast");
3280 }
3281 }
3282
3283 /// Build a new C++ static_cast expression.
3284 ///
3285 /// By default, performs semantic analysis to build the new expression.
3286 /// Subclasses may override this routine to provide different behavior.
3288 SourceLocation LAngleLoc,
3289 TypeSourceInfo *TInfo,
3290 SourceLocation RAngleLoc,
3291 SourceLocation LParenLoc,
3292 Expr *SubExpr,
3293 SourceLocation RParenLoc) {
3294 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3295 TInfo, SubExpr,
3296 SourceRange(LAngleLoc, RAngleLoc),
3297 SourceRange(LParenLoc, RParenLoc));
3298 }
3299
3300 /// Build a new C++ dynamic_cast expression.
3301 ///
3302 /// By default, performs semantic analysis to build the new expression.
3303 /// Subclasses may override this routine to provide different behavior.
3305 SourceLocation LAngleLoc,
3306 TypeSourceInfo *TInfo,
3307 SourceLocation RAngleLoc,
3308 SourceLocation LParenLoc,
3309 Expr *SubExpr,
3310 SourceLocation RParenLoc) {
3311 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3312 TInfo, SubExpr,
3313 SourceRange(LAngleLoc, RAngleLoc),
3314 SourceRange(LParenLoc, RParenLoc));
3315 }
3316
3317 /// Build a new C++ reinterpret_cast expression.
3318 ///
3319 /// By default, performs semantic analysis to build the new expression.
3320 /// Subclasses may override this routine to provide different behavior.
3322 SourceLocation LAngleLoc,
3323 TypeSourceInfo *TInfo,
3324 SourceLocation RAngleLoc,
3325 SourceLocation LParenLoc,
3326 Expr *SubExpr,
3327 SourceLocation RParenLoc) {
3328 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3329 TInfo, SubExpr,
3330 SourceRange(LAngleLoc, RAngleLoc),
3331 SourceRange(LParenLoc, RParenLoc));
3332 }
3333
3334 /// Build a new C++ const_cast expression.
3335 ///
3336 /// By default, performs semantic analysis to build the new expression.
3337 /// Subclasses may override this routine to provide different behavior.
3339 SourceLocation LAngleLoc,
3340 TypeSourceInfo *TInfo,
3341 SourceLocation RAngleLoc,
3342 SourceLocation LParenLoc,
3343 Expr *SubExpr,
3344 SourceLocation RParenLoc) {
3345 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3346 TInfo, SubExpr,
3347 SourceRange(LAngleLoc, RAngleLoc),
3348 SourceRange(LParenLoc, RParenLoc));
3349 }
3350
3353 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3354 SourceLocation LParenLoc, Expr *SubExpr,
3355 SourceLocation RParenLoc) {
3356 return getSema().BuildCXXNamedCast(
3357 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3358 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3359 }
3360
3361 /// Build a new C++ functional-style cast expression.
3362 ///
3363 /// By default, performs semantic analysis to build the new expression.
3364 /// Subclasses may override this routine to provide different behavior.
3366 SourceLocation LParenLoc,
3367 Expr *Sub,
3368 SourceLocation RParenLoc,
3369 bool ListInitialization) {
3370 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3371 // CXXParenListInitExpr. Pass its expanded arguments so that the
3372 // CXXParenListInitExpr can be rebuilt.
3373 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3375 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3376 RParenLoc, ListInitialization);
3377
3378 if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub))
3380 TInfo, LParenLoc, PLE->getInitExprs(), RParenLoc, ListInitialization);
3381
3382 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3383 MultiExprArg(&Sub, 1), RParenLoc,
3384 ListInitialization);
3385 }
3386
3387 /// Build a new C++ __builtin_bit_cast expression.
3388 ///
3389 /// By default, performs semantic analysis to build the new expression.
3390 /// Subclasses may override this routine to provide different behavior.
3392 TypeSourceInfo *TSI, Expr *Sub,
3393 SourceLocation RParenLoc) {
3394 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3395 }
3396
3397 /// Build a new C++ typeid(type) expression.
3398 ///
3399 /// By default, performs semantic analysis to build the new expression.
3400 /// Subclasses may override this routine to provide different behavior.
3402 SourceLocation TypeidLoc,
3403 TypeSourceInfo *Operand,
3404 SourceLocation RParenLoc) {
3405 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3406 RParenLoc);
3407 }
3408
3409
3410 /// Build a new C++ typeid(expr) expression.
3411 ///
3412 /// By default, performs semantic analysis to build the new expression.
3413 /// Subclasses may override this routine to provide different behavior.
3415 SourceLocation TypeidLoc,
3416 Expr *Operand,
3417 SourceLocation RParenLoc) {
3418 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3419 RParenLoc);
3420 }
3421
3422 /// Build a new C++ __uuidof(type) expression.
3423 ///
3424 /// By default, performs semantic analysis to build the new expression.
3425 /// Subclasses may override this routine to provide different behavior.
3427 TypeSourceInfo *Operand,
3428 SourceLocation RParenLoc) {
3429 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3430 }
3431
3432 /// Build a new C++ __uuidof(expr) expression.
3433 ///
3434 /// By default, performs semantic analysis to build the new expression.
3435 /// Subclasses may override this routine to provide different behavior.
3437 Expr *Operand, SourceLocation RParenLoc) {
3438 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3439 }
3440
3441 /// Build a new C++ "this" expression.
3442 ///
3443 /// By default, performs semantic analysis to build a new "this" expression.
3444 /// Subclasses may override this routine to provide different behavior.
3446 QualType ThisType,
3447 bool isImplicit) {
3448 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3449 return ExprError();
3450 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3451 }
3452
3453 /// Build a new C++ throw expression.
3454 ///
3455 /// By default, performs semantic analysis to build the new expression.
3456 /// Subclasses may override this routine to provide different behavior.
3458 bool IsThrownVariableInScope) {
3459 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3460 }
3461
3462 /// Build a new C++ default-argument expression.
3463 ///
3464 /// By default, builds a new default-argument expression, which does not
3465 /// require any semantic analysis. Subclasses may override this routine to
3466 /// provide different behavior.
3468 Expr *RewrittenExpr) {
3469 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3470 RewrittenExpr, getSema().CurContext);
3471 }
3472
3473 /// Build a new C++11 default-initialization expression.
3474 ///
3475 /// By default, builds a new default field initialization expression, which
3476 /// does not require any semantic analysis. Subclasses may override this
3477 /// routine to provide different behavior.
3482
3483 /// Build a new C++ zero-initialization expression.
3484 ///
3485 /// By default, performs semantic analysis to build the new expression.
3486 /// Subclasses may override this routine to provide different behavior.
3488 SourceLocation LParenLoc,
3489 SourceLocation RParenLoc) {
3490 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3491 /*ListInitialization=*/false);
3492 }
3493
3494 /// Build a new C++ "new" expression.
3495 ///
3496 /// By default, performs semantic analysis to build the new expression.
3497 /// Subclasses may override this routine to provide different behavior.
3499 SourceLocation PlacementLParen,
3500 MultiExprArg PlacementArgs,
3501 SourceLocation PlacementRParen,
3502 SourceRange TypeIdParens, QualType AllocatedType,
3503 TypeSourceInfo *AllocatedTypeInfo,
3504 std::optional<Expr *> ArraySize,
3505 SourceRange DirectInitRange, Expr *Initializer) {
3506 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3507 PlacementLParen,
3508 PlacementArgs,
3509 PlacementRParen,
3510 TypeIdParens,
3511 AllocatedType,
3512 AllocatedTypeInfo,
3513 ArraySize,
3514 DirectInitRange,
3515 Initializer);
3516 }
3517
3518 /// Build a new C++ "delete" expression.
3519 ///
3520 /// By default, performs semantic analysis to build the new expression.
3521 /// Subclasses may override this routine to provide different behavior.
3523 bool IsGlobalDelete,
3524 bool IsArrayForm,
3525 Expr *Operand) {
3526 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3527 Operand);
3528 }
3529
3530 /// Build a new type trait expression.
3531 ///
3532 /// By default, performs semantic analysis to build the new expression.
3533 /// Subclasses may override this routine to provide different behavior.
3535 SourceLocation StartLoc,
3537 SourceLocation RParenLoc) {
3538 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3539 }
3540
3541 /// Build a new array type trait expression.
3542 ///
3543 /// By default, performs semantic analysis to build the new expression.
3544 /// Subclasses may override this routine to provide different behavior.
3546 SourceLocation StartLoc,
3547 TypeSourceInfo *TSInfo,
3548 Expr *DimExpr,
3549 SourceLocation RParenLoc) {
3550 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3551 }
3552
3553 /// Build a new expression trait expression.
3554 ///
3555 /// By default, performs semantic analysis to build the new expression.
3556 /// Subclasses may override this routine to provide different behavior.
3558 SourceLocation StartLoc,
3559 Expr *Queried,
3560 SourceLocation RParenLoc) {
3561 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3562 }
3563
3564 /// Build a new (previously unresolved) declaration reference
3565 /// expression.
3566 ///
3567 /// By default, performs semantic analysis to build the new expression.
3568 /// Subclasses may override this routine to provide different behavior.
3570 NestedNameSpecifierLoc QualifierLoc,
3571 SourceLocation TemplateKWLoc,
3572 const DeclarationNameInfo &NameInfo,
3573 const TemplateArgumentListInfo *TemplateArgs,
3574 bool IsAddressOfOperand,
3575 TypeSourceInfo **RecoveryTSI) {
3576 CXXScopeSpec SS;
3577 SS.Adopt(QualifierLoc);
3578
3579 if (TemplateArgs || TemplateKWLoc.isValid())
3581 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3582
3584 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3585 }
3586
3587 /// Build a new template-id expression.
3588 ///
3589 /// By default, performs semantic analysis to build the new expression.
3590 /// Subclasses may override this routine to provide different behavior.
3592 SourceLocation TemplateKWLoc,
3593 LookupResult &R,
3594 bool RequiresADL,
3595 const TemplateArgumentListInfo *TemplateArgs) {
3596 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3597 TemplateArgs);
3598 }
3599
3600 /// Build a new object-construction expression.
3601 ///
3602 /// By default, performs semantic analysis to build the new expression.
3603 /// Subclasses may override this routine to provide different behavior.
3606 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3607 bool ListInitialization, bool StdInitListInitialization,
3608 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3609 SourceRange ParenRange) {
3610 // Reconstruct the constructor we originally found, which might be
3611 // different if this is a call to an inherited constructor.
3612 CXXConstructorDecl *FoundCtor = Constructor;
3613 if (Constructor->isInheritingConstructor())
3614 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3615
3616 SmallVector<Expr *, 8> ConvertedArgs;
3617 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3618 ConvertedArgs))
3619 return ExprError();
3620
3622 IsElidable,
3623 ConvertedArgs,
3624 HadMultipleCandidates,
3625 ListInitialization,
3626 StdInitListInitialization,
3627 RequiresZeroInit, ConstructKind,
3628 ParenRange);
3629 }
3630
3631 /// Build a new implicit construction via inherited constructor
3632 /// expression.
3635 bool ConstructsVBase,
3636 bool InheritedFromVBase) {
3638 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3639 }
3640
3641 /// Build a new object-construction expression.
3642 ///
3643 /// By default, performs semantic analysis to build the new expression.
3644 /// Subclasses may override this routine to provide different behavior.
3646 SourceLocation LParenOrBraceLoc,
3647 MultiExprArg Args,
3648 SourceLocation RParenOrBraceLoc,
3649 bool ListInitialization) {
3651 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3652 }
3653
3654 /// Build a new object-construction expression.
3655 ///
3656 /// By default, performs semantic analysis to build the new expression.
3657 /// Subclasses may override this routine to provide different behavior.
3659 SourceLocation LParenLoc,
3660 MultiExprArg Args,
3661 SourceLocation RParenLoc,
3662 bool ListInitialization) {
3663 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3664 RParenLoc, ListInitialization);
3665 }
3666
3667 /// Build a new member reference expression.
3668 ///
3669 /// By default, performs semantic analysis to build the new expression.
3670 /// Subclasses may override this routine to provide different behavior.
3672 QualType BaseType,
3673 bool IsArrow,
3674 SourceLocation OperatorLoc,
3675 NestedNameSpecifierLoc QualifierLoc,
3676 SourceLocation TemplateKWLoc,
3677 NamedDecl *FirstQualifierInScope,
3678 const DeclarationNameInfo &MemberNameInfo,
3679 const TemplateArgumentListInfo *TemplateArgs) {
3680 CXXScopeSpec SS;
3681 SS.Adopt(QualifierLoc);
3682
3683 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3684 OperatorLoc, IsArrow,
3685 SS, TemplateKWLoc,
3686 FirstQualifierInScope,
3687 MemberNameInfo,
3688 TemplateArgs, /*S*/nullptr);
3689 }
3690
3691 /// Build a new member reference expression.
3692 ///
3693 /// By default, performs semantic analysis to build the new expression.
3694 /// Subclasses may override this routine to provide different behavior.
3696 SourceLocation OperatorLoc,
3697 bool IsArrow,
3698 NestedNameSpecifierLoc QualifierLoc,
3699 SourceLocation TemplateKWLoc,
3700 NamedDecl *FirstQualifierInScope,
3701 LookupResult &R,
3702 const TemplateArgumentListInfo *TemplateArgs) {
3703 CXXScopeSpec SS;
3704 SS.Adopt(QualifierLoc);
3705
3706 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3707 OperatorLoc, IsArrow,
3708 SS, TemplateKWLoc,
3709 FirstQualifierInScope,
3710 R, TemplateArgs, /*S*/nullptr);
3711 }
3712
3713 /// Build a new noexcept expression.
3714 ///
3715 /// By default, performs semantic analysis to build the new expression.
3716 /// Subclasses may override this routine to provide different behavior.
3718 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3719 }
3720
3723
3724 /// Build a new expression to compute the length of a parameter pack.
3726 SourceLocation PackLoc,
3727 SourceLocation RParenLoc,
3728 UnsignedOrNone Length,
3729 ArrayRef<TemplateArgument> PartialArgs) {
3730 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3731 RParenLoc, Length, PartialArgs);
3732 }
3733
3735 SourceLocation RSquareLoc,
3736 Expr *PackIdExpression, Expr *IndexExpr,
3737 ArrayRef<Expr *> ExpandedExprs,
3738 bool FullySubstituted = false) {
3739 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3740 IndexExpr, RSquareLoc, ExpandedExprs,
3741 FullySubstituted);
3742 }
3743
3744 /// Build a new expression representing a call to a source location
3745 /// builtin.
3746 ///
3747 /// By default, performs semantic analysis to build the new expression.
3748 /// Subclasses may override this routine to provide different behavior.
3750 SourceLocation BuiltinLoc,
3751 SourceLocation RPLoc,
3752 DeclContext *ParentContext) {
3753 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3754 ParentContext);
3755 }
3756
3758 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3759 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3761 CXXScopeSpec SS;
3762 SS.Adopt(NNS);
3763 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3764 ConceptNameInfo,
3765 FoundDecl,
3766 NamedConcept, TALI);
3767 if (Result.isInvalid())
3768 return ExprError();
3769 return Result;
3770 }
3771
3772 /// \brief Build a new requires expression.
3773 ///
3774 /// By default, performs semantic analysis to build the new expression.
3775 /// Subclasses may override this routine to provide different behavior.
3778 SourceLocation LParenLoc,
3779 ArrayRef<ParmVarDecl *> LocalParameters,
3780 SourceLocation RParenLoc,
3782 SourceLocation ClosingBraceLoc) {
3783 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3784 LocalParameters, RParenLoc, Requirements,
3785 ClosingBraceLoc);
3786 }
3787
3791 return SemaRef.BuildTypeRequirement(SubstDiag);
3792 }
3793
3795 return SemaRef.BuildTypeRequirement(T);
3796 }
3797
3800 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3801 SourceLocation NoexceptLoc,
3803 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3804 std::move(Ret));
3805 }
3806
3808 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3810 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3811 std::move(Ret));
3812 }
3813
3815 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3816 const ASTConstraintSatisfaction &Satisfaction) {
3817 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3818 Satisfaction);
3819 }
3820
3822 return SemaRef.BuildNestedRequirement(Constraint);
3823 }
3824
3825 /// \brief Build a new Objective-C boxed expression.
3826 ///
3827 /// By default, performs semantic analysis to build the new expression.
3828 /// Subclasses may override this routine to provide different behavior.
3830 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3831 }
3832
3833 /// Build a new Objective-C array literal.
3834 ///
3835 /// By default, performs semantic analysis to build the new expression.
3836 /// Subclasses may override this routine to provide different behavior.
3838 Expr **Elements, unsigned NumElements) {
3840 Range, MultiExprArg(Elements, NumElements));
3841 }
3842
3844 Expr *Base, Expr *Key,
3845 ObjCMethodDecl *getterMethod,
3846 ObjCMethodDecl *setterMethod) {
3848 RB, Base, Key, getterMethod, setterMethod);
3849 }
3850
3851 /// Build a new Objective-C dictionary literal.
3852 ///
3853 /// By default, performs semantic analysis to build the new expression.
3854 /// Subclasses may override this routine to provide different behavior.
3859
3860 /// Build a new Objective-C \@encode expression.
3861 ///
3862 /// By default, performs semantic analysis to build the new expression.
3863 /// Subclasses may override this routine to provide different behavior.
3865 TypeSourceInfo *EncodeTypeInfo,
3866 SourceLocation RParenLoc) {
3867 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3868 RParenLoc);
3869 }
3870
3871 /// Build a new Objective-C class message.
3873 Selector Sel,
3874 ArrayRef<SourceLocation> SelectorLocs,
3876 SourceLocation LBracLoc,
3877 MultiExprArg Args,
3878 SourceLocation RBracLoc) {
3879 return SemaRef.ObjC().BuildClassMessage(
3880 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3881 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3882 RBracLoc, Args);
3883 }
3884
3885 /// Build a new Objective-C instance message.
3887 Selector Sel,
3888 ArrayRef<SourceLocation> SelectorLocs,
3890 SourceLocation LBracLoc,
3891 MultiExprArg Args,
3892 SourceLocation RBracLoc) {
3893 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3894 /*SuperLoc=*/SourceLocation(),
3895 Sel, Method, LBracLoc,
3896 SelectorLocs, RBracLoc, Args);
3897 }
3898
3899 /// Build a new Objective-C instance/class message to 'super'.
3901 Selector Sel,
3902 ArrayRef<SourceLocation> SelectorLocs,
3903 QualType SuperType,
3905 SourceLocation LBracLoc,
3906 MultiExprArg Args,
3907 SourceLocation RBracLoc) {
3908 return Method->isInstanceMethod()
3909 ? SemaRef.ObjC().BuildInstanceMessage(
3910 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3911 SelectorLocs, RBracLoc, Args)
3912 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3913 Sel, Method, LBracLoc,
3914 SelectorLocs, RBracLoc, Args);
3915 }
3916
3917 /// Build a new Objective-C ivar reference expression.
3918 ///
3919 /// By default, performs semantic analysis to build the new expression.
3920 /// Subclasses may override this routine to provide different behavior.
3922 SourceLocation IvarLoc,
3923 bool IsArrow, bool IsFreeIvar) {
3924 CXXScopeSpec SS;
3925 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3927 BaseArg, BaseArg->getType(),
3928 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3929 /*FirstQualifierInScope=*/nullptr, NameInfo,
3930 /*TemplateArgs=*/nullptr,
3931 /*S=*/nullptr);
3932 if (IsFreeIvar && Result.isUsable())
3933 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3934 return Result;
3935 }
3936
3937 /// Build a new Objective-C property reference expression.
3938 ///
3939 /// By default, performs semantic analysis to build the new expression.
3940 /// Subclasses may override this routine to provide different behavior.
3943 SourceLocation PropertyLoc) {
3944 CXXScopeSpec SS;
3945 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3946 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3947 /*FIXME:*/PropertyLoc,
3948 /*IsArrow=*/false,
3949 SS, SourceLocation(),
3950 /*FirstQualifierInScope=*/nullptr,
3951 NameInfo,
3952 /*TemplateArgs=*/nullptr,
3953 /*S=*/nullptr);
3954 }
3955
3956 /// Build a new Objective-C property reference expression.
3957 ///
3958 /// By default, performs semantic analysis to build the new expression.
3959 /// Subclasses may override this routine to provide different behavior.
3961 ObjCMethodDecl *Getter,
3962 ObjCMethodDecl *Setter,
3963 SourceLocation PropertyLoc) {
3964 // Since these expressions can only be value-dependent, we do not
3965 // need to perform semantic analysis again.
3966 return Owned(
3967 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3969 PropertyLoc, Base));
3970 }
3971
3972 /// Build a new Objective-C "isa" expression.
3973 ///
3974 /// By default, performs semantic analysis to build the new expression.
3975 /// Subclasses may override this routine to provide different behavior.
3977 SourceLocation OpLoc, bool IsArrow) {
3978 CXXScopeSpec SS;
3979 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
3980 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3981 OpLoc, IsArrow,
3982 SS, SourceLocation(),
3983 /*FirstQualifierInScope=*/nullptr,
3984 NameInfo,
3985 /*TemplateArgs=*/nullptr,
3986 /*S=*/nullptr);
3987 }
3988
3989 /// Build a new shuffle vector expression.
3990 ///
3991 /// By default, performs semantic analysis to build the new expression.
3992 /// Subclasses may override this routine to provide different behavior.
3994 MultiExprArg SubExprs,
3995 SourceLocation RParenLoc) {
3996 // Find the declaration for __builtin_shufflevector
3997 const IdentifierInfo &Name
3998 = SemaRef.Context.Idents.get("__builtin_shufflevector");
3999 TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
4000 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
4001 assert(!Lookup.empty() && "No __builtin_shufflevector?");
4002
4003 // Build a reference to the __builtin_shufflevector builtin
4005 Expr *Callee = new (SemaRef.Context)
4006 DeclRefExpr(SemaRef.Context, Builtin, false,
4007 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
4008 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
4009 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
4010 CK_BuiltinFnToFnPtr).get();
4011
4012 // Build the CallExpr
4013 ExprResult TheCall = CallExpr::Create(
4014 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
4015 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
4017
4018 // Type-check the __builtin_shufflevector expression.
4019 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
4020 }
4021
4022 /// Build a new convert vector expression.
4024 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
4025 SourceLocation RParenLoc) {
4026 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
4027 }
4028
4029 /// Build a new template argument pack expansion.
4030 ///
4031 /// By default, performs semantic analysis to build a new pack expansion
4032 /// for a template argument. Subclasses may override this routine to provide
4033 /// different behavior.
4035 SourceLocation EllipsisLoc,
4036 UnsignedOrNone NumExpansions) {
4037 switch (Pattern.getArgument().getKind()) {
4041 EllipsisLoc, NumExpansions);
4042 if (Result.isInvalid())
4043 return TemplateArgumentLoc();
4044
4046 /*IsCanonical=*/false),
4047 Result.get());
4048 }
4049
4051 return TemplateArgumentLoc(
4052 SemaRef.Context,
4054 NumExpansions),
4055 Pattern.getTemplateKWLoc(), Pattern.getTemplateQualifierLoc(),
4056 Pattern.getTemplateNameLoc(), EllipsisLoc);
4057
4065 llvm_unreachable("Pack expansion pattern has no parameter packs");
4066
4068 if (TypeSourceInfo *Expansion
4069 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4070 EllipsisLoc,
4071 NumExpansions))
4072 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4073 Expansion);
4074 break;
4075 }
4076
4077 return TemplateArgumentLoc();
4078 }
4079
4080 /// Build a new expression pack expansion.
4081 ///
4082 /// By default, performs semantic analysis to build a new pack expansion
4083 /// for an expression. Subclasses may override this routine to provide
4084 /// different behavior.
4086 UnsignedOrNone NumExpansions) {
4087 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4088 }
4089
4090 /// Build a new C++1z fold-expression.
4091 ///
4092 /// By default, performs semantic analysis in order to build a new fold
4093 /// expression.
4095 SourceLocation LParenLoc, Expr *LHS,
4096 BinaryOperatorKind Operator,
4097 SourceLocation EllipsisLoc, Expr *RHS,
4098 SourceLocation RParenLoc,
4099 UnsignedOrNone NumExpansions) {
4100 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4101 EllipsisLoc, RHS, RParenLoc,
4102 NumExpansions);
4103 }
4104
4106 LambdaScopeInfo *LSI) {
4107 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4108 if (Expr *Init = PVD->getInit())
4110 Init->containsUnexpandedParameterPack();
4111 else if (PVD->hasUninstantiatedDefaultArg())
4113 PVD->getUninstantiatedDefaultArg()
4114 ->containsUnexpandedParameterPack();
4115 }
4116 return getSema().BuildLambdaExpr(StartLoc, EndLoc);
4117 }
4118
4119 /// Build an empty C++1z fold-expression with the given operator.
4120 ///
4121 /// By default, produces the fallback value for the fold-expression, or
4122 /// produce an error if there is no fallback value.
4124 BinaryOperatorKind Operator) {
4125 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4126 }
4127
4128 /// Build a new atomic operation expression.
4129 ///
4130 /// By default, performs semantic analysis to build the new expression.
4131 /// Subclasses may override this routine to provide different behavior.
4134 SourceLocation RParenLoc) {
4135 // Use this for all of the locations, since we don't know the difference
4136 // between the call and the expr at this point.
4137 SourceRange Range{BuiltinLoc, RParenLoc};
4138 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4140 }
4141
4143 ArrayRef<Expr *> SubExprs, QualType Type) {
4144 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4145 }
4146
4148 SourceLocation BeginLoc,
4149 SourceLocation DirLoc,
4150 SourceLocation EndLoc,
4152 StmtResult StrBlock) {
4154 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4155 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, StrBlock);
4156 }
4157
4168
4170 SourceLocation BeginLoc,
4171 SourceLocation DirLoc,
4172 SourceLocation EndLoc,
4174 StmtResult Loop) {
4176 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4177 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, Loop);
4178 }
4179
4181 SourceLocation DirLoc,
4182 SourceLocation EndLoc,
4184 StmtResult StrBlock) {
4186 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4188 Clauses, StrBlock);
4189 }
4190
4200
4210
4212 SourceLocation DirLoc,
4213 SourceLocation EndLoc,
4215 StmtResult StrBlock) {
4219 Clauses, StrBlock);
4220 }
4221
4223 SourceLocation DirLoc,
4224 SourceLocation EndLoc,
4225 ArrayRef<OpenACCClause *> Clauses) {
4227 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4229 Clauses, {});
4230 }
4231
4241
4243 SourceLocation DirLoc,
4244 SourceLocation EndLoc,
4245 ArrayRef<OpenACCClause *> Clauses) {
4247 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4249 Clauses, {});
4250 }
4251
4253 SourceLocation DirLoc,
4254 SourceLocation EndLoc,
4255 ArrayRef<OpenACCClause *> Clauses) {
4257 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4259 Clauses, {});
4260 }
4261
4263 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4264 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4265 SourceLocation RParenLoc, SourceLocation EndLoc,
4266 ArrayRef<OpenACCClause *> Clauses) {
4268 Exprs.push_back(DevNumExpr);
4269 llvm::append_range(Exprs, QueueIdExprs);
4271 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4272 Exprs, OpenACCAtomicKind::None, RParenLoc, EndLoc, Clauses, {});
4273 }
4274
4276 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4277 SourceLocation ReadOnlyLoc, ArrayRef<Expr *> VarList,
4278 SourceLocation RParenLoc, SourceLocation EndLoc) {
4280 OpenACCDirectiveKind::Cache, BeginLoc, DirLoc, LParenLoc, ReadOnlyLoc,
4281 VarList, OpenACCAtomicKind::None, RParenLoc, EndLoc, {}, {});
4282 }
4283
4285 SourceLocation DirLoc,
4286 OpenACCAtomicKind AtKind,
4287 SourceLocation EndLoc,
4289 StmtResult AssociatedStmt) {
4291 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4292 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, Clauses,
4293 AssociatedStmt);
4294 }
4295
4299
4302 const NonTypeTemplateParmDecl *NTTP,
4304 UnsignedOrNone PackIndex, bool Final) {
4306 AssociatedDecl, NTTP, Loc, Arg, PackIndex, Final);
4307 }
4308
4309private:
4310 QualType TransformTypeInObjectScope(TypeLocBuilder &TLB, TypeLoc TL,
4311 QualType ObjectType,
4312 NamedDecl *FirstQualifierInScope);
4313
4314 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4315 QualType ObjectType,
4316 NamedDecl *FirstQualifierInScope) {
4317 if (getDerived().AlreadyTransformed(TSInfo->getType()))
4318 return TSInfo;
4319
4320 TypeLocBuilder TLB;
4321 QualType T = TransformTypeInObjectScope(TLB, TSInfo->getTypeLoc(),
4322 ObjectType, FirstQualifierInScope);
4323 if (T.isNull())
4324 return nullptr;
4325 return TLB.getTypeSourceInfo(SemaRef.Context, T);
4326 }
4327
4328 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4329 DependentNameTypeLoc TL,
4330 bool DeducibleTSTContext,
4331 QualType ObjectType = QualType(),
4332 NamedDecl *UnqualLookup = nullptr);
4333
4335 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4337
4338 OpenACCClause *
4339 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4340 OpenACCDirectiveKind DirKind,
4341 const OpenACCClause *OldClause);
4342};
4343
4344template <typename Derived>
4346 if (!S)
4347 return S;
4348
4349 switch (S->getStmtClass()) {
4350 case Stmt::NoStmtClass: break;
4351
4352 // Transform individual statement nodes
4353 // Pass SDK into statements that can produce a value
4354#define STMT(Node, Parent) \
4355 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4356#define VALUESTMT(Node, Parent) \
4357 case Stmt::Node##Class: \
4358 return getDerived().Transform##Node(cast<Node>(S), SDK);
4359#define ABSTRACT_STMT(Node)
4360#define EXPR(Node, Parent)
4361#include "clang/AST/StmtNodes.inc"
4362
4363 // Transform expressions by calling TransformExpr.
4364#define STMT(Node, Parent)
4365#define ABSTRACT_STMT(Stmt)
4366#define EXPR(Node, Parent) case Stmt::Node##Class:
4367#include "clang/AST/StmtNodes.inc"
4368 {
4369 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4370
4372 E = getSema().ActOnStmtExprResult(E);
4373 return getSema().ActOnExprStmt(E, SDK == StmtDiscardKind::Discarded);
4374 }
4375 }
4376
4377 return S;
4378}
4379
4380template<typename Derived>
4382 if (!S)
4383 return S;
4384
4385 switch (S->getClauseKind()) {
4386 default: break;
4387 // Transform individual clause nodes
4388#define GEN_CLANG_CLAUSE_CLASS
4389#define CLAUSE_CLASS(Enum, Str, Class) \
4390 case Enum: \
4391 return getDerived().Transform##Class(cast<Class>(S));
4392#include "llvm/Frontend/OpenMP/OMP.inc"
4393 }
4394
4395 return S;
4396}
4397
4398
4399template<typename Derived>
4401 if (!E)
4402 return E;
4403
4404 switch (E->getStmtClass()) {
4405 case Stmt::NoStmtClass: break;
4406#define STMT(Node, Parent) case Stmt::Node##Class: break;
4407#define ABSTRACT_STMT(Stmt)
4408#define EXPR(Node, Parent) \
4409 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4410#include "clang/AST/StmtNodes.inc"
4411 }
4412
4413 return E;
4414}
4415
4416template<typename Derived>
4418 bool NotCopyInit) {
4419 // Initializers are instantiated like expressions, except that various outer
4420 // layers are stripped.
4421 if (!Init)
4422 return Init;
4423
4424 if (auto *FE = dyn_cast<FullExpr>(Init))
4425 Init = FE->getSubExpr();
4426
4427 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4428 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4429 Init = OVE->getSourceExpr();
4430 }
4431
4432 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4433 Init = MTE->getSubExpr();
4434
4435 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4436 Init = Binder->getSubExpr();
4437
4438 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4439 Init = ICE->getSubExprAsWritten();
4440
4441 if (CXXStdInitializerListExpr *ILE =
4442 dyn_cast<CXXStdInitializerListExpr>(Init))
4443 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4444
4445 // If this is copy-initialization, we only need to reconstruct
4446 // InitListExprs. Other forms of copy-initialization will be a no-op if
4447 // the initializer is already the right type.
4448 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4449 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4450 return getDerived().TransformExpr(Init);
4451
4452 // Revert value-initialization back to empty parens.
4453 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4454 SourceRange Parens = VIE->getSourceRange();
4455 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4456 Parens.getEnd());
4457 }
4458
4459 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4461 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4462 SourceLocation());
4463
4464 // Revert initialization by constructor back to a parenthesized or braced list
4465 // of expressions. Any other form of initializer can just be reused directly.
4466 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4467 return getDerived().TransformExpr(Init);
4468
4469 // If the initialization implicitly converted an initializer list to a
4470 // std::initializer_list object, unwrap the std::initializer_list too.
4471 if (Construct && Construct->isStdInitListInitialization())
4472 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4473
4474 // Enter a list-init context if this was list initialization.
4477 Construct->isListInitialization());
4478
4479 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4480 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4481 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4482 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4483 SmallVector<Expr*, 8> NewArgs;
4484 bool ArgChanged = false;
4485 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4486 /*IsCall*/true, NewArgs, &ArgChanged))
4487 return ExprError();
4488
4489 // If this was list initialization, revert to syntactic list form.
4490 if (Construct->isListInitialization())
4491 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4492 Construct->getEndLoc());
4493
4494 // Build a ParenListExpr to represent anything else.
4496 if (Parens.isInvalid()) {
4497 // This was a variable declaration's initialization for which no initializer
4498 // was specified.
4499 assert(NewArgs.empty() &&
4500 "no parens or braces but have direct init with arguments?");
4501 return ExprEmpty();
4502 }
4503 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4504 Parens.getEnd());
4505}
4506
4507template<typename Derived>
4509 unsigned NumInputs,
4510 bool IsCall,
4511 SmallVectorImpl<Expr *> &Outputs,
4512 bool *ArgChanged) {
4513 for (unsigned I = 0; I != NumInputs; ++I) {
4514 // If requested, drop call arguments that need to be dropped.
4515 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4516 if (ArgChanged)
4517 *ArgChanged = true;
4518
4519 break;
4520 }
4521
4522 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4523 Expr *Pattern = Expansion->getPattern();
4524
4526 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4527 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4528
4529 // Determine whether the set of unexpanded parameter packs can and should
4530 // be expanded.
4531 bool Expand = true;
4532 bool RetainExpansion = false;
4533 UnsignedOrNone OrigNumExpansions = Expansion->getNumExpansions();
4534 UnsignedOrNone NumExpansions = OrigNumExpansions;
4536 Expansion->getEllipsisLoc(), Pattern->getSourceRange(),
4537 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
4538 RetainExpansion, NumExpansions))
4539 return true;
4540
4541 if (!Expand) {
4542 // The transform has determined that we should perform a simple
4543 // transformation on the pack expansion, producing another pack
4544 // expansion.
4545 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
4546 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4547 if (OutPattern.isInvalid())
4548 return true;
4549
4550 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4551 Expansion->getEllipsisLoc(),
4552 NumExpansions);
4553 if (Out.isInvalid())
4554 return true;
4555
4556 if (ArgChanged)
4557 *ArgChanged = true;
4558 Outputs.push_back(Out.get());
4559 continue;
4560 }
4561
4562 // Record right away that the argument was changed. This needs
4563 // to happen even if the array expands to nothing.
4564 if (ArgChanged) *ArgChanged = true;
4565
4566 // The transform has determined that we should perform an elementwise
4567 // expansion of the pattern. Do so.
4568 for (unsigned I = 0; I != *NumExpansions; ++I) {
4569 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
4570 ExprResult Out = getDerived().TransformExpr(Pattern);
4571 if (Out.isInvalid())
4572 return true;
4573
4574 if (Out.get()->containsUnexpandedParameterPack()) {
4575 Out = getDerived().RebuildPackExpansion(
4576 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4577 if (Out.isInvalid())
4578 return true;
4579 }
4580
4581 Outputs.push_back(Out.get());
4582 }
4583
4584 // If we're supposed to retain a pack expansion, do so by temporarily
4585 // forgetting the partially-substituted parameter pack.
4586 if (RetainExpansion) {
4587 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4588
4589 ExprResult Out = getDerived().TransformExpr(Pattern);
4590 if (Out.isInvalid())
4591 return true;
4592
4593 Out = getDerived().RebuildPackExpansion(
4594 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4595 if (Out.isInvalid())
4596 return true;
4597
4598 Outputs.push_back(Out.get());
4599 }
4600
4601 continue;
4602 }
4603
4605 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4606 : getDerived().TransformExpr(Inputs[I]);
4607 if (Result.isInvalid())
4608 return true;
4609
4610 if (Result.get() != Inputs[I] && ArgChanged)
4611 *ArgChanged = true;
4612
4613 Outputs.push_back(Result.get());
4614 }
4615
4616 return false;
4617}
4618
4619template <typename Derived>
4622
4625 /*LambdaContextDecl=*/nullptr,
4627 /*ShouldEnter=*/Kind == Sema::ConditionKind::ConstexprIf);
4628
4629 if (Var) {
4630 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4632
4633 if (!ConditionVar)
4634 return Sema::ConditionError();
4635
4636 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4637 }
4638
4639 if (Expr) {
4640 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4641
4642 if (CondExpr.isInvalid())
4643 return Sema::ConditionError();
4644
4645 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4646 /*MissingOK=*/true);
4647 }
4648
4649 return Sema::ConditionResult();
4650}
4651
4652template <typename Derived>
4654 NestedNameSpecifierLoc NNS, QualType ObjectType,
4655 NamedDecl *FirstQualifierInScope) {
4657
4658 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4659 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4660 Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix)
4661 Qualifiers.push_back(Qualifier);
4662 };
4663 insertNNS(NNS);
4664
4665 CXXScopeSpec SS;
4666 while (!Qualifiers.empty()) {
4667 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4669
4670 switch (QNNS.getKind()) {
4672 llvm_unreachable("unexpected null nested name specifier");
4673
4676 Q.getLocalBeginLoc(), const_cast<NamespaceBaseDecl *>(
4678 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4679 break;
4680 }
4681
4683 // There is no meaningful transformation that one could perform on the
4684 // global scope.
4685 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4686 break;
4687
4689 CXXRecordDecl *RD = cast_or_null<CXXRecordDecl>(
4691 SS.MakeMicrosoftSuper(SemaRef.Context, RD, Q.getBeginLoc(),
4692 Q.getEndLoc());
4693 break;
4694 }
4695
4697 assert(SS.isEmpty());
4698 TypeLoc TL = Q.castAsTypeLoc();
4699
4700 if (auto DNT = TL.getAs<DependentNameTypeLoc>()) {
4701 NestedNameSpecifierLoc QualifierLoc = DNT.getQualifierLoc();
4702 if (QualifierLoc) {
4703 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4704 QualifierLoc, ObjectType, FirstQualifierInScope);
4705 if (!QualifierLoc)
4706 return NestedNameSpecifierLoc();
4707 ObjectType = QualType();
4708 FirstQualifierInScope = nullptr;
4709 }
4710 SS.Adopt(QualifierLoc);
4712 const_cast<IdentifierInfo *>(DNT.getTypePtr()->getIdentifier()),
4713 DNT.getNameLoc(), Q.getLocalEndLoc(), ObjectType);
4714 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo,
4715 false, SS,
4716 FirstQualifierInScope, false))
4717 return NestedNameSpecifierLoc();
4718 return SS.getWithLocInContext(SemaRef.Context);
4719 }
4720
4721 QualType T = TL.getType();
4722 TypeLocBuilder TLB;
4724 T = TransformTypeInObjectScope(TLB, TL, ObjectType,
4725 FirstQualifierInScope);
4726 if (T.isNull())
4727 return NestedNameSpecifierLoc();
4728 TL = TLB.getTypeLocInContext(SemaRef.Context, T);
4729 }
4730
4731 if (T->isDependentType() || T->isRecordType() ||
4732 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4733 if (T->isEnumeralType())
4734 SemaRef.Diag(TL.getBeginLoc(),
4735 diag::warn_cxx98_compat_enum_nested_name_spec);
4736 SS.Make(SemaRef.Context, TL, Q.getLocalEndLoc());
4737 break;
4738 }
4739 // If the nested-name-specifier is an invalid type def, don't emit an
4740 // error because a previous error should have already been emitted.
4742 if (!TTL || !TTL.getDecl()->isInvalidDecl()) {
4743 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4744 << T << SS.getRange();
4745 }
4746 return NestedNameSpecifierLoc();
4747 }
4748 }
4749 }
4750
4751 // Don't rebuild the nested-name-specifier if we don't have to.
4752 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4754 return NNS;
4755
4756 // If we can re-use the source-location data from the original
4757 // nested-name-specifier, do so.
4758 if (SS.location_size() == NNS.getDataLength() &&
4759 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4761
4762 // Allocate new nested-name-specifier location information.
4763 return SS.getWithLocInContext(SemaRef.Context);
4764}
4765
4766template<typename Derived>
4770 DeclarationName Name = NameInfo.getName();
4771 if (!Name)
4772 return DeclarationNameInfo();
4773
4774 switch (Name.getNameKind()) {
4782 return NameInfo;
4783
4785 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4786 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4787 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4788 if (!NewTemplate)
4789 return DeclarationNameInfo();
4790
4791 DeclarationNameInfo NewNameInfo(NameInfo);
4792 NewNameInfo.setName(
4793 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
4794 return NewNameInfo;
4795 }
4796
4800 TypeSourceInfo *NewTInfo;
4801 CanQualType NewCanTy;
4802 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4803 NewTInfo = getDerived().TransformType(OldTInfo);
4804 if (!NewTInfo)
4805 return DeclarationNameInfo();
4806 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4807 }
4808 else {
4809 NewTInfo = nullptr;
4810 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4811 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4812 if (NewT.isNull())
4813 return DeclarationNameInfo();
4814 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4815 }
4816
4817 DeclarationName NewName
4818 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4819 NewCanTy);
4820 DeclarationNameInfo NewNameInfo(NameInfo);
4821 NewNameInfo.setName(NewName);
4822 NewNameInfo.setNamedTypeInfo(NewTInfo);
4823 return NewNameInfo;
4824 }
4825 }
4826
4827 llvm_unreachable("Unknown name kind.");
4828}
4829
4830template <typename Derived>
4832 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4834 QualType ObjectType, bool AllowInjectedClassName) {
4835 if (const IdentifierInfo *II = IO.getIdentifier())
4836 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, *II, NameLoc,
4837 ObjectType, AllowInjectedClassName);
4838 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, IO.getOperator(),
4839 NameLoc, ObjectType,
4840 AllowInjectedClassName);
4841}
4842
4843template <typename Derived>
4845 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
4846 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
4847 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
4849 TemplateName UnderlyingName = QTN->getUnderlyingTemplate();
4850
4851 if (QualifierLoc) {
4852 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4853 QualifierLoc, ObjectType, FirstQualifierInScope);
4854 if (!QualifierLoc)
4855 return TemplateName();
4856 }
4857
4858 NestedNameSpecifierLoc UnderlyingQualifier;
4859 TemplateName NewUnderlyingName = getDerived().TransformTemplateName(
4860 UnderlyingQualifier, TemplateKWLoc, UnderlyingName, NameLoc, ObjectType,
4861 FirstQualifierInScope, AllowInjectedClassName);
4862 if (NewUnderlyingName.isNull())
4863 return TemplateName();
4864 assert(!UnderlyingQualifier && "unexpected qualifier");
4865
4866 if (!getDerived().AlwaysRebuild() &&
4867 QualifierLoc.getNestedNameSpecifier() == QTN->getQualifier() &&
4868 NewUnderlyingName == UnderlyingName)
4869 return Name;
4870 CXXScopeSpec SS;
4871 SS.Adopt(QualifierLoc);
4872 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4873 NewUnderlyingName);
4874 }
4875
4877 if (QualifierLoc) {
4878 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4879 QualifierLoc, ObjectType, FirstQualifierInScope);
4880 if (!QualifierLoc)
4881 return TemplateName();
4882 // The qualifier-in-scope and object type only apply to the leftmost
4883 // entity.
4884 ObjectType = QualType();
4885 }
4886
4887 if (!getDerived().AlwaysRebuild() &&
4888 QualifierLoc.getNestedNameSpecifier() == DTN->getQualifier() &&
4889 ObjectType.isNull())
4890 return Name;
4891
4892 CXXScopeSpec SS;
4893 SS.Adopt(QualifierLoc);
4894 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, DTN->getName(),
4895 NameLoc, ObjectType,
4896 AllowInjectedClassName);
4897 }
4898
4901 assert(!QualifierLoc && "Unexpected qualified SubstTemplateTemplateParm");
4902
4903 NestedNameSpecifierLoc ReplacementQualifierLoc;
4904 TemplateName ReplacementName = S->getReplacement();
4905 if (NestedNameSpecifier Qualifier = ReplacementName.getQualifier()) {
4907 Builder.MakeTrivial(SemaRef.Context, Qualifier, NameLoc);
4908 ReplacementQualifierLoc = Builder.getWithLocInContext(SemaRef.Context);
4909 }
4910
4911 TemplateName NewName = getDerived().TransformTemplateName(
4912 ReplacementQualifierLoc, TemplateKWLoc, ReplacementName, NameLoc,
4913 ObjectType, FirstQualifierInScope, AllowInjectedClassName);
4914 if (NewName.isNull())
4915 return TemplateName();
4916 Decl *AssociatedDecl =
4917 getDerived().TransformDecl(NameLoc, S->getAssociatedDecl());
4918 if (!getDerived().AlwaysRebuild() && NewName == S->getReplacement() &&
4919 AssociatedDecl == S->getAssociatedDecl())
4920 return Name;
4921 return SemaRef.Context.getSubstTemplateTemplateParm(
4922 NewName, AssociatedDecl, S->getIndex(), S->getPackIndex(),
4923 S->getFinal());
4924 }
4925
4926 assert(!Name.getAsDeducedTemplateName() &&
4927 "DeducedTemplateName should not escape partial ordering");
4928
4929 // FIXME: Preserve UsingTemplateName.
4930 if (auto *Template = Name.getAsTemplateDecl()) {
4931 assert(!QualifierLoc && "Unexpected qualifier");
4932 return TemplateName(cast_or_null<TemplateDecl>(
4933 getDerived().TransformDecl(NameLoc, Template)));
4934 }
4935
4938 assert(!QualifierLoc &&
4939 "Unexpected qualified SubstTemplateTemplateParmPack");
4940 return getDerived().RebuildTemplateName(
4941 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4942 SubstPack->getIndex(), SubstPack->getFinal());
4943 }
4944
4945 // These should be getting filtered out before they reach the AST.
4946 llvm_unreachable("overloaded function decl survived to here");
4947}
4948
4949template <typename Derived>
4951 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
4952 TemplateName Name, SourceLocation NameLoc) {
4953 TemplateName TN = getDerived().TransformTemplateName(
4954 QualifierLoc, TemplateKeywordLoc, Name, NameLoc);
4955 if (TN.isNull())
4956 return TemplateArgument();
4957 return TemplateArgument(TN);
4958}
4959
4960template<typename Derived>
4962 const TemplateArgument &Arg,
4963 TemplateArgumentLoc &Output) {
4964 Output = getSema().getTrivialTemplateArgumentLoc(
4965 Arg, QualType(), getDerived().getBaseLocation());
4966}
4967
4968template <typename Derived>
4970 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
4971 bool Uneval) {
4972 const TemplateArgument &Arg = Input.getArgument();
4973 switch (Arg.getKind()) {
4976 llvm_unreachable("Unexpected TemplateArgument");
4977
4982 // Transform a resolved template argument straight to a resolved template
4983 // argument. We get here when substituting into an already-substituted
4984 // template type argument during concept satisfaction checking.
4986 QualType NewT = getDerived().TransformType(T);
4987 if (NewT.isNull())
4988 return true;
4989
4991 ? Arg.getAsDecl()
4992 : nullptr;
4993 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
4995 : nullptr;
4996 if (D && !NewD)
4997 return true;
4998
4999 if (NewT == T && D == NewD)
5000 Output = Input;
5001 else if (Arg.getKind() == TemplateArgument::Integral)
5002 Output = TemplateArgumentLoc(
5003 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
5005 else if (Arg.getKind() == TemplateArgument::NullPtr)
5006 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
5008 else if (Arg.getKind() == TemplateArgument::Declaration)
5009 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
5012 Output = TemplateArgumentLoc(
5013 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
5015 else
5016 llvm_unreachable("unexpected template argument kind");
5017
5018 return false;
5019 }
5020
5022 TypeSourceInfo *TSI = Input.getTypeSourceInfo();
5023 if (!TSI)
5025
5026 TSI = getDerived().TransformType(TSI);
5027 if (!TSI)
5028 return true;
5029
5030 Output = TemplateArgumentLoc(TemplateArgument(TSI->getType()), TSI);
5031 return false;
5032 }
5033
5035 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
5036
5037 TemplateArgument Out = getDerived().TransformNamedTemplateTemplateArgument(
5038 QualifierLoc, Input.getTemplateKWLoc(), Arg.getAsTemplate(),
5039 Input.getTemplateNameLoc());
5040 if (Out.isNull())
5041 return true;
5042 Output = TemplateArgumentLoc(SemaRef.Context, Out, Input.getTemplateKWLoc(),
5043 QualifierLoc, Input.getTemplateNameLoc());
5044 return false;
5045 }
5046
5048 llvm_unreachable("Caller should expand pack expansions");
5049
5051 // Template argument expressions are constant expressions.
5053 getSema(),
5056 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
5058
5059 Expr *InputExpr = Input.getSourceExpression();
5060 if (!InputExpr)
5061 InputExpr = Input.getArgument().getAsExpr();
5062
5063 ExprResult E = getDerived().TransformExpr(InputExpr);
5064 E = SemaRef.ActOnConstantExpression(E);
5065 if (E.isInvalid())
5066 return true;
5067 Output = TemplateArgumentLoc(
5068 TemplateArgument(E.get(), /*IsCanonical=*/false), E.get());
5069 return false;
5070 }
5071 }
5072
5073 // Work around bogus GCC warning
5074 return true;
5075}
5076
5077/// Iterator adaptor that invents template argument location information
5078/// for each of the template arguments in its underlying iterator.
5079template<typename Derived, typename InputIterator>
5082 InputIterator Iter;
5083
5084public:
5087 typedef typename std::iterator_traits<InputIterator>::difference_type
5089 typedef std::input_iterator_tag iterator_category;
5090
5091 class pointer {
5093
5094 public:
5095 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5096
5097 const TemplateArgumentLoc *operator->() const { return &Arg; }
5098 };
5099
5101 InputIterator Iter)
5102 : Self(Self), Iter(Iter) { }
5103
5105 ++Iter;
5106 return *this;
5107 }
5108
5111 ++(*this);
5112 return Old;
5113 }
5114
5117 Self.InventTemplateArgumentLoc(*Iter, Result);
5118 return Result;
5119 }
5120
5121 pointer operator->() const { return pointer(**this); }
5122
5125 return X.Iter == Y.Iter;
5126 }
5127
5130 return X.Iter != Y.Iter;
5131 }
5132};
5133
5134template<typename Derived>
5135template<typename InputIterator>
5137 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5138 bool Uneval) {
5139 for (TemplateArgumentLoc In : llvm::make_range(First, Last)) {
5141 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5142 // Unpack argument packs, which we translate them into separate
5143 // arguments.
5144 // FIXME: We could do much better if we could guarantee that the
5145 // TemplateArgumentLocInfo for the pack expansion would be usable for
5146 // all of the template arguments in the argument pack.
5147 typedef TemplateArgumentLocInventIterator<Derived,
5149 PackLocIterator;
5150
5151 TemplateArgumentListInfo *PackOutput = &Outputs;
5153
5155 PackLocIterator(*this, In.getArgument().pack_begin()),
5156 PackLocIterator(*this, In.getArgument().pack_end()), *PackOutput,
5157 Uneval))
5158 return true;
5159
5160 continue;
5161 }
5162
5163 if (In.getArgument().isPackExpansion()) {
5164 UnexpandedInfo Info;
5165 TemplateArgumentLoc Prepared;
5166 if (PreparePackForExpansion(In, Uneval, Prepared, Info))
5167 return true;
5168 if (!Info.Expand) {
5169 Outputs.addArgument(Prepared);
5170 continue;
5171 }
5172
5173 // The transform has determined that we should perform an elementwise
5174 // expansion of the pattern. Do so.
5175 std::optional<ForgetSubstitutionRAII> ForgetSubst;
5177 ForgetSubst.emplace(getDerived());
5178 for (unsigned I = 0; I != *Info.NumExpansions; ++I) {
5179 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5180
5182 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5183 return true;
5184
5185 if (Out.getArgument().containsUnexpandedParameterPack()) {
5186 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5187 Info.OrigNumExpansions);
5188 if (Out.getArgument().isNull())
5189 return true;
5190 }
5191
5192 Outputs.addArgument(Out);
5193 }
5194
5195 // If we're supposed to retain a pack expansion, do so by temporarily
5196 // forgetting the partially-substituted parameter pack.
5197 if (Info.RetainExpansion) {
5198 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5199
5201 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5202 return true;
5203
5204 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5205 Info.OrigNumExpansions);
5206 if (Out.getArgument().isNull())
5207 return true;
5208
5209 Outputs.addArgument(Out);
5210 }
5211
5212 continue;
5213 }
5214
5215 // The simple case:
5216 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5217 return true;
5218
5219 Outputs.addArgument(Out);
5220 }
5221
5222 return false;
5223}
5224
5225template <typename Derived>
5226template <typename InputIterator>
5228 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5229 bool Uneval) {
5230
5231 // [C++26][temp.constr.normal]
5232 // any non-dependent concept template argument
5233 // is substituted into the constraint-expression of C.
5234 auto isNonDependentConceptArgument = [](const TemplateArgument &Arg) {
5235 return !Arg.isDependent() && Arg.isConceptOrConceptTemplateParameter();
5236 };
5237
5238 for (; First != Last; ++First) {
5241
5242 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5243 typedef TemplateArgumentLocInventIterator<Derived,
5245 PackLocIterator;
5247 PackLocIterator(*this, In.getArgument().pack_begin()),
5248 PackLocIterator(*this, In.getArgument().pack_end()), Outputs,
5249 Uneval))
5250 return true;
5251 continue;
5252 }
5253
5254 if (!isNonDependentConceptArgument(In.getArgument())) {
5255 Outputs.addArgument(In);
5256 continue;
5257 }
5258
5259 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5260 return true;
5261
5262 Outputs.addArgument(Out);
5263 }
5264
5265 return false;
5266}
5267
5268// FIXME: Find ways to reduce code duplication for pack expansions.
5269template <typename Derived>
5271 bool Uneval,
5273 UnexpandedInfo &Info) {
5274 auto ComputeInfo = [this](TemplateArgumentLoc Arg,
5275 bool IsLateExpansionAttempt, UnexpandedInfo &Info,
5276 TemplateArgumentLoc &Pattern) {
5277 assert(Arg.getArgument().isPackExpansion());
5278 // We have a pack expansion, for which we will be substituting into the
5279 // pattern.
5280 Pattern = getSema().getTemplateArgumentPackExpansionPattern(
5281 Arg, Info.Ellipsis, Info.OrigNumExpansions);
5283 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5284 if (IsLateExpansionAttempt) {
5285 // Request expansion only when there is an opportunity to expand a pack
5286 // that required a substituion first.
5287 bool SawPackTypes =
5288 llvm::any_of(Unexpanded, [](UnexpandedParameterPack P) {
5289 return P.first.dyn_cast<const SubstBuiltinTemplatePackType *>();
5290 });
5291 if (!SawPackTypes) {
5292 Info.Expand = false;
5293 return false;
5294 }
5295 }
5296 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5297
5298 // Determine whether the set of unexpanded parameter packs can and
5299 // should be expanded.
5300 Info.Expand = true;
5301 Info.RetainExpansion = false;
5302 Info.NumExpansions = Info.OrigNumExpansions;
5303 return getDerived().TryExpandParameterPacks(
5304 Info.Ellipsis, Pattern.getSourceRange(), Unexpanded,
5305 /*FailOnPackProducingTemplates=*/false, Info.Expand,
5306 Info.RetainExpansion, Info.NumExpansions);
5307 };
5308
5309 TemplateArgumentLoc Pattern;
5310 if (ComputeInfo(In, false, Info, Pattern))
5311 return true;
5312
5313 if (Info.Expand) {
5314 Out = Pattern;
5315 return false;
5316 }
5317
5318 // The transform has determined that we should perform a simple
5319 // transformation on the pack expansion, producing another pack
5320 // expansion.
5321 TemplateArgumentLoc OutPattern;
5322 std::optional<Sema::ArgPackSubstIndexRAII> SubstIndex(
5323 std::in_place, getSema(), std::nullopt);
5324 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5325 return true;
5326
5327 Out = getDerived().RebuildPackExpansion(OutPattern, Info.Ellipsis,
5328 Info.NumExpansions);
5329 if (Out.getArgument().isNull())
5330 return true;
5331 SubstIndex.reset();
5332
5333 if (!OutPattern.getArgument().containsUnexpandedParameterPack())
5334 return false;
5335
5336 // Some packs will learn their length after substitution, e.g.
5337 // __builtin_dedup_pack<T,int> has size 1 or 2, depending on the substitution
5338 // value of `T`.
5339 //
5340 // We only expand after we know sizes of all packs, check if this is the case
5341 // or not. However, we avoid a full template substitution and only do
5342 // expanstions after this point.
5343
5344 // E.g. when substituting template arguments of tuple with {T -> int} in the
5345 // following example:
5346 // template <class T>
5347 // struct TupleWithInt {
5348 // using type = std::tuple<__builtin_dedup_pack<T, int>...>;
5349 // };
5350 // TupleWithInt<int>::type y;
5351 // At this point we will see the `__builtin_dedup_pack<int, int>` with a known
5352 // lenght and run `ComputeInfo()` to provide the necessary information to our
5353 // caller.
5354 //
5355 // Note that we may still have situations where builtin is not going to be
5356 // expanded. For example:
5357 // template <class T>
5358 // struct Foo {
5359 // template <class U> using tuple_with_t =
5360 // std::tuple<__builtin_dedup_pack<T, U, int>...>; using type =
5361 // tuple_with_t<short>;
5362 // }
5363 // Because the substitution into `type` happens in dependent context, `type`
5364 // will be `tuple<builtin_dedup_pack<T, short, int>...>` after substitution
5365 // and the caller will not be able to expand it.
5366 ForgetSubstitutionRAII ForgetSubst(getDerived());
5367 if (ComputeInfo(Out, true, Info, OutPattern))
5368 return true;
5369 if (!Info.Expand)
5370 return false;
5371 Out = OutPattern;
5372 Info.ExpandUnderForgetSubstitions = true;
5373 return false;
5374}
5375
5376//===----------------------------------------------------------------------===//
5377// Type transformation
5378//===----------------------------------------------------------------------===//
5379
5380template<typename Derived>
5383 return T;
5384
5385 // Temporary workaround. All of these transformations should
5386 // eventually turn into transformations on TypeLocs.
5387 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5389
5390 TypeSourceInfo *NewTSI = getDerived().TransformType(TSI);
5391
5392 if (!NewTSI)
5393 return QualType();
5394
5395 return NewTSI->getType();
5396}
5397
5398template <typename Derived>
5400 // Refine the base location to the type's location.
5401 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5404 return TSI;
5405
5406 TypeLocBuilder TLB;
5407
5408 TypeLoc TL = TSI->getTypeLoc();
5409 TLB.reserve(TL.getFullDataSize());
5410
5411 QualType Result = getDerived().TransformType(TLB, TL);
5412 if (Result.isNull())
5413 return nullptr;
5414
5415 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5416}
5417
5418template<typename Derived>
5421 switch (T.getTypeLocClass()) {
5422#define ABSTRACT_TYPELOC(CLASS, PARENT)
5423#define TYPELOC(CLASS, PARENT) \
5424 case TypeLoc::CLASS: \
5425 return getDerived().Transform##CLASS##Type(TLB, \
5426 T.castAs<CLASS##TypeLoc>());
5427#include "clang/AST/TypeLocNodes.def"
5428 }
5429
5430 llvm_unreachable("unhandled type loc!");
5431}
5432
5433template<typename Derived>
5436 return TransformType(T);
5437
5439 return T;
5440 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5442 TypeSourceInfo *NewTSI = getDerived().TransformTypeWithDeducedTST(TSI);
5443 return NewTSI ? NewTSI->getType() : QualType();
5444}
5445
5446template <typename Derived>
5449 if (!isa<DependentNameType>(TSI->getType()))
5450 return TransformType(TSI);
5451
5452 // Refine the base location to the type's location.
5453 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5456 return TSI;
5457
5458 TypeLocBuilder TLB;
5459
5460 TypeLoc TL = TSI->getTypeLoc();
5461 TLB.reserve(TL.getFullDataSize());
5462
5463 auto QTL = TL.getAs<QualifiedTypeLoc>();
5464 if (QTL)
5465 TL = QTL.getUnqualifiedLoc();
5466
5467 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5468
5469 QualType Result = getDerived().TransformDependentNameType(
5470 TLB, DNTL, /*DeducedTSTContext*/true);
5471 if (Result.isNull())
5472 return nullptr;
5473
5474 if (QTL) {
5475 Result = getDerived().RebuildQualifiedType(Result, QTL);
5476 if (Result.isNull())
5477 return nullptr;
5479 }
5480
5481 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5482}
5483
5484template<typename Derived>
5489 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5490 auto SuppressObjCLifetime =
5491 T.getType().getLocalQualifiers().hasObjCLifetime();
5492 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5493 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5494 SuppressObjCLifetime);
5495 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5496 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5497 TLB, STTP, SuppressObjCLifetime);
5498 } else {
5499 Result = getDerived().TransformType(TLB, UnqualTL);
5500 }
5501
5502 if (Result.isNull())
5503 return QualType();
5504
5505 Result = getDerived().RebuildQualifiedType(Result, T);
5506
5507 if (Result.isNull())
5508 return QualType();
5509
5510 // RebuildQualifiedType might have updated the type, but not in a way
5511 // that invalidates the TypeLoc. (There's no location information for
5512 // qualifiers.)
5514
5515 return Result;
5516}
5517
5518template <typename Derived>
5520 QualifiedTypeLoc TL) {
5521
5522 SourceLocation Loc = TL.getBeginLoc();
5523 Qualifiers Quals = TL.getType().getLocalQualifiers();
5524
5525 if ((T.getAddressSpace() != LangAS::Default &&
5526 Quals.getAddressSpace() != LangAS::Default) &&
5527 T.getAddressSpace() != Quals.getAddressSpace()) {
5528 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5529 << TL.getType() << T;
5530 return QualType();
5531 }
5532
5533 PointerAuthQualifier LocalPointerAuth = Quals.getPointerAuth();
5534 if (LocalPointerAuth.isPresent()) {
5535 if (T.getPointerAuth().isPresent()) {
5536 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_redundant) << TL.getType();
5537 return QualType();
5538 }
5539 if (!T->isDependentType()) {
5540 if (!T->isSignableType(SemaRef.getASTContext())) {
5541 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_invalid_target) << T;
5542 return QualType();
5543 }
5544 }
5545 }
5546 // C++ [dcl.fct]p7:
5547 // [When] adding cv-qualifications on top of the function type [...] the
5548 // cv-qualifiers are ignored.
5549 if (T->isFunctionType()) {
5550 T = SemaRef.getASTContext().getAddrSpaceQualType(T,
5551 Quals.getAddressSpace());
5552 return T;
5553 }
5554
5555 // C++ [dcl.ref]p1:
5556 // when the cv-qualifiers are introduced through the use of a typedef-name
5557 // or decltype-specifier [...] the cv-qualifiers are ignored.
5558 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5559 // applied to a reference type.
5560 if (T->isReferenceType()) {
5561 // The only qualifier that applies to a reference type is restrict.
5562 if (!Quals.hasRestrict())
5563 return T;
5565 }
5566
5567 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5568 // resulting type.
5569 if (Quals.hasObjCLifetime()) {
5570 if (!T->isObjCLifetimeType() && !T->isDependentType())
5571 Quals.removeObjCLifetime();
5572 else if (T.getObjCLifetime()) {
5573 // Objective-C ARC:
5574 // A lifetime qualifier applied to a substituted template parameter
5575 // overrides the lifetime qualifier from the template argument.
5576 const AutoType *AutoTy;
5577 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5578 // 'auto' types behave the same way as template parameters.
5579 QualType Deduced = AutoTy->getDeducedType();
5580 Qualifiers Qs = Deduced.getQualifiers();
5581 Qs.removeObjCLifetime();
5582 Deduced =
5583 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5584 T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
5585 AutoTy->isDependentType(),
5586 /*isPack=*/false,
5587 AutoTy->getTypeConstraintConcept(),
5588 AutoTy->getTypeConstraintArguments());
5589 } else {
5590 // Otherwise, complain about the addition of a qualifier to an
5591 // already-qualified type.
5592 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5593 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5594 Quals.removeObjCLifetime();
5595 }
5596 }
5597 }
5598
5599 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5600}
5601
5602template <typename Derived>
5603QualType TreeTransform<Derived>::TransformTypeInObjectScope(
5604 TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType,
5605 NamedDecl *FirstQualifierInScope) {
5606 assert(!getDerived().AlreadyTransformed(TL.getType()));
5607
5608 switch (TL.getTypeLocClass()) {
5609 case TypeLoc::TemplateSpecialization:
5610 return getDerived().TransformTemplateSpecializationType(
5611 TLB, TL.castAs<TemplateSpecializationTypeLoc>(), ObjectType,
5612 FirstQualifierInScope, /*AllowInjectedClassName=*/true);
5613 case TypeLoc::DependentName:
5614 return getDerived().TransformDependentNameType(
5615 TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
5616 ObjectType, FirstQualifierInScope);
5617 default:
5618 // Any dependent canonical type can appear here, through type alias
5619 // templates.
5620 return getDerived().TransformType(TLB, TL);
5621 }
5622}
5623
5624template <class TyLoc> static inline
5626 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5627 NewT.setNameLoc(T.getNameLoc());
5628 return T.getType();
5629}
5630
5631template<typename Derived>
5632QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5633 BuiltinTypeLoc T) {
5634 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5635 NewT.setBuiltinLoc(T.getBuiltinLoc());
5636 if (T.needsExtraLocalData())
5637 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5638 return T.getType();
5639}
5640
5641template<typename Derived>
5643 ComplexTypeLoc T) {
5644 // FIXME: recurse?
5645 return TransformTypeSpecType(TLB, T);
5646}
5647
5648template <typename Derived>
5650 AdjustedTypeLoc TL) {
5651 // Adjustments applied during transformation are handled elsewhere.
5652 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5653}
5654
5655template<typename Derived>
5657 DecayedTypeLoc TL) {
5658 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5659 if (OriginalType.isNull())
5660 return QualType();
5661
5662 QualType Result = TL.getType();
5663 if (getDerived().AlwaysRebuild() ||
5664 OriginalType != TL.getOriginalLoc().getType())
5665 Result = SemaRef.Context.getDecayedType(OriginalType);
5666 TLB.push<DecayedTypeLoc>(Result);
5667 // Nothing to set for DecayedTypeLoc.
5668 return Result;
5669}
5670
5671template <typename Derived>
5675 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5676 if (OriginalType.isNull())
5677 return QualType();
5678
5679 QualType Result = TL.getType();
5680 if (getDerived().AlwaysRebuild() ||
5681 OriginalType != TL.getElementLoc().getType())
5682 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5683 TLB.push<ArrayParameterTypeLoc>(Result);
5684 // Nothing to set for ArrayParameterTypeLoc.
5685 return Result;
5686}
5687
5688template<typename Derived>
5690 PointerTypeLoc TL) {
5691 QualType PointeeType
5692 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5693 if (PointeeType.isNull())
5694 return QualType();
5695
5696 QualType Result = TL.getType();
5697 if (PointeeType->getAs<ObjCObjectType>()) {
5698 // A dependent pointer type 'T *' has is being transformed such
5699 // that an Objective-C class type is being replaced for 'T'. The
5700 // resulting pointer type is an ObjCObjectPointerType, not a
5701 // PointerType.
5702 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5703
5705 NewT.setStarLoc(TL.getStarLoc());
5706 return Result;
5707 }
5708
5709 if (getDerived().AlwaysRebuild() ||
5710 PointeeType != TL.getPointeeLoc().getType()) {
5711 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5712 if (Result.isNull())
5713 return QualType();
5714 }
5715
5716 // Objective-C ARC can add lifetime qualifiers to the type that we're
5717 // pointing to.
5718 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5719
5720 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5721 NewT.setSigilLoc(TL.getSigilLoc());
5722 return Result;
5723}
5724
5725template<typename Derived>
5729 QualType PointeeType
5730 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5731 if (PointeeType.isNull())
5732 return QualType();
5733
5734 QualType Result = TL.getType();
5735 if (getDerived().AlwaysRebuild() ||
5736 PointeeType != TL.getPointeeLoc().getType()) {
5737 Result = getDerived().RebuildBlockPointerType(PointeeType,
5738 TL.getSigilLoc());
5739 if (Result.isNull())
5740 return QualType();
5741 }
5742
5744 NewT.setSigilLoc(TL.getSigilLoc());
5745 return Result;
5746}
5747
5748/// Transforms a reference type. Note that somewhat paradoxically we
5749/// don't care whether the type itself is an l-value type or an r-value
5750/// type; we only care if the type was *written* as an l-value type
5751/// or an r-value type.
5752template<typename Derived>
5755 ReferenceTypeLoc TL) {
5756 const ReferenceType *T = TL.getTypePtr();
5757
5758 // Note that this works with the pointee-as-written.
5759 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5760 if (PointeeType.isNull())
5761 return QualType();
5762
5763 QualType Result = TL.getType();
5764 if (getDerived().AlwaysRebuild() ||
5765 PointeeType != T->getPointeeTypeAsWritten()) {
5766 Result = getDerived().RebuildReferenceType(PointeeType,
5767 T->isSpelledAsLValue(),
5768 TL.getSigilLoc());
5769 if (Result.isNull())
5770 return QualType();
5771 }
5772
5773 // Objective-C ARC can add lifetime qualifiers to the type that we're
5774 // referring to.
5777
5778 // r-value references can be rebuilt as l-value references.
5779 ReferenceTypeLoc NewTL;
5781 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5782 else
5783 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5784 NewTL.setSigilLoc(TL.getSigilLoc());
5785
5786 return Result;
5787}
5788
5789template<typename Derived>
5793 return TransformReferenceType(TLB, TL);
5794}
5795
5796template<typename Derived>
5797QualType
5798TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5799 RValueReferenceTypeLoc TL) {
5800 return TransformReferenceType(TLB, TL);
5801}
5802
5803template<typename Derived>
5807 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5808 if (PointeeType.isNull())
5809 return QualType();
5810
5811 const MemberPointerType *T = TL.getTypePtr();
5812
5813 NestedNameSpecifierLoc OldQualifierLoc = TL.getQualifierLoc();
5814 NestedNameSpecifierLoc NewQualifierLoc =
5815 getDerived().TransformNestedNameSpecifierLoc(OldQualifierLoc);
5816 if (!NewQualifierLoc)
5817 return QualType();
5818
5819 CXXRecordDecl *OldCls = T->getMostRecentCXXRecordDecl(), *NewCls = nullptr;
5820 if (OldCls) {
5821 NewCls = cast_or_null<CXXRecordDecl>(
5822 getDerived().TransformDecl(TL.getStarLoc(), OldCls));
5823 if (!NewCls)
5824 return QualType();
5825 }
5826
5827 QualType Result = TL.getType();
5828 if (getDerived().AlwaysRebuild() || PointeeType != T->getPointeeType() ||
5829 NewQualifierLoc.getNestedNameSpecifier() !=
5830 OldQualifierLoc.getNestedNameSpecifier() ||
5831 NewCls != OldCls) {
5832 CXXScopeSpec SS;
5833 SS.Adopt(NewQualifierLoc);
5834 Result = getDerived().RebuildMemberPointerType(PointeeType, SS, NewCls,
5835 TL.getStarLoc());
5836 if (Result.isNull())
5837 return QualType();
5838 }
5839
5840 // If we had to adjust the pointee type when building a member pointer, make
5841 // sure to push TypeLoc info for it.
5842 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5843 if (MPT && PointeeType != MPT->getPointeeType()) {
5844 assert(isa<AdjustedType>(MPT->getPointeeType()));
5845 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5846 }
5847
5849 NewTL.setSigilLoc(TL.getSigilLoc());
5850 NewTL.setQualifierLoc(NewQualifierLoc);
5851
5852 return Result;
5853}
5854
5855template<typename Derived>
5859 const ConstantArrayType *T = TL.getTypePtr();
5860 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5861 if (ElementType.isNull())
5862 return QualType();
5863
5864 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5865 Expr *OldSize = TL.getSizeExpr();
5866 if (!OldSize)
5867 OldSize = const_cast<Expr*>(T->getSizeExpr());
5868 Expr *NewSize = nullptr;
5869 if (OldSize) {
5872 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5873 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5874 }
5875
5876 QualType Result = TL.getType();
5877 if (getDerived().AlwaysRebuild() ||
5878 ElementType != T->getElementType() ||
5879 (T->getSizeExpr() && NewSize != OldSize)) {
5880 Result = getDerived().RebuildConstantArrayType(ElementType,
5881 T->getSizeModifier(),
5882 T->getSize(), NewSize,
5883 T->getIndexTypeCVRQualifiers(),
5884 TL.getBracketsRange());
5885 if (Result.isNull())
5886 return QualType();
5887 }
5888
5889 // We might have either a ConstantArrayType or a VariableArrayType now:
5890 // a ConstantArrayType is allowed to have an element type which is a
5891 // VariableArrayType if the type is dependent. Fortunately, all array
5892 // types have the same location layout.
5893 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5894 NewTL.setLBracketLoc(TL.getLBracketLoc());
5895 NewTL.setRBracketLoc(TL.getRBracketLoc());
5896 NewTL.setSizeExpr(NewSize);
5897
5898 return Result;
5899}
5900
5901template<typename Derived>
5903 TypeLocBuilder &TLB,
5905 const IncompleteArrayType *T = TL.getTypePtr();
5906 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5907 if (ElementType.isNull())
5908 return QualType();
5909
5910 QualType Result = TL.getType();
5911 if (getDerived().AlwaysRebuild() ||
5912 ElementType != T->getElementType()) {
5913 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5914 T->getSizeModifier(),
5915 T->getIndexTypeCVRQualifiers(),
5916 TL.getBracketsRange());
5917 if (Result.isNull())
5918 return QualType();
5919 }
5920
5922 NewTL.setLBracketLoc(TL.getLBracketLoc());
5923 NewTL.setRBracketLoc(TL.getRBracketLoc());
5924 NewTL.setSizeExpr(nullptr);
5925
5926 return Result;
5927}
5928
5929template<typename Derived>
5933 const VariableArrayType *T = TL.getTypePtr();
5934 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5935 if (ElementType.isNull())
5936 return QualType();
5937
5938 ExprResult SizeResult;
5939 {
5942 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5943 }
5944 if (SizeResult.isInvalid())
5945 return QualType();
5946 SizeResult =
5947 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5948 if (SizeResult.isInvalid())
5949 return QualType();
5950
5951 Expr *Size = SizeResult.get();
5952
5953 QualType Result = TL.getType();
5954 if (getDerived().AlwaysRebuild() ||
5955 ElementType != T->getElementType() ||
5956 Size != T->getSizeExpr()) {
5957 Result = getDerived().RebuildVariableArrayType(ElementType,
5958 T->getSizeModifier(),
5959 Size,
5960 T->getIndexTypeCVRQualifiers(),
5961 TL.getBracketsRange());
5962 if (Result.isNull())
5963 return QualType();
5964 }
5965
5966 // We might have constant size array now, but fortunately it has the same
5967 // location layout.
5968 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5969 NewTL.setLBracketLoc(TL.getLBracketLoc());
5970 NewTL.setRBracketLoc(TL.getRBracketLoc());
5971 NewTL.setSizeExpr(Size);
5972
5973 return Result;
5974}
5975
5976template<typename Derived>
5980 const DependentSizedArrayType *T = TL.getTypePtr();
5981 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5982 if (ElementType.isNull())
5983 return QualType();
5984
5985 // Array bounds are constant expressions.
5988
5989 // If we have a VLA then it won't be a constant.
5990 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
5991
5992 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5993 Expr *origSize = TL.getSizeExpr();
5994 if (!origSize) origSize = T->getSizeExpr();
5995
5996 ExprResult sizeResult
5997 = getDerived().TransformExpr(origSize);
5998 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
5999 if (sizeResult.isInvalid())
6000 return QualType();
6001
6002 Expr *size = sizeResult.get();
6003
6004 QualType Result = TL.getType();
6005 if (getDerived().AlwaysRebuild() ||
6006 ElementType != T->getElementType() ||
6007 size != origSize) {
6008 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
6009 T->getSizeModifier(),
6010 size,
6011 T->getIndexTypeCVRQualifiers(),
6012 TL.getBracketsRange());
6013 if (Result.isNull())
6014 return QualType();
6015 }
6016
6017 // We might have any sort of array type now, but fortunately they
6018 // all have the same location layout.
6019 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6020 NewTL.setLBracketLoc(TL.getLBracketLoc());
6021 NewTL.setRBracketLoc(TL.getRBracketLoc());
6022 NewTL.setSizeExpr(size);
6023
6024 return Result;
6025}
6026
6027template <typename Derived>
6030 const DependentVectorType *T = TL.getTypePtr();
6031 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6032 if (ElementType.isNull())
6033 return QualType();
6034
6037
6038 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6039 Size = SemaRef.ActOnConstantExpression(Size);
6040 if (Size.isInvalid())
6041 return QualType();
6042
6043 QualType Result = TL.getType();
6044 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6045 Size.get() != T->getSizeExpr()) {
6046 Result = getDerived().RebuildDependentVectorType(
6047 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
6048 if (Result.isNull())
6049 return QualType();
6050 }
6051
6052 // Result might be dependent or not.
6055 TLB.push<DependentVectorTypeLoc>(Result);
6056 NewTL.setNameLoc(TL.getNameLoc());
6057 } else {
6058 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6059 NewTL.setNameLoc(TL.getNameLoc());
6060 }
6061
6062 return Result;
6063}
6064
6065template<typename Derived>
6067 TypeLocBuilder &TLB,
6069 const DependentSizedExtVectorType *T = TL.getTypePtr();
6070
6071 // FIXME: ext vector locs should be nested
6072 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6073 if (ElementType.isNull())
6074 return QualType();
6075
6076 // Vector sizes are constant expressions.
6079
6080 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6081 Size = SemaRef.ActOnConstantExpression(Size);
6082 if (Size.isInvalid())
6083 return QualType();
6084
6085 QualType Result = TL.getType();
6086 if (getDerived().AlwaysRebuild() ||
6087 ElementType != T->getElementType() ||
6088 Size.get() != T->getSizeExpr()) {
6089 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
6090 Size.get(),
6091 T->getAttributeLoc());
6092 if (Result.isNull())
6093 return QualType();
6094 }
6095
6096 // Result might be dependent or not.
6100 NewTL.setNameLoc(TL.getNameLoc());
6101 } else {
6102 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6103 NewTL.setNameLoc(TL.getNameLoc());
6104 }
6105
6106 return Result;
6107}
6108
6109template <typename Derived>
6113 const ConstantMatrixType *T = TL.getTypePtr();
6114 QualType ElementType = getDerived().TransformType(T->getElementType());
6115 if (ElementType.isNull())
6116 return QualType();
6117
6118 QualType Result = TL.getType();
6119 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
6120 Result = getDerived().RebuildConstantMatrixType(
6121 ElementType, T->getNumRows(), T->getNumColumns());
6122 if (Result.isNull())
6123 return QualType();
6124 }
6125
6127 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6128 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6129 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
6130 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
6131
6132 return Result;
6133}
6134
6135template <typename Derived>
6138 const DependentSizedMatrixType *T = TL.getTypePtr();
6139
6140 QualType ElementType = getDerived().TransformType(T->getElementType());
6141 if (ElementType.isNull()) {
6142 return QualType();
6143 }
6144
6145 // Matrix dimensions are constant expressions.
6148
6149 Expr *origRows = TL.getAttrRowOperand();
6150 if (!origRows)
6151 origRows = T->getRowExpr();
6152 Expr *origColumns = TL.getAttrColumnOperand();
6153 if (!origColumns)
6154 origColumns = T->getColumnExpr();
6155
6156 ExprResult rowResult = getDerived().TransformExpr(origRows);
6157 rowResult = SemaRef.ActOnConstantExpression(rowResult);
6158 if (rowResult.isInvalid())
6159 return QualType();
6160
6161 ExprResult columnResult = getDerived().TransformExpr(origColumns);
6162 columnResult = SemaRef.ActOnConstantExpression(columnResult);
6163 if (columnResult.isInvalid())
6164 return QualType();
6165
6166 Expr *rows = rowResult.get();
6167 Expr *columns = columnResult.get();
6168
6169 QualType Result = TL.getType();
6170 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6171 rows != origRows || columns != origColumns) {
6172 Result = getDerived().RebuildDependentSizedMatrixType(
6173 ElementType, rows, columns, T->getAttributeLoc());
6174
6175 if (Result.isNull())
6176 return QualType();
6177 }
6178
6179 // We might have any sort of matrix type now, but fortunately they
6180 // all have the same location layout.
6181 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
6182 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6183 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6184 NewTL.setAttrRowOperand(rows);
6185 NewTL.setAttrColumnOperand(columns);
6186 return Result;
6187}
6188
6189template <typename Derived>
6192 const DependentAddressSpaceType *T = TL.getTypePtr();
6193
6194 QualType pointeeType =
6195 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
6196
6197 if (pointeeType.isNull())
6198 return QualType();
6199
6200 // Address spaces are constant expressions.
6203
6204 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
6205 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
6206 if (AddrSpace.isInvalid())
6207 return QualType();
6208
6209 QualType Result = TL.getType();
6210 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
6211 AddrSpace.get() != T->getAddrSpaceExpr()) {
6212 Result = getDerived().RebuildDependentAddressSpaceType(
6213 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6214 if (Result.isNull())
6215 return QualType();
6216 }
6217
6218 // Result might be dependent or not.
6222
6223 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6224 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6225 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6226
6227 } else {
6228 TLB.TypeWasModifiedSafely(Result);
6229 }
6230
6231 return Result;
6232}
6233
6234template <typename Derived>
6236 VectorTypeLoc TL) {
6237 const VectorType *T = TL.getTypePtr();
6238 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6239 if (ElementType.isNull())
6240 return QualType();
6241
6242 QualType Result = TL.getType();
6243 if (getDerived().AlwaysRebuild() ||
6244 ElementType != T->getElementType()) {
6245 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6246 T->getVectorKind());
6247 if (Result.isNull())
6248 return QualType();
6249 }
6250
6251 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6252 NewTL.setNameLoc(TL.getNameLoc());
6253
6254 return Result;
6255}
6256
6257template<typename Derived>
6259 ExtVectorTypeLoc TL) {
6260 const VectorType *T = TL.getTypePtr();
6261 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6262 if (ElementType.isNull())
6263 return QualType();
6264
6265 QualType Result = TL.getType();
6266 if (getDerived().AlwaysRebuild() ||
6267 ElementType != T->getElementType()) {
6268 Result = getDerived().RebuildExtVectorType(ElementType,
6269 T->getNumElements(),
6270 /*FIXME*/ SourceLocation());
6271 if (Result.isNull())
6272 return QualType();
6273 }
6274
6275 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6276 NewTL.setNameLoc(TL.getNameLoc());
6277
6278 return Result;
6279}
6280
6281template <typename Derived>
6283 ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions,
6284 bool ExpectParameterPack) {
6285 TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
6286 TypeSourceInfo *NewTSI = nullptr;
6287
6288 if (NumExpansions && isa<PackExpansionType>(OldTSI->getType())) {
6289 // If we're substituting into a pack expansion type and we know the
6290 // length we want to expand to, just substitute for the pattern.
6291 TypeLoc OldTL = OldTSI->getTypeLoc();
6292 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6293
6294 TypeLocBuilder TLB;
6295 TypeLoc NewTL = OldTSI->getTypeLoc();
6296 TLB.reserve(NewTL.getFullDataSize());
6297
6298 QualType Result = getDerived().TransformType(TLB,
6299 OldExpansionTL.getPatternLoc());
6300 if (Result.isNull())
6301 return nullptr;
6302
6304 OldExpansionTL.getPatternLoc().getSourceRange(),
6305 OldExpansionTL.getEllipsisLoc(),
6306 NumExpansions);
6307 if (Result.isNull())
6308 return nullptr;
6309
6310 PackExpansionTypeLoc NewExpansionTL
6311 = TLB.push<PackExpansionTypeLoc>(Result);
6312 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6313 NewTSI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6314 } else
6315 NewTSI = getDerived().TransformType(OldTSI);
6316 if (!NewTSI)
6317 return nullptr;
6318
6319 if (NewTSI == OldTSI && indexAdjustment == 0)
6320 return OldParm;
6321
6323 SemaRef.Context, OldParm->getDeclContext(), OldParm->getInnerLocStart(),
6324 OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
6325 NewTSI, OldParm->getStorageClass(),
6326 /* DefArg */ nullptr);
6327 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6328 OldParm->getFunctionScopeIndex() + indexAdjustment);
6329 getDerived().transformedLocalDecl(OldParm, {newParm});
6330 return newParm;
6331}
6332
6333template <typename Derived>
6336 const QualType *ParamTypes,
6337 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6338 SmallVectorImpl<QualType> &OutParamTypes,
6341 unsigned *LastParamTransformed) {
6342 int indexAdjustment = 0;
6343
6344 unsigned NumParams = Params.size();
6345 for (unsigned i = 0; i != NumParams; ++i) {
6346 if (LastParamTransformed)
6347 *LastParamTransformed = i;
6348 if (ParmVarDecl *OldParm = Params[i]) {
6349 assert(OldParm->getFunctionScopeIndex() == i);
6350
6351 UnsignedOrNone NumExpansions = std::nullopt;
6352 ParmVarDecl *NewParm = nullptr;
6353 if (OldParm->isParameterPack()) {
6354 // We have a function parameter pack that may need to be expanded.
6356
6357 // Find the parameter packs that could be expanded.
6358 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6360 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6361 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6362
6363 // Determine whether we should expand the parameter packs.
6364 bool ShouldExpand = false;
6365 bool RetainExpansion = false;
6366 UnsignedOrNone OrigNumExpansions = std::nullopt;
6367 if (Unexpanded.size() > 0) {
6368 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6369 NumExpansions = OrigNumExpansions;
6371 ExpansionTL.getEllipsisLoc(), Pattern.getSourceRange(),
6372 Unexpanded, /*FailOnPackProducingTemplates=*/true,
6373 ShouldExpand, RetainExpansion, NumExpansions)) {
6374 return true;
6375 }
6376 } else {
6377#ifndef NDEBUG
6378 const AutoType *AT =
6379 Pattern.getType().getTypePtr()->getContainedAutoType();
6380 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6381 "Could not find parameter packs or undeduced auto type!");
6382#endif
6383 }
6384
6385 if (ShouldExpand) {
6386 // Expand the function parameter pack into multiple, separate
6387 // parameters.
6388 getDerived().ExpandingFunctionParameterPack(OldParm);
6389 for (unsigned I = 0; I != *NumExpansions; ++I) {
6390 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6391 ParmVarDecl *NewParm
6392 = getDerived().TransformFunctionTypeParam(OldParm,
6393 indexAdjustment++,
6394 OrigNumExpansions,
6395 /*ExpectParameterPack=*/false);
6396 if (!NewParm)
6397 return true;
6398
6399 if (ParamInfos)
6400 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6401 OutParamTypes.push_back(NewParm->getType());
6402 if (PVars)
6403 PVars->push_back(NewParm);
6404 }
6405
6406 // If we're supposed to retain a pack expansion, do so by temporarily
6407 // forgetting the partially-substituted parameter pack.
6408 if (RetainExpansion) {
6409 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6410 ParmVarDecl *NewParm
6411 = getDerived().TransformFunctionTypeParam(OldParm,
6412 indexAdjustment++,
6413 OrigNumExpansions,
6414 /*ExpectParameterPack=*/false);
6415 if (!NewParm)
6416 return true;
6417
6418 if (ParamInfos)
6419 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6420 OutParamTypes.push_back(NewParm->getType());
6421 if (PVars)
6422 PVars->push_back(NewParm);
6423 }
6424
6425 // The next parameter should have the same adjustment as the
6426 // last thing we pushed, but we post-incremented indexAdjustment
6427 // on every push. Also, if we push nothing, the adjustment should
6428 // go down by one.
6429 indexAdjustment--;
6430
6431 // We're done with the pack expansion.
6432 continue;
6433 }
6434
6435 // We'll substitute the parameter now without expanding the pack
6436 // expansion.
6437 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6438 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6439 indexAdjustment,
6440 NumExpansions,
6441 /*ExpectParameterPack=*/true);
6442 assert(NewParm->isParameterPack() &&
6443 "Parameter pack no longer a parameter pack after "
6444 "transformation.");
6445 } else {
6446 NewParm = getDerived().TransformFunctionTypeParam(
6447 OldParm, indexAdjustment, std::nullopt,
6448 /*ExpectParameterPack=*/false);
6449 }
6450
6451 if (!NewParm)
6452 return true;
6453
6454 if (ParamInfos)
6455 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6456 OutParamTypes.push_back(NewParm->getType());
6457 if (PVars)
6458 PVars->push_back(NewParm);
6459 continue;
6460 }
6461
6462 // Deal with the possibility that we don't have a parameter
6463 // declaration for this parameter.
6464 assert(ParamTypes);
6465 QualType OldType = ParamTypes[i];
6466 bool IsPackExpansion = false;
6467 UnsignedOrNone NumExpansions = std::nullopt;
6468 QualType NewType;
6469 if (const PackExpansionType *Expansion
6470 = dyn_cast<PackExpansionType>(OldType)) {
6471 // We have a function parameter pack that may need to be expanded.
6472 QualType Pattern = Expansion->getPattern();
6474 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6475
6476 // Determine whether we should expand the parameter packs.
6477 bool ShouldExpand = false;
6478 bool RetainExpansion = false;
6480 Loc, SourceRange(), Unexpanded,
6481 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
6482 RetainExpansion, NumExpansions)) {
6483 return true;
6484 }
6485
6486 if (ShouldExpand) {
6487 // Expand the function parameter pack into multiple, separate
6488 // parameters.
6489 for (unsigned I = 0; I != *NumExpansions; ++I) {
6490 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6491 QualType NewType = getDerived().TransformType(Pattern);
6492 if (NewType.isNull())
6493 return true;
6494
6495 if (NewType->containsUnexpandedParameterPack()) {
6496 NewType = getSema().getASTContext().getPackExpansionType(
6497 NewType, std::nullopt);
6498
6499 if (NewType.isNull())
6500 return true;
6501 }
6502
6503 if (ParamInfos)
6504 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6505 OutParamTypes.push_back(NewType);
6506 if (PVars)
6507 PVars->push_back(nullptr);
6508 }
6509
6510 // We're done with the pack expansion.
6511 continue;
6512 }
6513
6514 // If we're supposed to retain a pack expansion, do so by temporarily
6515 // forgetting the partially-substituted parameter pack.
6516 if (RetainExpansion) {
6517 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6518 QualType NewType = getDerived().TransformType(Pattern);
6519 if (NewType.isNull())
6520 return true;
6521
6522 if (ParamInfos)
6523 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6524 OutParamTypes.push_back(NewType);
6525 if (PVars)
6526 PVars->push_back(nullptr);
6527 }
6528
6529 // We'll substitute the parameter now without expanding the pack
6530 // expansion.
6531 OldType = Expansion->getPattern();
6532 IsPackExpansion = true;
6533 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6534 NewType = getDerived().TransformType(OldType);
6535 } else {
6536 NewType = getDerived().TransformType(OldType);
6537 }
6538
6539 if (NewType.isNull())
6540 return true;
6541
6542 if (IsPackExpansion)
6543 NewType = getSema().Context.getPackExpansionType(NewType,
6544 NumExpansions);
6545
6546 if (ParamInfos)
6547 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6548 OutParamTypes.push_back(NewType);
6549 if (PVars)
6550 PVars->push_back(nullptr);
6551 }
6552
6553#ifndef NDEBUG
6554 if (PVars) {
6555 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6556 if (ParmVarDecl *parm = (*PVars)[i])
6557 assert(parm->getFunctionScopeIndex() == i);
6558 }
6559#endif
6560
6561 return false;
6562}
6563
6564template<typename Derived>
6568 SmallVector<QualType, 4> ExceptionStorage;
6569 return getDerived().TransformFunctionProtoType(
6570 TLB, TL, nullptr, Qualifiers(),
6571 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6572 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6573 ExceptionStorage, Changed);
6574 });
6575}
6576
6577template<typename Derived> template<typename Fn>
6579 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6580 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6581
6582 // Transform the parameters and return type.
6583 //
6584 // We are required to instantiate the params and return type in source order.
6585 // When the function has a trailing return type, we instantiate the
6586 // parameters before the return type, since the return type can then refer
6587 // to the parameters themselves (via decltype, sizeof, etc.).
6588 //
6589 SmallVector<QualType, 4> ParamTypes;
6591 Sema::ExtParameterInfoBuilder ExtParamInfos;
6592 const FunctionProtoType *T = TL.getTypePtr();
6593
6594 QualType ResultType;
6595
6596 if (T->hasTrailingReturn()) {
6598 TL.getBeginLoc(), TL.getParams(),
6600 T->getExtParameterInfosOrNull(),
6601 ParamTypes, &ParamDecls, ExtParamInfos))
6602 return QualType();
6603
6604 {
6605 // C++11 [expr.prim.general]p3:
6606 // If a declaration declares a member function or member function
6607 // template of a class X, the expression this is a prvalue of type
6608 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6609 // and the end of the function-definition, member-declarator, or
6610 // declarator.
6611 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6612 Sema::CXXThisScopeRAII ThisScope(
6613 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6614
6615 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6616 if (ResultType.isNull())
6617 return QualType();
6618 }
6619 }
6620 else {
6621 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6622 if (ResultType.isNull())
6623 return QualType();
6624
6626 TL.getBeginLoc(), TL.getParams(),
6628 T->getExtParameterInfosOrNull(),
6629 ParamTypes, &ParamDecls, ExtParamInfos))
6630 return QualType();
6631 }
6632
6633 FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
6634
6635 bool EPIChanged = false;
6636 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6637 return QualType();
6638
6639 // Handle extended parameter information.
6640 if (auto NewExtParamInfos =
6641 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6642 if (!EPI.ExtParameterInfos ||
6644 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6645 EPIChanged = true;
6646 }
6647 EPI.ExtParameterInfos = NewExtParamInfos;
6648 } else if (EPI.ExtParameterInfos) {
6649 EPIChanged = true;
6650 EPI.ExtParameterInfos = nullptr;
6651 }
6652
6653 // Transform any function effects with unevaluated conditions.
6654 // Hold this set in a local for the rest of this function, since EPI
6655 // may need to hold a FunctionEffectsRef pointing into it.
6656 std::optional<FunctionEffectSet> NewFX;
6657 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6658 NewFX.emplace();
6661
6662 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6663 FunctionEffectWithCondition NewEC = PrevEC;
6664 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6665 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6666 if (NewExpr.isInvalid())
6667 return QualType();
6668 std::optional<FunctionEffectMode> Mode =
6669 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6670 if (!Mode)
6671 return QualType();
6672
6673 // The condition expression has been transformed, and re-evaluated.
6674 // It may or may not have become constant.
6675 switch (*Mode) {
6677 NewEC.Cond = {};
6678 break;
6680 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6681 NewEC.Cond = {};
6682 break;
6684 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6685 break;
6687 llvm_unreachable(
6688 "FunctionEffectMode::None shouldn't be possible here");
6689 }
6690 }
6691 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6692 TL.getBeginLoc())) {
6694 NewFX->insert(NewEC, Errs);
6695 assert(Errs.empty());
6696 }
6697 }
6698 EPI.FunctionEffects = *NewFX;
6699 EPIChanged = true;
6700 }
6701
6702 QualType Result = TL.getType();
6703 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6704 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6705 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6706 if (Result.isNull())
6707 return QualType();
6708 }
6709
6712 NewTL.setLParenLoc(TL.getLParenLoc());
6713 NewTL.setRParenLoc(TL.getRParenLoc());
6716 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6717 NewTL.setParam(i, ParamDecls[i]);
6718
6719 return Result;
6720}
6721
6722template<typename Derived>
6725 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6726 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6727
6728 // Instantiate a dynamic noexcept expression, if any.
6729 if (isComputedNoexcept(ESI.Type)) {
6730 // Update this scrope because ContextDecl in Sema will be used in
6731 // TransformExpr.
6732 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6733 Sema::CXXThisScopeRAII ThisScope(
6734 SemaRef, Method ? Method->getParent() : nullptr,
6735 Method ? Method->getMethodQualifiers() : Qualifiers{},
6736 Method != nullptr);
6739 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6740 if (NoexceptExpr.isInvalid())
6741 return true;
6742
6744 NoexceptExpr =
6745 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6746 if (NoexceptExpr.isInvalid())
6747 return true;
6748
6749 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6750 Changed = true;
6751 ESI.NoexceptExpr = NoexceptExpr.get();
6752 ESI.Type = EST;
6753 }
6754
6755 if (ESI.Type != EST_Dynamic)
6756 return false;
6757
6758 // Instantiate a dynamic exception specification's type.
6759 for (QualType T : ESI.Exceptions) {
6760 if (const PackExpansionType *PackExpansion =
6761 T->getAs<PackExpansionType>()) {
6762 Changed = true;
6763
6764 // We have a pack expansion. Instantiate it.
6766 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6767 Unexpanded);
6768 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6769
6770 // Determine whether the set of unexpanded parameter packs can and
6771 // should
6772 // be expanded.
6773 bool Expand = false;
6774 bool RetainExpansion = false;
6775 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
6776 // FIXME: Track the location of the ellipsis (and track source location
6777 // information for the types in the exception specification in general).
6779 Loc, SourceRange(), Unexpanded,
6780 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
6781 NumExpansions))
6782 return true;
6783
6784 if (!Expand) {
6785 // We can't expand this pack expansion into separate arguments yet;
6786 // just substitute into the pattern and create a new pack expansion
6787 // type.
6788 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6789 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6790 if (U.isNull())
6791 return true;
6792
6793 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6794 Exceptions.push_back(U);
6795 continue;
6796 }
6797
6798 // Substitute into the pack expansion pattern for each slice of the
6799 // pack.
6800 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6801 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
6802
6803 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6804 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6805 return true;
6806
6807 Exceptions.push_back(U);
6808 }
6809 } else {
6810 QualType U = getDerived().TransformType(T);
6811 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6812 return true;
6813 if (T != U)
6814 Changed = true;
6815
6816 Exceptions.push_back(U);
6817 }
6818 }
6819
6820 ESI.Exceptions = Exceptions;
6821 if (ESI.Exceptions.empty())
6822 ESI.Type = EST_DynamicNone;
6823 return false;
6824}
6825
6826template<typename Derived>
6828 TypeLocBuilder &TLB,
6830 const FunctionNoProtoType *T = TL.getTypePtr();
6831 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6832 if (ResultType.isNull())
6833 return QualType();
6834
6835 QualType Result = TL.getType();
6836 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6837 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6838
6841 NewTL.setLParenLoc(TL.getLParenLoc());
6842 NewTL.setRParenLoc(TL.getRParenLoc());
6844
6845 return Result;
6846}
6847
6848template <typename Derived>
6849QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6850 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6851
6852 const UnresolvedUsingType *T = TL.getTypePtr();
6853 bool Changed = false;
6854
6855 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6856 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6857 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6858 if (!QualifierLoc)
6859 return QualType();
6860 Changed |= QualifierLoc != OldQualifierLoc;
6861 }
6862
6863 auto *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6864 if (!D)
6865 return QualType();
6866 Changed |= D != T->getDecl();
6867
6868 QualType Result = TL.getType();
6869 if (getDerived().AlwaysRebuild() || Changed) {
6870 Result = getDerived().RebuildUnresolvedUsingType(
6871 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TL.getNameLoc(),
6872 D);
6873 if (Result.isNull())
6874 return QualType();
6875 }
6876
6878 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6879 QualifierLoc, TL.getNameLoc());
6880 else
6881 TLB.push<UnresolvedUsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6882 QualifierLoc, TL.getNameLoc());
6883 return Result;
6884}
6885
6886template <typename Derived>
6888 UsingTypeLoc TL) {
6889 const UsingType *T = TL.getTypePtr();
6890 bool Changed = false;
6891
6892 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6893 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6894 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6895 if (!QualifierLoc)
6896 return QualType();
6897 Changed |= QualifierLoc != OldQualifierLoc;
6898 }
6899
6900 auto *D = cast_or_null<UsingShadowDecl>(
6901 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6902 if (!D)
6903 return QualType();
6904 Changed |= D != T->getDecl();
6905
6906 QualType UnderlyingType = getDerived().TransformType(T->desugar());
6907 if (UnderlyingType.isNull())
6908 return QualType();
6909 Changed |= UnderlyingType != T->desugar();
6910
6911 QualType Result = TL.getType();
6912 if (getDerived().AlwaysRebuild() || Changed) {
6913 Result = getDerived().RebuildUsingType(
6914 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), D,
6915 UnderlyingType);
6916 if (Result.isNull())
6917 return QualType();
6918 }
6919 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(), QualifierLoc,
6920 TL.getNameLoc());
6921 return Result;
6922}
6923
6924template<typename Derived>
6926 TypedefTypeLoc TL) {
6927 const TypedefType *T = TL.getTypePtr();
6928 bool Changed = false;
6929
6930 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6931 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6932 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6933 if (!QualifierLoc)
6934 return QualType();
6935 Changed |= QualifierLoc != OldQualifierLoc;
6936 }
6937
6938 auto *Typedef = cast_or_null<TypedefNameDecl>(
6939 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6940 if (!Typedef)
6941 return QualType();
6942 Changed |= Typedef != T->getDecl();
6943
6944 // FIXME: Transform the UnderlyingType if different from decl.
6945
6946 QualType Result = TL.getType();
6947 if (getDerived().AlwaysRebuild() || Changed) {
6948 Result = getDerived().RebuildTypedefType(
6949 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), Typedef);
6950 if (Result.isNull())
6951 return QualType();
6952 }
6953
6954 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6955 QualifierLoc, TL.getNameLoc());
6956 return Result;
6957}
6958
6959template<typename Derived>
6961 TypeOfExprTypeLoc TL) {
6962 // typeof expressions are not potentially evaluated contexts
6966
6967 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
6968 if (E.isInvalid())
6969 return QualType();
6970
6971 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
6972 if (E.isInvalid())
6973 return QualType();
6974
6975 QualType Result = TL.getType();
6977 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
6978 Result =
6979 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
6980 if (Result.isNull())
6981 return QualType();
6982 }
6983
6984 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
6985 NewTL.setTypeofLoc(TL.getTypeofLoc());
6986 NewTL.setLParenLoc(TL.getLParenLoc());
6987 NewTL.setRParenLoc(TL.getRParenLoc());
6988
6989 return Result;
6990}
6991
6992template<typename Derived>
6994 TypeOfTypeLoc TL) {
6995 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
6996 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
6997 if (!New_Under_TI)
6998 return QualType();
6999
7000 QualType Result = TL.getType();
7001 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
7002 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
7003 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
7004 if (Result.isNull())
7005 return QualType();
7006 }
7007
7008 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
7009 NewTL.setTypeofLoc(TL.getTypeofLoc());
7010 NewTL.setLParenLoc(TL.getLParenLoc());
7011 NewTL.setRParenLoc(TL.getRParenLoc());
7012 NewTL.setUnmodifiedTInfo(New_Under_TI);
7013
7014 return Result;
7015}
7016
7017template<typename Derived>
7019 DecltypeTypeLoc TL) {
7020 const DecltypeType *T = TL.getTypePtr();
7021
7022 // decltype expressions are not potentially evaluated contexts
7026
7027 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
7028 if (E.isInvalid())
7029 return QualType();
7030
7031 E = getSema().ActOnDecltypeExpression(E.get());
7032 if (E.isInvalid())
7033 return QualType();
7034
7035 QualType Result = TL.getType();
7036 if (getDerived().AlwaysRebuild() ||
7037 E.get() != T->getUnderlyingExpr()) {
7038 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
7039 if (Result.isNull())
7040 return QualType();
7041 }
7042 else E.get();
7043
7044 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
7045 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
7046 NewTL.setRParenLoc(TL.getRParenLoc());
7047 return Result;
7048}
7049
7050template <typename Derived>
7054 // Transform the index
7055 ExprResult IndexExpr;
7056 {
7057 EnterExpressionEvaluationContext ConstantContext(
7059
7060 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
7061 if (IndexExpr.isInvalid())
7062 return QualType();
7063 }
7064 QualType Pattern = TL.getPattern();
7065
7066 const PackIndexingType *PIT = TL.getTypePtr();
7067 SmallVector<QualType, 5> SubtitutedTypes;
7068 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
7069
7070 bool NotYetExpanded = Types.empty();
7071 bool FullySubstituted = true;
7072
7073 if (Types.empty() && !PIT->expandsToEmptyPack())
7074 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
7075
7076 for (QualType T : Types) {
7077 if (!T->containsUnexpandedParameterPack()) {
7078 QualType Transformed = getDerived().TransformType(T);
7079 if (Transformed.isNull())
7080 return QualType();
7081 SubtitutedTypes.push_back(Transformed);
7082 continue;
7083 }
7084
7086 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
7087 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7088 // Determine whether the set of unexpanded parameter packs can and should
7089 // be expanded.
7090 bool ShouldExpand = true;
7091 bool RetainExpansion = false;
7092 UnsignedOrNone NumExpansions = std::nullopt;
7093 if (getDerived().TryExpandParameterPacks(
7094 TL.getEllipsisLoc(), SourceRange(), Unexpanded,
7095 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
7096 RetainExpansion, NumExpansions))
7097 return QualType();
7098 if (!ShouldExpand) {
7099 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7100 // FIXME: should we keep TypeLoc for individual expansions in
7101 // PackIndexingTypeLoc?
7102 TypeSourceInfo *TI =
7103 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
7104 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
7105 if (Pack.isNull())
7106 return QualType();
7107 if (NotYetExpanded) {
7108 FullySubstituted = false;
7109 QualType Out = getDerived().RebuildPackIndexingType(
7110 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7111 FullySubstituted);
7112 if (Out.isNull())
7113 return QualType();
7114
7116 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7117 return Out;
7118 }
7119 SubtitutedTypes.push_back(Pack);
7120 continue;
7121 }
7122 for (unsigned I = 0; I != *NumExpansions; ++I) {
7123 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
7124 QualType Out = getDerived().TransformType(T);
7125 if (Out.isNull())
7126 return QualType();
7127 SubtitutedTypes.push_back(Out);
7128 FullySubstituted &= !Out->containsUnexpandedParameterPack();
7129 }
7130 // If we're supposed to retain a pack expansion, do so by temporarily
7131 // forgetting the partially-substituted parameter pack.
7132 if (RetainExpansion) {
7133 FullySubstituted = false;
7134 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
7135 QualType Out = getDerived().TransformType(T);
7136 if (Out.isNull())
7137 return QualType();
7138 SubtitutedTypes.push_back(Out);
7139 }
7140 }
7141
7142 // A pack indexing type can appear in a larger pack expansion,
7143 // e.g. `Pack...[pack_of_indexes]...`
7144 // so we need to temporarily disable substitution of pack elements
7145 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7146 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
7147
7148 QualType Out = getDerived().RebuildPackIndexingType(
7149 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7150 FullySubstituted, SubtitutedTypes);
7151 if (Out.isNull())
7152 return Out;
7153
7155 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7156 return Out;
7157}
7158
7159template<typename Derived>
7161 TypeLocBuilder &TLB,
7163 QualType Result = TL.getType();
7164 TypeSourceInfo *NewBaseTSI = TL.getUnderlyingTInfo();
7165 if (Result->isDependentType()) {
7166 const UnaryTransformType *T = TL.getTypePtr();
7167
7168 NewBaseTSI = getDerived().TransformType(TL.getUnderlyingTInfo());
7169 if (!NewBaseTSI)
7170 return QualType();
7171 QualType NewBase = NewBaseTSI->getType();
7172
7173 Result = getDerived().RebuildUnaryTransformType(NewBase,
7174 T->getUTTKind(),
7175 TL.getKWLoc());
7176 if (Result.isNull())
7177 return QualType();
7178 }
7179
7181 NewTL.setKWLoc(TL.getKWLoc());
7182 NewTL.setParensRange(TL.getParensRange());
7183 NewTL.setUnderlyingTInfo(NewBaseTSI);
7184 return Result;
7185}
7186
7187template<typename Derived>
7190 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
7191
7192 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7193 TemplateName TemplateName = getDerived().TransformTemplateName(
7194 QualifierLoc, /*TemplateKELoc=*/SourceLocation(), T->getTemplateName(),
7195 TL.getTemplateNameLoc());
7196 if (TemplateName.isNull())
7197 return QualType();
7198
7199 QualType OldDeduced = T->getDeducedType();
7200 QualType NewDeduced;
7201 if (!OldDeduced.isNull()) {
7202 NewDeduced = getDerived().TransformType(OldDeduced);
7203 if (NewDeduced.isNull())
7204 return QualType();
7205 }
7206
7207 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
7208 T->getKeyword(), TemplateName, NewDeduced);
7209 if (Result.isNull())
7210 return QualType();
7211
7212 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7213 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7214 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7215 NewTL.setQualifierLoc(QualifierLoc);
7216 return Result;
7217}
7218
7219template <typename Derived>
7221 TagTypeLoc TL) {
7222 const TagType *T = TL.getTypePtr();
7223
7224 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7225 if (QualifierLoc) {
7226 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7227 if (!QualifierLoc)
7228 return QualType();
7229 }
7230
7231 auto *TD = cast_or_null<TagDecl>(
7232 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7233 if (!TD)
7234 return QualType();
7235
7236 QualType Result = TL.getType();
7237 if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() ||
7238 TD != T->getDecl()) {
7239 if (T->isCanonicalUnqualified())
7240 Result = getDerived().RebuildCanonicalTagType(TD);
7241 else
7242 Result = getDerived().RebuildTagType(
7243 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TD);
7244 if (Result.isNull())
7245 return QualType();
7246 }
7247
7248 TagTypeLoc NewTL = TLB.push<TagTypeLoc>(Result);
7250 NewTL.setQualifierLoc(QualifierLoc);
7251 NewTL.setNameLoc(TL.getNameLoc());
7252
7253 return Result;
7254}
7255
7256template <typename Derived>
7258 EnumTypeLoc TL) {
7259 return getDerived().TransformTagType(TLB, TL);
7260}
7261
7262template <typename Derived>
7263QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
7264 RecordTypeLoc TL) {
7265 return getDerived().TransformTagType(TLB, TL);
7266}
7267
7268template<typename Derived>
7270 TypeLocBuilder &TLB,
7272 return getDerived().TransformTagType(TLB, TL);
7273}
7274
7275template<typename Derived>
7277 TypeLocBuilder &TLB,
7279 return getDerived().TransformTemplateTypeParmType(
7280 TLB, TL,
7281 /*SuppressObjCLifetime=*/false);
7282}
7283
7284template <typename Derived>
7286 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7287 return TransformTypeSpecType(TLB, TL);
7288}
7289
7290template<typename Derived>
7291QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7292 TypeLocBuilder &TLB,
7293 SubstTemplateTypeParmTypeLoc TL) {
7294 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7295
7296 Decl *NewReplaced =
7297 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7298
7299 // Substitute into the replacement type, which itself might involve something
7300 // that needs to be transformed. This only tends to occur with default
7301 // template arguments of template template parameters.
7302 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7303 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7304 if (Replacement.isNull())
7305 return QualType();
7306
7307 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7308 Replacement, NewReplaced, T->getIndex(), T->getPackIndex(),
7309 T->getFinal());
7310
7311 // Propagate type-source information.
7312 SubstTemplateTypeParmTypeLoc NewTL
7313 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7314 NewTL.setNameLoc(TL.getNameLoc());
7315 return Result;
7316
7317}
7318template <typename Derived>
7321 return TransformTypeSpecType(TLB, TL);
7322}
7323
7324template<typename Derived>
7326 TypeLocBuilder &TLB,
7328 return getDerived().TransformSubstTemplateTypeParmPackType(
7329 TLB, TL, /*SuppressObjCLifetime=*/false);
7330}
7331
7332template <typename Derived>
7335 return TransformTypeSpecType(TLB, TL);
7336}
7337
7338template<typename Derived>
7339QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
7340 AtomicTypeLoc TL) {
7341 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7342 if (ValueType.isNull())
7343 return QualType();
7344
7345 QualType Result = TL.getType();
7346 if (getDerived().AlwaysRebuild() ||
7347 ValueType != TL.getValueLoc().getType()) {
7348 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7349 if (Result.isNull())
7350 return QualType();
7351 }
7352
7353 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7354 NewTL.setKWLoc(TL.getKWLoc());
7355 NewTL.setLParenLoc(TL.getLParenLoc());
7356 NewTL.setRParenLoc(TL.getRParenLoc());
7357
7358 return Result;
7359}
7360
7361template <typename Derived>
7363 PipeTypeLoc TL) {
7364 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7365 if (ValueType.isNull())
7366 return QualType();
7367
7368 QualType Result = TL.getType();
7369 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7370 const PipeType *PT = Result->castAs<PipeType>();
7371 bool isReadPipe = PT->isReadOnly();
7372 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7373 if (Result.isNull())
7374 return QualType();
7375 }
7376
7377 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7378 NewTL.setKWLoc(TL.getKWLoc());
7379
7380 return Result;
7381}
7382
7383template <typename Derived>
7385 BitIntTypeLoc TL) {
7386 const BitIntType *EIT = TL.getTypePtr();
7387 QualType Result = TL.getType();
7388
7389 if (getDerived().AlwaysRebuild()) {
7390 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7391 EIT->getNumBits(), TL.getNameLoc());
7392 if (Result.isNull())
7393 return QualType();
7394 }
7395
7396 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7397 NewTL.setNameLoc(TL.getNameLoc());
7398 return Result;
7399}
7400
7401template <typename Derived>
7404 const DependentBitIntType *EIT = TL.getTypePtr();
7405
7408 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7409 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7410
7411 if (BitsExpr.isInvalid())
7412 return QualType();
7413
7414 QualType Result = TL.getType();
7415
7416 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7417 Result = getDerived().RebuildDependentBitIntType(
7418 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7419
7420 if (Result.isNull())
7421 return QualType();
7422 }
7423
7426 NewTL.setNameLoc(TL.getNameLoc());
7427 } else {
7428 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7429 NewTL.setNameLoc(TL.getNameLoc());
7430 }
7431 return Result;
7432}
7433
7434template <typename Derived>
7437 llvm_unreachable("This type does not need to be transformed.");
7438}
7439
7440 /// Simple iterator that traverses the template arguments in a
7441 /// container that provides a \c getArgLoc() member function.
7442 ///
7443 /// This iterator is intended to be used with the iterator form of
7444 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7445 template<typename ArgLocContainer>
7447 ArgLocContainer *Container;
7448 unsigned Index;
7449
7450 public:
7453 typedef int difference_type;
7454 typedef std::input_iterator_tag iterator_category;
7455
7456 class pointer {
7458
7459 public:
7460 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7461
7463 return &Arg;
7464 }
7465 };
7466
7467
7469
7470 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7471 unsigned Index)
7472 : Container(&Container), Index(Index) { }
7473
7475 ++Index;
7476 return *this;
7477 }
7478
7481 ++(*this);
7482 return Old;
7483 }
7484
7486 return Container->getArgLoc(Index);
7487 }
7488
7490 return pointer(Container->getArgLoc(Index));
7491 }
7492
7495 return X.Container == Y.Container && X.Index == Y.Index;
7496 }
7497
7500 return !(X == Y);
7501 }
7502 };
7503
7504template<typename Derived>
7505QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7506 AutoTypeLoc TL) {
7507 const AutoType *T = TL.getTypePtr();
7508 QualType OldDeduced = T->getDeducedType();
7509 QualType NewDeduced;
7510 if (!OldDeduced.isNull()) {
7511 NewDeduced = getDerived().TransformType(OldDeduced);
7512 if (NewDeduced.isNull())
7513 return QualType();
7514 }
7515
7516 ConceptDecl *NewCD = nullptr;
7517 TemplateArgumentListInfo NewTemplateArgs;
7518 NestedNameSpecifierLoc NewNestedNameSpec;
7519 if (T->isConstrained()) {
7520 assert(TL.getConceptReference());
7521 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7522 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7523
7524 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7525 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7527 if (getDerived().TransformTemplateArguments(
7528 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7529 NewTemplateArgs))
7530 return QualType();
7531
7532 if (TL.getNestedNameSpecifierLoc()) {
7533 NewNestedNameSpec
7534 = getDerived().TransformNestedNameSpecifierLoc(
7535 TL.getNestedNameSpecifierLoc());
7536 if (!NewNestedNameSpec)
7537 return QualType();
7538 }
7539 }
7540
7541 QualType Result = TL.getType();
7542 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7543 T->isDependentType() || T->isConstrained()) {
7544 // FIXME: Maybe don't rebuild if all template arguments are the same.
7546 NewArgList.reserve(NewTemplateArgs.size());
7547 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7548 NewArgList.push_back(ArgLoc.getArgument());
7549 Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword(), NewCD,
7550 NewArgList);
7551 if (Result.isNull())
7552 return QualType();
7553 }
7554
7555 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7556 NewTL.setNameLoc(TL.getNameLoc());
7557 NewTL.setRParenLoc(TL.getRParenLoc());
7558 NewTL.setConceptReference(nullptr);
7559
7560 if (T->isConstrained()) {
7562 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7563 TL.getConceptNameLoc(),
7564 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7565 auto *CR = ConceptReference::Create(
7566 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7567 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7568 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7569 NewTL.setConceptReference(CR);
7570 }
7571
7572 return Result;
7573}
7574
7575template <typename Derived>
7578 return getDerived().TransformTemplateSpecializationType(
7579 TLB, TL, /*ObjectType=*/QualType(), /*FirstQualifierInScope=*/nullptr,
7580 /*AllowInjectedClassName=*/false);
7581}
7582
7583template <typename Derived>
7586 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
7587 const TemplateSpecializationType *T = TL.getTypePtr();
7588
7589 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7590 TemplateName Template = getDerived().TransformTemplateName(
7591 QualifierLoc, TL.getTemplateKeywordLoc(), T->getTemplateName(),
7592 TL.getTemplateNameLoc(), ObjectType, FirstQualifierInScope,
7593 AllowInjectedClassName);
7594 if (Template.isNull())
7595 return QualType();
7596
7597 TemplateArgumentListInfo NewTemplateArgs;
7598 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7599 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7601 ArgIterator;
7602 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7603 ArgIterator(TL, TL.getNumArgs()),
7604 NewTemplateArgs))
7605 return QualType();
7606
7607 // This needs to be rebuilt if either the arguments changed, or if the
7608 // original template changed. If the template changed, and even if the
7609 // arguments didn't change, these arguments might not correspond to their
7610 // respective parameters, therefore needing conversions.
7611 QualType Result = getDerived().RebuildTemplateSpecializationType(
7612 TL.getTypePtr()->getKeyword(), Template, TL.getTemplateNameLoc(),
7613 NewTemplateArgs);
7614
7615 if (!Result.isNull()) {
7617 TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getTemplateKeywordLoc(),
7618 TL.getTemplateNameLoc(), NewTemplateArgs);
7619 }
7620
7621 return Result;
7622}
7623
7624template <typename Derived>
7626 AttributedTypeLoc TL) {
7627 const AttributedType *oldType = TL.getTypePtr();
7628 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7629 if (modifiedType.isNull())
7630 return QualType();
7631
7632 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7633 const Attr *oldAttr = TL.getAttr();
7634 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7635 if (oldAttr && !newAttr)
7636 return QualType();
7637
7638 QualType result = TL.getType();
7639
7640 // FIXME: dependent operand expressions?
7641 if (getDerived().AlwaysRebuild() ||
7642 modifiedType != oldType->getModifiedType()) {
7643 // If the equivalent type is equal to the modified type, we don't want to
7644 // transform it as well because:
7645 //
7646 // 1. The transformation would yield the same result and is therefore
7647 // superfluous, and
7648 //
7649 // 2. Transforming the same type twice can cause problems, e.g. if it
7650 // is a FunctionProtoType, we may end up instantiating the function
7651 // parameters twice, which causes an assertion since the parameters
7652 // are already bound to their counterparts in the template for this
7653 // instantiation.
7654 //
7655 QualType equivalentType = modifiedType;
7656 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7657 TypeLocBuilder AuxiliaryTLB;
7658 AuxiliaryTLB.reserve(TL.getFullDataSize());
7659 equivalentType =
7660 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7661 if (equivalentType.isNull())
7662 return QualType();
7663 }
7664
7665 // Check whether we can add nullability; it is only represented as
7666 // type sugar, and therefore cannot be diagnosed in any other way.
7667 if (auto nullability = oldType->getImmediateNullability()) {
7668 if (!modifiedType->canHaveNullability()) {
7669 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7670 : TL.getModifiedLoc().getBeginLoc()),
7671 diag::err_nullability_nonpointer)
7672 << DiagNullabilityKind(*nullability, false) << modifiedType;
7673 return QualType();
7674 }
7675 }
7676
7677 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7678 modifiedType,
7679 equivalentType,
7680 TL.getAttr());
7681 }
7682
7683 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7684 newTL.setAttr(newAttr);
7685 return result;
7686}
7687
7688template <typename Derived>
7691 const CountAttributedType *OldTy = TL.getTypePtr();
7692 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7693 if (InnerTy.isNull())
7694 return QualType();
7695
7696 Expr *OldCount = TL.getCountExpr();
7697 Expr *NewCount = nullptr;
7698 if (OldCount) {
7699 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7700 if (CountResult.isInvalid())
7701 return QualType();
7702 NewCount = CountResult.get();
7703 }
7704
7705 QualType Result = TL.getType();
7706 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7707 OldCount != NewCount) {
7708 // Currently, CountAttributedType can only wrap incomplete array types.
7710 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7711 }
7712
7713 TLB.push<CountAttributedTypeLoc>(Result);
7714 return Result;
7715}
7716
7717template <typename Derived>
7720 // The BTFTagAttributedType is available for C only.
7721 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7722}
7723
7724template <typename Derived>
7727
7728 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7729
7730 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7731 if (WrappedTy.isNull())
7732 return QualType();
7733
7734 QualType ContainedTy = QualType();
7735 QualType OldContainedTy = oldType->getContainedType();
7736 if (!OldContainedTy.isNull()) {
7737 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7738 if (!oldContainedTSI)
7739 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7740 OldContainedTy, SourceLocation());
7741 TypeSourceInfo *ContainedTSI = getDerived().TransformType(oldContainedTSI);
7742 if (!ContainedTSI)
7743 return QualType();
7744 ContainedTy = ContainedTSI->getType();
7745 }
7746
7747 QualType Result = TL.getType();
7748 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7749 ContainedTy != oldType->getContainedType()) {
7751 WrappedTy, ContainedTy, oldType->getAttrs());
7752 }
7753
7755 return Result;
7756}
7757
7758template <typename Derived>
7761 // No transformations needed.
7762 return TL.getType();
7763}
7764
7765template<typename Derived>
7768 ParenTypeLoc TL) {
7769 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7770 if (Inner.isNull())
7771 return QualType();
7772
7773 QualType Result = TL.getType();
7774 if (getDerived().AlwaysRebuild() ||
7775 Inner != TL.getInnerLoc().getType()) {
7776 Result = getDerived().RebuildParenType(Inner);
7777 if (Result.isNull())
7778 return QualType();
7779 }
7780
7781 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7782 NewTL.setLParenLoc(TL.getLParenLoc());
7783 NewTL.setRParenLoc(TL.getRParenLoc());
7784 return Result;
7785}
7786
7787template <typename Derived>
7791 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7792 if (Inner.isNull())
7793 return QualType();
7794
7795 QualType Result = TL.getType();
7796 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7797 Result =
7798 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7799 if (Result.isNull())
7800 return QualType();
7801 }
7802
7804 NewTL.setExpansionLoc(TL.getExpansionLoc());
7805 return Result;
7806}
7807
7808template<typename Derived>
7809QualType TreeTransform<Derived>::TransformDependentNameType(
7811 return TransformDependentNameType(TLB, TL, false);
7812}
7813
7814template <typename Derived>
7815QualType TreeTransform<Derived>::TransformDependentNameType(
7816 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext,
7817 QualType ObjectType, NamedDecl *UnqualLookup) {
7818 const DependentNameType *T = TL.getTypePtr();
7819
7820 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7821 if (QualifierLoc) {
7822 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
7823 QualifierLoc, ObjectType, UnqualLookup);
7824 if (!QualifierLoc)
7825 return QualType();
7826 } else {
7827 assert((ObjectType.isNull() && !UnqualLookup) &&
7828 "must be transformed by TransformNestedNameSpecifierLoc");
7829 }
7830
7832 = getDerived().RebuildDependentNameType(T->getKeyword(),
7833 TL.getElaboratedKeywordLoc(),
7834 QualifierLoc,
7835 T->getIdentifier(),
7836 TL.getNameLoc(),
7837 DeducedTSTContext);
7838 if (Result.isNull())
7839 return QualType();
7840
7841 if (isa<TagType>(Result)) {
7842 auto NewTL = TLB.push<TagTypeLoc>(Result);
7843 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7844 NewTL.setQualifierLoc(QualifierLoc);
7845 NewTL.setNameLoc(TL.getNameLoc());
7847 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7848 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7849 NewTL.setTemplateNameLoc(TL.getNameLoc());
7850 NewTL.setQualifierLoc(QualifierLoc);
7851 } else if (isa<TypedefType>(Result)) {
7852 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7853 QualifierLoc, TL.getNameLoc());
7854 } else if (isa<UnresolvedUsingType>(Result)) {
7855 auto NewTL = TLB.push<UnresolvedUsingTypeLoc>(Result);
7856 NewTL.set(TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getNameLoc());
7857 } else {
7858 auto NewTL = TLB.push<DependentNameTypeLoc>(Result);
7859 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7860 NewTL.setQualifierLoc(QualifierLoc);
7861 NewTL.setNameLoc(TL.getNameLoc());
7862 }
7863 return Result;
7864}
7865
7866template<typename Derived>
7869 QualType Pattern
7870 = getDerived().TransformType(TLB, TL.getPatternLoc());
7871 if (Pattern.isNull())
7872 return QualType();
7873
7874 QualType Result = TL.getType();
7875 if (getDerived().AlwaysRebuild() ||
7876 Pattern != TL.getPatternLoc().getType()) {
7877 Result = getDerived().RebuildPackExpansionType(Pattern,
7878 TL.getPatternLoc().getSourceRange(),
7879 TL.getEllipsisLoc(),
7880 TL.getTypePtr()->getNumExpansions());
7881 if (Result.isNull())
7882 return QualType();
7883 }
7884
7886 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7887 return Result;
7888}
7889
7890template<typename Derived>
7894 // ObjCInterfaceType is never dependent.
7895 TLB.pushFullCopy(TL);
7896 return TL.getType();
7897}
7898
7899template<typename Derived>
7903 const ObjCTypeParamType *T = TL.getTypePtr();
7904 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7905 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7906 if (!OTP)
7907 return QualType();
7908
7909 QualType Result = TL.getType();
7910 if (getDerived().AlwaysRebuild() ||
7911 OTP != T->getDecl()) {
7912 Result = getDerived().RebuildObjCTypeParamType(
7913 OTP, TL.getProtocolLAngleLoc(),
7914 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7915 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7916 if (Result.isNull())
7917 return QualType();
7918 }
7919
7921 if (TL.getNumProtocols()) {
7922 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7923 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7924 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7925 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7926 }
7927 return Result;
7928}
7929
7930template<typename Derived>
7933 ObjCObjectTypeLoc TL) {
7934 // Transform base type.
7935 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
7936 if (BaseType.isNull())
7937 return QualType();
7938
7939 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
7940
7941 // Transform type arguments.
7942 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
7943 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
7944 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
7945 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
7946 QualType TypeArg = TypeArgInfo->getType();
7947 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
7948 AnyChanged = true;
7949
7950 // We have a pack expansion. Instantiate it.
7951 const auto *PackExpansion = PackExpansionLoc.getType()
7952 ->castAs<PackExpansionType>();
7954 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
7955 Unexpanded);
7956 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7957
7958 // Determine whether the set of unexpanded parameter packs can
7959 // and should be expanded.
7960 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
7961 bool Expand = false;
7962 bool RetainExpansion = false;
7963 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
7964 if (getDerived().TryExpandParameterPacks(
7965 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
7966 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
7967 RetainExpansion, NumExpansions))
7968 return QualType();
7969
7970 if (!Expand) {
7971 // We can't expand this pack expansion into separate arguments yet;
7972 // just substitute into the pattern and create a new pack expansion
7973 // type.
7974 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7975
7976 TypeLocBuilder TypeArgBuilder;
7977 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7978 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
7979 PatternLoc);
7980 if (NewPatternType.isNull())
7981 return QualType();
7982
7983 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
7984 NewPatternType, NumExpansions);
7985 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
7986 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
7987 NewTypeArgInfos.push_back(
7988 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
7989 continue;
7990 }
7991
7992 // Substitute into the pack expansion pattern for each slice of the
7993 // pack.
7994 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
7995 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
7996
7997 TypeLocBuilder TypeArgBuilder;
7998 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7999
8000 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
8001 PatternLoc);
8002 if (NewTypeArg.isNull())
8003 return QualType();
8004
8005 NewTypeArgInfos.push_back(
8006 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8007 }
8008
8009 continue;
8010 }
8011
8012 TypeLocBuilder TypeArgBuilder;
8013 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
8014 QualType NewTypeArg =
8015 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
8016 if (NewTypeArg.isNull())
8017 return QualType();
8018
8019 // If nothing changed, just keep the old TypeSourceInfo.
8020 if (NewTypeArg == TypeArg) {
8021 NewTypeArgInfos.push_back(TypeArgInfo);
8022 continue;
8023 }
8024
8025 NewTypeArgInfos.push_back(
8026 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8027 AnyChanged = true;
8028 }
8029
8030 QualType Result = TL.getType();
8031 if (getDerived().AlwaysRebuild() || AnyChanged) {
8032 // Rebuild the type.
8033 Result = getDerived().RebuildObjCObjectType(
8034 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
8035 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
8036 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8037 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8038
8039 if (Result.isNull())
8040 return QualType();
8041 }
8042
8043 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
8044 NewT.setHasBaseTypeAsWritten(true);
8045 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
8046 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
8047 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
8048 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
8049 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8050 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8051 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
8052 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8053 return Result;
8054}
8055
8056template<typename Derived>
8060 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8061 if (PointeeType.isNull())
8062 return QualType();
8063
8064 QualType Result = TL.getType();
8065 if (getDerived().AlwaysRebuild() ||
8066 PointeeType != TL.getPointeeLoc().getType()) {
8067 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8068 TL.getStarLoc());
8069 if (Result.isNull())
8070 return QualType();
8071 }
8072
8074 NewT.setStarLoc(TL.getStarLoc());
8075 return Result;
8076}
8077
8078//===----------------------------------------------------------------------===//
8079// Statement transformation
8080//===----------------------------------------------------------------------===//
8081template<typename Derived>
8084 return S;
8085}
8086
8087template<typename Derived>
8090 return getDerived().TransformCompoundStmt(S, false);
8091}
8092
8093template<typename Derived>
8096 bool IsStmtExpr) {
8097 Sema::CompoundScopeRAII CompoundScope(getSema());
8098 Sema::FPFeaturesStateRAII FPSave(getSema());
8099 if (S->hasStoredFPFeatures())
8100 getSema().resetFPOptions(
8101 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8102
8103 bool SubStmtInvalid = false;
8104 bool SubStmtChanged = false;
8105 SmallVector<Stmt*, 8> Statements;
8106 for (auto *B : S->body()) {
8107 StmtResult Result = getDerived().TransformStmt(
8108 B, IsStmtExpr && B == S->body_back() ? StmtDiscardKind::StmtExprResult
8109 : StmtDiscardKind::Discarded);
8110
8111 if (Result.isInvalid()) {
8112 // Immediately fail if this was a DeclStmt, since it's very
8113 // likely that this will cause problems for future statements.
8114 if (isa<DeclStmt>(B))
8115 return StmtError();
8116
8117 // Otherwise, just keep processing substatements and fail later.
8118 SubStmtInvalid = true;
8119 continue;
8120 }
8121
8122 SubStmtChanged = SubStmtChanged || Result.get() != B;
8123 Statements.push_back(Result.getAs<Stmt>());
8124 }
8125
8126 if (SubStmtInvalid)
8127 return StmtError();
8128
8129 if (!getDerived().AlwaysRebuild() &&
8130 !SubStmtChanged)
8131 return S;
8132
8133 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8134 Statements,
8135 S->getRBracLoc(),
8136 IsStmtExpr);
8137}
8138
8139template<typename Derived>
8142 ExprResult LHS, RHS;
8143 {
8146
8147 // Transform the left-hand case value.
8148 LHS = getDerived().TransformExpr(S->getLHS());
8149 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8150 if (LHS.isInvalid())
8151 return StmtError();
8152
8153 // Transform the right-hand case value (for the GNU case-range extension).
8154 RHS = getDerived().TransformExpr(S->getRHS());
8155 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8156 if (RHS.isInvalid())
8157 return StmtError();
8158 }
8159
8160 // Build the case statement.
8161 // Case statements are always rebuilt so that they will attached to their
8162 // transformed switch statement.
8163 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8164 LHS.get(),
8165 S->getEllipsisLoc(),
8166 RHS.get(),
8167 S->getColonLoc());
8168 if (Case.isInvalid())
8169 return StmtError();
8170
8171 // Transform the statement following the case
8172 StmtResult SubStmt =
8173 getDerived().TransformStmt(S->getSubStmt());
8174 if (SubStmt.isInvalid())
8175 return StmtError();
8176
8177 // Attach the body to the case statement
8178 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8179}
8180
8181template <typename Derived>
8183 // Transform the statement following the default case
8184 StmtResult SubStmt =
8185 getDerived().TransformStmt(S->getSubStmt());
8186 if (SubStmt.isInvalid())
8187 return StmtError();
8188
8189 // Default statements are always rebuilt
8190 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8191 SubStmt.get());
8192}
8193
8194template<typename Derived>
8197 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8198 if (SubStmt.isInvalid())
8199 return StmtError();
8200
8201 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8202 S->getDecl());
8203 if (!LD)
8204 return StmtError();
8205
8206 // If we're transforming "in-place" (we're not creating new local
8207 // declarations), assume we're replacing the old label statement
8208 // and clear out the reference to it.
8209 if (LD == S->getDecl())
8210 S->getDecl()->setStmt(nullptr);
8211
8212 // FIXME: Pass the real colon location in.
8213 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8215 SubStmt.get());
8216}
8217
8218template <typename Derived>
8220 if (!R)
8221 return R;
8222
8223 switch (R->getKind()) {
8224// Transform attributes by calling TransformXXXAttr.
8225#define ATTR(X) \
8226 case attr::X: \
8227 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8228#include "clang/Basic/AttrList.inc"
8229 }
8230 return R;
8231}
8232
8233template <typename Derived>
8235 const Stmt *InstS,
8236 const Attr *R) {
8237 if (!R)
8238 return R;
8239
8240 switch (R->getKind()) {
8241// Transform attributes by calling TransformStmtXXXAttr.
8242#define ATTR(X) \
8243 case attr::X: \
8244 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8245#include "clang/Basic/AttrList.inc"
8246 }
8247 return TransformAttr(R);
8248}
8249
8250template <typename Derived>
8253 StmtDiscardKind SDK) {
8254 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8255 if (SubStmt.isInvalid())
8256 return StmtError();
8257
8258 bool AttrsChanged = false;
8260
8261 // Visit attributes and keep track if any are transformed.
8262 for (const auto *I : S->getAttrs()) {
8263 const Attr *R =
8264 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8265 AttrsChanged |= (I != R);
8266 if (R)
8267 Attrs.push_back(R);
8268 }
8269
8270 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8271 return S;
8272
8273 // If transforming the attributes failed for all of the attributes in the
8274 // statement, don't make an AttributedStmt without attributes.
8275 if (Attrs.empty())
8276 return SubStmt;
8277
8278 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8279 SubStmt.get());
8280}
8281
8282template<typename Derived>
8285 // Transform the initialization statement
8286 StmtResult Init = getDerived().TransformStmt(S->getInit());
8287 if (Init.isInvalid())
8288 return StmtError();
8289
8291 if (!S->isConsteval()) {
8292 // Transform the condition
8293 Cond = getDerived().TransformCondition(
8294 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8295 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8297 if (Cond.isInvalid())
8298 return StmtError();
8299 }
8300
8301 // If this is a constexpr if, determine which arm we should instantiate.
8302 std::optional<bool> ConstexprConditionValue;
8303 if (S->isConstexpr())
8304 ConstexprConditionValue = Cond.getKnownValue();
8305
8306 // Transform the "then" branch.
8307 StmtResult Then;
8308 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8312 S->isNonNegatedConsteval());
8313
8314 Then = getDerived().TransformStmt(S->getThen());
8315 if (Then.isInvalid())
8316 return StmtError();
8317 } else {
8318 // Discarded branch is replaced with empty CompoundStmt so we can keep
8319 // proper source location for start and end of original branch, so
8320 // subsequent transformations like CoverageMapping work properly
8321 Then = new (getSema().Context)
8322 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8323 }
8324
8325 // Transform the "else" branch.
8326 StmtResult Else;
8327 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8331 S->isNegatedConsteval());
8332
8333 Else = getDerived().TransformStmt(S->getElse());
8334 if (Else.isInvalid())
8335 return StmtError();
8336 } else if (S->getElse() && ConstexprConditionValue &&
8337 *ConstexprConditionValue) {
8338 // Same thing here as with <then> branch, we are discarding it, we can't
8339 // replace it with NULL nor NullStmt as we need to keep for source location
8340 // range, for CoverageMapping
8341 Else = new (getSema().Context)
8342 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8343 }
8344
8345 if (!getDerived().AlwaysRebuild() &&
8346 Init.get() == S->getInit() &&
8347 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8348 Then.get() == S->getThen() &&
8349 Else.get() == S->getElse())
8350 return S;
8351
8352 return getDerived().RebuildIfStmt(
8353 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8354 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8355}
8356
8357template<typename Derived>
8360 // Transform the initialization statement
8361 StmtResult Init = getDerived().TransformStmt(S->getInit());
8362 if (Init.isInvalid())
8363 return StmtError();
8364
8365 // Transform the condition.
8366 Sema::ConditionResult Cond = getDerived().TransformCondition(
8367 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8369 if (Cond.isInvalid())
8370 return StmtError();
8371
8372 // Rebuild the switch statement.
8374 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8375 Init.get(), Cond, S->getRParenLoc());
8376 if (Switch.isInvalid())
8377 return StmtError();
8378
8379 // Transform the body of the switch statement.
8380 StmtResult Body = getDerived().TransformStmt(S->getBody());
8381 if (Body.isInvalid())
8382 return StmtError();
8383
8384 // Complete the switch statement.
8385 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8386 Body.get());
8387}
8388
8389template<typename Derived>
8392 // Transform the condition
8393 Sema::ConditionResult Cond = getDerived().TransformCondition(
8394 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8396 if (Cond.isInvalid())
8397 return StmtError();
8398
8399 // OpenACC Restricts a while-loop inside of certain construct/clause
8400 // combinations, so diagnose that here in OpenACC mode.
8402 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8403
8404 // Transform the body
8405 StmtResult Body = getDerived().TransformStmt(S->getBody());
8406 if (Body.isInvalid())
8407 return StmtError();
8408
8409 if (!getDerived().AlwaysRebuild() &&
8410 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8411 Body.get() == S->getBody())
8412 return Owned(S);
8413
8414 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8415 Cond, S->getRParenLoc(), Body.get());
8416}
8417
8418template<typename Derived>
8421 // OpenACC Restricts a do-loop inside of certain construct/clause
8422 // combinations, so diagnose that here in OpenACC mode.
8424 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8425
8426 // Transform the body
8427 StmtResult Body = getDerived().TransformStmt(S->getBody());
8428 if (Body.isInvalid())
8429 return StmtError();
8430
8431 // Transform the condition
8432 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8433 if (Cond.isInvalid())
8434 return StmtError();
8435
8436 if (!getDerived().AlwaysRebuild() &&
8437 Cond.get() == S->getCond() &&
8438 Body.get() == S->getBody())
8439 return S;
8440
8441 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8442 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8443 S->getRParenLoc());
8444}
8445
8446template<typename Derived>
8449 if (getSema().getLangOpts().OpenMP)
8450 getSema().OpenMP().startOpenMPLoop();
8451
8452 // Transform the initialization statement
8453 StmtResult Init = getDerived().TransformStmt(S->getInit());
8454 if (Init.isInvalid())
8455 return StmtError();
8456
8457 // In OpenMP loop region loop control variable must be captured and be
8458 // private. Perform analysis of first part (if any).
8459 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8460 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8461 Init.get());
8462
8463 // Transform the condition
8464 Sema::ConditionResult Cond = getDerived().TransformCondition(
8465 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8467 if (Cond.isInvalid())
8468 return StmtError();
8469
8470 // Transform the increment
8471 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8472 if (Inc.isInvalid())
8473 return StmtError();
8474
8475 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8476 if (S->getInc() && !FullInc.get())
8477 return StmtError();
8478
8479 // OpenACC Restricts a for-loop inside of certain construct/clause
8480 // combinations, so diagnose that here in OpenACC mode.
8482 SemaRef.OpenACC().ActOnForStmtBegin(
8483 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8484 Cond.get().second, S->getInc(), Inc.get());
8485
8486 // Transform the body
8487 StmtResult Body = getDerived().TransformStmt(S->getBody());
8488 if (Body.isInvalid())
8489 return StmtError();
8490
8491 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8492
8493 if (!getDerived().AlwaysRebuild() &&
8494 Init.get() == S->getInit() &&
8495 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8496 Inc.get() == S->getInc() &&
8497 Body.get() == S->getBody())
8498 return S;
8499
8500 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8501 Init.get(), Cond, FullInc,
8502 S->getRParenLoc(), Body.get());
8503}
8504
8505template<typename Derived>
8508 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8509 S->getLabel());
8510 if (!LD)
8511 return StmtError();
8512
8513 // Goto statements must always be rebuilt, to resolve the label.
8514 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8515 cast<LabelDecl>(LD));
8516}
8517
8518template<typename Derived>
8521 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8522 if (Target.isInvalid())
8523 return StmtError();
8524 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8525
8526 if (!getDerived().AlwaysRebuild() &&
8527 Target.get() == S->getTarget())
8528 return S;
8529
8530 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8531 Target.get());
8532}
8533
8534template<typename Derived>
8537 if (!S->hasLabelTarget())
8538 return S;
8539
8540 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8541 S->getLabelDecl());
8542 if (!LD)
8543 return StmtError();
8544
8545 return new (SemaRef.Context)
8546 ContinueStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8547}
8548
8549template<typename Derived>
8552 if (!S->hasLabelTarget())
8553 return S;
8554
8555 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8556 S->getLabelDecl());
8557 if (!LD)
8558 return StmtError();
8559
8560 return new (SemaRef.Context)
8561 BreakStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8562}
8563
8564template <typename Derived>
8566 StmtResult Result = getDerived().TransformStmt(S->getBody());
8567 if (!Result.isUsable())
8568 return StmtError();
8569 return DeferStmt::Create(getSema().Context, S->getDeferLoc(), Result.get());
8570}
8571
8572template<typename Derived>
8575 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8576 /*NotCopyInit*/false);
8577 if (Result.isInvalid())
8578 return StmtError();
8579
8580 // FIXME: We always rebuild the return statement because there is no way
8581 // to tell whether the return type of the function has changed.
8582 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8583}
8584
8585template<typename Derived>
8588 bool DeclChanged = false;
8590 LambdaScopeInfo *LSI = getSema().getCurLambda();
8591 for (auto *D : S->decls()) {
8592 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8593 if (!Transformed)
8594 return StmtError();
8595
8596 if (Transformed != D)
8597 DeclChanged = true;
8598
8599 if (LSI) {
8600 if (auto *TD = dyn_cast<TypeDecl>(Transformed)) {
8601 if (auto *TN = dyn_cast<TypedefNameDecl>(TD)) {
8602 LSI->ContainsUnexpandedParameterPack |=
8603 TN->getUnderlyingType()->containsUnexpandedParameterPack();
8604 } else {
8605 LSI->ContainsUnexpandedParameterPack |=
8606 getSema()
8607 .getASTContext()
8608 .getTypeDeclType(TD)
8609 ->containsUnexpandedParameterPack();
8610 }
8611 }
8612 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8613 LSI->ContainsUnexpandedParameterPack |=
8614 VD->getType()->containsUnexpandedParameterPack();
8615 }
8616
8617 Decls.push_back(Transformed);
8618 }
8619
8620 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8621 return S;
8622
8623 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8624}
8625
8626template<typename Derived>
8629
8630 SmallVector<Expr*, 8> Constraints;
8633
8634 SmallVector<Expr*, 8> Clobbers;
8635
8636 bool ExprsChanged = false;
8637
8638 auto RebuildString = [&](Expr *E) {
8639 ExprResult Result = getDerived().TransformExpr(E);
8640 if (!Result.isUsable())
8641 return Result;
8642 if (Result.get() != E) {
8643 ExprsChanged = true;
8644 Result = SemaRef.ActOnGCCAsmStmtString(Result.get(), /*ForLabel=*/false);
8645 }
8646 return Result;
8647 };
8648
8649 // Go through the outputs.
8650 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8651 Names.push_back(S->getOutputIdentifier(I));
8652
8653 ExprResult Result = RebuildString(S->getOutputConstraintExpr(I));
8654 if (Result.isInvalid())
8655 return StmtError();
8656
8657 Constraints.push_back(Result.get());
8658
8659 // Transform the output expr.
8660 Expr *OutputExpr = S->getOutputExpr(I);
8661 Result = getDerived().TransformExpr(OutputExpr);
8662 if (Result.isInvalid())
8663 return StmtError();
8664
8665 ExprsChanged |= Result.get() != OutputExpr;
8666
8667 Exprs.push_back(Result.get());
8668 }
8669
8670 // Go through the inputs.
8671 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8672 Names.push_back(S->getInputIdentifier(I));
8673
8674 ExprResult Result = RebuildString(S->getInputConstraintExpr(I));
8675 if (Result.isInvalid())
8676 return StmtError();
8677
8678 Constraints.push_back(Result.get());
8679
8680 // Transform the input expr.
8681 Expr *InputExpr = S->getInputExpr(I);
8682 Result = getDerived().TransformExpr(InputExpr);
8683 if (Result.isInvalid())
8684 return StmtError();
8685
8686 ExprsChanged |= Result.get() != InputExpr;
8687
8688 Exprs.push_back(Result.get());
8689 }
8690
8691 // Go through the Labels.
8692 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8693 Names.push_back(S->getLabelIdentifier(I));
8694
8695 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8696 if (Result.isInvalid())
8697 return StmtError();
8698 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8699 Exprs.push_back(Result.get());
8700 }
8701
8702 // Go through the clobbers.
8703 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) {
8704 ExprResult Result = RebuildString(S->getClobberExpr(I));
8705 if (Result.isInvalid())
8706 return StmtError();
8707 Clobbers.push_back(Result.get());
8708 }
8709
8710 ExprResult AsmString = RebuildString(S->getAsmStringExpr());
8711 if (AsmString.isInvalid())
8712 return StmtError();
8713
8714 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8715 return S;
8716
8717 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8718 S->isVolatile(), S->getNumOutputs(),
8719 S->getNumInputs(), Names.data(),
8720 Constraints, Exprs, AsmString.get(),
8721 Clobbers, S->getNumLabels(),
8722 S->getRParenLoc());
8723}
8724
8725template<typename Derived>
8728 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8729
8730 bool HadError = false, HadChange = false;
8731
8732 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8733 SmallVector<Expr*, 8> TransformedExprs;
8734 TransformedExprs.reserve(SrcExprs.size());
8735 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8736 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8737 if (!Result.isUsable()) {
8738 HadError = true;
8739 } else {
8740 HadChange |= (Result.get() != SrcExprs[i]);
8741 TransformedExprs.push_back(Result.get());
8742 }
8743 }
8744
8745 if (HadError) return StmtError();
8746 if (!HadChange && !getDerived().AlwaysRebuild())
8747 return Owned(S);
8748
8749 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8750 AsmToks, S->getAsmString(),
8751 S->getNumOutputs(), S->getNumInputs(),
8752 S->getAllConstraints(), S->getClobbers(),
8753 TransformedExprs, S->getEndLoc());
8754}
8755
8756// C++ Coroutines
8757template<typename Derived>
8760 auto *ScopeInfo = SemaRef.getCurFunction();
8761 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8762 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8763 ScopeInfo->NeedsCoroutineSuspends &&
8764 ScopeInfo->CoroutineSuspends.first == nullptr &&
8765 ScopeInfo->CoroutineSuspends.second == nullptr &&
8766 "expected clean scope info");
8767
8768 // Set that we have (possibly-invalid) suspend points before we do anything
8769 // that may fail.
8770 ScopeInfo->setNeedsCoroutineSuspends(false);
8771
8772 // We re-build the coroutine promise object (and the coroutine parameters its
8773 // type and constructor depend on) based on the types used in our current
8774 // function. We must do so, and set it on the current FunctionScopeInfo,
8775 // before attempting to transform the other parts of the coroutine body
8776 // statement, such as the implicit suspend statements (because those
8777 // statements reference the FunctionScopeInfo::CoroutinePromise).
8778 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8779 return StmtError();
8780 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8781 if (!Promise)
8782 return StmtError();
8783 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8784 ScopeInfo->CoroutinePromise = Promise;
8785
8786 // Transform the implicit coroutine statements constructed using dependent
8787 // types during the previous parse: initial and final suspensions, the return
8788 // object, and others. We also transform the coroutine function's body.
8789 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8790 if (InitSuspend.isInvalid())
8791 return StmtError();
8792 StmtResult FinalSuspend =
8793 getDerived().TransformStmt(S->getFinalSuspendStmt());
8794 if (FinalSuspend.isInvalid() ||
8795 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8796 return StmtError();
8797 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8798 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8799
8800 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8801 if (BodyRes.isInvalid())
8802 return StmtError();
8803
8804 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8805 if (Builder.isInvalid())
8806 return StmtError();
8807
8808 Expr *ReturnObject = S->getReturnValueInit();
8809 assert(ReturnObject && "the return object is expected to be valid");
8810 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8811 /*NoCopyInit*/ false);
8812 if (Res.isInvalid())
8813 return StmtError();
8814 Builder.ReturnValue = Res.get();
8815
8816 // If during the previous parse the coroutine still had a dependent promise
8817 // statement, we may need to build some implicit coroutine statements
8818 // (such as exception and fallthrough handlers) for the first time.
8819 if (S->hasDependentPromiseType()) {
8820 // We can only build these statements, however, if the current promise type
8821 // is not dependent.
8822 if (!Promise->getType()->isDependentType()) {
8823 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8824 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8825 "these nodes should not have been built yet");
8826 if (!Builder.buildDependentStatements())
8827 return StmtError();
8828 }
8829 } else {
8830 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8831 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8832 if (Res.isInvalid())
8833 return StmtError();
8834 Builder.OnFallthrough = Res.get();
8835 }
8836
8837 if (auto *OnException = S->getExceptionHandler()) {
8838 StmtResult Res = getDerived().TransformStmt(OnException);
8839 if (Res.isInvalid())
8840 return StmtError();
8841 Builder.OnException = Res.get();
8842 }
8843
8844 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8845 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8846 if (Res.isInvalid())
8847 return StmtError();
8848 Builder.ReturnStmtOnAllocFailure = Res.get();
8849 }
8850
8851 // Transform any additional statements we may have already built
8852 assert(S->getAllocate() && S->getDeallocate() &&
8853 "allocation and deallocation calls must already be built");
8854 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8855 if (AllocRes.isInvalid())
8856 return StmtError();
8857 Builder.Allocate = AllocRes.get();
8858
8859 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8860 if (DeallocRes.isInvalid())
8861 return StmtError();
8862 Builder.Deallocate = DeallocRes.get();
8863
8864 if (auto *ResultDecl = S->getResultDecl()) {
8865 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8866 if (Res.isInvalid())
8867 return StmtError();
8868 Builder.ResultDecl = Res.get();
8869 }
8870
8871 if (auto *ReturnStmt = S->getReturnStmt()) {
8872 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8873 if (Res.isInvalid())
8874 return StmtError();
8875 Builder.ReturnStmt = Res.get();
8876 }
8877 }
8878
8879 return getDerived().RebuildCoroutineBodyStmt(Builder);
8880}
8881
8882template<typename Derived>
8885 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8886 /*NotCopyInit*/false);
8887 if (Result.isInvalid())
8888 return StmtError();
8889
8890 // Always rebuild; we don't know if this needs to be injected into a new
8891 // context or if the promise type has changed.
8892 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8893 S->isImplicit());
8894}
8895
8896template <typename Derived>
8898 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8899 /*NotCopyInit*/ false);
8900 if (Operand.isInvalid())
8901 return ExprError();
8902
8903 // Rebuild the common-expr from the operand rather than transforming it
8904 // separately.
8905
8906 // FIXME: getCurScope() should not be used during template instantiation.
8907 // We should pick up the set of unqualified lookup results for operator
8908 // co_await during the initial parse.
8909 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8910 getSema().getCurScope(), E->getKeywordLoc());
8911
8912 // Always rebuild; we don't know if this needs to be injected into a new
8913 // context or if the promise type has changed.
8914 return getDerived().RebuildCoawaitExpr(
8915 E->getKeywordLoc(), Operand.get(),
8916 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8917}
8918
8919template <typename Derived>
8922 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8923 /*NotCopyInit*/ false);
8924 if (OperandResult.isInvalid())
8925 return ExprError();
8926
8927 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8928 E->getOperatorCoawaitLookup());
8929
8930 if (LookupResult.isInvalid())
8931 return ExprError();
8932
8933 // Always rebuild; we don't know if this needs to be injected into a new
8934 // context or if the promise type has changed.
8935 return getDerived().RebuildDependentCoawaitExpr(
8936 E->getKeywordLoc(), OperandResult.get(),
8938}
8939
8940template<typename Derived>
8943 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
8944 /*NotCopyInit*/false);
8945 if (Result.isInvalid())
8946 return ExprError();
8947
8948 // Always rebuild; we don't know if this needs to be injected into a new
8949 // context or if the promise type has changed.
8950 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
8951}
8952
8953// Objective-C Statements.
8954
8955template<typename Derived>
8958 // Transform the body of the @try.
8959 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
8960 if (TryBody.isInvalid())
8961 return StmtError();
8962
8963 // Transform the @catch statements (if present).
8964 bool AnyCatchChanged = false;
8965 SmallVector<Stmt*, 8> CatchStmts;
8966 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
8967 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
8968 if (Catch.isInvalid())
8969 return StmtError();
8970 if (Catch.get() != S->getCatchStmt(I))
8971 AnyCatchChanged = true;
8972 CatchStmts.push_back(Catch.get());
8973 }
8974
8975 // Transform the @finally statement (if present).
8976 StmtResult Finally;
8977 if (S->getFinallyStmt()) {
8978 Finally = getDerived().TransformStmt(S->getFinallyStmt());
8979 if (Finally.isInvalid())
8980 return StmtError();
8981 }
8982
8983 // If nothing changed, just retain this statement.
8984 if (!getDerived().AlwaysRebuild() &&
8985 TryBody.get() == S->getTryBody() &&
8986 !AnyCatchChanged &&
8987 Finally.get() == S->getFinallyStmt())
8988 return S;
8989
8990 // Build a new statement.
8991 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
8992 CatchStmts, Finally.get());
8993}
8994
8995template<typename Derived>
8998 // Transform the @catch parameter, if there is one.
8999 VarDecl *Var = nullptr;
9000 if (VarDecl *FromVar = S->getCatchParamDecl()) {
9001 TypeSourceInfo *TSInfo = nullptr;
9002 if (FromVar->getTypeSourceInfo()) {
9003 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
9004 if (!TSInfo)
9005 return StmtError();
9006 }
9007
9008 QualType T;
9009 if (TSInfo)
9010 T = TSInfo->getType();
9011 else {
9012 T = getDerived().TransformType(FromVar->getType());
9013 if (T.isNull())
9014 return StmtError();
9015 }
9016
9017 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
9018 if (!Var)
9019 return StmtError();
9020 }
9021
9022 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
9023 if (Body.isInvalid())
9024 return StmtError();
9025
9026 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
9027 S->getRParenLoc(),
9028 Var, Body.get());
9029}
9030
9031template<typename Derived>
9034 // Transform the body.
9035 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
9036 if (Body.isInvalid())
9037 return StmtError();
9038
9039 // If nothing changed, just retain this statement.
9040 if (!getDerived().AlwaysRebuild() &&
9041 Body.get() == S->getFinallyBody())
9042 return S;
9043
9044 // Build a new statement.
9045 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
9046 Body.get());
9047}
9048
9049template<typename Derived>
9053 if (S->getThrowExpr()) {
9054 Operand = getDerived().TransformExpr(S->getThrowExpr());
9055 if (Operand.isInvalid())
9056 return StmtError();
9057 }
9058
9059 if (!getDerived().AlwaysRebuild() &&
9060 Operand.get() == S->getThrowExpr())
9061 return S;
9062
9063 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
9064}
9065
9066template<typename Derived>
9070 // Transform the object we are locking.
9071 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
9072 if (Object.isInvalid())
9073 return StmtError();
9074 Object =
9075 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
9076 Object.get());
9077 if (Object.isInvalid())
9078 return StmtError();
9079
9080 // Transform the body.
9081 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
9082 if (Body.isInvalid())
9083 return StmtError();
9084
9085 // If nothing change, just retain the current statement.
9086 if (!getDerived().AlwaysRebuild() &&
9087 Object.get() == S->getSynchExpr() &&
9088 Body.get() == S->getSynchBody())
9089 return S;
9090
9091 // Build a new statement.
9092 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
9093 Object.get(), Body.get());
9094}
9095
9096template<typename Derived>
9100 // Transform the body.
9101 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
9102 if (Body.isInvalid())
9103 return StmtError();
9104
9105 // If nothing changed, just retain this statement.
9106 if (!getDerived().AlwaysRebuild() &&
9107 Body.get() == S->getSubStmt())
9108 return S;
9109
9110 // Build a new statement.
9111 return getDerived().RebuildObjCAutoreleasePoolStmt(
9112 S->getAtLoc(), Body.get());
9113}
9114
9115template<typename Derived>
9119 // Transform the element statement.
9120 StmtResult Element = getDerived().TransformStmt(
9121 S->getElement(), StmtDiscardKind::NotDiscarded);
9122 if (Element.isInvalid())
9123 return StmtError();
9124
9125 // Transform the collection expression.
9126 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9127 if (Collection.isInvalid())
9128 return StmtError();
9129
9130 // Transform the body.
9131 StmtResult Body = getDerived().TransformStmt(S->getBody());
9132 if (Body.isInvalid())
9133 return StmtError();
9134
9135 // If nothing changed, just retain this statement.
9136 if (!getDerived().AlwaysRebuild() &&
9137 Element.get() == S->getElement() &&
9138 Collection.get() == S->getCollection() &&
9139 Body.get() == S->getBody())
9140 return S;
9141
9142 // Build a new statement.
9143 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9144 Element.get(),
9145 Collection.get(),
9146 S->getRParenLoc(),
9147 Body.get());
9148}
9149
9150template <typename Derived>
9152 // Transform the exception declaration, if any.
9153 VarDecl *Var = nullptr;
9154 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9155 TypeSourceInfo *T =
9156 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9157 if (!T)
9158 return StmtError();
9159
9160 Var = getDerived().RebuildExceptionDecl(
9161 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9162 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9163 if (!Var || Var->isInvalidDecl())
9164 return StmtError();
9165 }
9166
9167 // Transform the actual exception handler.
9168 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9169 if (Handler.isInvalid())
9170 return StmtError();
9171
9172 if (!getDerived().AlwaysRebuild() && !Var &&
9173 Handler.get() == S->getHandlerBlock())
9174 return S;
9175
9176 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9177}
9178
9179template <typename Derived>
9181 // Transform the try block itself.
9182 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9183 if (TryBlock.isInvalid())
9184 return StmtError();
9185
9186 // Transform the handlers.
9187 bool HandlerChanged = false;
9188 SmallVector<Stmt *, 8> Handlers;
9189 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9190 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9191 if (Handler.isInvalid())
9192 return StmtError();
9193
9194 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9195 Handlers.push_back(Handler.getAs<Stmt>());
9196 }
9197
9198 getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
9199
9200 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9201 !HandlerChanged)
9202 return S;
9203
9204 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9205 Handlers);
9206}
9207
9208template<typename Derived>
9211 EnterExpressionEvaluationContext ForRangeInitContext(
9213 /*LambdaContextDecl=*/nullptr,
9215 getSema().getLangOpts().CPlusPlus23);
9216
9217 // P2718R0 - Lifetime extension in range-based for loops.
9218 if (getSema().getLangOpts().CPlusPlus23) {
9219 auto &LastRecord = getSema().currentEvaluationContext();
9220 LastRecord.InLifetimeExtendingContext = true;
9221 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9222 }
9224 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9225 if (Init.isInvalid())
9226 return StmtError();
9227
9228 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9229 if (Range.isInvalid())
9230 return StmtError();
9231
9232 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9233 assert(getSema().getLangOpts().CPlusPlus23 ||
9234 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9235 auto ForRangeLifetimeExtendTemps =
9236 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9237
9238 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9239 if (Begin.isInvalid())
9240 return StmtError();
9241 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9242 if (End.isInvalid())
9243 return StmtError();
9244
9245 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9246 if (Cond.isInvalid())
9247 return StmtError();
9248 if (Cond.get())
9249 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9250 if (Cond.isInvalid())
9251 return StmtError();
9252 if (Cond.get())
9253 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9254
9255 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9256 if (Inc.isInvalid())
9257 return StmtError();
9258 if (Inc.get())
9259 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9260
9261 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9262 if (LoopVar.isInvalid())
9263 return StmtError();
9264
9265 StmtResult NewStmt = S;
9266 if (getDerived().AlwaysRebuild() ||
9267 Init.get() != S->getInit() ||
9268 Range.get() != S->getRangeStmt() ||
9269 Begin.get() != S->getBeginStmt() ||
9270 End.get() != S->getEndStmt() ||
9271 Cond.get() != S->getCond() ||
9272 Inc.get() != S->getInc() ||
9273 LoopVar.get() != S->getLoopVarStmt()) {
9274 NewStmt = getDerived().RebuildCXXForRangeStmt(
9275 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9276 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9277 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9278 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9279 // Might not have attached any initializer to the loop variable.
9280 getSema().ActOnInitializerError(
9281 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9282 return StmtError();
9283 }
9284 }
9285
9286 // OpenACC Restricts a while-loop inside of certain construct/clause
9287 // combinations, so diagnose that here in OpenACC mode.
9289 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9290
9291 StmtResult Body = getDerived().TransformStmt(S->getBody());
9292 if (Body.isInvalid())
9293 return StmtError();
9294
9295 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9296
9297 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9298 // it now so we have a new statement to attach the body to.
9299 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9300 NewStmt = getDerived().RebuildCXXForRangeStmt(
9301 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9302 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9303 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9304 if (NewStmt.isInvalid())
9305 return StmtError();
9306 }
9307
9308 if (NewStmt.get() == S)
9309 return S;
9310
9311 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9312}
9313
9314template<typename Derived>
9318 // Transform the nested-name-specifier, if any.
9319 NestedNameSpecifierLoc QualifierLoc;
9320 if (S->getQualifierLoc()) {
9321 QualifierLoc
9322 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9323 if (!QualifierLoc)
9324 return StmtError();
9325 }
9326
9327 // Transform the declaration name.
9328 DeclarationNameInfo NameInfo = S->getNameInfo();
9329 if (NameInfo.getName()) {
9330 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9331 if (!NameInfo.getName())
9332 return StmtError();
9333 }
9334
9335 // Check whether anything changed.
9336 if (!getDerived().AlwaysRebuild() &&
9337 QualifierLoc == S->getQualifierLoc() &&
9338 NameInfo.getName() == S->getNameInfo().getName())
9339 return S;
9340
9341 // Determine whether this name exists, if we can.
9342 CXXScopeSpec SS;
9343 SS.Adopt(QualifierLoc);
9344 bool Dependent = false;
9345 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9347 if (S->isIfExists())
9348 break;
9349
9350 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9351
9353 if (S->isIfNotExists())
9354 break;
9355
9356 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9357
9359 Dependent = true;
9360 break;
9361
9363 return StmtError();
9364 }
9365
9366 // We need to continue with the instantiation, so do so now.
9367 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9368 if (SubStmt.isInvalid())
9369 return StmtError();
9370
9371 // If we have resolved the name, just transform to the substatement.
9372 if (!Dependent)
9373 return SubStmt;
9374
9375 // The name is still dependent, so build a dependent expression again.
9376 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9377 S->isIfExists(),
9378 QualifierLoc,
9379 NameInfo,
9380 SubStmt.get());
9381}
9382
9383template<typename Derived>
9386 NestedNameSpecifierLoc QualifierLoc;
9387 if (E->getQualifierLoc()) {
9388 QualifierLoc
9389 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9390 if (!QualifierLoc)
9391 return ExprError();
9392 }
9393
9394 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9395 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9396 if (!PD)
9397 return ExprError();
9398
9399 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9400 if (Base.isInvalid())
9401 return ExprError();
9402
9403 return new (SemaRef.getASTContext())
9404 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9406 QualifierLoc, E->getMemberLoc());
9407}
9408
9409template <typename Derived>
9412 auto BaseRes = getDerived().TransformExpr(E->getBase());
9413 if (BaseRes.isInvalid())
9414 return ExprError();
9415 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9416 if (IdxRes.isInvalid())
9417 return ExprError();
9418
9419 if (!getDerived().AlwaysRebuild() &&
9420 BaseRes.get() == E->getBase() &&
9421 IdxRes.get() == E->getIdx())
9422 return E;
9423
9424 return getDerived().RebuildArraySubscriptExpr(
9425 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9426}
9427
9428template <typename Derived>
9430 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9431 if (TryBlock.isInvalid())
9432 return StmtError();
9433
9434 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9435 if (Handler.isInvalid())
9436 return StmtError();
9437
9438 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9439 Handler.get() == S->getHandler())
9440 return S;
9441
9442 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9443 TryBlock.get(), Handler.get());
9444}
9445
9446template <typename Derived>
9448 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9449 if (Block.isInvalid())
9450 return StmtError();
9451
9452 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9453}
9454
9455template <typename Derived>
9457 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9458 if (FilterExpr.isInvalid())
9459 return StmtError();
9460
9461 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9462 if (Block.isInvalid())
9463 return StmtError();
9464
9465 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9466 Block.get());
9467}
9468
9469template <typename Derived>
9471 if (isa<SEHFinallyStmt>(Handler))
9472 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9473 else
9474 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9475}
9476
9477template<typename Derived>
9480 return S;
9481}
9482
9483//===----------------------------------------------------------------------===//
9484// OpenMP directive transformation
9485//===----------------------------------------------------------------------===//
9486
9487template <typename Derived>
9488StmtResult
9489TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9490 // OMPCanonicalLoops are eliminated during transformation, since they will be
9491 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9492 // after transformation.
9493 return getDerived().TransformStmt(L->getLoopStmt());
9494}
9495
9496template <typename Derived>
9499
9500 // Transform the clauses
9502 ArrayRef<OMPClause *> Clauses = D->clauses();
9503 TClauses.reserve(Clauses.size());
9504 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9505 I != E; ++I) {
9506 if (*I) {
9507 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9508 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9509 getDerived().getSema().OpenMP().EndOpenMPClause();
9510 if (Clause)
9511 TClauses.push_back(Clause);
9512 } else {
9513 TClauses.push_back(nullptr);
9514 }
9515 }
9516 StmtResult AssociatedStmt;
9517 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9518 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9519 D->getDirectiveKind(),
9520 /*CurScope=*/nullptr);
9521 StmtResult Body;
9522 {
9523 Sema::CompoundScopeRAII CompoundScope(getSema());
9524 Stmt *CS;
9525 if (D->getDirectiveKind() == OMPD_atomic ||
9526 D->getDirectiveKind() == OMPD_critical ||
9527 D->getDirectiveKind() == OMPD_section ||
9528 D->getDirectiveKind() == OMPD_master)
9529 CS = D->getAssociatedStmt();
9530 else
9531 CS = D->getRawStmt();
9532 Body = getDerived().TransformStmt(CS);
9533 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9534 getSema().getLangOpts().OpenMPIRBuilder)
9535 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9536 }
9537 AssociatedStmt =
9538 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9539 if (AssociatedStmt.isInvalid()) {
9540 return StmtError();
9541 }
9542 }
9543 if (TClauses.size() != Clauses.size()) {
9544 return StmtError();
9545 }
9546
9547 // Transform directive name for 'omp critical' directive.
9548 DeclarationNameInfo DirName;
9549 if (D->getDirectiveKind() == OMPD_critical) {
9550 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9551 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9552 }
9553 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9554 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9555 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9556 } else if (D->getDirectiveKind() == OMPD_cancel) {
9557 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9558 }
9559
9560 return getDerived().RebuildOMPExecutableDirective(
9561 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9562 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
9563}
9564
9565/// This is mostly the same as above, but allows 'informational' class
9566/// directives when rebuilding the stmt. It still takes an
9567/// OMPExecutableDirective-type argument because we're reusing that as the
9568/// superclass for the 'assume' directive at present, instead of defining a
9569/// mostly-identical OMPInformationalDirective parent class.
9570template <typename Derived>
9573
9574 // Transform the clauses
9576 ArrayRef<OMPClause *> Clauses = D->clauses();
9577 TClauses.reserve(Clauses.size());
9578 for (OMPClause *C : Clauses) {
9579 if (C) {
9580 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
9581 OMPClause *Clause = getDerived().TransformOMPClause(C);
9582 getDerived().getSema().OpenMP().EndOpenMPClause();
9583 if (Clause)
9584 TClauses.push_back(Clause);
9585 } else {
9586 TClauses.push_back(nullptr);
9587 }
9588 }
9589 StmtResult AssociatedStmt;
9590 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9591 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9592 D->getDirectiveKind(),
9593 /*CurScope=*/nullptr);
9594 StmtResult Body;
9595 {
9596 Sema::CompoundScopeRAII CompoundScope(getSema());
9597 assert(D->getDirectiveKind() == OMPD_assume &&
9598 "Unexpected informational directive");
9599 Stmt *CS = D->getAssociatedStmt();
9600 Body = getDerived().TransformStmt(CS);
9601 }
9602 AssociatedStmt =
9603 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9604 if (AssociatedStmt.isInvalid())
9605 return StmtError();
9606 }
9607 if (TClauses.size() != Clauses.size())
9608 return StmtError();
9609
9610 DeclarationNameInfo DirName;
9611
9612 return getDerived().RebuildOMPInformationalDirective(
9613 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
9614 D->getBeginLoc(), D->getEndLoc());
9615}
9616
9617template <typename Derived>
9620 // TODO: Fix This
9621 unsigned OMPVersion = getDerived().getSema().getLangOpts().OpenMP;
9622 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9623 << getOpenMPDirectiveName(D->getDirectiveKind(), OMPVersion);
9624 return StmtError();
9625}
9626
9627template <typename Derived>
9628StmtResult
9629TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9630 DeclarationNameInfo DirName;
9631 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9632 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
9633 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9634 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9635 return Res;
9636}
9637
9638template <typename Derived>
9641 DeclarationNameInfo DirName;
9642 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9643 OMPD_simd, DirName, nullptr, D->getBeginLoc());
9644 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9645 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9646 return Res;
9647}
9648
9649template <typename Derived>
9652 DeclarationNameInfo DirName;
9653 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9654 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9655 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9656 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9657 return Res;
9658}
9659
9660template <typename Derived>
9663 DeclarationNameInfo DirName;
9664 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9665 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9666 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9667 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9668 return Res;
9669}
9670
9671template <typename Derived>
9674 DeclarationNameInfo DirName;
9675 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9676 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9677 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9678 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9679 return Res;
9680}
9681
9682template <typename Derived>
9685 DeclarationNameInfo DirName;
9686 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9687 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9688 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9689 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9690 return Res;
9691}
9692
9693template <typename Derived>
9695 OMPInterchangeDirective *D) {
9696 DeclarationNameInfo DirName;
9697 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9698 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9699 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9700 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9701 return Res;
9702}
9703
9704template <typename Derived>
9707 DeclarationNameInfo DirName;
9708 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9709 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9710 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9711 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9712 return Res;
9713}
9714
9715template <typename Derived>
9718 DeclarationNameInfo DirName;
9719 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9720 OMPD_for, DirName, nullptr, D->getBeginLoc());
9721 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9722 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9723 return Res;
9724}
9725
9726template <typename Derived>
9729 DeclarationNameInfo DirName;
9730 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9731 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
9732 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9733 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9734 return Res;
9735}
9736
9737template <typename Derived>
9740 DeclarationNameInfo DirName;
9741 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9742 OMPD_sections, DirName, nullptr, D->getBeginLoc());
9743 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9744 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9745 return Res;
9746}
9747
9748template <typename Derived>
9751 DeclarationNameInfo DirName;
9752 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9753 OMPD_section, DirName, nullptr, D->getBeginLoc());
9754 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9755 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9756 return Res;
9757}
9758
9759template <typename Derived>
9762 DeclarationNameInfo DirName;
9763 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9764 OMPD_scope, DirName, nullptr, D->getBeginLoc());
9765 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9766 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9767 return Res;
9768}
9769
9770template <typename Derived>
9773 DeclarationNameInfo DirName;
9774 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9775 OMPD_single, DirName, nullptr, D->getBeginLoc());
9776 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9777 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9778 return Res;
9779}
9780
9781template <typename Derived>
9784 DeclarationNameInfo DirName;
9785 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9786 OMPD_master, DirName, nullptr, D->getBeginLoc());
9787 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9788 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9789 return Res;
9790}
9791
9792template <typename Derived>
9795 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9796 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
9797 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9798 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9799 return Res;
9800}
9801
9802template <typename Derived>
9804 OMPParallelForDirective *D) {
9805 DeclarationNameInfo DirName;
9806 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9807 OMPD_parallel_for, DirName, nullptr, D->getBeginLoc());
9808 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9809 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9810 return Res;
9811}
9812
9813template <typename Derived>
9815 OMPParallelForSimdDirective *D) {
9816 DeclarationNameInfo DirName;
9817 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9818 OMPD_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9819 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9820 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9821 return Res;
9822}
9823
9824template <typename Derived>
9826 OMPParallelMasterDirective *D) {
9827 DeclarationNameInfo DirName;
9828 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9829 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
9830 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9831 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9832 return Res;
9833}
9834
9835template <typename Derived>
9837 OMPParallelMaskedDirective *D) {
9838 DeclarationNameInfo DirName;
9839 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9840 OMPD_parallel_masked, DirName, nullptr, D->getBeginLoc());
9841 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9842 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9843 return Res;
9844}
9845
9846template <typename Derived>
9848 OMPParallelSectionsDirective *D) {
9849 DeclarationNameInfo DirName;
9850 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9851 OMPD_parallel_sections, DirName, nullptr, D->getBeginLoc());
9852 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9853 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9854 return Res;
9855}
9856
9857template <typename Derived>
9860 DeclarationNameInfo DirName;
9861 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9862 OMPD_task, DirName, nullptr, D->getBeginLoc());
9863 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9864 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9865 return Res;
9866}
9867
9868template <typename Derived>
9870 OMPTaskyieldDirective *D) {
9871 DeclarationNameInfo DirName;
9872 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9873 OMPD_taskyield, DirName, nullptr, D->getBeginLoc());
9874 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9875 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9876 return Res;
9877}
9878
9879template <typename Derived>
9882 DeclarationNameInfo DirName;
9883 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9884 OMPD_barrier, DirName, nullptr, D->getBeginLoc());
9885 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9886 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9887 return Res;
9888}
9889
9890template <typename Derived>
9893 DeclarationNameInfo DirName;
9894 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9895 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
9896 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9897 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9898 return Res;
9899}
9900
9901template <typename Derived>
9904 DeclarationNameInfo DirName;
9905 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9906 OMPD_assume, DirName, nullptr, D->getBeginLoc());
9907 StmtResult Res = getDerived().TransformOMPInformationalDirective(D);
9908 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9909 return Res;
9910}
9911
9912template <typename Derived>
9915 DeclarationNameInfo DirName;
9916 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9917 OMPD_error, DirName, nullptr, D->getBeginLoc());
9918 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9919 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9920 return Res;
9921}
9922
9923template <typename Derived>
9925 OMPTaskgroupDirective *D) {
9926 DeclarationNameInfo DirName;
9927 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9928 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
9929 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9930 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9931 return Res;
9932}
9933
9934template <typename Derived>
9937 DeclarationNameInfo DirName;
9938 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9939 OMPD_flush, DirName, nullptr, D->getBeginLoc());
9940 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9941 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9942 return Res;
9943}
9944
9945template <typename Derived>
9948 DeclarationNameInfo DirName;
9949 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9950 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
9951 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9952 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9953 return Res;
9954}
9955
9956template <typename Derived>
9959 DeclarationNameInfo DirName;
9960 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9961 OMPD_scan, DirName, nullptr, D->getBeginLoc());
9962 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9963 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9964 return Res;
9965}
9966
9967template <typename Derived>
9970 DeclarationNameInfo DirName;
9971 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9972 OMPD_ordered, DirName, nullptr, D->getBeginLoc());
9973 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9974 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9975 return Res;
9976}
9977
9978template <typename Derived>
9981 DeclarationNameInfo DirName;
9982 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9983 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
9984 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9985 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9986 return Res;
9987}
9988
9989template <typename Derived>
9992 DeclarationNameInfo DirName;
9993 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9994 OMPD_target, DirName, nullptr, D->getBeginLoc());
9995 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9996 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9997 return Res;
9998}
9999
10000template <typename Derived>
10002 OMPTargetDataDirective *D) {
10003 DeclarationNameInfo DirName;
10004 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10005 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
10006 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10007 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10008 return Res;
10009}
10010
10011template <typename Derived>
10013 OMPTargetEnterDataDirective *D) {
10014 DeclarationNameInfo DirName;
10015 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10016 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
10017 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10018 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10019 return Res;
10020}
10021
10022template <typename Derived>
10024 OMPTargetExitDataDirective *D) {
10025 DeclarationNameInfo DirName;
10026 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10027 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
10028 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10029 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10030 return Res;
10031}
10032
10033template <typename Derived>
10035 OMPTargetParallelDirective *D) {
10036 DeclarationNameInfo DirName;
10037 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10038 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
10039 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10040 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10041 return Res;
10042}
10043
10044template <typename Derived>
10046 OMPTargetParallelForDirective *D) {
10047 DeclarationNameInfo DirName;
10048 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10049 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
10050 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10051 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10052 return Res;
10053}
10054
10055template <typename Derived>
10057 OMPTargetUpdateDirective *D) {
10058 DeclarationNameInfo DirName;
10059 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10060 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
10061 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10062 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10063 return Res;
10064}
10065
10066template <typename Derived>
10069 DeclarationNameInfo DirName;
10070 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10071 OMPD_teams, DirName, nullptr, D->getBeginLoc());
10072 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10073 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10074 return Res;
10075}
10076
10077template <typename Derived>
10079 OMPCancellationPointDirective *D) {
10080 DeclarationNameInfo DirName;
10081 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10082 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
10083 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10084 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10085 return Res;
10086}
10087
10088template <typename Derived>
10091 DeclarationNameInfo DirName;
10092 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10093 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
10094 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10095 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10096 return Res;
10097}
10098
10099template <typename Derived>
10102 DeclarationNameInfo DirName;
10103 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10104 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
10105 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10106 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10107 return Res;
10108}
10109
10110template <typename Derived>
10112 OMPTaskLoopSimdDirective *D) {
10113 DeclarationNameInfo DirName;
10114 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10115 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10116 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10117 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10118 return Res;
10119}
10120
10121template <typename Derived>
10123 OMPMasterTaskLoopDirective *D) {
10124 DeclarationNameInfo DirName;
10125 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10126 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
10127 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10128 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10129 return Res;
10130}
10131
10132template <typename Derived>
10134 OMPMaskedTaskLoopDirective *D) {
10135 DeclarationNameInfo DirName;
10136 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10137 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10138 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10139 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10140 return Res;
10141}
10142
10143template <typename Derived>
10145 OMPMasterTaskLoopSimdDirective *D) {
10146 DeclarationNameInfo DirName;
10147 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10148 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10149 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10150 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10151 return Res;
10152}
10153
10154template <typename Derived>
10156 OMPMaskedTaskLoopSimdDirective *D) {
10157 DeclarationNameInfo DirName;
10158 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10159 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10160 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10161 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10162 return Res;
10163}
10164
10165template <typename Derived>
10167 OMPParallelMasterTaskLoopDirective *D) {
10168 DeclarationNameInfo DirName;
10169 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10170 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10171 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10172 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10173 return Res;
10174}
10175
10176template <typename Derived>
10178 OMPParallelMaskedTaskLoopDirective *D) {
10179 DeclarationNameInfo DirName;
10180 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10181 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10182 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10183 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10184 return Res;
10185}
10186
10187template <typename Derived>
10190 OMPParallelMasterTaskLoopSimdDirective *D) {
10191 DeclarationNameInfo DirName;
10192 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10193 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10194 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10195 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10196 return Res;
10197}
10198
10199template <typename Derived>
10202 OMPParallelMaskedTaskLoopSimdDirective *D) {
10203 DeclarationNameInfo DirName;
10204 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10205 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10206 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10207 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10208 return Res;
10209}
10210
10211template <typename Derived>
10213 OMPDistributeDirective *D) {
10214 DeclarationNameInfo DirName;
10215 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10216 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10217 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10218 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10219 return Res;
10220}
10221
10222template <typename Derived>
10224 OMPDistributeParallelForDirective *D) {
10225 DeclarationNameInfo DirName;
10226 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10227 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10228 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10229 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10230 return Res;
10231}
10232
10233template <typename Derived>
10236 OMPDistributeParallelForSimdDirective *D) {
10237 DeclarationNameInfo DirName;
10238 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10239 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10240 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10241 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10242 return Res;
10243}
10244
10245template <typename Derived>
10247 OMPDistributeSimdDirective *D) {
10248 DeclarationNameInfo DirName;
10249 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10250 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
10251 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10252 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10253 return Res;
10254}
10255
10256template <typename Derived>
10258 OMPTargetParallelForSimdDirective *D) {
10259 DeclarationNameInfo DirName;
10260 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10261 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10262 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10263 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10264 return Res;
10265}
10266
10267template <typename Derived>
10269 OMPTargetSimdDirective *D) {
10270 DeclarationNameInfo DirName;
10271 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10272 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
10273 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10274 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10275 return Res;
10276}
10277
10278template <typename Derived>
10280 OMPTeamsDistributeDirective *D) {
10281 DeclarationNameInfo DirName;
10282 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10283 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10284 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10285 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10286 return Res;
10287}
10288
10289template <typename Derived>
10291 OMPTeamsDistributeSimdDirective *D) {
10292 DeclarationNameInfo DirName;
10293 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10294 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10295 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10296 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10297 return Res;
10298}
10299
10300template <typename Derived>
10302 OMPTeamsDistributeParallelForSimdDirective *D) {
10303 DeclarationNameInfo DirName;
10304 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10305 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10306 D->getBeginLoc());
10307 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10308 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10309 return Res;
10310}
10311
10312template <typename Derived>
10314 OMPTeamsDistributeParallelForDirective *D) {
10315 DeclarationNameInfo DirName;
10316 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10317 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10318 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10319 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10320 return Res;
10321}
10322
10323template <typename Derived>
10325 OMPTargetTeamsDirective *D) {
10326 DeclarationNameInfo DirName;
10327 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10328 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10329 auto Res = getDerived().TransformOMPExecutableDirective(D);
10330 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10331 return Res;
10332}
10333
10334template <typename Derived>
10336 OMPTargetTeamsDistributeDirective *D) {
10337 DeclarationNameInfo DirName;
10338 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10339 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10340 auto Res = getDerived().TransformOMPExecutableDirective(D);
10341 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10342 return Res;
10343}
10344
10345template <typename Derived>
10348 OMPTargetTeamsDistributeParallelForDirective *D) {
10349 DeclarationNameInfo DirName;
10350 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10351 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10352 D->getBeginLoc());
10353 auto Res = getDerived().TransformOMPExecutableDirective(D);
10354 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10355 return Res;
10356}
10357
10358template <typename Derived>
10361 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10362 DeclarationNameInfo DirName;
10363 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10364 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10365 D->getBeginLoc());
10366 auto Res = getDerived().TransformOMPExecutableDirective(D);
10367 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10368 return Res;
10369}
10370
10371template <typename Derived>
10374 OMPTargetTeamsDistributeSimdDirective *D) {
10375 DeclarationNameInfo DirName;
10376 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10377 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10378 auto Res = getDerived().TransformOMPExecutableDirective(D);
10379 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10380 return Res;
10381}
10382
10383template <typename Derived>
10386 DeclarationNameInfo DirName;
10387 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10388 OMPD_interop, DirName, nullptr, D->getBeginLoc());
10389 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10390 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10391 return Res;
10392}
10393
10394template <typename Derived>
10397 DeclarationNameInfo DirName;
10398 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10399 OMPD_dispatch, DirName, nullptr, D->getBeginLoc());
10400 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10401 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10402 return Res;
10403}
10404
10405template <typename Derived>
10408 DeclarationNameInfo DirName;
10409 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10410 OMPD_masked, DirName, nullptr, D->getBeginLoc());
10411 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10412 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10413 return Res;
10414}
10415
10416template <typename Derived>
10418 OMPGenericLoopDirective *D) {
10419 DeclarationNameInfo DirName;
10420 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10421 OMPD_loop, DirName, nullptr, D->getBeginLoc());
10422 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10423 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10424 return Res;
10425}
10426
10427template <typename Derived>
10429 OMPTeamsGenericLoopDirective *D) {
10430 DeclarationNameInfo DirName;
10431 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10432 OMPD_teams_loop, DirName, nullptr, D->getBeginLoc());
10433 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10434 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10435 return Res;
10436}
10437
10438template <typename Derived>
10440 OMPTargetTeamsGenericLoopDirective *D) {
10441 DeclarationNameInfo DirName;
10442 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10443 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
10444 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10445 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10446 return Res;
10447}
10448
10449template <typename Derived>
10451 OMPParallelGenericLoopDirective *D) {
10452 DeclarationNameInfo DirName;
10453 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10454 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
10455 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10456 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10457 return Res;
10458}
10459
10460template <typename Derived>
10463 OMPTargetParallelGenericLoopDirective *D) {
10464 DeclarationNameInfo DirName;
10465 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10466 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10467 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10468 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10469 return Res;
10470}
10471
10472//===----------------------------------------------------------------------===//
10473// OpenMP clause transformation
10474//===----------------------------------------------------------------------===//
10475template <typename Derived>
10477 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10478 if (Cond.isInvalid())
10479 return nullptr;
10480 return getDerived().RebuildOMPIfClause(
10481 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10482 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10483}
10484
10485template <typename Derived>
10487 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10488 if (Cond.isInvalid())
10489 return nullptr;
10490 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10491 C->getLParenLoc(), C->getEndLoc());
10492}
10493
10494template <typename Derived>
10495OMPClause *
10497 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
10498 if (NumThreads.isInvalid())
10499 return nullptr;
10500 return getDerived().RebuildOMPNumThreadsClause(
10501 C->getModifier(), NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(),
10502 C->getModifierLoc(), C->getEndLoc());
10503}
10504
10505template <typename Derived>
10506OMPClause *
10508 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10509 if (E.isInvalid())
10510 return nullptr;
10511 return getDerived().RebuildOMPSafelenClause(
10512 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10513}
10514
10515template <typename Derived>
10516OMPClause *
10518 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10519 if (E.isInvalid())
10520 return nullptr;
10521 return getDerived().RebuildOMPAllocatorClause(
10522 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10523}
10524
10525template <typename Derived>
10526OMPClause *
10528 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
10529 if (E.isInvalid())
10530 return nullptr;
10531 return getDerived().RebuildOMPSimdlenClause(
10532 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10533}
10534
10535template <typename Derived>
10537 SmallVector<Expr *, 4> TransformedSizes;
10538 TransformedSizes.reserve(C->getNumSizes());
10539 bool Changed = false;
10540 for (Expr *E : C->getSizesRefs()) {
10541 if (!E) {
10542 TransformedSizes.push_back(nullptr);
10543 continue;
10544 }
10545
10546 ExprResult T = getDerived().TransformExpr(E);
10547 if (T.isInvalid())
10548 return nullptr;
10549 if (E != T.get())
10550 Changed = true;
10551 TransformedSizes.push_back(T.get());
10552 }
10553
10554 if (!Changed && !getDerived().AlwaysRebuild())
10555 return C;
10556 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
10557 C->getLParenLoc(), C->getEndLoc());
10558}
10559
10560template <typename Derived>
10561OMPClause *
10563 SmallVector<Expr *> TransformedArgs;
10564 TransformedArgs.reserve(C->getNumLoops());
10565 bool Changed = false;
10566 for (Expr *E : C->getArgsRefs()) {
10567 if (!E) {
10568 TransformedArgs.push_back(nullptr);
10569 continue;
10570 }
10571
10572 ExprResult T = getDerived().TransformExpr(E);
10573 if (T.isInvalid())
10574 return nullptr;
10575 if (E != T.get())
10576 Changed = true;
10577 TransformedArgs.push_back(T.get());
10578 }
10579
10580 if (!Changed && !getDerived().AlwaysRebuild())
10581 return C;
10582 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
10583 C->getLParenLoc(), C->getEndLoc());
10584}
10585
10586template <typename Derived>
10588 if (!getDerived().AlwaysRebuild())
10589 return C;
10590 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10591}
10592
10593template <typename Derived>
10594OMPClause *
10596 ExprResult T = getDerived().TransformExpr(C->getFactor());
10597 if (T.isInvalid())
10598 return nullptr;
10599 Expr *Factor = T.get();
10600 bool Changed = Factor != C->getFactor();
10601
10602 if (!Changed && !getDerived().AlwaysRebuild())
10603 return C;
10604 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10605 C->getEndLoc());
10606}
10607
10608template <typename Derived>
10609OMPClause *
10611 ExprResult F = getDerived().TransformExpr(C->getFirst());
10612 if (F.isInvalid())
10613 return nullptr;
10614
10615 ExprResult Cn = getDerived().TransformExpr(C->getCount());
10616 if (Cn.isInvalid())
10617 return nullptr;
10618
10619 Expr *First = F.get();
10620 Expr *Count = Cn.get();
10621
10622 bool Changed = (First != C->getFirst()) || (Count != C->getCount());
10623
10624 // If no changes and AlwaysRebuild() is false, return the original clause
10625 if (!Changed && !getDerived().AlwaysRebuild())
10626 return C;
10627
10628 return RebuildOMPLoopRangeClause(First, Count, C->getBeginLoc(),
10629 C->getLParenLoc(), C->getFirstLoc(),
10630 C->getCountLoc(), C->getEndLoc());
10631}
10632
10633template <typename Derived>
10634OMPClause *
10636 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10637 if (E.isInvalid())
10638 return nullptr;
10639 return getDerived().RebuildOMPCollapseClause(
10640 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10641}
10642
10643template <typename Derived>
10644OMPClause *
10646 return getDerived().RebuildOMPDefaultClause(
10647 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getDefaultVC(),
10648 C->getDefaultVCLoc(), C->getBeginLoc(), C->getLParenLoc(),
10649 C->getEndLoc());
10650}
10651
10652template <typename Derived>
10653OMPClause *
10655 // No need to rebuild this clause, no template-dependent parameters.
10656 return C;
10657}
10658
10659template <typename Derived>
10660OMPClause *
10662 return getDerived().RebuildOMPProcBindClause(
10663 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10664 C->getLParenLoc(), C->getEndLoc());
10665}
10666
10667template <typename Derived>
10668OMPClause *
10670 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10671 if (E.isInvalid())
10672 return nullptr;
10673 return getDerived().RebuildOMPScheduleClause(
10674 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10675 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10676 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10677 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10678}
10679
10680template <typename Derived>
10681OMPClause *
10683 ExprResult E;
10684 if (auto *Num = C->getNumForLoops()) {
10685 E = getDerived().TransformExpr(Num);
10686 if (E.isInvalid())
10687 return nullptr;
10688 }
10689 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10690 C->getLParenLoc(), E.get());
10691}
10692
10693template <typename Derived>
10694OMPClause *
10696 ExprResult E;
10697 if (Expr *Evt = C->getEventHandler()) {
10698 E = getDerived().TransformExpr(Evt);
10699 if (E.isInvalid())
10700 return nullptr;
10701 }
10702 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10703 C->getLParenLoc(), C->getEndLoc());
10704}
10705
10706template <typename Derived>
10707OMPClause *
10710 if (auto *Condition = C->getCondition()) {
10711 Cond = getDerived().TransformExpr(Condition);
10712 if (Cond.isInvalid())
10713 return nullptr;
10714 }
10715 return getDerived().RebuildOMPNowaitClause(Cond.get(), C->getBeginLoc(),
10716 C->getLParenLoc(), C->getEndLoc());
10717}
10718
10719template <typename Derived>
10720OMPClause *
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>
10735 // No need to rebuild this clause, no template-dependent parameters.
10736 return C;
10737}
10738
10739template <typename Derived>
10741 // No need to rebuild this clause, no template-dependent parameters.
10742 return C;
10743}
10744
10745template <typename Derived>
10746OMPClause *
10748 // No need to rebuild this clause, no template-dependent parameters.
10749 return C;
10750}
10751
10752template <typename Derived>
10753OMPClause *
10755 // No need to rebuild this clause, no template-dependent parameters.
10756 return C;
10757}
10758
10759template <typename Derived>
10760OMPClause *
10762 // No need to rebuild this clause, no template-dependent parameters.
10763 return C;
10764}
10765
10766template <typename Derived>
10768 // No need to rebuild this clause, no template-dependent parameters.
10769 return C;
10770}
10771
10772template <typename Derived>
10773OMPClause *
10775 return C;
10776}
10777
10778template <typename Derived>
10780 ExprResult E = getDerived().TransformExpr(C->getExpr());
10781 if (E.isInvalid())
10782 return nullptr;
10783 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
10784 C->getLParenLoc(), C->getEndLoc());
10785}
10786
10787template <typename Derived>
10788OMPClause *
10790 return C;
10791}
10792
10793template <typename Derived>
10794OMPClause *
10796 return C;
10797}
10798template <typename Derived>
10801 return C;
10802}
10803template <typename Derived>
10806 return C;
10807}
10808template <typename Derived>
10811 return C;
10812}
10813
10814template <typename Derived>
10815OMPClause *
10817 // No need to rebuild this clause, no template-dependent parameters.
10818 return C;
10819}
10820
10821template <typename Derived>
10822OMPClause *
10824 // No need to rebuild this clause, no template-dependent parameters.
10825 return C;
10826}
10827
10828template <typename Derived>
10829OMPClause *
10831 // No need to rebuild this clause, no template-dependent parameters.
10832 return C;
10833}
10834
10835template <typename Derived>
10836OMPClause *
10838 // No need to rebuild this clause, no template-dependent parameters.
10839 return C;
10840}
10841
10842template <typename Derived>
10843OMPClause *
10845 // No need to rebuild this clause, no template-dependent parameters.
10846 return C;
10847}
10848
10849template <typename Derived>
10851 // No need to rebuild this clause, no template-dependent parameters.
10852 return C;
10853}
10854
10855template <typename Derived>
10856OMPClause *
10858 // No need to rebuild this clause, no template-dependent parameters.
10859 return C;
10860}
10861
10862template <typename Derived>
10864 // No need to rebuild this clause, no template-dependent parameters.
10865 return C;
10866}
10867
10868template <typename Derived>
10869OMPClause *
10871 // No need to rebuild this clause, no template-dependent parameters.
10872 return C;
10873}
10874
10875template <typename Derived>
10877 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
10878 if (IVR.isInvalid())
10879 return nullptr;
10880
10881 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
10882 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
10883 for (Expr *E : llvm::drop_begin(C->varlist())) {
10884 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
10885 if (ER.isInvalid())
10886 return nullptr;
10887 InteropInfo.PreferTypes.push_back(ER.get());
10888 }
10889 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
10890 C->getBeginLoc(), C->getLParenLoc(),
10891 C->getVarLoc(), C->getEndLoc());
10892}
10893
10894template <typename Derived>
10896 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
10897 if (ER.isInvalid())
10898 return nullptr;
10899 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
10900 C->getLParenLoc(), C->getVarLoc(),
10901 C->getEndLoc());
10902}
10903
10904template <typename Derived>
10905OMPClause *
10907 ExprResult ER;
10908 if (Expr *IV = C->getInteropVar()) {
10909 ER = getDerived().TransformExpr(IV);
10910 if (ER.isInvalid())
10911 return nullptr;
10912 }
10913 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
10914 C->getLParenLoc(), C->getVarLoc(),
10915 C->getEndLoc());
10916}
10917
10918template <typename Derived>
10919OMPClause *
10921 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10922 if (Cond.isInvalid())
10923 return nullptr;
10924 return getDerived().RebuildOMPNovariantsClause(
10925 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10926}
10927
10928template <typename Derived>
10929OMPClause *
10931 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10932 if (Cond.isInvalid())
10933 return nullptr;
10934 return getDerived().RebuildOMPNocontextClause(
10935 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10936}
10937
10938template <typename Derived>
10939OMPClause *
10941 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
10942 if (ThreadID.isInvalid())
10943 return nullptr;
10944 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
10945 C->getLParenLoc(), C->getEndLoc());
10946}
10947
10948template <typename Derived>
10950 ExprResult E = getDerived().TransformExpr(C->getAlignment());
10951 if (E.isInvalid())
10952 return nullptr;
10953 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
10954 C->getLParenLoc(), C->getEndLoc());
10955}
10956
10957template <typename Derived>
10960 llvm_unreachable("unified_address clause cannot appear in dependent context");
10961}
10962
10963template <typename Derived>
10966 llvm_unreachable(
10967 "unified_shared_memory clause cannot appear in dependent context");
10968}
10969
10970template <typename Derived>
10973 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
10974}
10975
10976template <typename Derived>
10979 llvm_unreachable(
10980 "dynamic_allocators clause cannot appear in dependent context");
10981}
10982
10983template <typename Derived>
10986 llvm_unreachable(
10987 "atomic_default_mem_order clause cannot appear in dependent context");
10988}
10989
10990template <typename Derived>
10991OMPClause *
10993 llvm_unreachable("self_maps clause cannot appear in dependent context");
10994}
10995
10996template <typename Derived>
10998 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
10999 C->getBeginLoc(), C->getLParenLoc(),
11000 C->getEndLoc());
11001}
11002
11003template <typename Derived>
11004OMPClause *
11006 return getDerived().RebuildOMPSeverityClause(
11007 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
11008 C->getLParenLoc(), C->getEndLoc());
11009}
11010
11011template <typename Derived>
11012OMPClause *
11014 ExprResult E = getDerived().TransformExpr(C->getMessageString());
11015 if (E.isInvalid())
11016 return nullptr;
11017 return getDerived().RebuildOMPMessageClause(
11018 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11019}
11020
11021template <typename Derived>
11022OMPClause *
11025 Vars.reserve(C->varlist_size());
11026 for (auto *VE : C->varlist()) {
11027 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11028 if (EVar.isInvalid())
11029 return nullptr;
11030 Vars.push_back(EVar.get());
11031 }
11032 return getDerived().RebuildOMPPrivateClause(
11033 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11034}
11035
11036template <typename Derived>
11040 Vars.reserve(C->varlist_size());
11041 for (auto *VE : C->varlist()) {
11042 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11043 if (EVar.isInvalid())
11044 return nullptr;
11045 Vars.push_back(EVar.get());
11046 }
11047 return getDerived().RebuildOMPFirstprivateClause(
11048 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11049}
11050
11051template <typename Derived>
11052OMPClause *
11055 Vars.reserve(C->varlist_size());
11056 for (auto *VE : C->varlist()) {
11057 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11058 if (EVar.isInvalid())
11059 return nullptr;
11060 Vars.push_back(EVar.get());
11061 }
11062 return getDerived().RebuildOMPLastprivateClause(
11063 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11064 C->getLParenLoc(), C->getEndLoc());
11065}
11066
11067template <typename Derived>
11068OMPClause *
11071 Vars.reserve(C->varlist_size());
11072 for (auto *VE : C->varlist()) {
11073 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11074 if (EVar.isInvalid())
11075 return nullptr;
11076 Vars.push_back(EVar.get());
11077 }
11078 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11079 C->getLParenLoc(), C->getEndLoc());
11080}
11081
11082template <typename Derived>
11083OMPClause *
11086 Vars.reserve(C->varlist_size());
11087 for (auto *VE : C->varlist()) {
11088 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11089 if (EVar.isInvalid())
11090 return nullptr;
11091 Vars.push_back(EVar.get());
11092 }
11093 CXXScopeSpec ReductionIdScopeSpec;
11094 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11095
11096 DeclarationNameInfo NameInfo = C->getNameInfo();
11097 if (NameInfo.getName()) {
11098 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11099 if (!NameInfo.getName())
11100 return nullptr;
11101 }
11102 // Build a list of all UDR decls with the same names ranged by the Scopes.
11103 // The Scope boundary is a duplication of the previous decl.
11104 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11105 for (auto *E : C->reduction_ops()) {
11106 // Transform all the decls.
11107 if (E) {
11108 auto *ULE = cast<UnresolvedLookupExpr>(E);
11109 UnresolvedSet<8> Decls;
11110 for (auto *D : ULE->decls()) {
11111 NamedDecl *InstD =
11112 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11113 Decls.addDecl(InstD, InstD->getAccess());
11114 }
11115 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11116 SemaRef.Context, /*NamingClass=*/nullptr,
11117 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11118 /*ADL=*/true, Decls.begin(), Decls.end(),
11119 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11120 } else
11121 UnresolvedReductions.push_back(nullptr);
11122 }
11123 return getDerived().RebuildOMPReductionClause(
11124 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11125 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11126 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11127}
11128
11129template <typename Derived>
11133 Vars.reserve(C->varlist_size());
11134 for (auto *VE : C->varlist()) {
11135 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11136 if (EVar.isInvalid())
11137 return nullptr;
11138 Vars.push_back(EVar.get());
11139 }
11140 CXXScopeSpec ReductionIdScopeSpec;
11141 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11142
11143 DeclarationNameInfo NameInfo = C->getNameInfo();
11144 if (NameInfo.getName()) {
11145 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11146 if (!NameInfo.getName())
11147 return nullptr;
11148 }
11149 // Build a list of all UDR decls with the same names ranged by the Scopes.
11150 // The Scope boundary is a duplication of the previous decl.
11151 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11152 for (auto *E : C->reduction_ops()) {
11153 // Transform all the decls.
11154 if (E) {
11155 auto *ULE = cast<UnresolvedLookupExpr>(E);
11156 UnresolvedSet<8> Decls;
11157 for (auto *D : ULE->decls()) {
11158 NamedDecl *InstD =
11159 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11160 Decls.addDecl(InstD, InstD->getAccess());
11161 }
11162 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11163 SemaRef.Context, /*NamingClass=*/nullptr,
11164 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11165 /*ADL=*/true, Decls.begin(), Decls.end(),
11166 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11167 } else
11168 UnresolvedReductions.push_back(nullptr);
11169 }
11170 return getDerived().RebuildOMPTaskReductionClause(
11171 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11172 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11173}
11174
11175template <typename Derived>
11176OMPClause *
11179 Vars.reserve(C->varlist_size());
11180 for (auto *VE : C->varlist()) {
11181 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11182 if (EVar.isInvalid())
11183 return nullptr;
11184 Vars.push_back(EVar.get());
11185 }
11186 CXXScopeSpec ReductionIdScopeSpec;
11187 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11188
11189 DeclarationNameInfo NameInfo = C->getNameInfo();
11190 if (NameInfo.getName()) {
11191 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11192 if (!NameInfo.getName())
11193 return nullptr;
11194 }
11195 // Build a list of all UDR decls with the same names ranged by the Scopes.
11196 // The Scope boundary is a duplication of the previous decl.
11197 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11198 for (auto *E : C->reduction_ops()) {
11199 // Transform all the decls.
11200 if (E) {
11201 auto *ULE = cast<UnresolvedLookupExpr>(E);
11202 UnresolvedSet<8> Decls;
11203 for (auto *D : ULE->decls()) {
11204 NamedDecl *InstD =
11205 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11206 Decls.addDecl(InstD, InstD->getAccess());
11207 }
11208 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11209 SemaRef.Context, /*NamingClass=*/nullptr,
11210 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11211 /*ADL=*/true, Decls.begin(), Decls.end(),
11212 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11213 } else
11214 UnresolvedReductions.push_back(nullptr);
11215 }
11216 return getDerived().RebuildOMPInReductionClause(
11217 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11218 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11219}
11220
11221template <typename Derived>
11222OMPClause *
11225 Vars.reserve(C->varlist_size());
11226 for (auto *VE : C->varlist()) {
11227 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11228 if (EVar.isInvalid())
11229 return nullptr;
11230 Vars.push_back(EVar.get());
11231 }
11232 ExprResult Step = getDerived().TransformExpr(C->getStep());
11233 if (Step.isInvalid())
11234 return nullptr;
11235 return getDerived().RebuildOMPLinearClause(
11236 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11237 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11238 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 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11253 if (Alignment.isInvalid())
11254 return nullptr;
11255 return getDerived().RebuildOMPAlignedClause(
11256 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11257 C->getColonLoc(), C->getEndLoc());
11258}
11259
11260template <typename Derived>
11261OMPClause *
11264 Vars.reserve(C->varlist_size());
11265 for (auto *VE : C->varlist()) {
11266 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11267 if (EVar.isInvalid())
11268 return nullptr;
11269 Vars.push_back(EVar.get());
11270 }
11271 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11272 C->getLParenLoc(), C->getEndLoc());
11273}
11274
11275template <typename Derived>
11276OMPClause *
11279 Vars.reserve(C->varlist_size());
11280 for (auto *VE : C->varlist()) {
11281 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11282 if (EVar.isInvalid())
11283 return nullptr;
11284 Vars.push_back(EVar.get());
11285 }
11286 return getDerived().RebuildOMPCopyprivateClause(
11287 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11288}
11289
11290template <typename Derived>
11293 Vars.reserve(C->varlist_size());
11294 for (auto *VE : C->varlist()) {
11295 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11296 if (EVar.isInvalid())
11297 return nullptr;
11298 Vars.push_back(EVar.get());
11299 }
11300 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11301 C->getLParenLoc(), C->getEndLoc());
11302}
11303
11304template <typename Derived>
11305OMPClause *
11307 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11308 if (E.isInvalid())
11309 return nullptr;
11310 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11311 C->getLParenLoc(), C->getEndLoc());
11312}
11313
11314template <typename Derived>
11315OMPClause *
11318 Expr *DepModifier = C->getModifier();
11319 if (DepModifier) {
11320 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11321 if (DepModRes.isInvalid())
11322 return nullptr;
11323 DepModifier = DepModRes.get();
11324 }
11325 Vars.reserve(C->varlist_size());
11326 for (auto *VE : C->varlist()) {
11327 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11328 if (EVar.isInvalid())
11329 return nullptr;
11330 Vars.push_back(EVar.get());
11331 }
11332 return getDerived().RebuildOMPDependClause(
11333 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11334 C->getOmpAllMemoryLoc()},
11335 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11336}
11337
11338template <typename Derived>
11339OMPClause *
11341 ExprResult E = getDerived().TransformExpr(C->getDevice());
11342 if (E.isInvalid())
11343 return nullptr;
11344 return getDerived().RebuildOMPDeviceClause(
11345 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11346 C->getModifierLoc(), C->getEndLoc());
11347}
11348
11349template <typename Derived, class T>
11352 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11353 DeclarationNameInfo &MapperIdInfo,
11354 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11355 // Transform expressions in the list.
11356 Vars.reserve(C->varlist_size());
11357 for (auto *VE : C->varlist()) {
11358 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11359 if (EVar.isInvalid())
11360 return true;
11361 Vars.push_back(EVar.get());
11362 }
11363 // Transform mapper scope specifier and identifier.
11364 NestedNameSpecifierLoc QualifierLoc;
11365 if (C->getMapperQualifierLoc()) {
11366 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11367 C->getMapperQualifierLoc());
11368 if (!QualifierLoc)
11369 return true;
11370 }
11371 MapperIdScopeSpec.Adopt(QualifierLoc);
11372 MapperIdInfo = C->getMapperIdInfo();
11373 if (MapperIdInfo.getName()) {
11374 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11375 if (!MapperIdInfo.getName())
11376 return true;
11377 }
11378 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11379 // the previous user-defined mapper lookup in dependent environment.
11380 for (auto *E : C->mapperlists()) {
11381 // Transform all the decls.
11382 if (E) {
11383 auto *ULE = cast<UnresolvedLookupExpr>(E);
11384 UnresolvedSet<8> Decls;
11385 for (auto *D : ULE->decls()) {
11386 NamedDecl *InstD =
11387 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11388 Decls.addDecl(InstD, InstD->getAccess());
11389 }
11390 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11391 TT.getSema().Context, /*NamingClass=*/nullptr,
11392 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11393 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11394 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11395 } else {
11396 UnresolvedMappers.push_back(nullptr);
11397 }
11398 }
11399 return false;
11400}
11401
11402template <typename Derived>
11403OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11404 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11406 Expr *IteratorModifier = C->getIteratorModifier();
11407 if (IteratorModifier) {
11408 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11409 if (MapModRes.isInvalid())
11410 return nullptr;
11411 IteratorModifier = MapModRes.get();
11412 }
11413 CXXScopeSpec MapperIdScopeSpec;
11414 DeclarationNameInfo MapperIdInfo;
11415 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11417 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11418 return nullptr;
11419 return getDerived().RebuildOMPMapClause(
11420 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11421 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11422 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11423}
11424
11425template <typename Derived>
11426OMPClause *
11428 Expr *Allocator = C->getAllocator();
11429 if (Allocator) {
11430 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11431 if (AllocatorRes.isInvalid())
11432 return nullptr;
11433 Allocator = AllocatorRes.get();
11434 }
11435 Expr *Alignment = C->getAlignment();
11436 if (Alignment) {
11437 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11438 if (AlignmentRes.isInvalid())
11439 return nullptr;
11440 Alignment = AlignmentRes.get();
11441 }
11443 Vars.reserve(C->varlist_size());
11444 for (auto *VE : C->varlist()) {
11445 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11446 if (EVar.isInvalid())
11447 return nullptr;
11448 Vars.push_back(EVar.get());
11449 }
11450 return getDerived().RebuildOMPAllocateClause(
11451 Allocator, Alignment, C->getFirstAllocateModifier(),
11452 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11453 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11454 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11455}
11456
11457template <typename Derived>
11458OMPClause *
11461 Vars.reserve(C->varlist_size());
11462 for (auto *VE : C->varlist()) {
11463 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11464 if (EVar.isInvalid())
11465 return nullptr;
11466 Vars.push_back(EVar.get());
11467 }
11468 return getDerived().RebuildOMPNumTeamsClause(
11469 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11470}
11471
11472template <typename Derived>
11473OMPClause *
11476 Vars.reserve(C->varlist_size());
11477 for (auto *VE : C->varlist()) {
11478 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11479 if (EVar.isInvalid())
11480 return nullptr;
11481 Vars.push_back(EVar.get());
11482 }
11483 return getDerived().RebuildOMPThreadLimitClause(
11484 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11485}
11486
11487template <typename Derived>
11488OMPClause *
11490 ExprResult E = getDerived().TransformExpr(C->getPriority());
11491 if (E.isInvalid())
11492 return nullptr;
11493 return getDerived().RebuildOMPPriorityClause(
11494 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11495}
11496
11497template <typename Derived>
11498OMPClause *
11500 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11501 if (E.isInvalid())
11502 return nullptr;
11503 return getDerived().RebuildOMPGrainsizeClause(
11504 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11505 C->getModifierLoc(), C->getEndLoc());
11506}
11507
11508template <typename Derived>
11509OMPClause *
11511 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11512 if (E.isInvalid())
11513 return nullptr;
11514 return getDerived().RebuildOMPNumTasksClause(
11515 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11516 C->getModifierLoc(), C->getEndLoc());
11517}
11518
11519template <typename Derived>
11521 ExprResult E = getDerived().TransformExpr(C->getHint());
11522 if (E.isInvalid())
11523 return nullptr;
11524 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11525 C->getLParenLoc(), C->getEndLoc());
11526}
11527
11528template <typename Derived>
11531 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11532 if (E.isInvalid())
11533 return nullptr;
11534 return getDerived().RebuildOMPDistScheduleClause(
11535 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11536 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11537}
11538
11539template <typename Derived>
11540OMPClause *
11542 // Rebuild Defaultmap Clause since we need to invoke the checking of
11543 // defaultmap(none:variable-category) after template initialization.
11544 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11545 C->getDefaultmapKind(),
11546 C->getBeginLoc(),
11547 C->getLParenLoc(),
11548 C->getDefaultmapModifierLoc(),
11549 C->getDefaultmapKindLoc(),
11550 C->getEndLoc());
11551}
11552
11553template <typename Derived>
11555 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11557 Expr *IteratorModifier = C->getIteratorModifier();
11558 if (IteratorModifier) {
11559 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11560 if (MapModRes.isInvalid())
11561 return nullptr;
11562 IteratorModifier = MapModRes.get();
11563 }
11564 CXXScopeSpec MapperIdScopeSpec;
11565 DeclarationNameInfo MapperIdInfo;
11566 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11568 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11569 return nullptr;
11570 return getDerived().RebuildOMPToClause(
11571 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11572 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11573 UnresolvedMappers);
11574}
11575
11576template <typename Derived>
11578 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11580 Expr *IteratorModifier = C->getIteratorModifier();
11581 if (IteratorModifier) {
11582 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11583 if (MapModRes.isInvalid())
11584 return nullptr;
11585 IteratorModifier = MapModRes.get();
11586 }
11587 CXXScopeSpec MapperIdScopeSpec;
11588 DeclarationNameInfo MapperIdInfo;
11589 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11591 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11592 return nullptr;
11593 return getDerived().RebuildOMPFromClause(
11594 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11595 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11596 UnresolvedMappers);
11597}
11598
11599template <typename Derived>
11603 Vars.reserve(C->varlist_size());
11604 for (auto *VE : C->varlist()) {
11605 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11606 if (EVar.isInvalid())
11607 return nullptr;
11608 Vars.push_back(EVar.get());
11609 }
11610 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11611 return getDerived().RebuildOMPUseDevicePtrClause(Vars, Locs);
11612}
11613
11614template <typename Derived>
11618 Vars.reserve(C->varlist_size());
11619 for (auto *VE : C->varlist()) {
11620 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11621 if (EVar.isInvalid())
11622 return nullptr;
11623 Vars.push_back(EVar.get());
11624 }
11625 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11626 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11627}
11628
11629template <typename Derived>
11630OMPClause *
11633 Vars.reserve(C->varlist_size());
11634 for (auto *VE : C->varlist()) {
11635 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11636 if (EVar.isInvalid())
11637 return nullptr;
11638 Vars.push_back(EVar.get());
11639 }
11640 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11641 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11642}
11643
11644template <typename Derived>
11648 Vars.reserve(C->varlist_size());
11649 for (auto *VE : C->varlist()) {
11650 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11651 if (EVar.isInvalid())
11652 return nullptr;
11653 Vars.push_back(EVar.get());
11654 }
11655 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11656 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11657}
11658
11659template <typename Derived>
11660OMPClause *
11663 Vars.reserve(C->varlist_size());
11664 for (auto *VE : C->varlist()) {
11665 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11666 if (EVar.isInvalid())
11667 return nullptr;
11668 Vars.push_back(EVar.get());
11669 }
11670 return getDerived().RebuildOMPNontemporalClause(
11671 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11672}
11673
11674template <typename Derived>
11675OMPClause *
11678 Vars.reserve(C->varlist_size());
11679 for (auto *VE : C->varlist()) {
11680 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11681 if (EVar.isInvalid())
11682 return nullptr;
11683 Vars.push_back(EVar.get());
11684 }
11685 return getDerived().RebuildOMPInclusiveClause(
11686 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11687}
11688
11689template <typename Derived>
11690OMPClause *
11693 Vars.reserve(C->varlist_size());
11694 for (auto *VE : C->varlist()) {
11695 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11696 if (EVar.isInvalid())
11697 return nullptr;
11698 Vars.push_back(EVar.get());
11699 }
11700 return getDerived().RebuildOMPExclusiveClause(
11701 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11702}
11703
11704template <typename Derived>
11708 Data.reserve(C->getNumberOfAllocators());
11709 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11710 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11711 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11712 if (Allocator.isInvalid())
11713 continue;
11714 ExprResult AllocatorTraits;
11715 if (Expr *AT = D.AllocatorTraits) {
11716 AllocatorTraits = getDerived().TransformExpr(AT);
11717 if (AllocatorTraits.isInvalid())
11718 continue;
11719 }
11720 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11721 NewD.Allocator = Allocator.get();
11722 NewD.AllocatorTraits = AllocatorTraits.get();
11723 NewD.LParenLoc = D.LParenLoc;
11724 NewD.RParenLoc = D.RParenLoc;
11725 }
11726 return getDerived().RebuildOMPUsesAllocatorsClause(
11727 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11728}
11729
11730template <typename Derived>
11731OMPClause *
11733 SmallVector<Expr *, 4> Locators;
11734 Locators.reserve(C->varlist_size());
11735 ExprResult ModifierRes;
11736 if (Expr *Modifier = C->getModifier()) {
11737 ModifierRes = getDerived().TransformExpr(Modifier);
11738 if (ModifierRes.isInvalid())
11739 return nullptr;
11740 }
11741 for (Expr *E : C->varlist()) {
11742 ExprResult Locator = getDerived().TransformExpr(E);
11743 if (Locator.isInvalid())
11744 continue;
11745 Locators.push_back(Locator.get());
11746 }
11747 return getDerived().RebuildOMPAffinityClause(
11748 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11749 ModifierRes.get(), Locators);
11750}
11751
11752template <typename Derived>
11754 return getDerived().RebuildOMPOrderClause(
11755 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11756 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11757}
11758
11759template <typename Derived>
11761 return getDerived().RebuildOMPBindClause(
11762 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11763 C->getLParenLoc(), C->getEndLoc());
11764}
11765
11766template <typename Derived>
11769 ExprResult Size = getDerived().TransformExpr(C->getSize());
11770 if (Size.isInvalid())
11771 return nullptr;
11772 return getDerived().RebuildOMPXDynCGroupMemClause(
11773 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11774}
11775
11776template <typename Derived>
11779 ExprResult Size = getDerived().TransformExpr(C->getSize());
11780 if (Size.isInvalid())
11781 return nullptr;
11782 return getDerived().RebuildOMPDynGroupprivateClause(
11783 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
11784 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
11785 C->getDynGroupprivateModifierLoc(),
11786 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
11787}
11788
11789template <typename Derived>
11790OMPClause *
11793 Vars.reserve(C->varlist_size());
11794 for (auto *VE : C->varlist()) {
11795 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11796 if (EVar.isInvalid())
11797 return nullptr;
11798 Vars.push_back(EVar.get());
11799 }
11800 return getDerived().RebuildOMPDoacrossClause(
11801 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11802 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11803}
11804
11805template <typename Derived>
11806OMPClause *
11809 for (auto *A : C->getAttrs())
11810 NewAttrs.push_back(getDerived().TransformAttr(A));
11811 return getDerived().RebuildOMPXAttributeClause(
11812 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11813}
11814
11815template <typename Derived>
11817 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11818}
11819
11820//===----------------------------------------------------------------------===//
11821// OpenACC transformation
11822//===----------------------------------------------------------------------===//
11823namespace {
11824template <typename Derived>
11825class OpenACCClauseTransform final
11826 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11827 TreeTransform<Derived> &Self;
11828 ArrayRef<const OpenACCClause *> ExistingClauses;
11829 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11830 OpenACCClause *NewClause = nullptr;
11831
11832 ExprResult VisitVar(Expr *VarRef) {
11833 ExprResult Res = Self.TransformExpr(VarRef);
11834
11835 if (!Res.isUsable())
11836 return Res;
11837
11838 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11839 ParsedClause.getClauseKind(),
11840 Res.get());
11841
11842 return Res;
11843 }
11844
11845 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11846 llvm::SmallVector<Expr *> InstantiatedVarList;
11847 for (Expr *CurVar : VarList) {
11848 ExprResult VarRef = VisitVar(CurVar);
11849
11850 if (VarRef.isUsable())
11851 InstantiatedVarList.push_back(VarRef.get());
11852 }
11853
11854 return InstantiatedVarList;
11855 }
11856
11857public:
11858 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11859 ArrayRef<const OpenACCClause *> ExistingClauses,
11860 SemaOpenACC::OpenACCParsedClause &PC)
11861 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
11862
11863 OpenACCClause *CreatedClause() const { return NewClause; }
11864
11865#define VISIT_CLAUSE(CLAUSE_NAME) \
11866 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11867#include "clang/Basic/OpenACCClauses.def"
11868};
11869
11870template <typename Derived>
11871void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11872 const OpenACCDefaultClause &C) {
11873 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
11874
11875 NewClause = OpenACCDefaultClause::Create(
11876 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
11877 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11878 ParsedClause.getEndLoc());
11879}
11880
11881template <typename Derived>
11882void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
11883 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11884 assert(Cond && "If constructed with invalid Condition");
11885 Sema::ConditionResult Res = Self.TransformCondition(
11886 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
11887
11888 if (Res.isInvalid() || !Res.get().second)
11889 return;
11890
11891 ParsedClause.setConditionDetails(Res.get().second);
11892
11893 NewClause = OpenACCIfClause::Create(
11894 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11895 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11896 ParsedClause.getEndLoc());
11897}
11898
11899template <typename Derived>
11900void OpenACCClauseTransform<Derived>::VisitSelfClause(
11901 const OpenACCSelfClause &C) {
11902
11903 // If this is an 'update' 'self' clause, this is actually a var list instead.
11904 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
11905 llvm::SmallVector<Expr *> InstantiatedVarList;
11906 for (Expr *CurVar : C.getVarList()) {
11907 ExprResult Res = Self.TransformExpr(CurVar);
11908
11909 if (!Res.isUsable())
11910 continue;
11911
11912 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11913 ParsedClause.getClauseKind(),
11914 Res.get());
11915
11916 if (Res.isUsable())
11917 InstantiatedVarList.push_back(Res.get());
11918 }
11919
11920 ParsedClause.setVarListDetails(InstantiatedVarList,
11922
11923 NewClause = OpenACCSelfClause::Create(
11924 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11925 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11926 ParsedClause.getEndLoc());
11927 } else {
11928
11929 if (C.hasConditionExpr()) {
11930 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11932 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
11934
11935 if (Res.isInvalid() || !Res.get().second)
11936 return;
11937
11938 ParsedClause.setConditionDetails(Res.get().second);
11939 }
11940
11941 NewClause = OpenACCSelfClause::Create(
11942 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11943 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11944 ParsedClause.getEndLoc());
11945 }
11946}
11947
11948template <typename Derived>
11949void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
11950 const OpenACCNumGangsClause &C) {
11951 llvm::SmallVector<Expr *> InstantiatedIntExprs;
11952
11953 for (Expr *CurIntExpr : C.getIntExprs()) {
11954 ExprResult Res = Self.TransformExpr(CurIntExpr);
11955
11956 if (!Res.isUsable())
11957 return;
11958
11959 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
11960 C.getClauseKind(),
11961 C.getBeginLoc(), Res.get());
11962 if (!Res.isUsable())
11963 return;
11964
11965 InstantiatedIntExprs.push_back(Res.get());
11966 }
11967
11968 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
11970 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11971 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
11972 ParsedClause.getEndLoc());
11973}
11974
11975template <typename Derived>
11976void OpenACCClauseTransform<Derived>::VisitPrivateClause(
11977 const OpenACCPrivateClause &C) {
11978 llvm::SmallVector<Expr *> InstantiatedVarList;
11980
11981 for (const auto [RefExpr, InitRecipe] :
11982 llvm::zip(C.getVarList(), C.getInitRecipes())) {
11983 ExprResult VarRef = VisitVar(RefExpr);
11984
11985 if (VarRef.isUsable()) {
11986 InstantiatedVarList.push_back(VarRef.get());
11987
11988 // We only have to create a new one if it is dependent, and Sema won't
11989 // make one of these unless the type is non-dependent.
11990 if (InitRecipe.isSet())
11991 InitRecipes.push_back(InitRecipe);
11992 else
11993 InitRecipes.push_back(
11994 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
11995 }
11996 }
11997 ParsedClause.setVarListDetails(InstantiatedVarList,
11999
12000 NewClause = OpenACCPrivateClause::Create(
12001 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12002 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12003 ParsedClause.getEndLoc());
12004}
12005
12006template <typename Derived>
12007void OpenACCClauseTransform<Derived>::VisitHostClause(
12008 const OpenACCHostClause &C) {
12009 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12011
12012 NewClause = OpenACCHostClause::Create(
12013 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12014 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12015 ParsedClause.getEndLoc());
12016}
12017
12018template <typename Derived>
12019void OpenACCClauseTransform<Derived>::VisitDeviceClause(
12020 const OpenACCDeviceClause &C) {
12021 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12023
12024 NewClause = OpenACCDeviceClause::Create(
12025 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12026 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12027 ParsedClause.getEndLoc());
12028}
12029
12030template <typename Derived>
12031void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
12033 llvm::SmallVector<Expr *> InstantiatedVarList;
12035
12036 for (const auto [RefExpr, InitRecipe] :
12037 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12038 ExprResult VarRef = VisitVar(RefExpr);
12039
12040 if (VarRef.isUsable()) {
12041 InstantiatedVarList.push_back(VarRef.get());
12042
12043 // We only have to create a new one if it is dependent, and Sema won't
12044 // make one of these unless the type is non-dependent.
12045 if (InitRecipe.isSet())
12046 InitRecipes.push_back(InitRecipe);
12047 else
12048 InitRecipes.push_back(
12049 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12050 VarRef.get()));
12051 }
12052 }
12053 ParsedClause.setVarListDetails(InstantiatedVarList,
12055
12057 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12058 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12059 ParsedClause.getEndLoc());
12060}
12061
12062template <typename Derived>
12063void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12064 const OpenACCNoCreateClause &C) {
12065 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12067
12069 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12070 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12071 ParsedClause.getEndLoc());
12072}
12073
12074template <typename Derived>
12075void OpenACCClauseTransform<Derived>::VisitPresentClause(
12076 const OpenACCPresentClause &C) {
12077 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12079
12080 NewClause = OpenACCPresentClause::Create(
12081 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12082 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12083 ParsedClause.getEndLoc());
12084}
12085
12086template <typename Derived>
12087void OpenACCClauseTransform<Derived>::VisitCopyClause(
12088 const OpenACCCopyClause &C) {
12089 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12090 C.getModifierList());
12091
12092 NewClause = OpenACCCopyClause::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>::VisitLinkClause(
12101 const OpenACCLinkClause &C) {
12102 llvm_unreachable("link clause not valid unless a decl transform");
12103}
12104
12105template <typename Derived>
12106void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12108 llvm_unreachable("device_resident clause not valid unless a decl transform");
12109}
12110template <typename Derived>
12111void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12112 const OpenACCNoHostClause &C) {
12113 llvm_unreachable("nohost clause not valid unless a decl transform");
12114}
12115template <typename Derived>
12116void OpenACCClauseTransform<Derived>::VisitBindClause(
12117 const OpenACCBindClause &C) {
12118 llvm_unreachable("bind clause not valid unless a decl transform");
12119}
12120
12121template <typename Derived>
12122void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12123 const OpenACCCopyInClause &C) {
12124 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12125 C.getModifierList());
12126
12127 NewClause = OpenACCCopyInClause::Create(
12128 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12129 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12130 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12131 ParsedClause.getEndLoc());
12132}
12133
12134template <typename Derived>
12135void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12136 const OpenACCCopyOutClause &C) {
12137 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12138 C.getModifierList());
12139
12140 NewClause = OpenACCCopyOutClause::Create(
12141 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12142 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12143 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12144 ParsedClause.getEndLoc());
12145}
12146
12147template <typename Derived>
12148void OpenACCClauseTransform<Derived>::VisitCreateClause(
12149 const OpenACCCreateClause &C) {
12150 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12151 C.getModifierList());
12152
12153 NewClause = OpenACCCreateClause::Create(
12154 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12155 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12156 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12157 ParsedClause.getEndLoc());
12158}
12159template <typename Derived>
12160void OpenACCClauseTransform<Derived>::VisitAttachClause(
12161 const OpenACCAttachClause &C) {
12162 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12163
12164 // Ensure each var is a pointer type.
12165 llvm::erase_if(VarList, [&](Expr *E) {
12166 return Self.getSema().OpenACC().CheckVarIsPointerType(
12168 });
12169
12170 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12171 NewClause = OpenACCAttachClause::Create(
12172 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12173 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12174 ParsedClause.getEndLoc());
12175}
12176
12177template <typename Derived>
12178void OpenACCClauseTransform<Derived>::VisitDetachClause(
12179 const OpenACCDetachClause &C) {
12180 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12181
12182 // Ensure each var is a pointer type.
12183 llvm::erase_if(VarList, [&](Expr *E) {
12184 return Self.getSema().OpenACC().CheckVarIsPointerType(
12186 });
12187
12188 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12189 NewClause = OpenACCDetachClause::Create(
12190 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12191 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12192 ParsedClause.getEndLoc());
12193}
12194
12195template <typename Derived>
12196void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12197 const OpenACCDeleteClause &C) {
12198 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12200 NewClause = OpenACCDeleteClause::Create(
12201 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12202 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12203 ParsedClause.getEndLoc());
12204}
12205
12206template <typename Derived>
12207void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12208 const OpenACCUseDeviceClause &C) {
12209 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12212 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12213 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12214 ParsedClause.getEndLoc());
12215}
12216
12217template <typename Derived>
12218void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12219 const OpenACCDevicePtrClause &C) {
12220 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12221
12222 // Ensure each var is a pointer type.
12223 llvm::erase_if(VarList, [&](Expr *E) {
12224 return Self.getSema().OpenACC().CheckVarIsPointerType(
12226 });
12227
12228 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12230 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12231 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12232 ParsedClause.getEndLoc());
12233}
12234
12235template <typename Derived>
12236void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12237 const OpenACCNumWorkersClause &C) {
12238 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12239 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12240
12241 ExprResult Res = Self.TransformExpr(IntExpr);
12242 if (!Res.isUsable())
12243 return;
12244
12245 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12246 C.getClauseKind(),
12247 C.getBeginLoc(), Res.get());
12248 if (!Res.isUsable())
12249 return;
12250
12251 ParsedClause.setIntExprDetails(Res.get());
12253 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12254 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12255 ParsedClause.getEndLoc());
12256}
12257
12258template <typename Derived>
12259void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12260 const OpenACCDeviceNumClause &C) {
12261 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12262 assert(IntExpr && "device_num clause constructed with invalid int expr");
12263
12264 ExprResult Res = Self.TransformExpr(IntExpr);
12265 if (!Res.isUsable())
12266 return;
12267
12268 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12269 C.getClauseKind(),
12270 C.getBeginLoc(), Res.get());
12271 if (!Res.isUsable())
12272 return;
12273
12274 ParsedClause.setIntExprDetails(Res.get());
12276 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12277 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12278 ParsedClause.getEndLoc());
12279}
12280
12281template <typename Derived>
12282void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12284 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12285 assert(IntExpr && "default_async clause constructed with invalid int expr");
12286
12287 ExprResult Res = Self.TransformExpr(IntExpr);
12288 if (!Res.isUsable())
12289 return;
12290
12291 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12292 C.getClauseKind(),
12293 C.getBeginLoc(), Res.get());
12294 if (!Res.isUsable())
12295 return;
12296
12297 ParsedClause.setIntExprDetails(Res.get());
12299 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12300 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12301 ParsedClause.getEndLoc());
12302}
12303
12304template <typename Derived>
12305void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12307 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12308 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12309
12310 ExprResult Res = Self.TransformExpr(IntExpr);
12311 if (!Res.isUsable())
12312 return;
12313
12314 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12315 C.getClauseKind(),
12316 C.getBeginLoc(), Res.get());
12317 if (!Res.isUsable())
12318 return;
12319
12320 ParsedClause.setIntExprDetails(Res.get());
12322 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12323 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12324 ParsedClause.getEndLoc());
12325}
12326
12327template <typename Derived>
12328void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12329 const OpenACCAsyncClause &C) {
12330 if (C.hasIntExpr()) {
12331 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12332 if (!Res.isUsable())
12333 return;
12334
12335 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12336 C.getClauseKind(),
12337 C.getBeginLoc(), Res.get());
12338 if (!Res.isUsable())
12339 return;
12340 ParsedClause.setIntExprDetails(Res.get());
12341 }
12342
12343 NewClause = OpenACCAsyncClause::Create(
12344 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12345 ParsedClause.getLParenLoc(),
12346 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12347 : nullptr,
12348 ParsedClause.getEndLoc());
12349}
12350
12351template <typename Derived>
12352void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12353 const OpenACCWorkerClause &C) {
12354 if (C.hasIntExpr()) {
12355 // restrictions on this expression are all "does it exist in certain
12356 // situations" that are not possible to be dependent, so the only check we
12357 // have is that it transforms, and is an int expression.
12358 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12359 if (!Res.isUsable())
12360 return;
12361
12362 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12363 C.getClauseKind(),
12364 C.getBeginLoc(), Res.get());
12365 if (!Res.isUsable())
12366 return;
12367 ParsedClause.setIntExprDetails(Res.get());
12368 }
12369
12370 NewClause = OpenACCWorkerClause::Create(
12371 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12372 ParsedClause.getLParenLoc(),
12373 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12374 : nullptr,
12375 ParsedClause.getEndLoc());
12376}
12377
12378template <typename Derived>
12379void OpenACCClauseTransform<Derived>::VisitVectorClause(
12380 const OpenACCVectorClause &C) {
12381 if (C.hasIntExpr()) {
12382 // restrictions on this expression are all "does it exist in certain
12383 // situations" that are not possible to be dependent, so the only check we
12384 // have is that it transforms, and is an int expression.
12385 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12386 if (!Res.isUsable())
12387 return;
12388
12389 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12390 C.getClauseKind(),
12391 C.getBeginLoc(), Res.get());
12392 if (!Res.isUsable())
12393 return;
12394 ParsedClause.setIntExprDetails(Res.get());
12395 }
12396
12397 NewClause = OpenACCVectorClause::Create(
12398 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12399 ParsedClause.getLParenLoc(),
12400 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12401 : nullptr,
12402 ParsedClause.getEndLoc());
12403}
12404
12405template <typename Derived>
12406void OpenACCClauseTransform<Derived>::VisitWaitClause(
12407 const OpenACCWaitClause &C) {
12408 if (C.hasExprs()) {
12409 Expr *DevNumExpr = nullptr;
12410 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12411
12412 // Instantiate devnum expr if it exists.
12413 if (C.getDevNumExpr()) {
12414 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12415 if (!Res.isUsable())
12416 return;
12417 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12418 C.getClauseKind(),
12419 C.getBeginLoc(), Res.get());
12420 if (!Res.isUsable())
12421 return;
12422
12423 DevNumExpr = Res.get();
12424 }
12425
12426 // Instantiate queue ids.
12427 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12428 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12429 if (!Res.isUsable())
12430 return;
12431 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12432 C.getClauseKind(),
12433 C.getBeginLoc(), Res.get());
12434 if (!Res.isUsable())
12435 return;
12436
12437 InstantiatedQueueIdExprs.push_back(Res.get());
12438 }
12439
12440 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12441 std::move(InstantiatedQueueIdExprs));
12442 }
12443
12444 NewClause = OpenACCWaitClause::Create(
12445 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12446 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12447 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12448 ParsedClause.getEndLoc());
12449}
12450
12451template <typename Derived>
12452void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12453 const OpenACCDeviceTypeClause &C) {
12454 // Nothing to transform here, just create a new version of 'C'.
12456 Self.getSema().getASTContext(), C.getClauseKind(),
12457 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12458 C.getArchitectures(), ParsedClause.getEndLoc());
12459}
12460
12461template <typename Derived>
12462void OpenACCClauseTransform<Derived>::VisitAutoClause(
12463 const OpenACCAutoClause &C) {
12464 // Nothing to do, so just create a new node.
12465 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12466 ParsedClause.getBeginLoc(),
12467 ParsedClause.getEndLoc());
12468}
12469
12470template <typename Derived>
12471void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12472 const OpenACCIndependentClause &C) {
12473 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12474 ParsedClause.getBeginLoc(),
12475 ParsedClause.getEndLoc());
12476}
12477
12478template <typename Derived>
12479void OpenACCClauseTransform<Derived>::VisitSeqClause(
12480 const OpenACCSeqClause &C) {
12481 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12482 ParsedClause.getBeginLoc(),
12483 ParsedClause.getEndLoc());
12484}
12485template <typename Derived>
12486void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12487 const OpenACCFinalizeClause &C) {
12488 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12489 ParsedClause.getBeginLoc(),
12490 ParsedClause.getEndLoc());
12491}
12492
12493template <typename Derived>
12494void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12495 const OpenACCIfPresentClause &C) {
12496 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12497 ParsedClause.getBeginLoc(),
12498 ParsedClause.getEndLoc());
12499}
12500
12501template <typename Derived>
12502void OpenACCClauseTransform<Derived>::VisitReductionClause(
12503 const OpenACCReductionClause &C) {
12504 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12505 SmallVector<Expr *> ValidVars;
12507
12508 for (const auto [Var, OrigRecipe] :
12509 llvm::zip(TransformedVars, C.getRecipes())) {
12510 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12511 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12512 if (Res.isUsable()) {
12513 ValidVars.push_back(Res.get());
12514
12515 if (OrigRecipe.isSet())
12516 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
12517 else
12518 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
12519 C.getReductionOp(), Res.get()));
12520 }
12521 }
12522
12523 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12524 ExistingClauses, ParsedClause.getDirectiveKind(),
12525 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12526 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
12527}
12528
12529template <typename Derived>
12530void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12531 const OpenACCCollapseClause &C) {
12532 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12533 assert(LoopCount && "collapse clause constructed with invalid loop count");
12534
12535 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12536
12537 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12538 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12539 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12540
12541 NewLoopCount =
12542 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12543
12544 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12546 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12547 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12548 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12549}
12550
12551template <typename Derived>
12552void OpenACCClauseTransform<Derived>::VisitTileClause(
12553 const OpenACCTileClause &C) {
12554
12555 llvm::SmallVector<Expr *> TransformedExprs;
12556
12557 for (Expr *E : C.getSizeExprs()) {
12558 ExprResult NewSizeExpr = Self.TransformExpr(E);
12559
12560 if (!NewSizeExpr.isUsable())
12561 return;
12562
12563 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12564 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12565 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12566
12567 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12568
12569 if (!NewSizeExpr.isUsable())
12570 return;
12571 TransformedExprs.push_back(NewSizeExpr.get());
12572 }
12573
12574 ParsedClause.setIntExprDetails(TransformedExprs);
12575 NewClause = OpenACCTileClause::Create(
12576 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12577 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12578 ParsedClause.getEndLoc());
12579}
12580template <typename Derived>
12581void OpenACCClauseTransform<Derived>::VisitGangClause(
12582 const OpenACCGangClause &C) {
12583 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12584 llvm::SmallVector<Expr *> TransformedIntExprs;
12585
12586 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12587 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12588 if (!ER.isUsable())
12589 continue;
12590
12591 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12592 ParsedClause.getDirectiveKind(),
12593 C.getExpr(I).first, ER.get());
12594 if (!ER.isUsable())
12595 continue;
12596 TransformedGangKinds.push_back(C.getExpr(I).first);
12597 TransformedIntExprs.push_back(ER.get());
12598 }
12599
12600 NewClause = Self.getSema().OpenACC().CheckGangClause(
12601 ParsedClause.getDirectiveKind(), ExistingClauses,
12602 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12603 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12604}
12605} // namespace
12606template <typename Derived>
12607OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12608 ArrayRef<const OpenACCClause *> ExistingClauses,
12609 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12610
12612 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12613 ParsedClause.setEndLoc(OldClause->getEndLoc());
12614
12615 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12616 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12617
12618 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12619 ParsedClause};
12620 Transform.Visit(OldClause);
12621
12622 return Transform.CreatedClause();
12623}
12624
12625template <typename Derived>
12627TreeTransform<Derived>::TransformOpenACCClauseList(
12629 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12630 for (const auto *Clause : OldClauses) {
12631 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12632 TransformedClauses, DirKind, Clause))
12633 TransformedClauses.push_back(TransformedClause);
12634 }
12635 return TransformedClauses;
12636}
12637
12638template <typename Derived>
12641 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12642
12643 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12644 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12645 C->clauses());
12646
12647 if (getSema().OpenACC().ActOnStartStmtDirective(
12648 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12649 return StmtError();
12650
12651 // Transform Structured Block.
12652 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12653 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12654 C->clauses(), TransformedClauses);
12655 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12656 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12657 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12658
12659 return getDerived().RebuildOpenACCComputeConstruct(
12660 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12661 C->getEndLoc(), TransformedClauses, StrBlock);
12662}
12663
12664template <typename Derived>
12667
12668 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12669
12670 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12671 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12672 C->clauses());
12673
12674 if (getSema().OpenACC().ActOnStartStmtDirective(
12675 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12676 return StmtError();
12677
12678 // Transform Loop.
12679 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12680 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12681 C->clauses(), TransformedClauses);
12682 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12683 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12684 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12685
12686 return getDerived().RebuildOpenACCLoopConstruct(
12687 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12688 TransformedClauses, Loop);
12689}
12690
12691template <typename Derived>
12693 OpenACCCombinedConstruct *C) {
12694 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12695
12696 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12697 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12698 C->clauses());
12699
12700 if (getSema().OpenACC().ActOnStartStmtDirective(
12701 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12702 return StmtError();
12703
12704 // Transform Loop.
12705 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12706 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12707 C->clauses(), TransformedClauses);
12708 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12709 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12710 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12711
12712 return getDerived().RebuildOpenACCCombinedConstruct(
12713 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12714 C->getEndLoc(), TransformedClauses, Loop);
12715}
12716
12717template <typename Derived>
12720 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12721
12722 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12723 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12724 C->clauses());
12725 if (getSema().OpenACC().ActOnStartStmtDirective(
12726 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12727 return StmtError();
12728
12729 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12730 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12731 C->clauses(), TransformedClauses);
12732 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12733 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12734 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12735
12736 return getDerived().RebuildOpenACCDataConstruct(
12737 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12738 TransformedClauses, StrBlock);
12739}
12740
12741template <typename Derived>
12743 OpenACCEnterDataConstruct *C) {
12744 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12745
12746 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12747 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12748 C->clauses());
12749 if (getSema().OpenACC().ActOnStartStmtDirective(
12750 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12751 return StmtError();
12752
12753 return getDerived().RebuildOpenACCEnterDataConstruct(
12754 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12755 TransformedClauses);
12756}
12757
12758template <typename Derived>
12760 OpenACCExitDataConstruct *C) {
12761 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12762
12763 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12764 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12765 C->clauses());
12766 if (getSema().OpenACC().ActOnStartStmtDirective(
12767 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12768 return StmtError();
12769
12770 return getDerived().RebuildOpenACCExitDataConstruct(
12771 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12772 TransformedClauses);
12773}
12774
12775template <typename Derived>
12777 OpenACCHostDataConstruct *C) {
12778 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12779
12780 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12781 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12782 C->clauses());
12783 if (getSema().OpenACC().ActOnStartStmtDirective(
12784 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12785 return StmtError();
12786
12787 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12788 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12789 C->clauses(), TransformedClauses);
12790 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12791 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12792 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12793
12794 return getDerived().RebuildOpenACCHostDataConstruct(
12795 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12796 TransformedClauses, StrBlock);
12797}
12798
12799template <typename Derived>
12802 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12803
12804 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12805 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12806 C->clauses());
12807 if (getSema().OpenACC().ActOnStartStmtDirective(
12808 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12809 return StmtError();
12810
12811 return getDerived().RebuildOpenACCInitConstruct(
12812 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12813 TransformedClauses);
12814}
12815
12816template <typename Derived>
12818 OpenACCShutdownConstruct *C) {
12819 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12820
12821 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12822 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12823 C->clauses());
12824 if (getSema().OpenACC().ActOnStartStmtDirective(
12825 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12826 return StmtError();
12827
12828 return getDerived().RebuildOpenACCShutdownConstruct(
12829 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12830 TransformedClauses);
12831}
12832template <typename Derived>
12835 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12836
12837 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12838 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12839 C->clauses());
12840 if (getSema().OpenACC().ActOnStartStmtDirective(
12841 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12842 return StmtError();
12843
12844 return getDerived().RebuildOpenACCSetConstruct(
12845 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12846 TransformedClauses);
12847}
12848
12849template <typename Derived>
12851 OpenACCUpdateConstruct *C) {
12852 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12853
12854 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12855 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12856 C->clauses());
12857 if (getSema().OpenACC().ActOnStartStmtDirective(
12858 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12859 return StmtError();
12860
12861 return getDerived().RebuildOpenACCUpdateConstruct(
12862 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12863 TransformedClauses);
12864}
12865
12866template <typename Derived>
12869 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12870
12871 ExprResult DevNumExpr;
12872 if (C->hasDevNumExpr()) {
12873 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
12874
12875 if (DevNumExpr.isUsable())
12876 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
12878 C->getBeginLoc(), DevNumExpr.get());
12879 }
12880
12881 llvm::SmallVector<Expr *> QueueIdExprs;
12882
12883 for (Expr *QE : C->getQueueIdExprs()) {
12884 assert(QE && "Null queue id expr?");
12885 ExprResult NewEQ = getDerived().TransformExpr(QE);
12886
12887 if (!NewEQ.isUsable())
12888 break;
12889 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
12891 C->getBeginLoc(), NewEQ.get());
12892 if (NewEQ.isUsable())
12893 QueueIdExprs.push_back(NewEQ.get());
12894 }
12895
12896 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12897 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12898 C->clauses());
12899
12900 if (getSema().OpenACC().ActOnStartStmtDirective(
12901 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12902 return StmtError();
12903
12904 return getDerived().RebuildOpenACCWaitConstruct(
12905 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12906 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
12907 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
12908}
12909template <typename Derived>
12911 OpenACCCacheConstruct *C) {
12912 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12913
12914 llvm::SmallVector<Expr *> TransformedVarList;
12915 for (Expr *Var : C->getVarList()) {
12916 assert(Var && "Null var listexpr?");
12917
12918 ExprResult NewVar = getDerived().TransformExpr(Var);
12919
12920 if (!NewVar.isUsable())
12921 break;
12922
12923 NewVar = getSema().OpenACC().ActOnVar(
12924 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
12925 if (!NewVar.isUsable())
12926 break;
12927
12928 TransformedVarList.push_back(NewVar.get());
12929 }
12930
12931 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
12932 C->getBeginLoc(), {}))
12933 return StmtError();
12934
12935 return getDerived().RebuildOpenACCCacheConstruct(
12936 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12937 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
12938 C->getEndLoc());
12939}
12940
12941template <typename Derived>
12943 OpenACCAtomicConstruct *C) {
12944 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12945
12946 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12947 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12948 C->clauses());
12949
12950 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
12951 C->getBeginLoc(), {}))
12952 return StmtError();
12953
12954 // Transform Associated Stmt.
12955 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12956 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
12957
12958 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
12959 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
12960 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
12961 AssocStmt);
12962
12963 return getDerived().RebuildOpenACCAtomicConstruct(
12964 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
12965 C->getEndLoc(), TransformedClauses, AssocStmt);
12966}
12967
12968template <typename Derived>
12971 if (getDerived().AlwaysRebuild())
12972 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
12973 // Nothing can ever change, so there is never anything to transform.
12974 return E;
12975}
12976
12977//===----------------------------------------------------------------------===//
12978// Expression transformation
12979//===----------------------------------------------------------------------===//
12980template<typename Derived>
12983 return TransformExpr(E->getSubExpr());
12984}
12985
12986template <typename Derived>
12989 if (!E->isTypeDependent())
12990 return E;
12991
12992 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
12993
12994 if (!NewT)
12995 return ExprError();
12996
12997 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
12998 return E;
12999
13000 return getDerived().RebuildSYCLUniqueStableNameExpr(
13001 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
13002}
13003
13004template<typename Derived>
13007 if (!E->isTypeDependent())
13008 return E;
13009
13010 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13011 E->getIdentKind());
13012}
13013
13014template<typename Derived>
13017 NestedNameSpecifierLoc QualifierLoc;
13018 if (E->getQualifierLoc()) {
13019 QualifierLoc
13020 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13021 if (!QualifierLoc)
13022 return ExprError();
13023 }
13024
13025 ValueDecl *ND
13026 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13027 E->getDecl()));
13028 if (!ND || ND->isInvalidDecl())
13029 return ExprError();
13030
13031 NamedDecl *Found = ND;
13032 if (E->getFoundDecl() != E->getDecl()) {
13033 Found = cast_or_null<NamedDecl>(
13034 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13035 if (!Found)
13036 return ExprError();
13037 }
13038
13039 DeclarationNameInfo NameInfo = E->getNameInfo();
13040 if (NameInfo.getName()) {
13041 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13042 if (!NameInfo.getName())
13043 return ExprError();
13044 }
13045
13046 if (!getDerived().AlwaysRebuild() &&
13047 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13048 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13049 Found == E->getFoundDecl() &&
13050 NameInfo.getName() == E->getDecl()->getDeclName() &&
13051 !E->hasExplicitTemplateArgs()) {
13052
13053 // Mark it referenced in the new context regardless.
13054 // FIXME: this is a bit instantiation-specific.
13055 SemaRef.MarkDeclRefReferenced(E);
13056
13057 return E;
13058 }
13059
13060 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13061 if (E->hasExplicitTemplateArgs()) {
13062 TemplateArgs = &TransArgs;
13063 TransArgs.setLAngleLoc(E->getLAngleLoc());
13064 TransArgs.setRAngleLoc(E->getRAngleLoc());
13065 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13066 E->getNumTemplateArgs(),
13067 TransArgs))
13068 return ExprError();
13069 }
13070
13071 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13072 Found, TemplateArgs);
13073}
13074
13075template<typename Derived>
13078 return E;
13079}
13080
13081template <typename Derived>
13083 FixedPointLiteral *E) {
13084 return E;
13085}
13086
13087template<typename Derived>
13090 return E;
13091}
13092
13093template<typename Derived>
13096 return E;
13097}
13098
13099template<typename Derived>
13102 return E;
13103}
13104
13105template<typename Derived>
13108 return E;
13109}
13110
13111template<typename Derived>
13114 return getDerived().TransformCallExpr(E);
13115}
13116
13117template<typename Derived>
13120 ExprResult ControllingExpr;
13121 TypeSourceInfo *ControllingType = nullptr;
13122 if (E->isExprPredicate())
13123 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13124 else
13125 ControllingType = getDerived().TransformType(E->getControllingType());
13126
13127 if (ControllingExpr.isInvalid() && !ControllingType)
13128 return ExprError();
13129
13130 SmallVector<Expr *, 4> AssocExprs;
13132 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13133 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13134 if (TSI) {
13135 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13136 if (!AssocType)
13137 return ExprError();
13138 AssocTypes.push_back(AssocType);
13139 } else {
13140 AssocTypes.push_back(nullptr);
13141 }
13142
13143 ExprResult AssocExpr =
13144 getDerived().TransformExpr(Assoc.getAssociationExpr());
13145 if (AssocExpr.isInvalid())
13146 return ExprError();
13147 AssocExprs.push_back(AssocExpr.get());
13148 }
13149
13150 if (!ControllingType)
13151 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13152 E->getDefaultLoc(),
13153 E->getRParenLoc(),
13154 ControllingExpr.get(),
13155 AssocTypes,
13156 AssocExprs);
13157 return getDerived().RebuildGenericSelectionExpr(
13158 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13159 ControllingType, AssocTypes, AssocExprs);
13160}
13161
13162template<typename Derived>
13165 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13166 if (SubExpr.isInvalid())
13167 return ExprError();
13168
13169 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13170 return E;
13171
13172 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13173 E->getRParen());
13174}
13175
13176/// The operand of a unary address-of operator has special rules: it's
13177/// allowed to refer to a non-static member of a class even if there's no 'this'
13178/// object available.
13179template<typename Derived>
13182 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13183 return getDerived().TransformDependentScopeDeclRefExpr(
13184 DRE, /*IsAddressOfOperand=*/true, nullptr);
13185 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13186 return getDerived().TransformUnresolvedLookupExpr(
13187 ULE, /*IsAddressOfOperand=*/true);
13188 else
13189 return getDerived().TransformExpr(E);
13190}
13191
13192template<typename Derived>
13195 ExprResult SubExpr;
13196 if (E->getOpcode() == UO_AddrOf)
13197 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13198 else
13199 SubExpr = TransformExpr(E->getSubExpr());
13200 if (SubExpr.isInvalid())
13201 return ExprError();
13202
13203 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13204 return E;
13205
13206 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13207 E->getOpcode(),
13208 SubExpr.get());
13209}
13210
13211template<typename Derived>
13213TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13214 // Transform the type.
13215 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13216 if (!Type)
13217 return ExprError();
13218
13219 // Transform all of the components into components similar to what the
13220 // parser uses.
13221 // FIXME: It would be slightly more efficient in the non-dependent case to
13222 // just map FieldDecls, rather than requiring the rebuilder to look for
13223 // the fields again. However, __builtin_offsetof is rare enough in
13224 // template code that we don't care.
13225 bool ExprChanged = false;
13226 typedef Sema::OffsetOfComponent Component;
13227 SmallVector<Component, 4> Components;
13228 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13229 const OffsetOfNode &ON = E->getComponent(I);
13230 Component Comp;
13231 Comp.isBrackets = true;
13232 Comp.LocStart = ON.getSourceRange().getBegin();
13233 Comp.LocEnd = ON.getSourceRange().getEnd();
13234 switch (ON.getKind()) {
13235 case OffsetOfNode::Array: {
13236 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13237 ExprResult Index = getDerived().TransformExpr(FromIndex);
13238 if (Index.isInvalid())
13239 return ExprError();
13240
13241 ExprChanged = ExprChanged || Index.get() != FromIndex;
13242 Comp.isBrackets = true;
13243 Comp.U.E = Index.get();
13244 break;
13245 }
13246
13249 Comp.isBrackets = false;
13250 Comp.U.IdentInfo = ON.getFieldName();
13251 if (!Comp.U.IdentInfo)
13252 continue;
13253
13254 break;
13255
13256 case OffsetOfNode::Base:
13257 // Will be recomputed during the rebuild.
13258 continue;
13259 }
13260
13261 Components.push_back(Comp);
13262 }
13263
13264 // If nothing changed, retain the existing expression.
13265 if (!getDerived().AlwaysRebuild() &&
13266 Type == E->getTypeSourceInfo() &&
13267 !ExprChanged)
13268 return E;
13269
13270 // Build a new offsetof expression.
13271 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13272 Components, E->getRParenLoc());
13273}
13274
13275template<typename Derived>
13278 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13279 "opaque value expression requires transformation");
13280 return E;
13281}
13282
13283template <typename Derived>
13286 bool Changed = false;
13287 for (Expr *C : E->subExpressions()) {
13288 ExprResult NewC = getDerived().TransformExpr(C);
13289 if (NewC.isInvalid())
13290 return ExprError();
13291 Children.push_back(NewC.get());
13292
13293 Changed |= NewC.get() != C;
13294 }
13295 if (!getDerived().AlwaysRebuild() && !Changed)
13296 return E;
13297 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13298 Children, E->getType());
13299}
13300
13301template<typename Derived>
13304 // Rebuild the syntactic form. The original syntactic form has
13305 // opaque-value expressions in it, so strip those away and rebuild
13306 // the result. This is a really awful way of doing this, but the
13307 // better solution (rebuilding the semantic expressions and
13308 // rebinding OVEs as necessary) doesn't work; we'd need
13309 // TreeTransform to not strip away implicit conversions.
13310 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13311 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13312 if (result.isInvalid()) return ExprError();
13313
13314 // If that gives us a pseudo-object result back, the pseudo-object
13315 // expression must have been an lvalue-to-rvalue conversion which we
13316 // should reapply.
13317 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13318 result = SemaRef.PseudoObject().checkRValue(result.get());
13319
13320 return result;
13321}
13322
13323template<typename Derived>
13327 if (E->isArgumentType()) {
13328 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13329
13330 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13331 if (!NewT)
13332 return ExprError();
13333
13334 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13335 return E;
13336
13337 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13338 E->getKind(),
13339 E->getSourceRange());
13340 }
13341
13342 // C++0x [expr.sizeof]p1:
13343 // The operand is either an expression, which is an unevaluated operand
13344 // [...]
13348
13349 // Try to recover if we have something like sizeof(T::X) where X is a type.
13350 // Notably, there must be *exactly* one set of parens if X is a type.
13351 TypeSourceInfo *RecoveryTSI = nullptr;
13352 ExprResult SubExpr;
13353 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13354 if (auto *DRE =
13355 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13356 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13357 PE, DRE, false, &RecoveryTSI);
13358 else
13359 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13360
13361 if (RecoveryTSI) {
13362 return getDerived().RebuildUnaryExprOrTypeTrait(
13363 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13364 } else if (SubExpr.isInvalid())
13365 return ExprError();
13366
13367 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13368 return E;
13369
13370 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13371 E->getOperatorLoc(),
13372 E->getKind(),
13373 E->getSourceRange());
13374}
13375
13376template<typename Derived>
13379 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13380 if (LHS.isInvalid())
13381 return ExprError();
13382
13383 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13384 if (RHS.isInvalid())
13385 return ExprError();
13386
13387
13388 if (!getDerived().AlwaysRebuild() &&
13389 LHS.get() == E->getLHS() &&
13390 RHS.get() == E->getRHS())
13391 return E;
13392
13393 return getDerived().RebuildArraySubscriptExpr(
13394 LHS.get(),
13395 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13396}
13397
13398template <typename Derived>
13401 ExprResult Base = getDerived().TransformExpr(E->getBase());
13402 if (Base.isInvalid())
13403 return ExprError();
13404
13405 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13406 if (RowIdx.isInvalid())
13407 return ExprError();
13408
13409 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13410 if (ColumnIdx.isInvalid())
13411 return ExprError();
13412
13413 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13414 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13415 return E;
13416
13417 return getDerived().RebuildMatrixSubscriptExpr(
13418 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13419}
13420
13421template <typename Derived>
13424 ExprResult Base = getDerived().TransformExpr(E->getBase());
13425 if (Base.isInvalid())
13426 return ExprError();
13427
13428 ExprResult LowerBound;
13429 if (E->getLowerBound()) {
13430 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13431 if (LowerBound.isInvalid())
13432 return ExprError();
13433 }
13434
13435 ExprResult Length;
13436 if (E->getLength()) {
13437 Length = getDerived().TransformExpr(E->getLength());
13438 if (Length.isInvalid())
13439 return ExprError();
13440 }
13441
13442 ExprResult Stride;
13443 if (E->isOMPArraySection()) {
13444 if (Expr *Str = E->getStride()) {
13445 Stride = getDerived().TransformExpr(Str);
13446 if (Stride.isInvalid())
13447 return ExprError();
13448 }
13449 }
13450
13451 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13452 LowerBound.get() == E->getLowerBound() &&
13453 Length.get() == E->getLength() &&
13454 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13455 return E;
13456
13457 return getDerived().RebuildArraySectionExpr(
13458 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13459 LowerBound.get(), E->getColonLocFirst(),
13460 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13461 Length.get(), Stride.get(), E->getRBracketLoc());
13462}
13463
13464template <typename Derived>
13467 ExprResult Base = getDerived().TransformExpr(E->getBase());
13468 if (Base.isInvalid())
13469 return ExprError();
13470
13472 bool ErrorFound = false;
13473 for (Expr *Dim : E->getDimensions()) {
13474 ExprResult DimRes = getDerived().TransformExpr(Dim);
13475 if (DimRes.isInvalid()) {
13476 ErrorFound = true;
13477 continue;
13478 }
13479 Dims.push_back(DimRes.get());
13480 }
13481
13482 if (ErrorFound)
13483 return ExprError();
13484 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13485 E->getRParenLoc(), Dims,
13486 E->getBracketsRanges());
13487}
13488
13489template <typename Derived>
13492 unsigned NumIterators = E->numOfIterators();
13494
13495 bool ErrorFound = false;
13496 bool NeedToRebuild = getDerived().AlwaysRebuild();
13497 for (unsigned I = 0; I < NumIterators; ++I) {
13498 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13499 Data[I].DeclIdent = D->getIdentifier();
13500 Data[I].DeclIdentLoc = D->getLocation();
13501 if (D->getLocation() == D->getBeginLoc()) {
13502 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13503 "Implicit type must be int.");
13504 } else {
13505 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13506 QualType DeclTy = getDerived().TransformType(D->getType());
13507 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13508 }
13509 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13510 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13511 ExprResult End = getDerived().TransformExpr(Range.End);
13512 ExprResult Step = getDerived().TransformExpr(Range.Step);
13513 ErrorFound = ErrorFound ||
13514 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13515 !Data[I].Type.get().isNull())) ||
13516 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13517 if (ErrorFound)
13518 continue;
13519 Data[I].Range.Begin = Begin.get();
13520 Data[I].Range.End = End.get();
13521 Data[I].Range.Step = Step.get();
13522 Data[I].AssignLoc = E->getAssignLoc(I);
13523 Data[I].ColonLoc = E->getColonLoc(I);
13524 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13525 NeedToRebuild =
13526 NeedToRebuild ||
13527 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13528 D->getType().getTypePtrOrNull()) ||
13529 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13530 Range.Step != Data[I].Range.Step;
13531 }
13532 if (ErrorFound)
13533 return ExprError();
13534 if (!NeedToRebuild)
13535 return E;
13536
13537 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13538 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13539 if (!Res.isUsable())
13540 return Res;
13541 auto *IE = cast<OMPIteratorExpr>(Res.get());
13542 for (unsigned I = 0; I < NumIterators; ++I)
13543 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13544 IE->getIteratorDecl(I));
13545 return Res;
13546}
13547
13548template<typename Derived>
13551 // Transform the callee.
13552 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13553 if (Callee.isInvalid())
13554 return ExprError();
13555
13556 // Transform arguments.
13557 bool ArgChanged = false;
13559 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13560 &ArgChanged))
13561 return ExprError();
13562
13563 if (!getDerived().AlwaysRebuild() &&
13564 Callee.get() == E->getCallee() &&
13565 !ArgChanged)
13566 return SemaRef.MaybeBindToTemporary(E);
13567
13568 // FIXME: Wrong source location information for the '('.
13569 SourceLocation FakeLParenLoc
13570 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13571
13572 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13573 if (E->hasStoredFPFeatures()) {
13574 FPOptionsOverride NewOverrides = E->getFPFeatures();
13575 getSema().CurFPFeatures =
13576 NewOverrides.applyOverrides(getSema().getLangOpts());
13577 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13578 }
13579
13580 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13581 Args,
13582 E->getRParenLoc());
13583}
13584
13585template<typename Derived>
13588 ExprResult Base = getDerived().TransformExpr(E->getBase());
13589 if (Base.isInvalid())
13590 return ExprError();
13591
13592 NestedNameSpecifierLoc QualifierLoc;
13593 if (E->hasQualifier()) {
13594 QualifierLoc
13595 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13596
13597 if (!QualifierLoc)
13598 return ExprError();
13599 }
13600 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13601
13603 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13604 E->getMemberDecl()));
13605 if (!Member)
13606 return ExprError();
13607
13608 NamedDecl *FoundDecl = E->getFoundDecl();
13609 if (FoundDecl == E->getMemberDecl()) {
13610 FoundDecl = Member;
13611 } else {
13612 FoundDecl = cast_or_null<NamedDecl>(
13613 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13614 if (!FoundDecl)
13615 return ExprError();
13616 }
13617
13618 if (!getDerived().AlwaysRebuild() &&
13619 Base.get() == E->getBase() &&
13620 QualifierLoc == E->getQualifierLoc() &&
13621 Member == E->getMemberDecl() &&
13622 FoundDecl == E->getFoundDecl() &&
13623 !E->hasExplicitTemplateArgs()) {
13624
13625 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13626 // for Openmp where the field need to be privatizized in the case.
13627 if (!(isa<CXXThisExpr>(E->getBase()) &&
13628 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13630 // Mark it referenced in the new context regardless.
13631 // FIXME: this is a bit instantiation-specific.
13632 SemaRef.MarkMemberReferenced(E);
13633 return E;
13634 }
13635 }
13636
13637 TemplateArgumentListInfo TransArgs;
13638 if (E->hasExplicitTemplateArgs()) {
13639 TransArgs.setLAngleLoc(E->getLAngleLoc());
13640 TransArgs.setRAngleLoc(E->getRAngleLoc());
13641 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13642 E->getNumTemplateArgs(),
13643 TransArgs))
13644 return ExprError();
13645 }
13646
13647 // FIXME: Bogus source location for the operator
13648 SourceLocation FakeOperatorLoc =
13649 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13650
13651 // FIXME: to do this check properly, we will need to preserve the
13652 // first-qualifier-in-scope here, just in case we had a dependent
13653 // base (and therefore couldn't do the check) and a
13654 // nested-name-qualifier (and therefore could do the lookup).
13655 NamedDecl *FirstQualifierInScope = nullptr;
13656 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13657 if (MemberNameInfo.getName()) {
13658 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13659 if (!MemberNameInfo.getName())
13660 return ExprError();
13661 }
13662
13663 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13664 E->isArrow(),
13665 QualifierLoc,
13666 TemplateKWLoc,
13667 MemberNameInfo,
13668 Member,
13669 FoundDecl,
13670 (E->hasExplicitTemplateArgs()
13671 ? &TransArgs : nullptr),
13672 FirstQualifierInScope);
13673}
13674
13675template<typename Derived>
13678 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13679 if (LHS.isInvalid())
13680 return ExprError();
13681
13682 ExprResult RHS =
13683 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13684 if (RHS.isInvalid())
13685 return ExprError();
13686
13687 if (!getDerived().AlwaysRebuild() &&
13688 LHS.get() == E->getLHS() &&
13689 RHS.get() == E->getRHS())
13690 return E;
13691
13692 if (E->isCompoundAssignmentOp())
13693 // FPFeatures has already been established from trailing storage
13694 return getDerived().RebuildBinaryOperator(
13695 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13696 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13697 FPOptionsOverride NewOverrides(E->getFPFeatures());
13698 getSema().CurFPFeatures =
13699 NewOverrides.applyOverrides(getSema().getLangOpts());
13700 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13701 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13702 LHS.get(), RHS.get());
13703}
13704
13705template <typename Derived>
13708 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13709
13710 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13711 if (LHS.isInvalid())
13712 return ExprError();
13713
13714 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13715 if (RHS.isInvalid())
13716 return ExprError();
13717
13718 // Extract the already-resolved callee declarations so that we can restrict
13719 // ourselves to using them as the unqualified lookup results when rebuilding.
13720 UnresolvedSet<2> UnqualLookups;
13721 bool ChangedAnyLookups = false;
13722 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13723 const_cast<Expr *>(Decomp.InnerBinOp)};
13724 for (Expr *PossibleBinOp : PossibleBinOps) {
13725 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13726 if (!Op)
13727 continue;
13728 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13729 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13730 continue;
13731
13732 // Transform the callee in case we built a call to a local extern
13733 // declaration.
13734 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13735 E->getOperatorLoc(), Callee->getFoundDecl()));
13736 if (!Found)
13737 return ExprError();
13738 if (Found != Callee->getFoundDecl())
13739 ChangedAnyLookups = true;
13740 UnqualLookups.addDecl(Found);
13741 }
13742
13743 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13744 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13745 // Mark all functions used in the rewrite as referenced. Note that when
13746 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13747 // function calls, and/or there might be a user-defined conversion sequence
13748 // applied to the operands of the <.
13749 // FIXME: this is a bit instantiation-specific.
13750 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13751 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13752 return E;
13753 }
13754
13755 return getDerived().RebuildCXXRewrittenBinaryOperator(
13756 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13757}
13758
13759template<typename Derived>
13763 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13764 FPOptionsOverride NewOverrides(E->getFPFeatures());
13765 getSema().CurFPFeatures =
13766 NewOverrides.applyOverrides(getSema().getLangOpts());
13767 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13768 return getDerived().TransformBinaryOperator(E);
13769}
13770
13771template<typename Derived>
13774 // Just rebuild the common and RHS expressions and see whether we
13775 // get any changes.
13776
13777 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13778 if (commonExpr.isInvalid())
13779 return ExprError();
13780
13781 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13782 if (rhs.isInvalid())
13783 return ExprError();
13784
13785 if (!getDerived().AlwaysRebuild() &&
13786 commonExpr.get() == e->getCommon() &&
13787 rhs.get() == e->getFalseExpr())
13788 return e;
13789
13790 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13791 e->getQuestionLoc(),
13792 nullptr,
13793 e->getColonLoc(),
13794 rhs.get());
13795}
13796
13797template<typename Derived>
13800 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13801 if (Cond.isInvalid())
13802 return ExprError();
13803
13804 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13805 if (LHS.isInvalid())
13806 return ExprError();
13807
13808 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13809 if (RHS.isInvalid())
13810 return ExprError();
13811
13812 if (!getDerived().AlwaysRebuild() &&
13813 Cond.get() == E->getCond() &&
13814 LHS.get() == E->getLHS() &&
13815 RHS.get() == E->getRHS())
13816 return E;
13817
13818 return getDerived().RebuildConditionalOperator(Cond.get(),
13819 E->getQuestionLoc(),
13820 LHS.get(),
13821 E->getColonLoc(),
13822 RHS.get());
13823}
13824
13825template<typename Derived>
13828 // Implicit casts are eliminated during transformation, since they
13829 // will be recomputed by semantic analysis after transformation.
13830 return getDerived().TransformExpr(E->getSubExprAsWritten());
13831}
13832
13833template<typename Derived>
13836 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
13837 if (!Type)
13838 return ExprError();
13839
13840 ExprResult SubExpr
13841 = getDerived().TransformExpr(E->getSubExprAsWritten());
13842 if (SubExpr.isInvalid())
13843 return ExprError();
13844
13845 if (!getDerived().AlwaysRebuild() &&
13846 Type == E->getTypeInfoAsWritten() &&
13847 SubExpr.get() == E->getSubExpr())
13848 return E;
13849
13850 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
13851 Type,
13852 E->getRParenLoc(),
13853 SubExpr.get());
13854}
13855
13856template<typename Derived>
13859 TypeSourceInfo *OldT = E->getTypeSourceInfo();
13860 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13861 if (!NewT)
13862 return ExprError();
13863
13864 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
13865 if (Init.isInvalid())
13866 return ExprError();
13867
13868 if (!getDerived().AlwaysRebuild() &&
13869 OldT == NewT &&
13870 Init.get() == E->getInitializer())
13871 return SemaRef.MaybeBindToTemporary(E);
13872
13873 // Note: the expression type doesn't necessarily match the
13874 // type-as-written, but that's okay, because it should always be
13875 // derivable from the initializer.
13876
13877 return getDerived().RebuildCompoundLiteralExpr(
13878 E->getLParenLoc(), NewT,
13879 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
13880}
13881
13882template<typename Derived>
13885 ExprResult Base = getDerived().TransformExpr(E->getBase());
13886 if (Base.isInvalid())
13887 return ExprError();
13888
13889 if (!getDerived().AlwaysRebuild() &&
13890 Base.get() == E->getBase())
13891 return E;
13892
13893 // FIXME: Bad source location
13894 SourceLocation FakeOperatorLoc =
13895 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
13896 return getDerived().RebuildExtVectorElementExpr(
13897 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
13898 E->getAccessor());
13899}
13900
13901template<typename Derived>
13904 if (InitListExpr *Syntactic = E->getSyntacticForm())
13905 E = Syntactic;
13906
13907 bool InitChanged = false;
13908
13911
13913 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
13914 Inits, &InitChanged))
13915 return ExprError();
13916
13917 if (!getDerived().AlwaysRebuild() && !InitChanged) {
13918 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
13919 // in some cases. We can't reuse it in general, because the syntactic and
13920 // semantic forms are linked, and we can't know that semantic form will
13921 // match even if the syntactic form does.
13922 }
13923
13924 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
13925 E->getRBraceLoc());
13926}
13927
13928template<typename Derived>
13931 Designation Desig;
13932
13933 // transform the initializer value
13934 ExprResult Init = getDerived().TransformExpr(E->getInit());
13935 if (Init.isInvalid())
13936 return ExprError();
13937
13938 // transform the designators.
13939 SmallVector<Expr*, 4> ArrayExprs;
13940 bool ExprChanged = false;
13941 for (const DesignatedInitExpr::Designator &D : E->designators()) {
13942 if (D.isFieldDesignator()) {
13943 if (D.getFieldDecl()) {
13944 FieldDecl *Field = cast_or_null<FieldDecl>(
13945 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
13946 if (Field != D.getFieldDecl())
13947 // Rebuild the expression when the transformed FieldDecl is
13948 // different to the already assigned FieldDecl.
13949 ExprChanged = true;
13950 if (Field->isAnonymousStructOrUnion())
13951 continue;
13952 } else {
13953 // Ensure that the designator expression is rebuilt when there isn't
13954 // a resolved FieldDecl in the designator as we don't want to assign
13955 // a FieldDecl to a pattern designator that will be instantiated again.
13956 ExprChanged = true;
13957 }
13958 Desig.AddDesignator(Designator::CreateFieldDesignator(
13959 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
13960 continue;
13961 }
13962
13963 if (D.isArrayDesignator()) {
13964 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
13965 if (Index.isInvalid())
13966 return ExprError();
13967
13968 Desig.AddDesignator(
13969 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
13970
13971 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
13972 ArrayExprs.push_back(Index.get());
13973 continue;
13974 }
13975
13976 assert(D.isArrayRangeDesignator() && "New kind of designator?");
13977 ExprResult Start
13978 = getDerived().TransformExpr(E->getArrayRangeStart(D));
13979 if (Start.isInvalid())
13980 return ExprError();
13981
13982 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
13983 if (End.isInvalid())
13984 return ExprError();
13985
13986 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
13987 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
13988
13989 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
13990 End.get() != E->getArrayRangeEnd(D);
13991
13992 ArrayExprs.push_back(Start.get());
13993 ArrayExprs.push_back(End.get());
13994 }
13995
13996 if (!getDerived().AlwaysRebuild() &&
13997 Init.get() == E->getInit() &&
13998 !ExprChanged)
13999 return E;
14000
14001 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14002 E->getEqualOrColonLoc(),
14003 E->usesGNUSyntax(), Init.get());
14004}
14005
14006// Seems that if TransformInitListExpr() only works on the syntactic form of an
14007// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14008template<typename Derived>
14012 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14013 "initializer");
14014 return ExprError();
14015}
14016
14017template<typename Derived>
14020 NoInitExpr *E) {
14021 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14022 return ExprError();
14023}
14024
14025template<typename Derived>
14028 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14029 return ExprError();
14030}
14031
14032template<typename Derived>
14035 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14036 return ExprError();
14037}
14038
14039template<typename Derived>
14043 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14044
14045 // FIXME: Will we ever have proper type location here? Will we actually
14046 // need to transform the type?
14047 QualType T = getDerived().TransformType(E->getType());
14048 if (T.isNull())
14049 return ExprError();
14050
14051 if (!getDerived().AlwaysRebuild() &&
14052 T == E->getType())
14053 return E;
14054
14055 return getDerived().RebuildImplicitValueInitExpr(T);
14056}
14057
14058template<typename Derived>
14061 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14062 if (!TInfo)
14063 return ExprError();
14064
14065 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14066 if (SubExpr.isInvalid())
14067 return ExprError();
14068
14069 if (!getDerived().AlwaysRebuild() &&
14070 TInfo == E->getWrittenTypeInfo() &&
14071 SubExpr.get() == E->getSubExpr())
14072 return E;
14073
14074 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14075 TInfo, E->getRParenLoc());
14076}
14077
14078template<typename Derived>
14081 bool ArgumentChanged = false;
14083 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14084 &ArgumentChanged))
14085 return ExprError();
14086
14087 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14088 Inits,
14089 E->getRParenLoc());
14090}
14091
14092/// Transform an address-of-label expression.
14093///
14094/// By default, the transformation of an address-of-label expression always
14095/// rebuilds the expression, so that the label identifier can be resolved to
14096/// the corresponding label statement by semantic analysis.
14097template<typename Derived>
14100 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14101 E->getLabel());
14102 if (!LD)
14103 return ExprError();
14104
14105 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14106 cast<LabelDecl>(LD));
14107}
14108
14109template<typename Derived>
14112 SemaRef.ActOnStartStmtExpr();
14113 StmtResult SubStmt
14114 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14115 if (SubStmt.isInvalid()) {
14116 SemaRef.ActOnStmtExprError();
14117 return ExprError();
14118 }
14119
14120 unsigned OldDepth = E->getTemplateDepth();
14121 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14122
14123 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14124 SubStmt.get() == E->getSubStmt()) {
14125 // Calling this an 'error' is unintuitive, but it does the right thing.
14126 SemaRef.ActOnStmtExprError();
14127 return SemaRef.MaybeBindToTemporary(E);
14128 }
14129
14130 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14131 E->getRParenLoc(), NewDepth);
14132}
14133
14134template<typename Derived>
14137 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14138 if (Cond.isInvalid())
14139 return ExprError();
14140
14141 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14142 if (LHS.isInvalid())
14143 return ExprError();
14144
14145 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14146 if (RHS.isInvalid())
14147 return ExprError();
14148
14149 if (!getDerived().AlwaysRebuild() &&
14150 Cond.get() == E->getCond() &&
14151 LHS.get() == E->getLHS() &&
14152 RHS.get() == E->getRHS())
14153 return E;
14154
14155 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14156 Cond.get(), LHS.get(), RHS.get(),
14157 E->getRParenLoc());
14158}
14159
14160template<typename Derived>
14163 return E;
14164}
14165
14166template<typename Derived>
14169 switch (E->getOperator()) {
14170 case OO_New:
14171 case OO_Delete:
14172 case OO_Array_New:
14173 case OO_Array_Delete:
14174 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14175
14176 case OO_Subscript:
14177 case OO_Call: {
14178 // This is a call to an object's operator().
14179 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14180
14181 // Transform the object itself.
14182 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14183 if (Object.isInvalid())
14184 return ExprError();
14185
14186 // FIXME: Poor location information. Also, if the location for the end of
14187 // the token is within a macro expansion, getLocForEndOfToken() will return
14188 // an invalid source location. If that happens and we have an otherwise
14189 // valid end location, use the valid one instead of the invalid one.
14190 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14191 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14192 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14193 FakeLParenLoc = EndLoc;
14194
14195 // Transform the call arguments.
14197 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14198 Args))
14199 return ExprError();
14200
14201 if (E->getOperator() == OO_Subscript)
14202 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14203 Args, E->getEndLoc());
14204
14205 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14206 E->getEndLoc());
14207 }
14208
14209#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14210 case OO_##Name: \
14211 break;
14212
14213#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14214#include "clang/Basic/OperatorKinds.def"
14215
14216 case OO_Conditional:
14217 llvm_unreachable("conditional operator is not actually overloadable");
14218
14219 case OO_None:
14221 llvm_unreachable("not an overloaded operator?");
14222 }
14223
14225 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14226 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14227 else
14228 First = getDerived().TransformExpr(E->getArg(0));
14229 if (First.isInvalid())
14230 return ExprError();
14231
14232 ExprResult Second;
14233 if (E->getNumArgs() == 2) {
14234 Second =
14235 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14236 if (Second.isInvalid())
14237 return ExprError();
14238 }
14239
14240 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14241 FPOptionsOverride NewOverrides(E->getFPFeatures());
14242 getSema().CurFPFeatures =
14243 NewOverrides.applyOverrides(getSema().getLangOpts());
14244 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14245
14246 Expr *Callee = E->getCallee();
14247 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14248 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14250 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14251 return ExprError();
14252
14253 return getDerived().RebuildCXXOperatorCallExpr(
14254 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14255 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14256 }
14257
14258 UnresolvedSet<1> Functions;
14259 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14260 Callee = ICE->getSubExprAsWritten();
14261 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14262 ValueDecl *VD = cast_or_null<ValueDecl>(
14263 getDerived().TransformDecl(DR->getLocation(), DR));
14264 if (!VD)
14265 return ExprError();
14266
14267 if (!isa<CXXMethodDecl>(VD))
14268 Functions.addDecl(VD);
14269
14270 return getDerived().RebuildCXXOperatorCallExpr(
14271 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14272 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14273}
14274
14275template<typename Derived>
14278 return getDerived().TransformCallExpr(E);
14279}
14280
14281template <typename Derived>
14283 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14284 getSema().CurContext != E->getParentContext();
14285
14286 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14287 return E;
14288
14289 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14290 E->getBeginLoc(), E->getEndLoc(),
14291 getSema().CurContext);
14292}
14293
14294template <typename Derived>
14296 return E;
14297}
14298
14299template<typename Derived>
14302 // Transform the callee.
14303 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14304 if (Callee.isInvalid())
14305 return ExprError();
14306
14307 // Transform exec config.
14308 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14309 if (EC.isInvalid())
14310 return ExprError();
14311
14312 // Transform arguments.
14313 bool ArgChanged = false;
14315 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14316 &ArgChanged))
14317 return ExprError();
14318
14319 if (!getDerived().AlwaysRebuild() &&
14320 Callee.get() == E->getCallee() &&
14321 !ArgChanged)
14322 return SemaRef.MaybeBindToTemporary(E);
14323
14324 // FIXME: Wrong source location information for the '('.
14325 SourceLocation FakeLParenLoc
14326 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14327 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14328 Args,
14329 E->getRParenLoc(), EC.get());
14330}
14331
14332template<typename Derived>
14335 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14336 if (!Type)
14337 return ExprError();
14338
14339 ExprResult SubExpr
14340 = getDerived().TransformExpr(E->getSubExprAsWritten());
14341 if (SubExpr.isInvalid())
14342 return ExprError();
14343
14344 if (!getDerived().AlwaysRebuild() &&
14345 Type == E->getTypeInfoAsWritten() &&
14346 SubExpr.get() == E->getSubExpr())
14347 return E;
14348 return getDerived().RebuildCXXNamedCastExpr(
14351 // FIXME. this should be '(' location
14352 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14353}
14354
14355template<typename Derived>
14358 TypeSourceInfo *TSI =
14359 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14360 if (!TSI)
14361 return ExprError();
14362
14363 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14364 if (Sub.isInvalid())
14365 return ExprError();
14366
14367 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14368 Sub.get(), BCE->getEndLoc());
14369}
14370
14371template<typename Derived>
14373TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14374 return getDerived().TransformCXXNamedCastExpr(E);
14375}
14376
14377template<typename Derived>
14380 return getDerived().TransformCXXNamedCastExpr(E);
14381}
14382
14383template<typename Derived>
14387 return getDerived().TransformCXXNamedCastExpr(E);
14388}
14389
14390template<typename Derived>
14393 return getDerived().TransformCXXNamedCastExpr(E);
14394}
14395
14396template<typename Derived>
14399 return getDerived().TransformCXXNamedCastExpr(E);
14400}
14401
14402template<typename Derived>
14407 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14408 if (!Type)
14409 return ExprError();
14410
14411 ExprResult SubExpr
14412 = getDerived().TransformExpr(E->getSubExprAsWritten());
14413 if (SubExpr.isInvalid())
14414 return ExprError();
14415
14416 if (!getDerived().AlwaysRebuild() &&
14417 Type == E->getTypeInfoAsWritten() &&
14418 SubExpr.get() == E->getSubExpr())
14419 return E;
14420
14421 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14422 E->getLParenLoc(),
14423 SubExpr.get(),
14424 E->getRParenLoc(),
14425 E->isListInitialization());
14426}
14427
14428template<typename Derived>
14431 if (E->isTypeOperand()) {
14432 TypeSourceInfo *TInfo
14433 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14434 if (!TInfo)
14435 return ExprError();
14436
14437 if (!getDerived().AlwaysRebuild() &&
14438 TInfo == E->getTypeOperandSourceInfo())
14439 return E;
14440
14441 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14442 TInfo, E->getEndLoc());
14443 }
14444
14445 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14446 // type. We must not unilaterally enter unevaluated context here, as then
14447 // semantic processing can re-transform an already transformed operand.
14448 Expr *Op = E->getExprOperand();
14450 if (E->isGLValue())
14451 if (auto *RD = Op->getType()->getAsCXXRecordDecl();
14452 RD && RD->isPolymorphic())
14453 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14454
14457
14458 ExprResult SubExpr = getDerived().TransformExpr(Op);
14459 if (SubExpr.isInvalid())
14460 return ExprError();
14461
14462 if (!getDerived().AlwaysRebuild() &&
14463 SubExpr.get() == E->getExprOperand())
14464 return E;
14465
14466 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14467 SubExpr.get(), E->getEndLoc());
14468}
14469
14470template<typename Derived>
14473 if (E->isTypeOperand()) {
14474 TypeSourceInfo *TInfo
14475 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14476 if (!TInfo)
14477 return ExprError();
14478
14479 if (!getDerived().AlwaysRebuild() &&
14480 TInfo == E->getTypeOperandSourceInfo())
14481 return E;
14482
14483 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14484 TInfo, E->getEndLoc());
14485 }
14486
14489
14490 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14491 if (SubExpr.isInvalid())
14492 return ExprError();
14493
14494 if (!getDerived().AlwaysRebuild() &&
14495 SubExpr.get() == E->getExprOperand())
14496 return E;
14497
14498 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14499 SubExpr.get(), E->getEndLoc());
14500}
14501
14502template<typename Derived>
14505 return E;
14506}
14507
14508template<typename Derived>
14512 return E;
14513}
14514
14515template<typename Derived>
14518
14519 // In lambdas, the qualifiers of the type depends of where in
14520 // the call operator `this` appear, and we do not have a good way to
14521 // rebuild this information, so we transform the type.
14522 //
14523 // In other contexts, the type of `this` may be overrided
14524 // for type deduction, so we need to recompute it.
14525 //
14526 // Always recompute the type if we're in the body of a lambda, and
14527 // 'this' is dependent on a lambda's explicit object parameter; we
14528 // also need to always rebuild the expression in this case to clear
14529 // the flag.
14530 QualType T = [&]() {
14531 auto &S = getSema();
14532 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14533 return S.getCurrentThisType();
14534 if (S.getCurLambda())
14535 return getDerived().TransformType(E->getType());
14536 return S.getCurrentThisType();
14537 }();
14538
14539 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14540 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14541 // Mark it referenced in the new context regardless.
14542 // FIXME: this is a bit instantiation-specific.
14543 getSema().MarkThisReferenced(E);
14544 return E;
14545 }
14546
14547 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14548}
14549
14550template<typename Derived>
14553 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14554 if (SubExpr.isInvalid())
14555 return ExprError();
14556
14557 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14558
14559 if (!getDerived().AlwaysRebuild() &&
14560 SubExpr.get() == E->getSubExpr())
14561 return E;
14562
14563 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14564 E->isThrownVariableInScope());
14565}
14566
14567template<typename Derived>
14570 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14571 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14572 if (!Param)
14573 return ExprError();
14574
14575 ExprResult InitRes;
14576 if (E->hasRewrittenInit()) {
14577 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14578 if (InitRes.isInvalid())
14579 return ExprError();
14580 }
14581
14582 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14583 E->getUsedContext() == SemaRef.CurContext &&
14584 InitRes.get() == E->getRewrittenExpr())
14585 return E;
14586
14587 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14588 InitRes.get());
14589}
14590
14591template<typename Derived>
14594 FieldDecl *Field = cast_or_null<FieldDecl>(
14595 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14596 if (!Field)
14597 return ExprError();
14598
14599 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14600 E->getUsedContext() == SemaRef.CurContext)
14601 return E;
14602
14603 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14604}
14605
14606template<typename Derived>
14610 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14611 if (!T)
14612 return ExprError();
14613
14614 if (!getDerived().AlwaysRebuild() &&
14615 T == E->getTypeSourceInfo())
14616 return E;
14617
14618 return getDerived().RebuildCXXScalarValueInitExpr(T,
14619 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14620 E->getRParenLoc());
14621}
14622
14623template<typename Derived>
14626 // Transform the type that we're allocating
14627 TypeSourceInfo *AllocTypeInfo =
14628 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14629 if (!AllocTypeInfo)
14630 return ExprError();
14631
14632 // Transform the size of the array we're allocating (if any).
14633 std::optional<Expr *> ArraySize;
14634 if (E->isArray()) {
14635 ExprResult NewArraySize;
14636 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14637 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14638 if (NewArraySize.isInvalid())
14639 return ExprError();
14640 }
14641 ArraySize = NewArraySize.get();
14642 }
14643
14644 // Transform the placement arguments (if any).
14645 bool ArgumentChanged = false;
14646 SmallVector<Expr*, 8> PlacementArgs;
14647 if (getDerived().TransformExprs(E->getPlacementArgs(),
14648 E->getNumPlacementArgs(), true,
14649 PlacementArgs, &ArgumentChanged))
14650 return ExprError();
14651
14652 // Transform the initializer (if any).
14653 Expr *OldInit = E->getInitializer();
14654 ExprResult NewInit;
14655 if (OldInit)
14656 NewInit = getDerived().TransformInitializer(OldInit, true);
14657 if (NewInit.isInvalid())
14658 return ExprError();
14659
14660 // Transform new operator and delete operator.
14661 FunctionDecl *OperatorNew = nullptr;
14662 if (E->getOperatorNew()) {
14663 OperatorNew = cast_or_null<FunctionDecl>(
14664 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14665 if (!OperatorNew)
14666 return ExprError();
14667 }
14668
14669 FunctionDecl *OperatorDelete = nullptr;
14670 if (E->getOperatorDelete()) {
14671 OperatorDelete = cast_or_null<FunctionDecl>(
14672 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14673 if (!OperatorDelete)
14674 return ExprError();
14675 }
14676
14677 if (!getDerived().AlwaysRebuild() &&
14678 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14679 ArraySize == E->getArraySize() &&
14680 NewInit.get() == OldInit &&
14681 OperatorNew == E->getOperatorNew() &&
14682 OperatorDelete == E->getOperatorDelete() &&
14683 !ArgumentChanged) {
14684 // Mark any declarations we need as referenced.
14685 // FIXME: instantiation-specific.
14686 if (OperatorNew)
14687 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14688 if (OperatorDelete)
14689 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14690
14691 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14692 QualType ElementType
14693 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14694 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14696 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14697 }
14698 }
14699
14700 return E;
14701 }
14702
14703 QualType AllocType = AllocTypeInfo->getType();
14704 if (!ArraySize) {
14705 // If no array size was specified, but the new expression was
14706 // instantiated with an array type (e.g., "new T" where T is
14707 // instantiated with "int[4]"), extract the outer bound from the
14708 // array type as our array size. We do this with constant and
14709 // dependently-sized array types.
14710 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14711 if (!ArrayT) {
14712 // Do nothing
14713 } else if (const ConstantArrayType *ConsArrayT
14714 = dyn_cast<ConstantArrayType>(ArrayT)) {
14715 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14716 SemaRef.Context.getSizeType(),
14717 /*FIXME:*/ E->getBeginLoc());
14718 AllocType = ConsArrayT->getElementType();
14719 } else if (const DependentSizedArrayType *DepArrayT
14720 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14721 if (DepArrayT->getSizeExpr()) {
14722 ArraySize = DepArrayT->getSizeExpr();
14723 AllocType = DepArrayT->getElementType();
14724 }
14725 }
14726 }
14727
14728 return getDerived().RebuildCXXNewExpr(
14729 E->getBeginLoc(), E->isGlobalNew(),
14730 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14731 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14732 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14733}
14734
14735template<typename Derived>
14738 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14739 if (Operand.isInvalid())
14740 return ExprError();
14741
14742 // Transform the delete operator, if known.
14743 FunctionDecl *OperatorDelete = nullptr;
14744 if (E->getOperatorDelete()) {
14745 OperatorDelete = cast_or_null<FunctionDecl>(
14746 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14747 if (!OperatorDelete)
14748 return ExprError();
14749 }
14750
14751 if (!getDerived().AlwaysRebuild() &&
14752 Operand.get() == E->getArgument() &&
14753 OperatorDelete == E->getOperatorDelete()) {
14754 // Mark any declarations we need as referenced.
14755 // FIXME: instantiation-specific.
14756 if (OperatorDelete)
14757 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14758
14759 if (!E->getArgument()->isTypeDependent()) {
14760 QualType Destroyed = SemaRef.Context.getBaseElementType(
14761 E->getDestroyedType());
14762 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14763 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14764 SemaRef.LookupDestructor(Record));
14765 }
14766
14767 return E;
14768 }
14769
14770 return getDerived().RebuildCXXDeleteExpr(
14771 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14772}
14773
14774template<typename Derived>
14778 ExprResult Base = getDerived().TransformExpr(E->getBase());
14779 if (Base.isInvalid())
14780 return ExprError();
14781
14782 ParsedType ObjectTypePtr;
14783 bool MayBePseudoDestructor = false;
14784 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14785 E->getOperatorLoc(),
14786 E->isArrow()? tok::arrow : tok::period,
14787 ObjectTypePtr,
14788 MayBePseudoDestructor);
14789 if (Base.isInvalid())
14790 return ExprError();
14791
14792 QualType ObjectType = ObjectTypePtr.get();
14793 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
14794 if (QualifierLoc) {
14795 QualifierLoc
14796 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
14797 if (!QualifierLoc)
14798 return ExprError();
14799 }
14800 CXXScopeSpec SS;
14801 SS.Adopt(QualifierLoc);
14802
14804 if (E->getDestroyedTypeInfo()) {
14805 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
14806 E->getDestroyedTypeInfo(), ObjectType,
14807 /*FirstQualifierInScope=*/nullptr);
14808 if (!DestroyedTypeInfo)
14809 return ExprError();
14810 Destroyed = DestroyedTypeInfo;
14811 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
14812 // We aren't likely to be able to resolve the identifier down to a type
14813 // now anyway, so just retain the identifier.
14814 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
14815 E->getDestroyedTypeLoc());
14816 } else {
14817 // Look for a destructor known with the given name.
14818 ParsedType T = SemaRef.getDestructorName(
14819 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
14820 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
14821 if (!T)
14822 return ExprError();
14823
14824 Destroyed
14826 E->getDestroyedTypeLoc());
14827 }
14828
14829 TypeSourceInfo *ScopeTypeInfo = nullptr;
14830 if (E->getScopeTypeInfo()) {
14831 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
14832 E->getScopeTypeInfo(), ObjectType, nullptr);
14833 if (!ScopeTypeInfo)
14834 return ExprError();
14835 }
14836
14837 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
14838 E->getOperatorLoc(),
14839 E->isArrow(),
14840 SS,
14841 ScopeTypeInfo,
14842 E->getColonColonLoc(),
14843 E->getTildeLoc(),
14844 Destroyed);
14845}
14846
14847template <typename Derived>
14849 bool RequiresADL,
14850 LookupResult &R) {
14851 // Transform all the decls.
14852 bool AllEmptyPacks = true;
14853 for (auto *OldD : Old->decls()) {
14854 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
14855 if (!InstD) {
14856 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
14857 // This can happen because of dependent hiding.
14858 if (isa<UsingShadowDecl>(OldD))
14859 continue;
14860 else {
14861 R.clear();
14862 return true;
14863 }
14864 }
14865
14866 // Expand using pack declarations.
14867 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
14868 ArrayRef<NamedDecl*> Decls = SingleDecl;
14869 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
14870 Decls = UPD->expansions();
14871
14872 // Expand using declarations.
14873 for (auto *D : Decls) {
14874 if (auto *UD = dyn_cast<UsingDecl>(D)) {
14875 for (auto *SD : UD->shadows())
14876 R.addDecl(SD);
14877 } else {
14878 R.addDecl(D);
14879 }
14880 }
14881
14882 AllEmptyPacks &= Decls.empty();
14883 }
14884
14885 // C++ [temp.res]/8.4.2:
14886 // The program is ill-formed, no diagnostic required, if [...] lookup for
14887 // a name in the template definition found a using-declaration, but the
14888 // lookup in the corresponding scope in the instantiation odoes not find
14889 // any declarations because the using-declaration was a pack expansion and
14890 // the corresponding pack is empty
14891 if (AllEmptyPacks && !RequiresADL) {
14892 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
14893 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
14894 return true;
14895 }
14896
14897 // Resolve a kind, but don't do any further analysis. If it's
14898 // ambiguous, the callee needs to deal with it.
14899 R.resolveKind();
14900
14901 if (Old->hasTemplateKeyword() && !R.empty()) {
14903 getSema().FilterAcceptableTemplateNames(R,
14904 /*AllowFunctionTemplates=*/true,
14905 /*AllowDependent=*/true);
14906 if (R.empty()) {
14907 // If a 'template' keyword was used, a lookup that finds only non-template
14908 // names is an error.
14909 getSema().Diag(R.getNameLoc(),
14910 diag::err_template_kw_refers_to_non_template)
14912 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
14913 getSema().Diag(FoundDecl->getLocation(),
14914 diag::note_template_kw_refers_to_non_template)
14915 << R.getLookupName();
14916 return true;
14917 }
14918 }
14919
14920 return false;
14921}
14922
14923template <typename Derived>
14928
14929template <typename Derived>
14932 bool IsAddressOfOperand) {
14933 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
14935
14936 // Transform the declaration set.
14937 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
14938 return ExprError();
14939
14940 // Rebuild the nested-name qualifier, if present.
14941 CXXScopeSpec SS;
14942 if (Old->getQualifierLoc()) {
14943 NestedNameSpecifierLoc QualifierLoc
14944 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
14945 if (!QualifierLoc)
14946 return ExprError();
14947
14948 SS.Adopt(QualifierLoc);
14949 }
14950
14951 if (Old->getNamingClass()) {
14952 CXXRecordDecl *NamingClass
14953 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
14954 Old->getNameLoc(),
14955 Old->getNamingClass()));
14956 if (!NamingClass) {
14957 R.clear();
14958 return ExprError();
14959 }
14960
14961 R.setNamingClass(NamingClass);
14962 }
14963
14964 // Rebuild the template arguments, if any.
14965 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
14966 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
14967 if (Old->hasExplicitTemplateArgs() &&
14968 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
14969 Old->getNumTemplateArgs(),
14970 TransArgs)) {
14971 R.clear();
14972 return ExprError();
14973 }
14974
14975 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
14976 // a non-static data member is named in an unevaluated operand, or when
14977 // a member is named in a dependent class scope function template explicit
14978 // specialization that is neither declared static nor with an explicit object
14979 // parameter.
14980 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
14981 return SemaRef.BuildPossibleImplicitMemberExpr(
14982 SS, TemplateKWLoc, R,
14983 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
14984 /*S=*/nullptr);
14985
14986 // If we have neither explicit template arguments, nor the template keyword,
14987 // it's a normal declaration name or member reference.
14988 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
14989 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
14990
14991 // If we have template arguments, then rebuild the template-id expression.
14992 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
14993 Old->requiresADL(), &TransArgs);
14994}
14995
14996template<typename Derived>
14999 bool ArgChanged = false;
15001 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15002 TypeSourceInfo *From = E->getArg(I);
15003 TypeLoc FromTL = From->getTypeLoc();
15004 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15005 TypeLocBuilder TLB;
15006 TLB.reserve(FromTL.getFullDataSize());
15007 QualType To = getDerived().TransformType(TLB, FromTL);
15008 if (To.isNull())
15009 return ExprError();
15010
15011 if (To == From->getType())
15012 Args.push_back(From);
15013 else {
15014 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15015 ArgChanged = true;
15016 }
15017 continue;
15018 }
15019
15020 ArgChanged = true;
15021
15022 // We have a pack expansion. Instantiate it.
15023 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15024 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15026 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15027
15028 // Determine whether the set of unexpanded parameter packs can and should
15029 // be expanded.
15030 bool Expand = true;
15031 bool RetainExpansion = false;
15032 UnsignedOrNone OrigNumExpansions =
15033 ExpansionTL.getTypePtr()->getNumExpansions();
15034 UnsignedOrNone NumExpansions = OrigNumExpansions;
15035 if (getDerived().TryExpandParameterPacks(
15036 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15037 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15038 RetainExpansion, NumExpansions))
15039 return ExprError();
15040
15041 if (!Expand) {
15042 // The transform has determined that we should perform a simple
15043 // transformation on the pack expansion, producing another pack
15044 // expansion.
15045 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15046
15047 TypeLocBuilder TLB;
15048 TLB.reserve(From->getTypeLoc().getFullDataSize());
15049
15050 QualType To = getDerived().TransformType(TLB, PatternTL);
15051 if (To.isNull())
15052 return ExprError();
15053
15054 To = getDerived().RebuildPackExpansionType(To,
15055 PatternTL.getSourceRange(),
15056 ExpansionTL.getEllipsisLoc(),
15057 NumExpansions);
15058 if (To.isNull())
15059 return ExprError();
15060
15061 PackExpansionTypeLoc ToExpansionTL
15062 = TLB.push<PackExpansionTypeLoc>(To);
15063 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15064 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15065 continue;
15066 }
15067
15068 // Expand the pack expansion by substituting for each argument in the
15069 // pack(s).
15070 for (unsigned I = 0; I != *NumExpansions; ++I) {
15071 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15072 TypeLocBuilder TLB;
15073 TLB.reserve(PatternTL.getFullDataSize());
15074 QualType To = getDerived().TransformType(TLB, PatternTL);
15075 if (To.isNull())
15076 return ExprError();
15077
15078 if (To->containsUnexpandedParameterPack()) {
15079 To = getDerived().RebuildPackExpansionType(To,
15080 PatternTL.getSourceRange(),
15081 ExpansionTL.getEllipsisLoc(),
15082 NumExpansions);
15083 if (To.isNull())
15084 return ExprError();
15085
15086 PackExpansionTypeLoc ToExpansionTL
15087 = TLB.push<PackExpansionTypeLoc>(To);
15088 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15089 }
15090
15091 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15092 }
15093
15094 if (!RetainExpansion)
15095 continue;
15096
15097 // If we're supposed to retain a pack expansion, do so by temporarily
15098 // forgetting the partially-substituted parameter pack.
15099 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15100
15101 TypeLocBuilder TLB;
15102 TLB.reserve(From->getTypeLoc().getFullDataSize());
15103
15104 QualType To = getDerived().TransformType(TLB, PatternTL);
15105 if (To.isNull())
15106 return ExprError();
15107
15108 To = getDerived().RebuildPackExpansionType(To,
15109 PatternTL.getSourceRange(),
15110 ExpansionTL.getEllipsisLoc(),
15111 NumExpansions);
15112 if (To.isNull())
15113 return ExprError();
15114
15115 PackExpansionTypeLoc ToExpansionTL
15116 = TLB.push<PackExpansionTypeLoc>(To);
15117 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15118 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15119 }
15120
15121 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15122 return E;
15123
15124 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15125 E->getEndLoc());
15126}
15127
15128template<typename Derived>
15132 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15133 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15134 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15135 Old->NumTemplateArgs, TransArgs))
15136 return ExprError();
15137
15138 return getDerived().RebuildConceptSpecializationExpr(
15139 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15140 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15141 &TransArgs);
15142}
15143
15144template<typename Derived>
15147 SmallVector<ParmVarDecl*, 4> TransParams;
15148 SmallVector<QualType, 4> TransParamTypes;
15149 Sema::ExtParameterInfoBuilder ExtParamInfos;
15150
15151 // C++2a [expr.prim.req]p2
15152 // Expressions appearing within a requirement-body are unevaluated operands.
15156
15158 getSema().Context, getSema().CurContext,
15159 E->getBody()->getBeginLoc());
15160
15161 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15162
15163 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15164 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15165 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15166
15167 for (ParmVarDecl *Param : TransParams)
15168 if (Param)
15169 Param->setDeclContext(Body);
15170
15171 // On failure to transform, TransformRequiresTypeParams returns an expression
15172 // in the event that the transformation of the type params failed in some way.
15173 // It is expected that this will result in a 'not satisfied' Requires clause
15174 // when instantiating.
15175 if (!TypeParamResult.isUnset())
15176 return TypeParamResult;
15177
15179 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15180 TransReqs))
15181 return ExprError();
15182
15183 for (concepts::Requirement *Req : TransReqs) {
15184 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15185 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15186 ER->getReturnTypeRequirement()
15187 .getTypeConstraintTemplateParameterList()->getParam(0)
15188 ->setDeclContext(Body);
15189 }
15190 }
15191 }
15192
15193 return getDerived().RebuildRequiresExpr(
15194 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15195 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15196}
15197
15198template<typename Derived>
15202 for (concepts::Requirement *Req : Reqs) {
15203 concepts::Requirement *TransReq = nullptr;
15204 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15205 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15206 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15207 TransReq = getDerived().TransformExprRequirement(ExprReq);
15208 else
15209 TransReq = getDerived().TransformNestedRequirement(
15211 if (!TransReq)
15212 return true;
15213 Transformed.push_back(TransReq);
15214 }
15215 return false;
15216}
15217
15218template<typename Derived>
15222 if (Req->isSubstitutionFailure()) {
15223 if (getDerived().AlwaysRebuild())
15224 return getDerived().RebuildTypeRequirement(
15226 return Req;
15227 }
15228 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15229 if (!TransType)
15230 return nullptr;
15231 return getDerived().RebuildTypeRequirement(TransType);
15232}
15233
15234template<typename Derived>
15237 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15238 if (Req->isExprSubstitutionFailure())
15239 TransExpr = Req->getExprSubstitutionDiagnostic();
15240 else {
15241 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15242 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15243 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15244 if (TransExprRes.isInvalid())
15245 return nullptr;
15246 TransExpr = TransExprRes.get();
15247 }
15248
15249 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15250 const auto &RetReq = Req->getReturnTypeRequirement();
15251 if (RetReq.isEmpty())
15252 TransRetReq.emplace();
15253 else if (RetReq.isSubstitutionFailure())
15254 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15255 else if (RetReq.isTypeConstraint()) {
15256 TemplateParameterList *OrigTPL =
15257 RetReq.getTypeConstraintTemplateParameterList();
15259 getDerived().TransformTemplateParameterList(OrigTPL);
15260 if (!TPL)
15261 return nullptr;
15262 TransRetReq.emplace(TPL);
15263 }
15264 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15265 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15266 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15267 Req->getNoexceptLoc(),
15268 std::move(*TransRetReq));
15269 return getDerived().RebuildExprRequirement(
15271 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15272}
15273
15274template<typename Derived>
15278 if (Req->hasInvalidConstraint()) {
15279 if (getDerived().AlwaysRebuild())
15280 return getDerived().RebuildNestedRequirement(
15282 return Req;
15283 }
15284 ExprResult TransConstraint =
15285 getDerived().TransformExpr(Req->getConstraintExpr());
15286 if (TransConstraint.isInvalid())
15287 return nullptr;
15288 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15289}
15290
15291template<typename Derived>
15294 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15295 if (!T)
15296 return ExprError();
15297
15298 if (!getDerived().AlwaysRebuild() &&
15300 return E;
15301
15302 ExprResult SubExpr;
15303 {
15306 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15307 if (SubExpr.isInvalid())
15308 return ExprError();
15309 }
15310
15311 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15312 SubExpr.get(), E->getEndLoc());
15313}
15314
15315template<typename Derived>
15318 ExprResult SubExpr;
15319 {
15322 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15323 if (SubExpr.isInvalid())
15324 return ExprError();
15325
15326 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15327 return E;
15328 }
15329
15330 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15331 SubExpr.get(), E->getEndLoc());
15332}
15333
15334template <typename Derived>
15336 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15337 TypeSourceInfo **RecoveryTSI) {
15338 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15339 DRE, AddrTaken, RecoveryTSI);
15340
15341 // Propagate both errors and recovered types, which return ExprEmpty.
15342 if (!NewDRE.isUsable())
15343 return NewDRE;
15344
15345 // We got an expr, wrap it up in parens.
15346 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15347 return PE;
15348 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15349 PE->getRParen());
15350}
15351
15352template <typename Derived>
15358
15359template <typename Derived>
15361 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15362 TypeSourceInfo **RecoveryTSI) {
15363 assert(E->getQualifierLoc());
15364 NestedNameSpecifierLoc QualifierLoc =
15365 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15366 if (!QualifierLoc)
15367 return ExprError();
15368 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15369
15370 // TODO: If this is a conversion-function-id, verify that the
15371 // destination type name (if present) resolves the same way after
15372 // instantiation as it did in the local scope.
15373
15374 DeclarationNameInfo NameInfo =
15375 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15376 if (!NameInfo.getName())
15377 return ExprError();
15378
15379 if (!E->hasExplicitTemplateArgs()) {
15380 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15381 // Note: it is sufficient to compare the Name component of NameInfo:
15382 // if name has not changed, DNLoc has not changed either.
15383 NameInfo.getName() == E->getDeclName())
15384 return E;
15385
15386 return getDerived().RebuildDependentScopeDeclRefExpr(
15387 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15388 IsAddressOfOperand, RecoveryTSI);
15389 }
15390
15391 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15392 if (getDerived().TransformTemplateArguments(
15393 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15394 return ExprError();
15395
15396 return getDerived().RebuildDependentScopeDeclRefExpr(
15397 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15398 RecoveryTSI);
15399}
15400
15401template<typename Derived>
15404 // CXXConstructExprs other than for list-initialization and
15405 // CXXTemporaryObjectExpr are always implicit, so when we have
15406 // a 1-argument construction we just transform that argument.
15407 if (getDerived().AllowSkippingCXXConstructExpr() &&
15408 ((E->getNumArgs() == 1 ||
15409 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15410 (!getDerived().DropCallArgument(E->getArg(0))) &&
15411 !E->isListInitialization()))
15412 return getDerived().TransformInitializer(E->getArg(0),
15413 /*DirectInit*/ false);
15414
15415 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15416
15417 QualType T = getDerived().TransformType(E->getType());
15418 if (T.isNull())
15419 return ExprError();
15420
15421 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15422 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15423 if (!Constructor)
15424 return ExprError();
15425
15426 bool ArgumentChanged = false;
15428 {
15431 E->isListInitialization());
15432 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15433 &ArgumentChanged))
15434 return ExprError();
15435 }
15436
15437 if (!getDerived().AlwaysRebuild() &&
15438 T == E->getType() &&
15439 Constructor == E->getConstructor() &&
15440 !ArgumentChanged) {
15441 // Mark the constructor as referenced.
15442 // FIXME: Instantiation-specific
15443 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15444 return E;
15445 }
15446
15447 return getDerived().RebuildCXXConstructExpr(
15448 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15449 E->hadMultipleCandidates(), E->isListInitialization(),
15450 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15451 E->getConstructionKind(), E->getParenOrBraceRange());
15452}
15453
15454template<typename Derived>
15457 QualType T = getDerived().TransformType(E->getType());
15458 if (T.isNull())
15459 return ExprError();
15460
15461 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15462 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15463 if (!Constructor)
15464 return ExprError();
15465
15466 if (!getDerived().AlwaysRebuild() &&
15467 T == E->getType() &&
15468 Constructor == E->getConstructor()) {
15469 // Mark the constructor as referenced.
15470 // FIXME: Instantiation-specific
15471 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15472 return E;
15473 }
15474
15475 return getDerived().RebuildCXXInheritedCtorInitExpr(
15476 T, E->getLocation(), Constructor,
15477 E->constructsVBase(), E->inheritedFromVBase());
15478}
15479
15480/// Transform a C++ temporary-binding expression.
15481///
15482/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15483/// transform the subexpression and return that.
15484template<typename Derived>
15487 if (auto *Dtor = E->getTemporary()->getDestructor())
15488 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15489 const_cast<CXXDestructorDecl *>(Dtor));
15490 return getDerived().TransformExpr(E->getSubExpr());
15491}
15492
15493/// Transform a C++ expression that contains cleanups that should
15494/// be run after the expression is evaluated.
15495///
15496/// Since ExprWithCleanups nodes are implicitly generated, we
15497/// just transform the subexpression and return that.
15498template<typename Derived>
15501 return getDerived().TransformExpr(E->getSubExpr());
15502}
15503
15504template<typename Derived>
15508 TypeSourceInfo *T =
15509 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15510 if (!T)
15511 return ExprError();
15512
15513 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15514 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15515 if (!Constructor)
15516 return ExprError();
15517
15518 bool ArgumentChanged = false;
15520 Args.reserve(E->getNumArgs());
15521 {
15524 E->isListInitialization());
15525 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15526 &ArgumentChanged))
15527 return ExprError();
15528
15529 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15530 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc());
15531 if (Res.isInvalid())
15532 return ExprError();
15533 Args = {Res.get()};
15534 }
15535 }
15536
15537 if (!getDerived().AlwaysRebuild() &&
15538 T == E->getTypeSourceInfo() &&
15539 Constructor == E->getConstructor() &&
15540 !ArgumentChanged) {
15541 // FIXME: Instantiation-specific
15542 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15543 return SemaRef.MaybeBindToTemporary(E);
15544 }
15545
15546 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15547 return getDerived().RebuildCXXTemporaryObjectExpr(
15548 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15549}
15550
15551template<typename Derived>
15554 // Transform any init-capture expressions before entering the scope of the
15555 // lambda body, because they are not semantically within that scope.
15556 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15557 struct TransformedInitCapture {
15558 // The location of the ... if the result is retaining a pack expansion.
15559 SourceLocation EllipsisLoc;
15560 // Zero or more expansions of the init-capture.
15561 SmallVector<InitCaptureInfoTy, 4> Expansions;
15562 };
15564 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15565 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15566 CEnd = E->capture_end();
15567 C != CEnd; ++C) {
15568 if (!E->isInitCapture(C))
15569 continue;
15570
15571 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15572 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15573
15574 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15575 UnsignedOrNone NumExpansions) {
15576 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15577 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15578
15579 if (NewExprInitResult.isInvalid()) {
15580 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15581 return;
15582 }
15583 Expr *NewExprInit = NewExprInitResult.get();
15584
15585 QualType NewInitCaptureType =
15586 getSema().buildLambdaInitCaptureInitialization(
15587 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15588 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15589 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15591 NewExprInit);
15592 Result.Expansions.push_back(
15593 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15594 };
15595
15596 // If this is an init-capture pack, consider expanding the pack now.
15597 if (OldVD->isParameterPack()) {
15598 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15599 ->getTypeLoc()
15602 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15603
15604 // Determine whether the set of unexpanded parameter packs can and should
15605 // be expanded.
15606 bool Expand = true;
15607 bool RetainExpansion = false;
15608 UnsignedOrNone OrigNumExpansions =
15609 ExpansionTL.getTypePtr()->getNumExpansions();
15610 UnsignedOrNone NumExpansions = OrigNumExpansions;
15611 if (getDerived().TryExpandParameterPacks(
15612 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15613 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15614 RetainExpansion, NumExpansions))
15615 return ExprError();
15616 assert(!RetainExpansion && "Should not need to retain expansion after a "
15617 "capture since it cannot be extended");
15618 if (Expand) {
15619 for (unsigned I = 0; I != *NumExpansions; ++I) {
15620 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15621 SubstInitCapture(SourceLocation(), std::nullopt);
15622 }
15623 } else {
15624 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15625 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15626 }
15627 } else {
15628 SubstInitCapture(SourceLocation(), std::nullopt);
15629 }
15630 }
15631
15632 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15633 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15634
15635 // Create the local class that will describe the lambda.
15636
15637 // FIXME: DependencyKind below is wrong when substituting inside a templated
15638 // context that isn't a DeclContext (such as a variable template), or when
15639 // substituting an unevaluated lambda inside of a function's parameter's type
15640 // - as parameter types are not instantiated from within a function's DC. We
15641 // use evaluation contexts to distinguish the function parameter case.
15644 DeclContext *DC = getSema().CurContext;
15645 // A RequiresExprBodyDecl is not interesting for dependencies.
15646 // For the following case,
15647 //
15648 // template <typename>
15649 // concept C = requires { [] {}; };
15650 //
15651 // template <class F>
15652 // struct Widget;
15653 //
15654 // template <C F>
15655 // struct Widget<F> {};
15656 //
15657 // While we are substituting Widget<F>, the parent of DC would be
15658 // the template specialization itself. Thus, the lambda expression
15659 // will be deemed as dependent even if there are no dependent template
15660 // arguments.
15661 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15662 while (DC->isRequiresExprBody())
15663 DC = DC->getParent();
15664 if ((getSema().isUnevaluatedContext() ||
15665 getSema().isConstantEvaluatedContext()) &&
15666 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15667 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
15668 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15669 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15670
15671 CXXRecordDecl *OldClass = E->getLambdaClass();
15672 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15673 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15674 E->getCaptureDefault());
15675 getDerived().transformedLocalDecl(OldClass, {Class});
15676
15677 CXXMethodDecl *NewCallOperator =
15678 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15679
15680 // Enter the scope of the lambda.
15681 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15682 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15683 E->hasExplicitParameters(), E->isMutable());
15684
15685 // Introduce the context of the call operator.
15686 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15687 /*NewThisContext*/false);
15688
15689 bool Invalid = false;
15690
15691 // Transform captures.
15692 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15693 CEnd = E->capture_end();
15694 C != CEnd; ++C) {
15695 // When we hit the first implicit capture, tell Sema that we've finished
15696 // the list of explicit captures.
15697 if (C->isImplicit())
15698 break;
15699
15700 // Capturing 'this' is trivial.
15701 if (C->capturesThis()) {
15702 // If this is a lambda that is part of a default member initialiser
15703 // and which we're instantiating outside the class that 'this' is
15704 // supposed to refer to, adjust the type of 'this' accordingly.
15705 //
15706 // Otherwise, leave the type of 'this' as-is.
15707 Sema::CXXThisScopeRAII ThisScope(
15708 getSema(),
15709 dyn_cast_if_present<CXXRecordDecl>(
15710 getSema().getFunctionLevelDeclContext()),
15711 Qualifiers());
15712 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15713 /*BuildAndDiagnose*/ true, nullptr,
15714 C->getCaptureKind() == LCK_StarThis);
15715 continue;
15716 }
15717 // Captured expression will be recaptured during captured variables
15718 // rebuilding.
15719 if (C->capturesVLAType())
15720 continue;
15721
15722 // Rebuild init-captures, including the implied field declaration.
15723 if (E->isInitCapture(C)) {
15724 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15725
15726 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15728
15729 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15730 ExprResult Init = Info.first;
15731 QualType InitQualType = Info.second;
15732 if (Init.isInvalid() || InitQualType.isNull()) {
15733 Invalid = true;
15734 break;
15735 }
15736 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15737 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15738 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15739 getSema().CurContext);
15740 if (!NewVD) {
15741 Invalid = true;
15742 break;
15743 }
15744 NewVDs.push_back(NewVD);
15745 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15746 // Cases we want to tackle:
15747 // ([C(Pack)] {}, ...)
15748 // But rule out cases e.g.
15749 // [...C = Pack()] {}
15750 if (NewC.EllipsisLoc.isInvalid())
15751 LSI->ContainsUnexpandedParameterPack |=
15752 Init.get()->containsUnexpandedParameterPack();
15753 }
15754
15755 if (Invalid)
15756 break;
15757
15758 getDerived().transformedLocalDecl(OldVD, NewVDs);
15759 continue;
15760 }
15761
15762 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15763
15764 // Determine the capture kind for Sema.
15766 : C->getCaptureKind() == LCK_ByCopy
15769 SourceLocation EllipsisLoc;
15770 if (C->isPackExpansion()) {
15771 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15772 bool ShouldExpand = false;
15773 bool RetainExpansion = false;
15774 UnsignedOrNone NumExpansions = std::nullopt;
15775 if (getDerived().TryExpandParameterPacks(
15776 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
15777 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
15778 RetainExpansion, NumExpansions)) {
15779 Invalid = true;
15780 continue;
15781 }
15782
15783 if (ShouldExpand) {
15784 // The transform has determined that we should perform an expansion;
15785 // transform and capture each of the arguments.
15786 // expansion of the pattern. Do so.
15787 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
15788 for (unsigned I = 0; I != *NumExpansions; ++I) {
15789 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15790 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
15791 getDerived().TransformDecl(C->getLocation(), Pack));
15792 if (!CapturedVar) {
15793 Invalid = true;
15794 continue;
15795 }
15796
15797 // Capture the transformed variable.
15798 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
15799 }
15800
15801 // FIXME: Retain a pack expansion if RetainExpansion is true.
15802
15803 continue;
15804 }
15805
15806 EllipsisLoc = C->getEllipsisLoc();
15807 }
15808
15809 // Transform the captured variable.
15810 auto *CapturedVar = cast_or_null<ValueDecl>(
15811 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15812 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
15813 Invalid = true;
15814 continue;
15815 }
15816
15817 // This is not an init-capture; however it contains an unexpanded pack e.g.
15818 // ([Pack] {}(), ...)
15819 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
15820 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
15821
15822 // Capture the transformed variable.
15823 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
15824 EllipsisLoc);
15825 }
15826 getSema().finishLambdaExplicitCaptures(LSI);
15827
15828 // Transform the template parameters, and add them to the current
15829 // instantiation scope. The null case is handled correctly.
15830 auto TPL = getDerived().TransformTemplateParameterList(
15831 E->getTemplateParameterList());
15832 LSI->GLTemplateParameterList = TPL;
15833 if (TPL) {
15834 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
15835 TPL);
15836 LSI->ContainsUnexpandedParameterPack |=
15837 TPL->containsUnexpandedParameterPack();
15838 }
15839
15840 TypeLocBuilder NewCallOpTLBuilder;
15841 TypeLoc OldCallOpTypeLoc =
15842 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
15843 QualType NewCallOpType =
15844 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
15845 if (NewCallOpType.isNull())
15846 return ExprError();
15847 LSI->ContainsUnexpandedParameterPack |=
15848 NewCallOpType->containsUnexpandedParameterPack();
15849 TypeSourceInfo *NewCallOpTSI =
15850 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
15851
15852 // The type may be an AttributedType or some other kind of sugar;
15853 // get the actual underlying FunctionProtoType.
15854 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
15855 assert(FPTL && "Not a FunctionProtoType?");
15856
15857 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
15858 if (!TRC.ArgPackSubstIndex)
15860
15861 getSema().CompleteLambdaCallOperator(
15862 NewCallOperator, E->getCallOperator()->getLocation(),
15863 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
15864 E->getCallOperator()->getConstexprKind(),
15865 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
15866 E->hasExplicitResultType());
15867
15868 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
15869 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
15870
15871 {
15872 // Number the lambda for linkage purposes if necessary.
15873 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
15874
15875 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
15876 if (getDerived().ReplacingOriginal()) {
15877 Numbering = OldClass->getLambdaNumbering();
15878 }
15879
15880 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
15881 }
15882
15883 // FIXME: Sema's lambda-building mechanism expects us to push an expression
15884 // evaluation context even if we're not transforming the function body.
15885 getSema().PushExpressionEvaluationContextForFunction(
15887 E->getCallOperator());
15888
15889 StmtResult Body;
15890 {
15891 Sema::NonSFINAEContext _(getSema());
15894 C.PointOfInstantiation = E->getBody()->getBeginLoc();
15895 getSema().pushCodeSynthesisContext(C);
15896
15897 // Instantiate the body of the lambda expression.
15898 Body = Invalid ? StmtError()
15899 : getDerived().TransformLambdaBody(E, E->getBody());
15900
15901 getSema().popCodeSynthesisContext();
15902 }
15903
15904 // ActOnLambda* will pop the function scope for us.
15905 FuncScopeCleanup.disable();
15906
15907 if (Body.isInvalid()) {
15908 SavedContext.pop();
15909 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
15910 /*IsInstantiation=*/true);
15911 return ExprError();
15912 }
15913
15914 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
15915 /*IsInstantiation=*/true,
15916 /*RetainFunctionScopeInfo=*/true);
15917 SavedContext.pop();
15918
15919 // Recompute the dependency of the lambda so that we can defer the lambda call
15920 // construction until after we have all the necessary template arguments. For
15921 // example, given
15922 //
15923 // template <class> struct S {
15924 // template <class U>
15925 // using Type = decltype([](U){}(42.0));
15926 // };
15927 // void foo() {
15928 // using T = S<int>::Type<float>;
15929 // ^~~~~~
15930 // }
15931 //
15932 // We would end up here from instantiating S<int> when ensuring its
15933 // completeness. That would transform the lambda call expression regardless of
15934 // the absence of the corresponding argument for U.
15935 //
15936 // Going ahead with unsubstituted type U makes things worse: we would soon
15937 // compare the argument type (which is float) against the parameter U
15938 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
15939 // error suggesting unmatched types 'U' and 'float'!
15940 //
15941 // That said, everything will be fine if we defer that semantic checking.
15942 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
15943 // dependent. Since the CallExpr's dependency boils down to the lambda's
15944 // dependency in this case, we can harness that by recomputing the dependency
15945 // from the instantiation arguments.
15946 //
15947 // FIXME: Creating the type of a lambda requires us to have a dependency
15948 // value, which happens before its substitution. We update its dependency
15949 // *after* the substitution in case we can't decide the dependency
15950 // so early, e.g. because we want to see if any of the *substituted*
15951 // parameters are dependent.
15952 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
15953 Class->setLambdaDependencyKind(DependencyKind);
15954
15955 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
15956 Body.get()->getEndLoc(), LSI);
15957}
15958
15959template<typename Derived>
15964
15965template<typename Derived>
15968 // Transform captures.
15970 CEnd = E->capture_end();
15971 C != CEnd; ++C) {
15972 // When we hit the first implicit capture, tell Sema that we've finished
15973 // the list of explicit captures.
15974 if (!C->isImplicit())
15975 continue;
15976
15977 // Capturing 'this' is trivial.
15978 if (C->capturesThis()) {
15979 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15980 /*BuildAndDiagnose*/ true, nullptr,
15981 C->getCaptureKind() == LCK_StarThis);
15982 continue;
15983 }
15984 // Captured expression will be recaptured during captured variables
15985 // rebuilding.
15986 if (C->capturesVLAType())
15987 continue;
15988
15989 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15990 assert(!E->isInitCapture(C) && "implicit init-capture?");
15991
15992 // Transform the captured variable.
15993 VarDecl *CapturedVar = cast_or_null<VarDecl>(
15994 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15995 if (!CapturedVar || CapturedVar->isInvalidDecl())
15996 return StmtError();
15997
15998 // Capture the transformed variable.
15999 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16000 }
16001
16002 return S;
16003}
16004
16005template<typename Derived>
16009 TypeSourceInfo *T =
16010 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16011 if (!T)
16012 return ExprError();
16013
16014 bool ArgumentChanged = false;
16016 Args.reserve(E->getNumArgs());
16017 {
16021 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16022 &ArgumentChanged))
16023 return ExprError();
16024 }
16025
16026 if (!getDerived().AlwaysRebuild() &&
16027 T == E->getTypeSourceInfo() &&
16028 !ArgumentChanged)
16029 return E;
16030
16031 // FIXME: we're faking the locations of the commas
16032 return getDerived().RebuildCXXUnresolvedConstructExpr(
16033 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16034}
16035
16036template<typename Derived>
16040 // Transform the base of the expression.
16041 ExprResult Base((Expr*) nullptr);
16042 Expr *OldBase;
16043 QualType BaseType;
16044 QualType ObjectType;
16045 if (!E->isImplicitAccess()) {
16046 OldBase = E->getBase();
16047 Base = getDerived().TransformExpr(OldBase);
16048 if (Base.isInvalid())
16049 return ExprError();
16050
16051 // Start the member reference and compute the object's type.
16052 ParsedType ObjectTy;
16053 bool MayBePseudoDestructor = false;
16054 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16055 E->getOperatorLoc(),
16056 E->isArrow()? tok::arrow : tok::period,
16057 ObjectTy,
16058 MayBePseudoDestructor);
16059 if (Base.isInvalid())
16060 return ExprError();
16061
16062 ObjectType = ObjectTy.get();
16063 BaseType = ((Expr*) Base.get())->getType();
16064 } else {
16065 OldBase = nullptr;
16066 BaseType = getDerived().TransformType(E->getBaseType());
16067 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16068 }
16069
16070 // Transform the first part of the nested-name-specifier that qualifies
16071 // the member name.
16072 NamedDecl *FirstQualifierInScope
16073 = getDerived().TransformFirstQualifierInScope(
16074 E->getFirstQualifierFoundInScope(),
16075 E->getQualifierLoc().getBeginLoc());
16076
16077 NestedNameSpecifierLoc QualifierLoc;
16078 if (E->getQualifier()) {
16079 QualifierLoc
16080 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16081 ObjectType,
16082 FirstQualifierInScope);
16083 if (!QualifierLoc)
16084 return ExprError();
16085 }
16086
16087 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16088
16089 // TODO: If this is a conversion-function-id, verify that the
16090 // destination type name (if present) resolves the same way after
16091 // instantiation as it did in the local scope.
16092
16093 DeclarationNameInfo NameInfo
16094 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16095 if (!NameInfo.getName())
16096 return ExprError();
16097
16098 if (!E->hasExplicitTemplateArgs()) {
16099 // This is a reference to a member without an explicitly-specified
16100 // template argument list. Optimize for this common case.
16101 if (!getDerived().AlwaysRebuild() &&
16102 Base.get() == OldBase &&
16103 BaseType == E->getBaseType() &&
16104 QualifierLoc == E->getQualifierLoc() &&
16105 NameInfo.getName() == E->getMember() &&
16106 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16107 return E;
16108
16109 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16110 BaseType,
16111 E->isArrow(),
16112 E->getOperatorLoc(),
16113 QualifierLoc,
16114 TemplateKWLoc,
16115 FirstQualifierInScope,
16116 NameInfo,
16117 /*TemplateArgs*/nullptr);
16118 }
16119
16120 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16121 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16122 E->getNumTemplateArgs(),
16123 TransArgs))
16124 return ExprError();
16125
16126 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16127 BaseType,
16128 E->isArrow(),
16129 E->getOperatorLoc(),
16130 QualifierLoc,
16131 TemplateKWLoc,
16132 FirstQualifierInScope,
16133 NameInfo,
16134 &TransArgs);
16135}
16136
16137template <typename Derived>
16139 UnresolvedMemberExpr *Old) {
16140 // Transform the base of the expression.
16141 ExprResult Base((Expr *)nullptr);
16142 QualType BaseType;
16143 if (!Old->isImplicitAccess()) {
16144 Base = getDerived().TransformExpr(Old->getBase());
16145 if (Base.isInvalid())
16146 return ExprError();
16147 Base =
16148 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16149 if (Base.isInvalid())
16150 return ExprError();
16151 BaseType = Base.get()->getType();
16152 } else {
16153 BaseType = getDerived().TransformType(Old->getBaseType());
16154 }
16155
16156 NestedNameSpecifierLoc QualifierLoc;
16157 if (Old->getQualifierLoc()) {
16158 QualifierLoc =
16159 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16160 if (!QualifierLoc)
16161 return ExprError();
16162 }
16163
16164 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16165
16166 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16167
16168 // Transform the declaration set.
16169 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16170 return ExprError();
16171
16172 // Determine the naming class.
16173 if (Old->getNamingClass()) {
16174 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16175 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16176 if (!NamingClass)
16177 return ExprError();
16178
16179 R.setNamingClass(NamingClass);
16180 }
16181
16182 TemplateArgumentListInfo TransArgs;
16183 if (Old->hasExplicitTemplateArgs()) {
16184 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16185 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16186 if (getDerived().TransformTemplateArguments(
16187 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16188 return ExprError();
16189 }
16190
16191 // FIXME: to do this check properly, we will need to preserve the
16192 // first-qualifier-in-scope here, just in case we had a dependent
16193 // base (and therefore couldn't do the check) and a
16194 // nested-name-qualifier (and therefore could do the lookup).
16195 NamedDecl *FirstQualifierInScope = nullptr;
16196
16197 return getDerived().RebuildUnresolvedMemberExpr(
16198 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16199 TemplateKWLoc, FirstQualifierInScope, R,
16200 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16201}
16202
16203template<typename Derived>
16208 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16209 if (SubExpr.isInvalid())
16210 return ExprError();
16211
16212 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16213 return E;
16214
16215 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16216}
16217
16218template<typename Derived>
16221 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16222 if (Pattern.isInvalid())
16223 return ExprError();
16224
16225 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16226 return E;
16227
16228 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16229 E->getNumExpansions());
16230}
16231
16232template <typename Derived>
16234 ArrayRef<TemplateArgument> PackArgs) {
16236 for (const TemplateArgument &Arg : PackArgs) {
16237 if (!Arg.isPackExpansion()) {
16238 Result = *Result + 1;
16239 continue;
16240 }
16241
16242 TemplateArgumentLoc ArgLoc;
16243 InventTemplateArgumentLoc(Arg, ArgLoc);
16244
16245 // Find the pattern of the pack expansion.
16246 SourceLocation Ellipsis;
16247 UnsignedOrNone OrigNumExpansions = std::nullopt;
16248 TemplateArgumentLoc Pattern =
16249 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16250 OrigNumExpansions);
16251
16252 // Substitute under the pack expansion. Do not expand the pack (yet).
16253 TemplateArgumentLoc OutPattern;
16254 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16255 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16256 /*Uneval*/ true))
16257 return 1u;
16258
16259 // See if we can determine the number of arguments from the result.
16260 UnsignedOrNone NumExpansions =
16261 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16262 if (!NumExpansions) {
16263 // No: we must be in an alias template expansion, and we're going to
16264 // need to actually expand the packs.
16265 Result = std::nullopt;
16266 break;
16267 }
16268
16269 Result = *Result + *NumExpansions;
16270 }
16271 return Result;
16272}
16273
16274template<typename Derived>
16277 // If E is not value-dependent, then nothing will change when we transform it.
16278 // Note: This is an instantiation-centric view.
16279 if (!E->isValueDependent())
16280 return E;
16281
16284
16286 TemplateArgument ArgStorage;
16287
16288 // Find the argument list to transform.
16289 if (E->isPartiallySubstituted()) {
16290 PackArgs = E->getPartialArguments();
16291 } else if (E->isValueDependent()) {
16292 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16293 bool ShouldExpand = false;
16294 bool RetainExpansion = false;
16295 UnsignedOrNone NumExpansions = std::nullopt;
16296 if (getDerived().TryExpandParameterPacks(
16297 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16298 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16299 RetainExpansion, NumExpansions))
16300 return ExprError();
16301
16302 // If we need to expand the pack, build a template argument from it and
16303 // expand that.
16304 if (ShouldExpand) {
16305 auto *Pack = E->getPack();
16306 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16307 ArgStorage = getSema().Context.getPackExpansionType(
16308 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16309 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16310 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16311 } else {
16312 auto *VD = cast<ValueDecl>(Pack);
16313 ExprResult DRE = getSema().BuildDeclRefExpr(
16314 VD, VD->getType().getNonLValueExprType(getSema().Context),
16315 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16316 E->getPackLoc());
16317 if (DRE.isInvalid())
16318 return ExprError();
16319 ArgStorage = TemplateArgument(
16320 new (getSema().Context)
16321 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16322 /*IsCanonical=*/false);
16323 }
16324 PackArgs = ArgStorage;
16325 }
16326 }
16327
16328 // If we're not expanding the pack, just transform the decl.
16329 if (!PackArgs.size()) {
16330 auto *Pack = cast_or_null<NamedDecl>(
16331 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16332 if (!Pack)
16333 return ExprError();
16334 return getDerived().RebuildSizeOfPackExpr(
16335 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16336 std::nullopt, {});
16337 }
16338
16339 // Try to compute the result without performing a partial substitution.
16341 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16342
16343 // Common case: we could determine the number of expansions without
16344 // substituting.
16345 if (Result)
16346 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16347 E->getPackLoc(),
16348 E->getRParenLoc(), *Result, {});
16349
16350 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16351 E->getPackLoc());
16352 {
16353 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16355 Derived, const TemplateArgument*> PackLocIterator;
16356 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16357 PackLocIterator(*this, PackArgs.end()),
16358 TransformedPackArgs, /*Uneval*/true))
16359 return ExprError();
16360 }
16361
16362 // Check whether we managed to fully-expand the pack.
16363 // FIXME: Is it possible for us to do so and not hit the early exit path?
16365 bool PartialSubstitution = false;
16366 for (auto &Loc : TransformedPackArgs.arguments()) {
16367 Args.push_back(Loc.getArgument());
16368 if (Loc.getArgument().isPackExpansion())
16369 PartialSubstitution = true;
16370 }
16371
16372 if (PartialSubstitution)
16373 return getDerived().RebuildSizeOfPackExpr(
16374 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16375 std::nullopt, Args);
16376
16377 return getDerived().RebuildSizeOfPackExpr(
16378 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16379 /*Length=*/static_cast<unsigned>(Args.size()),
16380 /*PartialArgs=*/{});
16381}
16382
16383template <typename Derived>
16386 if (!E->isValueDependent())
16387 return E;
16388
16389 // Transform the index
16390 ExprResult IndexExpr;
16391 {
16392 EnterExpressionEvaluationContext ConstantContext(
16394 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16395 if (IndexExpr.isInvalid())
16396 return ExprError();
16397 }
16398
16399 SmallVector<Expr *, 5> ExpandedExprs;
16400 bool FullySubstituted = true;
16401 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16402 Expr *Pattern = E->getPackIdExpression();
16404 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16405 Unexpanded);
16406 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16407
16408 // Determine whether the set of unexpanded parameter packs can and should
16409 // be expanded.
16410 bool ShouldExpand = true;
16411 bool RetainExpansion = false;
16412 UnsignedOrNone OrigNumExpansions = std::nullopt,
16413 NumExpansions = std::nullopt;
16414 if (getDerived().TryExpandParameterPacks(
16415 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16416 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16417 RetainExpansion, NumExpansions))
16418 return true;
16419 if (!ShouldExpand) {
16420 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16421 ExprResult Pack = getDerived().TransformExpr(Pattern);
16422 if (Pack.isInvalid())
16423 return ExprError();
16424 return getDerived().RebuildPackIndexingExpr(
16425 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16426 {}, /*FullySubstituted=*/false);
16427 }
16428 for (unsigned I = 0; I != *NumExpansions; ++I) {
16429 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16430 ExprResult Out = getDerived().TransformExpr(Pattern);
16431 if (Out.isInvalid())
16432 return true;
16433 if (Out.get()->containsUnexpandedParameterPack()) {
16434 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16435 OrigNumExpansions);
16436 if (Out.isInvalid())
16437 return true;
16438 FullySubstituted = false;
16439 }
16440 ExpandedExprs.push_back(Out.get());
16441 }
16442 // If we're supposed to retain a pack expansion, do so by temporarily
16443 // forgetting the partially-substituted parameter pack.
16444 if (RetainExpansion) {
16445 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16446
16447 ExprResult Out = getDerived().TransformExpr(Pattern);
16448 if (Out.isInvalid())
16449 return true;
16450
16451 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16452 OrigNumExpansions);
16453 if (Out.isInvalid())
16454 return true;
16455 FullySubstituted = false;
16456 ExpandedExprs.push_back(Out.get());
16457 }
16458 } else if (!E->expandsToEmptyPack()) {
16459 if (getDerived().TransformExprs(E->getExpressions().data(),
16460 E->getExpressions().size(), false,
16461 ExpandedExprs))
16462 return ExprError();
16463 }
16464
16465 return getDerived().RebuildPackIndexingExpr(
16466 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16467 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16468}
16469
16470template <typename Derived>
16473 if (!getSema().ArgPackSubstIndex)
16474 // We aren't expanding the parameter pack, so just return ourselves.
16475 return E;
16476
16477 TemplateArgument Pack = E->getArgumentPack();
16479 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16480 E->getAssociatedDecl(), E->getParameterPack(),
16481 E->getParameterPackLocation(), Arg, SemaRef.getPackIndex(Pack),
16482 E->getFinal());
16483}
16484
16485template <typename Derived>
16488 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16489 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16490 if (Replacement.isInvalid())
16491 return true;
16492
16493 Decl *AssociatedDecl =
16494 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16495 if (!AssociatedDecl)
16496 return true;
16497
16498 if (Replacement.get() == OrigReplacement &&
16499 AssociatedDecl == E->getAssociatedDecl())
16500 return E;
16501
16502 auto getParamAndType = [E](Decl *AssociatedDecl)
16503 -> std::tuple<NonTypeTemplateParmDecl *, QualType> {
16504 auto [PDecl, Arg] =
16505 getReplacedTemplateParameter(AssociatedDecl, E->getIndex());
16506 auto *Param = cast<NonTypeTemplateParmDecl>(PDecl);
16507 if (Arg.isNull())
16508 return {Param, Param->getType()};
16509 if (UnsignedOrNone PackIndex = E->getPackIndex())
16510 Arg = Arg.getPackAsArray()[*PackIndex];
16511 return {Param, Arg.getNonTypeTemplateArgumentType()};
16512 };
16513
16514 // If the replacement expression did not change, and the parameter type
16515 // did not change, we can skip the semantic action because it would
16516 // produce the same result anyway.
16517 if (auto [Param, ParamType] = getParamAndType(AssociatedDecl);
16518 !SemaRef.Context.hasSameType(
16519 ParamType, std::get<1>(getParamAndType(E->getAssociatedDecl()))) ||
16520 Replacement.get() != OrigReplacement) {
16521 // When transforming the replacement expression previously, all Sema
16522 // specific annotations, such as implicit casts, are discarded. Calling the
16523 // corresponding sema action is necessary to recover those. Otherwise,
16524 // equivalency of the result would be lost.
16525 TemplateArgument SugaredConverted, CanonicalConverted;
16526 Replacement = SemaRef.CheckTemplateArgument(
16527 Param, ParamType, Replacement.get(), SugaredConverted,
16528 CanonicalConverted,
16529 /*StrictCheck=*/false, Sema::CTAK_Specified);
16530 if (Replacement.isInvalid())
16531 return true;
16532 } else {
16533 // Otherwise, the same expression would have been produced.
16534 Replacement = E->getReplacement();
16535 }
16536
16537 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16538 AssociatedDecl, E->getParameter(), E->getNameLoc(),
16539 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
16540 E->getPackIndex(), E->getFinal());
16541}
16542
16543template<typename Derived>
16546 // Default behavior is to do nothing with this transformation.
16547 return E;
16548}
16549
16550template<typename Derived>
16554 return getDerived().TransformExpr(E->getSubExpr());
16555}
16556
16557template<typename Derived>
16560 UnresolvedLookupExpr *Callee = nullptr;
16561 if (Expr *OldCallee = E->getCallee()) {
16562 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16563 if (CalleeResult.isInvalid())
16564 return ExprError();
16565 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16566 }
16567
16568 Expr *Pattern = E->getPattern();
16569
16571 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16572 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16573
16574 // Determine whether the set of unexpanded parameter packs can and should
16575 // be expanded.
16576 bool Expand = true;
16577 bool RetainExpansion = false;
16578 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16579 NumExpansions = OrigNumExpansions;
16580 if (getDerived().TryExpandParameterPacks(
16581 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16582 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16583 NumExpansions))
16584 return true;
16585
16586 if (!Expand) {
16587 // Do not expand any packs here, just transform and rebuild a fold
16588 // expression.
16589 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16590
16591 ExprResult LHS =
16592 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16593 if (LHS.isInvalid())
16594 return true;
16595
16596 ExprResult RHS =
16597 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16598 if (RHS.isInvalid())
16599 return true;
16600
16601 if (!getDerived().AlwaysRebuild() &&
16602 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16603 return E;
16604
16605 return getDerived().RebuildCXXFoldExpr(
16606 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16607 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16608 }
16609
16610 // Formally a fold expression expands to nested parenthesized expressions.
16611 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16612 // them.
16613 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16614 SemaRef.Diag(E->getEllipsisLoc(),
16615 clang::diag::err_fold_expression_limit_exceeded)
16616 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16617 << E->getSourceRange();
16618 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16619 return ExprError();
16620 }
16621
16622 // The transform has determined that we should perform an elementwise
16623 // expansion of the pattern. Do so.
16624 ExprResult Result = getDerived().TransformExpr(E->getInit());
16625 if (Result.isInvalid())
16626 return true;
16627 bool LeftFold = E->isLeftFold();
16628
16629 // If we're retaining an expansion for a right fold, it is the innermost
16630 // component and takes the init (if any).
16631 if (!LeftFold && RetainExpansion) {
16632 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16633
16634 ExprResult Out = getDerived().TransformExpr(Pattern);
16635 if (Out.isInvalid())
16636 return true;
16637
16638 Result = getDerived().RebuildCXXFoldExpr(
16639 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16640 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16641 if (Result.isInvalid())
16642 return true;
16643 }
16644
16645 bool WarnedOnComparison = false;
16646 for (unsigned I = 0; I != *NumExpansions; ++I) {
16647 Sema::ArgPackSubstIndexRAII SubstIndex(
16648 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16649 ExprResult Out = getDerived().TransformExpr(Pattern);
16650 if (Out.isInvalid())
16651 return true;
16652
16653 if (Out.get()->containsUnexpandedParameterPack()) {
16654 // We still have a pack; retain a pack expansion for this slice.
16655 Result = getDerived().RebuildCXXFoldExpr(
16656 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16657 E->getOperator(), E->getEllipsisLoc(),
16658 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16659 OrigNumExpansions);
16660 } else if (Result.isUsable()) {
16661 // We've got down to a single element; build a binary operator.
16662 Expr *LHS = LeftFold ? Result.get() : Out.get();
16663 Expr *RHS = LeftFold ? Out.get() : Result.get();
16664 if (Callee) {
16665 UnresolvedSet<16> Functions;
16666 Functions.append(Callee->decls_begin(), Callee->decls_end());
16667 Result = getDerived().RebuildCXXOperatorCallExpr(
16668 BinaryOperator::getOverloadedOperator(E->getOperator()),
16669 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16670 Functions, LHS, RHS);
16671 } else {
16672 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16673 E->getOperator(), LHS, RHS,
16674 /*ForFoldExpresion=*/true);
16675 if (!WarnedOnComparison && Result.isUsable()) {
16676 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16677 BO && BO->isComparisonOp()) {
16678 WarnedOnComparison = true;
16679 SemaRef.Diag(BO->getBeginLoc(),
16680 diag::warn_comparison_in_fold_expression)
16681 << BO->getOpcodeStr();
16682 }
16683 }
16684 }
16685 } else
16686 Result = Out;
16687
16688 if (Result.isInvalid())
16689 return true;
16690 }
16691
16692 // If we're retaining an expansion for a left fold, it is the outermost
16693 // component and takes the complete expansion so far as its init (if any).
16694 if (LeftFold && RetainExpansion) {
16695 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16696
16697 ExprResult Out = getDerived().TransformExpr(Pattern);
16698 if (Out.isInvalid())
16699 return true;
16700
16701 Result = getDerived().RebuildCXXFoldExpr(
16702 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16703 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16704 if (Result.isInvalid())
16705 return true;
16706 }
16707
16708 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16709 PE->setIsProducedByFoldExpansion();
16710
16711 // If we had no init and an empty pack, and we're not retaining an expansion,
16712 // then produce a fallback value or error.
16713 if (Result.isUnset())
16714 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16715 E->getOperator());
16716 return Result;
16717}
16718
16719template <typename Derived>
16722 SmallVector<Expr *, 4> TransformedInits;
16723 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16724
16725 QualType T = getDerived().TransformType(E->getType());
16726
16727 bool ArgChanged = false;
16728
16729 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16730 TransformedInits, &ArgChanged))
16731 return ExprError();
16732
16733 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16734 return E;
16735
16736 return getDerived().RebuildCXXParenListInitExpr(
16737 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16738 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16739}
16740
16741template<typename Derived>
16745 return getDerived().TransformExpr(E->getSubExpr());
16746}
16747
16748template<typename Derived>
16751 return SemaRef.MaybeBindToTemporary(E);
16752}
16753
16754template<typename Derived>
16757 return E;
16758}
16759
16760template<typename Derived>
16763 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16764 if (SubExpr.isInvalid())
16765 return ExprError();
16766
16767 if (!getDerived().AlwaysRebuild() &&
16768 SubExpr.get() == E->getSubExpr())
16769 return E;
16770
16771 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16772}
16773
16774template<typename Derived>
16777 // Transform each of the elements.
16778 SmallVector<Expr *, 8> Elements;
16779 bool ArgChanged = false;
16780 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
16781 /*IsCall=*/false, Elements, &ArgChanged))
16782 return ExprError();
16783
16784 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16785 return SemaRef.MaybeBindToTemporary(E);
16786
16787 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
16788 Elements.data(),
16789 Elements.size());
16790}
16791
16792template<typename Derived>
16796 // Transform each of the elements.
16798 bool ArgChanged = false;
16799 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
16800 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
16801
16802 if (OrigElement.isPackExpansion()) {
16803 // This key/value element is a pack expansion.
16805 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
16806 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
16807 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16808
16809 // Determine whether the set of unexpanded parameter packs can
16810 // and should be expanded.
16811 bool Expand = true;
16812 bool RetainExpansion = false;
16813 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
16814 UnsignedOrNone NumExpansions = OrigNumExpansions;
16815 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
16816 OrigElement.Value->getEndLoc());
16817 if (getDerived().TryExpandParameterPacks(
16818 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
16819 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16820 NumExpansions))
16821 return ExprError();
16822
16823 if (!Expand) {
16824 // The transform has determined that we should perform a simple
16825 // transformation on the pack expansion, producing another pack
16826 // expansion.
16827 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16828 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16829 if (Key.isInvalid())
16830 return ExprError();
16831
16832 if (Key.get() != OrigElement.Key)
16833 ArgChanged = true;
16834
16835 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16836 if (Value.isInvalid())
16837 return ExprError();
16838
16839 if (Value.get() != OrigElement.Value)
16840 ArgChanged = true;
16841
16842 ObjCDictionaryElement Expansion = {
16843 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
16844 };
16845 Elements.push_back(Expansion);
16846 continue;
16847 }
16848
16849 // Record right away that the argument was changed. This needs
16850 // to happen even if the array expands to nothing.
16851 ArgChanged = true;
16852
16853 // The transform has determined that we should perform an elementwise
16854 // expansion of the pattern. Do so.
16855 for (unsigned I = 0; I != *NumExpansions; ++I) {
16856 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16857 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16858 if (Key.isInvalid())
16859 return ExprError();
16860
16861 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16862 if (Value.isInvalid())
16863 return ExprError();
16864
16865 ObjCDictionaryElement Element = {
16866 Key.get(), Value.get(), SourceLocation(), NumExpansions
16867 };
16868
16869 // If any unexpanded parameter packs remain, we still have a
16870 // pack expansion.
16871 // FIXME: Can this really happen?
16872 if (Key.get()->containsUnexpandedParameterPack() ||
16873 Value.get()->containsUnexpandedParameterPack())
16874 Element.EllipsisLoc = OrigElement.EllipsisLoc;
16875
16876 Elements.push_back(Element);
16877 }
16878
16879 // FIXME: Retain a pack expansion if RetainExpansion is true.
16880
16881 // We've finished with this pack expansion.
16882 continue;
16883 }
16884
16885 // Transform and check key.
16886 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16887 if (Key.isInvalid())
16888 return ExprError();
16889
16890 if (Key.get() != OrigElement.Key)
16891 ArgChanged = true;
16892
16893 // Transform and check value.
16895 = getDerived().TransformExpr(OrigElement.Value);
16896 if (Value.isInvalid())
16897 return ExprError();
16898
16899 if (Value.get() != OrigElement.Value)
16900 ArgChanged = true;
16901
16902 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
16903 std::nullopt};
16904 Elements.push_back(Element);
16905 }
16906
16907 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16908 return SemaRef.MaybeBindToTemporary(E);
16909
16910 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
16911 Elements);
16912}
16913
16914template<typename Derived>
16917 TypeSourceInfo *EncodedTypeInfo
16918 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
16919 if (!EncodedTypeInfo)
16920 return ExprError();
16921
16922 if (!getDerived().AlwaysRebuild() &&
16923 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
16924 return E;
16925
16926 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
16927 EncodedTypeInfo,
16928 E->getRParenLoc());
16929}
16930
16931template<typename Derived>
16934 // This is a kind of implicit conversion, and it needs to get dropped
16935 // and recomputed for the same general reasons that ImplicitCastExprs
16936 // do, as well a more specific one: this expression is only valid when
16937 // it appears *immediately* as an argument expression.
16938 return getDerived().TransformExpr(E->getSubExpr());
16939}
16940
16941template<typename Derived>
16944 TypeSourceInfo *TSInfo
16945 = getDerived().TransformType(E->getTypeInfoAsWritten());
16946 if (!TSInfo)
16947 return ExprError();
16948
16949 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
16950 if (Result.isInvalid())
16951 return ExprError();
16952
16953 if (!getDerived().AlwaysRebuild() &&
16954 TSInfo == E->getTypeInfoAsWritten() &&
16955 Result.get() == E->getSubExpr())
16956 return E;
16957
16958 return SemaRef.ObjC().BuildObjCBridgedCast(
16959 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
16960 Result.get());
16961}
16962
16963template <typename Derived>
16966 return E;
16967}
16968
16969template<typename Derived>
16972 // Transform arguments.
16973 bool ArgChanged = false;
16975 Args.reserve(E->getNumArgs());
16976 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
16977 &ArgChanged))
16978 return ExprError();
16979
16980 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
16981 // Class message: transform the receiver type.
16982 TypeSourceInfo *ReceiverTypeInfo
16983 = getDerived().TransformType(E->getClassReceiverTypeInfo());
16984 if (!ReceiverTypeInfo)
16985 return ExprError();
16986
16987 // If nothing changed, just retain the existing message send.
16988 if (!getDerived().AlwaysRebuild() &&
16989 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
16990 return SemaRef.MaybeBindToTemporary(E);
16991
16992 // Build a new class message send.
16994 E->getSelectorLocs(SelLocs);
16995 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
16996 E->getSelector(),
16997 SelLocs,
16998 E->getMethodDecl(),
16999 E->getLeftLoc(),
17000 Args,
17001 E->getRightLoc());
17002 }
17003 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17004 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17005 if (!E->getMethodDecl())
17006 return ExprError();
17007
17008 // Build a new class message send to 'super'.
17010 E->getSelectorLocs(SelLocs);
17011 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17012 E->getSelector(),
17013 SelLocs,
17014 E->getReceiverType(),
17015 E->getMethodDecl(),
17016 E->getLeftLoc(),
17017 Args,
17018 E->getRightLoc());
17019 }
17020
17021 // Instance message: transform the receiver
17022 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17023 "Only class and instance messages may be instantiated");
17024 ExprResult Receiver
17025 = getDerived().TransformExpr(E->getInstanceReceiver());
17026 if (Receiver.isInvalid())
17027 return ExprError();
17028
17029 // If nothing changed, just retain the existing message send.
17030 if (!getDerived().AlwaysRebuild() &&
17031 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17032 return SemaRef.MaybeBindToTemporary(E);
17033
17034 // Build a new instance message send.
17036 E->getSelectorLocs(SelLocs);
17037 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17038 E->getSelector(),
17039 SelLocs,
17040 E->getMethodDecl(),
17041 E->getLeftLoc(),
17042 Args,
17043 E->getRightLoc());
17044}
17045
17046template<typename Derived>
17049 return E;
17050}
17051
17052template<typename Derived>
17055 return E;
17056}
17057
17058template<typename Derived>
17061 // Transform the base expression.
17062 ExprResult Base = getDerived().TransformExpr(E->getBase());
17063 if (Base.isInvalid())
17064 return ExprError();
17065
17066 // We don't need to transform the ivar; it will never change.
17067
17068 // If nothing changed, just retain the existing expression.
17069 if (!getDerived().AlwaysRebuild() &&
17070 Base.get() == E->getBase())
17071 return E;
17072
17073 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17074 E->getLocation(),
17075 E->isArrow(), E->isFreeIvar());
17076}
17077
17078template<typename Derived>
17081 // 'super' and types never change. Property never changes. Just
17082 // retain the existing expression.
17083 if (!E->isObjectReceiver())
17084 return E;
17085
17086 // Transform the base expression.
17087 ExprResult Base = getDerived().TransformExpr(E->getBase());
17088 if (Base.isInvalid())
17089 return ExprError();
17090
17091 // We don't need to transform the property; it will never change.
17092
17093 // If nothing changed, just retain the existing expression.
17094 if (!getDerived().AlwaysRebuild() &&
17095 Base.get() == E->getBase())
17096 return E;
17097
17098 if (E->isExplicitProperty())
17099 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17100 E->getExplicitProperty(),
17101 E->getLocation());
17102
17103 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17104 SemaRef.Context.PseudoObjectTy,
17105 E->getImplicitPropertyGetter(),
17106 E->getImplicitPropertySetter(),
17107 E->getLocation());
17108}
17109
17110template<typename Derived>
17113 // Transform the base expression.
17114 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17115 if (Base.isInvalid())
17116 return ExprError();
17117
17118 // Transform the key expression.
17119 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17120 if (Key.isInvalid())
17121 return ExprError();
17122
17123 // If nothing changed, just retain the existing expression.
17124 if (!getDerived().AlwaysRebuild() &&
17125 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17126 return E;
17127
17128 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17129 Base.get(), Key.get(),
17130 E->getAtIndexMethodDecl(),
17131 E->setAtIndexMethodDecl());
17132}
17133
17134template<typename Derived>
17137 // Transform the base expression.
17138 ExprResult Base = getDerived().TransformExpr(E->getBase());
17139 if (Base.isInvalid())
17140 return ExprError();
17141
17142 // If nothing changed, just retain the existing expression.
17143 if (!getDerived().AlwaysRebuild() &&
17144 Base.get() == E->getBase())
17145 return E;
17146
17147 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17148 E->getOpLoc(),
17149 E->isArrow());
17150}
17151
17152template<typename Derived>
17155 bool ArgumentChanged = false;
17156 SmallVector<Expr*, 8> SubExprs;
17157 SubExprs.reserve(E->getNumSubExprs());
17158 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17159 SubExprs, &ArgumentChanged))
17160 return ExprError();
17161
17162 if (!getDerived().AlwaysRebuild() &&
17163 !ArgumentChanged)
17164 return E;
17165
17166 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17167 SubExprs,
17168 E->getRParenLoc());
17169}
17170
17171template<typename Derived>
17174 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17175 if (SrcExpr.isInvalid())
17176 return ExprError();
17177
17178 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17179 if (!Type)
17180 return ExprError();
17181
17182 if (!getDerived().AlwaysRebuild() &&
17183 Type == E->getTypeSourceInfo() &&
17184 SrcExpr.get() == E->getSrcExpr())
17185 return E;
17186
17187 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17188 SrcExpr.get(), Type,
17189 E->getRParenLoc());
17190}
17191
17192template<typename Derived>
17195 BlockDecl *oldBlock = E->getBlockDecl();
17196
17197 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17198 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17199
17200 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17201 blockScope->TheDecl->setBlockMissingReturnType(
17202 oldBlock->blockMissingReturnType());
17203
17205 SmallVector<QualType, 4> paramTypes;
17206
17207 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17208
17209 // Parameter substitution.
17210 Sema::ExtParameterInfoBuilder extParamInfos;
17211 if (getDerived().TransformFunctionTypeParams(
17212 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17213 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17214 extParamInfos)) {
17215 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17216 return ExprError();
17217 }
17218
17219 QualType exprResultType =
17220 getDerived().TransformType(exprFunctionType->getReturnType());
17221
17222 auto epi = exprFunctionType->getExtProtoInfo();
17223 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17224
17226 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17227 blockScope->FunctionType = functionType;
17228
17229 // Set the parameters on the block decl.
17230 if (!params.empty())
17231 blockScope->TheDecl->setParams(params);
17232
17233 if (!oldBlock->blockMissingReturnType()) {
17234 blockScope->HasImplicitReturnType = false;
17235 blockScope->ReturnType = exprResultType;
17236 }
17237
17238 // Transform the body
17239 StmtResult body = getDerived().TransformStmt(E->getBody());
17240 if (body.isInvalid()) {
17241 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17242 return ExprError();
17243 }
17244
17245#ifndef NDEBUG
17246 // In builds with assertions, make sure that we captured everything we
17247 // captured before.
17248 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17249 for (const auto &I : oldBlock->captures()) {
17250 VarDecl *oldCapture = I.getVariable();
17251
17252 // Ignore parameter packs.
17253 if (oldCapture->isParameterPack())
17254 continue;
17255
17256 VarDecl *newCapture =
17257 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17258 oldCapture));
17259 assert(blockScope->CaptureMap.count(newCapture));
17260 }
17261
17262 // The this pointer may not be captured by the instantiated block, even when
17263 // it's captured by the original block, if the expression causing the
17264 // capture is in the discarded branch of a constexpr if statement.
17265 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17266 "this pointer isn't captured in the old block");
17267 }
17268#endif
17269
17270 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17271 /*Scope=*/nullptr);
17272}
17273
17274template<typename Derived>
17277 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17278 if (SrcExpr.isInvalid())
17279 return ExprError();
17280
17281 QualType Type = getDerived().TransformType(E->getType());
17282
17283 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17284 E->getRParenLoc());
17285}
17286
17287template<typename Derived>
17290 bool ArgumentChanged = false;
17291 SmallVector<Expr*, 8> SubExprs;
17292 SubExprs.reserve(E->getNumSubExprs());
17293 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17294 SubExprs, &ArgumentChanged))
17295 return ExprError();
17296
17297 if (!getDerived().AlwaysRebuild() &&
17298 !ArgumentChanged)
17299 return E;
17300
17301 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17302 E->getOp(), E->getRParenLoc());
17303}
17304
17305//===----------------------------------------------------------------------===//
17306// Type reconstruction
17307//===----------------------------------------------------------------------===//
17308
17309template<typename Derived>
17312 return SemaRef.BuildPointerType(PointeeType, Star,
17314}
17315
17316template<typename Derived>
17319 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17321}
17322
17323template<typename Derived>
17326 bool WrittenAsLValue,
17327 SourceLocation Sigil) {
17328 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17329 Sigil, getDerived().getBaseEntity());
17330}
17331
17332template <typename Derived>
17334 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17335 SourceLocation Sigil) {
17336 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17338}
17339
17340template<typename Derived>
17342 const ObjCTypeParamDecl *Decl,
17343 SourceLocation ProtocolLAngleLoc,
17345 ArrayRef<SourceLocation> ProtocolLocs,
17346 SourceLocation ProtocolRAngleLoc) {
17347 return SemaRef.ObjC().BuildObjCTypeParamType(
17348 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17349 /*FailOnError=*/true);
17350}
17351
17352template<typename Derived>
17354 QualType BaseType,
17355 SourceLocation Loc,
17356 SourceLocation TypeArgsLAngleLoc,
17358 SourceLocation TypeArgsRAngleLoc,
17359 SourceLocation ProtocolLAngleLoc,
17361 ArrayRef<SourceLocation> ProtocolLocs,
17362 SourceLocation ProtocolRAngleLoc) {
17363 return SemaRef.ObjC().BuildObjCObjectType(
17364 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17365 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17366 /*FailOnError=*/true,
17367 /*Rebuilding=*/true);
17368}
17369
17370template<typename Derived>
17372 QualType PointeeType,
17374 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17375}
17376
17377template <typename Derived>
17379 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17380 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17381 if (SizeExpr || !Size)
17382 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17383 IndexTypeQuals, BracketsRange,
17385
17386 QualType Types[] = {
17387 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17388 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17389 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17390 };
17391 QualType SizeType;
17392 for (const auto &T : Types)
17393 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17394 SizeType = T;
17395 break;
17396 }
17397
17398 // Note that we can return a VariableArrayType here in the case where
17399 // the element type was a dependent VariableArrayType.
17400 IntegerLiteral *ArraySize
17401 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17402 /*FIXME*/BracketsRange.getBegin());
17403 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17404 IndexTypeQuals, BracketsRange,
17406}
17407
17408template <typename Derived>
17410 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17411 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17412 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17413 IndexTypeQuals, BracketsRange);
17414}
17415
17416template <typename Derived>
17418 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17419 SourceRange BracketsRange) {
17420 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17421 IndexTypeQuals, BracketsRange);
17422}
17423
17424template <typename Derived>
17426 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17427 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17428 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17429 SizeExpr,
17430 IndexTypeQuals, BracketsRange);
17431}
17432
17433template <typename Derived>
17435 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17436 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17437 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17438 SizeExpr,
17439 IndexTypeQuals, BracketsRange);
17440}
17441
17442template <typename Derived>
17444 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17445 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17446 AttributeLoc);
17447}
17448
17449template <typename Derived>
17451 unsigned NumElements,
17452 VectorKind VecKind) {
17453 // FIXME: semantic checking!
17454 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17455}
17456
17457template <typename Derived>
17459 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17460 VectorKind VecKind) {
17461 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17462}
17463
17464template<typename Derived>
17466 unsigned NumElements,
17467 SourceLocation AttributeLoc) {
17468 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17469 NumElements, true);
17470 IntegerLiteral *VectorSize
17471 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17472 AttributeLoc);
17473 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17474}
17475
17476template<typename Derived>
17479 Expr *SizeExpr,
17480 SourceLocation AttributeLoc) {
17481 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17482}
17483
17484template <typename Derived>
17486 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17487 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17488 NumColumns);
17489}
17490
17491template <typename Derived>
17493 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17494 SourceLocation AttributeLoc) {
17495 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17496 AttributeLoc);
17497}
17498
17499template <typename Derived>
17503 return SemaRef.BuildFunctionType(T, ParamTypes,
17506 EPI);
17507}
17508
17509template<typename Derived>
17511 return SemaRef.Context.getFunctionNoProtoType(T);
17512}
17513
17514template <typename Derived>
17517 SourceLocation NameLoc, Decl *D) {
17518 assert(D && "no decl found");
17519 if (D->isInvalidDecl()) return QualType();
17520
17521 // FIXME: Doesn't account for ObjCInterfaceDecl!
17522 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17523 // A valid resolved using typename pack expansion decl can have multiple
17524 // UsingDecls, but they must each have exactly one type, and it must be
17525 // the same type in every case. But we must have at least one expansion!
17526 if (UPD->expansions().empty()) {
17527 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17528 << UPD->isCXXClassMember() << UPD;
17529 return QualType();
17530 }
17531
17532 // We might still have some unresolved types. Try to pick a resolved type
17533 // if we can. The final instantiation will check that the remaining
17534 // unresolved types instantiate to the type we pick.
17535 QualType FallbackT;
17536 QualType T;
17537 for (auto *E : UPD->expansions()) {
17538 QualType ThisT =
17539 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17540 if (ThisT.isNull())
17541 continue;
17542 if (ThisT->getAs<UnresolvedUsingType>())
17543 FallbackT = ThisT;
17544 else if (T.isNull())
17545 T = ThisT;
17546 else
17547 assert(getSema().Context.hasSameType(ThisT, T) &&
17548 "mismatched resolved types in using pack expansion");
17549 }
17550 return T.isNull() ? FallbackT : T;
17551 }
17552 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17553 assert(Using->hasTypename() &&
17554 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17555
17556 // A valid resolved using typename decl points to exactly one type decl.
17557 assert(++Using->shadow_begin() == Using->shadow_end());
17558
17559 UsingShadowDecl *Shadow = *Using->shadow_begin();
17560 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17561 return QualType();
17562 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17563 }
17565 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17566 return SemaRef.Context.getUnresolvedUsingType(
17568}
17569
17570template <typename Derived>
17572 TypeOfKind Kind) {
17573 return SemaRef.BuildTypeofExprType(E, Kind);
17574}
17575
17576template<typename Derived>
17578 TypeOfKind Kind) {
17579 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17580}
17581
17582template <typename Derived>
17584 return SemaRef.BuildDecltypeType(E);
17585}
17586
17587template <typename Derived>
17589 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17590 SourceLocation EllipsisLoc, bool FullySubstituted,
17591 ArrayRef<QualType> Expansions) {
17592 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17593 FullySubstituted, Expansions);
17594}
17595
17596template<typename Derived>
17598 UnaryTransformType::UTTKind UKind,
17599 SourceLocation Loc) {
17600 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17601}
17602
17603template <typename Derived>
17606 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17607 return SemaRef.CheckTemplateIdType(
17608 Keyword, Template, TemplateNameLoc, TemplateArgs,
17609 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17610}
17611
17612template<typename Derived>
17614 SourceLocation KWLoc) {
17615 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17616}
17617
17618template<typename Derived>
17620 SourceLocation KWLoc,
17621 bool isReadPipe) {
17622 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17623 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17624}
17625
17626template <typename Derived>
17628 unsigned NumBits,
17629 SourceLocation Loc) {
17630 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17631 NumBits, true);
17632 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17633 SemaRef.Context.IntTy, Loc);
17634 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17635}
17636
17637template <typename Derived>
17639 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17640 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17641}
17642
17643template <typename Derived>
17645 bool TemplateKW,
17646 TemplateName Name) {
17647 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17648 Name);
17649}
17650
17651template <typename Derived>
17653 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17654 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17656 TemplateName.setIdentifier(&Name, NameLoc);
17658 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17659 TemplateName, ParsedType::make(ObjectType),
17660 /*EnteringContext=*/false, Template,
17661 AllowInjectedClassName);
17662 return Template.get();
17663}
17664
17665template<typename Derived>
17668 SourceLocation TemplateKWLoc,
17669 OverloadedOperatorKind Operator,
17670 SourceLocation NameLoc,
17671 QualType ObjectType,
17672 bool AllowInjectedClassName) {
17673 UnqualifiedId Name;
17674 // FIXME: Bogus location information.
17675 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17676 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17678 getSema().ActOnTemplateName(
17679 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17680 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17681 return Template.get();
17682}
17683
17684template <typename Derived>
17687 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17688 Expr *Second) {
17689 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17690
17691 if (First->getObjectKind() == OK_ObjCProperty) {
17694 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17695 Opc, First, Second);
17696 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17697 if (Result.isInvalid())
17698 return ExprError();
17699 First = Result.get();
17700 }
17701
17702 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17703 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17704 if (Result.isInvalid())
17705 return ExprError();
17706 Second = Result.get();
17707 }
17708
17709 // Determine whether this should be a builtin operation.
17710 if (Op == OO_Subscript) {
17711 if (!First->getType()->isOverloadableType() &&
17712 !Second->getType()->isOverloadableType())
17713 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17714 OpLoc);
17715 } else if (Op == OO_Arrow) {
17716 // It is possible that the type refers to a RecoveryExpr created earlier
17717 // in the tree transformation.
17718 if (First->getType()->isDependentType())
17719 return ExprError();
17720 // -> is never a builtin operation.
17721 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17722 } else if (Second == nullptr || isPostIncDec) {
17723 if (!First->getType()->isOverloadableType() ||
17724 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17725 // The argument is not of overloadable type, or this is an expression
17726 // of the form &Class::member, so try to create a built-in unary
17727 // operation.
17729 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17730
17731 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17732 }
17733 } else {
17734 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17735 !First->getType()->isOverloadableType() &&
17736 !Second->getType()->isOverloadableType()) {
17737 // Neither of the arguments is type-dependent or has an overloadable
17738 // type, so try to create a built-in binary operation.
17741 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17742 if (Result.isInvalid())
17743 return ExprError();
17744
17745 return Result;
17746 }
17747 }
17748
17749 // Create the overloaded operator invocation for unary operators.
17750 if (!Second || isPostIncDec) {
17752 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17753 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17754 RequiresADL);
17755 }
17756
17757 // Create the overloaded operator invocation for binary operators.
17759 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17760 First, Second, RequiresADL);
17761 if (Result.isInvalid())
17762 return ExprError();
17763
17764 return Result;
17765}
17766
17767template<typename Derived>
17770 SourceLocation OperatorLoc,
17771 bool isArrow,
17772 CXXScopeSpec &SS,
17773 TypeSourceInfo *ScopeType,
17774 SourceLocation CCLoc,
17775 SourceLocation TildeLoc,
17776 PseudoDestructorTypeStorage Destroyed) {
17777 QualType CanonicalBaseType = Base->getType().getCanonicalType();
17778 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
17779 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
17780 (isArrow && isa<PointerType>(CanonicalBaseType) &&
17781 !cast<PointerType>(CanonicalBaseType)
17782 ->getPointeeType()
17783 ->getAsCanonical<RecordType>())) {
17784 // This pseudo-destructor expression is still a pseudo-destructor.
17785 return SemaRef.BuildPseudoDestructorExpr(
17786 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
17787 CCLoc, TildeLoc, Destroyed);
17788 }
17789
17790 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
17791 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
17792 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
17793 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
17794 NameInfo.setNamedTypeInfo(DestroyedType);
17795
17796 // The scope type is now known to be a valid nested name specifier
17797 // component. Tack it on to the nested name specifier.
17798 if (ScopeType) {
17799 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
17800 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
17801 diag::err_expected_class_or_namespace)
17802 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
17803 return ExprError();
17804 }
17805 SS.clear();
17806 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
17807 }
17808
17809 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
17810 return getSema().BuildMemberReferenceExpr(
17811 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
17812 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
17813 /*TemplateArgs*/ nullptr,
17814 /*S*/ nullptr);
17815}
17816
17817template<typename Derived>
17820 SourceLocation Loc = S->getBeginLoc();
17821 CapturedDecl *CD = S->getCapturedDecl();
17822 unsigned NumParams = CD->getNumParams();
17823 unsigned ContextParamPos = CD->getContextParamPosition();
17825 for (unsigned I = 0; I < NumParams; ++I) {
17826 if (I != ContextParamPos) {
17827 Params.push_back(
17828 std::make_pair(
17829 CD->getParam(I)->getName(),
17830 getDerived().TransformType(CD->getParam(I)->getType())));
17831 } else {
17832 Params.push_back(std::make_pair(StringRef(), QualType()));
17833 }
17834 }
17835 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
17836 S->getCapturedRegionKind(), Params);
17837 StmtResult Body;
17838 {
17839 Sema::CompoundScopeRAII CompoundScope(getSema());
17840 Body = getDerived().TransformStmt(S->getCapturedStmt());
17841 }
17842
17843 if (Body.isInvalid()) {
17844 getSema().ActOnCapturedRegionError();
17845 return StmtError();
17846 }
17847
17848 return getSema().ActOnCapturedRegionEnd(Body.get());
17849}
17850
17851template <typename Derived>
17854 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
17855 // function definition or instantiation of a function template specialization
17856 // and will therefore never appear in a dependent context.
17857 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
17858 "context");
17859}
17860
17861template <typename Derived>
17863 // We can transform the base expression and allow argument resolution to fill
17864 // in the rest.
17865 return getDerived().TransformExpr(E->getArgLValue());
17866}
17867
17868} // end namespace clang
17869
17870#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:2996
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:3034
ArrayTypeTrait getTrait() const
Definition ExprCXX.h:3036
Expr * getDimensionExpression() const
Definition ExprCXX.h:3046
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition ExprCXX.h:3042
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:3033
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h: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:2193
Stmt * getSubStmt()
Definition Stmt.h:2229
SourceLocation getAttrLoc() const
Definition Stmt.h:2224
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2225
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:2179
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:2141
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:4668
void setIsVariadic(bool value)
Definition Decl.h:4744
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:3125
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5476
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:5495
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:5494
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition Expr.h: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:1493
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition ExprCXX.h:723
CXXCatchStmt - This represents a C++ catch block.
Definition StmtCXX.h:28
A C++ const_cast expression (C++ [expr.const.cast]).
Definition ExprCXX.h:566
Represents a call to a C++ constructor.
Definition ExprCXX.h:1548
SourceRange getParenOrBraceRange() const
Definition ExprCXX.h:1729
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition ExprCXX.h:1691
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition ExprCXX.h:1641
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:581
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:575
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition ExprCXX.h:1630
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition ExprCXX.h:1688
Represents a C++ constructor within a class.
Definition DeclCXX.h:2604
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1270
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition ExprCXX.cpp:1039
A use of a default initializer in a constructor or in aggregate initialization.
Definition ExprCXX.h:1377
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2626
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition ExprCXX.h:3870
Represents a C++ destructor within a class.
Definition DeclCXX.h:2869
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:481
Represents a folding of a pack over an operator.
Definition ExprCXX.h:5032
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition StmtCXX.h:135
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition ExprCXX.h:1831
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition ExprCXX.h:1751
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:179
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2129
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition ExprCXX.h:375
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition ExprCXX.h:406
SourceRange getAngleBrackets() const LLVM_READONLY
Definition ExprCXX.h:413
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition ExprCXX.h:409
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition ExprCXX.h:2355
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition ExprCXX.h:4309
The null pointer literal (C++11 [lex.nullptr])
Definition ExprCXX.h:768
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:84
Represents a list-initialization with parenthesis.
Definition ExprCXX.h:5141
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition ExprCXX.h:2745
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
unsigned getLambdaDependencyKind() const
Definition DeclCXX.h:1854
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition ExprCXX.h:526
A rewritten comparison expression that was originally written using operator syntax.
Definition ExprCXX.h:286
An expression "T()" which creates an rvalue of a non-class type T.
Definition ExprCXX.h:2196
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:73
void Make(ASTContext &Context, TypeLoc TL, SourceLocation ColonColonLoc)
Make a nested-name-specifier of the form 'type::'.
Definition DeclSpec.cpp:51
char * location_data() const
Retrieve the data associated with the source-location information.
Definition DeclSpec.h:206
SourceRange getRange() const
Definition DeclSpec.h:79
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition DeclSpec.cpp:75
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition DeclSpec.h:94
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition DeclSpec.cpp:123
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition DeclSpec.h:210
void Extend(ASTContext &Context, NamespaceBaseDecl *Namespace, SourceLocation NamespaceLoc, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'name...
Definition DeclSpec.cpp:62
void MakeMicrosoftSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition DeclSpec.cpp:85
bool isEmpty() const
No scope specifier.
Definition DeclSpec.h:178
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition DeclSpec.cpp:103
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition ExprCXX.h:800
Represents a C++ functional cast expression that builds a temporary object.
Definition ExprCXX.h:1899
Represents the this expression in C++.
Definition ExprCXX.h:1154
A C++ throw-expression (C++ [except.throw]).
Definition ExprCXX.h:1208
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:69
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition ExprCXX.h:848
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition ExprCXX.h:3744
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition ExprCXX.h:3788
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition ExprCXX.h:3799
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition ExprCXX.h:3782
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition ExprCXX.h:3793
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition ExprCXX.h:3802
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1068
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h: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:4940
unsigned getNumParams() const
Definition Decl.h:4978
unsigned getContextParamPosition() const
Definition Decl.h:5007
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4980
This captures a statement into a function.
Definition Stmt.h:3917
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1455
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:4021
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:4112
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition Stmt.cpp:1470
CaseStmt - Represent a case statement.
Definition Stmt.h:1910
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition Expr.cpp:1979
Expr * getSubExpr()
Definition Expr.h:3660
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4782
Represents a 'co_await' expression.
Definition ExprCXX.h:5369
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:1730
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Stmt.h:1780
body_range body()
Definition Stmt.h:1793
SourceLocation getLBracLoc() const
Definition Stmt.h:1847
bool hasStoredFPFeatures() const
Definition Stmt.h:1777
Stmt * body_back()
Definition Stmt.h:1798
SourceLocation getRBracLoc() const
Definition Stmt.h:1848
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:3109
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:5450
Wrapper for source info for pointers decayed from arrays and functions.
Definition TypeLoc.h:1445
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1449
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2109
DeclContextLookupResult lookup_result
Definition DeclBase.h:2577
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addDecl(Decl *D)
Add the declaration D into this context.
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1270
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1621
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
bool isInvalidDecl() const
Definition DeclBase.h:588
SourceLocation getLocation() const
Definition DeclBase.h:439
DeclContext * getDeclContext()
Definition DeclBase.h:448
AccessSpecifier getAccess() const
Definition DeclBase.h:507
The name of a declaration.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition Decl.h:822
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:809
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:1874
void setDecltypeLoc(SourceLocation Loc)
Definition TypeLoc.h:2259
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2484
DeferStmt - This represents a deferred statement.
Definition Stmt.h:3226
static DeferStmt * Create(ASTContext &Context, SourceLocation DeferLoc, Stmt *Body)
Definition Stmt.cpp:1514
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:1969
Represents an extended address space qualifier where the input address space value is dependent.
Definition TypeBase.h:4061
Represents a 'co_await' expression while the type of the promise is dependent.
Definition ExprCXX.h:5401
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2552
A qualified reference to a name whose declaration cannot yet be resolved.
Definition ExprCXX.h:3510
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3584
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition ExprCXX.h:3558
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3576
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition ExprCXX.h:3594
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3568
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3611
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3549
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3604
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3546
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h: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:2822
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:3661
This represents one expression.
Definition Expr.h:112
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition Expr.h:177
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:194
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition Expr.h:451
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3081
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3213
QualType getType() const
Definition Expr.h:144
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition Expr.h:523
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition Expr.h:434
An expression trait intrinsic.
Definition ExprCXX.h:3069
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h: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:2878
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:4841
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:3426
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:2959
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:2249
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:2998
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:2136
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition ExprCXX.h:1968
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition ExprCXX.cpp:1363
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1358
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1367
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition ExprCXX.h:2033
Represents the results of name lookup.
Definition Lookup.h:147
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
Definition Lookup.h:607
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition Lookup.h:475
bool empty() const
Return true if no decls were found.
Definition Lookup.h:362
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Definition Lookup.h:666
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition Lookup.h:576
DeclarationName getLookupName() const
Gets the name to look up.
Definition Lookup.h:265
This represents a Microsoft inline-assembly statement extension.
Definition Stmt.h:3645
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition StmtCXX.h:253
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4340
A member reference to an MSPropertyDecl.
Definition ExprCXX.h:936
MS property subscript expression.
Definition ExprCXX.h:1006
void setExpansionLoc(SourceLocation Loc)
Definition TypeLoc.h:1354
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4920
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
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h:1693
This represents the 'absent' clause in the 'pragma omp assume' directive.
This represents 'acq_rel' clause in the 'pragma omp atomic|flush' directives.
This represents 'acquire' clause in the 'pragma omp atomic|flush' directives.
This represents clause 'affinity' in the 'pragma omp task'-based directives.
This represents the 'align' clause in the 'pragma omp allocate' directive.
This represents clause 'aligned' in the 'pragma omp ...' directives.
This represents clause 'allocate' in the 'pragma omp ...' directives.
This represents 'allocator' clause in the 'pragma omp ...' directive.
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
Definition ExprOpenMP.h:24
This represents 'at' clause in the 'pragma omp error' directive.
This represents 'atomic_default_mem_order' clause in the 'pragma omp requires' directive.
This represents 'bind' clause in the 'pragma omp ...' directives.
This represents 'capture' clause in the 'pragma omp atomic' directive.
This is a basic class for representing single OpenMP clause.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
This represents 'collapse' clause in the 'pragma omp ...' directive.
This represents 'compare' clause in the 'pragma omp atomic' directive.
This represents the 'contains' clause in the 'pragma omp assume' directive.
This represents clause 'copyin' in the 'pragma omp ...' directives.
This represents clause 'copyprivate' in the 'pragma omp ...' directives.
This represents 'default' clause in the 'pragma omp ...' directive.
This represents 'defaultmap' clause in the 'pragma omp ...' directive.
This represents implicit clause 'depend' for the 'pragma omp task' directive.
This represents implicit clause 'depobj' for the 'pragma omp depobj' directive.
This represents 'destroy' clause in the 'pragma omp depobj' directive or the 'pragma omp interop' dir...
This represents 'detach' clause in the 'pragma omp task' directive.
This represents 'device' clause in the 'pragma omp ...' directive.
This represents 'dist_schedule' clause in the 'pragma omp ...' directive.
This represents the 'doacross' clause for the 'pragma omp ordered' directive.
This represents 'dyn_groupprivate' clause in 'pragma omp target ...' and 'pragma omp teams ....
This represents 'dynamic_allocators' clause in the 'pragma omp requires' directive.
This represents clause 'exclusive' in the 'pragma omp scan' directive.
This represents 'fail' clause in the 'pragma omp atomic' directive.
This represents 'filter' clause in the 'pragma omp ...' directive.
This represents 'final' clause in the 'pragma omp ...' directive.
This represents clause 'firstprivate' in the 'pragma omp ...' directives.
This represents implicit clause 'flush' for the 'pragma omp flush' directive.
This represents clause 'from' in the 'pragma omp ...' directives.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
This represents 'grainsize' clause in the 'pragma omp ...' directive.
This represents clause 'has_device_ptr' in the 'pragma omp ...' directives.
This represents 'hint' clause in the 'pragma omp ...' directive.
This represents the 'holds' clause in the 'pragma omp assume' directive.
This represents 'if' clause in the 'pragma omp ...' directive.
This represents clause 'in_reduction' in the 'pragma omp task' directives.
This represents clause 'inclusive' in the 'pragma omp scan' directive.
This represents the 'init' clause in 'pragma omp ...' directives.
This represents clause 'is_device_ptr' in the 'pragma omp ...' directives.
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
Definition ExprOpenMP.h:151
This represents clause 'lastprivate' in the 'pragma omp ...' directives.
This represents clause 'linear' in the 'pragma omp ...' directives.
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
This represents clauses with a list of expressions that are mappable.
This represents 'mergeable' clause in the 'pragma omp ...' directive.
This represents the 'message' clause in the 'pragma omp error' and the 'pragma omp parallel' directiv...
This represents the 'no_openmp' clause in the 'pragma omp assume' directive.
This represents the 'no_openmp_constructs' clause in the.
This represents the 'no_openmp_routines' clause in the 'pragma omp assume' directive.
This represents the 'no_parallelism' clause in the 'pragma omp assume' directive.
This represents 'nocontext' clause in the 'pragma omp ...' directive.
This represents 'nogroup' clause in the 'pragma omp ...' directive.
This represents clause 'nontemporal' in the 'pragma omp ...' directives.
This represents 'novariants' clause in the 'pragma omp ...' directive.
This represents 'nowait' clause in the 'pragma omp ...' directive.
This represents 'num_tasks' clause in the 'pragma omp ...' directive.
This represents 'num_teams' clause in the 'pragma omp ...' directive.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
This represents 'order' clause in the 'pragma omp ...' directive.
This represents 'ordered' clause in the 'pragma omp ...' directive.
Representation of the 'partial' clause of the 'pragma omp unroll' directive.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
This represents 'priority' clause in the 'pragma omp ...' directive.
This represents clause 'private' in the 'pragma omp ...' directives.
This represents 'proc_bind' clause in the 'pragma omp ...' directive.
This represents 'read' clause in the 'pragma omp atomic' directive.
This represents clause 'reduction' in the 'pragma omp ...' directives.
This represents 'relaxed' clause in the 'pragma omp atomic' directives.
This represents 'release' clause in the 'pragma omp atomic|flush' directives.
This represents 'reverse_offload' clause in the 'pragma omp requires' directive.
This represents 'simd' clause in the 'pragma omp ...' directive.
This represents 'safelen' clause in the 'pragma omp ...' directive.
This represents 'schedule' clause in the 'pragma omp ...' directive.
This represents 'self_maps' clause in the 'pragma omp requires' directive.
This represents 'seq_cst' clause in the 'pragma omp atomic|flush' directives.
This represents the 'severity' clause in the 'pragma omp error' and the 'pragma omp parallel' directi...
This represents clause 'shared' in the 'pragma omp ...' directives.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
This represents clause 'task_reduction' in the 'pragma omp taskgroup' directives.
This represents 'thread_limit' clause in the 'pragma omp ...' directive.
This represents 'threads' clause in the 'pragma omp ...' directive.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
This represents clause 'to' in the 'pragma omp ...' directives.
This represents 'unified_address' clause in the 'pragma omp requires' directive.
This represents 'unified_shared_memory' clause in the 'pragma omp requires' directive.
This represents 'untied' clause in the 'pragma omp ...' directive.
This represents 'update' clause in the 'pragma omp atomic' directive.
This represents the 'use' clause in 'pragma omp ...' directives.
This represents clause 'use_device_addr' in the 'pragma omp ...' directives.
This represents clause 'use_device_ptr' in the 'pragma omp ...' directives.
This represents clause 'uses_allocators' in the 'pragma omp target'-based directives.
This represents 'weak' clause in the 'pragma omp atomic' directives.
This represents 'write' clause in the 'pragma omp atomic' directive.
This represents 'ompx_attribute' clause in a directive that might generate an outlined function.
This represents 'ompx_bare' clause in the 'pragma omp target teams ...' directive.
This represents 'ompx_dyn_cgroup_mem' clause in the 'pragma omp target ...' directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition ExprObjC.h:192
Represents Objective-C's @catch statement.
Definition StmtObjC.h:77
Represents Objective-C's @finally statement.
Definition StmtObjC.h:127
Represents Objective-C's @synchronized statement.
Definition StmtObjC.h:303
Represents Objective-C's @throw statement.
Definition StmtObjC.h:358
Represents Objective-C's @try ... @catch ... @finally statement.
Definition StmtObjC.h:167
Represents Objective-C's @autoreleasepool Statement.
Definition StmtObjC.h:394
A runtime availability query.
Definition ExprObjC.h:1700
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition ExprObjC.h:88
ObjCBoxedExpr - used for generalized expression boxing.
Definition ExprObjC.h:128
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition ExprObjC.h:1640
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition ExprObjC.h:307
ObjCEncodeExpr, used for @encode in Objective-C.
Definition ExprObjC.h:407
Represents Objective-C's collection statement.
Definition StmtObjC.h:23
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition ExprObjC.h:1579
Wrapper for source info for ObjC interfaces.
Definition TypeLoc.h:1274
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition ExprObjC.h:1495
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1952
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:546
An expression that sends a message to the given Objective-C object or class.
Definition ExprObjC.h:937
@ SuperInstance
The receiver is the instance of the superclass object.
Definition ExprObjC.h:951
@ Instance
The receiver is an object instance.
Definition ExprObjC.h:945
@ SuperClass
The receiver is a superclass.
Definition ExprObjC.h:948
@ Class
The receiver is a class.
Definition ExprObjC.h:942
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Wraps an ObjCPointerType with source location information.
Definition TypeLoc.h:1557
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1563
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition TypeLoc.h:1229
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:731
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition ExprObjC.h:614
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition ExprObjC.h:502
ObjCSelectorExpr used for @selector in Objective-C.
Definition ExprObjC.h:452
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition ExprObjC.h:52
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition ExprObjC.h:836
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:578
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition TypeLoc.h:895
@ Array
An index into an array.
Definition Expr.h:2426
@ Identifier
A field in a dependent type, known only by its name.
Definition Expr.h:2430
@ Field
A field.
Definition Expr.h:2428
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition Expr.h:2433
static OpaquePtr make(QualType P)
Definition Ownership.h:61
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition Expr.h:1178
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1228
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition Expr.h:2090
static OpenACCAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCAttachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCAutoClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
This is the base type for all OpenACC Clauses.
Represents a 'collapse' clause on a 'loop' construct.
static OpenACCCollapseClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, bool HasForce, Expr *LoopCount, SourceLocation EndLoc)
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A 'default' clause, has the optional 'none' or 'present' argument.
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCDeleteClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDetachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceNumClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCFinalizeClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCFirstPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCHostClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
An 'if' clause, which has a required condition expression.
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCIfPresentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCIndependentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCNoCreateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCPrivateRecipe > InitRecipes, SourceLocation EndLoc)
A 'self' clause, which has an optional condition expression, or, in the event of an 'update' directiv...
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCTileClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > SizeExprs, SourceLocation EndLoc)
static OpenACCUseDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWaitClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition ExprCXX.h:3128
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition ExprCXX.h:3280
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3262
SourceLocation getNameLoc() const
Gets the location of the name.
Definition ExprCXX.h:3241
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3254
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition ExprCXX.h:3250
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3324
llvm::iterator_range< decls_iterator > decls() const
Definition ExprCXX.h:3227
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3330
DeclarationName getName() const
Gets the name looked up.
Definition ExprCXX.h:3238
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3270
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition ExprCXX.h:3277
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition ExprCXX.h:4363
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2604
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2600
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2616
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2287
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2182
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition Expr.h:2207
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition Expr.h:2211
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1382
Represents a parameter to a function.
Definition Decl.h:1790
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1850
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1823
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition Decl.cpp:2953
unsigned getFunctionScopeDepth() const
Definition Decl.h:1840
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2696
PipeType - OpenCL20.
Definition TypeBase.h: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:2694
const IdentifierInfo * getIdentifier() const
Definition ExprCXX.h:2714
SourceLocation getLocation() const
Definition ExprCXX.h:2718
TypeSourceInfo * getTypeSourceInfo() const
Definition ExprCXX.h:2710
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h: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:3150
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition Stmt.cpp:1323
Represents a __leave statement.
Definition Stmt.h:3878
SYCLKernelCallStmt represents the transformation that is applied to the body of a function declared w...
Definition StmtSYCL.h:37
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
Definition SemaObjC.cpp:36
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
Definition SemaObjC.cpp:193
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition SemaObjC.cpp:320
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
Definition SemaObjC.cpp:218
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:213
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition SemaObjC.cpp:238
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition SemaObjC.cpp:282
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Definition SemaObjC.cpp:202
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:329
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
Helper type for the registration/assignment of constructs that need to 'know' about their parent cons...
Helper type to restore the state of various 'loop' constructs when we run into a loop (for,...
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
void ActOnWhileStmt(SourceLocation WhileLoc)
ExprResult ActOnOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
void ActOnDoStmt(SourceLocation DoLoc)
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *OldRangeFor, const Stmt *RangeFor)
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation MiscLoc, ArrayRef< Expr * > Exprs, OpenACCAtomicKind AK, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
void ActOnForStmtEnd(SourceLocation ForLoc, StmtResult Body)
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *First, const Stmt *Second, const Stmt *Third)
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
OMPClause * ActOnOpenMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nocontext' clause.
OMPClause * ActOnOpenMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_dyn_cgroup_mem' clause.
OMPClause * ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'safelen' clause.
OMPClause * ActOnOpenMPHoldsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'holds' clause.
OMPClause * ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'filter' clause.
OMPClause * ActOnOpenMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on well-form 'full' clauses.
OMPClause * ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'detach' clause.
OMPClause * ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'use' clause.
OMPClause * ActOnOpenMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'private' clause.
OMPClause * ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc=SourceLocation(), Expr *NumForLoops=nullptr)
Called on well-formed 'ordered' clause.
OMPClause * ActOnOpenMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'is_device_ptr' clause.
OMPClause * ActOnOpenMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'has_device_addr' clause.
OMPClause * ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'partial' clauses.
OMPClause * ActOnOpenMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'lastprivate' clause.
OMPClause * ActOnOpenMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'firstprivate' clause.
OMPClause * ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'priority' clause.
OMPClause * ActOnOpenMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'dist_schedule' clause.
OMPClause * ActOnOpenMPLoopRangeClause(Expr *First, Expr *Count, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc)
Called on well-form 'looprange' clause after parsing its arguments.
OMPClause * ActOnOpenMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'permutation' clause after parsing its arguments.
OMPClause * ActOnOpenMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nontemporal' clause.
OMPClause * ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'bind' clause.
OMPClause * ActOnOpenMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' clause.
OMPClause * ActOnOpenMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'shared' clause.
OMPClause * ActOnOpenMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyin' clause.
OMPClause * ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'destroy' clause.
OMPClause * ActOnOpenMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Called on well-formed 'affinity' clause.
OMPClause * ActOnOpenMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' clause.
OMPClause * ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depend' clause.
OMPClause * ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'doacross' clause.
OMPClause * ActOnOpenMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'grainsize' clause.
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
ExprResult ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< OMPIteratorData > Data)
OMPClause * ActOnOpenMPUsesAllocatorClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< UsesAllocatorsData > Data)
Called on well-formed 'uses_allocators' clause.
OMPClause * ActOnOpenMPAllocatorClause(Expr *Allocator, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocator' clause.
OMPClause * ActOnOpenMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'inclusive' clause.
OMPClause * ActOnOpenMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'task_reduction' clause.
OMPClause * ActOnOpenMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Condition)
Called on well-formed 'nowait' clause.
OMPClause * ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, OpenMPOrderClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'order' clause.
OMPClause * ActOnOpenMPSizesClause(ArrayRef< Expr * > SizeExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'sizes' clause.
OMPClause * ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'device' clause.
OMPClause * ActOnOpenMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'in_reduction' clause.
OMPClause * ActOnOpenMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'flush' pseudo clause.
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
OMPClause * ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'message' clause.
OMPClause * ActOnOpenMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'schedule' clause.
OMPClause * ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'simdlen' clause.
OMPClause * ActOnOpenMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_ptr' clause.
OMPClause * ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'proc_bind' clause.
OMPClause * ActOnOpenMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_bare' clause.
StmtResult ActOnOpenMPInformationalDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Process an OpenMP informational directive.
StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt)
Called for syntactical loops (ForStmt or CXXForRangeStmt) associated to an OpenMP loop directive.
OMPClause * ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'hint' clause.
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
OMPClause * ActOnOpenMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_threads' clause.
OMPClause * ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'at' clause.
OMPClause * ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'init' clause.
OMPClause * ActOnOpenMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_addr' clause.
OMPClause * ActOnOpenMPAllocateClause(Expr *Allocator, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocate' clause.
OMPClause * ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'final' clause.
OMPClause * ActOnOpenMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, bool NoDiagnose=false, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'map' clause.
OMPClause * ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_tasks' clause.
OMPClause * ActOnOpenMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'from' clause.
OMPClause * ActOnOpenMPDynGroupprivateClause(OpenMPDynGroupprivateClauseModifier M1, OpenMPDynGroupprivateClauseFallbackModifier M2, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation EndLoc)
Called on a well-formed 'dyn_groupprivate' clause.
void StartOpenMPDSABlock(OpenMPDirectiveKind K, const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc)
Called on start of new data sharing attribute block.
OMPClause * ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'severity' clause.
OMPClause * ActOnOpenMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'to' clause.
OMPClause * ActOnOpenMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind LinKind, SourceLocation LinLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Called on well-formed 'linear' clause.
OMPClause * ActOnOpenMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'defaultmap' clause.
OMPClause * ActOnOpenMPReductionClause(ArrayRef< Expr * > VarList, OpenMPVarListDataTy::OpenMPReductionClauseModifiers Modifiers, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'reduction' clause.
OMPClause * ActOnOpenMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'aligned' clause.
OMPClause * ActOnOpenMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depobj' pseudo clause.
OMPClause * ActOnOpenMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'novariants' clause.
OMPClause * ActOnOpenMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyprivate' clause.
OMPClause * ActOnOpenMPCollapseClause(Expr *NumForLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'collapse' clause.
OMPClause * ActOnOpenMPDefaultClause(llvm::omp::DefaultKind M, SourceLocation MLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCKindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'default' clause.
OMPClause * ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'align' clause.
OMPClause * ActOnOpenMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_attribute' clause.
OMPClause * ActOnOpenMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'exclusive' clause.
OMPClause * ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'if' clause.
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
Given a pseudo-object expression, recreate what it looks like syntactically without the attendant Opa...
ExprResult checkRValue(Expr *E)
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition SemaSYCL.cpp:143
RAII object used to change the argument pack substitution index within a Sema object.
Definition Sema.h:13608
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8432
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:13001
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:13020
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13008
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14005
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:9319
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9327
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9322
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:7824
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7826
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7825
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:11951
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:7005
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:11754
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:11749
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition Sema.cpp:2513
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1414
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Create a new AsTypeExpr node (bitcast) from the arguments.
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
UnsignedOrNone ArgPackSubstIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition Sema.h:13602
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:6718
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6728
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6697
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6723
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:8301
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:11040
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:7810
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:8641
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:4441
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition ExprCXX.h:4503
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
Definition ExprCXX.h:4526
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Definition ExprCXX.cpp:1709
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition ExprCXX.h:4531
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
Definition ExprCXX.h:4500
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition ExprCXX.h:4506
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition ExprCXX.h:4509
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition Expr.h: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:1483
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:338
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1799
Wrapper for substituted template type parameters.
Definition TypeLoc.h:998
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition ExprCXX.h:4664
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition ExprCXX.h:4754
A structure for storing an already-substituted template template parameter pack.
A structure for storing the information associated with a substituted template template parameter.
Wrapper for substituted template type parameters.
Definition TypeLoc.h:992
SwitchStmt - This represents a 'switch' stmt.
Definition Stmt.h:2499
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.
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.
ExprResult RebuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP, SourceLocation Loc, TemplateArgument Arg, UnsignedOrNone PackIndex, bool Final)
bool TransformExceptionSpec(SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, SmallVectorImpl< QualType > &Exceptions, bool &Changed)
ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait, SourceLocation StartLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParenLoc)
Build a new array type trait expression.
OMPClause * RebuildOMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'is_device_ptr' clause.
QualType RebuildMacroQualifiedType(QualType T, const IdentifierInfo *MacroII)
Build a new MacroDefined type.
concepts::NestedRequirement * RebuildNestedRequirement(Expr *Constraint)
ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length, ArrayRef< TemplateArgument > PartialArgs)
Build a new expression to compute the length of a parameter pack.
ExprResult RebuildMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBracketLoc)
Build a new matrix subscript expression.
ExprResult TransformParenDependentScopeDeclRefExpr(ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
TemplateParameterList * TransformTemplateParameterList(TemplateParameterList *TPL)
void transformAttrs(Decl *Old, Decl *New)
Transform the attributes associated with the given declaration and place them on the new declaration.
QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL)
QualType RebuildTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &Args)
Build a new template specialization type.
Decl * TransformDecl(SourceLocation Loc, Decl *D)
Transform the given declaration, which is referenced from a type or expression.
bool AlwaysRebuild()
Whether the transformation should always rebuild AST nodes, even if none of the children have changed...
ExprResult RebuildObjCMessageExpr(SourceLocation SuperLoc, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, QualType SuperType, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C instance/class message to 'super'.
OMPClause * RebuildOMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'lastprivate' clause.
QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc, VectorKind)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
bool AllowSkippingCXXConstructExpr()
Wether CXXConstructExpr can be skipped when they are implicit.
OMPClause * RebuildOMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'safelen' clause.
StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *Init, Sema::ConditionResult Cond, SourceLocation RParenLoc)
Start building a new switch statement.
StmtResult RebuildDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new default statement.
StmtResult RebuildObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParenLoc, VarDecl *Var, Stmt *Body)
Build a new Objective-C @catch statement.
OMPClause * RebuildOMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'filter' clause.
ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base, SourceLocation OperatorLoc, bool isArrow, CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage Destroyed)
Build a new pseudo-destructor expression.
QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits, SourceLocation Loc)
Build a bit-precise int given its value type.
ExprResult RebuildObjCArrayLiteral(SourceRange Range, Expr **Elements, unsigned NumElements)
Build a new Objective-C array literal.
ExprResult RebuildCXXUuidofExpr(QualType Type, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(type) expression.
ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE, QualType BaseType, SourceLocation OperatorLoc, bool IsArrow, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs)
Build a new member reference expression.
OMPClause * RebuildOMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'bind' clause.
concepts::NestedRequirement * RebuildNestedRequirement(StringRef InvalidConstraintEntity, const ASTConstraintSatisfaction &Satisfaction)
OMPClause * RebuildOMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'copyprivate' clause.
QualType RebuildAutoType(QualType Deduced, AutoTypeKeyword Keyword, ConceptDecl *TypeConstraintConcept, ArrayRef< TemplateArgument > TypeConstraintArgs)
Build a new C++11 auto type.
QualType RebuildPackExpansionType(QualType Pattern, SourceRange PatternRange, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new pack expansion type.
QualType RebuildVariableArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new variable-length array type given the element type, size modifier, size expression,...
ExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ dynamic_cast expression.
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, TypeSourceInfo *ControllingType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
Build a new generic selection expression with a type predicate.
QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new pointer type given its pointee type.
concepts::TypeRequirement * RebuildTypeRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag)
OMPClause * RebuildOMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'permutation' clause.
OMPClause * RebuildOMPUsesAllocatorsClause(ArrayRef< SemaOpenMP::UsesAllocatorsData > Data, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'uses_allocators' clause.
ExprResult RebuildCXXInheritedCtorInitExpr(QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor, bool ConstructsVBase, bool InheritedFromVBase)
Build a new implicit construction via inherited constructor expression.
ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ const_cast expression.
OMPClause * RebuildOMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'to' clause.
ExprResult RebuildCXXParenListInitExpr(ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
TypeSourceInfo * TransformTypeWithDeducedTST(TypeSourceInfo *TSI)
ExprResult RebuildAtomicExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, AtomicExpr::AtomicOp Op, SourceLocation RParenLoc)
Build a new atomic operation expression.
DeclarationNameInfo TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
Transform the given declaration name.
OMPClause * RebuildOMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_attribute' clause.
void RememberSubstitution(MultiLevelTemplateArgumentList)
StmtResult RebuildDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation LParenLoc, Expr *Cond, SourceLocation RParenLoc)
Build a new do-while statement.
OMPClause * RebuildOMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'if' clause.
StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body)
Attach the body to a new case statement.
ExprResult RebuildTypeTrait(TypeTrait Trait, SourceLocation StartLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
Build a new type trait expression.
ExprResult RebuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Build an empty C++1z fold-expression with the given operator.
QualType TransformTypeWithDeducedTST(QualType T)
Transform a type that is permitted to produce a DeducedTemplateSpecializationType.
OMPClause * RebuildOMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'init' clause.
OMPClause * RebuildOMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'detach' clause.
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, MultiStmtArg Statements, SourceLocation RBraceLoc, bool IsStmtExpr)
Build a new compound statement.
ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, ValueDecl *VD, const DeclarationNameInfo &NameInfo, NamedDecl *Found, TemplateArgumentListInfo *TemplateArgs)
Build a new expression that references a declaration.
QualType RebuildArrayType(QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new array type given the element type, size modifier, size of the array (if known),...
StmtResult RebuildDeclStmt(MutableArrayRef< Decl * > Decls, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new declaration statement.
ExprResult RebuildConvertVectorExpr(SourceLocation BuiltinLoc, Expr *SrcExpr, TypeSourceInfo *DstTInfo, SourceLocation RParenLoc)
Build a new convert vector expression.
QualType RebuildQualifiedType(QualType T, QualifiedTypeLoc TL)
Build a new qualified type given its unqualified type and type location.
OMPClause * RebuildOMPDependClause(OMPDependClause::DependDataTy Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'depend' pseudo clause.
OMPClause * RebuildOMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'aligned' clause.
unsigned TransformTemplateDepth(unsigned Depth)
Transform a template parameter depth level.
QualType RebuildFunctionNoProtoType(QualType ResultType)
Build a new unprototyped function type.
QualType RebuildTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, TypedefNameDecl *Typedef)
Build a new typedef type.
QualType TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, Fn TransformExceptionSpec)
TemplateArgumentLoc RebuildPackExpansion(TemplateArgumentLoc Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new template argument pack expansion.
const Attr * TransformAttr(const Attr *S)
Transform the given attribute.
QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns)
Build a new matrix type given the element type and dimensions.
OMPClause * RebuildOMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'map' clause.
ExprResult RebuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Sub, SourceLocation RParenLoc)
Build a new C++ __builtin_bit_cast expression.
QualType RebuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted, ArrayRef< QualType > Expansions={})
StmtResult RebuildOMPCanonicalLoop(Stmt *LoopStmt)
Build a new OpenMP Canonical loop.
StmtResult RebuildOMPExecutableDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP executable directive.
concepts::ExprRequirement * RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
TypeSourceInfo * TransformType(TypeSourceInfo *TSI)
Transforms the given type-with-location into a new type-with-location.
ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
OMPClause * RebuildOMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP 'full' clause.
StmtResult RebuildSEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
OMPClause * RebuildOMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Build a new OpenMP 'affinity' clause.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(type) expression.
ExprResult RebuildCXXDependentScopeMemberExpr(Expr *BaseE, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Build a new member reference expression.
ExprResult RebuildCXXNamedCastExpr(SourceLocation OpLoc, Stmt::StmtClass Class, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ "named" cast expression, such as static_cast or reinterpret_cast.
StmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Attach the body to the switch statement.
TypeSourceInfo * InventTypeSourceInfo(QualType T)
Fakes up a TypeSourceInfo for a type.
ExprResult RebuildUnaryExprOrTypeTrait(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec_step expression with a type argument.
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
Build a new generic selection expression with an expression predicate.
QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool SuppressObjCLifetime)
Derived & getDerived()
Retrieves a reference to the derived class.
OMPClause * RebuildOMPHoldsClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'holds' clause.
StmtResult RebuildOpenACCAtomicConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, OpenACCAtomicKind AtKind, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssociatedStmt)
ExprResult RebuildArraySectionExpr(bool IsOMPArraySection, Expr *Base, SourceLocation LBracketLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBracketLoc)
Build a new array section expression.
concepts::ExprRequirement * TransformExprRequirement(concepts::ExprRequirement *Req)
QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc, TypeOfKind Kind)
Build a new typeof(expr) type.
bool ReplacingOriginal()
Whether the transformation is forming an expression or statement that replaces the original.
OMPClause * RebuildOMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'flush' pseudo clause.
bool TransformTemplateArgument(const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output, bool Uneval=false)
Transform the given template argument.
ExprResult RebuildArraySubscriptExpr(Expr *LHS, SourceLocation LBracketLoc, Expr *RHS, SourceLocation RBracketLoc)
Build a new array subscript expression.
OMPClause * RebuildOMPReductionClause(ArrayRef< Expr * > VarList, OpenMPReductionClauseModifier Modifier, OpenMPOriginalSharingModifier OriginalSharingModifier, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'reduction' clause.
QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements, SourceLocation AttributeLoc)
Build a new extended vector type given the element type and number of elements.
void transformedLocalDecl(Decl *Old, ArrayRef< Decl * > New)
Note that a local declaration has been transformed by this transformer.
ExprResult RebuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
Build a new Objective-C boxed expression.
ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub, bool IsThrownVariableInScope)
Build a new C++ throw expression.
bool TransformRequiresExprRequirements(ArrayRef< concepts::Requirement * > Reqs, llvm::SmallVectorImpl< concepts::Requirement * > &Transformed)
TemplateName TransformTemplateName(NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc, TemplateName Name, SourceLocation NameLoc, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr, bool AllowInjectedClassName=false)
Transform the given template name.
bool DropCallArgument(Expr *E)
Determine whether the given call argument should be dropped, e.g., because it is a default argument.
StmtResult RebuildGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new goto statement.
OMPClause * RebuildOMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'private' clause.
ExprResult RebuildObjCPropertyRefExpr(Expr *Base, QualType T, ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
ExprResult RebuildRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation ClosingBraceLoc)
Build a new requires expression.
ExprResult RebuildExpressionTrait(ExpressionTrait Trait, SourceLocation StartLoc, Expr *Queried, SourceLocation RParenLoc)
Build a new expression trait expression.
OMPClause * RebuildOMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'doacross' clause.
OMPClause * RebuildOMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'final' clause.
StmtResult RebuildIfStmt(SourceLocation IfLoc, IfStatementKind Kind, SourceLocation LParenLoc, Sema::ConditionResult Cond, SourceLocation RParenLoc, Stmt *Init, Stmt *Then, SourceLocation ElseLoc, Stmt *Else)
Build a new "if" statement.
OMPClause * RebuildOMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'from' clause.
bool TransformConceptTemplateArguments(InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs, bool Uneval=false)
TypeLoc getTypeLocInContext(ASTContext &Context, QualType T)
Copies the type-location information to the given AST context and returns a TypeLoc referring into th...
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
void TypeWasModifiedSafely(QualType T)
Tell the TypeLocBuilder that the type it is storing has been modified in some safe way that doesn't a...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
Definition TypeLoc.h:59
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition TypeLoc.h:349
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition TypeLoc.h:133
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition TypeLoc.h:89
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition TypeLoc.h:78
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition TypeLoc.h:154
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition TypeLoc.h:165
TypeLocClass getTypeLocClass() const
Definition TypeLoc.h:116
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition TypeLoc.h:2706
SourceLocation getBeginLoc() const
Get the begin source location.
Definition TypeLoc.cpp:193
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Definition TypeBase.h: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:2896
The base class of the type hierarchy.
Definition TypeBase.h:1833
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition TypeBase.h: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:3390
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition ExprCXX.h:3464
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition ExprCXX.h:3459
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Definition ExprCXX.cpp:432
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4126
A set of unresolved declarations.
void append(iterator I, iterator E)
A set of unresolved declarations.
Wrapper for source info for unresolved typename using decls.
Definition TypeLoc.h:782
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition TypeBase.h: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:5527
Value()=default
Represents a variable declaration or definition.
Definition Decl.h:926
@ CInit
C-style initialization with assignment.
Definition Decl.h:931
@ CallInit
Call-style initialization (C++98)
Definition Decl.h:934
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1168
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h: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:2687
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:1540
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
Definition Specifiers.h:161
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
Definition Lambda.h:36
@ LCK_ByRef
Capturing by reference.
Definition Lambda.h:37
@ LCK_StarThis
Capturing the *this object by copy.
Definition Lambda.h:35
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition Sema.h: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:2245
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Uninstantiated
not instantiated yet
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition Expr.h:1989
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition OpenMPKinds.h:31
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition OpenMPKinds.h:71
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition ASTConcept.h:91
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:89
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition TypeBase.h: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:260
Data for list of allocators.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition Sema.h:13078
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13109
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