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 single 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 SourceLocation RBracketLoc) {
2859 RBracketLoc);
2860 }
2861
2862 /// Build a new matrix subscript expression.
2863 ///
2864 /// By default, performs semantic analysis to build the new expression.
2865 /// Subclasses may override this routine to provide different behavior.
2867 Expr *ColumnIdx,
2868 SourceLocation RBracketLoc) {
2869 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2870 RBracketLoc);
2871 }
2872
2873 /// Build a new array section expression.
2874 ///
2875 /// By default, performs semantic analysis to build the new expression.
2876 /// Subclasses may override this routine to provide different behavior.
2878 SourceLocation LBracketLoc,
2879 Expr *LowerBound,
2880 SourceLocation ColonLocFirst,
2881 SourceLocation ColonLocSecond,
2882 Expr *Length, Expr *Stride,
2883 SourceLocation RBracketLoc) {
2884 if (IsOMPArraySection)
2886 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2887 Stride, RBracketLoc);
2888
2889 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2890 "Stride/second colon not allowed for OpenACC");
2891
2893 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2894 }
2895
2896 /// Build a new array shaping expression.
2897 ///
2898 /// By default, performs semantic analysis to build the new expression.
2899 /// Subclasses may override this routine to provide different behavior.
2901 SourceLocation RParenLoc,
2902 ArrayRef<Expr *> Dims,
2903 ArrayRef<SourceRange> BracketsRanges) {
2905 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2906 }
2907
2908 /// Build a new iterator expression.
2909 ///
2910 /// By default, performs semantic analysis to build the new expression.
2911 /// Subclasses may override this routine to provide different behavior.
2914 SourceLocation RLoc,
2917 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2918 }
2919
2920 /// Build a new call expression.
2921 ///
2922 /// By default, performs semantic analysis to build the new expression.
2923 /// Subclasses may override this routine to provide different behavior.
2925 MultiExprArg Args,
2926 SourceLocation RParenLoc,
2927 Expr *ExecConfig = nullptr) {
2928 return getSema().ActOnCallExpr(
2929 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2930 }
2931
2933 MultiExprArg Args,
2934 SourceLocation RParenLoc) {
2936 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2937 }
2938
2939 /// Build a new member access expression.
2940 ///
2941 /// By default, performs semantic analysis to build the new expression.
2942 /// Subclasses may override this routine to provide different behavior.
2944 bool isArrow,
2945 NestedNameSpecifierLoc QualifierLoc,
2946 SourceLocation TemplateKWLoc,
2947 const DeclarationNameInfo &MemberNameInfo,
2949 NamedDecl *FoundDecl,
2950 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2951 NamedDecl *FirstQualifierInScope) {
2953 isArrow);
2954 if (!Member->getDeclName()) {
2955 // We have a reference to an unnamed field. This is always the
2956 // base of an anonymous struct/union member access, i.e. the
2957 // field is always of record type.
2958 assert(Member->getType()->isRecordType() &&
2959 "unnamed member not of record type?");
2960
2961 BaseResult =
2963 QualifierLoc.getNestedNameSpecifier(),
2964 FoundDecl, Member);
2965 if (BaseResult.isInvalid())
2966 return ExprError();
2967 Base = BaseResult.get();
2968
2969 // `TranformMaterializeTemporaryExpr()` removes materialized temporaries
2970 // from the AST, so we need to re-insert them if needed (since
2971 // `BuildFieldRefereneExpr()` doesn't do this).
2972 if (!isArrow && Base->isPRValue()) {
2974 if (BaseResult.isInvalid())
2975 return ExprError();
2976 Base = BaseResult.get();
2977 }
2978
2979 CXXScopeSpec EmptySS;
2981 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
2982 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
2983 MemberNameInfo);
2984 }
2985
2986 CXXScopeSpec SS;
2987 SS.Adopt(QualifierLoc);
2988
2989 Base = BaseResult.get();
2990 if (Base->containsErrors())
2991 return ExprError();
2992
2993 QualType BaseType = Base->getType();
2994
2995 if (isArrow && !BaseType->isPointerType())
2996 return ExprError();
2997
2998 // FIXME: this involves duplicating earlier analysis in a lot of
2999 // cases; we should avoid this when possible.
3000 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
3001 R.addDecl(FoundDecl);
3002 R.resolveKind();
3003
3004 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
3006 if (auto *ThisClass = cast<CXXThisExpr>(Base)
3007 ->getType()
3008 ->getPointeeType()
3009 ->getAsCXXRecordDecl()) {
3010 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
3011 // In unevaluated contexts, an expression supposed to be a member access
3012 // might reference a member in an unrelated class.
3013 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
3014 return getSema().BuildDeclRefExpr(Member, Member->getType(),
3015 VK_LValue, Member->getLocation());
3016 }
3017 }
3018
3019 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
3020 SS, TemplateKWLoc,
3021 FirstQualifierInScope,
3022 R, ExplicitTemplateArgs,
3023 /*S*/nullptr);
3024 }
3025
3026 /// Build a new binary operator expression.
3027 ///
3028 /// By default, performs semantic analysis to build the new expression.
3029 /// Subclasses may override this routine to provide different behavior.
3031 Expr *LHS, Expr *RHS,
3032 bool ForFoldExpression = false) {
3033 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS,
3034 ForFoldExpression);
3035 }
3036
3037 /// Build a new rewritten operator expression.
3038 ///
3039 /// By default, performs semantic analysis to build the new expression.
3040 /// Subclasses may override this routine to provide different behavior.
3042 SourceLocation OpLoc, BinaryOperatorKind Opcode,
3043 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
3044 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
3045 RHS, /*RequiresADL*/false);
3046 }
3047
3048 /// Build a new conditional operator expression.
3049 ///
3050 /// By default, performs semantic analysis to build the new expression.
3051 /// Subclasses may override this routine to provide different behavior.
3053 SourceLocation QuestionLoc,
3054 Expr *LHS,
3055 SourceLocation ColonLoc,
3056 Expr *RHS) {
3057 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
3058 LHS, RHS);
3059 }
3060
3061 /// Build a new C-style cast expression.
3062 ///
3063 /// By default, performs semantic analysis to build the new expression.
3064 /// Subclasses may override this routine to provide different behavior.
3066 TypeSourceInfo *TInfo,
3067 SourceLocation RParenLoc,
3068 Expr *SubExpr) {
3069 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
3070 SubExpr);
3071 }
3072
3073 /// Build a new compound literal expression.
3074 ///
3075 /// By default, performs semantic analysis to build the new expression.
3076 /// Subclasses may override this routine to provide different behavior.
3078 TypeSourceInfo *TInfo,
3079 SourceLocation RParenLoc,
3080 Expr *Init) {
3081 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
3082 Init);
3083 }
3084
3085 /// Build a new extended vector element access expression.
3086 ///
3087 /// By default, performs semantic analysis to build the new expression.
3088 /// Subclasses may override this routine to provide different behavior.
3090 bool IsArrow,
3091 SourceLocation AccessorLoc,
3092 IdentifierInfo &Accessor) {
3093
3094 CXXScopeSpec SS;
3095 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3097 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3098 /*FirstQualifierInScope*/ nullptr, NameInfo,
3099 /* TemplateArgs */ nullptr,
3100 /*S*/ nullptr);
3101 }
3102
3103 /// Build a new initializer list 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 Inits,
3109 SourceLocation RBraceLoc) {
3110 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
3111 }
3112
3113 /// Build a new designated initializer expression.
3114 ///
3115 /// By default, performs semantic analysis to build the new expression.
3116 /// Subclasses may override this routine to provide different behavior.
3118 MultiExprArg ArrayExprs,
3119 SourceLocation EqualOrColonLoc,
3120 bool GNUSyntax,
3121 Expr *Init) {
3123 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3124 Init);
3125 if (Result.isInvalid())
3126 return ExprError();
3127
3128 return Result;
3129 }
3130
3131 /// Build a new value-initialized expression.
3132 ///
3133 /// By default, builds the implicit value initialization without performing
3134 /// any semantic analysis. Subclasses may override this routine to provide
3135 /// different behavior.
3139
3140 /// Build a new \c va_arg expression.
3141 ///
3142 /// By default, performs semantic analysis to build the new expression.
3143 /// Subclasses may override this routine to provide different behavior.
3145 Expr *SubExpr, TypeSourceInfo *TInfo,
3146 SourceLocation RParenLoc) {
3147 return getSema().BuildVAArgExpr(BuiltinLoc,
3148 SubExpr, TInfo,
3149 RParenLoc);
3150 }
3151
3152 /// Build a new expression list in parentheses.
3153 ///
3154 /// By default, performs semantic analysis to build the new expression.
3155 /// Subclasses may override this routine to provide different behavior.
3157 MultiExprArg SubExprs,
3158 SourceLocation RParenLoc) {
3159 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3160 }
3161
3163 unsigned NumUserSpecifiedExprs,
3164 SourceLocation InitLoc,
3165 SourceLocation LParenLoc,
3166 SourceLocation RParenLoc) {
3167 return getSema().ActOnCXXParenListInitExpr(Args, T, NumUserSpecifiedExprs,
3168 InitLoc, LParenLoc, RParenLoc);
3169 }
3170
3171 /// Build a new address-of-label expression.
3172 ///
3173 /// By default, performs semantic analysis, using the name of the label
3174 /// rather than attempting to map the label statement itself.
3175 /// Subclasses may override this routine to provide different behavior.
3177 SourceLocation LabelLoc, LabelDecl *Label) {
3178 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3179 }
3180
3181 /// Build a new GNU statement expression.
3182 ///
3183 /// By default, performs semantic analysis to build the new expression.
3184 /// Subclasses may override this routine to provide different behavior.
3186 SourceLocation RParenLoc, unsigned TemplateDepth) {
3187 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3188 TemplateDepth);
3189 }
3190
3191 /// Build a new __builtin_choose_expr expression.
3192 ///
3193 /// By default, performs semantic analysis to build the new expression.
3194 /// Subclasses may override this routine to provide different behavior.
3196 Expr *Cond, Expr *LHS, Expr *RHS,
3197 SourceLocation RParenLoc) {
3198 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3199 Cond, LHS, RHS,
3200 RParenLoc);
3201 }
3202
3203 /// Build a new generic selection expression with an expression predicate.
3204 ///
3205 /// By default, performs semantic analysis to build the new expression.
3206 /// Subclasses may override this routine to provide different behavior.
3208 SourceLocation DefaultLoc,
3209 SourceLocation RParenLoc,
3210 Expr *ControllingExpr,
3212 ArrayRef<Expr *> Exprs) {
3213 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3214 /*PredicateIsExpr=*/true,
3215 ControllingExpr, Types, Exprs);
3216 }
3217
3218 /// Build a new generic selection expression with a type predicate.
3219 ///
3220 /// By default, performs semantic analysis to build the new expression.
3221 /// Subclasses may override this routine to provide different behavior.
3223 SourceLocation DefaultLoc,
3224 SourceLocation RParenLoc,
3225 TypeSourceInfo *ControllingType,
3227 ArrayRef<Expr *> Exprs) {
3228 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3229 /*PredicateIsExpr=*/false,
3230 ControllingType, Types, Exprs);
3231 }
3232
3233 /// Build a new overloaded operator call expression.
3234 ///
3235 /// By default, performs semantic analysis to build the new expression.
3236 /// The semantic analysis provides the behavior of template instantiation,
3237 /// copying with transformations that turn what looks like an overloaded
3238 /// operator call into a use of a builtin operator, performing
3239 /// argument-dependent lookup, etc. Subclasses may override this routine to
3240 /// provide different behavior.
3242 SourceLocation OpLoc,
3243 SourceLocation CalleeLoc,
3244 bool RequiresADL,
3245 const UnresolvedSetImpl &Functions,
3246 Expr *First, Expr *Second);
3247
3248 /// Build a new C++ "named" cast expression, such as static_cast or
3249 /// reinterpret_cast.
3250 ///
3251 /// By default, this routine dispatches to one of the more-specific routines
3252 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3253 /// Subclasses may override this routine to provide different behavior.
3256 SourceLocation LAngleLoc,
3257 TypeSourceInfo *TInfo,
3258 SourceLocation RAngleLoc,
3259 SourceLocation LParenLoc,
3260 Expr *SubExpr,
3261 SourceLocation RParenLoc) {
3262 switch (Class) {
3263 case Stmt::CXXStaticCastExprClass:
3264 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3265 RAngleLoc, LParenLoc,
3266 SubExpr, RParenLoc);
3267
3268 case Stmt::CXXDynamicCastExprClass:
3269 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3270 RAngleLoc, LParenLoc,
3271 SubExpr, RParenLoc);
3272
3273 case Stmt::CXXReinterpretCastExprClass:
3274 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3275 RAngleLoc, LParenLoc,
3276 SubExpr,
3277 RParenLoc);
3278
3279 case Stmt::CXXConstCastExprClass:
3280 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3281 RAngleLoc, LParenLoc,
3282 SubExpr, RParenLoc);
3283
3284 case Stmt::CXXAddrspaceCastExprClass:
3285 return getDerived().RebuildCXXAddrspaceCastExpr(
3286 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3287
3288 default:
3289 llvm_unreachable("Invalid C++ named cast");
3290 }
3291 }
3292
3293 /// Build a new C++ static_cast expression.
3294 ///
3295 /// By default, performs semantic analysis to build the new expression.
3296 /// Subclasses may override this routine to provide different behavior.
3298 SourceLocation LAngleLoc,
3299 TypeSourceInfo *TInfo,
3300 SourceLocation RAngleLoc,
3301 SourceLocation LParenLoc,
3302 Expr *SubExpr,
3303 SourceLocation RParenLoc) {
3304 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3305 TInfo, SubExpr,
3306 SourceRange(LAngleLoc, RAngleLoc),
3307 SourceRange(LParenLoc, RParenLoc));
3308 }
3309
3310 /// Build a new C++ dynamic_cast expression.
3311 ///
3312 /// By default, performs semantic analysis to build the new expression.
3313 /// Subclasses may override this routine to provide different behavior.
3315 SourceLocation LAngleLoc,
3316 TypeSourceInfo *TInfo,
3317 SourceLocation RAngleLoc,
3318 SourceLocation LParenLoc,
3319 Expr *SubExpr,
3320 SourceLocation RParenLoc) {
3321 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3322 TInfo, SubExpr,
3323 SourceRange(LAngleLoc, RAngleLoc),
3324 SourceRange(LParenLoc, RParenLoc));
3325 }
3326
3327 /// Build a new C++ reinterpret_cast expression.
3328 ///
3329 /// By default, performs semantic analysis to build the new expression.
3330 /// Subclasses may override this routine to provide different behavior.
3332 SourceLocation LAngleLoc,
3333 TypeSourceInfo *TInfo,
3334 SourceLocation RAngleLoc,
3335 SourceLocation LParenLoc,
3336 Expr *SubExpr,
3337 SourceLocation RParenLoc) {
3338 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3339 TInfo, SubExpr,
3340 SourceRange(LAngleLoc, RAngleLoc),
3341 SourceRange(LParenLoc, RParenLoc));
3342 }
3343
3344 /// Build a new C++ const_cast expression.
3345 ///
3346 /// By default, performs semantic analysis to build the new expression.
3347 /// Subclasses may override this routine to provide different behavior.
3349 SourceLocation LAngleLoc,
3350 TypeSourceInfo *TInfo,
3351 SourceLocation RAngleLoc,
3352 SourceLocation LParenLoc,
3353 Expr *SubExpr,
3354 SourceLocation RParenLoc) {
3355 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3356 TInfo, SubExpr,
3357 SourceRange(LAngleLoc, RAngleLoc),
3358 SourceRange(LParenLoc, RParenLoc));
3359 }
3360
3363 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3364 SourceLocation LParenLoc, Expr *SubExpr,
3365 SourceLocation RParenLoc) {
3366 return getSema().BuildCXXNamedCast(
3367 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3368 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3369 }
3370
3371 /// Build a new C++ functional-style cast expression.
3372 ///
3373 /// By default, performs semantic analysis to build the new expression.
3374 /// Subclasses may override this routine to provide different behavior.
3376 SourceLocation LParenLoc,
3377 Expr *Sub,
3378 SourceLocation RParenLoc,
3379 bool ListInitialization) {
3380 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3381 // CXXParenListInitExpr. Pass its expanded arguments so that the
3382 // CXXParenListInitExpr can be rebuilt.
3383 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3385 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3386 RParenLoc, ListInitialization);
3387
3388 if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub))
3390 TInfo, LParenLoc, PLE->getInitExprs(), RParenLoc, ListInitialization);
3391
3392 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3393 MultiExprArg(&Sub, 1), RParenLoc,
3394 ListInitialization);
3395 }
3396
3397 /// Build a new C++ __builtin_bit_cast expression.
3398 ///
3399 /// By default, performs semantic analysis to build the new expression.
3400 /// Subclasses may override this routine to provide different behavior.
3402 TypeSourceInfo *TSI, Expr *Sub,
3403 SourceLocation RParenLoc) {
3404 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3405 }
3406
3407 /// Build a new C++ typeid(type) expression.
3408 ///
3409 /// By default, performs semantic analysis to build the new expression.
3410 /// Subclasses may override this routine to provide different behavior.
3412 SourceLocation TypeidLoc,
3413 TypeSourceInfo *Operand,
3414 SourceLocation RParenLoc) {
3415 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3416 RParenLoc);
3417 }
3418
3419
3420 /// Build a new C++ typeid(expr) expression.
3421 ///
3422 /// By default, performs semantic analysis to build the new expression.
3423 /// Subclasses may override this routine to provide different behavior.
3425 SourceLocation TypeidLoc,
3426 Expr *Operand,
3427 SourceLocation RParenLoc) {
3428 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3429 RParenLoc);
3430 }
3431
3432 /// Build a new C++ __uuidof(type) expression.
3433 ///
3434 /// By default, performs semantic analysis to build the new expression.
3435 /// Subclasses may override this routine to provide different behavior.
3437 TypeSourceInfo *Operand,
3438 SourceLocation RParenLoc) {
3439 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3440 }
3441
3442 /// Build a new C++ __uuidof(expr) expression.
3443 ///
3444 /// By default, performs semantic analysis to build the new expression.
3445 /// Subclasses may override this routine to provide different behavior.
3447 Expr *Operand, SourceLocation RParenLoc) {
3448 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3449 }
3450
3451 /// Build a new C++ "this" expression.
3452 ///
3453 /// By default, performs semantic analysis to build a new "this" expression.
3454 /// Subclasses may override this routine to provide different behavior.
3456 QualType ThisType,
3457 bool isImplicit) {
3458 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3459 return ExprError();
3460 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3461 }
3462
3463 /// Build a new C++ throw expression.
3464 ///
3465 /// By default, performs semantic analysis to build the new expression.
3466 /// Subclasses may override this routine to provide different behavior.
3468 bool IsThrownVariableInScope) {
3469 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3470 }
3471
3472 /// Build a new C++ default-argument expression.
3473 ///
3474 /// By default, builds a new default-argument expression, which does not
3475 /// require any semantic analysis. Subclasses may override this routine to
3476 /// provide different behavior.
3478 Expr *RewrittenExpr) {
3479 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3480 RewrittenExpr, getSema().CurContext);
3481 }
3482
3483 /// Build a new C++11 default-initialization expression.
3484 ///
3485 /// By default, builds a new default field initialization expression, which
3486 /// does not require any semantic analysis. Subclasses may override this
3487 /// routine to provide different behavior.
3492
3493 /// Build a new C++ zero-initialization expression.
3494 ///
3495 /// By default, performs semantic analysis to build the new expression.
3496 /// Subclasses may override this routine to provide different behavior.
3498 SourceLocation LParenLoc,
3499 SourceLocation RParenLoc) {
3500 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3501 /*ListInitialization=*/false);
3502 }
3503
3504 /// Build a new C++ "new" expression.
3505 ///
3506 /// By default, performs semantic analysis to build the new expression.
3507 /// Subclasses may override this routine to provide different behavior.
3509 SourceLocation PlacementLParen,
3510 MultiExprArg PlacementArgs,
3511 SourceLocation PlacementRParen,
3512 SourceRange TypeIdParens, QualType AllocatedType,
3513 TypeSourceInfo *AllocatedTypeInfo,
3514 std::optional<Expr *> ArraySize,
3515 SourceRange DirectInitRange, Expr *Initializer) {
3516 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3517 PlacementLParen,
3518 PlacementArgs,
3519 PlacementRParen,
3520 TypeIdParens,
3521 AllocatedType,
3522 AllocatedTypeInfo,
3523 ArraySize,
3524 DirectInitRange,
3525 Initializer);
3526 }
3527
3528 /// Build a new C++ "delete" expression.
3529 ///
3530 /// By default, performs semantic analysis to build the new expression.
3531 /// Subclasses may override this routine to provide different behavior.
3533 bool IsGlobalDelete,
3534 bool IsArrayForm,
3535 Expr *Operand) {
3536 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3537 Operand);
3538 }
3539
3540 /// Build a new type trait expression.
3541 ///
3542 /// By default, performs semantic analysis to build the new expression.
3543 /// Subclasses may override this routine to provide different behavior.
3545 SourceLocation StartLoc,
3547 SourceLocation RParenLoc) {
3548 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3549 }
3550
3551 /// Build a new array type trait expression.
3552 ///
3553 /// By default, performs semantic analysis to build the new expression.
3554 /// Subclasses may override this routine to provide different behavior.
3556 SourceLocation StartLoc,
3557 TypeSourceInfo *TSInfo,
3558 Expr *DimExpr,
3559 SourceLocation RParenLoc) {
3560 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3561 }
3562
3563 /// Build a new expression trait expression.
3564 ///
3565 /// By default, performs semantic analysis to build the new expression.
3566 /// Subclasses may override this routine to provide different behavior.
3568 SourceLocation StartLoc,
3569 Expr *Queried,
3570 SourceLocation RParenLoc) {
3571 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3572 }
3573
3574 /// Build a new (previously unresolved) declaration reference
3575 /// expression.
3576 ///
3577 /// By default, performs semantic analysis to build the new expression.
3578 /// Subclasses may override this routine to provide different behavior.
3580 NestedNameSpecifierLoc QualifierLoc,
3581 SourceLocation TemplateKWLoc,
3582 const DeclarationNameInfo &NameInfo,
3583 const TemplateArgumentListInfo *TemplateArgs,
3584 bool IsAddressOfOperand,
3585 TypeSourceInfo **RecoveryTSI) {
3586 CXXScopeSpec SS;
3587 SS.Adopt(QualifierLoc);
3588
3589 if (TemplateArgs || TemplateKWLoc.isValid())
3591 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3592
3594 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3595 }
3596
3597 /// Build a new template-id expression.
3598 ///
3599 /// By default, performs semantic analysis to build the new expression.
3600 /// Subclasses may override this routine to provide different behavior.
3602 SourceLocation TemplateKWLoc,
3603 LookupResult &R,
3604 bool RequiresADL,
3605 const TemplateArgumentListInfo *TemplateArgs) {
3606 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3607 TemplateArgs);
3608 }
3609
3610 /// Build a new object-construction expression.
3611 ///
3612 /// By default, performs semantic analysis to build the new expression.
3613 /// Subclasses may override this routine to provide different behavior.
3616 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3617 bool ListInitialization, bool StdInitListInitialization,
3618 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3619 SourceRange ParenRange) {
3620 // Reconstruct the constructor we originally found, which might be
3621 // different if this is a call to an inherited constructor.
3622 CXXConstructorDecl *FoundCtor = Constructor;
3623 if (Constructor->isInheritingConstructor())
3624 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3625
3626 SmallVector<Expr *, 8> ConvertedArgs;
3627 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3628 ConvertedArgs))
3629 return ExprError();
3630
3632 IsElidable,
3633 ConvertedArgs,
3634 HadMultipleCandidates,
3635 ListInitialization,
3636 StdInitListInitialization,
3637 RequiresZeroInit, ConstructKind,
3638 ParenRange);
3639 }
3640
3641 /// Build a new implicit construction via inherited constructor
3642 /// expression.
3645 bool ConstructsVBase,
3646 bool InheritedFromVBase) {
3648 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3649 }
3650
3651 /// Build a new object-construction expression.
3652 ///
3653 /// By default, performs semantic analysis to build the new expression.
3654 /// Subclasses may override this routine to provide different behavior.
3656 SourceLocation LParenOrBraceLoc,
3657 MultiExprArg Args,
3658 SourceLocation RParenOrBraceLoc,
3659 bool ListInitialization) {
3661 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3662 }
3663
3664 /// Build a new object-construction expression.
3665 ///
3666 /// By default, performs semantic analysis to build the new expression.
3667 /// Subclasses may override this routine to provide different behavior.
3669 SourceLocation LParenLoc,
3670 MultiExprArg Args,
3671 SourceLocation RParenLoc,
3672 bool ListInitialization) {
3673 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3674 RParenLoc, ListInitialization);
3675 }
3676
3677 /// Build a new member reference expression.
3678 ///
3679 /// By default, performs semantic analysis to build the new expression.
3680 /// Subclasses may override this routine to provide different behavior.
3682 QualType BaseType,
3683 bool IsArrow,
3684 SourceLocation OperatorLoc,
3685 NestedNameSpecifierLoc QualifierLoc,
3686 SourceLocation TemplateKWLoc,
3687 NamedDecl *FirstQualifierInScope,
3688 const DeclarationNameInfo &MemberNameInfo,
3689 const TemplateArgumentListInfo *TemplateArgs) {
3690 CXXScopeSpec SS;
3691 SS.Adopt(QualifierLoc);
3692
3693 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3694 OperatorLoc, IsArrow,
3695 SS, TemplateKWLoc,
3696 FirstQualifierInScope,
3697 MemberNameInfo,
3698 TemplateArgs, /*S*/nullptr);
3699 }
3700
3701 /// Build a new member reference expression.
3702 ///
3703 /// By default, performs semantic analysis to build the new expression.
3704 /// Subclasses may override this routine to provide different behavior.
3706 SourceLocation OperatorLoc,
3707 bool IsArrow,
3708 NestedNameSpecifierLoc QualifierLoc,
3709 SourceLocation TemplateKWLoc,
3710 NamedDecl *FirstQualifierInScope,
3711 LookupResult &R,
3712 const TemplateArgumentListInfo *TemplateArgs) {
3713 CXXScopeSpec SS;
3714 SS.Adopt(QualifierLoc);
3715
3716 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3717 OperatorLoc, IsArrow,
3718 SS, TemplateKWLoc,
3719 FirstQualifierInScope,
3720 R, TemplateArgs, /*S*/nullptr);
3721 }
3722
3723 /// Build a new noexcept expression.
3724 ///
3725 /// By default, performs semantic analysis to build the new expression.
3726 /// Subclasses may override this routine to provide different behavior.
3728 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3729 }
3730
3733
3734 /// Build a new expression to compute the length of a parameter pack.
3736 SourceLocation PackLoc,
3737 SourceLocation RParenLoc,
3738 UnsignedOrNone Length,
3739 ArrayRef<TemplateArgument> PartialArgs) {
3740 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3741 RParenLoc, Length, PartialArgs);
3742 }
3743
3745 SourceLocation RSquareLoc,
3746 Expr *PackIdExpression, Expr *IndexExpr,
3747 ArrayRef<Expr *> ExpandedExprs,
3748 bool FullySubstituted = false) {
3749 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3750 IndexExpr, RSquareLoc, ExpandedExprs,
3751 FullySubstituted);
3752 }
3753
3754 /// Build a new expression representing a call to a source location
3755 /// builtin.
3756 ///
3757 /// By default, performs semantic analysis to build the new expression.
3758 /// Subclasses may override this routine to provide different behavior.
3760 SourceLocation BuiltinLoc,
3761 SourceLocation RPLoc,
3762 DeclContext *ParentContext) {
3763 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3764 ParentContext);
3765 }
3766
3768 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3769 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3771 CXXScopeSpec SS;
3772 SS.Adopt(NNS);
3773 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3774 ConceptNameInfo,
3775 FoundDecl,
3776 NamedConcept, TALI);
3777 if (Result.isInvalid())
3778 return ExprError();
3779 return Result;
3780 }
3781
3782 /// \brief Build a new requires expression.
3783 ///
3784 /// By default, performs semantic analysis to build the new expression.
3785 /// Subclasses may override this routine to provide different behavior.
3788 SourceLocation LParenLoc,
3789 ArrayRef<ParmVarDecl *> LocalParameters,
3790 SourceLocation RParenLoc,
3792 SourceLocation ClosingBraceLoc) {
3793 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3794 LocalParameters, RParenLoc, Requirements,
3795 ClosingBraceLoc);
3796 }
3797
3801 return SemaRef.BuildTypeRequirement(SubstDiag);
3802 }
3803
3805 return SemaRef.BuildTypeRequirement(T);
3806 }
3807
3810 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3811 SourceLocation NoexceptLoc,
3813 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3814 std::move(Ret));
3815 }
3816
3818 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3820 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3821 std::move(Ret));
3822 }
3823
3825 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3826 const ASTConstraintSatisfaction &Satisfaction) {
3827 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3828 Satisfaction);
3829 }
3830
3832 return SemaRef.BuildNestedRequirement(Constraint);
3833 }
3834
3835 /// \brief Build a new Objective-C boxed expression.
3836 ///
3837 /// By default, performs semantic analysis to build the new expression.
3838 /// Subclasses may override this routine to provide different behavior.
3840 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3841 }
3842
3843 /// Build a new Objective-C array literal.
3844 ///
3845 /// By default, performs semantic analysis to build the new expression.
3846 /// Subclasses may override this routine to provide different behavior.
3848 Expr **Elements, unsigned NumElements) {
3850 Range, MultiExprArg(Elements, NumElements));
3851 }
3852
3854 Expr *Base, Expr *Key,
3855 ObjCMethodDecl *getterMethod,
3856 ObjCMethodDecl *setterMethod) {
3858 RB, Base, Key, getterMethod, setterMethod);
3859 }
3860
3861 /// Build a new Objective-C dictionary literal.
3862 ///
3863 /// By default, performs semantic analysis to build the new expression.
3864 /// Subclasses may override this routine to provide different behavior.
3869
3870 /// Build a new Objective-C \@encode expression.
3871 ///
3872 /// By default, performs semantic analysis to build the new expression.
3873 /// Subclasses may override this routine to provide different behavior.
3875 TypeSourceInfo *EncodeTypeInfo,
3876 SourceLocation RParenLoc) {
3877 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3878 RParenLoc);
3879 }
3880
3881 /// Build a new Objective-C class message.
3883 Selector Sel,
3884 ArrayRef<SourceLocation> SelectorLocs,
3886 SourceLocation LBracLoc,
3887 MultiExprArg Args,
3888 SourceLocation RBracLoc) {
3889 return SemaRef.ObjC().BuildClassMessage(
3890 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3891 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3892 RBracLoc, Args);
3893 }
3894
3895 /// Build a new Objective-C instance message.
3897 Selector Sel,
3898 ArrayRef<SourceLocation> SelectorLocs,
3900 SourceLocation LBracLoc,
3901 MultiExprArg Args,
3902 SourceLocation RBracLoc) {
3903 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3904 /*SuperLoc=*/SourceLocation(),
3905 Sel, Method, LBracLoc,
3906 SelectorLocs, RBracLoc, Args);
3907 }
3908
3909 /// Build a new Objective-C instance/class message to 'super'.
3911 Selector Sel,
3912 ArrayRef<SourceLocation> SelectorLocs,
3913 QualType SuperType,
3915 SourceLocation LBracLoc,
3916 MultiExprArg Args,
3917 SourceLocation RBracLoc) {
3918 return Method->isInstanceMethod()
3919 ? SemaRef.ObjC().BuildInstanceMessage(
3920 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3921 SelectorLocs, RBracLoc, Args)
3922 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3923 Sel, Method, LBracLoc,
3924 SelectorLocs, RBracLoc, Args);
3925 }
3926
3927 /// Build a new Objective-C ivar reference expression.
3928 ///
3929 /// By default, performs semantic analysis to build the new expression.
3930 /// Subclasses may override this routine to provide different behavior.
3932 SourceLocation IvarLoc,
3933 bool IsArrow, bool IsFreeIvar) {
3934 CXXScopeSpec SS;
3935 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3937 BaseArg, BaseArg->getType(),
3938 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3939 /*FirstQualifierInScope=*/nullptr, NameInfo,
3940 /*TemplateArgs=*/nullptr,
3941 /*S=*/nullptr);
3942 if (IsFreeIvar && Result.isUsable())
3943 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3944 return Result;
3945 }
3946
3947 /// Build a new Objective-C property reference expression.
3948 ///
3949 /// By default, performs semantic analysis to build the new expression.
3950 /// Subclasses may override this routine to provide different behavior.
3953 SourceLocation PropertyLoc) {
3954 CXXScopeSpec SS;
3955 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3956 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3957 /*FIXME:*/PropertyLoc,
3958 /*IsArrow=*/false,
3959 SS, SourceLocation(),
3960 /*FirstQualifierInScope=*/nullptr,
3961 NameInfo,
3962 /*TemplateArgs=*/nullptr,
3963 /*S=*/nullptr);
3964 }
3965
3966 /// Build a new Objective-C property reference expression.
3967 ///
3968 /// By default, performs semantic analysis to build the new expression.
3969 /// Subclasses may override this routine to provide different behavior.
3971 ObjCMethodDecl *Getter,
3972 ObjCMethodDecl *Setter,
3973 SourceLocation PropertyLoc) {
3974 // Since these expressions can only be value-dependent, we do not
3975 // need to perform semantic analysis again.
3976 return Owned(
3977 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3979 PropertyLoc, Base));
3980 }
3981
3982 /// Build a new Objective-C "isa" expression.
3983 ///
3984 /// By default, performs semantic analysis to build the new expression.
3985 /// Subclasses may override this routine to provide different behavior.
3987 SourceLocation OpLoc, bool IsArrow) {
3988 CXXScopeSpec SS;
3989 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
3990 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3991 OpLoc, IsArrow,
3992 SS, SourceLocation(),
3993 /*FirstQualifierInScope=*/nullptr,
3994 NameInfo,
3995 /*TemplateArgs=*/nullptr,
3996 /*S=*/nullptr);
3997 }
3998
3999 /// Build a new shuffle vector expression.
4000 ///
4001 /// By default, performs semantic analysis to build the new expression.
4002 /// Subclasses may override this routine to provide different behavior.
4004 MultiExprArg SubExprs,
4005 SourceLocation RParenLoc) {
4006 // Find the declaration for __builtin_shufflevector
4007 const IdentifierInfo &Name
4008 = SemaRef.Context.Idents.get("__builtin_shufflevector");
4009 TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
4010 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
4011 assert(!Lookup.empty() && "No __builtin_shufflevector?");
4012
4013 // Build a reference to the __builtin_shufflevector builtin
4015 Expr *Callee = new (SemaRef.Context)
4016 DeclRefExpr(SemaRef.Context, Builtin, false,
4017 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
4018 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
4019 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
4020 CK_BuiltinFnToFnPtr).get();
4021
4022 // Build the CallExpr
4023 ExprResult TheCall = CallExpr::Create(
4024 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
4025 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
4027
4028 // Type-check the __builtin_shufflevector expression.
4029 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
4030 }
4031
4032 /// Build a new convert vector expression.
4034 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
4035 SourceLocation RParenLoc) {
4036 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
4037 }
4038
4039 /// Build a new template argument pack expansion.
4040 ///
4041 /// By default, performs semantic analysis to build a new pack expansion
4042 /// for a template argument. Subclasses may override this routine to provide
4043 /// different behavior.
4045 SourceLocation EllipsisLoc,
4046 UnsignedOrNone NumExpansions) {
4047 switch (Pattern.getArgument().getKind()) {
4051 EllipsisLoc, NumExpansions);
4052 if (Result.isInvalid())
4053 return TemplateArgumentLoc();
4054
4056 /*IsCanonical=*/false),
4057 Result.get());
4058 }
4059
4061 return TemplateArgumentLoc(
4062 SemaRef.Context,
4064 NumExpansions),
4065 Pattern.getTemplateKWLoc(), Pattern.getTemplateQualifierLoc(),
4066 Pattern.getTemplateNameLoc(), EllipsisLoc);
4067
4075 llvm_unreachable("Pack expansion pattern has no parameter packs");
4076
4078 if (TypeSourceInfo *Expansion
4079 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4080 EllipsisLoc,
4081 NumExpansions))
4082 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4083 Expansion);
4084 break;
4085 }
4086
4087 return TemplateArgumentLoc();
4088 }
4089
4090 /// Build a new expression pack expansion.
4091 ///
4092 /// By default, performs semantic analysis to build a new pack expansion
4093 /// for an expression. Subclasses may override this routine to provide
4094 /// different behavior.
4096 UnsignedOrNone NumExpansions) {
4097 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4098 }
4099
4100 /// Build a new C++1z fold-expression.
4101 ///
4102 /// By default, performs semantic analysis in order to build a new fold
4103 /// expression.
4105 SourceLocation LParenLoc, Expr *LHS,
4106 BinaryOperatorKind Operator,
4107 SourceLocation EllipsisLoc, Expr *RHS,
4108 SourceLocation RParenLoc,
4109 UnsignedOrNone NumExpansions) {
4110 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4111 EllipsisLoc, RHS, RParenLoc,
4112 NumExpansions);
4113 }
4114
4116 LambdaScopeInfo *LSI) {
4117 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4118 if (Expr *Init = PVD->getInit())
4120 Init->containsUnexpandedParameterPack();
4121 else if (PVD->hasUninstantiatedDefaultArg())
4123 PVD->getUninstantiatedDefaultArg()
4124 ->containsUnexpandedParameterPack();
4125 }
4126 return getSema().BuildLambdaExpr(StartLoc, EndLoc);
4127 }
4128
4129 /// Build an empty C++1z fold-expression with the given operator.
4130 ///
4131 /// By default, produces the fallback value for the fold-expression, or
4132 /// produce an error if there is no fallback value.
4134 BinaryOperatorKind Operator) {
4135 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4136 }
4137
4138 /// Build a new atomic operation expression.
4139 ///
4140 /// By default, performs semantic analysis to build the new expression.
4141 /// Subclasses may override this routine to provide different behavior.
4144 SourceLocation RParenLoc) {
4145 // Use this for all of the locations, since we don't know the difference
4146 // between the call and the expr at this point.
4147 SourceRange Range{BuiltinLoc, RParenLoc};
4148 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4150 }
4151
4153 ArrayRef<Expr *> SubExprs, QualType Type) {
4154 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4155 }
4156
4158 SourceLocation BeginLoc,
4159 SourceLocation DirLoc,
4160 SourceLocation EndLoc,
4162 StmtResult StrBlock) {
4164 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4165 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, StrBlock);
4166 }
4167
4178
4180 SourceLocation BeginLoc,
4181 SourceLocation DirLoc,
4182 SourceLocation EndLoc,
4184 StmtResult Loop) {
4186 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4187 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, Loop);
4188 }
4189
4191 SourceLocation DirLoc,
4192 SourceLocation EndLoc,
4194 StmtResult StrBlock) {
4196 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4198 Clauses, StrBlock);
4199 }
4200
4210
4220
4222 SourceLocation DirLoc,
4223 SourceLocation EndLoc,
4225 StmtResult StrBlock) {
4229 Clauses, StrBlock);
4230 }
4231
4233 SourceLocation DirLoc,
4234 SourceLocation EndLoc,
4235 ArrayRef<OpenACCClause *> Clauses) {
4237 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4239 Clauses, {});
4240 }
4241
4251
4253 SourceLocation DirLoc,
4254 SourceLocation EndLoc,
4255 ArrayRef<OpenACCClause *> Clauses) {
4257 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4259 Clauses, {});
4260 }
4261
4263 SourceLocation DirLoc,
4264 SourceLocation EndLoc,
4265 ArrayRef<OpenACCClause *> Clauses) {
4267 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4269 Clauses, {});
4270 }
4271
4273 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4274 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4275 SourceLocation RParenLoc, SourceLocation EndLoc,
4276 ArrayRef<OpenACCClause *> Clauses) {
4278 Exprs.push_back(DevNumExpr);
4279 llvm::append_range(Exprs, QueueIdExprs);
4281 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4282 Exprs, OpenACCAtomicKind::None, RParenLoc, EndLoc, Clauses, {});
4283 }
4284
4286 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4287 SourceLocation ReadOnlyLoc, ArrayRef<Expr *> VarList,
4288 SourceLocation RParenLoc, SourceLocation EndLoc) {
4290 OpenACCDirectiveKind::Cache, BeginLoc, DirLoc, LParenLoc, ReadOnlyLoc,
4291 VarList, OpenACCAtomicKind::None, RParenLoc, EndLoc, {}, {});
4292 }
4293
4295 SourceLocation DirLoc,
4296 OpenACCAtomicKind AtKind,
4297 SourceLocation EndLoc,
4299 StmtResult AssociatedStmt) {
4301 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4302 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, Clauses,
4303 AssociatedStmt);
4304 }
4305
4309
4312 const NonTypeTemplateParmDecl *NTTP,
4314 UnsignedOrNone PackIndex, bool Final) {
4316 AssociatedDecl, NTTP, Loc, Arg, PackIndex, Final);
4317 }
4318
4319private:
4320 QualType TransformTypeInObjectScope(TypeLocBuilder &TLB, TypeLoc TL,
4321 QualType ObjectType,
4322 NamedDecl *FirstQualifierInScope);
4323
4324 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4325 QualType ObjectType,
4326 NamedDecl *FirstQualifierInScope) {
4327 if (getDerived().AlreadyTransformed(TSInfo->getType()))
4328 return TSInfo;
4329
4330 TypeLocBuilder TLB;
4331 QualType T = TransformTypeInObjectScope(TLB, TSInfo->getTypeLoc(),
4332 ObjectType, FirstQualifierInScope);
4333 if (T.isNull())
4334 return nullptr;
4335 return TLB.getTypeSourceInfo(SemaRef.Context, T);
4336 }
4337
4338 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4339 DependentNameTypeLoc TL,
4340 bool DeducibleTSTContext,
4341 QualType ObjectType = QualType(),
4342 NamedDecl *UnqualLookup = nullptr);
4343
4345 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4347
4348 OpenACCClause *
4349 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4350 OpenACCDirectiveKind DirKind,
4351 const OpenACCClause *OldClause);
4352};
4353
4354template <typename Derived>
4356 if (!S)
4357 return S;
4358
4359 switch (S->getStmtClass()) {
4360 case Stmt::NoStmtClass: break;
4361
4362 // Transform individual statement nodes
4363 // Pass SDK into statements that can produce a value
4364#define STMT(Node, Parent) \
4365 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4366#define VALUESTMT(Node, Parent) \
4367 case Stmt::Node##Class: \
4368 return getDerived().Transform##Node(cast<Node>(S), SDK);
4369#define ABSTRACT_STMT(Node)
4370#define EXPR(Node, Parent)
4371#include "clang/AST/StmtNodes.inc"
4372
4373 // Transform expressions by calling TransformExpr.
4374#define STMT(Node, Parent)
4375#define ABSTRACT_STMT(Stmt)
4376#define EXPR(Node, Parent) case Stmt::Node##Class:
4377#include "clang/AST/StmtNodes.inc"
4378 {
4379 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4380
4382 E = getSema().ActOnStmtExprResult(E);
4383 return getSema().ActOnExprStmt(E, SDK == StmtDiscardKind::Discarded);
4384 }
4385 }
4386
4387 return S;
4388}
4389
4390template<typename Derived>
4392 if (!S)
4393 return S;
4394
4395 switch (S->getClauseKind()) {
4396 default: break;
4397 // Transform individual clause nodes
4398#define GEN_CLANG_CLAUSE_CLASS
4399#define CLAUSE_CLASS(Enum, Str, Class) \
4400 case Enum: \
4401 return getDerived().Transform##Class(cast<Class>(S));
4402#include "llvm/Frontend/OpenMP/OMP.inc"
4403 }
4404
4405 return S;
4406}
4407
4408
4409template<typename Derived>
4411 if (!E)
4412 return E;
4413
4414 switch (E->getStmtClass()) {
4415 case Stmt::NoStmtClass: break;
4416#define STMT(Node, Parent) case Stmt::Node##Class: break;
4417#define ABSTRACT_STMT(Stmt)
4418#define EXPR(Node, Parent) \
4419 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4420#include "clang/AST/StmtNodes.inc"
4421 }
4422
4423 return E;
4424}
4425
4426template<typename Derived>
4428 bool NotCopyInit) {
4429 // Initializers are instantiated like expressions, except that various outer
4430 // layers are stripped.
4431 if (!Init)
4432 return Init;
4433
4434 if (auto *FE = dyn_cast<FullExpr>(Init))
4435 Init = FE->getSubExpr();
4436
4437 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4438 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4439 Init = OVE->getSourceExpr();
4440 }
4441
4442 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4443 Init = MTE->getSubExpr();
4444
4445 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4446 Init = Binder->getSubExpr();
4447
4448 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4449 Init = ICE->getSubExprAsWritten();
4450
4451 if (CXXStdInitializerListExpr *ILE =
4452 dyn_cast<CXXStdInitializerListExpr>(Init))
4453 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4454
4455 // If this is copy-initialization, we only need to reconstruct
4456 // InitListExprs. Other forms of copy-initialization will be a no-op if
4457 // the initializer is already the right type.
4458 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4459 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4460 return getDerived().TransformExpr(Init);
4461
4462 // Revert value-initialization back to empty parens.
4463 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4464 SourceRange Parens = VIE->getSourceRange();
4465 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4466 Parens.getEnd());
4467 }
4468
4469 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4471 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4472 SourceLocation());
4473
4474 // Revert initialization by constructor back to a parenthesized or braced list
4475 // of expressions. Any other form of initializer can just be reused directly.
4476 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4477 return getDerived().TransformExpr(Init);
4478
4479 // If the initialization implicitly converted an initializer list to a
4480 // std::initializer_list object, unwrap the std::initializer_list too.
4481 if (Construct && Construct->isStdInitListInitialization())
4482 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4483
4484 // Enter a list-init context if this was list initialization.
4487 Construct->isListInitialization());
4488
4489 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4490 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4491 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4492 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4493 SmallVector<Expr*, 8> NewArgs;
4494 bool ArgChanged = false;
4495 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4496 /*IsCall*/true, NewArgs, &ArgChanged))
4497 return ExprError();
4498
4499 // If this was list initialization, revert to syntactic list form.
4500 if (Construct->isListInitialization())
4501 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4502 Construct->getEndLoc());
4503
4504 // Build a ParenListExpr to represent anything else.
4506 if (Parens.isInvalid()) {
4507 // This was a variable declaration's initialization for which no initializer
4508 // was specified.
4509 assert(NewArgs.empty() &&
4510 "no parens or braces but have direct init with arguments?");
4511 return ExprEmpty();
4512 }
4513 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4514 Parens.getEnd());
4515}
4516
4517template<typename Derived>
4519 unsigned NumInputs,
4520 bool IsCall,
4521 SmallVectorImpl<Expr *> &Outputs,
4522 bool *ArgChanged) {
4523 for (unsigned I = 0; I != NumInputs; ++I) {
4524 // If requested, drop call arguments that need to be dropped.
4525 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4526 if (ArgChanged)
4527 *ArgChanged = true;
4528
4529 break;
4530 }
4531
4532 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4533 Expr *Pattern = Expansion->getPattern();
4534
4536 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4537 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4538
4539 // Determine whether the set of unexpanded parameter packs can and should
4540 // be expanded.
4541 bool Expand = true;
4542 bool RetainExpansion = false;
4543 UnsignedOrNone OrigNumExpansions = Expansion->getNumExpansions();
4544 UnsignedOrNone NumExpansions = OrigNumExpansions;
4546 Expansion->getEllipsisLoc(), Pattern->getSourceRange(),
4547 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
4548 RetainExpansion, NumExpansions))
4549 return true;
4550
4551 if (!Expand) {
4552 // The transform has determined that we should perform a simple
4553 // transformation on the pack expansion, producing another pack
4554 // expansion.
4555 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
4556 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4557 if (OutPattern.isInvalid())
4558 return true;
4559
4560 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4561 Expansion->getEllipsisLoc(),
4562 NumExpansions);
4563 if (Out.isInvalid())
4564 return true;
4565
4566 if (ArgChanged)
4567 *ArgChanged = true;
4568 Outputs.push_back(Out.get());
4569 continue;
4570 }
4571
4572 // Record right away that the argument was changed. This needs
4573 // to happen even if the array expands to nothing.
4574 if (ArgChanged) *ArgChanged = true;
4575
4576 // The transform has determined that we should perform an elementwise
4577 // expansion of the pattern. Do so.
4578 for (unsigned I = 0; I != *NumExpansions; ++I) {
4579 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
4580 ExprResult Out = getDerived().TransformExpr(Pattern);
4581 if (Out.isInvalid())
4582 return true;
4583
4584 if (Out.get()->containsUnexpandedParameterPack()) {
4585 Out = getDerived().RebuildPackExpansion(
4586 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4587 if (Out.isInvalid())
4588 return true;
4589 }
4590
4591 Outputs.push_back(Out.get());
4592 }
4593
4594 // If we're supposed to retain a pack expansion, do so by temporarily
4595 // forgetting the partially-substituted parameter pack.
4596 if (RetainExpansion) {
4597 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4598
4599 ExprResult Out = getDerived().TransformExpr(Pattern);
4600 if (Out.isInvalid())
4601 return true;
4602
4603 Out = getDerived().RebuildPackExpansion(
4604 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4605 if (Out.isInvalid())
4606 return true;
4607
4608 Outputs.push_back(Out.get());
4609 }
4610
4611 continue;
4612 }
4613
4615 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4616 : getDerived().TransformExpr(Inputs[I]);
4617 if (Result.isInvalid())
4618 return true;
4619
4620 if (Result.get() != Inputs[I] && ArgChanged)
4621 *ArgChanged = true;
4622
4623 Outputs.push_back(Result.get());
4624 }
4625
4626 return false;
4627}
4628
4629template <typename Derived>
4632
4635 /*LambdaContextDecl=*/nullptr,
4637 /*ShouldEnter=*/Kind == Sema::ConditionKind::ConstexprIf);
4638
4639 if (Var) {
4640 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4642
4643 if (!ConditionVar)
4644 return Sema::ConditionError();
4645
4646 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4647 }
4648
4649 if (Expr) {
4650 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4651
4652 if (CondExpr.isInvalid())
4653 return Sema::ConditionError();
4654
4655 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4656 /*MissingOK=*/true);
4657 }
4658
4659 return Sema::ConditionResult();
4660}
4661
4662template <typename Derived>
4664 NestedNameSpecifierLoc NNS, QualType ObjectType,
4665 NamedDecl *FirstQualifierInScope) {
4667
4668 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4669 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4670 Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix)
4671 Qualifiers.push_back(Qualifier);
4672 };
4673 insertNNS(NNS);
4674
4675 CXXScopeSpec SS;
4676 while (!Qualifiers.empty()) {
4677 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4679
4680 switch (QNNS.getKind()) {
4682 llvm_unreachable("unexpected null nested name specifier");
4683
4686 Q.getLocalBeginLoc(), const_cast<NamespaceBaseDecl *>(
4688 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4689 break;
4690 }
4691
4693 // There is no meaningful transformation that one could perform on the
4694 // global scope.
4695 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4696 break;
4697
4699 CXXRecordDecl *RD = cast_or_null<CXXRecordDecl>(
4701 SS.MakeMicrosoftSuper(SemaRef.Context, RD, Q.getBeginLoc(),
4702 Q.getEndLoc());
4703 break;
4704 }
4705
4707 assert(SS.isEmpty());
4708 TypeLoc TL = Q.castAsTypeLoc();
4709
4710 if (auto DNT = TL.getAs<DependentNameTypeLoc>()) {
4711 NestedNameSpecifierLoc QualifierLoc = DNT.getQualifierLoc();
4712 if (QualifierLoc) {
4713 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4714 QualifierLoc, ObjectType, FirstQualifierInScope);
4715 if (!QualifierLoc)
4716 return NestedNameSpecifierLoc();
4717 ObjectType = QualType();
4718 FirstQualifierInScope = nullptr;
4719 }
4720 SS.Adopt(QualifierLoc);
4722 const_cast<IdentifierInfo *>(DNT.getTypePtr()->getIdentifier()),
4723 DNT.getNameLoc(), Q.getLocalEndLoc(), ObjectType);
4724 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo,
4725 false, SS,
4726 FirstQualifierInScope, false))
4727 return NestedNameSpecifierLoc();
4728 return SS.getWithLocInContext(SemaRef.Context);
4729 }
4730
4731 QualType T = TL.getType();
4732 TypeLocBuilder TLB;
4734 T = TransformTypeInObjectScope(TLB, TL, ObjectType,
4735 FirstQualifierInScope);
4736 if (T.isNull())
4737 return NestedNameSpecifierLoc();
4738 TL = TLB.getTypeLocInContext(SemaRef.Context, T);
4739 }
4740
4741 if (T->isDependentType() || T->isRecordType() ||
4742 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4743 if (T->isEnumeralType())
4744 SemaRef.Diag(TL.getBeginLoc(),
4745 diag::warn_cxx98_compat_enum_nested_name_spec);
4746 SS.Make(SemaRef.Context, TL, Q.getLocalEndLoc());
4747 break;
4748 }
4749 // If the nested-name-specifier is an invalid type def, don't emit an
4750 // error because a previous error should have already been emitted.
4752 if (!TTL || !TTL.getDecl()->isInvalidDecl()) {
4753 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4754 << T << SS.getRange();
4755 }
4756 return NestedNameSpecifierLoc();
4757 }
4758 }
4759 }
4760
4761 // Don't rebuild the nested-name-specifier if we don't have to.
4762 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4764 return NNS;
4765
4766 // If we can re-use the source-location data from the original
4767 // nested-name-specifier, do so.
4768 if (SS.location_size() == NNS.getDataLength() &&
4769 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4771
4772 // Allocate new nested-name-specifier location information.
4773 return SS.getWithLocInContext(SemaRef.Context);
4774}
4775
4776template<typename Derived>
4780 DeclarationName Name = NameInfo.getName();
4781 if (!Name)
4782 return DeclarationNameInfo();
4783
4784 switch (Name.getNameKind()) {
4792 return NameInfo;
4793
4795 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4796 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4797 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4798 if (!NewTemplate)
4799 return DeclarationNameInfo();
4800
4801 DeclarationNameInfo NewNameInfo(NameInfo);
4802 NewNameInfo.setName(
4803 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
4804 return NewNameInfo;
4805 }
4806
4810 TypeSourceInfo *NewTInfo;
4811 CanQualType NewCanTy;
4812 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4813 NewTInfo = getDerived().TransformType(OldTInfo);
4814 if (!NewTInfo)
4815 return DeclarationNameInfo();
4816 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4817 }
4818 else {
4819 NewTInfo = nullptr;
4820 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4821 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4822 if (NewT.isNull())
4823 return DeclarationNameInfo();
4824 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4825 }
4826
4827 DeclarationName NewName
4828 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4829 NewCanTy);
4830 DeclarationNameInfo NewNameInfo(NameInfo);
4831 NewNameInfo.setName(NewName);
4832 NewNameInfo.setNamedTypeInfo(NewTInfo);
4833 return NewNameInfo;
4834 }
4835 }
4836
4837 llvm_unreachable("Unknown name kind.");
4838}
4839
4840template <typename Derived>
4842 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4844 QualType ObjectType, bool AllowInjectedClassName) {
4845 if (const IdentifierInfo *II = IO.getIdentifier())
4846 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, *II, NameLoc,
4847 ObjectType, AllowInjectedClassName);
4848 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, IO.getOperator(),
4849 NameLoc, ObjectType,
4850 AllowInjectedClassName);
4851}
4852
4853template <typename Derived>
4855 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
4856 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
4857 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
4859 TemplateName UnderlyingName = QTN->getUnderlyingTemplate();
4860
4861 if (QualifierLoc) {
4862 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4863 QualifierLoc, ObjectType, FirstQualifierInScope);
4864 if (!QualifierLoc)
4865 return TemplateName();
4866 }
4867
4868 NestedNameSpecifierLoc UnderlyingQualifier;
4869 TemplateName NewUnderlyingName = getDerived().TransformTemplateName(
4870 UnderlyingQualifier, TemplateKWLoc, UnderlyingName, NameLoc, ObjectType,
4871 FirstQualifierInScope, AllowInjectedClassName);
4872 if (NewUnderlyingName.isNull())
4873 return TemplateName();
4874 assert(!UnderlyingQualifier && "unexpected qualifier");
4875
4876 if (!getDerived().AlwaysRebuild() &&
4877 QualifierLoc.getNestedNameSpecifier() == QTN->getQualifier() &&
4878 NewUnderlyingName == UnderlyingName)
4879 return Name;
4880 CXXScopeSpec SS;
4881 SS.Adopt(QualifierLoc);
4882 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4883 NewUnderlyingName);
4884 }
4885
4887 if (QualifierLoc) {
4888 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4889 QualifierLoc, ObjectType, FirstQualifierInScope);
4890 if (!QualifierLoc)
4891 return TemplateName();
4892 // The qualifier-in-scope and object type only apply to the leftmost
4893 // entity.
4894 ObjectType = QualType();
4895 }
4896
4897 if (!getDerived().AlwaysRebuild() &&
4898 QualifierLoc.getNestedNameSpecifier() == DTN->getQualifier() &&
4899 ObjectType.isNull())
4900 return Name;
4901
4902 CXXScopeSpec SS;
4903 SS.Adopt(QualifierLoc);
4904 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, DTN->getName(),
4905 NameLoc, ObjectType,
4906 AllowInjectedClassName);
4907 }
4908
4911 assert(!QualifierLoc && "Unexpected qualified SubstTemplateTemplateParm");
4912
4913 NestedNameSpecifierLoc ReplacementQualifierLoc;
4914 TemplateName ReplacementName = S->getReplacement();
4915 if (NestedNameSpecifier Qualifier = ReplacementName.getQualifier()) {
4917 Builder.MakeTrivial(SemaRef.Context, Qualifier, NameLoc);
4918 ReplacementQualifierLoc = Builder.getWithLocInContext(SemaRef.Context);
4919 }
4920
4921 TemplateName NewName = getDerived().TransformTemplateName(
4922 ReplacementQualifierLoc, TemplateKWLoc, ReplacementName, NameLoc,
4923 ObjectType, FirstQualifierInScope, AllowInjectedClassName);
4924 if (NewName.isNull())
4925 return TemplateName();
4926 Decl *AssociatedDecl =
4927 getDerived().TransformDecl(NameLoc, S->getAssociatedDecl());
4928 if (!getDerived().AlwaysRebuild() && NewName == S->getReplacement() &&
4929 AssociatedDecl == S->getAssociatedDecl())
4930 return Name;
4931 return SemaRef.Context.getSubstTemplateTemplateParm(
4932 NewName, AssociatedDecl, S->getIndex(), S->getPackIndex(),
4933 S->getFinal());
4934 }
4935
4936 assert(!Name.getAsDeducedTemplateName() &&
4937 "DeducedTemplateName should not escape partial ordering");
4938
4939 // FIXME: Preserve UsingTemplateName.
4940 if (auto *Template = Name.getAsTemplateDecl()) {
4941 assert(!QualifierLoc && "Unexpected qualifier");
4942 return TemplateName(cast_or_null<TemplateDecl>(
4943 getDerived().TransformDecl(NameLoc, Template)));
4944 }
4945
4948 assert(!QualifierLoc &&
4949 "Unexpected qualified SubstTemplateTemplateParmPack");
4950 return getDerived().RebuildTemplateName(
4951 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4952 SubstPack->getIndex(), SubstPack->getFinal());
4953 }
4954
4955 // These should be getting filtered out before they reach the AST.
4956 llvm_unreachable("overloaded function decl survived to here");
4957}
4958
4959template <typename Derived>
4961 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
4962 TemplateName Name, SourceLocation NameLoc) {
4963 TemplateName TN = getDerived().TransformTemplateName(
4964 QualifierLoc, TemplateKeywordLoc, Name, NameLoc);
4965 if (TN.isNull())
4966 return TemplateArgument();
4967 return TemplateArgument(TN);
4968}
4969
4970template<typename Derived>
4972 const TemplateArgument &Arg,
4973 TemplateArgumentLoc &Output) {
4974 Output = getSema().getTrivialTemplateArgumentLoc(
4975 Arg, QualType(), getDerived().getBaseLocation());
4976}
4977
4978template <typename Derived>
4980 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
4981 bool Uneval) {
4982 const TemplateArgument &Arg = Input.getArgument();
4983 switch (Arg.getKind()) {
4986 llvm_unreachable("Unexpected TemplateArgument");
4987
4992 // Transform a resolved template argument straight to a resolved template
4993 // argument. We get here when substituting into an already-substituted
4994 // template type argument during concept satisfaction checking.
4996 QualType NewT = getDerived().TransformType(T);
4997 if (NewT.isNull())
4998 return true;
4999
5001 ? Arg.getAsDecl()
5002 : nullptr;
5003 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
5005 : nullptr;
5006 if (D && !NewD)
5007 return true;
5008
5009 if (NewT == T && D == NewD)
5010 Output = Input;
5011 else if (Arg.getKind() == TemplateArgument::Integral)
5012 Output = TemplateArgumentLoc(
5013 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
5015 else if (Arg.getKind() == TemplateArgument::NullPtr)
5016 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
5018 else if (Arg.getKind() == TemplateArgument::Declaration)
5019 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
5022 Output = TemplateArgumentLoc(
5023 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
5025 else
5026 llvm_unreachable("unexpected template argument kind");
5027
5028 return false;
5029 }
5030
5032 TypeSourceInfo *TSI = Input.getTypeSourceInfo();
5033 if (!TSI)
5035
5036 TSI = getDerived().TransformType(TSI);
5037 if (!TSI)
5038 return true;
5039
5040 Output = TemplateArgumentLoc(TemplateArgument(TSI->getType()), TSI);
5041 return false;
5042 }
5043
5045 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
5046
5047 TemplateArgument Out = getDerived().TransformNamedTemplateTemplateArgument(
5048 QualifierLoc, Input.getTemplateKWLoc(), Arg.getAsTemplate(),
5049 Input.getTemplateNameLoc());
5050 if (Out.isNull())
5051 return true;
5052 Output = TemplateArgumentLoc(SemaRef.Context, Out, Input.getTemplateKWLoc(),
5053 QualifierLoc, Input.getTemplateNameLoc());
5054 return false;
5055 }
5056
5058 llvm_unreachable("Caller should expand pack expansions");
5059
5061 // Template argument expressions are constant expressions.
5063 getSema(),
5066 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
5068
5069 Expr *InputExpr = Input.getSourceExpression();
5070 if (!InputExpr)
5071 InputExpr = Input.getArgument().getAsExpr();
5072
5073 ExprResult E = getDerived().TransformExpr(InputExpr);
5074 E = SemaRef.ActOnConstantExpression(E);
5075 if (E.isInvalid())
5076 return true;
5077 Output = TemplateArgumentLoc(
5078 TemplateArgument(E.get(), /*IsCanonical=*/false), E.get());
5079 return false;
5080 }
5081 }
5082
5083 // Work around bogus GCC warning
5084 return true;
5085}
5086
5087/// Iterator adaptor that invents template argument location information
5088/// for each of the template arguments in its underlying iterator.
5089template<typename Derived, typename InputIterator>
5092 InputIterator Iter;
5093
5094public:
5097 typedef typename std::iterator_traits<InputIterator>::difference_type
5099 typedef std::input_iterator_tag iterator_category;
5100
5101 class pointer {
5103
5104 public:
5105 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5106
5107 const TemplateArgumentLoc *operator->() const { return &Arg; }
5108 };
5109
5111 InputIterator Iter)
5112 : Self(Self), Iter(Iter) { }
5113
5115 ++Iter;
5116 return *this;
5117 }
5118
5121 ++(*this);
5122 return Old;
5123 }
5124
5127 Self.InventTemplateArgumentLoc(*Iter, Result);
5128 return Result;
5129 }
5130
5131 pointer operator->() const { return pointer(**this); }
5132
5135 return X.Iter == Y.Iter;
5136 }
5137
5140 return X.Iter != Y.Iter;
5141 }
5142};
5143
5144template<typename Derived>
5145template<typename InputIterator>
5147 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5148 bool Uneval) {
5149 for (TemplateArgumentLoc In : llvm::make_range(First, Last)) {
5151 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5152 // Unpack argument packs, which we translate them into separate
5153 // arguments.
5154 // FIXME: We could do much better if we could guarantee that the
5155 // TemplateArgumentLocInfo for the pack expansion would be usable for
5156 // all of the template arguments in the argument pack.
5157 typedef TemplateArgumentLocInventIterator<Derived,
5159 PackLocIterator;
5160
5161 TemplateArgumentListInfo *PackOutput = &Outputs;
5163
5165 PackLocIterator(*this, In.getArgument().pack_begin()),
5166 PackLocIterator(*this, In.getArgument().pack_end()), *PackOutput,
5167 Uneval))
5168 return true;
5169
5170 continue;
5171 }
5172
5173 if (In.getArgument().isPackExpansion()) {
5174 UnexpandedInfo Info;
5175 TemplateArgumentLoc Prepared;
5176 if (PreparePackForExpansion(In, Uneval, Prepared, Info))
5177 return true;
5178 if (!Info.Expand) {
5179 Outputs.addArgument(Prepared);
5180 continue;
5181 }
5182
5183 // The transform has determined that we should perform an elementwise
5184 // expansion of the pattern. Do so.
5185 std::optional<ForgetSubstitutionRAII> ForgetSubst;
5187 ForgetSubst.emplace(getDerived());
5188 for (unsigned I = 0; I != *Info.NumExpansions; ++I) {
5189 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5190
5192 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5193 return true;
5194
5195 if (Out.getArgument().containsUnexpandedParameterPack()) {
5196 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5197 Info.OrigNumExpansions);
5198 if (Out.getArgument().isNull())
5199 return true;
5200 }
5201
5202 Outputs.addArgument(Out);
5203 }
5204
5205 // If we're supposed to retain a pack expansion, do so by temporarily
5206 // forgetting the partially-substituted parameter pack.
5207 if (Info.RetainExpansion) {
5208 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5209
5211 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5212 return true;
5213
5214 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5215 Info.OrigNumExpansions);
5216 if (Out.getArgument().isNull())
5217 return true;
5218
5219 Outputs.addArgument(Out);
5220 }
5221
5222 continue;
5223 }
5224
5225 // The simple case:
5226 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5227 return true;
5228
5229 Outputs.addArgument(Out);
5230 }
5231
5232 return false;
5233}
5234
5235template <typename Derived>
5236template <typename InputIterator>
5238 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5239 bool Uneval) {
5240
5241 // [C++26][temp.constr.normal]
5242 // any non-dependent concept template argument
5243 // is substituted into the constraint-expression of C.
5244 auto isNonDependentConceptArgument = [](const TemplateArgument &Arg) {
5245 return !Arg.isDependent() && Arg.isConceptOrConceptTemplateParameter();
5246 };
5247
5248 for (; First != Last; ++First) {
5251
5252 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5253 typedef TemplateArgumentLocInventIterator<Derived,
5255 PackLocIterator;
5257 PackLocIterator(*this, In.getArgument().pack_begin()),
5258 PackLocIterator(*this, In.getArgument().pack_end()), Outputs,
5259 Uneval))
5260 return true;
5261 continue;
5262 }
5263
5264 if (!isNonDependentConceptArgument(In.getArgument())) {
5265 Outputs.addArgument(In);
5266 continue;
5267 }
5268
5269 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5270 return true;
5271
5272 Outputs.addArgument(Out);
5273 }
5274
5275 return false;
5276}
5277
5278// FIXME: Find ways to reduce code duplication for pack expansions.
5279template <typename Derived>
5281 bool Uneval,
5283 UnexpandedInfo &Info) {
5284 auto ComputeInfo = [this](TemplateArgumentLoc Arg,
5285 bool IsLateExpansionAttempt, UnexpandedInfo &Info,
5286 TemplateArgumentLoc &Pattern) {
5287 assert(Arg.getArgument().isPackExpansion());
5288 // We have a pack expansion, for which we will be substituting into the
5289 // pattern.
5290 Pattern = getSema().getTemplateArgumentPackExpansionPattern(
5291 Arg, Info.Ellipsis, Info.OrigNumExpansions);
5293 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5294 if (IsLateExpansionAttempt) {
5295 // Request expansion only when there is an opportunity to expand a pack
5296 // that required a substituion first.
5297 bool SawPackTypes =
5298 llvm::any_of(Unexpanded, [](UnexpandedParameterPack P) {
5299 return P.first.dyn_cast<const SubstBuiltinTemplatePackType *>();
5300 });
5301 if (!SawPackTypes) {
5302 Info.Expand = false;
5303 return false;
5304 }
5305 }
5306 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5307
5308 // Determine whether the set of unexpanded parameter packs can and
5309 // should be expanded.
5310 Info.Expand = true;
5311 Info.RetainExpansion = false;
5312 Info.NumExpansions = Info.OrigNumExpansions;
5313 return getDerived().TryExpandParameterPacks(
5314 Info.Ellipsis, Pattern.getSourceRange(), Unexpanded,
5315 /*FailOnPackProducingTemplates=*/false, Info.Expand,
5316 Info.RetainExpansion, Info.NumExpansions);
5317 };
5318
5319 TemplateArgumentLoc Pattern;
5320 if (ComputeInfo(In, false, Info, Pattern))
5321 return true;
5322
5323 if (Info.Expand) {
5324 Out = Pattern;
5325 return false;
5326 }
5327
5328 // The transform has determined that we should perform a simple
5329 // transformation on the pack expansion, producing another pack
5330 // expansion.
5331 TemplateArgumentLoc OutPattern;
5332 std::optional<Sema::ArgPackSubstIndexRAII> SubstIndex(
5333 std::in_place, getSema(), std::nullopt);
5334 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5335 return true;
5336
5337 Out = getDerived().RebuildPackExpansion(OutPattern, Info.Ellipsis,
5338 Info.NumExpansions);
5339 if (Out.getArgument().isNull())
5340 return true;
5341 SubstIndex.reset();
5342
5343 if (!OutPattern.getArgument().containsUnexpandedParameterPack())
5344 return false;
5345
5346 // Some packs will learn their length after substitution, e.g.
5347 // __builtin_dedup_pack<T,int> has size 1 or 2, depending on the substitution
5348 // value of `T`.
5349 //
5350 // We only expand after we know sizes of all packs, check if this is the case
5351 // or not. However, we avoid a full template substitution and only do
5352 // expanstions after this point.
5353
5354 // E.g. when substituting template arguments of tuple with {T -> int} in the
5355 // following example:
5356 // template <class T>
5357 // struct TupleWithInt {
5358 // using type = std::tuple<__builtin_dedup_pack<T, int>...>;
5359 // };
5360 // TupleWithInt<int>::type y;
5361 // At this point we will see the `__builtin_dedup_pack<int, int>` with a known
5362 // lenght and run `ComputeInfo()` to provide the necessary information to our
5363 // caller.
5364 //
5365 // Note that we may still have situations where builtin is not going to be
5366 // expanded. For example:
5367 // template <class T>
5368 // struct Foo {
5369 // template <class U> using tuple_with_t =
5370 // std::tuple<__builtin_dedup_pack<T, U, int>...>; using type =
5371 // tuple_with_t<short>;
5372 // }
5373 // Because the substitution into `type` happens in dependent context, `type`
5374 // will be `tuple<builtin_dedup_pack<T, short, int>...>` after substitution
5375 // and the caller will not be able to expand it.
5376 ForgetSubstitutionRAII ForgetSubst(getDerived());
5377 if (ComputeInfo(Out, true, Info, OutPattern))
5378 return true;
5379 if (!Info.Expand)
5380 return false;
5381 Out = OutPattern;
5382 Info.ExpandUnderForgetSubstitions = true;
5383 return false;
5384}
5385
5386//===----------------------------------------------------------------------===//
5387// Type transformation
5388//===----------------------------------------------------------------------===//
5389
5390template<typename Derived>
5393 return T;
5394
5395 // Temporary workaround. All of these transformations should
5396 // eventually turn into transformations on TypeLocs.
5397 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5399
5400 TypeSourceInfo *NewTSI = getDerived().TransformType(TSI);
5401
5402 if (!NewTSI)
5403 return QualType();
5404
5405 return NewTSI->getType();
5406}
5407
5408template <typename Derived>
5410 // Refine the base location to the type's location.
5411 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5414 return TSI;
5415
5416 TypeLocBuilder TLB;
5417
5418 TypeLoc TL = TSI->getTypeLoc();
5419 TLB.reserve(TL.getFullDataSize());
5420
5421 QualType Result = getDerived().TransformType(TLB, TL);
5422 if (Result.isNull())
5423 return nullptr;
5424
5425 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5426}
5427
5428template<typename Derived>
5431 switch (T.getTypeLocClass()) {
5432#define ABSTRACT_TYPELOC(CLASS, PARENT)
5433#define TYPELOC(CLASS, PARENT) \
5434 case TypeLoc::CLASS: \
5435 return getDerived().Transform##CLASS##Type(TLB, \
5436 T.castAs<CLASS##TypeLoc>());
5437#include "clang/AST/TypeLocNodes.def"
5438 }
5439
5440 llvm_unreachable("unhandled type loc!");
5441}
5442
5443template<typename Derived>
5446 return TransformType(T);
5447
5449 return T;
5450 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5452 TypeSourceInfo *NewTSI = getDerived().TransformTypeWithDeducedTST(TSI);
5453 return NewTSI ? NewTSI->getType() : QualType();
5454}
5455
5456template <typename Derived>
5459 if (!isa<DependentNameType>(TSI->getType()))
5460 return TransformType(TSI);
5461
5462 // Refine the base location to the type's location.
5463 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5466 return TSI;
5467
5468 TypeLocBuilder TLB;
5469
5470 TypeLoc TL = TSI->getTypeLoc();
5471 TLB.reserve(TL.getFullDataSize());
5472
5473 auto QTL = TL.getAs<QualifiedTypeLoc>();
5474 if (QTL)
5475 TL = QTL.getUnqualifiedLoc();
5476
5477 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5478
5479 QualType Result = getDerived().TransformDependentNameType(
5480 TLB, DNTL, /*DeducedTSTContext*/true);
5481 if (Result.isNull())
5482 return nullptr;
5483
5484 if (QTL) {
5485 Result = getDerived().RebuildQualifiedType(Result, QTL);
5486 if (Result.isNull())
5487 return nullptr;
5489 }
5490
5491 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5492}
5493
5494template<typename Derived>
5499 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5500 auto SuppressObjCLifetime =
5501 T.getType().getLocalQualifiers().hasObjCLifetime();
5502 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5503 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5504 SuppressObjCLifetime);
5505 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5506 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5507 TLB, STTP, SuppressObjCLifetime);
5508 } else {
5509 Result = getDerived().TransformType(TLB, UnqualTL);
5510 }
5511
5512 if (Result.isNull())
5513 return QualType();
5514
5515 Result = getDerived().RebuildQualifiedType(Result, T);
5516
5517 if (Result.isNull())
5518 return QualType();
5519
5520 // RebuildQualifiedType might have updated the type, but not in a way
5521 // that invalidates the TypeLoc. (There's no location information for
5522 // qualifiers.)
5524
5525 return Result;
5526}
5527
5528template <typename Derived>
5530 QualifiedTypeLoc TL) {
5531
5532 SourceLocation Loc = TL.getBeginLoc();
5533 Qualifiers Quals = TL.getType().getLocalQualifiers();
5534
5535 if ((T.getAddressSpace() != LangAS::Default &&
5536 Quals.getAddressSpace() != LangAS::Default) &&
5537 T.getAddressSpace() != Quals.getAddressSpace()) {
5538 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5539 << TL.getType() << T;
5540 return QualType();
5541 }
5542
5543 PointerAuthQualifier LocalPointerAuth = Quals.getPointerAuth();
5544 if (LocalPointerAuth.isPresent()) {
5545 if (T.getPointerAuth().isPresent()) {
5546 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_redundant) << TL.getType();
5547 return QualType();
5548 }
5549 if (!T->isDependentType()) {
5550 if (!T->isSignableType(SemaRef.getASTContext())) {
5551 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_invalid_target) << T;
5552 return QualType();
5553 }
5554 }
5555 }
5556 // C++ [dcl.fct]p7:
5557 // [When] adding cv-qualifications on top of the function type [...] the
5558 // cv-qualifiers are ignored.
5559 if (T->isFunctionType()) {
5560 T = SemaRef.getASTContext().getAddrSpaceQualType(T,
5561 Quals.getAddressSpace());
5562 return T;
5563 }
5564
5565 // C++ [dcl.ref]p1:
5566 // when the cv-qualifiers are introduced through the use of a typedef-name
5567 // or decltype-specifier [...] the cv-qualifiers are ignored.
5568 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5569 // applied to a reference type.
5570 if (T->isReferenceType()) {
5571 // The only qualifier that applies to a reference type is restrict.
5572 if (!Quals.hasRestrict())
5573 return T;
5575 }
5576
5577 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5578 // resulting type.
5579 if (Quals.hasObjCLifetime()) {
5580 if (!T->isObjCLifetimeType() && !T->isDependentType())
5581 Quals.removeObjCLifetime();
5582 else if (T.getObjCLifetime()) {
5583 // Objective-C ARC:
5584 // A lifetime qualifier applied to a substituted template parameter
5585 // overrides the lifetime qualifier from the template argument.
5586 const AutoType *AutoTy;
5587 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5588 // 'auto' types behave the same way as template parameters.
5589 QualType Deduced = AutoTy->getDeducedType();
5590 Qualifiers Qs = Deduced.getQualifiers();
5591 Qs.removeObjCLifetime();
5592 Deduced =
5593 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5594 T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
5595 AutoTy->isDependentType(),
5596 /*isPack=*/false,
5597 AutoTy->getTypeConstraintConcept(),
5598 AutoTy->getTypeConstraintArguments());
5599 } else {
5600 // Otherwise, complain about the addition of a qualifier to an
5601 // already-qualified type.
5602 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5603 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5604 Quals.removeObjCLifetime();
5605 }
5606 }
5607 }
5608
5609 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5610}
5611
5612template <typename Derived>
5613QualType TreeTransform<Derived>::TransformTypeInObjectScope(
5614 TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType,
5615 NamedDecl *FirstQualifierInScope) {
5616 assert(!getDerived().AlreadyTransformed(TL.getType()));
5617
5618 switch (TL.getTypeLocClass()) {
5619 case TypeLoc::TemplateSpecialization:
5620 return getDerived().TransformTemplateSpecializationType(
5621 TLB, TL.castAs<TemplateSpecializationTypeLoc>(), ObjectType,
5622 FirstQualifierInScope, /*AllowInjectedClassName=*/true);
5623 case TypeLoc::DependentName:
5624 return getDerived().TransformDependentNameType(
5625 TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
5626 ObjectType, FirstQualifierInScope);
5627 default:
5628 // Any dependent canonical type can appear here, through type alias
5629 // templates.
5630 return getDerived().TransformType(TLB, TL);
5631 }
5632}
5633
5634template <class TyLoc> static inline
5636 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5637 NewT.setNameLoc(T.getNameLoc());
5638 return T.getType();
5639}
5640
5641template<typename Derived>
5642QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5643 BuiltinTypeLoc T) {
5644 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5645 NewT.setBuiltinLoc(T.getBuiltinLoc());
5646 if (T.needsExtraLocalData())
5647 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5648 return T.getType();
5649}
5650
5651template<typename Derived>
5653 ComplexTypeLoc T) {
5654 // FIXME: recurse?
5655 return TransformTypeSpecType(TLB, T);
5656}
5657
5658template <typename Derived>
5660 AdjustedTypeLoc TL) {
5661 // Adjustments applied during transformation are handled elsewhere.
5662 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5663}
5664
5665template<typename Derived>
5667 DecayedTypeLoc TL) {
5668 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5669 if (OriginalType.isNull())
5670 return QualType();
5671
5672 QualType Result = TL.getType();
5673 if (getDerived().AlwaysRebuild() ||
5674 OriginalType != TL.getOriginalLoc().getType())
5675 Result = SemaRef.Context.getDecayedType(OriginalType);
5676 TLB.push<DecayedTypeLoc>(Result);
5677 // Nothing to set for DecayedTypeLoc.
5678 return Result;
5679}
5680
5681template <typename Derived>
5685 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5686 if (OriginalType.isNull())
5687 return QualType();
5688
5689 QualType Result = TL.getType();
5690 if (getDerived().AlwaysRebuild() ||
5691 OriginalType != TL.getElementLoc().getType())
5692 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5693 TLB.push<ArrayParameterTypeLoc>(Result);
5694 // Nothing to set for ArrayParameterTypeLoc.
5695 return Result;
5696}
5697
5698template<typename Derived>
5700 PointerTypeLoc TL) {
5701 QualType PointeeType
5702 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5703 if (PointeeType.isNull())
5704 return QualType();
5705
5706 QualType Result = TL.getType();
5707 if (PointeeType->getAs<ObjCObjectType>()) {
5708 // A dependent pointer type 'T *' has is being transformed such
5709 // that an Objective-C class type is being replaced for 'T'. The
5710 // resulting pointer type is an ObjCObjectPointerType, not a
5711 // PointerType.
5712 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5713
5715 NewT.setStarLoc(TL.getStarLoc());
5716 return Result;
5717 }
5718
5719 if (getDerived().AlwaysRebuild() ||
5720 PointeeType != TL.getPointeeLoc().getType()) {
5721 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5722 if (Result.isNull())
5723 return QualType();
5724 }
5725
5726 // Objective-C ARC can add lifetime qualifiers to the type that we're
5727 // pointing to.
5728 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5729
5730 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5731 NewT.setSigilLoc(TL.getSigilLoc());
5732 return Result;
5733}
5734
5735template<typename Derived>
5739 QualType PointeeType
5740 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5741 if (PointeeType.isNull())
5742 return QualType();
5743
5744 QualType Result = TL.getType();
5745 if (getDerived().AlwaysRebuild() ||
5746 PointeeType != TL.getPointeeLoc().getType()) {
5747 Result = getDerived().RebuildBlockPointerType(PointeeType,
5748 TL.getSigilLoc());
5749 if (Result.isNull())
5750 return QualType();
5751 }
5752
5754 NewT.setSigilLoc(TL.getSigilLoc());
5755 return Result;
5756}
5757
5758/// Transforms a reference type. Note that somewhat paradoxically we
5759/// don't care whether the type itself is an l-value type or an r-value
5760/// type; we only care if the type was *written* as an l-value type
5761/// or an r-value type.
5762template<typename Derived>
5765 ReferenceTypeLoc TL) {
5766 const ReferenceType *T = TL.getTypePtr();
5767
5768 // Note that this works with the pointee-as-written.
5769 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5770 if (PointeeType.isNull())
5771 return QualType();
5772
5773 QualType Result = TL.getType();
5774 if (getDerived().AlwaysRebuild() ||
5775 PointeeType != T->getPointeeTypeAsWritten()) {
5776 Result = getDerived().RebuildReferenceType(PointeeType,
5777 T->isSpelledAsLValue(),
5778 TL.getSigilLoc());
5779 if (Result.isNull())
5780 return QualType();
5781 }
5782
5783 // Objective-C ARC can add lifetime qualifiers to the type that we're
5784 // referring to.
5787
5788 // r-value references can be rebuilt as l-value references.
5789 ReferenceTypeLoc NewTL;
5791 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5792 else
5793 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5794 NewTL.setSigilLoc(TL.getSigilLoc());
5795
5796 return Result;
5797}
5798
5799template<typename Derived>
5803 return TransformReferenceType(TLB, TL);
5804}
5805
5806template<typename Derived>
5807QualType
5808TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5809 RValueReferenceTypeLoc TL) {
5810 return TransformReferenceType(TLB, TL);
5811}
5812
5813template<typename Derived>
5817 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5818 if (PointeeType.isNull())
5819 return QualType();
5820
5821 const MemberPointerType *T = TL.getTypePtr();
5822
5823 NestedNameSpecifierLoc OldQualifierLoc = TL.getQualifierLoc();
5824 NestedNameSpecifierLoc NewQualifierLoc =
5825 getDerived().TransformNestedNameSpecifierLoc(OldQualifierLoc);
5826 if (!NewQualifierLoc)
5827 return QualType();
5828
5829 CXXRecordDecl *OldCls = T->getMostRecentCXXRecordDecl(), *NewCls = nullptr;
5830 if (OldCls) {
5831 NewCls = cast_or_null<CXXRecordDecl>(
5832 getDerived().TransformDecl(TL.getStarLoc(), OldCls));
5833 if (!NewCls)
5834 return QualType();
5835 }
5836
5837 QualType Result = TL.getType();
5838 if (getDerived().AlwaysRebuild() || PointeeType != T->getPointeeType() ||
5839 NewQualifierLoc.getNestedNameSpecifier() !=
5840 OldQualifierLoc.getNestedNameSpecifier() ||
5841 NewCls != OldCls) {
5842 CXXScopeSpec SS;
5843 SS.Adopt(NewQualifierLoc);
5844 Result = getDerived().RebuildMemberPointerType(PointeeType, SS, NewCls,
5845 TL.getStarLoc());
5846 if (Result.isNull())
5847 return QualType();
5848 }
5849
5850 // If we had to adjust the pointee type when building a member pointer, make
5851 // sure to push TypeLoc info for it.
5852 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5853 if (MPT && PointeeType != MPT->getPointeeType()) {
5854 assert(isa<AdjustedType>(MPT->getPointeeType()));
5855 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5856 }
5857
5859 NewTL.setSigilLoc(TL.getSigilLoc());
5860 NewTL.setQualifierLoc(NewQualifierLoc);
5861
5862 return Result;
5863}
5864
5865template<typename Derived>
5869 const ConstantArrayType *T = TL.getTypePtr();
5870 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5871 if (ElementType.isNull())
5872 return QualType();
5873
5874 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5875 Expr *OldSize = TL.getSizeExpr();
5876 if (!OldSize)
5877 OldSize = const_cast<Expr*>(T->getSizeExpr());
5878 Expr *NewSize = nullptr;
5879 if (OldSize) {
5882 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5883 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5884 }
5885
5886 QualType Result = TL.getType();
5887 if (getDerived().AlwaysRebuild() ||
5888 ElementType != T->getElementType() ||
5889 (T->getSizeExpr() && NewSize != OldSize)) {
5890 Result = getDerived().RebuildConstantArrayType(ElementType,
5891 T->getSizeModifier(),
5892 T->getSize(), NewSize,
5893 T->getIndexTypeCVRQualifiers(),
5894 TL.getBracketsRange());
5895 if (Result.isNull())
5896 return QualType();
5897 }
5898
5899 // We might have either a ConstantArrayType or a VariableArrayType now:
5900 // a ConstantArrayType is allowed to have an element type which is a
5901 // VariableArrayType if the type is dependent. Fortunately, all array
5902 // types have the same location layout.
5903 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5904 NewTL.setLBracketLoc(TL.getLBracketLoc());
5905 NewTL.setRBracketLoc(TL.getRBracketLoc());
5906 NewTL.setSizeExpr(NewSize);
5907
5908 return Result;
5909}
5910
5911template<typename Derived>
5913 TypeLocBuilder &TLB,
5915 const IncompleteArrayType *T = TL.getTypePtr();
5916 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5917 if (ElementType.isNull())
5918 return QualType();
5919
5920 QualType Result = TL.getType();
5921 if (getDerived().AlwaysRebuild() ||
5922 ElementType != T->getElementType()) {
5923 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5924 T->getSizeModifier(),
5925 T->getIndexTypeCVRQualifiers(),
5926 TL.getBracketsRange());
5927 if (Result.isNull())
5928 return QualType();
5929 }
5930
5932 NewTL.setLBracketLoc(TL.getLBracketLoc());
5933 NewTL.setRBracketLoc(TL.getRBracketLoc());
5934 NewTL.setSizeExpr(nullptr);
5935
5936 return Result;
5937}
5938
5939template<typename Derived>
5943 const VariableArrayType *T = TL.getTypePtr();
5944 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5945 if (ElementType.isNull())
5946 return QualType();
5947
5948 ExprResult SizeResult;
5949 {
5952 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5953 }
5954 if (SizeResult.isInvalid())
5955 return QualType();
5956 SizeResult =
5957 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5958 if (SizeResult.isInvalid())
5959 return QualType();
5960
5961 Expr *Size = SizeResult.get();
5962
5963 QualType Result = TL.getType();
5964 if (getDerived().AlwaysRebuild() ||
5965 ElementType != T->getElementType() ||
5966 Size != T->getSizeExpr()) {
5967 Result = getDerived().RebuildVariableArrayType(ElementType,
5968 T->getSizeModifier(),
5969 Size,
5970 T->getIndexTypeCVRQualifiers(),
5971 TL.getBracketsRange());
5972 if (Result.isNull())
5973 return QualType();
5974 }
5975
5976 // We might have constant size array now, but fortunately it has the same
5977 // location layout.
5978 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5979 NewTL.setLBracketLoc(TL.getLBracketLoc());
5980 NewTL.setRBracketLoc(TL.getRBracketLoc());
5981 NewTL.setSizeExpr(Size);
5982
5983 return Result;
5984}
5985
5986template<typename Derived>
5990 const DependentSizedArrayType *T = TL.getTypePtr();
5991 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5992 if (ElementType.isNull())
5993 return QualType();
5994
5995 // Array bounds are constant expressions.
5998
5999 // If we have a VLA then it won't be a constant.
6000 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
6001
6002 // Prefer the expression from the TypeLoc; the other may have been uniqued.
6003 Expr *origSize = TL.getSizeExpr();
6004 if (!origSize) origSize = T->getSizeExpr();
6005
6006 ExprResult sizeResult
6007 = getDerived().TransformExpr(origSize);
6008 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
6009 if (sizeResult.isInvalid())
6010 return QualType();
6011
6012 Expr *size = sizeResult.get();
6013
6014 QualType Result = TL.getType();
6015 if (getDerived().AlwaysRebuild() ||
6016 ElementType != T->getElementType() ||
6017 size != origSize) {
6018 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
6019 T->getSizeModifier(),
6020 size,
6021 T->getIndexTypeCVRQualifiers(),
6022 TL.getBracketsRange());
6023 if (Result.isNull())
6024 return QualType();
6025 }
6026
6027 // We might have any sort of array type now, but fortunately they
6028 // all have the same location layout.
6029 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6030 NewTL.setLBracketLoc(TL.getLBracketLoc());
6031 NewTL.setRBracketLoc(TL.getRBracketLoc());
6032 NewTL.setSizeExpr(size);
6033
6034 return Result;
6035}
6036
6037template <typename Derived>
6040 const DependentVectorType *T = TL.getTypePtr();
6041 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6042 if (ElementType.isNull())
6043 return QualType();
6044
6047
6048 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6049 Size = SemaRef.ActOnConstantExpression(Size);
6050 if (Size.isInvalid())
6051 return QualType();
6052
6053 QualType Result = TL.getType();
6054 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6055 Size.get() != T->getSizeExpr()) {
6056 Result = getDerived().RebuildDependentVectorType(
6057 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
6058 if (Result.isNull())
6059 return QualType();
6060 }
6061
6062 // Result might be dependent or not.
6065 TLB.push<DependentVectorTypeLoc>(Result);
6066 NewTL.setNameLoc(TL.getNameLoc());
6067 } else {
6068 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6069 NewTL.setNameLoc(TL.getNameLoc());
6070 }
6071
6072 return Result;
6073}
6074
6075template<typename Derived>
6077 TypeLocBuilder &TLB,
6079 const DependentSizedExtVectorType *T = TL.getTypePtr();
6080
6081 // FIXME: ext vector locs should be nested
6082 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6083 if (ElementType.isNull())
6084 return QualType();
6085
6086 // Vector sizes are constant expressions.
6089
6090 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6091 Size = SemaRef.ActOnConstantExpression(Size);
6092 if (Size.isInvalid())
6093 return QualType();
6094
6095 QualType Result = TL.getType();
6096 if (getDerived().AlwaysRebuild() ||
6097 ElementType != T->getElementType() ||
6098 Size.get() != T->getSizeExpr()) {
6099 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
6100 Size.get(),
6101 T->getAttributeLoc());
6102 if (Result.isNull())
6103 return QualType();
6104 }
6105
6106 // Result might be dependent or not.
6110 NewTL.setNameLoc(TL.getNameLoc());
6111 } else {
6112 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6113 NewTL.setNameLoc(TL.getNameLoc());
6114 }
6115
6116 return Result;
6117}
6118
6119template <typename Derived>
6123 const ConstantMatrixType *T = TL.getTypePtr();
6124 QualType ElementType = getDerived().TransformType(T->getElementType());
6125 if (ElementType.isNull())
6126 return QualType();
6127
6128 QualType Result = TL.getType();
6129 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
6130 Result = getDerived().RebuildConstantMatrixType(
6131 ElementType, T->getNumRows(), T->getNumColumns());
6132 if (Result.isNull())
6133 return QualType();
6134 }
6135
6137 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6138 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6139 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
6140 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
6141
6142 return Result;
6143}
6144
6145template <typename Derived>
6148 const DependentSizedMatrixType *T = TL.getTypePtr();
6149
6150 QualType ElementType = getDerived().TransformType(T->getElementType());
6151 if (ElementType.isNull()) {
6152 return QualType();
6153 }
6154
6155 // Matrix dimensions are constant expressions.
6158
6159 Expr *origRows = TL.getAttrRowOperand();
6160 if (!origRows)
6161 origRows = T->getRowExpr();
6162 Expr *origColumns = TL.getAttrColumnOperand();
6163 if (!origColumns)
6164 origColumns = T->getColumnExpr();
6165
6166 ExprResult rowResult = getDerived().TransformExpr(origRows);
6167 rowResult = SemaRef.ActOnConstantExpression(rowResult);
6168 if (rowResult.isInvalid())
6169 return QualType();
6170
6171 ExprResult columnResult = getDerived().TransformExpr(origColumns);
6172 columnResult = SemaRef.ActOnConstantExpression(columnResult);
6173 if (columnResult.isInvalid())
6174 return QualType();
6175
6176 Expr *rows = rowResult.get();
6177 Expr *columns = columnResult.get();
6178
6179 QualType Result = TL.getType();
6180 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6181 rows != origRows || columns != origColumns) {
6182 Result = getDerived().RebuildDependentSizedMatrixType(
6183 ElementType, rows, columns, T->getAttributeLoc());
6184
6185 if (Result.isNull())
6186 return QualType();
6187 }
6188
6189 // We might have any sort of matrix type now, but fortunately they
6190 // all have the same location layout.
6191 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
6192 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6193 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6194 NewTL.setAttrRowOperand(rows);
6195 NewTL.setAttrColumnOperand(columns);
6196 return Result;
6197}
6198
6199template <typename Derived>
6202 const DependentAddressSpaceType *T = TL.getTypePtr();
6203
6204 QualType pointeeType =
6205 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
6206
6207 if (pointeeType.isNull())
6208 return QualType();
6209
6210 // Address spaces are constant expressions.
6213
6214 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
6215 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
6216 if (AddrSpace.isInvalid())
6217 return QualType();
6218
6219 QualType Result = TL.getType();
6220 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
6221 AddrSpace.get() != T->getAddrSpaceExpr()) {
6222 Result = getDerived().RebuildDependentAddressSpaceType(
6223 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6224 if (Result.isNull())
6225 return QualType();
6226 }
6227
6228 // Result might be dependent or not.
6232
6233 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6234 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6235 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6236
6237 } else {
6238 TLB.TypeWasModifiedSafely(Result);
6239 }
6240
6241 return Result;
6242}
6243
6244template <typename Derived>
6246 VectorTypeLoc TL) {
6247 const VectorType *T = TL.getTypePtr();
6248 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6249 if (ElementType.isNull())
6250 return QualType();
6251
6252 QualType Result = TL.getType();
6253 if (getDerived().AlwaysRebuild() ||
6254 ElementType != T->getElementType()) {
6255 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6256 T->getVectorKind());
6257 if (Result.isNull())
6258 return QualType();
6259 }
6260
6261 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6262 NewTL.setNameLoc(TL.getNameLoc());
6263
6264 return Result;
6265}
6266
6267template<typename Derived>
6269 ExtVectorTypeLoc TL) {
6270 const VectorType *T = TL.getTypePtr();
6271 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6272 if (ElementType.isNull())
6273 return QualType();
6274
6275 QualType Result = TL.getType();
6276 if (getDerived().AlwaysRebuild() ||
6277 ElementType != T->getElementType()) {
6278 Result = getDerived().RebuildExtVectorType(ElementType,
6279 T->getNumElements(),
6280 /*FIXME*/ SourceLocation());
6281 if (Result.isNull())
6282 return QualType();
6283 }
6284
6285 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6286 NewTL.setNameLoc(TL.getNameLoc());
6287
6288 return Result;
6289}
6290
6291template <typename Derived>
6293 ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions,
6294 bool ExpectParameterPack) {
6295 TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
6296 TypeSourceInfo *NewTSI = nullptr;
6297
6298 if (NumExpansions && isa<PackExpansionType>(OldTSI->getType())) {
6299 // If we're substituting into a pack expansion type and we know the
6300 // length we want to expand to, just substitute for the pattern.
6301 TypeLoc OldTL = OldTSI->getTypeLoc();
6302 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6303
6304 TypeLocBuilder TLB;
6305 TypeLoc NewTL = OldTSI->getTypeLoc();
6306 TLB.reserve(NewTL.getFullDataSize());
6307
6308 QualType Result = getDerived().TransformType(TLB,
6309 OldExpansionTL.getPatternLoc());
6310 if (Result.isNull())
6311 return nullptr;
6312
6314 OldExpansionTL.getPatternLoc().getSourceRange(),
6315 OldExpansionTL.getEllipsisLoc(),
6316 NumExpansions);
6317 if (Result.isNull())
6318 return nullptr;
6319
6320 PackExpansionTypeLoc NewExpansionTL
6321 = TLB.push<PackExpansionTypeLoc>(Result);
6322 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6323 NewTSI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6324 } else
6325 NewTSI = getDerived().TransformType(OldTSI);
6326 if (!NewTSI)
6327 return nullptr;
6328
6329 if (NewTSI == OldTSI && indexAdjustment == 0)
6330 return OldParm;
6331
6333 SemaRef.Context, OldParm->getDeclContext(), OldParm->getInnerLocStart(),
6334 OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
6335 NewTSI, OldParm->getStorageClass(),
6336 /* DefArg */ nullptr);
6337 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6338 OldParm->getFunctionScopeIndex() + indexAdjustment);
6339 getDerived().transformedLocalDecl(OldParm, {newParm});
6340 return newParm;
6341}
6342
6343template <typename Derived>
6346 const QualType *ParamTypes,
6347 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6348 SmallVectorImpl<QualType> &OutParamTypes,
6351 unsigned *LastParamTransformed) {
6352 int indexAdjustment = 0;
6353
6354 unsigned NumParams = Params.size();
6355 for (unsigned i = 0; i != NumParams; ++i) {
6356 if (LastParamTransformed)
6357 *LastParamTransformed = i;
6358 if (ParmVarDecl *OldParm = Params[i]) {
6359 assert(OldParm->getFunctionScopeIndex() == i);
6360
6361 UnsignedOrNone NumExpansions = std::nullopt;
6362 ParmVarDecl *NewParm = nullptr;
6363 if (OldParm->isParameterPack()) {
6364 // We have a function parameter pack that may need to be expanded.
6366
6367 // Find the parameter packs that could be expanded.
6368 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6370 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6371 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6372
6373 // Determine whether we should expand the parameter packs.
6374 bool ShouldExpand = false;
6375 bool RetainExpansion = false;
6376 UnsignedOrNone OrigNumExpansions = std::nullopt;
6377 if (Unexpanded.size() > 0) {
6378 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6379 NumExpansions = OrigNumExpansions;
6381 ExpansionTL.getEllipsisLoc(), Pattern.getSourceRange(),
6382 Unexpanded, /*FailOnPackProducingTemplates=*/true,
6383 ShouldExpand, RetainExpansion, NumExpansions)) {
6384 return true;
6385 }
6386 } else {
6387#ifndef NDEBUG
6388 const AutoType *AT =
6389 Pattern.getType().getTypePtr()->getContainedAutoType();
6390 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6391 "Could not find parameter packs or undeduced auto type!");
6392#endif
6393 }
6394
6395 if (ShouldExpand) {
6396 // Expand the function parameter pack into multiple, separate
6397 // parameters.
6398 getDerived().ExpandingFunctionParameterPack(OldParm);
6399 for (unsigned I = 0; I != *NumExpansions; ++I) {
6400 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6401 ParmVarDecl *NewParm
6402 = getDerived().TransformFunctionTypeParam(OldParm,
6403 indexAdjustment++,
6404 OrigNumExpansions,
6405 /*ExpectParameterPack=*/false);
6406 if (!NewParm)
6407 return true;
6408
6409 if (ParamInfos)
6410 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6411 OutParamTypes.push_back(NewParm->getType());
6412 if (PVars)
6413 PVars->push_back(NewParm);
6414 }
6415
6416 // If we're supposed to retain a pack expansion, do so by temporarily
6417 // forgetting the partially-substituted parameter pack.
6418 if (RetainExpansion) {
6419 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6420 ParmVarDecl *NewParm
6421 = getDerived().TransformFunctionTypeParam(OldParm,
6422 indexAdjustment++,
6423 OrigNumExpansions,
6424 /*ExpectParameterPack=*/false);
6425 if (!NewParm)
6426 return true;
6427
6428 if (ParamInfos)
6429 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6430 OutParamTypes.push_back(NewParm->getType());
6431 if (PVars)
6432 PVars->push_back(NewParm);
6433 }
6434
6435 // The next parameter should have the same adjustment as the
6436 // last thing we pushed, but we post-incremented indexAdjustment
6437 // on every push. Also, if we push nothing, the adjustment should
6438 // go down by one.
6439 indexAdjustment--;
6440
6441 // We're done with the pack expansion.
6442 continue;
6443 }
6444
6445 // We'll substitute the parameter now without expanding the pack
6446 // expansion.
6447 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6448 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6449 indexAdjustment,
6450 NumExpansions,
6451 /*ExpectParameterPack=*/true);
6452 assert(NewParm->isParameterPack() &&
6453 "Parameter pack no longer a parameter pack after "
6454 "transformation.");
6455 } else {
6456 NewParm = getDerived().TransformFunctionTypeParam(
6457 OldParm, indexAdjustment, std::nullopt,
6458 /*ExpectParameterPack=*/false);
6459 }
6460
6461 if (!NewParm)
6462 return true;
6463
6464 if (ParamInfos)
6465 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6466 OutParamTypes.push_back(NewParm->getType());
6467 if (PVars)
6468 PVars->push_back(NewParm);
6469 continue;
6470 }
6471
6472 // Deal with the possibility that we don't have a parameter
6473 // declaration for this parameter.
6474 assert(ParamTypes);
6475 QualType OldType = ParamTypes[i];
6476 bool IsPackExpansion = false;
6477 UnsignedOrNone NumExpansions = std::nullopt;
6478 QualType NewType;
6479 if (const PackExpansionType *Expansion
6480 = dyn_cast<PackExpansionType>(OldType)) {
6481 // We have a function parameter pack that may need to be expanded.
6482 QualType Pattern = Expansion->getPattern();
6484 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6485
6486 // Determine whether we should expand the parameter packs.
6487 bool ShouldExpand = false;
6488 bool RetainExpansion = false;
6490 Loc, SourceRange(), Unexpanded,
6491 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
6492 RetainExpansion, NumExpansions)) {
6493 return true;
6494 }
6495
6496 if (ShouldExpand) {
6497 // Expand the function parameter pack into multiple, separate
6498 // parameters.
6499 for (unsigned I = 0; I != *NumExpansions; ++I) {
6500 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6501 QualType NewType = getDerived().TransformType(Pattern);
6502 if (NewType.isNull())
6503 return true;
6504
6505 if (NewType->containsUnexpandedParameterPack()) {
6506 NewType = getSema().getASTContext().getPackExpansionType(
6507 NewType, std::nullopt);
6508
6509 if (NewType.isNull())
6510 return true;
6511 }
6512
6513 if (ParamInfos)
6514 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6515 OutParamTypes.push_back(NewType);
6516 if (PVars)
6517 PVars->push_back(nullptr);
6518 }
6519
6520 // We're done with the pack expansion.
6521 continue;
6522 }
6523
6524 // If we're supposed to retain a pack expansion, do so by temporarily
6525 // forgetting the partially-substituted parameter pack.
6526 if (RetainExpansion) {
6527 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6528 QualType NewType = getDerived().TransformType(Pattern);
6529 if (NewType.isNull())
6530 return true;
6531
6532 if (ParamInfos)
6533 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6534 OutParamTypes.push_back(NewType);
6535 if (PVars)
6536 PVars->push_back(nullptr);
6537 }
6538
6539 // We'll substitute the parameter now without expanding the pack
6540 // expansion.
6541 OldType = Expansion->getPattern();
6542 IsPackExpansion = true;
6543 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6544 NewType = getDerived().TransformType(OldType);
6545 } else {
6546 NewType = getDerived().TransformType(OldType);
6547 }
6548
6549 if (NewType.isNull())
6550 return true;
6551
6552 if (IsPackExpansion)
6553 NewType = getSema().Context.getPackExpansionType(NewType,
6554 NumExpansions);
6555
6556 if (ParamInfos)
6557 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6558 OutParamTypes.push_back(NewType);
6559 if (PVars)
6560 PVars->push_back(nullptr);
6561 }
6562
6563#ifndef NDEBUG
6564 if (PVars) {
6565 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6566 if (ParmVarDecl *parm = (*PVars)[i])
6567 assert(parm->getFunctionScopeIndex() == i);
6568 }
6569#endif
6570
6571 return false;
6572}
6573
6574template<typename Derived>
6578 SmallVector<QualType, 4> ExceptionStorage;
6579 return getDerived().TransformFunctionProtoType(
6580 TLB, TL, nullptr, Qualifiers(),
6581 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6582 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6583 ExceptionStorage, Changed);
6584 });
6585}
6586
6587template<typename Derived> template<typename Fn>
6589 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6590 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6591
6592 // Transform the parameters and return type.
6593 //
6594 // We are required to instantiate the params and return type in source order.
6595 // When the function has a trailing return type, we instantiate the
6596 // parameters before the return type, since the return type can then refer
6597 // to the parameters themselves (via decltype, sizeof, etc.).
6598 //
6599 SmallVector<QualType, 4> ParamTypes;
6601 Sema::ExtParameterInfoBuilder ExtParamInfos;
6602 const FunctionProtoType *T = TL.getTypePtr();
6603
6604 QualType ResultType;
6605
6606 if (T->hasTrailingReturn()) {
6608 TL.getBeginLoc(), TL.getParams(),
6610 T->getExtParameterInfosOrNull(),
6611 ParamTypes, &ParamDecls, ExtParamInfos))
6612 return QualType();
6613
6614 {
6615 // C++11 [expr.prim.general]p3:
6616 // If a declaration declares a member function or member function
6617 // template of a class X, the expression this is a prvalue of type
6618 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6619 // and the end of the function-definition, member-declarator, or
6620 // declarator.
6621 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6622 Sema::CXXThisScopeRAII ThisScope(
6623 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6624
6625 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6626 if (ResultType.isNull())
6627 return QualType();
6628 }
6629 }
6630 else {
6631 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6632 if (ResultType.isNull())
6633 return QualType();
6634
6636 TL.getBeginLoc(), TL.getParams(),
6638 T->getExtParameterInfosOrNull(),
6639 ParamTypes, &ParamDecls, ExtParamInfos))
6640 return QualType();
6641 }
6642
6643 FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
6644
6645 bool EPIChanged = false;
6646 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6647 return QualType();
6648
6649 // Handle extended parameter information.
6650 if (auto NewExtParamInfos =
6651 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6652 if (!EPI.ExtParameterInfos ||
6654 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6655 EPIChanged = true;
6656 }
6657 EPI.ExtParameterInfos = NewExtParamInfos;
6658 } else if (EPI.ExtParameterInfos) {
6659 EPIChanged = true;
6660 EPI.ExtParameterInfos = nullptr;
6661 }
6662
6663 // Transform any function effects with unevaluated conditions.
6664 // Hold this set in a local for the rest of this function, since EPI
6665 // may need to hold a FunctionEffectsRef pointing into it.
6666 std::optional<FunctionEffectSet> NewFX;
6667 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6668 NewFX.emplace();
6671
6672 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6673 FunctionEffectWithCondition NewEC = PrevEC;
6674 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6675 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6676 if (NewExpr.isInvalid())
6677 return QualType();
6678 std::optional<FunctionEffectMode> Mode =
6679 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6680 if (!Mode)
6681 return QualType();
6682
6683 // The condition expression has been transformed, and re-evaluated.
6684 // It may or may not have become constant.
6685 switch (*Mode) {
6687 NewEC.Cond = {};
6688 break;
6690 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6691 NewEC.Cond = {};
6692 break;
6694 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6695 break;
6697 llvm_unreachable(
6698 "FunctionEffectMode::None shouldn't be possible here");
6699 }
6700 }
6701 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6702 TL.getBeginLoc())) {
6704 NewFX->insert(NewEC, Errs);
6705 assert(Errs.empty());
6706 }
6707 }
6708 EPI.FunctionEffects = *NewFX;
6709 EPIChanged = true;
6710 }
6711
6712 QualType Result = TL.getType();
6713 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6714 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6715 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6716 if (Result.isNull())
6717 return QualType();
6718 }
6719
6722 NewTL.setLParenLoc(TL.getLParenLoc());
6723 NewTL.setRParenLoc(TL.getRParenLoc());
6726 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6727 NewTL.setParam(i, ParamDecls[i]);
6728
6729 return Result;
6730}
6731
6732template<typename Derived>
6735 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6736 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6737
6738 // Instantiate a dynamic noexcept expression, if any.
6739 if (isComputedNoexcept(ESI.Type)) {
6740 // Update this scrope because ContextDecl in Sema will be used in
6741 // TransformExpr.
6742 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6743 Sema::CXXThisScopeRAII ThisScope(
6744 SemaRef, Method ? Method->getParent() : nullptr,
6745 Method ? Method->getMethodQualifiers() : Qualifiers{},
6746 Method != nullptr);
6749 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6750 if (NoexceptExpr.isInvalid())
6751 return true;
6752
6754 NoexceptExpr =
6755 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6756 if (NoexceptExpr.isInvalid())
6757 return true;
6758
6759 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6760 Changed = true;
6761 ESI.NoexceptExpr = NoexceptExpr.get();
6762 ESI.Type = EST;
6763 }
6764
6765 if (ESI.Type != EST_Dynamic)
6766 return false;
6767
6768 // Instantiate a dynamic exception specification's type.
6769 for (QualType T : ESI.Exceptions) {
6770 if (const PackExpansionType *PackExpansion =
6771 T->getAs<PackExpansionType>()) {
6772 Changed = true;
6773
6774 // We have a pack expansion. Instantiate it.
6776 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6777 Unexpanded);
6778 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6779
6780 // Determine whether the set of unexpanded parameter packs can and
6781 // should
6782 // be expanded.
6783 bool Expand = false;
6784 bool RetainExpansion = false;
6785 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
6786 // FIXME: Track the location of the ellipsis (and track source location
6787 // information for the types in the exception specification in general).
6789 Loc, SourceRange(), Unexpanded,
6790 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
6791 NumExpansions))
6792 return true;
6793
6794 if (!Expand) {
6795 // We can't expand this pack expansion into separate arguments yet;
6796 // just substitute into the pattern and create a new pack expansion
6797 // type.
6798 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6799 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6800 if (U.isNull())
6801 return true;
6802
6803 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6804 Exceptions.push_back(U);
6805 continue;
6806 }
6807
6808 // Substitute into the pack expansion pattern for each slice of the
6809 // pack.
6810 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6811 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
6812
6813 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6814 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6815 return true;
6816
6817 Exceptions.push_back(U);
6818 }
6819 } else {
6820 QualType U = getDerived().TransformType(T);
6821 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6822 return true;
6823 if (T != U)
6824 Changed = true;
6825
6826 Exceptions.push_back(U);
6827 }
6828 }
6829
6830 ESI.Exceptions = Exceptions;
6831 if (ESI.Exceptions.empty())
6832 ESI.Type = EST_DynamicNone;
6833 return false;
6834}
6835
6836template<typename Derived>
6838 TypeLocBuilder &TLB,
6840 const FunctionNoProtoType *T = TL.getTypePtr();
6841 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6842 if (ResultType.isNull())
6843 return QualType();
6844
6845 QualType Result = TL.getType();
6846 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6847 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6848
6851 NewTL.setLParenLoc(TL.getLParenLoc());
6852 NewTL.setRParenLoc(TL.getRParenLoc());
6854
6855 return Result;
6856}
6857
6858template <typename Derived>
6859QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6860 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6861
6862 const UnresolvedUsingType *T = TL.getTypePtr();
6863 bool Changed = false;
6864
6865 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6866 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6867 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6868 if (!QualifierLoc)
6869 return QualType();
6870 Changed |= QualifierLoc != OldQualifierLoc;
6871 }
6872
6873 auto *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6874 if (!D)
6875 return QualType();
6876 Changed |= D != T->getDecl();
6877
6878 QualType Result = TL.getType();
6879 if (getDerived().AlwaysRebuild() || Changed) {
6880 Result = getDerived().RebuildUnresolvedUsingType(
6881 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TL.getNameLoc(),
6882 D);
6883 if (Result.isNull())
6884 return QualType();
6885 }
6886
6888 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6889 QualifierLoc, TL.getNameLoc());
6890 else
6891 TLB.push<UnresolvedUsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6892 QualifierLoc, TL.getNameLoc());
6893 return Result;
6894}
6895
6896template <typename Derived>
6898 UsingTypeLoc TL) {
6899 const UsingType *T = TL.getTypePtr();
6900 bool Changed = false;
6901
6902 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6903 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6904 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6905 if (!QualifierLoc)
6906 return QualType();
6907 Changed |= QualifierLoc != OldQualifierLoc;
6908 }
6909
6910 auto *D = cast_or_null<UsingShadowDecl>(
6911 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6912 if (!D)
6913 return QualType();
6914 Changed |= D != T->getDecl();
6915
6916 QualType UnderlyingType = getDerived().TransformType(T->desugar());
6917 if (UnderlyingType.isNull())
6918 return QualType();
6919 Changed |= UnderlyingType != T->desugar();
6920
6921 QualType Result = TL.getType();
6922 if (getDerived().AlwaysRebuild() || Changed) {
6923 Result = getDerived().RebuildUsingType(
6924 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), D,
6925 UnderlyingType);
6926 if (Result.isNull())
6927 return QualType();
6928 }
6929 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(), QualifierLoc,
6930 TL.getNameLoc());
6931 return Result;
6932}
6933
6934template<typename Derived>
6936 TypedefTypeLoc TL) {
6937 const TypedefType *T = TL.getTypePtr();
6938 bool Changed = false;
6939
6940 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6941 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6942 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6943 if (!QualifierLoc)
6944 return QualType();
6945 Changed |= QualifierLoc != OldQualifierLoc;
6946 }
6947
6948 auto *Typedef = cast_or_null<TypedefNameDecl>(
6949 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6950 if (!Typedef)
6951 return QualType();
6952 Changed |= Typedef != T->getDecl();
6953
6954 // FIXME: Transform the UnderlyingType if different from decl.
6955
6956 QualType Result = TL.getType();
6957 if (getDerived().AlwaysRebuild() || Changed) {
6958 Result = getDerived().RebuildTypedefType(
6959 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), Typedef);
6960 if (Result.isNull())
6961 return QualType();
6962 }
6963
6964 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6965 QualifierLoc, TL.getNameLoc());
6966 return Result;
6967}
6968
6969template<typename Derived>
6971 TypeOfExprTypeLoc TL) {
6972 // typeof expressions are not potentially evaluated contexts
6976
6977 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
6978 if (E.isInvalid())
6979 return QualType();
6980
6981 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
6982 if (E.isInvalid())
6983 return QualType();
6984
6985 QualType Result = TL.getType();
6987 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
6988 Result =
6989 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
6990 if (Result.isNull())
6991 return QualType();
6992 }
6993
6994 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
6995 NewTL.setTypeofLoc(TL.getTypeofLoc());
6996 NewTL.setLParenLoc(TL.getLParenLoc());
6997 NewTL.setRParenLoc(TL.getRParenLoc());
6998
6999 return Result;
7000}
7001
7002template<typename Derived>
7004 TypeOfTypeLoc TL) {
7005 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
7006 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
7007 if (!New_Under_TI)
7008 return QualType();
7009
7010 QualType Result = TL.getType();
7011 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
7012 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
7013 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
7014 if (Result.isNull())
7015 return QualType();
7016 }
7017
7018 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
7019 NewTL.setTypeofLoc(TL.getTypeofLoc());
7020 NewTL.setLParenLoc(TL.getLParenLoc());
7021 NewTL.setRParenLoc(TL.getRParenLoc());
7022 NewTL.setUnmodifiedTInfo(New_Under_TI);
7023
7024 return Result;
7025}
7026
7027template<typename Derived>
7029 DecltypeTypeLoc TL) {
7030 const DecltypeType *T = TL.getTypePtr();
7031
7032 // decltype expressions are not potentially evaluated contexts
7036
7037 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
7038 if (E.isInvalid())
7039 return QualType();
7040
7041 E = getSema().ActOnDecltypeExpression(E.get());
7042 if (E.isInvalid())
7043 return QualType();
7044
7045 QualType Result = TL.getType();
7046 if (getDerived().AlwaysRebuild() ||
7047 E.get() != T->getUnderlyingExpr()) {
7048 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
7049 if (Result.isNull())
7050 return QualType();
7051 }
7052 else E.get();
7053
7054 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
7055 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
7056 NewTL.setRParenLoc(TL.getRParenLoc());
7057 return Result;
7058}
7059
7060template <typename Derived>
7064 // Transform the index
7065 ExprResult IndexExpr;
7066 {
7067 EnterExpressionEvaluationContext ConstantContext(
7069
7070 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
7071 if (IndexExpr.isInvalid())
7072 return QualType();
7073 }
7074 QualType Pattern = TL.getPattern();
7075
7076 const PackIndexingType *PIT = TL.getTypePtr();
7077 SmallVector<QualType, 5> SubtitutedTypes;
7078 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
7079
7080 bool NotYetExpanded = Types.empty();
7081 bool FullySubstituted = true;
7082
7083 if (Types.empty() && !PIT->expandsToEmptyPack())
7084 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
7085
7086 for (QualType T : Types) {
7087 if (!T->containsUnexpandedParameterPack()) {
7088 QualType Transformed = getDerived().TransformType(T);
7089 if (Transformed.isNull())
7090 return QualType();
7091 SubtitutedTypes.push_back(Transformed);
7092 continue;
7093 }
7094
7096 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
7097 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7098 // Determine whether the set of unexpanded parameter packs can and should
7099 // be expanded.
7100 bool ShouldExpand = true;
7101 bool RetainExpansion = false;
7102 UnsignedOrNone NumExpansions = std::nullopt;
7103 if (getDerived().TryExpandParameterPacks(
7104 TL.getEllipsisLoc(), SourceRange(), Unexpanded,
7105 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
7106 RetainExpansion, NumExpansions))
7107 return QualType();
7108 if (!ShouldExpand) {
7109 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7110 // FIXME: should we keep TypeLoc for individual expansions in
7111 // PackIndexingTypeLoc?
7112 TypeSourceInfo *TI =
7113 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
7114 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
7115 if (Pack.isNull())
7116 return QualType();
7117 if (NotYetExpanded) {
7118 FullySubstituted = false;
7119 QualType Out = getDerived().RebuildPackIndexingType(
7120 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7121 FullySubstituted);
7122 if (Out.isNull())
7123 return QualType();
7124
7126 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7127 return Out;
7128 }
7129 SubtitutedTypes.push_back(Pack);
7130 continue;
7131 }
7132 for (unsigned I = 0; I != *NumExpansions; ++I) {
7133 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
7134 QualType Out = getDerived().TransformType(T);
7135 if (Out.isNull())
7136 return QualType();
7137 SubtitutedTypes.push_back(Out);
7138 FullySubstituted &= !Out->containsUnexpandedParameterPack();
7139 }
7140 // If we're supposed to retain a pack expansion, do so by temporarily
7141 // forgetting the partially-substituted parameter pack.
7142 if (RetainExpansion) {
7143 FullySubstituted = false;
7144 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
7145 QualType Out = getDerived().TransformType(T);
7146 if (Out.isNull())
7147 return QualType();
7148 SubtitutedTypes.push_back(Out);
7149 }
7150 }
7151
7152 // A pack indexing type can appear in a larger pack expansion,
7153 // e.g. `Pack...[pack_of_indexes]...`
7154 // so we need to temporarily disable substitution of pack elements
7155 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7156 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
7157
7158 QualType Out = getDerived().RebuildPackIndexingType(
7159 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7160 FullySubstituted, SubtitutedTypes);
7161 if (Out.isNull())
7162 return Out;
7163
7165 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7166 return Out;
7167}
7168
7169template<typename Derived>
7171 TypeLocBuilder &TLB,
7173 QualType Result = TL.getType();
7174 TypeSourceInfo *NewBaseTSI = TL.getUnderlyingTInfo();
7175 if (Result->isDependentType()) {
7176 const UnaryTransformType *T = TL.getTypePtr();
7177
7178 NewBaseTSI = getDerived().TransformType(TL.getUnderlyingTInfo());
7179 if (!NewBaseTSI)
7180 return QualType();
7181 QualType NewBase = NewBaseTSI->getType();
7182
7183 Result = getDerived().RebuildUnaryTransformType(NewBase,
7184 T->getUTTKind(),
7185 TL.getKWLoc());
7186 if (Result.isNull())
7187 return QualType();
7188 }
7189
7191 NewTL.setKWLoc(TL.getKWLoc());
7192 NewTL.setParensRange(TL.getParensRange());
7193 NewTL.setUnderlyingTInfo(NewBaseTSI);
7194 return Result;
7195}
7196
7197template<typename Derived>
7200 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
7201
7202 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7203 TemplateName TemplateName = getDerived().TransformTemplateName(
7204 QualifierLoc, /*TemplateKELoc=*/SourceLocation(), T->getTemplateName(),
7205 TL.getTemplateNameLoc());
7206 if (TemplateName.isNull())
7207 return QualType();
7208
7209 QualType OldDeduced = T->getDeducedType();
7210 QualType NewDeduced;
7211 if (!OldDeduced.isNull()) {
7212 NewDeduced = getDerived().TransformType(OldDeduced);
7213 if (NewDeduced.isNull())
7214 return QualType();
7215 }
7216
7217 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
7218 T->getKeyword(), TemplateName, NewDeduced);
7219 if (Result.isNull())
7220 return QualType();
7221
7222 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7223 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7224 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7225 NewTL.setQualifierLoc(QualifierLoc);
7226 return Result;
7227}
7228
7229template <typename Derived>
7231 TagTypeLoc TL) {
7232 const TagType *T = TL.getTypePtr();
7233
7234 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7235 if (QualifierLoc) {
7236 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7237 if (!QualifierLoc)
7238 return QualType();
7239 }
7240
7241 auto *TD = cast_or_null<TagDecl>(
7242 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7243 if (!TD)
7244 return QualType();
7245
7246 QualType Result = TL.getType();
7247 if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() ||
7248 TD != T->getDecl()) {
7249 if (T->isCanonicalUnqualified())
7250 Result = getDerived().RebuildCanonicalTagType(TD);
7251 else
7252 Result = getDerived().RebuildTagType(
7253 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TD);
7254 if (Result.isNull())
7255 return QualType();
7256 }
7257
7258 TagTypeLoc NewTL = TLB.push<TagTypeLoc>(Result);
7260 NewTL.setQualifierLoc(QualifierLoc);
7261 NewTL.setNameLoc(TL.getNameLoc());
7262
7263 return Result;
7264}
7265
7266template <typename Derived>
7268 EnumTypeLoc TL) {
7269 return getDerived().TransformTagType(TLB, TL);
7270}
7271
7272template <typename Derived>
7273QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
7274 RecordTypeLoc TL) {
7275 return getDerived().TransformTagType(TLB, TL);
7276}
7277
7278template<typename Derived>
7280 TypeLocBuilder &TLB,
7282 return getDerived().TransformTagType(TLB, TL);
7283}
7284
7285template<typename Derived>
7287 TypeLocBuilder &TLB,
7289 return getDerived().TransformTemplateTypeParmType(
7290 TLB, TL,
7291 /*SuppressObjCLifetime=*/false);
7292}
7293
7294template <typename Derived>
7296 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7297 return TransformTypeSpecType(TLB, TL);
7298}
7299
7300template<typename Derived>
7301QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7302 TypeLocBuilder &TLB,
7303 SubstTemplateTypeParmTypeLoc TL) {
7304 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7305
7306 Decl *NewReplaced =
7307 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7308
7309 // Substitute into the replacement type, which itself might involve something
7310 // that needs to be transformed. This only tends to occur with default
7311 // template arguments of template template parameters.
7312 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7313 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7314 if (Replacement.isNull())
7315 return QualType();
7316
7317 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7318 Replacement, NewReplaced, T->getIndex(), T->getPackIndex(),
7319 T->getFinal());
7320
7321 // Propagate type-source information.
7322 SubstTemplateTypeParmTypeLoc NewTL
7323 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7324 NewTL.setNameLoc(TL.getNameLoc());
7325 return Result;
7326
7327}
7328template <typename Derived>
7331 return TransformTypeSpecType(TLB, TL);
7332}
7333
7334template<typename Derived>
7336 TypeLocBuilder &TLB,
7338 return getDerived().TransformSubstTemplateTypeParmPackType(
7339 TLB, TL, /*SuppressObjCLifetime=*/false);
7340}
7341
7342template <typename Derived>
7345 return TransformTypeSpecType(TLB, TL);
7346}
7347
7348template<typename Derived>
7349QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
7350 AtomicTypeLoc TL) {
7351 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7352 if (ValueType.isNull())
7353 return QualType();
7354
7355 QualType Result = TL.getType();
7356 if (getDerived().AlwaysRebuild() ||
7357 ValueType != TL.getValueLoc().getType()) {
7358 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7359 if (Result.isNull())
7360 return QualType();
7361 }
7362
7363 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7364 NewTL.setKWLoc(TL.getKWLoc());
7365 NewTL.setLParenLoc(TL.getLParenLoc());
7366 NewTL.setRParenLoc(TL.getRParenLoc());
7367
7368 return Result;
7369}
7370
7371template <typename Derived>
7373 PipeTypeLoc TL) {
7374 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7375 if (ValueType.isNull())
7376 return QualType();
7377
7378 QualType Result = TL.getType();
7379 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7380 const PipeType *PT = Result->castAs<PipeType>();
7381 bool isReadPipe = PT->isReadOnly();
7382 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7383 if (Result.isNull())
7384 return QualType();
7385 }
7386
7387 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7388 NewTL.setKWLoc(TL.getKWLoc());
7389
7390 return Result;
7391}
7392
7393template <typename Derived>
7395 BitIntTypeLoc TL) {
7396 const BitIntType *EIT = TL.getTypePtr();
7397 QualType Result = TL.getType();
7398
7399 if (getDerived().AlwaysRebuild()) {
7400 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7401 EIT->getNumBits(), TL.getNameLoc());
7402 if (Result.isNull())
7403 return QualType();
7404 }
7405
7406 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7407 NewTL.setNameLoc(TL.getNameLoc());
7408 return Result;
7409}
7410
7411template <typename Derived>
7414 const DependentBitIntType *EIT = TL.getTypePtr();
7415
7418 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7419 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7420
7421 if (BitsExpr.isInvalid())
7422 return QualType();
7423
7424 QualType Result = TL.getType();
7425
7426 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7427 Result = getDerived().RebuildDependentBitIntType(
7428 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7429
7430 if (Result.isNull())
7431 return QualType();
7432 }
7433
7436 NewTL.setNameLoc(TL.getNameLoc());
7437 } else {
7438 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7439 NewTL.setNameLoc(TL.getNameLoc());
7440 }
7441 return Result;
7442}
7443
7444template <typename Derived>
7447 llvm_unreachable("This type does not need to be transformed.");
7448}
7449
7450 /// Simple iterator that traverses the template arguments in a
7451 /// container that provides a \c getArgLoc() member function.
7452 ///
7453 /// This iterator is intended to be used with the iterator form of
7454 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7455 template<typename ArgLocContainer>
7457 ArgLocContainer *Container;
7458 unsigned Index;
7459
7460 public:
7463 typedef int difference_type;
7464 typedef std::input_iterator_tag iterator_category;
7465
7466 class pointer {
7468
7469 public:
7470 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7471
7473 return &Arg;
7474 }
7475 };
7476
7477
7479
7480 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7481 unsigned Index)
7482 : Container(&Container), Index(Index) { }
7483
7485 ++Index;
7486 return *this;
7487 }
7488
7491 ++(*this);
7492 return Old;
7493 }
7494
7496 return Container->getArgLoc(Index);
7497 }
7498
7500 return pointer(Container->getArgLoc(Index));
7501 }
7502
7505 return X.Container == Y.Container && X.Index == Y.Index;
7506 }
7507
7510 return !(X == Y);
7511 }
7512 };
7513
7514template<typename Derived>
7515QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7516 AutoTypeLoc TL) {
7517 const AutoType *T = TL.getTypePtr();
7518 QualType OldDeduced = T->getDeducedType();
7519 QualType NewDeduced;
7520 if (!OldDeduced.isNull()) {
7521 NewDeduced = getDerived().TransformType(OldDeduced);
7522 if (NewDeduced.isNull())
7523 return QualType();
7524 }
7525
7526 ConceptDecl *NewCD = nullptr;
7527 TemplateArgumentListInfo NewTemplateArgs;
7528 NestedNameSpecifierLoc NewNestedNameSpec;
7529 if (T->isConstrained()) {
7530 assert(TL.getConceptReference());
7531 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7532 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7533
7534 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7535 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7537 if (getDerived().TransformTemplateArguments(
7538 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7539 NewTemplateArgs))
7540 return QualType();
7541
7542 if (TL.getNestedNameSpecifierLoc()) {
7543 NewNestedNameSpec
7544 = getDerived().TransformNestedNameSpecifierLoc(
7545 TL.getNestedNameSpecifierLoc());
7546 if (!NewNestedNameSpec)
7547 return QualType();
7548 }
7549 }
7550
7551 QualType Result = TL.getType();
7552 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7553 T->isDependentType() || T->isConstrained()) {
7554 // FIXME: Maybe don't rebuild if all template arguments are the same.
7556 NewArgList.reserve(NewTemplateArgs.size());
7557 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7558 NewArgList.push_back(ArgLoc.getArgument());
7559 Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword(), NewCD,
7560 NewArgList);
7561 if (Result.isNull())
7562 return QualType();
7563 }
7564
7565 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7566 NewTL.setNameLoc(TL.getNameLoc());
7567 NewTL.setRParenLoc(TL.getRParenLoc());
7568 NewTL.setConceptReference(nullptr);
7569
7570 if (T->isConstrained()) {
7572 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7573 TL.getConceptNameLoc(),
7574 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7575 auto *CR = ConceptReference::Create(
7576 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7577 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7578 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7579 NewTL.setConceptReference(CR);
7580 }
7581
7582 return Result;
7583}
7584
7585template <typename Derived>
7588 return getDerived().TransformTemplateSpecializationType(
7589 TLB, TL, /*ObjectType=*/QualType(), /*FirstQualifierInScope=*/nullptr,
7590 /*AllowInjectedClassName=*/false);
7591}
7592
7593template <typename Derived>
7596 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
7597 const TemplateSpecializationType *T = TL.getTypePtr();
7598
7599 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7600 TemplateName Template = getDerived().TransformTemplateName(
7601 QualifierLoc, TL.getTemplateKeywordLoc(), T->getTemplateName(),
7602 TL.getTemplateNameLoc(), ObjectType, FirstQualifierInScope,
7603 AllowInjectedClassName);
7604 if (Template.isNull())
7605 return QualType();
7606
7607 TemplateArgumentListInfo NewTemplateArgs;
7608 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7609 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7611 ArgIterator;
7612 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7613 ArgIterator(TL, TL.getNumArgs()),
7614 NewTemplateArgs))
7615 return QualType();
7616
7617 // This needs to be rebuilt if either the arguments changed, or if the
7618 // original template changed. If the template changed, and even if the
7619 // arguments didn't change, these arguments might not correspond to their
7620 // respective parameters, therefore needing conversions.
7621 QualType Result = getDerived().RebuildTemplateSpecializationType(
7622 TL.getTypePtr()->getKeyword(), Template, TL.getTemplateNameLoc(),
7623 NewTemplateArgs);
7624
7625 if (!Result.isNull()) {
7627 TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getTemplateKeywordLoc(),
7628 TL.getTemplateNameLoc(), NewTemplateArgs);
7629 }
7630
7631 return Result;
7632}
7633
7634template <typename Derived>
7636 AttributedTypeLoc TL) {
7637 const AttributedType *oldType = TL.getTypePtr();
7638 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7639 if (modifiedType.isNull())
7640 return QualType();
7641
7642 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7643 const Attr *oldAttr = TL.getAttr();
7644 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7645 if (oldAttr && !newAttr)
7646 return QualType();
7647
7648 QualType result = TL.getType();
7649
7650 // FIXME: dependent operand expressions?
7651 if (getDerived().AlwaysRebuild() ||
7652 modifiedType != oldType->getModifiedType()) {
7653 // If the equivalent type is equal to the modified type, we don't want to
7654 // transform it as well because:
7655 //
7656 // 1. The transformation would yield the same result and is therefore
7657 // superfluous, and
7658 //
7659 // 2. Transforming the same type twice can cause problems, e.g. if it
7660 // is a FunctionProtoType, we may end up instantiating the function
7661 // parameters twice, which causes an assertion since the parameters
7662 // are already bound to their counterparts in the template for this
7663 // instantiation.
7664 //
7665 QualType equivalentType = modifiedType;
7666 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7667 TypeLocBuilder AuxiliaryTLB;
7668 AuxiliaryTLB.reserve(TL.getFullDataSize());
7669 equivalentType =
7670 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7671 if (equivalentType.isNull())
7672 return QualType();
7673 }
7674
7675 // Check whether we can add nullability; it is only represented as
7676 // type sugar, and therefore cannot be diagnosed in any other way.
7677 if (auto nullability = oldType->getImmediateNullability()) {
7678 if (!modifiedType->canHaveNullability()) {
7679 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7680 : TL.getModifiedLoc().getBeginLoc()),
7681 diag::err_nullability_nonpointer)
7682 << DiagNullabilityKind(*nullability, false) << modifiedType;
7683 return QualType();
7684 }
7685 }
7686
7687 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7688 modifiedType,
7689 equivalentType,
7690 TL.getAttr());
7691 }
7692
7693 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7694 newTL.setAttr(newAttr);
7695 return result;
7696}
7697
7698template <typename Derived>
7701 const CountAttributedType *OldTy = TL.getTypePtr();
7702 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7703 if (InnerTy.isNull())
7704 return QualType();
7705
7706 Expr *OldCount = TL.getCountExpr();
7707 Expr *NewCount = nullptr;
7708 if (OldCount) {
7709 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7710 if (CountResult.isInvalid())
7711 return QualType();
7712 NewCount = CountResult.get();
7713 }
7714
7715 QualType Result = TL.getType();
7716 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7717 OldCount != NewCount) {
7718 // Currently, CountAttributedType can only wrap incomplete array types.
7720 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7721 }
7722
7723 TLB.push<CountAttributedTypeLoc>(Result);
7724 return Result;
7725}
7726
7727template <typename Derived>
7730 // The BTFTagAttributedType is available for C only.
7731 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7732}
7733
7734template <typename Derived>
7737
7738 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7739
7740 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7741 if (WrappedTy.isNull())
7742 return QualType();
7743
7744 QualType ContainedTy = QualType();
7745 QualType OldContainedTy = oldType->getContainedType();
7746 if (!OldContainedTy.isNull()) {
7747 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7748 if (!oldContainedTSI)
7749 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7750 OldContainedTy, SourceLocation());
7751 TypeSourceInfo *ContainedTSI = getDerived().TransformType(oldContainedTSI);
7752 if (!ContainedTSI)
7753 return QualType();
7754 ContainedTy = ContainedTSI->getType();
7755 }
7756
7757 QualType Result = TL.getType();
7758 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7759 ContainedTy != oldType->getContainedType()) {
7761 WrappedTy, ContainedTy, oldType->getAttrs());
7762 }
7763
7765 return Result;
7766}
7767
7768template <typename Derived>
7771 // No transformations needed.
7772 return TL.getType();
7773}
7774
7775template<typename Derived>
7778 ParenTypeLoc TL) {
7779 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7780 if (Inner.isNull())
7781 return QualType();
7782
7783 QualType Result = TL.getType();
7784 if (getDerived().AlwaysRebuild() ||
7785 Inner != TL.getInnerLoc().getType()) {
7786 Result = getDerived().RebuildParenType(Inner);
7787 if (Result.isNull())
7788 return QualType();
7789 }
7790
7791 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7792 NewTL.setLParenLoc(TL.getLParenLoc());
7793 NewTL.setRParenLoc(TL.getRParenLoc());
7794 return Result;
7795}
7796
7797template <typename Derived>
7801 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7802 if (Inner.isNull())
7803 return QualType();
7804
7805 QualType Result = TL.getType();
7806 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7807 Result =
7808 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7809 if (Result.isNull())
7810 return QualType();
7811 }
7812
7814 NewTL.setExpansionLoc(TL.getExpansionLoc());
7815 return Result;
7816}
7817
7818template<typename Derived>
7819QualType TreeTransform<Derived>::TransformDependentNameType(
7821 return TransformDependentNameType(TLB, TL, false);
7822}
7823
7824template <typename Derived>
7825QualType TreeTransform<Derived>::TransformDependentNameType(
7826 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext,
7827 QualType ObjectType, NamedDecl *UnqualLookup) {
7828 const DependentNameType *T = TL.getTypePtr();
7829
7830 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7831 if (QualifierLoc) {
7832 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
7833 QualifierLoc, ObjectType, UnqualLookup);
7834 if (!QualifierLoc)
7835 return QualType();
7836 } else {
7837 assert((ObjectType.isNull() && !UnqualLookup) &&
7838 "must be transformed by TransformNestedNameSpecifierLoc");
7839 }
7840
7842 = getDerived().RebuildDependentNameType(T->getKeyword(),
7843 TL.getElaboratedKeywordLoc(),
7844 QualifierLoc,
7845 T->getIdentifier(),
7846 TL.getNameLoc(),
7847 DeducedTSTContext);
7848 if (Result.isNull())
7849 return QualType();
7850
7851 if (isa<TagType>(Result)) {
7852 auto NewTL = TLB.push<TagTypeLoc>(Result);
7853 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7854 NewTL.setQualifierLoc(QualifierLoc);
7855 NewTL.setNameLoc(TL.getNameLoc());
7857 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7858 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7859 NewTL.setTemplateNameLoc(TL.getNameLoc());
7860 NewTL.setQualifierLoc(QualifierLoc);
7861 } else if (isa<TypedefType>(Result)) {
7862 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7863 QualifierLoc, TL.getNameLoc());
7864 } else if (isa<UnresolvedUsingType>(Result)) {
7865 auto NewTL = TLB.push<UnresolvedUsingTypeLoc>(Result);
7866 NewTL.set(TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getNameLoc());
7867 } else {
7868 auto NewTL = TLB.push<DependentNameTypeLoc>(Result);
7869 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7870 NewTL.setQualifierLoc(QualifierLoc);
7871 NewTL.setNameLoc(TL.getNameLoc());
7872 }
7873 return Result;
7874}
7875
7876template<typename Derived>
7879 QualType Pattern
7880 = getDerived().TransformType(TLB, TL.getPatternLoc());
7881 if (Pattern.isNull())
7882 return QualType();
7883
7884 QualType Result = TL.getType();
7885 if (getDerived().AlwaysRebuild() ||
7886 Pattern != TL.getPatternLoc().getType()) {
7887 Result = getDerived().RebuildPackExpansionType(Pattern,
7888 TL.getPatternLoc().getSourceRange(),
7889 TL.getEllipsisLoc(),
7890 TL.getTypePtr()->getNumExpansions());
7891 if (Result.isNull())
7892 return QualType();
7893 }
7894
7896 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7897 return Result;
7898}
7899
7900template<typename Derived>
7904 // ObjCInterfaceType is never dependent.
7905 TLB.pushFullCopy(TL);
7906 return TL.getType();
7907}
7908
7909template<typename Derived>
7913 const ObjCTypeParamType *T = TL.getTypePtr();
7914 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7915 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7916 if (!OTP)
7917 return QualType();
7918
7919 QualType Result = TL.getType();
7920 if (getDerived().AlwaysRebuild() ||
7921 OTP != T->getDecl()) {
7922 Result = getDerived().RebuildObjCTypeParamType(
7923 OTP, TL.getProtocolLAngleLoc(),
7924 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7925 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7926 if (Result.isNull())
7927 return QualType();
7928 }
7929
7931 if (TL.getNumProtocols()) {
7932 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7933 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7934 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7935 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7936 }
7937 return Result;
7938}
7939
7940template<typename Derived>
7943 ObjCObjectTypeLoc TL) {
7944 // Transform base type.
7945 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
7946 if (BaseType.isNull())
7947 return QualType();
7948
7949 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
7950
7951 // Transform type arguments.
7952 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
7953 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
7954 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
7955 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
7956 QualType TypeArg = TypeArgInfo->getType();
7957 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
7958 AnyChanged = true;
7959
7960 // We have a pack expansion. Instantiate it.
7961 const auto *PackExpansion = PackExpansionLoc.getType()
7962 ->castAs<PackExpansionType>();
7964 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
7965 Unexpanded);
7966 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7967
7968 // Determine whether the set of unexpanded parameter packs can
7969 // and should be expanded.
7970 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
7971 bool Expand = false;
7972 bool RetainExpansion = false;
7973 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
7974 if (getDerived().TryExpandParameterPacks(
7975 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
7976 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
7977 RetainExpansion, NumExpansions))
7978 return QualType();
7979
7980 if (!Expand) {
7981 // We can't expand this pack expansion into separate arguments yet;
7982 // just substitute into the pattern and create a new pack expansion
7983 // type.
7984 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7985
7986 TypeLocBuilder TypeArgBuilder;
7987 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7988 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
7989 PatternLoc);
7990 if (NewPatternType.isNull())
7991 return QualType();
7992
7993 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
7994 NewPatternType, NumExpansions);
7995 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
7996 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
7997 NewTypeArgInfos.push_back(
7998 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
7999 continue;
8000 }
8001
8002 // Substitute into the pack expansion pattern for each slice of the
8003 // pack.
8004 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
8005 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
8006
8007 TypeLocBuilder TypeArgBuilder;
8008 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8009
8010 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
8011 PatternLoc);
8012 if (NewTypeArg.isNull())
8013 return QualType();
8014
8015 NewTypeArgInfos.push_back(
8016 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8017 }
8018
8019 continue;
8020 }
8021
8022 TypeLocBuilder TypeArgBuilder;
8023 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
8024 QualType NewTypeArg =
8025 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
8026 if (NewTypeArg.isNull())
8027 return QualType();
8028
8029 // If nothing changed, just keep the old TypeSourceInfo.
8030 if (NewTypeArg == TypeArg) {
8031 NewTypeArgInfos.push_back(TypeArgInfo);
8032 continue;
8033 }
8034
8035 NewTypeArgInfos.push_back(
8036 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8037 AnyChanged = true;
8038 }
8039
8040 QualType Result = TL.getType();
8041 if (getDerived().AlwaysRebuild() || AnyChanged) {
8042 // Rebuild the type.
8043 Result = getDerived().RebuildObjCObjectType(
8044 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
8045 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
8046 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8047 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8048
8049 if (Result.isNull())
8050 return QualType();
8051 }
8052
8053 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
8054 NewT.setHasBaseTypeAsWritten(true);
8055 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
8056 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
8057 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
8058 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
8059 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8060 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8061 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
8062 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8063 return Result;
8064}
8065
8066template<typename Derived>
8070 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8071 if (PointeeType.isNull())
8072 return QualType();
8073
8074 QualType Result = TL.getType();
8075 if (getDerived().AlwaysRebuild() ||
8076 PointeeType != TL.getPointeeLoc().getType()) {
8077 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8078 TL.getStarLoc());
8079 if (Result.isNull())
8080 return QualType();
8081 }
8082
8084 NewT.setStarLoc(TL.getStarLoc());
8085 return Result;
8086}
8087
8088//===----------------------------------------------------------------------===//
8089// Statement transformation
8090//===----------------------------------------------------------------------===//
8091template<typename Derived>
8094 return S;
8095}
8096
8097template<typename Derived>
8100 return getDerived().TransformCompoundStmt(S, false);
8101}
8102
8103template<typename Derived>
8106 bool IsStmtExpr) {
8107 Sema::CompoundScopeRAII CompoundScope(getSema());
8108 Sema::FPFeaturesStateRAII FPSave(getSema());
8109 if (S->hasStoredFPFeatures())
8110 getSema().resetFPOptions(
8111 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8112
8113 bool SubStmtInvalid = false;
8114 bool SubStmtChanged = false;
8115 SmallVector<Stmt*, 8> Statements;
8116 for (auto *B : S->body()) {
8117 StmtResult Result = getDerived().TransformStmt(
8118 B, IsStmtExpr && B == S->body_back() ? StmtDiscardKind::StmtExprResult
8119 : StmtDiscardKind::Discarded);
8120
8121 if (Result.isInvalid()) {
8122 // Immediately fail if this was a DeclStmt, since it's very
8123 // likely that this will cause problems for future statements.
8124 if (isa<DeclStmt>(B))
8125 return StmtError();
8126
8127 // Otherwise, just keep processing substatements and fail later.
8128 SubStmtInvalid = true;
8129 continue;
8130 }
8131
8132 SubStmtChanged = SubStmtChanged || Result.get() != B;
8133 Statements.push_back(Result.getAs<Stmt>());
8134 }
8135
8136 if (SubStmtInvalid)
8137 return StmtError();
8138
8139 if (!getDerived().AlwaysRebuild() &&
8140 !SubStmtChanged)
8141 return S;
8142
8143 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8144 Statements,
8145 S->getRBracLoc(),
8146 IsStmtExpr);
8147}
8148
8149template<typename Derived>
8152 ExprResult LHS, RHS;
8153 {
8156
8157 // Transform the left-hand case value.
8158 LHS = getDerived().TransformExpr(S->getLHS());
8159 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8160 if (LHS.isInvalid())
8161 return StmtError();
8162
8163 // Transform the right-hand case value (for the GNU case-range extension).
8164 RHS = getDerived().TransformExpr(S->getRHS());
8165 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8166 if (RHS.isInvalid())
8167 return StmtError();
8168 }
8169
8170 // Build the case statement.
8171 // Case statements are always rebuilt so that they will attached to their
8172 // transformed switch statement.
8173 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8174 LHS.get(),
8175 S->getEllipsisLoc(),
8176 RHS.get(),
8177 S->getColonLoc());
8178 if (Case.isInvalid())
8179 return StmtError();
8180
8181 // Transform the statement following the case
8182 StmtResult SubStmt =
8183 getDerived().TransformStmt(S->getSubStmt());
8184 if (SubStmt.isInvalid())
8185 return StmtError();
8186
8187 // Attach the body to the case statement
8188 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8189}
8190
8191template <typename Derived>
8193 // Transform the statement following the default case
8194 StmtResult SubStmt =
8195 getDerived().TransformStmt(S->getSubStmt());
8196 if (SubStmt.isInvalid())
8197 return StmtError();
8198
8199 // Default statements are always rebuilt
8200 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8201 SubStmt.get());
8202}
8203
8204template<typename Derived>
8207 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8208 if (SubStmt.isInvalid())
8209 return StmtError();
8210
8211 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8212 S->getDecl());
8213 if (!LD)
8214 return StmtError();
8215
8216 // If we're transforming "in-place" (we're not creating new local
8217 // declarations), assume we're replacing the old label statement
8218 // and clear out the reference to it.
8219 if (LD == S->getDecl())
8220 S->getDecl()->setStmt(nullptr);
8221
8222 // FIXME: Pass the real colon location in.
8223 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8225 SubStmt.get());
8226}
8227
8228template <typename Derived>
8230 if (!R)
8231 return R;
8232
8233 switch (R->getKind()) {
8234// Transform attributes by calling TransformXXXAttr.
8235#define ATTR(X) \
8236 case attr::X: \
8237 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8238#include "clang/Basic/AttrList.inc"
8239 }
8240 return R;
8241}
8242
8243template <typename Derived>
8245 const Stmt *InstS,
8246 const Attr *R) {
8247 if (!R)
8248 return R;
8249
8250 switch (R->getKind()) {
8251// Transform attributes by calling TransformStmtXXXAttr.
8252#define ATTR(X) \
8253 case attr::X: \
8254 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8255#include "clang/Basic/AttrList.inc"
8256 }
8257 return TransformAttr(R);
8258}
8259
8260template <typename Derived>
8263 StmtDiscardKind SDK) {
8264 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8265 if (SubStmt.isInvalid())
8266 return StmtError();
8267
8268 bool AttrsChanged = false;
8270
8271 // Visit attributes and keep track if any are transformed.
8272 for (const auto *I : S->getAttrs()) {
8273 const Attr *R =
8274 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8275 AttrsChanged |= (I != R);
8276 if (R)
8277 Attrs.push_back(R);
8278 }
8279
8280 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8281 return S;
8282
8283 // If transforming the attributes failed for all of the attributes in the
8284 // statement, don't make an AttributedStmt without attributes.
8285 if (Attrs.empty())
8286 return SubStmt;
8287
8288 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8289 SubStmt.get());
8290}
8291
8292template<typename Derived>
8295 // Transform the initialization statement
8296 StmtResult Init = getDerived().TransformStmt(S->getInit());
8297 if (Init.isInvalid())
8298 return StmtError();
8299
8301 if (!S->isConsteval()) {
8302 // Transform the condition
8303 Cond = getDerived().TransformCondition(
8304 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8305 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8307 if (Cond.isInvalid())
8308 return StmtError();
8309 }
8310
8311 // If this is a constexpr if, determine which arm we should instantiate.
8312 std::optional<bool> ConstexprConditionValue;
8313 if (S->isConstexpr())
8314 ConstexprConditionValue = Cond.getKnownValue();
8315
8316 // Transform the "then" branch.
8317 StmtResult Then;
8318 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8322 S->isNonNegatedConsteval());
8323
8324 Then = getDerived().TransformStmt(S->getThen());
8325 if (Then.isInvalid())
8326 return StmtError();
8327 } else {
8328 // Discarded branch is replaced with empty CompoundStmt so we can keep
8329 // proper source location for start and end of original branch, so
8330 // subsequent transformations like CoverageMapping work properly
8331 Then = new (getSema().Context)
8332 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8333 }
8334
8335 // Transform the "else" branch.
8336 StmtResult Else;
8337 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8341 S->isNegatedConsteval());
8342
8343 Else = getDerived().TransformStmt(S->getElse());
8344 if (Else.isInvalid())
8345 return StmtError();
8346 } else if (S->getElse() && ConstexprConditionValue &&
8347 *ConstexprConditionValue) {
8348 // Same thing here as with <then> branch, we are discarding it, we can't
8349 // replace it with NULL nor NullStmt as we need to keep for source location
8350 // range, for CoverageMapping
8351 Else = new (getSema().Context)
8352 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8353 }
8354
8355 if (!getDerived().AlwaysRebuild() &&
8356 Init.get() == S->getInit() &&
8357 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8358 Then.get() == S->getThen() &&
8359 Else.get() == S->getElse())
8360 return S;
8361
8362 return getDerived().RebuildIfStmt(
8363 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8364 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8365}
8366
8367template<typename Derived>
8370 // Transform the initialization statement
8371 StmtResult Init = getDerived().TransformStmt(S->getInit());
8372 if (Init.isInvalid())
8373 return StmtError();
8374
8375 // Transform the condition.
8376 Sema::ConditionResult Cond = getDerived().TransformCondition(
8377 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8379 if (Cond.isInvalid())
8380 return StmtError();
8381
8382 // Rebuild the switch statement.
8384 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8385 Init.get(), Cond, S->getRParenLoc());
8386 if (Switch.isInvalid())
8387 return StmtError();
8388
8389 // Transform the body of the switch statement.
8390 StmtResult Body = getDerived().TransformStmt(S->getBody());
8391 if (Body.isInvalid())
8392 return StmtError();
8393
8394 // Complete the switch statement.
8395 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8396 Body.get());
8397}
8398
8399template<typename Derived>
8402 // Transform the condition
8403 Sema::ConditionResult Cond = getDerived().TransformCondition(
8404 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8406 if (Cond.isInvalid())
8407 return StmtError();
8408
8409 // OpenACC Restricts a while-loop inside of certain construct/clause
8410 // combinations, so diagnose that here in OpenACC mode.
8412 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8413
8414 // Transform the body
8415 StmtResult Body = getDerived().TransformStmt(S->getBody());
8416 if (Body.isInvalid())
8417 return StmtError();
8418
8419 if (!getDerived().AlwaysRebuild() &&
8420 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8421 Body.get() == S->getBody())
8422 return Owned(S);
8423
8424 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8425 Cond, S->getRParenLoc(), Body.get());
8426}
8427
8428template<typename Derived>
8431 // OpenACC Restricts a do-loop inside of certain construct/clause
8432 // combinations, so diagnose that here in OpenACC mode.
8434 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8435
8436 // Transform the body
8437 StmtResult Body = getDerived().TransformStmt(S->getBody());
8438 if (Body.isInvalid())
8439 return StmtError();
8440
8441 // Transform the condition
8442 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8443 if (Cond.isInvalid())
8444 return StmtError();
8445
8446 if (!getDerived().AlwaysRebuild() &&
8447 Cond.get() == S->getCond() &&
8448 Body.get() == S->getBody())
8449 return S;
8450
8451 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8452 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8453 S->getRParenLoc());
8454}
8455
8456template<typename Derived>
8459 if (getSema().getLangOpts().OpenMP)
8460 getSema().OpenMP().startOpenMPLoop();
8461
8462 // Transform the initialization statement
8463 StmtResult Init = getDerived().TransformStmt(S->getInit());
8464 if (Init.isInvalid())
8465 return StmtError();
8466
8467 // In OpenMP loop region loop control variable must be captured and be
8468 // private. Perform analysis of first part (if any).
8469 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8470 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8471 Init.get());
8472
8473 // Transform the condition
8474 Sema::ConditionResult Cond = getDerived().TransformCondition(
8475 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8477 if (Cond.isInvalid())
8478 return StmtError();
8479
8480 // Transform the increment
8481 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8482 if (Inc.isInvalid())
8483 return StmtError();
8484
8485 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8486 if (S->getInc() && !FullInc.get())
8487 return StmtError();
8488
8489 // OpenACC Restricts a for-loop inside of certain construct/clause
8490 // combinations, so diagnose that here in OpenACC mode.
8492 SemaRef.OpenACC().ActOnForStmtBegin(
8493 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8494 Cond.get().second, S->getInc(), Inc.get());
8495
8496 // Transform the body
8497 StmtResult Body = getDerived().TransformStmt(S->getBody());
8498 if (Body.isInvalid())
8499 return StmtError();
8500
8501 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8502
8503 if (!getDerived().AlwaysRebuild() &&
8504 Init.get() == S->getInit() &&
8505 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8506 Inc.get() == S->getInc() &&
8507 Body.get() == S->getBody())
8508 return S;
8509
8510 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8511 Init.get(), Cond, FullInc,
8512 S->getRParenLoc(), Body.get());
8513}
8514
8515template<typename Derived>
8518 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8519 S->getLabel());
8520 if (!LD)
8521 return StmtError();
8522
8523 // Goto statements must always be rebuilt, to resolve the label.
8524 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8525 cast<LabelDecl>(LD));
8526}
8527
8528template<typename Derived>
8531 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8532 if (Target.isInvalid())
8533 return StmtError();
8534 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8535
8536 if (!getDerived().AlwaysRebuild() &&
8537 Target.get() == S->getTarget())
8538 return S;
8539
8540 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8541 Target.get());
8542}
8543
8544template<typename Derived>
8547 if (!S->hasLabelTarget())
8548 return S;
8549
8550 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8551 S->getLabelDecl());
8552 if (!LD)
8553 return StmtError();
8554
8555 return new (SemaRef.Context)
8556 ContinueStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8557}
8558
8559template<typename Derived>
8562 if (!S->hasLabelTarget())
8563 return S;
8564
8565 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8566 S->getLabelDecl());
8567 if (!LD)
8568 return StmtError();
8569
8570 return new (SemaRef.Context)
8571 BreakStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8572}
8573
8574template <typename Derived>
8576 StmtResult Result = getDerived().TransformStmt(S->getBody());
8577 if (!Result.isUsable())
8578 return StmtError();
8579 return DeferStmt::Create(getSema().Context, S->getDeferLoc(), Result.get());
8580}
8581
8582template<typename Derived>
8585 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8586 /*NotCopyInit*/false);
8587 if (Result.isInvalid())
8588 return StmtError();
8589
8590 // FIXME: We always rebuild the return statement because there is no way
8591 // to tell whether the return type of the function has changed.
8592 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8593}
8594
8595template<typename Derived>
8598 bool DeclChanged = false;
8600 LambdaScopeInfo *LSI = getSema().getCurLambda();
8601 for (auto *D : S->decls()) {
8602 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8603 if (!Transformed)
8604 return StmtError();
8605
8606 if (Transformed != D)
8607 DeclChanged = true;
8608
8609 if (LSI) {
8610 if (auto *TD = dyn_cast<TypeDecl>(Transformed)) {
8611 if (auto *TN = dyn_cast<TypedefNameDecl>(TD)) {
8612 LSI->ContainsUnexpandedParameterPack |=
8613 TN->getUnderlyingType()->containsUnexpandedParameterPack();
8614 } else {
8615 LSI->ContainsUnexpandedParameterPack |=
8616 getSema()
8617 .getASTContext()
8618 .getTypeDeclType(TD)
8619 ->containsUnexpandedParameterPack();
8620 }
8621 }
8622 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8623 LSI->ContainsUnexpandedParameterPack |=
8624 VD->getType()->containsUnexpandedParameterPack();
8625 }
8626
8627 Decls.push_back(Transformed);
8628 }
8629
8630 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8631 return S;
8632
8633 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8634}
8635
8636template<typename Derived>
8639
8640 SmallVector<Expr*, 8> Constraints;
8643
8644 SmallVector<Expr*, 8> Clobbers;
8645
8646 bool ExprsChanged = false;
8647
8648 auto RebuildString = [&](Expr *E) {
8649 ExprResult Result = getDerived().TransformExpr(E);
8650 if (!Result.isUsable())
8651 return Result;
8652 if (Result.get() != E) {
8653 ExprsChanged = true;
8654 Result = SemaRef.ActOnGCCAsmStmtString(Result.get(), /*ForLabel=*/false);
8655 }
8656 return Result;
8657 };
8658
8659 // Go through the outputs.
8660 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8661 Names.push_back(S->getOutputIdentifier(I));
8662
8663 ExprResult Result = RebuildString(S->getOutputConstraintExpr(I));
8664 if (Result.isInvalid())
8665 return StmtError();
8666
8667 Constraints.push_back(Result.get());
8668
8669 // Transform the output expr.
8670 Expr *OutputExpr = S->getOutputExpr(I);
8671 Result = getDerived().TransformExpr(OutputExpr);
8672 if (Result.isInvalid())
8673 return StmtError();
8674
8675 ExprsChanged |= Result.get() != OutputExpr;
8676
8677 Exprs.push_back(Result.get());
8678 }
8679
8680 // Go through the inputs.
8681 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8682 Names.push_back(S->getInputIdentifier(I));
8683
8684 ExprResult Result = RebuildString(S->getInputConstraintExpr(I));
8685 if (Result.isInvalid())
8686 return StmtError();
8687
8688 Constraints.push_back(Result.get());
8689
8690 // Transform the input expr.
8691 Expr *InputExpr = S->getInputExpr(I);
8692 Result = getDerived().TransformExpr(InputExpr);
8693 if (Result.isInvalid())
8694 return StmtError();
8695
8696 ExprsChanged |= Result.get() != InputExpr;
8697
8698 Exprs.push_back(Result.get());
8699 }
8700
8701 // Go through the Labels.
8702 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8703 Names.push_back(S->getLabelIdentifier(I));
8704
8705 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8706 if (Result.isInvalid())
8707 return StmtError();
8708 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8709 Exprs.push_back(Result.get());
8710 }
8711
8712 // Go through the clobbers.
8713 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) {
8714 ExprResult Result = RebuildString(S->getClobberExpr(I));
8715 if (Result.isInvalid())
8716 return StmtError();
8717 Clobbers.push_back(Result.get());
8718 }
8719
8720 ExprResult AsmString = RebuildString(S->getAsmStringExpr());
8721 if (AsmString.isInvalid())
8722 return StmtError();
8723
8724 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8725 return S;
8726
8727 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8728 S->isVolatile(), S->getNumOutputs(),
8729 S->getNumInputs(), Names.data(),
8730 Constraints, Exprs, AsmString.get(),
8731 Clobbers, S->getNumLabels(),
8732 S->getRParenLoc());
8733}
8734
8735template<typename Derived>
8738 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8739
8740 bool HadError = false, HadChange = false;
8741
8742 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8743 SmallVector<Expr*, 8> TransformedExprs;
8744 TransformedExprs.reserve(SrcExprs.size());
8745 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8746 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8747 if (!Result.isUsable()) {
8748 HadError = true;
8749 } else {
8750 HadChange |= (Result.get() != SrcExprs[i]);
8751 TransformedExprs.push_back(Result.get());
8752 }
8753 }
8754
8755 if (HadError) return StmtError();
8756 if (!HadChange && !getDerived().AlwaysRebuild())
8757 return Owned(S);
8758
8759 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8760 AsmToks, S->getAsmString(),
8761 S->getNumOutputs(), S->getNumInputs(),
8762 S->getAllConstraints(), S->getClobbers(),
8763 TransformedExprs, S->getEndLoc());
8764}
8765
8766// C++ Coroutines
8767template<typename Derived>
8770 auto *ScopeInfo = SemaRef.getCurFunction();
8771 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8772 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8773 ScopeInfo->NeedsCoroutineSuspends &&
8774 ScopeInfo->CoroutineSuspends.first == nullptr &&
8775 ScopeInfo->CoroutineSuspends.second == nullptr &&
8776 "expected clean scope info");
8777
8778 // Set that we have (possibly-invalid) suspend points before we do anything
8779 // that may fail.
8780 ScopeInfo->setNeedsCoroutineSuspends(false);
8781
8782 // We re-build the coroutine promise object (and the coroutine parameters its
8783 // type and constructor depend on) based on the types used in our current
8784 // function. We must do so, and set it on the current FunctionScopeInfo,
8785 // before attempting to transform the other parts of the coroutine body
8786 // statement, such as the implicit suspend statements (because those
8787 // statements reference the FunctionScopeInfo::CoroutinePromise).
8788 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8789 return StmtError();
8790 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8791 if (!Promise)
8792 return StmtError();
8793 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8794 ScopeInfo->CoroutinePromise = Promise;
8795
8796 // Transform the implicit coroutine statements constructed using dependent
8797 // types during the previous parse: initial and final suspensions, the return
8798 // object, and others. We also transform the coroutine function's body.
8799 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8800 if (InitSuspend.isInvalid())
8801 return StmtError();
8802 StmtResult FinalSuspend =
8803 getDerived().TransformStmt(S->getFinalSuspendStmt());
8804 if (FinalSuspend.isInvalid() ||
8805 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8806 return StmtError();
8807 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8808 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8809
8810 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8811 if (BodyRes.isInvalid())
8812 return StmtError();
8813
8814 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8815 if (Builder.isInvalid())
8816 return StmtError();
8817
8818 Expr *ReturnObject = S->getReturnValueInit();
8819 assert(ReturnObject && "the return object is expected to be valid");
8820 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8821 /*NoCopyInit*/ false);
8822 if (Res.isInvalid())
8823 return StmtError();
8824 Builder.ReturnValue = Res.get();
8825
8826 // If during the previous parse the coroutine still had a dependent promise
8827 // statement, we may need to build some implicit coroutine statements
8828 // (such as exception and fallthrough handlers) for the first time.
8829 if (S->hasDependentPromiseType()) {
8830 // We can only build these statements, however, if the current promise type
8831 // is not dependent.
8832 if (!Promise->getType()->isDependentType()) {
8833 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8834 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8835 "these nodes should not have been built yet");
8836 if (!Builder.buildDependentStatements())
8837 return StmtError();
8838 }
8839 } else {
8840 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8841 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8842 if (Res.isInvalid())
8843 return StmtError();
8844 Builder.OnFallthrough = Res.get();
8845 }
8846
8847 if (auto *OnException = S->getExceptionHandler()) {
8848 StmtResult Res = getDerived().TransformStmt(OnException);
8849 if (Res.isInvalid())
8850 return StmtError();
8851 Builder.OnException = Res.get();
8852 }
8853
8854 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8855 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8856 if (Res.isInvalid())
8857 return StmtError();
8858 Builder.ReturnStmtOnAllocFailure = Res.get();
8859 }
8860
8861 // Transform any additional statements we may have already built
8862 assert(S->getAllocate() && S->getDeallocate() &&
8863 "allocation and deallocation calls must already be built");
8864 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8865 if (AllocRes.isInvalid())
8866 return StmtError();
8867 Builder.Allocate = AllocRes.get();
8868
8869 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8870 if (DeallocRes.isInvalid())
8871 return StmtError();
8872 Builder.Deallocate = DeallocRes.get();
8873
8874 if (auto *ResultDecl = S->getResultDecl()) {
8875 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8876 if (Res.isInvalid())
8877 return StmtError();
8878 Builder.ResultDecl = Res.get();
8879 }
8880
8881 if (auto *ReturnStmt = S->getReturnStmt()) {
8882 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8883 if (Res.isInvalid())
8884 return StmtError();
8885 Builder.ReturnStmt = Res.get();
8886 }
8887 }
8888
8889 return getDerived().RebuildCoroutineBodyStmt(Builder);
8890}
8891
8892template<typename Derived>
8895 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8896 /*NotCopyInit*/false);
8897 if (Result.isInvalid())
8898 return StmtError();
8899
8900 // Always rebuild; we don't know if this needs to be injected into a new
8901 // context or if the promise type has changed.
8902 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8903 S->isImplicit());
8904}
8905
8906template <typename Derived>
8908 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8909 /*NotCopyInit*/ false);
8910 if (Operand.isInvalid())
8911 return ExprError();
8912
8913 // Rebuild the common-expr from the operand rather than transforming it
8914 // separately.
8915
8916 // FIXME: getCurScope() should not be used during template instantiation.
8917 // We should pick up the set of unqualified lookup results for operator
8918 // co_await during the initial parse.
8919 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8920 getSema().getCurScope(), E->getKeywordLoc());
8921
8922 // Always rebuild; we don't know if this needs to be injected into a new
8923 // context or if the promise type has changed.
8924 return getDerived().RebuildCoawaitExpr(
8925 E->getKeywordLoc(), Operand.get(),
8926 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8927}
8928
8929template <typename Derived>
8932 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8933 /*NotCopyInit*/ false);
8934 if (OperandResult.isInvalid())
8935 return ExprError();
8936
8937 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8938 E->getOperatorCoawaitLookup());
8939
8940 if (LookupResult.isInvalid())
8941 return ExprError();
8942
8943 // Always rebuild; we don't know if this needs to be injected into a new
8944 // context or if the promise type has changed.
8945 return getDerived().RebuildDependentCoawaitExpr(
8946 E->getKeywordLoc(), OperandResult.get(),
8948}
8949
8950template<typename Derived>
8953 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
8954 /*NotCopyInit*/false);
8955 if (Result.isInvalid())
8956 return ExprError();
8957
8958 // Always rebuild; we don't know if this needs to be injected into a new
8959 // context or if the promise type has changed.
8960 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
8961}
8962
8963// Objective-C Statements.
8964
8965template<typename Derived>
8968 // Transform the body of the @try.
8969 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
8970 if (TryBody.isInvalid())
8971 return StmtError();
8972
8973 // Transform the @catch statements (if present).
8974 bool AnyCatchChanged = false;
8975 SmallVector<Stmt*, 8> CatchStmts;
8976 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
8977 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
8978 if (Catch.isInvalid())
8979 return StmtError();
8980 if (Catch.get() != S->getCatchStmt(I))
8981 AnyCatchChanged = true;
8982 CatchStmts.push_back(Catch.get());
8983 }
8984
8985 // Transform the @finally statement (if present).
8986 StmtResult Finally;
8987 if (S->getFinallyStmt()) {
8988 Finally = getDerived().TransformStmt(S->getFinallyStmt());
8989 if (Finally.isInvalid())
8990 return StmtError();
8991 }
8992
8993 // If nothing changed, just retain this statement.
8994 if (!getDerived().AlwaysRebuild() &&
8995 TryBody.get() == S->getTryBody() &&
8996 !AnyCatchChanged &&
8997 Finally.get() == S->getFinallyStmt())
8998 return S;
8999
9000 // Build a new statement.
9001 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
9002 CatchStmts, Finally.get());
9003}
9004
9005template<typename Derived>
9008 // Transform the @catch parameter, if there is one.
9009 VarDecl *Var = nullptr;
9010 if (VarDecl *FromVar = S->getCatchParamDecl()) {
9011 TypeSourceInfo *TSInfo = nullptr;
9012 if (FromVar->getTypeSourceInfo()) {
9013 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
9014 if (!TSInfo)
9015 return StmtError();
9016 }
9017
9018 QualType T;
9019 if (TSInfo)
9020 T = TSInfo->getType();
9021 else {
9022 T = getDerived().TransformType(FromVar->getType());
9023 if (T.isNull())
9024 return StmtError();
9025 }
9026
9027 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
9028 if (!Var)
9029 return StmtError();
9030 }
9031
9032 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
9033 if (Body.isInvalid())
9034 return StmtError();
9035
9036 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
9037 S->getRParenLoc(),
9038 Var, Body.get());
9039}
9040
9041template<typename Derived>
9044 // Transform the body.
9045 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
9046 if (Body.isInvalid())
9047 return StmtError();
9048
9049 // If nothing changed, just retain this statement.
9050 if (!getDerived().AlwaysRebuild() &&
9051 Body.get() == S->getFinallyBody())
9052 return S;
9053
9054 // Build a new statement.
9055 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
9056 Body.get());
9057}
9058
9059template<typename Derived>
9063 if (S->getThrowExpr()) {
9064 Operand = getDerived().TransformExpr(S->getThrowExpr());
9065 if (Operand.isInvalid())
9066 return StmtError();
9067 }
9068
9069 if (!getDerived().AlwaysRebuild() &&
9070 Operand.get() == S->getThrowExpr())
9071 return S;
9072
9073 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
9074}
9075
9076template<typename Derived>
9080 // Transform the object we are locking.
9081 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
9082 if (Object.isInvalid())
9083 return StmtError();
9084 Object =
9085 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
9086 Object.get());
9087 if (Object.isInvalid())
9088 return StmtError();
9089
9090 // Transform the body.
9091 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
9092 if (Body.isInvalid())
9093 return StmtError();
9094
9095 // If nothing change, just retain the current statement.
9096 if (!getDerived().AlwaysRebuild() &&
9097 Object.get() == S->getSynchExpr() &&
9098 Body.get() == S->getSynchBody())
9099 return S;
9100
9101 // Build a new statement.
9102 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
9103 Object.get(), Body.get());
9104}
9105
9106template<typename Derived>
9110 // Transform the body.
9111 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
9112 if (Body.isInvalid())
9113 return StmtError();
9114
9115 // If nothing changed, just retain this statement.
9116 if (!getDerived().AlwaysRebuild() &&
9117 Body.get() == S->getSubStmt())
9118 return S;
9119
9120 // Build a new statement.
9121 return getDerived().RebuildObjCAutoreleasePoolStmt(
9122 S->getAtLoc(), Body.get());
9123}
9124
9125template<typename Derived>
9129 // Transform the element statement.
9130 StmtResult Element = getDerived().TransformStmt(
9131 S->getElement(), StmtDiscardKind::NotDiscarded);
9132 if (Element.isInvalid())
9133 return StmtError();
9134
9135 // Transform the collection expression.
9136 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9137 if (Collection.isInvalid())
9138 return StmtError();
9139
9140 // Transform the body.
9141 StmtResult Body = getDerived().TransformStmt(S->getBody());
9142 if (Body.isInvalid())
9143 return StmtError();
9144
9145 // If nothing changed, just retain this statement.
9146 if (!getDerived().AlwaysRebuild() &&
9147 Element.get() == S->getElement() &&
9148 Collection.get() == S->getCollection() &&
9149 Body.get() == S->getBody())
9150 return S;
9151
9152 // Build a new statement.
9153 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9154 Element.get(),
9155 Collection.get(),
9156 S->getRParenLoc(),
9157 Body.get());
9158}
9159
9160template <typename Derived>
9162 // Transform the exception declaration, if any.
9163 VarDecl *Var = nullptr;
9164 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9165 TypeSourceInfo *T =
9166 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9167 if (!T)
9168 return StmtError();
9169
9170 Var = getDerived().RebuildExceptionDecl(
9171 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9172 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9173 if (!Var || Var->isInvalidDecl())
9174 return StmtError();
9175 }
9176
9177 // Transform the actual exception handler.
9178 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9179 if (Handler.isInvalid())
9180 return StmtError();
9181
9182 if (!getDerived().AlwaysRebuild() && !Var &&
9183 Handler.get() == S->getHandlerBlock())
9184 return S;
9185
9186 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9187}
9188
9189template <typename Derived>
9191 // Transform the try block itself.
9192 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9193 if (TryBlock.isInvalid())
9194 return StmtError();
9195
9196 // Transform the handlers.
9197 bool HandlerChanged = false;
9198 SmallVector<Stmt *, 8> Handlers;
9199 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9200 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9201 if (Handler.isInvalid())
9202 return StmtError();
9203
9204 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9205 Handlers.push_back(Handler.getAs<Stmt>());
9206 }
9207
9208 getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
9209
9210 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9211 !HandlerChanged)
9212 return S;
9213
9214 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9215 Handlers);
9216}
9217
9218template<typename Derived>
9221 EnterExpressionEvaluationContext ForRangeInitContext(
9223 /*LambdaContextDecl=*/nullptr,
9225 getSema().getLangOpts().CPlusPlus23);
9226
9227 // P2718R0 - Lifetime extension in range-based for loops.
9228 if (getSema().getLangOpts().CPlusPlus23) {
9229 auto &LastRecord = getSema().currentEvaluationContext();
9230 LastRecord.InLifetimeExtendingContext = true;
9231 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9232 }
9234 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9235 if (Init.isInvalid())
9236 return StmtError();
9237
9238 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9239 if (Range.isInvalid())
9240 return StmtError();
9241
9242 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9243 assert(getSema().getLangOpts().CPlusPlus23 ||
9244 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9245 auto ForRangeLifetimeExtendTemps =
9246 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9247
9248 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9249 if (Begin.isInvalid())
9250 return StmtError();
9251 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9252 if (End.isInvalid())
9253 return StmtError();
9254
9255 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9256 if (Cond.isInvalid())
9257 return StmtError();
9258 if (Cond.get())
9259 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9260 if (Cond.isInvalid())
9261 return StmtError();
9262 if (Cond.get())
9263 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9264
9265 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9266 if (Inc.isInvalid())
9267 return StmtError();
9268 if (Inc.get())
9269 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9270
9271 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9272 if (LoopVar.isInvalid())
9273 return StmtError();
9274
9275 StmtResult NewStmt = S;
9276 if (getDerived().AlwaysRebuild() ||
9277 Init.get() != S->getInit() ||
9278 Range.get() != S->getRangeStmt() ||
9279 Begin.get() != S->getBeginStmt() ||
9280 End.get() != S->getEndStmt() ||
9281 Cond.get() != S->getCond() ||
9282 Inc.get() != S->getInc() ||
9283 LoopVar.get() != S->getLoopVarStmt()) {
9284 NewStmt = getDerived().RebuildCXXForRangeStmt(
9285 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9286 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9287 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9288 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9289 // Might not have attached any initializer to the loop variable.
9290 getSema().ActOnInitializerError(
9291 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9292 return StmtError();
9293 }
9294 }
9295
9296 // OpenACC Restricts a while-loop inside of certain construct/clause
9297 // combinations, so diagnose that here in OpenACC mode.
9299 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9300
9301 StmtResult Body = getDerived().TransformStmt(S->getBody());
9302 if (Body.isInvalid())
9303 return StmtError();
9304
9305 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9306
9307 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9308 // it now so we have a new statement to attach the body to.
9309 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9310 NewStmt = getDerived().RebuildCXXForRangeStmt(
9311 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9312 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9313 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9314 if (NewStmt.isInvalid())
9315 return StmtError();
9316 }
9317
9318 if (NewStmt.get() == S)
9319 return S;
9320
9321 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9322}
9323
9324template<typename Derived>
9328 // Transform the nested-name-specifier, if any.
9329 NestedNameSpecifierLoc QualifierLoc;
9330 if (S->getQualifierLoc()) {
9331 QualifierLoc
9332 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9333 if (!QualifierLoc)
9334 return StmtError();
9335 }
9336
9337 // Transform the declaration name.
9338 DeclarationNameInfo NameInfo = S->getNameInfo();
9339 if (NameInfo.getName()) {
9340 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9341 if (!NameInfo.getName())
9342 return StmtError();
9343 }
9344
9345 // Check whether anything changed.
9346 if (!getDerived().AlwaysRebuild() &&
9347 QualifierLoc == S->getQualifierLoc() &&
9348 NameInfo.getName() == S->getNameInfo().getName())
9349 return S;
9350
9351 // Determine whether this name exists, if we can.
9352 CXXScopeSpec SS;
9353 SS.Adopt(QualifierLoc);
9354 bool Dependent = false;
9355 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9357 if (S->isIfExists())
9358 break;
9359
9360 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9361
9363 if (S->isIfNotExists())
9364 break;
9365
9366 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9367
9369 Dependent = true;
9370 break;
9371
9373 return StmtError();
9374 }
9375
9376 // We need to continue with the instantiation, so do so now.
9377 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9378 if (SubStmt.isInvalid())
9379 return StmtError();
9380
9381 // If we have resolved the name, just transform to the substatement.
9382 if (!Dependent)
9383 return SubStmt;
9384
9385 // The name is still dependent, so build a dependent expression again.
9386 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9387 S->isIfExists(),
9388 QualifierLoc,
9389 NameInfo,
9390 SubStmt.get());
9391}
9392
9393template<typename Derived>
9396 NestedNameSpecifierLoc QualifierLoc;
9397 if (E->getQualifierLoc()) {
9398 QualifierLoc
9399 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9400 if (!QualifierLoc)
9401 return ExprError();
9402 }
9403
9404 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9405 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9406 if (!PD)
9407 return ExprError();
9408
9409 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9410 if (Base.isInvalid())
9411 return ExprError();
9412
9413 return new (SemaRef.getASTContext())
9414 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9416 QualifierLoc, E->getMemberLoc());
9417}
9418
9419template <typename Derived>
9422 auto BaseRes = getDerived().TransformExpr(E->getBase());
9423 if (BaseRes.isInvalid())
9424 return ExprError();
9425 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9426 if (IdxRes.isInvalid())
9427 return ExprError();
9428
9429 if (!getDerived().AlwaysRebuild() &&
9430 BaseRes.get() == E->getBase() &&
9431 IdxRes.get() == E->getIdx())
9432 return E;
9433
9434 return getDerived().RebuildArraySubscriptExpr(
9435 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9436}
9437
9438template <typename Derived>
9440 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9441 if (TryBlock.isInvalid())
9442 return StmtError();
9443
9444 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9445 if (Handler.isInvalid())
9446 return StmtError();
9447
9448 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9449 Handler.get() == S->getHandler())
9450 return S;
9451
9452 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9453 TryBlock.get(), Handler.get());
9454}
9455
9456template <typename Derived>
9458 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9459 if (Block.isInvalid())
9460 return StmtError();
9461
9462 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9463}
9464
9465template <typename Derived>
9467 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9468 if (FilterExpr.isInvalid())
9469 return StmtError();
9470
9471 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9472 if (Block.isInvalid())
9473 return StmtError();
9474
9475 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9476 Block.get());
9477}
9478
9479template <typename Derived>
9481 if (isa<SEHFinallyStmt>(Handler))
9482 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9483 else
9484 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9485}
9486
9487template<typename Derived>
9490 return S;
9491}
9492
9493//===----------------------------------------------------------------------===//
9494// OpenMP directive transformation
9495//===----------------------------------------------------------------------===//
9496
9497template <typename Derived>
9498StmtResult
9499TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9500 // OMPCanonicalLoops are eliminated during transformation, since they will be
9501 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9502 // after transformation.
9503 return getDerived().TransformStmt(L->getLoopStmt());
9504}
9505
9506template <typename Derived>
9509
9510 // Transform the clauses
9512 ArrayRef<OMPClause *> Clauses = D->clauses();
9513 TClauses.reserve(Clauses.size());
9514 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9515 I != E; ++I) {
9516 if (*I) {
9517 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9518 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9519 getDerived().getSema().OpenMP().EndOpenMPClause();
9520 if (Clause)
9521 TClauses.push_back(Clause);
9522 } else {
9523 TClauses.push_back(nullptr);
9524 }
9525 }
9526 StmtResult AssociatedStmt;
9527 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9528 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9529 D->getDirectiveKind(),
9530 /*CurScope=*/nullptr);
9531 StmtResult Body;
9532 {
9533 Sema::CompoundScopeRAII CompoundScope(getSema());
9534 Stmt *CS;
9535 if (D->getDirectiveKind() == OMPD_atomic ||
9536 D->getDirectiveKind() == OMPD_critical ||
9537 D->getDirectiveKind() == OMPD_section ||
9538 D->getDirectiveKind() == OMPD_master)
9539 CS = D->getAssociatedStmt();
9540 else
9541 CS = D->getRawStmt();
9542 Body = getDerived().TransformStmt(CS);
9543 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9544 getSema().getLangOpts().OpenMPIRBuilder)
9545 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9546 }
9547 AssociatedStmt =
9548 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9549 if (AssociatedStmt.isInvalid()) {
9550 return StmtError();
9551 }
9552 }
9553 if (TClauses.size() != Clauses.size()) {
9554 return StmtError();
9555 }
9556
9557 // Transform directive name for 'omp critical' directive.
9558 DeclarationNameInfo DirName;
9559 if (D->getDirectiveKind() == OMPD_critical) {
9560 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9561 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9562 }
9563 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9564 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9565 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9566 } else if (D->getDirectiveKind() == OMPD_cancel) {
9567 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9568 }
9569
9570 return getDerived().RebuildOMPExecutableDirective(
9571 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9572 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
9573}
9574
9575/// This is mostly the same as above, but allows 'informational' class
9576/// directives when rebuilding the stmt. It still takes an
9577/// OMPExecutableDirective-type argument because we're reusing that as the
9578/// superclass for the 'assume' directive at present, instead of defining a
9579/// mostly-identical OMPInformationalDirective parent class.
9580template <typename Derived>
9583
9584 // Transform the clauses
9586 ArrayRef<OMPClause *> Clauses = D->clauses();
9587 TClauses.reserve(Clauses.size());
9588 for (OMPClause *C : Clauses) {
9589 if (C) {
9590 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
9591 OMPClause *Clause = getDerived().TransformOMPClause(C);
9592 getDerived().getSema().OpenMP().EndOpenMPClause();
9593 if (Clause)
9594 TClauses.push_back(Clause);
9595 } else {
9596 TClauses.push_back(nullptr);
9597 }
9598 }
9599 StmtResult AssociatedStmt;
9600 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9601 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9602 D->getDirectiveKind(),
9603 /*CurScope=*/nullptr);
9604 StmtResult Body;
9605 {
9606 Sema::CompoundScopeRAII CompoundScope(getSema());
9607 assert(D->getDirectiveKind() == OMPD_assume &&
9608 "Unexpected informational directive");
9609 Stmt *CS = D->getAssociatedStmt();
9610 Body = getDerived().TransformStmt(CS);
9611 }
9612 AssociatedStmt =
9613 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9614 if (AssociatedStmt.isInvalid())
9615 return StmtError();
9616 }
9617 if (TClauses.size() != Clauses.size())
9618 return StmtError();
9619
9620 DeclarationNameInfo DirName;
9621
9622 return getDerived().RebuildOMPInformationalDirective(
9623 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
9624 D->getBeginLoc(), D->getEndLoc());
9625}
9626
9627template <typename Derived>
9630 // TODO: Fix This
9631 unsigned OMPVersion = getDerived().getSema().getLangOpts().OpenMP;
9632 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9633 << getOpenMPDirectiveName(D->getDirectiveKind(), OMPVersion);
9634 return StmtError();
9635}
9636
9637template <typename Derived>
9638StmtResult
9639TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9640 DeclarationNameInfo DirName;
9641 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9642 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
9643 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9644 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9645 return Res;
9646}
9647
9648template <typename Derived>
9651 DeclarationNameInfo DirName;
9652 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9653 OMPD_simd, DirName, nullptr, D->getBeginLoc());
9654 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9655 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9656 return Res;
9657}
9658
9659template <typename Derived>
9662 DeclarationNameInfo DirName;
9663 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9664 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9665 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9666 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9667 return Res;
9668}
9669
9670template <typename Derived>
9673 DeclarationNameInfo DirName;
9674 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9675 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9676 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9677 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9678 return Res;
9679}
9680
9681template <typename Derived>
9684 DeclarationNameInfo DirName;
9685 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9686 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9687 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9688 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9689 return Res;
9690}
9691
9692template <typename Derived>
9695 DeclarationNameInfo DirName;
9696 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9697 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9698 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9699 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9700 return Res;
9701}
9702
9703template <typename Derived>
9705 OMPInterchangeDirective *D) {
9706 DeclarationNameInfo DirName;
9707 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9708 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9709 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9710 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9711 return Res;
9712}
9713
9714template <typename Derived>
9717 DeclarationNameInfo DirName;
9718 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9719 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9720 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9721 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9722 return Res;
9723}
9724
9725template <typename Derived>
9728 DeclarationNameInfo DirName;
9729 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9730 OMPD_for, DirName, nullptr, D->getBeginLoc());
9731 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9732 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9733 return Res;
9734}
9735
9736template <typename Derived>
9739 DeclarationNameInfo DirName;
9740 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9741 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
9742 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9743 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9744 return Res;
9745}
9746
9747template <typename Derived>
9750 DeclarationNameInfo DirName;
9751 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9752 OMPD_sections, DirName, nullptr, D->getBeginLoc());
9753 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9754 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9755 return Res;
9756}
9757
9758template <typename Derived>
9761 DeclarationNameInfo DirName;
9762 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9763 OMPD_section, DirName, nullptr, D->getBeginLoc());
9764 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9765 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9766 return Res;
9767}
9768
9769template <typename Derived>
9772 DeclarationNameInfo DirName;
9773 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9774 OMPD_scope, DirName, nullptr, D->getBeginLoc());
9775 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9776 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9777 return Res;
9778}
9779
9780template <typename Derived>
9783 DeclarationNameInfo DirName;
9784 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9785 OMPD_single, DirName, nullptr, D->getBeginLoc());
9786 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9787 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9788 return Res;
9789}
9790
9791template <typename Derived>
9794 DeclarationNameInfo DirName;
9795 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9796 OMPD_master, DirName, nullptr, D->getBeginLoc());
9797 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9798 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9799 return Res;
9800}
9801
9802template <typename Derived>
9805 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9806 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
9807 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9808 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9809 return Res;
9810}
9811
9812template <typename Derived>
9814 OMPParallelForDirective *D) {
9815 DeclarationNameInfo DirName;
9816 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9817 OMPD_parallel_for, DirName, nullptr, D->getBeginLoc());
9818 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9819 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9820 return Res;
9821}
9822
9823template <typename Derived>
9825 OMPParallelForSimdDirective *D) {
9826 DeclarationNameInfo DirName;
9827 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9828 OMPD_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9829 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9830 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9831 return Res;
9832}
9833
9834template <typename Derived>
9836 OMPParallelMasterDirective *D) {
9837 DeclarationNameInfo DirName;
9838 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9839 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
9840 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9841 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9842 return Res;
9843}
9844
9845template <typename Derived>
9847 OMPParallelMaskedDirective *D) {
9848 DeclarationNameInfo DirName;
9849 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9850 OMPD_parallel_masked, DirName, nullptr, D->getBeginLoc());
9851 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9852 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9853 return Res;
9854}
9855
9856template <typename Derived>
9858 OMPParallelSectionsDirective *D) {
9859 DeclarationNameInfo DirName;
9860 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9861 OMPD_parallel_sections, DirName, nullptr, D->getBeginLoc());
9862 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9863 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9864 return Res;
9865}
9866
9867template <typename Derived>
9870 DeclarationNameInfo DirName;
9871 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9872 OMPD_task, DirName, nullptr, D->getBeginLoc());
9873 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9874 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9875 return Res;
9876}
9877
9878template <typename Derived>
9880 OMPTaskyieldDirective *D) {
9881 DeclarationNameInfo DirName;
9882 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9883 OMPD_taskyield, DirName, nullptr, D->getBeginLoc());
9884 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9885 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9886 return Res;
9887}
9888
9889template <typename Derived>
9892 DeclarationNameInfo DirName;
9893 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9894 OMPD_barrier, DirName, nullptr, D->getBeginLoc());
9895 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9896 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9897 return Res;
9898}
9899
9900template <typename Derived>
9903 DeclarationNameInfo DirName;
9904 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9905 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
9906 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9907 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9908 return Res;
9909}
9910
9911template <typename Derived>
9914 DeclarationNameInfo DirName;
9915 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9916 OMPD_assume, DirName, nullptr, D->getBeginLoc());
9917 StmtResult Res = getDerived().TransformOMPInformationalDirective(D);
9918 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9919 return Res;
9920}
9921
9922template <typename Derived>
9925 DeclarationNameInfo DirName;
9926 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9927 OMPD_error, DirName, nullptr, D->getBeginLoc());
9928 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9929 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9930 return Res;
9931}
9932
9933template <typename Derived>
9935 OMPTaskgroupDirective *D) {
9936 DeclarationNameInfo DirName;
9937 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9938 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
9939 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9940 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9941 return Res;
9942}
9943
9944template <typename Derived>
9947 DeclarationNameInfo DirName;
9948 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9949 OMPD_flush, DirName, nullptr, D->getBeginLoc());
9950 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9951 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9952 return Res;
9953}
9954
9955template <typename Derived>
9958 DeclarationNameInfo DirName;
9959 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9960 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
9961 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9962 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9963 return Res;
9964}
9965
9966template <typename Derived>
9969 DeclarationNameInfo DirName;
9970 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9971 OMPD_scan, DirName, nullptr, D->getBeginLoc());
9972 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9973 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9974 return Res;
9975}
9976
9977template <typename Derived>
9980 DeclarationNameInfo DirName;
9981 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9982 OMPD_ordered, DirName, nullptr, D->getBeginLoc());
9983 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9984 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9985 return Res;
9986}
9987
9988template <typename Derived>
9991 DeclarationNameInfo DirName;
9992 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9993 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
9994 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9995 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9996 return Res;
9997}
9998
9999template <typename Derived>
10002 DeclarationNameInfo DirName;
10003 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10004 OMPD_target, DirName, nullptr, D->getBeginLoc());
10005 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10006 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10007 return Res;
10008}
10009
10010template <typename Derived>
10012 OMPTargetDataDirective *D) {
10013 DeclarationNameInfo DirName;
10014 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10015 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
10016 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10017 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10018 return Res;
10019}
10020
10021template <typename Derived>
10023 OMPTargetEnterDataDirective *D) {
10024 DeclarationNameInfo DirName;
10025 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10026 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
10027 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10028 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10029 return Res;
10030}
10031
10032template <typename Derived>
10034 OMPTargetExitDataDirective *D) {
10035 DeclarationNameInfo DirName;
10036 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10037 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
10038 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10039 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10040 return Res;
10041}
10042
10043template <typename Derived>
10045 OMPTargetParallelDirective *D) {
10046 DeclarationNameInfo DirName;
10047 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10048 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
10049 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10050 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10051 return Res;
10052}
10053
10054template <typename Derived>
10056 OMPTargetParallelForDirective *D) {
10057 DeclarationNameInfo DirName;
10058 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10059 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
10060 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10061 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10062 return Res;
10063}
10064
10065template <typename Derived>
10067 OMPTargetUpdateDirective *D) {
10068 DeclarationNameInfo DirName;
10069 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10070 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
10071 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10072 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10073 return Res;
10074}
10075
10076template <typename Derived>
10079 DeclarationNameInfo DirName;
10080 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10081 OMPD_teams, DirName, nullptr, D->getBeginLoc());
10082 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10083 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10084 return Res;
10085}
10086
10087template <typename Derived>
10089 OMPCancellationPointDirective *D) {
10090 DeclarationNameInfo DirName;
10091 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10092 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
10093 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10094 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10095 return Res;
10096}
10097
10098template <typename Derived>
10101 DeclarationNameInfo DirName;
10102 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10103 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
10104 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10105 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10106 return Res;
10107}
10108
10109template <typename Derived>
10112 DeclarationNameInfo DirName;
10113 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10114 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
10115 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10116 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10117 return Res;
10118}
10119
10120template <typename Derived>
10122 OMPTaskLoopSimdDirective *D) {
10123 DeclarationNameInfo DirName;
10124 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10125 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10126 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10127 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10128 return Res;
10129}
10130
10131template <typename Derived>
10133 OMPMasterTaskLoopDirective *D) {
10134 DeclarationNameInfo DirName;
10135 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10136 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
10137 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10138 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10139 return Res;
10140}
10141
10142template <typename Derived>
10144 OMPMaskedTaskLoopDirective *D) {
10145 DeclarationNameInfo DirName;
10146 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10147 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10148 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10149 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10150 return Res;
10151}
10152
10153template <typename Derived>
10155 OMPMasterTaskLoopSimdDirective *D) {
10156 DeclarationNameInfo DirName;
10157 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10158 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10159 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10160 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10161 return Res;
10162}
10163
10164template <typename Derived>
10166 OMPMaskedTaskLoopSimdDirective *D) {
10167 DeclarationNameInfo DirName;
10168 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10169 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10170 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10171 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10172 return Res;
10173}
10174
10175template <typename Derived>
10177 OMPParallelMasterTaskLoopDirective *D) {
10178 DeclarationNameInfo DirName;
10179 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10180 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10181 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10182 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10183 return Res;
10184}
10185
10186template <typename Derived>
10188 OMPParallelMaskedTaskLoopDirective *D) {
10189 DeclarationNameInfo DirName;
10190 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10191 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10192 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10193 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10194 return Res;
10195}
10196
10197template <typename Derived>
10200 OMPParallelMasterTaskLoopSimdDirective *D) {
10201 DeclarationNameInfo DirName;
10202 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10203 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10204 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10205 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10206 return Res;
10207}
10208
10209template <typename Derived>
10212 OMPParallelMaskedTaskLoopSimdDirective *D) {
10213 DeclarationNameInfo DirName;
10214 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10215 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10216 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10217 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10218 return Res;
10219}
10220
10221template <typename Derived>
10223 OMPDistributeDirective *D) {
10224 DeclarationNameInfo DirName;
10225 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10226 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10227 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10228 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10229 return Res;
10230}
10231
10232template <typename Derived>
10234 OMPDistributeParallelForDirective *D) {
10235 DeclarationNameInfo DirName;
10236 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10237 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10238 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10239 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10240 return Res;
10241}
10242
10243template <typename Derived>
10246 OMPDistributeParallelForSimdDirective *D) {
10247 DeclarationNameInfo DirName;
10248 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10249 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10250 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10251 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10252 return Res;
10253}
10254
10255template <typename Derived>
10257 OMPDistributeSimdDirective *D) {
10258 DeclarationNameInfo DirName;
10259 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10260 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
10261 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10262 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10263 return Res;
10264}
10265
10266template <typename Derived>
10268 OMPTargetParallelForSimdDirective *D) {
10269 DeclarationNameInfo DirName;
10270 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10271 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10272 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10273 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10274 return Res;
10275}
10276
10277template <typename Derived>
10279 OMPTargetSimdDirective *D) {
10280 DeclarationNameInfo DirName;
10281 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10282 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
10283 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10284 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10285 return Res;
10286}
10287
10288template <typename Derived>
10290 OMPTeamsDistributeDirective *D) {
10291 DeclarationNameInfo DirName;
10292 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10293 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10294 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10295 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10296 return Res;
10297}
10298
10299template <typename Derived>
10301 OMPTeamsDistributeSimdDirective *D) {
10302 DeclarationNameInfo DirName;
10303 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10304 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10305 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10306 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10307 return Res;
10308}
10309
10310template <typename Derived>
10312 OMPTeamsDistributeParallelForSimdDirective *D) {
10313 DeclarationNameInfo DirName;
10314 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10315 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10316 D->getBeginLoc());
10317 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10318 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10319 return Res;
10320}
10321
10322template <typename Derived>
10324 OMPTeamsDistributeParallelForDirective *D) {
10325 DeclarationNameInfo DirName;
10326 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10327 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10328 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10329 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10330 return Res;
10331}
10332
10333template <typename Derived>
10335 OMPTargetTeamsDirective *D) {
10336 DeclarationNameInfo DirName;
10337 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10338 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10339 auto Res = getDerived().TransformOMPExecutableDirective(D);
10340 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10341 return Res;
10342}
10343
10344template <typename Derived>
10346 OMPTargetTeamsDistributeDirective *D) {
10347 DeclarationNameInfo DirName;
10348 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10349 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10350 auto Res = getDerived().TransformOMPExecutableDirective(D);
10351 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10352 return Res;
10353}
10354
10355template <typename Derived>
10358 OMPTargetTeamsDistributeParallelForDirective *D) {
10359 DeclarationNameInfo DirName;
10360 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10361 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10362 D->getBeginLoc());
10363 auto Res = getDerived().TransformOMPExecutableDirective(D);
10364 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10365 return Res;
10366}
10367
10368template <typename Derived>
10371 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10372 DeclarationNameInfo DirName;
10373 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10374 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10375 D->getBeginLoc());
10376 auto Res = getDerived().TransformOMPExecutableDirective(D);
10377 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10378 return Res;
10379}
10380
10381template <typename Derived>
10384 OMPTargetTeamsDistributeSimdDirective *D) {
10385 DeclarationNameInfo DirName;
10386 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10387 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10388 auto Res = getDerived().TransformOMPExecutableDirective(D);
10389 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10390 return Res;
10391}
10392
10393template <typename Derived>
10396 DeclarationNameInfo DirName;
10397 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10398 OMPD_interop, DirName, nullptr, D->getBeginLoc());
10399 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10400 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10401 return Res;
10402}
10403
10404template <typename Derived>
10407 DeclarationNameInfo DirName;
10408 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10409 OMPD_dispatch, DirName, nullptr, D->getBeginLoc());
10410 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10411 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10412 return Res;
10413}
10414
10415template <typename Derived>
10418 DeclarationNameInfo DirName;
10419 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10420 OMPD_masked, DirName, nullptr, D->getBeginLoc());
10421 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10422 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10423 return Res;
10424}
10425
10426template <typename Derived>
10428 OMPGenericLoopDirective *D) {
10429 DeclarationNameInfo DirName;
10430 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10431 OMPD_loop, DirName, nullptr, D->getBeginLoc());
10432 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10433 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10434 return Res;
10435}
10436
10437template <typename Derived>
10439 OMPTeamsGenericLoopDirective *D) {
10440 DeclarationNameInfo DirName;
10441 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10442 OMPD_teams_loop, DirName, nullptr, D->getBeginLoc());
10443 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10444 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10445 return Res;
10446}
10447
10448template <typename Derived>
10450 OMPTargetTeamsGenericLoopDirective *D) {
10451 DeclarationNameInfo DirName;
10452 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10453 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
10454 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10455 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10456 return Res;
10457}
10458
10459template <typename Derived>
10461 OMPParallelGenericLoopDirective *D) {
10462 DeclarationNameInfo DirName;
10463 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10464 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
10465 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10466 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10467 return Res;
10468}
10469
10470template <typename Derived>
10473 OMPTargetParallelGenericLoopDirective *D) {
10474 DeclarationNameInfo DirName;
10475 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10476 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10477 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10478 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10479 return Res;
10480}
10481
10482//===----------------------------------------------------------------------===//
10483// OpenMP clause transformation
10484//===----------------------------------------------------------------------===//
10485template <typename Derived>
10487 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10488 if (Cond.isInvalid())
10489 return nullptr;
10490 return getDerived().RebuildOMPIfClause(
10491 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10492 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10493}
10494
10495template <typename Derived>
10497 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10498 if (Cond.isInvalid())
10499 return nullptr;
10500 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10501 C->getLParenLoc(), C->getEndLoc());
10502}
10503
10504template <typename Derived>
10505OMPClause *
10507 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
10508 if (NumThreads.isInvalid())
10509 return nullptr;
10510 return getDerived().RebuildOMPNumThreadsClause(
10511 C->getModifier(), NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(),
10512 C->getModifierLoc(), C->getEndLoc());
10513}
10514
10515template <typename Derived>
10516OMPClause *
10518 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10519 if (E.isInvalid())
10520 return nullptr;
10521 return getDerived().RebuildOMPSafelenClause(
10522 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10523}
10524
10525template <typename Derived>
10526OMPClause *
10528 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10529 if (E.isInvalid())
10530 return nullptr;
10531 return getDerived().RebuildOMPAllocatorClause(
10532 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10533}
10534
10535template <typename Derived>
10536OMPClause *
10538 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
10539 if (E.isInvalid())
10540 return nullptr;
10541 return getDerived().RebuildOMPSimdlenClause(
10542 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10543}
10544
10545template <typename Derived>
10547 SmallVector<Expr *, 4> TransformedSizes;
10548 TransformedSizes.reserve(C->getNumSizes());
10549 bool Changed = false;
10550 for (Expr *E : C->getSizesRefs()) {
10551 if (!E) {
10552 TransformedSizes.push_back(nullptr);
10553 continue;
10554 }
10555
10556 ExprResult T = getDerived().TransformExpr(E);
10557 if (T.isInvalid())
10558 return nullptr;
10559 if (E != T.get())
10560 Changed = true;
10561 TransformedSizes.push_back(T.get());
10562 }
10563
10564 if (!Changed && !getDerived().AlwaysRebuild())
10565 return C;
10566 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
10567 C->getLParenLoc(), C->getEndLoc());
10568}
10569
10570template <typename Derived>
10571OMPClause *
10573 SmallVector<Expr *> TransformedArgs;
10574 TransformedArgs.reserve(C->getNumLoops());
10575 bool Changed = false;
10576 for (Expr *E : C->getArgsRefs()) {
10577 if (!E) {
10578 TransformedArgs.push_back(nullptr);
10579 continue;
10580 }
10581
10582 ExprResult T = getDerived().TransformExpr(E);
10583 if (T.isInvalid())
10584 return nullptr;
10585 if (E != T.get())
10586 Changed = true;
10587 TransformedArgs.push_back(T.get());
10588 }
10589
10590 if (!Changed && !getDerived().AlwaysRebuild())
10591 return C;
10592 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
10593 C->getLParenLoc(), C->getEndLoc());
10594}
10595
10596template <typename Derived>
10598 if (!getDerived().AlwaysRebuild())
10599 return C;
10600 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10601}
10602
10603template <typename Derived>
10604OMPClause *
10606 ExprResult T = getDerived().TransformExpr(C->getFactor());
10607 if (T.isInvalid())
10608 return nullptr;
10609 Expr *Factor = T.get();
10610 bool Changed = Factor != C->getFactor();
10611
10612 if (!Changed && !getDerived().AlwaysRebuild())
10613 return C;
10614 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10615 C->getEndLoc());
10616}
10617
10618template <typename Derived>
10619OMPClause *
10621 ExprResult F = getDerived().TransformExpr(C->getFirst());
10622 if (F.isInvalid())
10623 return nullptr;
10624
10625 ExprResult Cn = getDerived().TransformExpr(C->getCount());
10626 if (Cn.isInvalid())
10627 return nullptr;
10628
10629 Expr *First = F.get();
10630 Expr *Count = Cn.get();
10631
10632 bool Changed = (First != C->getFirst()) || (Count != C->getCount());
10633
10634 // If no changes and AlwaysRebuild() is false, return the original clause
10635 if (!Changed && !getDerived().AlwaysRebuild())
10636 return C;
10637
10638 return RebuildOMPLoopRangeClause(First, Count, C->getBeginLoc(),
10639 C->getLParenLoc(), C->getFirstLoc(),
10640 C->getCountLoc(), C->getEndLoc());
10641}
10642
10643template <typename Derived>
10644OMPClause *
10646 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10647 if (E.isInvalid())
10648 return nullptr;
10649 return getDerived().RebuildOMPCollapseClause(
10650 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10651}
10652
10653template <typename Derived>
10654OMPClause *
10656 return getDerived().RebuildOMPDefaultClause(
10657 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getDefaultVC(),
10658 C->getDefaultVCLoc(), C->getBeginLoc(), C->getLParenLoc(),
10659 C->getEndLoc());
10660}
10661
10662template <typename Derived>
10663OMPClause *
10665 // No need to rebuild this clause, no template-dependent parameters.
10666 return C;
10667}
10668
10669template <typename Derived>
10670OMPClause *
10672 return getDerived().RebuildOMPProcBindClause(
10673 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10674 C->getLParenLoc(), C->getEndLoc());
10675}
10676
10677template <typename Derived>
10678OMPClause *
10680 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10681 if (E.isInvalid())
10682 return nullptr;
10683 return getDerived().RebuildOMPScheduleClause(
10684 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10685 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10686 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10687 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10688}
10689
10690template <typename Derived>
10691OMPClause *
10693 ExprResult E;
10694 if (auto *Num = C->getNumForLoops()) {
10695 E = getDerived().TransformExpr(Num);
10696 if (E.isInvalid())
10697 return nullptr;
10698 }
10699 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10700 C->getLParenLoc(), E.get());
10701}
10702
10703template <typename Derived>
10704OMPClause *
10706 ExprResult E;
10707 if (Expr *Evt = C->getEventHandler()) {
10708 E = getDerived().TransformExpr(Evt);
10709 if (E.isInvalid())
10710 return nullptr;
10711 }
10712 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10713 C->getLParenLoc(), C->getEndLoc());
10714}
10715
10716template <typename Derived>
10717OMPClause *
10720 if (auto *Condition = C->getCondition()) {
10721 Cond = getDerived().TransformExpr(Condition);
10722 if (Cond.isInvalid())
10723 return nullptr;
10724 }
10725 return getDerived().RebuildOMPNowaitClause(Cond.get(), C->getBeginLoc(),
10726 C->getLParenLoc(), C->getEndLoc());
10727}
10728
10729template <typename Derived>
10730OMPClause *
10732 // No need to rebuild this clause, no template-dependent parameters.
10733 return C;
10734}
10735
10736template <typename Derived>
10737OMPClause *
10739 // No need to rebuild this clause, no template-dependent parameters.
10740 return C;
10741}
10742
10743template <typename Derived>
10745 // No need to rebuild this clause, no template-dependent parameters.
10746 return C;
10747}
10748
10749template <typename Derived>
10751 // No need to rebuild this clause, no template-dependent parameters.
10752 return C;
10753}
10754
10755template <typename Derived>
10756OMPClause *
10758 // No need to rebuild this clause, no template-dependent parameters.
10759 return C;
10760}
10761
10762template <typename Derived>
10763OMPClause *
10765 // No need to rebuild this clause, no template-dependent parameters.
10766 return C;
10767}
10768
10769template <typename Derived>
10770OMPClause *
10772 // No need to rebuild this clause, no template-dependent parameters.
10773 return C;
10774}
10775
10776template <typename Derived>
10778 // No need to rebuild this clause, no template-dependent parameters.
10779 return C;
10780}
10781
10782template <typename Derived>
10783OMPClause *
10785 return C;
10786}
10787
10788template <typename Derived>
10790 ExprResult E = getDerived().TransformExpr(C->getExpr());
10791 if (E.isInvalid())
10792 return nullptr;
10793 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
10794 C->getLParenLoc(), C->getEndLoc());
10795}
10796
10797template <typename Derived>
10798OMPClause *
10800 return C;
10801}
10802
10803template <typename Derived>
10804OMPClause *
10806 return C;
10807}
10808template <typename Derived>
10811 return C;
10812}
10813template <typename Derived>
10816 return C;
10817}
10818template <typename Derived>
10821 return C;
10822}
10823
10824template <typename Derived>
10825OMPClause *
10827 // No need to rebuild this clause, no template-dependent parameters.
10828 return C;
10829}
10830
10831template <typename Derived>
10832OMPClause *
10834 // No need to rebuild this clause, no template-dependent parameters.
10835 return C;
10836}
10837
10838template <typename Derived>
10839OMPClause *
10841 // No need to rebuild this clause, no template-dependent parameters.
10842 return C;
10843}
10844
10845template <typename Derived>
10846OMPClause *
10848 // No need to rebuild this clause, no template-dependent parameters.
10849 return C;
10850}
10851
10852template <typename Derived>
10853OMPClause *
10855 // No need to rebuild this clause, no template-dependent parameters.
10856 return C;
10857}
10858
10859template <typename Derived>
10861 // No need to rebuild this clause, no template-dependent parameters.
10862 return C;
10863}
10864
10865template <typename Derived>
10866OMPClause *
10868 // No need to rebuild this clause, no template-dependent parameters.
10869 return C;
10870}
10871
10872template <typename Derived>
10874 // No need to rebuild this clause, no template-dependent parameters.
10875 return C;
10876}
10877
10878template <typename Derived>
10879OMPClause *
10881 // No need to rebuild this clause, no template-dependent parameters.
10882 return C;
10883}
10884
10885template <typename Derived>
10887 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
10888 if (IVR.isInvalid())
10889 return nullptr;
10890
10891 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
10892 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
10893 for (Expr *E : llvm::drop_begin(C->varlist())) {
10894 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
10895 if (ER.isInvalid())
10896 return nullptr;
10897 InteropInfo.PreferTypes.push_back(ER.get());
10898 }
10899 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
10900 C->getBeginLoc(), C->getLParenLoc(),
10901 C->getVarLoc(), C->getEndLoc());
10902}
10903
10904template <typename Derived>
10906 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
10907 if (ER.isInvalid())
10908 return nullptr;
10909 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
10910 C->getLParenLoc(), C->getVarLoc(),
10911 C->getEndLoc());
10912}
10913
10914template <typename Derived>
10915OMPClause *
10917 ExprResult ER;
10918 if (Expr *IV = C->getInteropVar()) {
10919 ER = getDerived().TransformExpr(IV);
10920 if (ER.isInvalid())
10921 return nullptr;
10922 }
10923 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
10924 C->getLParenLoc(), C->getVarLoc(),
10925 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().RebuildOMPNovariantsClause(
10935 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10936}
10937
10938template <typename Derived>
10939OMPClause *
10941 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10942 if (Cond.isInvalid())
10943 return nullptr;
10944 return getDerived().RebuildOMPNocontextClause(
10945 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10946}
10947
10948template <typename Derived>
10949OMPClause *
10951 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
10952 if (ThreadID.isInvalid())
10953 return nullptr;
10954 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
10955 C->getLParenLoc(), C->getEndLoc());
10956}
10957
10958template <typename Derived>
10960 ExprResult E = getDerived().TransformExpr(C->getAlignment());
10961 if (E.isInvalid())
10962 return nullptr;
10963 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
10964 C->getLParenLoc(), C->getEndLoc());
10965}
10966
10967template <typename Derived>
10970 llvm_unreachable("unified_address clause cannot appear in dependent context");
10971}
10972
10973template <typename Derived>
10976 llvm_unreachable(
10977 "unified_shared_memory clause cannot appear in dependent context");
10978}
10979
10980template <typename Derived>
10983 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
10984}
10985
10986template <typename Derived>
10989 llvm_unreachable(
10990 "dynamic_allocators clause cannot appear in dependent context");
10991}
10992
10993template <typename Derived>
10996 llvm_unreachable(
10997 "atomic_default_mem_order clause cannot appear in dependent context");
10998}
10999
11000template <typename Derived>
11001OMPClause *
11003 llvm_unreachable("self_maps clause cannot appear in dependent context");
11004}
11005
11006template <typename Derived>
11008 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
11009 C->getBeginLoc(), C->getLParenLoc(),
11010 C->getEndLoc());
11011}
11012
11013template <typename Derived>
11014OMPClause *
11016 return getDerived().RebuildOMPSeverityClause(
11017 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
11018 C->getLParenLoc(), C->getEndLoc());
11019}
11020
11021template <typename Derived>
11022OMPClause *
11024 ExprResult E = getDerived().TransformExpr(C->getMessageString());
11025 if (E.isInvalid())
11026 return nullptr;
11027 return getDerived().RebuildOMPMessageClause(
11028 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11029}
11030
11031template <typename Derived>
11032OMPClause *
11035 Vars.reserve(C->varlist_size());
11036 for (auto *VE : C->varlist()) {
11037 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11038 if (EVar.isInvalid())
11039 return nullptr;
11040 Vars.push_back(EVar.get());
11041 }
11042 return getDerived().RebuildOMPPrivateClause(
11043 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11044}
11045
11046template <typename Derived>
11050 Vars.reserve(C->varlist_size());
11051 for (auto *VE : C->varlist()) {
11052 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11053 if (EVar.isInvalid())
11054 return nullptr;
11055 Vars.push_back(EVar.get());
11056 }
11057 return getDerived().RebuildOMPFirstprivateClause(
11058 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11059}
11060
11061template <typename Derived>
11062OMPClause *
11065 Vars.reserve(C->varlist_size());
11066 for (auto *VE : C->varlist()) {
11067 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11068 if (EVar.isInvalid())
11069 return nullptr;
11070 Vars.push_back(EVar.get());
11071 }
11072 return getDerived().RebuildOMPLastprivateClause(
11073 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11074 C->getLParenLoc(), C->getEndLoc());
11075}
11076
11077template <typename Derived>
11078OMPClause *
11081 Vars.reserve(C->varlist_size());
11082 for (auto *VE : C->varlist()) {
11083 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11084 if (EVar.isInvalid())
11085 return nullptr;
11086 Vars.push_back(EVar.get());
11087 }
11088 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11089 C->getLParenLoc(), C->getEndLoc());
11090}
11091
11092template <typename Derived>
11093OMPClause *
11096 Vars.reserve(C->varlist_size());
11097 for (auto *VE : C->varlist()) {
11098 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11099 if (EVar.isInvalid())
11100 return nullptr;
11101 Vars.push_back(EVar.get());
11102 }
11103 CXXScopeSpec ReductionIdScopeSpec;
11104 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11105
11106 DeclarationNameInfo NameInfo = C->getNameInfo();
11107 if (NameInfo.getName()) {
11108 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11109 if (!NameInfo.getName())
11110 return nullptr;
11111 }
11112 // Build a list of all UDR decls with the same names ranged by the Scopes.
11113 // The Scope boundary is a duplication of the previous decl.
11114 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11115 for (auto *E : C->reduction_ops()) {
11116 // Transform all the decls.
11117 if (E) {
11118 auto *ULE = cast<UnresolvedLookupExpr>(E);
11119 UnresolvedSet<8> Decls;
11120 for (auto *D : ULE->decls()) {
11121 NamedDecl *InstD =
11122 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11123 Decls.addDecl(InstD, InstD->getAccess());
11124 }
11125 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11126 SemaRef.Context, /*NamingClass=*/nullptr,
11127 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11128 /*ADL=*/true, Decls.begin(), Decls.end(),
11129 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11130 } else
11131 UnresolvedReductions.push_back(nullptr);
11132 }
11133 return getDerived().RebuildOMPReductionClause(
11134 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11135 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11136 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11137}
11138
11139template <typename Derived>
11143 Vars.reserve(C->varlist_size());
11144 for (auto *VE : C->varlist()) {
11145 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11146 if (EVar.isInvalid())
11147 return nullptr;
11148 Vars.push_back(EVar.get());
11149 }
11150 CXXScopeSpec ReductionIdScopeSpec;
11151 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11152
11153 DeclarationNameInfo NameInfo = C->getNameInfo();
11154 if (NameInfo.getName()) {
11155 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11156 if (!NameInfo.getName())
11157 return nullptr;
11158 }
11159 // Build a list of all UDR decls with the same names ranged by the Scopes.
11160 // The Scope boundary is a duplication of the previous decl.
11161 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11162 for (auto *E : C->reduction_ops()) {
11163 // Transform all the decls.
11164 if (E) {
11165 auto *ULE = cast<UnresolvedLookupExpr>(E);
11166 UnresolvedSet<8> Decls;
11167 for (auto *D : ULE->decls()) {
11168 NamedDecl *InstD =
11169 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11170 Decls.addDecl(InstD, InstD->getAccess());
11171 }
11172 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11173 SemaRef.Context, /*NamingClass=*/nullptr,
11174 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11175 /*ADL=*/true, Decls.begin(), Decls.end(),
11176 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11177 } else
11178 UnresolvedReductions.push_back(nullptr);
11179 }
11180 return getDerived().RebuildOMPTaskReductionClause(
11181 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11182 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11183}
11184
11185template <typename Derived>
11186OMPClause *
11189 Vars.reserve(C->varlist_size());
11190 for (auto *VE : C->varlist()) {
11191 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11192 if (EVar.isInvalid())
11193 return nullptr;
11194 Vars.push_back(EVar.get());
11195 }
11196 CXXScopeSpec ReductionIdScopeSpec;
11197 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11198
11199 DeclarationNameInfo NameInfo = C->getNameInfo();
11200 if (NameInfo.getName()) {
11201 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11202 if (!NameInfo.getName())
11203 return nullptr;
11204 }
11205 // Build a list of all UDR decls with the same names ranged by the Scopes.
11206 // The Scope boundary is a duplication of the previous decl.
11207 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11208 for (auto *E : C->reduction_ops()) {
11209 // Transform all the decls.
11210 if (E) {
11211 auto *ULE = cast<UnresolvedLookupExpr>(E);
11212 UnresolvedSet<8> Decls;
11213 for (auto *D : ULE->decls()) {
11214 NamedDecl *InstD =
11215 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11216 Decls.addDecl(InstD, InstD->getAccess());
11217 }
11218 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11219 SemaRef.Context, /*NamingClass=*/nullptr,
11220 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11221 /*ADL=*/true, Decls.begin(), Decls.end(),
11222 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11223 } else
11224 UnresolvedReductions.push_back(nullptr);
11225 }
11226 return getDerived().RebuildOMPInReductionClause(
11227 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11228 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11229}
11230
11231template <typename Derived>
11232OMPClause *
11235 Vars.reserve(C->varlist_size());
11236 for (auto *VE : C->varlist()) {
11237 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11238 if (EVar.isInvalid())
11239 return nullptr;
11240 Vars.push_back(EVar.get());
11241 }
11242 ExprResult Step = getDerived().TransformExpr(C->getStep());
11243 if (Step.isInvalid())
11244 return nullptr;
11245 return getDerived().RebuildOMPLinearClause(
11246 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11247 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11248 C->getEndLoc());
11249}
11250
11251template <typename Derived>
11252OMPClause *
11255 Vars.reserve(C->varlist_size());
11256 for (auto *VE : C->varlist()) {
11257 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11258 if (EVar.isInvalid())
11259 return nullptr;
11260 Vars.push_back(EVar.get());
11261 }
11262 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11263 if (Alignment.isInvalid())
11264 return nullptr;
11265 return getDerived().RebuildOMPAlignedClause(
11266 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11267 C->getColonLoc(), C->getEndLoc());
11268}
11269
11270template <typename Derived>
11271OMPClause *
11274 Vars.reserve(C->varlist_size());
11275 for (auto *VE : C->varlist()) {
11276 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11277 if (EVar.isInvalid())
11278 return nullptr;
11279 Vars.push_back(EVar.get());
11280 }
11281 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11282 C->getLParenLoc(), C->getEndLoc());
11283}
11284
11285template <typename Derived>
11286OMPClause *
11289 Vars.reserve(C->varlist_size());
11290 for (auto *VE : C->varlist()) {
11291 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11292 if (EVar.isInvalid())
11293 return nullptr;
11294 Vars.push_back(EVar.get());
11295 }
11296 return getDerived().RebuildOMPCopyprivateClause(
11297 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11298}
11299
11300template <typename Derived>
11303 Vars.reserve(C->varlist_size());
11304 for (auto *VE : C->varlist()) {
11305 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11306 if (EVar.isInvalid())
11307 return nullptr;
11308 Vars.push_back(EVar.get());
11309 }
11310 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11311 C->getLParenLoc(), C->getEndLoc());
11312}
11313
11314template <typename Derived>
11315OMPClause *
11317 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11318 if (E.isInvalid())
11319 return nullptr;
11320 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11321 C->getLParenLoc(), C->getEndLoc());
11322}
11323
11324template <typename Derived>
11325OMPClause *
11328 Expr *DepModifier = C->getModifier();
11329 if (DepModifier) {
11330 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11331 if (DepModRes.isInvalid())
11332 return nullptr;
11333 DepModifier = DepModRes.get();
11334 }
11335 Vars.reserve(C->varlist_size());
11336 for (auto *VE : C->varlist()) {
11337 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11338 if (EVar.isInvalid())
11339 return nullptr;
11340 Vars.push_back(EVar.get());
11341 }
11342 return getDerived().RebuildOMPDependClause(
11343 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11344 C->getOmpAllMemoryLoc()},
11345 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11346}
11347
11348template <typename Derived>
11349OMPClause *
11351 ExprResult E = getDerived().TransformExpr(C->getDevice());
11352 if (E.isInvalid())
11353 return nullptr;
11354 return getDerived().RebuildOMPDeviceClause(
11355 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11356 C->getModifierLoc(), C->getEndLoc());
11357}
11358
11359template <typename Derived, class T>
11362 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11363 DeclarationNameInfo &MapperIdInfo,
11364 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11365 // Transform expressions in the list.
11366 Vars.reserve(C->varlist_size());
11367 for (auto *VE : C->varlist()) {
11368 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11369 if (EVar.isInvalid())
11370 return true;
11371 Vars.push_back(EVar.get());
11372 }
11373 // Transform mapper scope specifier and identifier.
11374 NestedNameSpecifierLoc QualifierLoc;
11375 if (C->getMapperQualifierLoc()) {
11376 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11377 C->getMapperQualifierLoc());
11378 if (!QualifierLoc)
11379 return true;
11380 }
11381 MapperIdScopeSpec.Adopt(QualifierLoc);
11382 MapperIdInfo = C->getMapperIdInfo();
11383 if (MapperIdInfo.getName()) {
11384 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11385 if (!MapperIdInfo.getName())
11386 return true;
11387 }
11388 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11389 // the previous user-defined mapper lookup in dependent environment.
11390 for (auto *E : C->mapperlists()) {
11391 // Transform all the decls.
11392 if (E) {
11393 auto *ULE = cast<UnresolvedLookupExpr>(E);
11394 UnresolvedSet<8> Decls;
11395 for (auto *D : ULE->decls()) {
11396 NamedDecl *InstD =
11397 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11398 Decls.addDecl(InstD, InstD->getAccess());
11399 }
11400 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11401 TT.getSema().Context, /*NamingClass=*/nullptr,
11402 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11403 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11404 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11405 } else {
11406 UnresolvedMappers.push_back(nullptr);
11407 }
11408 }
11409 return false;
11410}
11411
11412template <typename Derived>
11413OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11414 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11416 Expr *IteratorModifier = C->getIteratorModifier();
11417 if (IteratorModifier) {
11418 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11419 if (MapModRes.isInvalid())
11420 return nullptr;
11421 IteratorModifier = MapModRes.get();
11422 }
11423 CXXScopeSpec MapperIdScopeSpec;
11424 DeclarationNameInfo MapperIdInfo;
11425 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11427 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11428 return nullptr;
11429 return getDerived().RebuildOMPMapClause(
11430 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11431 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11432 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11433}
11434
11435template <typename Derived>
11436OMPClause *
11438 Expr *Allocator = C->getAllocator();
11439 if (Allocator) {
11440 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11441 if (AllocatorRes.isInvalid())
11442 return nullptr;
11443 Allocator = AllocatorRes.get();
11444 }
11445 Expr *Alignment = C->getAlignment();
11446 if (Alignment) {
11447 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11448 if (AlignmentRes.isInvalid())
11449 return nullptr;
11450 Alignment = AlignmentRes.get();
11451 }
11453 Vars.reserve(C->varlist_size());
11454 for (auto *VE : C->varlist()) {
11455 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11456 if (EVar.isInvalid())
11457 return nullptr;
11458 Vars.push_back(EVar.get());
11459 }
11460 return getDerived().RebuildOMPAllocateClause(
11461 Allocator, Alignment, C->getFirstAllocateModifier(),
11462 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11463 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11464 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11465}
11466
11467template <typename Derived>
11468OMPClause *
11471 Vars.reserve(C->varlist_size());
11472 for (auto *VE : C->varlist()) {
11473 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11474 if (EVar.isInvalid())
11475 return nullptr;
11476 Vars.push_back(EVar.get());
11477 }
11478 return getDerived().RebuildOMPNumTeamsClause(
11479 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11480}
11481
11482template <typename Derived>
11483OMPClause *
11486 Vars.reserve(C->varlist_size());
11487 for (auto *VE : C->varlist()) {
11488 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11489 if (EVar.isInvalid())
11490 return nullptr;
11491 Vars.push_back(EVar.get());
11492 }
11493 return getDerived().RebuildOMPThreadLimitClause(
11494 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11495}
11496
11497template <typename Derived>
11498OMPClause *
11500 ExprResult E = getDerived().TransformExpr(C->getPriority());
11501 if (E.isInvalid())
11502 return nullptr;
11503 return getDerived().RebuildOMPPriorityClause(
11504 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11505}
11506
11507template <typename Derived>
11508OMPClause *
11510 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11511 if (E.isInvalid())
11512 return nullptr;
11513 return getDerived().RebuildOMPGrainsizeClause(
11514 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11515 C->getModifierLoc(), C->getEndLoc());
11516}
11517
11518template <typename Derived>
11519OMPClause *
11521 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11522 if (E.isInvalid())
11523 return nullptr;
11524 return getDerived().RebuildOMPNumTasksClause(
11525 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11526 C->getModifierLoc(), C->getEndLoc());
11527}
11528
11529template <typename Derived>
11531 ExprResult E = getDerived().TransformExpr(C->getHint());
11532 if (E.isInvalid())
11533 return nullptr;
11534 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11535 C->getLParenLoc(), C->getEndLoc());
11536}
11537
11538template <typename Derived>
11541 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11542 if (E.isInvalid())
11543 return nullptr;
11544 return getDerived().RebuildOMPDistScheduleClause(
11545 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11546 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11547}
11548
11549template <typename Derived>
11550OMPClause *
11552 // Rebuild Defaultmap Clause since we need to invoke the checking of
11553 // defaultmap(none:variable-category) after template initialization.
11554 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11555 C->getDefaultmapKind(),
11556 C->getBeginLoc(),
11557 C->getLParenLoc(),
11558 C->getDefaultmapModifierLoc(),
11559 C->getDefaultmapKindLoc(),
11560 C->getEndLoc());
11561}
11562
11563template <typename Derived>
11565 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11567 Expr *IteratorModifier = C->getIteratorModifier();
11568 if (IteratorModifier) {
11569 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11570 if (MapModRes.isInvalid())
11571 return nullptr;
11572 IteratorModifier = MapModRes.get();
11573 }
11574 CXXScopeSpec MapperIdScopeSpec;
11575 DeclarationNameInfo MapperIdInfo;
11576 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11578 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11579 return nullptr;
11580 return getDerived().RebuildOMPToClause(
11581 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11582 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11583 UnresolvedMappers);
11584}
11585
11586template <typename Derived>
11588 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11590 Expr *IteratorModifier = C->getIteratorModifier();
11591 if (IteratorModifier) {
11592 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11593 if (MapModRes.isInvalid())
11594 return nullptr;
11595 IteratorModifier = MapModRes.get();
11596 }
11597 CXXScopeSpec MapperIdScopeSpec;
11598 DeclarationNameInfo MapperIdInfo;
11599 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11601 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11602 return nullptr;
11603 return getDerived().RebuildOMPFromClause(
11604 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11605 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11606 UnresolvedMappers);
11607}
11608
11609template <typename Derived>
11613 Vars.reserve(C->varlist_size());
11614 for (auto *VE : C->varlist()) {
11615 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11616 if (EVar.isInvalid())
11617 return nullptr;
11618 Vars.push_back(EVar.get());
11619 }
11620 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11621 return getDerived().RebuildOMPUseDevicePtrClause(Vars, Locs);
11622}
11623
11624template <typename Derived>
11628 Vars.reserve(C->varlist_size());
11629 for (auto *VE : C->varlist()) {
11630 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11631 if (EVar.isInvalid())
11632 return nullptr;
11633 Vars.push_back(EVar.get());
11634 }
11635 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11636 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11637}
11638
11639template <typename Derived>
11640OMPClause *
11643 Vars.reserve(C->varlist_size());
11644 for (auto *VE : C->varlist()) {
11645 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11646 if (EVar.isInvalid())
11647 return nullptr;
11648 Vars.push_back(EVar.get());
11649 }
11650 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11651 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11652}
11653
11654template <typename Derived>
11658 Vars.reserve(C->varlist_size());
11659 for (auto *VE : C->varlist()) {
11660 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11661 if (EVar.isInvalid())
11662 return nullptr;
11663 Vars.push_back(EVar.get());
11664 }
11665 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11666 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11667}
11668
11669template <typename Derived>
11670OMPClause *
11673 Vars.reserve(C->varlist_size());
11674 for (auto *VE : C->varlist()) {
11675 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11676 if (EVar.isInvalid())
11677 return nullptr;
11678 Vars.push_back(EVar.get());
11679 }
11680 return getDerived().RebuildOMPNontemporalClause(
11681 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11682}
11683
11684template <typename Derived>
11685OMPClause *
11688 Vars.reserve(C->varlist_size());
11689 for (auto *VE : C->varlist()) {
11690 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11691 if (EVar.isInvalid())
11692 return nullptr;
11693 Vars.push_back(EVar.get());
11694 }
11695 return getDerived().RebuildOMPInclusiveClause(
11696 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11697}
11698
11699template <typename Derived>
11700OMPClause *
11703 Vars.reserve(C->varlist_size());
11704 for (auto *VE : C->varlist()) {
11705 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11706 if (EVar.isInvalid())
11707 return nullptr;
11708 Vars.push_back(EVar.get());
11709 }
11710 return getDerived().RebuildOMPExclusiveClause(
11711 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11712}
11713
11714template <typename Derived>
11718 Data.reserve(C->getNumberOfAllocators());
11719 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11720 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11721 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11722 if (Allocator.isInvalid())
11723 continue;
11724 ExprResult AllocatorTraits;
11725 if (Expr *AT = D.AllocatorTraits) {
11726 AllocatorTraits = getDerived().TransformExpr(AT);
11727 if (AllocatorTraits.isInvalid())
11728 continue;
11729 }
11730 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11731 NewD.Allocator = Allocator.get();
11732 NewD.AllocatorTraits = AllocatorTraits.get();
11733 NewD.LParenLoc = D.LParenLoc;
11734 NewD.RParenLoc = D.RParenLoc;
11735 }
11736 return getDerived().RebuildOMPUsesAllocatorsClause(
11737 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11738}
11739
11740template <typename Derived>
11741OMPClause *
11743 SmallVector<Expr *, 4> Locators;
11744 Locators.reserve(C->varlist_size());
11745 ExprResult ModifierRes;
11746 if (Expr *Modifier = C->getModifier()) {
11747 ModifierRes = getDerived().TransformExpr(Modifier);
11748 if (ModifierRes.isInvalid())
11749 return nullptr;
11750 }
11751 for (Expr *E : C->varlist()) {
11752 ExprResult Locator = getDerived().TransformExpr(E);
11753 if (Locator.isInvalid())
11754 continue;
11755 Locators.push_back(Locator.get());
11756 }
11757 return getDerived().RebuildOMPAffinityClause(
11758 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11759 ModifierRes.get(), Locators);
11760}
11761
11762template <typename Derived>
11764 return getDerived().RebuildOMPOrderClause(
11765 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11766 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11767}
11768
11769template <typename Derived>
11771 return getDerived().RebuildOMPBindClause(
11772 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11773 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().RebuildOMPXDynCGroupMemClause(
11783 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11784}
11785
11786template <typename Derived>
11789 ExprResult Size = getDerived().TransformExpr(C->getSize());
11790 if (Size.isInvalid())
11791 return nullptr;
11792 return getDerived().RebuildOMPDynGroupprivateClause(
11793 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
11794 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
11795 C->getDynGroupprivateModifierLoc(),
11796 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
11797}
11798
11799template <typename Derived>
11800OMPClause *
11803 Vars.reserve(C->varlist_size());
11804 for (auto *VE : C->varlist()) {
11805 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11806 if (EVar.isInvalid())
11807 return nullptr;
11808 Vars.push_back(EVar.get());
11809 }
11810 return getDerived().RebuildOMPDoacrossClause(
11811 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11812 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11813}
11814
11815template <typename Derived>
11816OMPClause *
11819 for (auto *A : C->getAttrs())
11820 NewAttrs.push_back(getDerived().TransformAttr(A));
11821 return getDerived().RebuildOMPXAttributeClause(
11822 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11823}
11824
11825template <typename Derived>
11827 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11828}
11829
11830//===----------------------------------------------------------------------===//
11831// OpenACC transformation
11832//===----------------------------------------------------------------------===//
11833namespace {
11834template <typename Derived>
11835class OpenACCClauseTransform final
11836 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11837 TreeTransform<Derived> &Self;
11838 ArrayRef<const OpenACCClause *> ExistingClauses;
11839 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11840 OpenACCClause *NewClause = nullptr;
11841
11842 ExprResult VisitVar(Expr *VarRef) {
11843 ExprResult Res = Self.TransformExpr(VarRef);
11844
11845 if (!Res.isUsable())
11846 return Res;
11847
11848 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11849 ParsedClause.getClauseKind(),
11850 Res.get());
11851
11852 return Res;
11853 }
11854
11855 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11856 llvm::SmallVector<Expr *> InstantiatedVarList;
11857 for (Expr *CurVar : VarList) {
11858 ExprResult VarRef = VisitVar(CurVar);
11859
11860 if (VarRef.isUsable())
11861 InstantiatedVarList.push_back(VarRef.get());
11862 }
11863
11864 return InstantiatedVarList;
11865 }
11866
11867public:
11868 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11869 ArrayRef<const OpenACCClause *> ExistingClauses,
11870 SemaOpenACC::OpenACCParsedClause &PC)
11871 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
11872
11873 OpenACCClause *CreatedClause() const { return NewClause; }
11874
11875#define VISIT_CLAUSE(CLAUSE_NAME) \
11876 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11877#include "clang/Basic/OpenACCClauses.def"
11878};
11879
11880template <typename Derived>
11881void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11882 const OpenACCDefaultClause &C) {
11883 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
11884
11885 NewClause = OpenACCDefaultClause::Create(
11886 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
11887 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11888 ParsedClause.getEndLoc());
11889}
11890
11891template <typename Derived>
11892void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
11893 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11894 assert(Cond && "If constructed with invalid Condition");
11895 Sema::ConditionResult Res = Self.TransformCondition(
11896 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
11897
11898 if (Res.isInvalid() || !Res.get().second)
11899 return;
11900
11901 ParsedClause.setConditionDetails(Res.get().second);
11902
11903 NewClause = OpenACCIfClause::Create(
11904 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11905 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11906 ParsedClause.getEndLoc());
11907}
11908
11909template <typename Derived>
11910void OpenACCClauseTransform<Derived>::VisitSelfClause(
11911 const OpenACCSelfClause &C) {
11912
11913 // If this is an 'update' 'self' clause, this is actually a var list instead.
11914 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
11915 llvm::SmallVector<Expr *> InstantiatedVarList;
11916 for (Expr *CurVar : C.getVarList()) {
11917 ExprResult Res = Self.TransformExpr(CurVar);
11918
11919 if (!Res.isUsable())
11920 continue;
11921
11922 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11923 ParsedClause.getClauseKind(),
11924 Res.get());
11925
11926 if (Res.isUsable())
11927 InstantiatedVarList.push_back(Res.get());
11928 }
11929
11930 ParsedClause.setVarListDetails(InstantiatedVarList,
11932
11933 NewClause = OpenACCSelfClause::Create(
11934 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11935 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11936 ParsedClause.getEndLoc());
11937 } else {
11938
11939 if (C.hasConditionExpr()) {
11940 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11942 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
11944
11945 if (Res.isInvalid() || !Res.get().second)
11946 return;
11947
11948 ParsedClause.setConditionDetails(Res.get().second);
11949 }
11950
11951 NewClause = OpenACCSelfClause::Create(
11952 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11953 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11954 ParsedClause.getEndLoc());
11955 }
11956}
11957
11958template <typename Derived>
11959void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
11960 const OpenACCNumGangsClause &C) {
11961 llvm::SmallVector<Expr *> InstantiatedIntExprs;
11962
11963 for (Expr *CurIntExpr : C.getIntExprs()) {
11964 ExprResult Res = Self.TransformExpr(CurIntExpr);
11965
11966 if (!Res.isUsable())
11967 return;
11968
11969 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
11970 C.getClauseKind(),
11971 C.getBeginLoc(), Res.get());
11972 if (!Res.isUsable())
11973 return;
11974
11975 InstantiatedIntExprs.push_back(Res.get());
11976 }
11977
11978 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
11980 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11981 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
11982 ParsedClause.getEndLoc());
11983}
11984
11985template <typename Derived>
11986void OpenACCClauseTransform<Derived>::VisitPrivateClause(
11987 const OpenACCPrivateClause &C) {
11988 llvm::SmallVector<Expr *> InstantiatedVarList;
11990
11991 for (const auto [RefExpr, InitRecipe] :
11992 llvm::zip(C.getVarList(), C.getInitRecipes())) {
11993 ExprResult VarRef = VisitVar(RefExpr);
11994
11995 if (VarRef.isUsable()) {
11996 InstantiatedVarList.push_back(VarRef.get());
11997
11998 // We only have to create a new one if it is dependent, and Sema won't
11999 // make one of these unless the type is non-dependent.
12000 if (InitRecipe.isSet())
12001 InitRecipes.push_back(InitRecipe);
12002 else
12003 InitRecipes.push_back(
12004 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
12005 }
12006 }
12007 ParsedClause.setVarListDetails(InstantiatedVarList,
12009
12010 NewClause = OpenACCPrivateClause::Create(
12011 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12012 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12013 ParsedClause.getEndLoc());
12014}
12015
12016template <typename Derived>
12017void OpenACCClauseTransform<Derived>::VisitHostClause(
12018 const OpenACCHostClause &C) {
12019 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12021
12022 NewClause = OpenACCHostClause::Create(
12023 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12024 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12025 ParsedClause.getEndLoc());
12026}
12027
12028template <typename Derived>
12029void OpenACCClauseTransform<Derived>::VisitDeviceClause(
12030 const OpenACCDeviceClause &C) {
12031 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12033
12034 NewClause = OpenACCDeviceClause::Create(
12035 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12036 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12037 ParsedClause.getEndLoc());
12038}
12039
12040template <typename Derived>
12041void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
12043 llvm::SmallVector<Expr *> InstantiatedVarList;
12045
12046 for (const auto [RefExpr, InitRecipe] :
12047 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12048 ExprResult VarRef = VisitVar(RefExpr);
12049
12050 if (VarRef.isUsable()) {
12051 InstantiatedVarList.push_back(VarRef.get());
12052
12053 // We only have to create a new one if it is dependent, and Sema won't
12054 // make one of these unless the type is non-dependent.
12055 if (InitRecipe.isSet())
12056 InitRecipes.push_back(InitRecipe);
12057 else
12058 InitRecipes.push_back(
12059 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12060 VarRef.get()));
12061 }
12062 }
12063 ParsedClause.setVarListDetails(InstantiatedVarList,
12065
12067 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12068 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12069 ParsedClause.getEndLoc());
12070}
12071
12072template <typename Derived>
12073void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12074 const OpenACCNoCreateClause &C) {
12075 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12077
12079 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12080 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12081 ParsedClause.getEndLoc());
12082}
12083
12084template <typename Derived>
12085void OpenACCClauseTransform<Derived>::VisitPresentClause(
12086 const OpenACCPresentClause &C) {
12087 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12089
12090 NewClause = OpenACCPresentClause::Create(
12091 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12092 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12093 ParsedClause.getEndLoc());
12094}
12095
12096template <typename Derived>
12097void OpenACCClauseTransform<Derived>::VisitCopyClause(
12098 const OpenACCCopyClause &C) {
12099 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12100 C.getModifierList());
12101
12102 NewClause = OpenACCCopyClause::Create(
12103 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12104 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12105 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12106 ParsedClause.getEndLoc());
12107}
12108
12109template <typename Derived>
12110void OpenACCClauseTransform<Derived>::VisitLinkClause(
12111 const OpenACCLinkClause &C) {
12112 llvm_unreachable("link clause not valid unless a decl transform");
12113}
12114
12115template <typename Derived>
12116void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12118 llvm_unreachable("device_resident clause not valid unless a decl transform");
12119}
12120template <typename Derived>
12121void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12122 const OpenACCNoHostClause &C) {
12123 llvm_unreachable("nohost clause not valid unless a decl transform");
12124}
12125template <typename Derived>
12126void OpenACCClauseTransform<Derived>::VisitBindClause(
12127 const OpenACCBindClause &C) {
12128 llvm_unreachable("bind clause not valid unless a decl transform");
12129}
12130
12131template <typename Derived>
12132void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12133 const OpenACCCopyInClause &C) {
12134 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12135 C.getModifierList());
12136
12137 NewClause = OpenACCCopyInClause::Create(
12138 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12139 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12140 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12141 ParsedClause.getEndLoc());
12142}
12143
12144template <typename Derived>
12145void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12146 const OpenACCCopyOutClause &C) {
12147 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12148 C.getModifierList());
12149
12150 NewClause = OpenACCCopyOutClause::Create(
12151 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12152 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12153 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12154 ParsedClause.getEndLoc());
12155}
12156
12157template <typename Derived>
12158void OpenACCClauseTransform<Derived>::VisitCreateClause(
12159 const OpenACCCreateClause &C) {
12160 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12161 C.getModifierList());
12162
12163 NewClause = OpenACCCreateClause::Create(
12164 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12165 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12166 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12167 ParsedClause.getEndLoc());
12168}
12169template <typename Derived>
12170void OpenACCClauseTransform<Derived>::VisitAttachClause(
12171 const OpenACCAttachClause &C) {
12172 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12173
12174 // Ensure each var is a pointer type.
12175 llvm::erase_if(VarList, [&](Expr *E) {
12176 return Self.getSema().OpenACC().CheckVarIsPointerType(
12178 });
12179
12180 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12181 NewClause = OpenACCAttachClause::Create(
12182 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12183 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12184 ParsedClause.getEndLoc());
12185}
12186
12187template <typename Derived>
12188void OpenACCClauseTransform<Derived>::VisitDetachClause(
12189 const OpenACCDetachClause &C) {
12190 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12191
12192 // Ensure each var is a pointer type.
12193 llvm::erase_if(VarList, [&](Expr *E) {
12194 return Self.getSema().OpenACC().CheckVarIsPointerType(
12196 });
12197
12198 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12199 NewClause = OpenACCDetachClause::Create(
12200 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12201 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12202 ParsedClause.getEndLoc());
12203}
12204
12205template <typename Derived>
12206void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12207 const OpenACCDeleteClause &C) {
12208 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12210 NewClause = OpenACCDeleteClause::Create(
12211 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12212 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12213 ParsedClause.getEndLoc());
12214}
12215
12216template <typename Derived>
12217void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12218 const OpenACCUseDeviceClause &C) {
12219 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12222 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12223 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12224 ParsedClause.getEndLoc());
12225}
12226
12227template <typename Derived>
12228void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12229 const OpenACCDevicePtrClause &C) {
12230 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12231
12232 // Ensure each var is a pointer type.
12233 llvm::erase_if(VarList, [&](Expr *E) {
12234 return Self.getSema().OpenACC().CheckVarIsPointerType(
12236 });
12237
12238 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12240 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12241 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12242 ParsedClause.getEndLoc());
12243}
12244
12245template <typename Derived>
12246void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12247 const OpenACCNumWorkersClause &C) {
12248 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12249 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12250
12251 ExprResult Res = Self.TransformExpr(IntExpr);
12252 if (!Res.isUsable())
12253 return;
12254
12255 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12256 C.getClauseKind(),
12257 C.getBeginLoc(), Res.get());
12258 if (!Res.isUsable())
12259 return;
12260
12261 ParsedClause.setIntExprDetails(Res.get());
12263 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12264 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12265 ParsedClause.getEndLoc());
12266}
12267
12268template <typename Derived>
12269void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12270 const OpenACCDeviceNumClause &C) {
12271 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12272 assert(IntExpr && "device_num clause constructed with invalid int expr");
12273
12274 ExprResult Res = Self.TransformExpr(IntExpr);
12275 if (!Res.isUsable())
12276 return;
12277
12278 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12279 C.getClauseKind(),
12280 C.getBeginLoc(), Res.get());
12281 if (!Res.isUsable())
12282 return;
12283
12284 ParsedClause.setIntExprDetails(Res.get());
12286 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12287 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12288 ParsedClause.getEndLoc());
12289}
12290
12291template <typename Derived>
12292void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12294 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12295 assert(IntExpr && "default_async clause constructed with invalid int expr");
12296
12297 ExprResult Res = Self.TransformExpr(IntExpr);
12298 if (!Res.isUsable())
12299 return;
12300
12301 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12302 C.getClauseKind(),
12303 C.getBeginLoc(), Res.get());
12304 if (!Res.isUsable())
12305 return;
12306
12307 ParsedClause.setIntExprDetails(Res.get());
12309 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12310 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12311 ParsedClause.getEndLoc());
12312}
12313
12314template <typename Derived>
12315void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12317 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12318 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12319
12320 ExprResult Res = Self.TransformExpr(IntExpr);
12321 if (!Res.isUsable())
12322 return;
12323
12324 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12325 C.getClauseKind(),
12326 C.getBeginLoc(), Res.get());
12327 if (!Res.isUsable())
12328 return;
12329
12330 ParsedClause.setIntExprDetails(Res.get());
12332 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12333 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12334 ParsedClause.getEndLoc());
12335}
12336
12337template <typename Derived>
12338void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12339 const OpenACCAsyncClause &C) {
12340 if (C.hasIntExpr()) {
12341 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12342 if (!Res.isUsable())
12343 return;
12344
12345 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12346 C.getClauseKind(),
12347 C.getBeginLoc(), Res.get());
12348 if (!Res.isUsable())
12349 return;
12350 ParsedClause.setIntExprDetails(Res.get());
12351 }
12352
12353 NewClause = OpenACCAsyncClause::Create(
12354 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12355 ParsedClause.getLParenLoc(),
12356 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12357 : nullptr,
12358 ParsedClause.getEndLoc());
12359}
12360
12361template <typename Derived>
12362void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12363 const OpenACCWorkerClause &C) {
12364 if (C.hasIntExpr()) {
12365 // restrictions on this expression are all "does it exist in certain
12366 // situations" that are not possible to be dependent, so the only check we
12367 // have is that it transforms, and is an int expression.
12368 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12369 if (!Res.isUsable())
12370 return;
12371
12372 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12373 C.getClauseKind(),
12374 C.getBeginLoc(), Res.get());
12375 if (!Res.isUsable())
12376 return;
12377 ParsedClause.setIntExprDetails(Res.get());
12378 }
12379
12380 NewClause = OpenACCWorkerClause::Create(
12381 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12382 ParsedClause.getLParenLoc(),
12383 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12384 : nullptr,
12385 ParsedClause.getEndLoc());
12386}
12387
12388template <typename Derived>
12389void OpenACCClauseTransform<Derived>::VisitVectorClause(
12390 const OpenACCVectorClause &C) {
12391 if (C.hasIntExpr()) {
12392 // restrictions on this expression are all "does it exist in certain
12393 // situations" that are not possible to be dependent, so the only check we
12394 // have is that it transforms, and is an int expression.
12395 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12396 if (!Res.isUsable())
12397 return;
12398
12399 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12400 C.getClauseKind(),
12401 C.getBeginLoc(), Res.get());
12402 if (!Res.isUsable())
12403 return;
12404 ParsedClause.setIntExprDetails(Res.get());
12405 }
12406
12407 NewClause = OpenACCVectorClause::Create(
12408 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12409 ParsedClause.getLParenLoc(),
12410 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12411 : nullptr,
12412 ParsedClause.getEndLoc());
12413}
12414
12415template <typename Derived>
12416void OpenACCClauseTransform<Derived>::VisitWaitClause(
12417 const OpenACCWaitClause &C) {
12418 if (C.hasExprs()) {
12419 Expr *DevNumExpr = nullptr;
12420 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12421
12422 // Instantiate devnum expr if it exists.
12423 if (C.getDevNumExpr()) {
12424 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12425 if (!Res.isUsable())
12426 return;
12427 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12428 C.getClauseKind(),
12429 C.getBeginLoc(), Res.get());
12430 if (!Res.isUsable())
12431 return;
12432
12433 DevNumExpr = Res.get();
12434 }
12435
12436 // Instantiate queue ids.
12437 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12438 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12439 if (!Res.isUsable())
12440 return;
12441 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12442 C.getClauseKind(),
12443 C.getBeginLoc(), Res.get());
12444 if (!Res.isUsable())
12445 return;
12446
12447 InstantiatedQueueIdExprs.push_back(Res.get());
12448 }
12449
12450 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12451 std::move(InstantiatedQueueIdExprs));
12452 }
12453
12454 NewClause = OpenACCWaitClause::Create(
12455 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12456 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12457 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12458 ParsedClause.getEndLoc());
12459}
12460
12461template <typename Derived>
12462void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12463 const OpenACCDeviceTypeClause &C) {
12464 // Nothing to transform here, just create a new version of 'C'.
12466 Self.getSema().getASTContext(), C.getClauseKind(),
12467 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12468 C.getArchitectures(), ParsedClause.getEndLoc());
12469}
12470
12471template <typename Derived>
12472void OpenACCClauseTransform<Derived>::VisitAutoClause(
12473 const OpenACCAutoClause &C) {
12474 // Nothing to do, so just create a new node.
12475 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12476 ParsedClause.getBeginLoc(),
12477 ParsedClause.getEndLoc());
12478}
12479
12480template <typename Derived>
12481void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12482 const OpenACCIndependentClause &C) {
12483 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12484 ParsedClause.getBeginLoc(),
12485 ParsedClause.getEndLoc());
12486}
12487
12488template <typename Derived>
12489void OpenACCClauseTransform<Derived>::VisitSeqClause(
12490 const OpenACCSeqClause &C) {
12491 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12492 ParsedClause.getBeginLoc(),
12493 ParsedClause.getEndLoc());
12494}
12495template <typename Derived>
12496void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12497 const OpenACCFinalizeClause &C) {
12498 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12499 ParsedClause.getBeginLoc(),
12500 ParsedClause.getEndLoc());
12501}
12502
12503template <typename Derived>
12504void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12505 const OpenACCIfPresentClause &C) {
12506 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12507 ParsedClause.getBeginLoc(),
12508 ParsedClause.getEndLoc());
12509}
12510
12511template <typename Derived>
12512void OpenACCClauseTransform<Derived>::VisitReductionClause(
12513 const OpenACCReductionClause &C) {
12514 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12515 SmallVector<Expr *> ValidVars;
12517
12518 for (const auto [Var, OrigRecipe] :
12519 llvm::zip(TransformedVars, C.getRecipes())) {
12520 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12521 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12522 if (Res.isUsable()) {
12523 ValidVars.push_back(Res.get());
12524
12525 if (OrigRecipe.isSet())
12526 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
12527 else
12528 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
12529 C.getReductionOp(), Res.get()));
12530 }
12531 }
12532
12533 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12534 ExistingClauses, ParsedClause.getDirectiveKind(),
12535 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12536 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
12537}
12538
12539template <typename Derived>
12540void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12541 const OpenACCCollapseClause &C) {
12542 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12543 assert(LoopCount && "collapse clause constructed with invalid loop count");
12544
12545 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12546
12547 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12548 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12549 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12550
12551 NewLoopCount =
12552 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12553
12554 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12556 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12557 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12558 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12559}
12560
12561template <typename Derived>
12562void OpenACCClauseTransform<Derived>::VisitTileClause(
12563 const OpenACCTileClause &C) {
12564
12565 llvm::SmallVector<Expr *> TransformedExprs;
12566
12567 for (Expr *E : C.getSizeExprs()) {
12568 ExprResult NewSizeExpr = Self.TransformExpr(E);
12569
12570 if (!NewSizeExpr.isUsable())
12571 return;
12572
12573 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12574 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12575 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12576
12577 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12578
12579 if (!NewSizeExpr.isUsable())
12580 return;
12581 TransformedExprs.push_back(NewSizeExpr.get());
12582 }
12583
12584 ParsedClause.setIntExprDetails(TransformedExprs);
12585 NewClause = OpenACCTileClause::Create(
12586 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12587 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12588 ParsedClause.getEndLoc());
12589}
12590template <typename Derived>
12591void OpenACCClauseTransform<Derived>::VisitGangClause(
12592 const OpenACCGangClause &C) {
12593 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12594 llvm::SmallVector<Expr *> TransformedIntExprs;
12595
12596 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12597 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12598 if (!ER.isUsable())
12599 continue;
12600
12601 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12602 ParsedClause.getDirectiveKind(),
12603 C.getExpr(I).first, ER.get());
12604 if (!ER.isUsable())
12605 continue;
12606 TransformedGangKinds.push_back(C.getExpr(I).first);
12607 TransformedIntExprs.push_back(ER.get());
12608 }
12609
12610 NewClause = Self.getSema().OpenACC().CheckGangClause(
12611 ParsedClause.getDirectiveKind(), ExistingClauses,
12612 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12613 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12614}
12615} // namespace
12616template <typename Derived>
12617OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12618 ArrayRef<const OpenACCClause *> ExistingClauses,
12619 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12620
12622 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12623 ParsedClause.setEndLoc(OldClause->getEndLoc());
12624
12625 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12626 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12627
12628 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12629 ParsedClause};
12630 Transform.Visit(OldClause);
12631
12632 return Transform.CreatedClause();
12633}
12634
12635template <typename Derived>
12637TreeTransform<Derived>::TransformOpenACCClauseList(
12639 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12640 for (const auto *Clause : OldClauses) {
12641 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12642 TransformedClauses, DirKind, Clause))
12643 TransformedClauses.push_back(TransformedClause);
12644 }
12645 return TransformedClauses;
12646}
12647
12648template <typename Derived>
12651 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12652
12653 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12654 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12655 C->clauses());
12656
12657 if (getSema().OpenACC().ActOnStartStmtDirective(
12658 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12659 return StmtError();
12660
12661 // Transform Structured Block.
12662 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12663 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12664 C->clauses(), TransformedClauses);
12665 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12666 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12667 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12668
12669 return getDerived().RebuildOpenACCComputeConstruct(
12670 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12671 C->getEndLoc(), TransformedClauses, StrBlock);
12672}
12673
12674template <typename Derived>
12677
12678 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12679
12680 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12681 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12682 C->clauses());
12683
12684 if (getSema().OpenACC().ActOnStartStmtDirective(
12685 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12686 return StmtError();
12687
12688 // Transform Loop.
12689 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12690 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12691 C->clauses(), TransformedClauses);
12692 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12693 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12694 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12695
12696 return getDerived().RebuildOpenACCLoopConstruct(
12697 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12698 TransformedClauses, Loop);
12699}
12700
12701template <typename Derived>
12703 OpenACCCombinedConstruct *C) {
12704 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12705
12706 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12707 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12708 C->clauses());
12709
12710 if (getSema().OpenACC().ActOnStartStmtDirective(
12711 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12712 return StmtError();
12713
12714 // Transform Loop.
12715 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12716 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12717 C->clauses(), TransformedClauses);
12718 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12719 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12720 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12721
12722 return getDerived().RebuildOpenACCCombinedConstruct(
12723 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12724 C->getEndLoc(), TransformedClauses, Loop);
12725}
12726
12727template <typename Derived>
12730 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12731
12732 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12733 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12734 C->clauses());
12735 if (getSema().OpenACC().ActOnStartStmtDirective(
12736 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12737 return StmtError();
12738
12739 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12740 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12741 C->clauses(), TransformedClauses);
12742 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12743 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12744 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12745
12746 return getDerived().RebuildOpenACCDataConstruct(
12747 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12748 TransformedClauses, StrBlock);
12749}
12750
12751template <typename Derived>
12753 OpenACCEnterDataConstruct *C) {
12754 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12755
12756 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12757 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12758 C->clauses());
12759 if (getSema().OpenACC().ActOnStartStmtDirective(
12760 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12761 return StmtError();
12762
12763 return getDerived().RebuildOpenACCEnterDataConstruct(
12764 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12765 TransformedClauses);
12766}
12767
12768template <typename Derived>
12770 OpenACCExitDataConstruct *C) {
12771 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12772
12773 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12774 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12775 C->clauses());
12776 if (getSema().OpenACC().ActOnStartStmtDirective(
12777 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12778 return StmtError();
12779
12780 return getDerived().RebuildOpenACCExitDataConstruct(
12781 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12782 TransformedClauses);
12783}
12784
12785template <typename Derived>
12787 OpenACCHostDataConstruct *C) {
12788 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12789
12790 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12791 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12792 C->clauses());
12793 if (getSema().OpenACC().ActOnStartStmtDirective(
12794 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12795 return StmtError();
12796
12797 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12798 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12799 C->clauses(), TransformedClauses);
12800 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12801 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12802 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12803
12804 return getDerived().RebuildOpenACCHostDataConstruct(
12805 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12806 TransformedClauses, StrBlock);
12807}
12808
12809template <typename Derived>
12812 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12813
12814 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12815 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12816 C->clauses());
12817 if (getSema().OpenACC().ActOnStartStmtDirective(
12818 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12819 return StmtError();
12820
12821 return getDerived().RebuildOpenACCInitConstruct(
12822 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12823 TransformedClauses);
12824}
12825
12826template <typename Derived>
12828 OpenACCShutdownConstruct *C) {
12829 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12830
12831 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12832 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12833 C->clauses());
12834 if (getSema().OpenACC().ActOnStartStmtDirective(
12835 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12836 return StmtError();
12837
12838 return getDerived().RebuildOpenACCShutdownConstruct(
12839 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12840 TransformedClauses);
12841}
12842template <typename Derived>
12845 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12846
12847 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12848 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12849 C->clauses());
12850 if (getSema().OpenACC().ActOnStartStmtDirective(
12851 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12852 return StmtError();
12853
12854 return getDerived().RebuildOpenACCSetConstruct(
12855 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12856 TransformedClauses);
12857}
12858
12859template <typename Derived>
12861 OpenACCUpdateConstruct *C) {
12862 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12863
12864 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12865 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12866 C->clauses());
12867 if (getSema().OpenACC().ActOnStartStmtDirective(
12868 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12869 return StmtError();
12870
12871 return getDerived().RebuildOpenACCUpdateConstruct(
12872 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12873 TransformedClauses);
12874}
12875
12876template <typename Derived>
12879 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12880
12881 ExprResult DevNumExpr;
12882 if (C->hasDevNumExpr()) {
12883 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
12884
12885 if (DevNumExpr.isUsable())
12886 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
12888 C->getBeginLoc(), DevNumExpr.get());
12889 }
12890
12891 llvm::SmallVector<Expr *> QueueIdExprs;
12892
12893 for (Expr *QE : C->getQueueIdExprs()) {
12894 assert(QE && "Null queue id expr?");
12895 ExprResult NewEQ = getDerived().TransformExpr(QE);
12896
12897 if (!NewEQ.isUsable())
12898 break;
12899 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
12901 C->getBeginLoc(), NewEQ.get());
12902 if (NewEQ.isUsable())
12903 QueueIdExprs.push_back(NewEQ.get());
12904 }
12905
12906 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12907 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12908 C->clauses());
12909
12910 if (getSema().OpenACC().ActOnStartStmtDirective(
12911 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12912 return StmtError();
12913
12914 return getDerived().RebuildOpenACCWaitConstruct(
12915 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12916 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
12917 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
12918}
12919template <typename Derived>
12921 OpenACCCacheConstruct *C) {
12922 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12923
12924 llvm::SmallVector<Expr *> TransformedVarList;
12925 for (Expr *Var : C->getVarList()) {
12926 assert(Var && "Null var listexpr?");
12927
12928 ExprResult NewVar = getDerived().TransformExpr(Var);
12929
12930 if (!NewVar.isUsable())
12931 break;
12932
12933 NewVar = getSema().OpenACC().ActOnVar(
12934 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
12935 if (!NewVar.isUsable())
12936 break;
12937
12938 TransformedVarList.push_back(NewVar.get());
12939 }
12940
12941 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
12942 C->getBeginLoc(), {}))
12943 return StmtError();
12944
12945 return getDerived().RebuildOpenACCCacheConstruct(
12946 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12947 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
12948 C->getEndLoc());
12949}
12950
12951template <typename Derived>
12953 OpenACCAtomicConstruct *C) {
12954 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12955
12956 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12957 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12958 C->clauses());
12959
12960 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
12961 C->getBeginLoc(), {}))
12962 return StmtError();
12963
12964 // Transform Associated Stmt.
12965 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12966 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
12967
12968 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
12969 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
12970 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
12971 AssocStmt);
12972
12973 return getDerived().RebuildOpenACCAtomicConstruct(
12974 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
12975 C->getEndLoc(), TransformedClauses, AssocStmt);
12976}
12977
12978template <typename Derived>
12981 if (getDerived().AlwaysRebuild())
12982 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
12983 // Nothing can ever change, so there is never anything to transform.
12984 return E;
12985}
12986
12987//===----------------------------------------------------------------------===//
12988// Expression transformation
12989//===----------------------------------------------------------------------===//
12990template<typename Derived>
12993 return TransformExpr(E->getSubExpr());
12994}
12995
12996template <typename Derived>
12999 if (!E->isTypeDependent())
13000 return E;
13001
13002 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
13003
13004 if (!NewT)
13005 return ExprError();
13006
13007 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
13008 return E;
13009
13010 return getDerived().RebuildSYCLUniqueStableNameExpr(
13011 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
13012}
13013
13014template<typename Derived>
13017 if (!E->isTypeDependent())
13018 return E;
13019
13020 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13021 E->getIdentKind());
13022}
13023
13024template<typename Derived>
13027 NestedNameSpecifierLoc QualifierLoc;
13028 if (E->getQualifierLoc()) {
13029 QualifierLoc
13030 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13031 if (!QualifierLoc)
13032 return ExprError();
13033 }
13034
13035 ValueDecl *ND
13036 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13037 E->getDecl()));
13038 if (!ND || ND->isInvalidDecl())
13039 return ExprError();
13040
13041 NamedDecl *Found = ND;
13042 if (E->getFoundDecl() != E->getDecl()) {
13043 Found = cast_or_null<NamedDecl>(
13044 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13045 if (!Found)
13046 return ExprError();
13047 }
13048
13049 DeclarationNameInfo NameInfo = E->getNameInfo();
13050 if (NameInfo.getName()) {
13051 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13052 if (!NameInfo.getName())
13053 return ExprError();
13054 }
13055
13056 if (!getDerived().AlwaysRebuild() &&
13057 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13058 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13059 Found == E->getFoundDecl() &&
13060 NameInfo.getName() == E->getDecl()->getDeclName() &&
13061 !E->hasExplicitTemplateArgs()) {
13062
13063 // Mark it referenced in the new context regardless.
13064 // FIXME: this is a bit instantiation-specific.
13065 SemaRef.MarkDeclRefReferenced(E);
13066
13067 return E;
13068 }
13069
13070 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13071 if (E->hasExplicitTemplateArgs()) {
13072 TemplateArgs = &TransArgs;
13073 TransArgs.setLAngleLoc(E->getLAngleLoc());
13074 TransArgs.setRAngleLoc(E->getRAngleLoc());
13075 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13076 E->getNumTemplateArgs(),
13077 TransArgs))
13078 return ExprError();
13079 }
13080
13081 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13082 Found, TemplateArgs);
13083}
13084
13085template<typename Derived>
13088 return E;
13089}
13090
13091template <typename Derived>
13093 FixedPointLiteral *E) {
13094 return E;
13095}
13096
13097template<typename Derived>
13100 return E;
13101}
13102
13103template<typename Derived>
13106 return E;
13107}
13108
13109template<typename Derived>
13112 return E;
13113}
13114
13115template<typename Derived>
13118 return E;
13119}
13120
13121template<typename Derived>
13124 return getDerived().TransformCallExpr(E);
13125}
13126
13127template<typename Derived>
13130 ExprResult ControllingExpr;
13131 TypeSourceInfo *ControllingType = nullptr;
13132 if (E->isExprPredicate())
13133 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13134 else
13135 ControllingType = getDerived().TransformType(E->getControllingType());
13136
13137 if (ControllingExpr.isInvalid() && !ControllingType)
13138 return ExprError();
13139
13140 SmallVector<Expr *, 4> AssocExprs;
13142 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13143 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13144 if (TSI) {
13145 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13146 if (!AssocType)
13147 return ExprError();
13148 AssocTypes.push_back(AssocType);
13149 } else {
13150 AssocTypes.push_back(nullptr);
13151 }
13152
13153 ExprResult AssocExpr =
13154 getDerived().TransformExpr(Assoc.getAssociationExpr());
13155 if (AssocExpr.isInvalid())
13156 return ExprError();
13157 AssocExprs.push_back(AssocExpr.get());
13158 }
13159
13160 if (!ControllingType)
13161 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13162 E->getDefaultLoc(),
13163 E->getRParenLoc(),
13164 ControllingExpr.get(),
13165 AssocTypes,
13166 AssocExprs);
13167 return getDerived().RebuildGenericSelectionExpr(
13168 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13169 ControllingType, AssocTypes, AssocExprs);
13170}
13171
13172template<typename Derived>
13175 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13176 if (SubExpr.isInvalid())
13177 return ExprError();
13178
13179 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13180 return E;
13181
13182 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13183 E->getRParen());
13184}
13185
13186/// The operand of a unary address-of operator has special rules: it's
13187/// allowed to refer to a non-static member of a class even if there's no 'this'
13188/// object available.
13189template<typename Derived>
13192 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13193 return getDerived().TransformDependentScopeDeclRefExpr(
13194 DRE, /*IsAddressOfOperand=*/true, nullptr);
13195 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13196 return getDerived().TransformUnresolvedLookupExpr(
13197 ULE, /*IsAddressOfOperand=*/true);
13198 else
13199 return getDerived().TransformExpr(E);
13200}
13201
13202template<typename Derived>
13205 ExprResult SubExpr;
13206 if (E->getOpcode() == UO_AddrOf)
13207 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13208 else
13209 SubExpr = TransformExpr(E->getSubExpr());
13210 if (SubExpr.isInvalid())
13211 return ExprError();
13212
13213 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13214 return E;
13215
13216 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13217 E->getOpcode(),
13218 SubExpr.get());
13219}
13220
13221template<typename Derived>
13223TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13224 // Transform the type.
13225 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13226 if (!Type)
13227 return ExprError();
13228
13229 // Transform all of the components into components similar to what the
13230 // parser uses.
13231 // FIXME: It would be slightly more efficient in the non-dependent case to
13232 // just map FieldDecls, rather than requiring the rebuilder to look for
13233 // the fields again. However, __builtin_offsetof is rare enough in
13234 // template code that we don't care.
13235 bool ExprChanged = false;
13236 typedef Sema::OffsetOfComponent Component;
13237 SmallVector<Component, 4> Components;
13238 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13239 const OffsetOfNode &ON = E->getComponent(I);
13240 Component Comp;
13241 Comp.isBrackets = true;
13242 Comp.LocStart = ON.getSourceRange().getBegin();
13243 Comp.LocEnd = ON.getSourceRange().getEnd();
13244 switch (ON.getKind()) {
13245 case OffsetOfNode::Array: {
13246 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13247 ExprResult Index = getDerived().TransformExpr(FromIndex);
13248 if (Index.isInvalid())
13249 return ExprError();
13250
13251 ExprChanged = ExprChanged || Index.get() != FromIndex;
13252 Comp.isBrackets = true;
13253 Comp.U.E = Index.get();
13254 break;
13255 }
13256
13259 Comp.isBrackets = false;
13260 Comp.U.IdentInfo = ON.getFieldName();
13261 if (!Comp.U.IdentInfo)
13262 continue;
13263
13264 break;
13265
13266 case OffsetOfNode::Base:
13267 // Will be recomputed during the rebuild.
13268 continue;
13269 }
13270
13271 Components.push_back(Comp);
13272 }
13273
13274 // If nothing changed, retain the existing expression.
13275 if (!getDerived().AlwaysRebuild() &&
13276 Type == E->getTypeSourceInfo() &&
13277 !ExprChanged)
13278 return E;
13279
13280 // Build a new offsetof expression.
13281 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13282 Components, E->getRParenLoc());
13283}
13284
13285template<typename Derived>
13288 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13289 "opaque value expression requires transformation");
13290 return E;
13291}
13292
13293template <typename Derived>
13296 bool Changed = false;
13297 for (Expr *C : E->subExpressions()) {
13298 ExprResult NewC = getDerived().TransformExpr(C);
13299 if (NewC.isInvalid())
13300 return ExprError();
13301 Children.push_back(NewC.get());
13302
13303 Changed |= NewC.get() != C;
13304 }
13305 if (!getDerived().AlwaysRebuild() && !Changed)
13306 return E;
13307 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13308 Children, E->getType());
13309}
13310
13311template<typename Derived>
13314 // Rebuild the syntactic form. The original syntactic form has
13315 // opaque-value expressions in it, so strip those away and rebuild
13316 // the result. This is a really awful way of doing this, but the
13317 // better solution (rebuilding the semantic expressions and
13318 // rebinding OVEs as necessary) doesn't work; we'd need
13319 // TreeTransform to not strip away implicit conversions.
13320 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13321 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13322 if (result.isInvalid()) return ExprError();
13323
13324 // If that gives us a pseudo-object result back, the pseudo-object
13325 // expression must have been an lvalue-to-rvalue conversion which we
13326 // should reapply.
13327 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13328 result = SemaRef.PseudoObject().checkRValue(result.get());
13329
13330 return result;
13331}
13332
13333template<typename Derived>
13337 if (E->isArgumentType()) {
13338 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13339
13340 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13341 if (!NewT)
13342 return ExprError();
13343
13344 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13345 return E;
13346
13347 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13348 E->getKind(),
13349 E->getSourceRange());
13350 }
13351
13352 // C++0x [expr.sizeof]p1:
13353 // The operand is either an expression, which is an unevaluated operand
13354 // [...]
13358
13359 // Try to recover if we have something like sizeof(T::X) where X is a type.
13360 // Notably, there must be *exactly* one set of parens if X is a type.
13361 TypeSourceInfo *RecoveryTSI = nullptr;
13362 ExprResult SubExpr;
13363 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13364 if (auto *DRE =
13365 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13366 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13367 PE, DRE, false, &RecoveryTSI);
13368 else
13369 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13370
13371 if (RecoveryTSI) {
13372 return getDerived().RebuildUnaryExprOrTypeTrait(
13373 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13374 } else if (SubExpr.isInvalid())
13375 return ExprError();
13376
13377 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13378 return E;
13379
13380 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13381 E->getOperatorLoc(),
13382 E->getKind(),
13383 E->getSourceRange());
13384}
13385
13386template<typename Derived>
13389 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13390 if (LHS.isInvalid())
13391 return ExprError();
13392
13393 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13394 if (RHS.isInvalid())
13395 return ExprError();
13396
13397
13398 if (!getDerived().AlwaysRebuild() &&
13399 LHS.get() == E->getLHS() &&
13400 RHS.get() == E->getRHS())
13401 return E;
13402
13403 return getDerived().RebuildArraySubscriptExpr(
13404 LHS.get(),
13405 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13406}
13407
13408template <typename Derived>
13411 ExprResult Base = getDerived().TransformExpr(E->getBase());
13412 if (Base.isInvalid())
13413 return ExprError();
13414
13415 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13416 if (RowIdx.isInvalid())
13417 return ExprError();
13418
13419 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13420 RowIdx.get() == E->getRowIdx())
13421 return E;
13422
13423 return getDerived().RebuildMatrixSingleSubscriptExpr(Base.get(), RowIdx.get(),
13424 E->getRBracketLoc());
13425}
13426
13427template <typename Derived>
13430 ExprResult Base = getDerived().TransformExpr(E->getBase());
13431 if (Base.isInvalid())
13432 return ExprError();
13433
13434 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13435 if (RowIdx.isInvalid())
13436 return ExprError();
13437
13438 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13439 if (ColumnIdx.isInvalid())
13440 return ExprError();
13441
13442 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13443 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13444 return E;
13445
13446 return getDerived().RebuildMatrixSubscriptExpr(
13447 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13448}
13449
13450template <typename Derived>
13453 ExprResult Base = getDerived().TransformExpr(E->getBase());
13454 if (Base.isInvalid())
13455 return ExprError();
13456
13457 ExprResult LowerBound;
13458 if (E->getLowerBound()) {
13459 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13460 if (LowerBound.isInvalid())
13461 return ExprError();
13462 }
13463
13464 ExprResult Length;
13465 if (E->getLength()) {
13466 Length = getDerived().TransformExpr(E->getLength());
13467 if (Length.isInvalid())
13468 return ExprError();
13469 }
13470
13471 ExprResult Stride;
13472 if (E->isOMPArraySection()) {
13473 if (Expr *Str = E->getStride()) {
13474 Stride = getDerived().TransformExpr(Str);
13475 if (Stride.isInvalid())
13476 return ExprError();
13477 }
13478 }
13479
13480 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13481 LowerBound.get() == E->getLowerBound() &&
13482 Length.get() == E->getLength() &&
13483 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13484 return E;
13485
13486 return getDerived().RebuildArraySectionExpr(
13487 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13488 LowerBound.get(), E->getColonLocFirst(),
13489 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13490 Length.get(), Stride.get(), E->getRBracketLoc());
13491}
13492
13493template <typename Derived>
13496 ExprResult Base = getDerived().TransformExpr(E->getBase());
13497 if (Base.isInvalid())
13498 return ExprError();
13499
13501 bool ErrorFound = false;
13502 for (Expr *Dim : E->getDimensions()) {
13503 ExprResult DimRes = getDerived().TransformExpr(Dim);
13504 if (DimRes.isInvalid()) {
13505 ErrorFound = true;
13506 continue;
13507 }
13508 Dims.push_back(DimRes.get());
13509 }
13510
13511 if (ErrorFound)
13512 return ExprError();
13513 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13514 E->getRParenLoc(), Dims,
13515 E->getBracketsRanges());
13516}
13517
13518template <typename Derived>
13521 unsigned NumIterators = E->numOfIterators();
13523
13524 bool ErrorFound = false;
13525 bool NeedToRebuild = getDerived().AlwaysRebuild();
13526 for (unsigned I = 0; I < NumIterators; ++I) {
13527 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13528 Data[I].DeclIdent = D->getIdentifier();
13529 Data[I].DeclIdentLoc = D->getLocation();
13530 if (D->getLocation() == D->getBeginLoc()) {
13531 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13532 "Implicit type must be int.");
13533 } else {
13534 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13535 QualType DeclTy = getDerived().TransformType(D->getType());
13536 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13537 }
13538 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13539 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13540 ExprResult End = getDerived().TransformExpr(Range.End);
13541 ExprResult Step = getDerived().TransformExpr(Range.Step);
13542 ErrorFound = ErrorFound ||
13543 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13544 !Data[I].Type.get().isNull())) ||
13545 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13546 if (ErrorFound)
13547 continue;
13548 Data[I].Range.Begin = Begin.get();
13549 Data[I].Range.End = End.get();
13550 Data[I].Range.Step = Step.get();
13551 Data[I].AssignLoc = E->getAssignLoc(I);
13552 Data[I].ColonLoc = E->getColonLoc(I);
13553 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13554 NeedToRebuild =
13555 NeedToRebuild ||
13556 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13557 D->getType().getTypePtrOrNull()) ||
13558 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13559 Range.Step != Data[I].Range.Step;
13560 }
13561 if (ErrorFound)
13562 return ExprError();
13563 if (!NeedToRebuild)
13564 return E;
13565
13566 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13567 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13568 if (!Res.isUsable())
13569 return Res;
13570 auto *IE = cast<OMPIteratorExpr>(Res.get());
13571 for (unsigned I = 0; I < NumIterators; ++I)
13572 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13573 IE->getIteratorDecl(I));
13574 return Res;
13575}
13576
13577template<typename Derived>
13580 // Transform the callee.
13581 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13582 if (Callee.isInvalid())
13583 return ExprError();
13584
13585 // Transform arguments.
13586 bool ArgChanged = false;
13588 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13589 &ArgChanged))
13590 return ExprError();
13591
13592 if (!getDerived().AlwaysRebuild() &&
13593 Callee.get() == E->getCallee() &&
13594 !ArgChanged)
13595 return SemaRef.MaybeBindToTemporary(E);
13596
13597 // FIXME: Wrong source location information for the '('.
13598 SourceLocation FakeLParenLoc
13599 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13600
13601 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13602 if (E->hasStoredFPFeatures()) {
13603 FPOptionsOverride NewOverrides = E->getFPFeatures();
13604 getSema().CurFPFeatures =
13605 NewOverrides.applyOverrides(getSema().getLangOpts());
13606 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13607 }
13608
13609 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13610 Args,
13611 E->getRParenLoc());
13612}
13613
13614template<typename Derived>
13617 ExprResult Base = getDerived().TransformExpr(E->getBase());
13618 if (Base.isInvalid())
13619 return ExprError();
13620
13621 NestedNameSpecifierLoc QualifierLoc;
13622 if (E->hasQualifier()) {
13623 QualifierLoc
13624 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13625
13626 if (!QualifierLoc)
13627 return ExprError();
13628 }
13629 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13630
13632 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13633 E->getMemberDecl()));
13634 if (!Member)
13635 return ExprError();
13636
13637 NamedDecl *FoundDecl = E->getFoundDecl();
13638 if (FoundDecl == E->getMemberDecl()) {
13639 FoundDecl = Member;
13640 } else {
13641 FoundDecl = cast_or_null<NamedDecl>(
13642 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13643 if (!FoundDecl)
13644 return ExprError();
13645 }
13646
13647 if (!getDerived().AlwaysRebuild() &&
13648 Base.get() == E->getBase() &&
13649 QualifierLoc == E->getQualifierLoc() &&
13650 Member == E->getMemberDecl() &&
13651 FoundDecl == E->getFoundDecl() &&
13652 !E->hasExplicitTemplateArgs()) {
13653
13654 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13655 // for Openmp where the field need to be privatizized in the case.
13656 if (!(isa<CXXThisExpr>(E->getBase()) &&
13657 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13659 // Mark it referenced in the new context regardless.
13660 // FIXME: this is a bit instantiation-specific.
13661 SemaRef.MarkMemberReferenced(E);
13662 return E;
13663 }
13664 }
13665
13666 TemplateArgumentListInfo TransArgs;
13667 if (E->hasExplicitTemplateArgs()) {
13668 TransArgs.setLAngleLoc(E->getLAngleLoc());
13669 TransArgs.setRAngleLoc(E->getRAngleLoc());
13670 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13671 E->getNumTemplateArgs(),
13672 TransArgs))
13673 return ExprError();
13674 }
13675
13676 // FIXME: Bogus source location for the operator
13677 SourceLocation FakeOperatorLoc =
13678 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13679
13680 // FIXME: to do this check properly, we will need to preserve the
13681 // first-qualifier-in-scope here, just in case we had a dependent
13682 // base (and therefore couldn't do the check) and a
13683 // nested-name-qualifier (and therefore could do the lookup).
13684 NamedDecl *FirstQualifierInScope = nullptr;
13685 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13686 if (MemberNameInfo.getName()) {
13687 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13688 if (!MemberNameInfo.getName())
13689 return ExprError();
13690 }
13691
13692 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13693 E->isArrow(),
13694 QualifierLoc,
13695 TemplateKWLoc,
13696 MemberNameInfo,
13697 Member,
13698 FoundDecl,
13699 (E->hasExplicitTemplateArgs()
13700 ? &TransArgs : nullptr),
13701 FirstQualifierInScope);
13702}
13703
13704template<typename Derived>
13707 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13708 if (LHS.isInvalid())
13709 return ExprError();
13710
13711 ExprResult RHS =
13712 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13713 if (RHS.isInvalid())
13714 return ExprError();
13715
13716 if (!getDerived().AlwaysRebuild() &&
13717 LHS.get() == E->getLHS() &&
13718 RHS.get() == E->getRHS())
13719 return E;
13720
13721 if (E->isCompoundAssignmentOp())
13722 // FPFeatures has already been established from trailing storage
13723 return getDerived().RebuildBinaryOperator(
13724 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13725 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13726 FPOptionsOverride NewOverrides(E->getFPFeatures());
13727 getSema().CurFPFeatures =
13728 NewOverrides.applyOverrides(getSema().getLangOpts());
13729 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13730 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13731 LHS.get(), RHS.get());
13732}
13733
13734template <typename Derived>
13737 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13738
13739 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13740 if (LHS.isInvalid())
13741 return ExprError();
13742
13743 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13744 if (RHS.isInvalid())
13745 return ExprError();
13746
13747 // Extract the already-resolved callee declarations so that we can restrict
13748 // ourselves to using them as the unqualified lookup results when rebuilding.
13749 UnresolvedSet<2> UnqualLookups;
13750 bool ChangedAnyLookups = false;
13751 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13752 const_cast<Expr *>(Decomp.InnerBinOp)};
13753 for (Expr *PossibleBinOp : PossibleBinOps) {
13754 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13755 if (!Op)
13756 continue;
13757 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13758 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13759 continue;
13760
13761 // Transform the callee in case we built a call to a local extern
13762 // declaration.
13763 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13764 E->getOperatorLoc(), Callee->getFoundDecl()));
13765 if (!Found)
13766 return ExprError();
13767 if (Found != Callee->getFoundDecl())
13768 ChangedAnyLookups = true;
13769 UnqualLookups.addDecl(Found);
13770 }
13771
13772 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13773 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13774 // Mark all functions used in the rewrite as referenced. Note that when
13775 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13776 // function calls, and/or there might be a user-defined conversion sequence
13777 // applied to the operands of the <.
13778 // FIXME: this is a bit instantiation-specific.
13779 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13780 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13781 return E;
13782 }
13783
13784 return getDerived().RebuildCXXRewrittenBinaryOperator(
13785 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13786}
13787
13788template<typename Derived>
13792 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13793 FPOptionsOverride NewOverrides(E->getFPFeatures());
13794 getSema().CurFPFeatures =
13795 NewOverrides.applyOverrides(getSema().getLangOpts());
13796 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13797 return getDerived().TransformBinaryOperator(E);
13798}
13799
13800template<typename Derived>
13803 // Just rebuild the common and RHS expressions and see whether we
13804 // get any changes.
13805
13806 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13807 if (commonExpr.isInvalid())
13808 return ExprError();
13809
13810 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13811 if (rhs.isInvalid())
13812 return ExprError();
13813
13814 if (!getDerived().AlwaysRebuild() &&
13815 commonExpr.get() == e->getCommon() &&
13816 rhs.get() == e->getFalseExpr())
13817 return e;
13818
13819 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13820 e->getQuestionLoc(),
13821 nullptr,
13822 e->getColonLoc(),
13823 rhs.get());
13824}
13825
13826template<typename Derived>
13829 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13830 if (Cond.isInvalid())
13831 return ExprError();
13832
13833 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13834 if (LHS.isInvalid())
13835 return ExprError();
13836
13837 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13838 if (RHS.isInvalid())
13839 return ExprError();
13840
13841 if (!getDerived().AlwaysRebuild() &&
13842 Cond.get() == E->getCond() &&
13843 LHS.get() == E->getLHS() &&
13844 RHS.get() == E->getRHS())
13845 return E;
13846
13847 return getDerived().RebuildConditionalOperator(Cond.get(),
13848 E->getQuestionLoc(),
13849 LHS.get(),
13850 E->getColonLoc(),
13851 RHS.get());
13852}
13853
13854template<typename Derived>
13857 // Implicit casts are eliminated during transformation, since they
13858 // will be recomputed by semantic analysis after transformation.
13859 return getDerived().TransformExpr(E->getSubExprAsWritten());
13860}
13861
13862template<typename Derived>
13865 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
13866 if (!Type)
13867 return ExprError();
13868
13869 ExprResult SubExpr
13870 = getDerived().TransformExpr(E->getSubExprAsWritten());
13871 if (SubExpr.isInvalid())
13872 return ExprError();
13873
13874 if (!getDerived().AlwaysRebuild() &&
13875 Type == E->getTypeInfoAsWritten() &&
13876 SubExpr.get() == E->getSubExpr())
13877 return E;
13878
13879 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
13880 Type,
13881 E->getRParenLoc(),
13882 SubExpr.get());
13883}
13884
13885template<typename Derived>
13888 TypeSourceInfo *OldT = E->getTypeSourceInfo();
13889 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13890 if (!NewT)
13891 return ExprError();
13892
13893 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
13894 if (Init.isInvalid())
13895 return ExprError();
13896
13897 if (!getDerived().AlwaysRebuild() &&
13898 OldT == NewT &&
13899 Init.get() == E->getInitializer())
13900 return SemaRef.MaybeBindToTemporary(E);
13901
13902 // Note: the expression type doesn't necessarily match the
13903 // type-as-written, but that's okay, because it should always be
13904 // derivable from the initializer.
13905
13906 return getDerived().RebuildCompoundLiteralExpr(
13907 E->getLParenLoc(), NewT,
13908 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
13909}
13910
13911template<typename Derived>
13914 ExprResult Base = getDerived().TransformExpr(E->getBase());
13915 if (Base.isInvalid())
13916 return ExprError();
13917
13918 if (!getDerived().AlwaysRebuild() &&
13919 Base.get() == E->getBase())
13920 return E;
13921
13922 // FIXME: Bad source location
13923 SourceLocation FakeOperatorLoc =
13924 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
13925 return getDerived().RebuildExtVectorElementExpr(
13926 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
13927 E->getAccessor());
13928}
13929
13930template<typename Derived>
13933 if (InitListExpr *Syntactic = E->getSyntacticForm())
13934 E = Syntactic;
13935
13936 bool InitChanged = false;
13937
13940
13942 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
13943 Inits, &InitChanged))
13944 return ExprError();
13945
13946 if (!getDerived().AlwaysRebuild() && !InitChanged) {
13947 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
13948 // in some cases. We can't reuse it in general, because the syntactic and
13949 // semantic forms are linked, and we can't know that semantic form will
13950 // match even if the syntactic form does.
13951 }
13952
13953 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
13954 E->getRBraceLoc());
13955}
13956
13957template<typename Derived>
13960 Designation Desig;
13961
13962 // transform the initializer value
13963 ExprResult Init = getDerived().TransformExpr(E->getInit());
13964 if (Init.isInvalid())
13965 return ExprError();
13966
13967 // transform the designators.
13968 SmallVector<Expr*, 4> ArrayExprs;
13969 bool ExprChanged = false;
13970 for (const DesignatedInitExpr::Designator &D : E->designators()) {
13971 if (D.isFieldDesignator()) {
13972 if (D.getFieldDecl()) {
13973 FieldDecl *Field = cast_or_null<FieldDecl>(
13974 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
13975 if (Field != D.getFieldDecl())
13976 // Rebuild the expression when the transformed FieldDecl is
13977 // different to the already assigned FieldDecl.
13978 ExprChanged = true;
13979 if (Field->isAnonymousStructOrUnion())
13980 continue;
13981 } else {
13982 // Ensure that the designator expression is rebuilt when there isn't
13983 // a resolved FieldDecl in the designator as we don't want to assign
13984 // a FieldDecl to a pattern designator that will be instantiated again.
13985 ExprChanged = true;
13986 }
13987 Desig.AddDesignator(Designator::CreateFieldDesignator(
13988 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
13989 continue;
13990 }
13991
13992 if (D.isArrayDesignator()) {
13993 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
13994 if (Index.isInvalid())
13995 return ExprError();
13996
13997 Desig.AddDesignator(
13998 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
13999
14000 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
14001 ArrayExprs.push_back(Index.get());
14002 continue;
14003 }
14004
14005 assert(D.isArrayRangeDesignator() && "New kind of designator?");
14006 ExprResult Start
14007 = getDerived().TransformExpr(E->getArrayRangeStart(D));
14008 if (Start.isInvalid())
14009 return ExprError();
14010
14011 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
14012 if (End.isInvalid())
14013 return ExprError();
14014
14015 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
14016 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
14017
14018 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
14019 End.get() != E->getArrayRangeEnd(D);
14020
14021 ArrayExprs.push_back(Start.get());
14022 ArrayExprs.push_back(End.get());
14023 }
14024
14025 if (!getDerived().AlwaysRebuild() &&
14026 Init.get() == E->getInit() &&
14027 !ExprChanged)
14028 return E;
14029
14030 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14031 E->getEqualOrColonLoc(),
14032 E->usesGNUSyntax(), Init.get());
14033}
14034
14035// Seems that if TransformInitListExpr() only works on the syntactic form of an
14036// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14037template<typename Derived>
14041 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14042 "initializer");
14043 return ExprError();
14044}
14045
14046template<typename Derived>
14049 NoInitExpr *E) {
14050 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14051 return ExprError();
14052}
14053
14054template<typename Derived>
14057 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14058 return ExprError();
14059}
14060
14061template<typename Derived>
14064 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14065 return ExprError();
14066}
14067
14068template<typename Derived>
14072 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14073
14074 // FIXME: Will we ever have proper type location here? Will we actually
14075 // need to transform the type?
14076 QualType T = getDerived().TransformType(E->getType());
14077 if (T.isNull())
14078 return ExprError();
14079
14080 if (!getDerived().AlwaysRebuild() &&
14081 T == E->getType())
14082 return E;
14083
14084 return getDerived().RebuildImplicitValueInitExpr(T);
14085}
14086
14087template<typename Derived>
14090 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14091 if (!TInfo)
14092 return ExprError();
14093
14094 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14095 if (SubExpr.isInvalid())
14096 return ExprError();
14097
14098 if (!getDerived().AlwaysRebuild() &&
14099 TInfo == E->getWrittenTypeInfo() &&
14100 SubExpr.get() == E->getSubExpr())
14101 return E;
14102
14103 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14104 TInfo, E->getRParenLoc());
14105}
14106
14107template<typename Derived>
14110 bool ArgumentChanged = false;
14112 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14113 &ArgumentChanged))
14114 return ExprError();
14115
14116 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14117 Inits,
14118 E->getRParenLoc());
14119}
14120
14121/// Transform an address-of-label expression.
14122///
14123/// By default, the transformation of an address-of-label expression always
14124/// rebuilds the expression, so that the label identifier can be resolved to
14125/// the corresponding label statement by semantic analysis.
14126template<typename Derived>
14129 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14130 E->getLabel());
14131 if (!LD)
14132 return ExprError();
14133
14134 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14135 cast<LabelDecl>(LD));
14136}
14137
14138template<typename Derived>
14141 SemaRef.ActOnStartStmtExpr();
14142 StmtResult SubStmt
14143 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14144 if (SubStmt.isInvalid()) {
14145 SemaRef.ActOnStmtExprError();
14146 return ExprError();
14147 }
14148
14149 unsigned OldDepth = E->getTemplateDepth();
14150 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14151
14152 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14153 SubStmt.get() == E->getSubStmt()) {
14154 // Calling this an 'error' is unintuitive, but it does the right thing.
14155 SemaRef.ActOnStmtExprError();
14156 return SemaRef.MaybeBindToTemporary(E);
14157 }
14158
14159 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14160 E->getRParenLoc(), NewDepth);
14161}
14162
14163template<typename Derived>
14166 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14167 if (Cond.isInvalid())
14168 return ExprError();
14169
14170 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14171 if (LHS.isInvalid())
14172 return ExprError();
14173
14174 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14175 if (RHS.isInvalid())
14176 return ExprError();
14177
14178 if (!getDerived().AlwaysRebuild() &&
14179 Cond.get() == E->getCond() &&
14180 LHS.get() == E->getLHS() &&
14181 RHS.get() == E->getRHS())
14182 return E;
14183
14184 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14185 Cond.get(), LHS.get(), RHS.get(),
14186 E->getRParenLoc());
14187}
14188
14189template<typename Derived>
14192 return E;
14193}
14194
14195template<typename Derived>
14198 switch (E->getOperator()) {
14199 case OO_New:
14200 case OO_Delete:
14201 case OO_Array_New:
14202 case OO_Array_Delete:
14203 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14204
14205 case OO_Subscript:
14206 case OO_Call: {
14207 // This is a call to an object's operator().
14208 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14209
14210 // Transform the object itself.
14211 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14212 if (Object.isInvalid())
14213 return ExprError();
14214
14215 // FIXME: Poor location information. Also, if the location for the end of
14216 // the token is within a macro expansion, getLocForEndOfToken() will return
14217 // an invalid source location. If that happens and we have an otherwise
14218 // valid end location, use the valid one instead of the invalid one.
14219 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14220 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14221 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14222 FakeLParenLoc = EndLoc;
14223
14224 // Transform the call arguments.
14226 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14227 Args))
14228 return ExprError();
14229
14230 if (E->getOperator() == OO_Subscript)
14231 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14232 Args, E->getEndLoc());
14233
14234 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14235 E->getEndLoc());
14236 }
14237
14238#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14239 case OO_##Name: \
14240 break;
14241
14242#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14243#include "clang/Basic/OperatorKinds.def"
14244
14245 case OO_Conditional:
14246 llvm_unreachable("conditional operator is not actually overloadable");
14247
14248 case OO_None:
14250 llvm_unreachable("not an overloaded operator?");
14251 }
14252
14254 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14255 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14256 else
14257 First = getDerived().TransformExpr(E->getArg(0));
14258 if (First.isInvalid())
14259 return ExprError();
14260
14261 ExprResult Second;
14262 if (E->getNumArgs() == 2) {
14263 Second =
14264 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14265 if (Second.isInvalid())
14266 return ExprError();
14267 }
14268
14269 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14270 FPOptionsOverride NewOverrides(E->getFPFeatures());
14271 getSema().CurFPFeatures =
14272 NewOverrides.applyOverrides(getSema().getLangOpts());
14273 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14274
14275 Expr *Callee = E->getCallee();
14276 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14277 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14279 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14280 return ExprError();
14281
14282 return getDerived().RebuildCXXOperatorCallExpr(
14283 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14284 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14285 }
14286
14287 UnresolvedSet<1> Functions;
14288 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14289 Callee = ICE->getSubExprAsWritten();
14290 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14291 ValueDecl *VD = cast_or_null<ValueDecl>(
14292 getDerived().TransformDecl(DR->getLocation(), DR));
14293 if (!VD)
14294 return ExprError();
14295
14296 if (!isa<CXXMethodDecl>(VD))
14297 Functions.addDecl(VD);
14298
14299 return getDerived().RebuildCXXOperatorCallExpr(
14300 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14301 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14302}
14303
14304template<typename Derived>
14307 return getDerived().TransformCallExpr(E);
14308}
14309
14310template <typename Derived>
14312 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14313 getSema().CurContext != E->getParentContext();
14314
14315 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14316 return E;
14317
14318 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14319 E->getBeginLoc(), E->getEndLoc(),
14320 getSema().CurContext);
14321}
14322
14323template <typename Derived>
14325 return E;
14326}
14327
14328template<typename Derived>
14331 // Transform the callee.
14332 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14333 if (Callee.isInvalid())
14334 return ExprError();
14335
14336 // Transform exec config.
14337 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14338 if (EC.isInvalid())
14339 return ExprError();
14340
14341 // Transform arguments.
14342 bool ArgChanged = false;
14344 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14345 &ArgChanged))
14346 return ExprError();
14347
14348 if (!getDerived().AlwaysRebuild() &&
14349 Callee.get() == E->getCallee() &&
14350 !ArgChanged)
14351 return SemaRef.MaybeBindToTemporary(E);
14352
14353 // FIXME: Wrong source location information for the '('.
14354 SourceLocation FakeLParenLoc
14355 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14356 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14357 Args,
14358 E->getRParenLoc(), EC.get());
14359}
14360
14361template<typename Derived>
14364 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14365 if (!Type)
14366 return ExprError();
14367
14368 ExprResult SubExpr
14369 = getDerived().TransformExpr(E->getSubExprAsWritten());
14370 if (SubExpr.isInvalid())
14371 return ExprError();
14372
14373 if (!getDerived().AlwaysRebuild() &&
14374 Type == E->getTypeInfoAsWritten() &&
14375 SubExpr.get() == E->getSubExpr())
14376 return E;
14377 return getDerived().RebuildCXXNamedCastExpr(
14380 // FIXME. this should be '(' location
14381 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14382}
14383
14384template<typename Derived>
14387 TypeSourceInfo *TSI =
14388 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14389 if (!TSI)
14390 return ExprError();
14391
14392 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14393 if (Sub.isInvalid())
14394 return ExprError();
14395
14396 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14397 Sub.get(), BCE->getEndLoc());
14398}
14399
14400template<typename Derived>
14402TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14403 return getDerived().TransformCXXNamedCastExpr(E);
14404}
14405
14406template<typename Derived>
14409 return getDerived().TransformCXXNamedCastExpr(E);
14410}
14411
14412template<typename Derived>
14416 return getDerived().TransformCXXNamedCastExpr(E);
14417}
14418
14419template<typename Derived>
14422 return getDerived().TransformCXXNamedCastExpr(E);
14423}
14424
14425template<typename Derived>
14428 return getDerived().TransformCXXNamedCastExpr(E);
14429}
14430
14431template<typename Derived>
14436 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14437 if (!Type)
14438 return ExprError();
14439
14440 ExprResult SubExpr
14441 = getDerived().TransformExpr(E->getSubExprAsWritten());
14442 if (SubExpr.isInvalid())
14443 return ExprError();
14444
14445 if (!getDerived().AlwaysRebuild() &&
14446 Type == E->getTypeInfoAsWritten() &&
14447 SubExpr.get() == E->getSubExpr())
14448 return E;
14449
14450 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14451 E->getLParenLoc(),
14452 SubExpr.get(),
14453 E->getRParenLoc(),
14454 E->isListInitialization());
14455}
14456
14457template<typename Derived>
14460 if (E->isTypeOperand()) {
14461 TypeSourceInfo *TInfo
14462 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14463 if (!TInfo)
14464 return ExprError();
14465
14466 if (!getDerived().AlwaysRebuild() &&
14467 TInfo == E->getTypeOperandSourceInfo())
14468 return E;
14469
14470 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14471 TInfo, E->getEndLoc());
14472 }
14473
14474 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14475 // type. We must not unilaterally enter unevaluated context here, as then
14476 // semantic processing can re-transform an already transformed operand.
14477 Expr *Op = E->getExprOperand();
14479 if (E->isGLValue())
14480 if (auto *RD = Op->getType()->getAsCXXRecordDecl();
14481 RD && RD->isPolymorphic())
14482 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14483
14486
14487 ExprResult SubExpr = getDerived().TransformExpr(Op);
14488 if (SubExpr.isInvalid())
14489 return ExprError();
14490
14491 if (!getDerived().AlwaysRebuild() &&
14492 SubExpr.get() == E->getExprOperand())
14493 return E;
14494
14495 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14496 SubExpr.get(), E->getEndLoc());
14497}
14498
14499template<typename Derived>
14502 if (E->isTypeOperand()) {
14503 TypeSourceInfo *TInfo
14504 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14505 if (!TInfo)
14506 return ExprError();
14507
14508 if (!getDerived().AlwaysRebuild() &&
14509 TInfo == E->getTypeOperandSourceInfo())
14510 return E;
14511
14512 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14513 TInfo, E->getEndLoc());
14514 }
14515
14518
14519 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14520 if (SubExpr.isInvalid())
14521 return ExprError();
14522
14523 if (!getDerived().AlwaysRebuild() &&
14524 SubExpr.get() == E->getExprOperand())
14525 return E;
14526
14527 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14528 SubExpr.get(), E->getEndLoc());
14529}
14530
14531template<typename Derived>
14534 return E;
14535}
14536
14537template<typename Derived>
14541 return E;
14542}
14543
14544template<typename Derived>
14547
14548 // In lambdas, the qualifiers of the type depends of where in
14549 // the call operator `this` appear, and we do not have a good way to
14550 // rebuild this information, so we transform the type.
14551 //
14552 // In other contexts, the type of `this` may be overrided
14553 // for type deduction, so we need to recompute it.
14554 //
14555 // Always recompute the type if we're in the body of a lambda, and
14556 // 'this' is dependent on a lambda's explicit object parameter; we
14557 // also need to always rebuild the expression in this case to clear
14558 // the flag.
14559 QualType T = [&]() {
14560 auto &S = getSema();
14561 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14562 return S.getCurrentThisType();
14563 if (S.getCurLambda())
14564 return getDerived().TransformType(E->getType());
14565 return S.getCurrentThisType();
14566 }();
14567
14568 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14569 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14570 // Mark it referenced in the new context regardless.
14571 // FIXME: this is a bit instantiation-specific.
14572 getSema().MarkThisReferenced(E);
14573 return E;
14574 }
14575
14576 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14577}
14578
14579template<typename Derived>
14582 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14583 if (SubExpr.isInvalid())
14584 return ExprError();
14585
14586 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14587
14588 if (!getDerived().AlwaysRebuild() &&
14589 SubExpr.get() == E->getSubExpr())
14590 return E;
14591
14592 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14593 E->isThrownVariableInScope());
14594}
14595
14596template<typename Derived>
14599 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14600 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14601 if (!Param)
14602 return ExprError();
14603
14604 ExprResult InitRes;
14605 if (E->hasRewrittenInit()) {
14606 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14607 if (InitRes.isInvalid())
14608 return ExprError();
14609 }
14610
14611 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14612 E->getUsedContext() == SemaRef.CurContext &&
14613 InitRes.get() == E->getRewrittenExpr())
14614 return E;
14615
14616 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14617 InitRes.get());
14618}
14619
14620template<typename Derived>
14623 FieldDecl *Field = cast_or_null<FieldDecl>(
14624 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14625 if (!Field)
14626 return ExprError();
14627
14628 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14629 E->getUsedContext() == SemaRef.CurContext)
14630 return E;
14631
14632 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14633}
14634
14635template<typename Derived>
14639 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14640 if (!T)
14641 return ExprError();
14642
14643 if (!getDerived().AlwaysRebuild() &&
14644 T == E->getTypeSourceInfo())
14645 return E;
14646
14647 return getDerived().RebuildCXXScalarValueInitExpr(T,
14648 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14649 E->getRParenLoc());
14650}
14651
14652template<typename Derived>
14655 // Transform the type that we're allocating
14656 TypeSourceInfo *AllocTypeInfo =
14657 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14658 if (!AllocTypeInfo)
14659 return ExprError();
14660
14661 // Transform the size of the array we're allocating (if any).
14662 std::optional<Expr *> ArraySize;
14663 if (E->isArray()) {
14664 ExprResult NewArraySize;
14665 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14666 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14667 if (NewArraySize.isInvalid())
14668 return ExprError();
14669 }
14670 ArraySize = NewArraySize.get();
14671 }
14672
14673 // Transform the placement arguments (if any).
14674 bool ArgumentChanged = false;
14675 SmallVector<Expr*, 8> PlacementArgs;
14676 if (getDerived().TransformExprs(E->getPlacementArgs(),
14677 E->getNumPlacementArgs(), true,
14678 PlacementArgs, &ArgumentChanged))
14679 return ExprError();
14680
14681 // Transform the initializer (if any).
14682 Expr *OldInit = E->getInitializer();
14683 ExprResult NewInit;
14684 if (OldInit)
14685 NewInit = getDerived().TransformInitializer(OldInit, true);
14686 if (NewInit.isInvalid())
14687 return ExprError();
14688
14689 // Transform new operator and delete operator.
14690 FunctionDecl *OperatorNew = nullptr;
14691 if (E->getOperatorNew()) {
14692 OperatorNew = cast_or_null<FunctionDecl>(
14693 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14694 if (!OperatorNew)
14695 return ExprError();
14696 }
14697
14698 FunctionDecl *OperatorDelete = nullptr;
14699 if (E->getOperatorDelete()) {
14700 OperatorDelete = cast_or_null<FunctionDecl>(
14701 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14702 if (!OperatorDelete)
14703 return ExprError();
14704 }
14705
14706 if (!getDerived().AlwaysRebuild() &&
14707 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14708 ArraySize == E->getArraySize() &&
14709 NewInit.get() == OldInit &&
14710 OperatorNew == E->getOperatorNew() &&
14711 OperatorDelete == E->getOperatorDelete() &&
14712 !ArgumentChanged) {
14713 // Mark any declarations we need as referenced.
14714 // FIXME: instantiation-specific.
14715 if (OperatorNew)
14716 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14717 if (OperatorDelete)
14718 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14719
14720 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14721 QualType ElementType
14722 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14723 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14725 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14726 }
14727 }
14728
14729 return E;
14730 }
14731
14732 QualType AllocType = AllocTypeInfo->getType();
14733 if (!ArraySize) {
14734 // If no array size was specified, but the new expression was
14735 // instantiated with an array type (e.g., "new T" where T is
14736 // instantiated with "int[4]"), extract the outer bound from the
14737 // array type as our array size. We do this with constant and
14738 // dependently-sized array types.
14739 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14740 if (!ArrayT) {
14741 // Do nothing
14742 } else if (const ConstantArrayType *ConsArrayT
14743 = dyn_cast<ConstantArrayType>(ArrayT)) {
14744 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14745 SemaRef.Context.getSizeType(),
14746 /*FIXME:*/ E->getBeginLoc());
14747 AllocType = ConsArrayT->getElementType();
14748 } else if (const DependentSizedArrayType *DepArrayT
14749 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14750 if (DepArrayT->getSizeExpr()) {
14751 ArraySize = DepArrayT->getSizeExpr();
14752 AllocType = DepArrayT->getElementType();
14753 }
14754 }
14755 }
14756
14757 return getDerived().RebuildCXXNewExpr(
14758 E->getBeginLoc(), E->isGlobalNew(),
14759 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14760 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14761 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14762}
14763
14764template<typename Derived>
14767 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14768 if (Operand.isInvalid())
14769 return ExprError();
14770
14771 // Transform the delete operator, if known.
14772 FunctionDecl *OperatorDelete = nullptr;
14773 if (E->getOperatorDelete()) {
14774 OperatorDelete = cast_or_null<FunctionDecl>(
14775 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14776 if (!OperatorDelete)
14777 return ExprError();
14778 }
14779
14780 if (!getDerived().AlwaysRebuild() &&
14781 Operand.get() == E->getArgument() &&
14782 OperatorDelete == E->getOperatorDelete()) {
14783 // Mark any declarations we need as referenced.
14784 // FIXME: instantiation-specific.
14785 if (OperatorDelete)
14786 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14787
14788 if (!E->getArgument()->isTypeDependent()) {
14789 QualType Destroyed = SemaRef.Context.getBaseElementType(
14790 E->getDestroyedType());
14791 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14792 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14793 SemaRef.LookupDestructor(Record));
14794 }
14795
14796 return E;
14797 }
14798
14799 return getDerived().RebuildCXXDeleteExpr(
14800 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14801}
14802
14803template<typename Derived>
14807 ExprResult Base = getDerived().TransformExpr(E->getBase());
14808 if (Base.isInvalid())
14809 return ExprError();
14810
14811 ParsedType ObjectTypePtr;
14812 bool MayBePseudoDestructor = false;
14813 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14814 E->getOperatorLoc(),
14815 E->isArrow()? tok::arrow : tok::period,
14816 ObjectTypePtr,
14817 MayBePseudoDestructor);
14818 if (Base.isInvalid())
14819 return ExprError();
14820
14821 QualType ObjectType = ObjectTypePtr.get();
14822 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
14823 if (QualifierLoc) {
14824 QualifierLoc
14825 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
14826 if (!QualifierLoc)
14827 return ExprError();
14828 }
14829 CXXScopeSpec SS;
14830 SS.Adopt(QualifierLoc);
14831
14833 if (E->getDestroyedTypeInfo()) {
14834 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
14835 E->getDestroyedTypeInfo(), ObjectType,
14836 /*FirstQualifierInScope=*/nullptr);
14837 if (!DestroyedTypeInfo)
14838 return ExprError();
14839 Destroyed = DestroyedTypeInfo;
14840 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
14841 // We aren't likely to be able to resolve the identifier down to a type
14842 // now anyway, so just retain the identifier.
14843 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
14844 E->getDestroyedTypeLoc());
14845 } else {
14846 // Look for a destructor known with the given name.
14847 ParsedType T = SemaRef.getDestructorName(
14848 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
14849 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
14850 if (!T)
14851 return ExprError();
14852
14853 Destroyed
14855 E->getDestroyedTypeLoc());
14856 }
14857
14858 TypeSourceInfo *ScopeTypeInfo = nullptr;
14859 if (E->getScopeTypeInfo()) {
14860 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
14861 E->getScopeTypeInfo(), ObjectType, nullptr);
14862 if (!ScopeTypeInfo)
14863 return ExprError();
14864 }
14865
14866 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
14867 E->getOperatorLoc(),
14868 E->isArrow(),
14869 SS,
14870 ScopeTypeInfo,
14871 E->getColonColonLoc(),
14872 E->getTildeLoc(),
14873 Destroyed);
14874}
14875
14876template <typename Derived>
14878 bool RequiresADL,
14879 LookupResult &R) {
14880 // Transform all the decls.
14881 bool AllEmptyPacks = true;
14882 for (auto *OldD : Old->decls()) {
14883 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
14884 if (!InstD) {
14885 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
14886 // This can happen because of dependent hiding.
14887 if (isa<UsingShadowDecl>(OldD))
14888 continue;
14889 else {
14890 R.clear();
14891 return true;
14892 }
14893 }
14894
14895 // Expand using pack declarations.
14896 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
14897 ArrayRef<NamedDecl*> Decls = SingleDecl;
14898 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
14899 Decls = UPD->expansions();
14900
14901 // Expand using declarations.
14902 for (auto *D : Decls) {
14903 if (auto *UD = dyn_cast<UsingDecl>(D)) {
14904 for (auto *SD : UD->shadows())
14905 R.addDecl(SD);
14906 } else {
14907 R.addDecl(D);
14908 }
14909 }
14910
14911 AllEmptyPacks &= Decls.empty();
14912 }
14913
14914 // C++ [temp.res]/8.4.2:
14915 // The program is ill-formed, no diagnostic required, if [...] lookup for
14916 // a name in the template definition found a using-declaration, but the
14917 // lookup in the corresponding scope in the instantiation odoes not find
14918 // any declarations because the using-declaration was a pack expansion and
14919 // the corresponding pack is empty
14920 if (AllEmptyPacks && !RequiresADL) {
14921 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
14922 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
14923 return true;
14924 }
14925
14926 // Resolve a kind, but don't do any further analysis. If it's
14927 // ambiguous, the callee needs to deal with it.
14928 R.resolveKind();
14929
14930 if (Old->hasTemplateKeyword() && !R.empty()) {
14932 getSema().FilterAcceptableTemplateNames(R,
14933 /*AllowFunctionTemplates=*/true,
14934 /*AllowDependent=*/true);
14935 if (R.empty()) {
14936 // If a 'template' keyword was used, a lookup that finds only non-template
14937 // names is an error.
14938 getSema().Diag(R.getNameLoc(),
14939 diag::err_template_kw_refers_to_non_template)
14941 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
14942 getSema().Diag(FoundDecl->getLocation(),
14943 diag::note_template_kw_refers_to_non_template)
14944 << R.getLookupName();
14945 return true;
14946 }
14947 }
14948
14949 return false;
14950}
14951
14952template <typename Derived>
14957
14958template <typename Derived>
14961 bool IsAddressOfOperand) {
14962 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
14964
14965 // Transform the declaration set.
14966 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
14967 return ExprError();
14968
14969 // Rebuild the nested-name qualifier, if present.
14970 CXXScopeSpec SS;
14971 if (Old->getQualifierLoc()) {
14972 NestedNameSpecifierLoc QualifierLoc
14973 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
14974 if (!QualifierLoc)
14975 return ExprError();
14976
14977 SS.Adopt(QualifierLoc);
14978 }
14979
14980 if (Old->getNamingClass()) {
14981 CXXRecordDecl *NamingClass
14982 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
14983 Old->getNameLoc(),
14984 Old->getNamingClass()));
14985 if (!NamingClass) {
14986 R.clear();
14987 return ExprError();
14988 }
14989
14990 R.setNamingClass(NamingClass);
14991 }
14992
14993 // Rebuild the template arguments, if any.
14994 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
14995 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
14996 if (Old->hasExplicitTemplateArgs() &&
14997 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
14998 Old->getNumTemplateArgs(),
14999 TransArgs)) {
15000 R.clear();
15001 return ExprError();
15002 }
15003
15004 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
15005 // a non-static data member is named in an unevaluated operand, or when
15006 // a member is named in a dependent class scope function template explicit
15007 // specialization that is neither declared static nor with an explicit object
15008 // parameter.
15009 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
15010 return SemaRef.BuildPossibleImplicitMemberExpr(
15011 SS, TemplateKWLoc, R,
15012 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
15013 /*S=*/nullptr);
15014
15015 // If we have neither explicit template arguments, nor the template keyword,
15016 // it's a normal declaration name or member reference.
15017 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
15018 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
15019
15020 // If we have template arguments, then rebuild the template-id expression.
15021 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
15022 Old->requiresADL(), &TransArgs);
15023}
15024
15025template<typename Derived>
15028 bool ArgChanged = false;
15030 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15031 TypeSourceInfo *From = E->getArg(I);
15032 TypeLoc FromTL = From->getTypeLoc();
15033 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15034 TypeLocBuilder TLB;
15035 TLB.reserve(FromTL.getFullDataSize());
15036 QualType To = getDerived().TransformType(TLB, FromTL);
15037 if (To.isNull())
15038 return ExprError();
15039
15040 if (To == From->getType())
15041 Args.push_back(From);
15042 else {
15043 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15044 ArgChanged = true;
15045 }
15046 continue;
15047 }
15048
15049 ArgChanged = true;
15050
15051 // We have a pack expansion. Instantiate it.
15052 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15053 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15055 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15056
15057 // Determine whether the set of unexpanded parameter packs can and should
15058 // be expanded.
15059 bool Expand = true;
15060 bool RetainExpansion = false;
15061 UnsignedOrNone OrigNumExpansions =
15062 ExpansionTL.getTypePtr()->getNumExpansions();
15063 UnsignedOrNone NumExpansions = OrigNumExpansions;
15064 if (getDerived().TryExpandParameterPacks(
15065 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15066 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15067 RetainExpansion, NumExpansions))
15068 return ExprError();
15069
15070 if (!Expand) {
15071 // The transform has determined that we should perform a simple
15072 // transformation on the pack expansion, producing another pack
15073 // expansion.
15074 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15075
15076 TypeLocBuilder TLB;
15077 TLB.reserve(From->getTypeLoc().getFullDataSize());
15078
15079 QualType To = getDerived().TransformType(TLB, PatternTL);
15080 if (To.isNull())
15081 return ExprError();
15082
15083 To = getDerived().RebuildPackExpansionType(To,
15084 PatternTL.getSourceRange(),
15085 ExpansionTL.getEllipsisLoc(),
15086 NumExpansions);
15087 if (To.isNull())
15088 return ExprError();
15089
15090 PackExpansionTypeLoc ToExpansionTL
15091 = TLB.push<PackExpansionTypeLoc>(To);
15092 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15093 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15094 continue;
15095 }
15096
15097 // Expand the pack expansion by substituting for each argument in the
15098 // pack(s).
15099 for (unsigned I = 0; I != *NumExpansions; ++I) {
15100 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15101 TypeLocBuilder TLB;
15102 TLB.reserve(PatternTL.getFullDataSize());
15103 QualType To = getDerived().TransformType(TLB, PatternTL);
15104 if (To.isNull())
15105 return ExprError();
15106
15107 if (To->containsUnexpandedParameterPack()) {
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 }
15119
15120 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15121 }
15122
15123 if (!RetainExpansion)
15124 continue;
15125
15126 // If we're supposed to retain a pack expansion, do so by temporarily
15127 // forgetting the partially-substituted parameter pack.
15128 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15129
15130 TypeLocBuilder TLB;
15131 TLB.reserve(From->getTypeLoc().getFullDataSize());
15132
15133 QualType To = getDerived().TransformType(TLB, PatternTL);
15134 if (To.isNull())
15135 return ExprError();
15136
15137 To = getDerived().RebuildPackExpansionType(To,
15138 PatternTL.getSourceRange(),
15139 ExpansionTL.getEllipsisLoc(),
15140 NumExpansions);
15141 if (To.isNull())
15142 return ExprError();
15143
15144 PackExpansionTypeLoc ToExpansionTL
15145 = TLB.push<PackExpansionTypeLoc>(To);
15146 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15147 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15148 }
15149
15150 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15151 return E;
15152
15153 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15154 E->getEndLoc());
15155}
15156
15157template<typename Derived>
15161 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15162 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15163 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15164 Old->NumTemplateArgs, TransArgs))
15165 return ExprError();
15166
15167 return getDerived().RebuildConceptSpecializationExpr(
15168 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15169 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15170 &TransArgs);
15171}
15172
15173template<typename Derived>
15176 SmallVector<ParmVarDecl*, 4> TransParams;
15177 SmallVector<QualType, 4> TransParamTypes;
15178 Sema::ExtParameterInfoBuilder ExtParamInfos;
15179
15180 // C++2a [expr.prim.req]p2
15181 // Expressions appearing within a requirement-body are unevaluated operands.
15185
15187 getSema().Context, getSema().CurContext,
15188 E->getBody()->getBeginLoc());
15189
15190 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15191
15192 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15193 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15194 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15195
15196 for (ParmVarDecl *Param : TransParams)
15197 if (Param)
15198 Param->setDeclContext(Body);
15199
15200 // On failure to transform, TransformRequiresTypeParams returns an expression
15201 // in the event that the transformation of the type params failed in some way.
15202 // It is expected that this will result in a 'not satisfied' Requires clause
15203 // when instantiating.
15204 if (!TypeParamResult.isUnset())
15205 return TypeParamResult;
15206
15208 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15209 TransReqs))
15210 return ExprError();
15211
15212 for (concepts::Requirement *Req : TransReqs) {
15213 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15214 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15215 ER->getReturnTypeRequirement()
15216 .getTypeConstraintTemplateParameterList()->getParam(0)
15217 ->setDeclContext(Body);
15218 }
15219 }
15220 }
15221
15222 return getDerived().RebuildRequiresExpr(
15223 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15224 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15225}
15226
15227template<typename Derived>
15231 for (concepts::Requirement *Req : Reqs) {
15232 concepts::Requirement *TransReq = nullptr;
15233 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15234 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15235 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15236 TransReq = getDerived().TransformExprRequirement(ExprReq);
15237 else
15238 TransReq = getDerived().TransformNestedRequirement(
15240 if (!TransReq)
15241 return true;
15242 Transformed.push_back(TransReq);
15243 }
15244 return false;
15245}
15246
15247template<typename Derived>
15251 if (Req->isSubstitutionFailure()) {
15252 if (getDerived().AlwaysRebuild())
15253 return getDerived().RebuildTypeRequirement(
15255 return Req;
15256 }
15257 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15258 if (!TransType)
15259 return nullptr;
15260 return getDerived().RebuildTypeRequirement(TransType);
15261}
15262
15263template<typename Derived>
15266 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15267 if (Req->isExprSubstitutionFailure())
15268 TransExpr = Req->getExprSubstitutionDiagnostic();
15269 else {
15270 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15271 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15272 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15273 if (TransExprRes.isInvalid())
15274 return nullptr;
15275 TransExpr = TransExprRes.get();
15276 }
15277
15278 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15279 const auto &RetReq = Req->getReturnTypeRequirement();
15280 if (RetReq.isEmpty())
15281 TransRetReq.emplace();
15282 else if (RetReq.isSubstitutionFailure())
15283 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15284 else if (RetReq.isTypeConstraint()) {
15285 TemplateParameterList *OrigTPL =
15286 RetReq.getTypeConstraintTemplateParameterList();
15288 getDerived().TransformTemplateParameterList(OrigTPL);
15289 if (!TPL)
15290 return nullptr;
15291 TransRetReq.emplace(TPL);
15292 }
15293 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15294 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15295 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15296 Req->getNoexceptLoc(),
15297 std::move(*TransRetReq));
15298 return getDerived().RebuildExprRequirement(
15300 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15301}
15302
15303template<typename Derived>
15307 if (Req->hasInvalidConstraint()) {
15308 if (getDerived().AlwaysRebuild())
15309 return getDerived().RebuildNestedRequirement(
15311 return Req;
15312 }
15313 ExprResult TransConstraint =
15314 getDerived().TransformExpr(Req->getConstraintExpr());
15315 if (TransConstraint.isInvalid())
15316 return nullptr;
15317 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15318}
15319
15320template<typename Derived>
15323 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15324 if (!T)
15325 return ExprError();
15326
15327 if (!getDerived().AlwaysRebuild() &&
15329 return E;
15330
15331 ExprResult SubExpr;
15332 {
15335 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15336 if (SubExpr.isInvalid())
15337 return ExprError();
15338 }
15339
15340 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15341 SubExpr.get(), E->getEndLoc());
15342}
15343
15344template<typename Derived>
15347 ExprResult SubExpr;
15348 {
15351 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15352 if (SubExpr.isInvalid())
15353 return ExprError();
15354
15355 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15356 return E;
15357 }
15358
15359 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15360 SubExpr.get(), E->getEndLoc());
15361}
15362
15363template <typename Derived>
15365 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15366 TypeSourceInfo **RecoveryTSI) {
15367 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15368 DRE, AddrTaken, RecoveryTSI);
15369
15370 // Propagate both errors and recovered types, which return ExprEmpty.
15371 if (!NewDRE.isUsable())
15372 return NewDRE;
15373
15374 // We got an expr, wrap it up in parens.
15375 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15376 return PE;
15377 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15378 PE->getRParen());
15379}
15380
15381template <typename Derived>
15387
15388template <typename Derived>
15390 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15391 TypeSourceInfo **RecoveryTSI) {
15392 assert(E->getQualifierLoc());
15393 NestedNameSpecifierLoc QualifierLoc =
15394 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15395 if (!QualifierLoc)
15396 return ExprError();
15397 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15398
15399 // TODO: If this is a conversion-function-id, verify that the
15400 // destination type name (if present) resolves the same way after
15401 // instantiation as it did in the local scope.
15402
15403 DeclarationNameInfo NameInfo =
15404 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15405 if (!NameInfo.getName())
15406 return ExprError();
15407
15408 if (!E->hasExplicitTemplateArgs()) {
15409 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15410 // Note: it is sufficient to compare the Name component of NameInfo:
15411 // if name has not changed, DNLoc has not changed either.
15412 NameInfo.getName() == E->getDeclName())
15413 return E;
15414
15415 return getDerived().RebuildDependentScopeDeclRefExpr(
15416 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15417 IsAddressOfOperand, RecoveryTSI);
15418 }
15419
15420 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15421 if (getDerived().TransformTemplateArguments(
15422 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15423 return ExprError();
15424
15425 return getDerived().RebuildDependentScopeDeclRefExpr(
15426 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15427 RecoveryTSI);
15428}
15429
15430template<typename Derived>
15433 // CXXConstructExprs other than for list-initialization and
15434 // CXXTemporaryObjectExpr are always implicit, so when we have
15435 // a 1-argument construction we just transform that argument.
15436 if (getDerived().AllowSkippingCXXConstructExpr() &&
15437 ((E->getNumArgs() == 1 ||
15438 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15439 (!getDerived().DropCallArgument(E->getArg(0))) &&
15440 !E->isListInitialization()))
15441 return getDerived().TransformInitializer(E->getArg(0),
15442 /*DirectInit*/ false);
15443
15444 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15445
15446 QualType T = getDerived().TransformType(E->getType());
15447 if (T.isNull())
15448 return ExprError();
15449
15450 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15451 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15452 if (!Constructor)
15453 return ExprError();
15454
15455 bool ArgumentChanged = false;
15457 {
15460 E->isListInitialization());
15461 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15462 &ArgumentChanged))
15463 return ExprError();
15464 }
15465
15466 if (!getDerived().AlwaysRebuild() &&
15467 T == E->getType() &&
15468 Constructor == E->getConstructor() &&
15469 !ArgumentChanged) {
15470 // Mark the constructor as referenced.
15471 // FIXME: Instantiation-specific
15472 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15473 return E;
15474 }
15475
15476 return getDerived().RebuildCXXConstructExpr(
15477 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15478 E->hadMultipleCandidates(), E->isListInitialization(),
15479 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15480 E->getConstructionKind(), E->getParenOrBraceRange());
15481}
15482
15483template<typename Derived>
15486 QualType T = getDerived().TransformType(E->getType());
15487 if (T.isNull())
15488 return ExprError();
15489
15490 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15491 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15492 if (!Constructor)
15493 return ExprError();
15494
15495 if (!getDerived().AlwaysRebuild() &&
15496 T == E->getType() &&
15497 Constructor == E->getConstructor()) {
15498 // Mark the constructor as referenced.
15499 // FIXME: Instantiation-specific
15500 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15501 return E;
15502 }
15503
15504 return getDerived().RebuildCXXInheritedCtorInitExpr(
15505 T, E->getLocation(), Constructor,
15506 E->constructsVBase(), E->inheritedFromVBase());
15507}
15508
15509/// Transform a C++ temporary-binding expression.
15510///
15511/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15512/// transform the subexpression and return that.
15513template<typename Derived>
15516 if (auto *Dtor = E->getTemporary()->getDestructor())
15517 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15518 const_cast<CXXDestructorDecl *>(Dtor));
15519 return getDerived().TransformExpr(E->getSubExpr());
15520}
15521
15522/// Transform a C++ expression that contains cleanups that should
15523/// be run after the expression is evaluated.
15524///
15525/// Since ExprWithCleanups nodes are implicitly generated, we
15526/// just transform the subexpression and return that.
15527template<typename Derived>
15530 return getDerived().TransformExpr(E->getSubExpr());
15531}
15532
15533template<typename Derived>
15537 TypeSourceInfo *T =
15538 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15539 if (!T)
15540 return ExprError();
15541
15542 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15543 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15544 if (!Constructor)
15545 return ExprError();
15546
15547 bool ArgumentChanged = false;
15549 Args.reserve(E->getNumArgs());
15550 {
15553 E->isListInitialization());
15554 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15555 &ArgumentChanged))
15556 return ExprError();
15557
15558 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15559 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc());
15560 if (Res.isInvalid())
15561 return ExprError();
15562 Args = {Res.get()};
15563 }
15564 }
15565
15566 if (!getDerived().AlwaysRebuild() &&
15567 T == E->getTypeSourceInfo() &&
15568 Constructor == E->getConstructor() &&
15569 !ArgumentChanged) {
15570 // FIXME: Instantiation-specific
15571 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15572 return SemaRef.MaybeBindToTemporary(E);
15573 }
15574
15575 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15576 return getDerived().RebuildCXXTemporaryObjectExpr(
15577 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15578}
15579
15580template<typename Derived>
15583 // Transform any init-capture expressions before entering the scope of the
15584 // lambda body, because they are not semantically within that scope.
15585 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15586 struct TransformedInitCapture {
15587 // The location of the ... if the result is retaining a pack expansion.
15588 SourceLocation EllipsisLoc;
15589 // Zero or more expansions of the init-capture.
15590 SmallVector<InitCaptureInfoTy, 4> Expansions;
15591 };
15593 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15594 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15595 CEnd = E->capture_end();
15596 C != CEnd; ++C) {
15597 if (!E->isInitCapture(C))
15598 continue;
15599
15600 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15601 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15602
15603 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15604 UnsignedOrNone NumExpansions) {
15605 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15606 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15607
15608 if (NewExprInitResult.isInvalid()) {
15609 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15610 return;
15611 }
15612 Expr *NewExprInit = NewExprInitResult.get();
15613
15614 QualType NewInitCaptureType =
15615 getSema().buildLambdaInitCaptureInitialization(
15616 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15617 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15618 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15620 NewExprInit);
15621 Result.Expansions.push_back(
15622 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15623 };
15624
15625 // If this is an init-capture pack, consider expanding the pack now.
15626 if (OldVD->isParameterPack()) {
15627 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15628 ->getTypeLoc()
15631 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15632
15633 // Determine whether the set of unexpanded parameter packs can and should
15634 // be expanded.
15635 bool Expand = true;
15636 bool RetainExpansion = false;
15637 UnsignedOrNone OrigNumExpansions =
15638 ExpansionTL.getTypePtr()->getNumExpansions();
15639 UnsignedOrNone NumExpansions = OrigNumExpansions;
15640 if (getDerived().TryExpandParameterPacks(
15641 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15642 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15643 RetainExpansion, NumExpansions))
15644 return ExprError();
15645 assert(!RetainExpansion && "Should not need to retain expansion after a "
15646 "capture since it cannot be extended");
15647 if (Expand) {
15648 for (unsigned I = 0; I != *NumExpansions; ++I) {
15649 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15650 SubstInitCapture(SourceLocation(), std::nullopt);
15651 }
15652 } else {
15653 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15654 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15655 }
15656 } else {
15657 SubstInitCapture(SourceLocation(), std::nullopt);
15658 }
15659 }
15660
15661 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15662 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15663
15664 // Create the local class that will describe the lambda.
15665
15666 // FIXME: DependencyKind below is wrong when substituting inside a templated
15667 // context that isn't a DeclContext (such as a variable template), or when
15668 // substituting an unevaluated lambda inside of a function's parameter's type
15669 // - as parameter types are not instantiated from within a function's DC. We
15670 // use evaluation contexts to distinguish the function parameter case.
15673 DeclContext *DC = getSema().CurContext;
15674 // A RequiresExprBodyDecl is not interesting for dependencies.
15675 // For the following case,
15676 //
15677 // template <typename>
15678 // concept C = requires { [] {}; };
15679 //
15680 // template <class F>
15681 // struct Widget;
15682 //
15683 // template <C F>
15684 // struct Widget<F> {};
15685 //
15686 // While we are substituting Widget<F>, the parent of DC would be
15687 // the template specialization itself. Thus, the lambda expression
15688 // will be deemed as dependent even if there are no dependent template
15689 // arguments.
15690 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15691 while (DC->isRequiresExprBody())
15692 DC = DC->getParent();
15693 if ((getSema().isUnevaluatedContext() ||
15694 getSema().isConstantEvaluatedContext()) &&
15695 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15696 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
15697 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15698 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15699
15700 CXXRecordDecl *OldClass = E->getLambdaClass();
15701 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15702 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15703 E->getCaptureDefault());
15704 getDerived().transformedLocalDecl(OldClass, {Class});
15705
15706 CXXMethodDecl *NewCallOperator =
15707 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15708
15709 // Enter the scope of the lambda.
15710 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15711 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15712 E->hasExplicitParameters(), E->isMutable());
15713
15714 // Introduce the context of the call operator.
15715 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15716 /*NewThisContext*/false);
15717
15718 bool Invalid = false;
15719
15720 // Transform captures.
15721 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15722 CEnd = E->capture_end();
15723 C != CEnd; ++C) {
15724 // When we hit the first implicit capture, tell Sema that we've finished
15725 // the list of explicit captures.
15726 if (C->isImplicit())
15727 break;
15728
15729 // Capturing 'this' is trivial.
15730 if (C->capturesThis()) {
15731 // If this is a lambda that is part of a default member initialiser
15732 // and which we're instantiating outside the class that 'this' is
15733 // supposed to refer to, adjust the type of 'this' accordingly.
15734 //
15735 // Otherwise, leave the type of 'this' as-is.
15736 Sema::CXXThisScopeRAII ThisScope(
15737 getSema(),
15738 dyn_cast_if_present<CXXRecordDecl>(
15739 getSema().getFunctionLevelDeclContext()),
15740 Qualifiers());
15741 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15742 /*BuildAndDiagnose*/ true, nullptr,
15743 C->getCaptureKind() == LCK_StarThis);
15744 continue;
15745 }
15746 // Captured expression will be recaptured during captured variables
15747 // rebuilding.
15748 if (C->capturesVLAType())
15749 continue;
15750
15751 // Rebuild init-captures, including the implied field declaration.
15752 if (E->isInitCapture(C)) {
15753 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15754
15755 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15757
15758 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15759 ExprResult Init = Info.first;
15760 QualType InitQualType = Info.second;
15761 if (Init.isInvalid() || InitQualType.isNull()) {
15762 Invalid = true;
15763 break;
15764 }
15765 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15766 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15767 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15768 getSema().CurContext);
15769 if (!NewVD) {
15770 Invalid = true;
15771 break;
15772 }
15773 NewVDs.push_back(NewVD);
15774 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15775 // Cases we want to tackle:
15776 // ([C(Pack)] {}, ...)
15777 // But rule out cases e.g.
15778 // [...C = Pack()] {}
15779 if (NewC.EllipsisLoc.isInvalid())
15780 LSI->ContainsUnexpandedParameterPack |=
15781 Init.get()->containsUnexpandedParameterPack();
15782 }
15783
15784 if (Invalid)
15785 break;
15786
15787 getDerived().transformedLocalDecl(OldVD, NewVDs);
15788 continue;
15789 }
15790
15791 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15792
15793 // Determine the capture kind for Sema.
15795 : C->getCaptureKind() == LCK_ByCopy
15798 SourceLocation EllipsisLoc;
15799 if (C->isPackExpansion()) {
15800 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15801 bool ShouldExpand = false;
15802 bool RetainExpansion = false;
15803 UnsignedOrNone NumExpansions = std::nullopt;
15804 if (getDerived().TryExpandParameterPacks(
15805 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
15806 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
15807 RetainExpansion, NumExpansions)) {
15808 Invalid = true;
15809 continue;
15810 }
15811
15812 if (ShouldExpand) {
15813 // The transform has determined that we should perform an expansion;
15814 // transform and capture each of the arguments.
15815 // expansion of the pattern. Do so.
15816 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
15817 for (unsigned I = 0; I != *NumExpansions; ++I) {
15818 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15819 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
15820 getDerived().TransformDecl(C->getLocation(), Pack));
15821 if (!CapturedVar) {
15822 Invalid = true;
15823 continue;
15824 }
15825
15826 // Capture the transformed variable.
15827 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
15828 }
15829
15830 // FIXME: Retain a pack expansion if RetainExpansion is true.
15831
15832 continue;
15833 }
15834
15835 EllipsisLoc = C->getEllipsisLoc();
15836 }
15837
15838 // Transform the captured variable.
15839 auto *CapturedVar = cast_or_null<ValueDecl>(
15840 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15841 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
15842 Invalid = true;
15843 continue;
15844 }
15845
15846 // This is not an init-capture; however it contains an unexpanded pack e.g.
15847 // ([Pack] {}(), ...)
15848 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
15849 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
15850
15851 // Capture the transformed variable.
15852 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
15853 EllipsisLoc);
15854 }
15855 getSema().finishLambdaExplicitCaptures(LSI);
15856
15857 // Transform the template parameters, and add them to the current
15858 // instantiation scope. The null case is handled correctly.
15859 auto TPL = getDerived().TransformTemplateParameterList(
15860 E->getTemplateParameterList());
15861 LSI->GLTemplateParameterList = TPL;
15862 if (TPL) {
15863 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
15864 TPL);
15865 LSI->ContainsUnexpandedParameterPack |=
15866 TPL->containsUnexpandedParameterPack();
15867 }
15868
15869 TypeLocBuilder NewCallOpTLBuilder;
15870 TypeLoc OldCallOpTypeLoc =
15871 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
15872 QualType NewCallOpType =
15873 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
15874 if (NewCallOpType.isNull())
15875 return ExprError();
15876 LSI->ContainsUnexpandedParameterPack |=
15877 NewCallOpType->containsUnexpandedParameterPack();
15878 TypeSourceInfo *NewCallOpTSI =
15879 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
15880
15881 // The type may be an AttributedType or some other kind of sugar;
15882 // get the actual underlying FunctionProtoType.
15883 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
15884 assert(FPTL && "Not a FunctionProtoType?");
15885
15886 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
15887 if (!TRC.ArgPackSubstIndex)
15889
15890 getSema().CompleteLambdaCallOperator(
15891 NewCallOperator, E->getCallOperator()->getLocation(),
15892 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
15893 E->getCallOperator()->getConstexprKind(),
15894 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
15895 E->hasExplicitResultType());
15896
15897 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
15898 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
15899
15900 {
15901 // Number the lambda for linkage purposes if necessary.
15902 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
15903
15904 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
15905 if (getDerived().ReplacingOriginal()) {
15906 Numbering = OldClass->getLambdaNumbering();
15907 }
15908
15909 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
15910 }
15911
15912 // FIXME: Sema's lambda-building mechanism expects us to push an expression
15913 // evaluation context even if we're not transforming the function body.
15914 getSema().PushExpressionEvaluationContextForFunction(
15916 E->getCallOperator());
15917
15918 StmtResult Body;
15919 {
15920 Sema::NonSFINAEContext _(getSema());
15923 C.PointOfInstantiation = E->getBody()->getBeginLoc();
15924 getSema().pushCodeSynthesisContext(C);
15925
15926 // Instantiate the body of the lambda expression.
15927 Body = Invalid ? StmtError()
15928 : getDerived().TransformLambdaBody(E, E->getBody());
15929
15930 getSema().popCodeSynthesisContext();
15931 }
15932
15933 // ActOnLambda* will pop the function scope for us.
15934 FuncScopeCleanup.disable();
15935
15936 if (Body.isInvalid()) {
15937 SavedContext.pop();
15938 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
15939 /*IsInstantiation=*/true);
15940 return ExprError();
15941 }
15942
15943 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
15944 /*IsInstantiation=*/true,
15945 /*RetainFunctionScopeInfo=*/true);
15946 SavedContext.pop();
15947
15948 // Recompute the dependency of the lambda so that we can defer the lambda call
15949 // construction until after we have all the necessary template arguments. For
15950 // example, given
15951 //
15952 // template <class> struct S {
15953 // template <class U>
15954 // using Type = decltype([](U){}(42.0));
15955 // };
15956 // void foo() {
15957 // using T = S<int>::Type<float>;
15958 // ^~~~~~
15959 // }
15960 //
15961 // We would end up here from instantiating S<int> when ensuring its
15962 // completeness. That would transform the lambda call expression regardless of
15963 // the absence of the corresponding argument for U.
15964 //
15965 // Going ahead with unsubstituted type U makes things worse: we would soon
15966 // compare the argument type (which is float) against the parameter U
15967 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
15968 // error suggesting unmatched types 'U' and 'float'!
15969 //
15970 // That said, everything will be fine if we defer that semantic checking.
15971 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
15972 // dependent. Since the CallExpr's dependency boils down to the lambda's
15973 // dependency in this case, we can harness that by recomputing the dependency
15974 // from the instantiation arguments.
15975 //
15976 // FIXME: Creating the type of a lambda requires us to have a dependency
15977 // value, which happens before its substitution. We update its dependency
15978 // *after* the substitution in case we can't decide the dependency
15979 // so early, e.g. because we want to see if any of the *substituted*
15980 // parameters are dependent.
15981 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
15982 Class->setLambdaDependencyKind(DependencyKind);
15983
15984 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
15985 Body.get()->getEndLoc(), LSI);
15986}
15987
15988template<typename Derived>
15993
15994template<typename Derived>
15997 // Transform captures.
15999 CEnd = E->capture_end();
16000 C != CEnd; ++C) {
16001 // When we hit the first implicit capture, tell Sema that we've finished
16002 // the list of explicit captures.
16003 if (!C->isImplicit())
16004 continue;
16005
16006 // Capturing 'this' is trivial.
16007 if (C->capturesThis()) {
16008 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16009 /*BuildAndDiagnose*/ true, nullptr,
16010 C->getCaptureKind() == LCK_StarThis);
16011 continue;
16012 }
16013 // Captured expression will be recaptured during captured variables
16014 // rebuilding.
16015 if (C->capturesVLAType())
16016 continue;
16017
16018 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16019 assert(!E->isInitCapture(C) && "implicit init-capture?");
16020
16021 // Transform the captured variable.
16022 VarDecl *CapturedVar = cast_or_null<VarDecl>(
16023 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16024 if (!CapturedVar || CapturedVar->isInvalidDecl())
16025 return StmtError();
16026
16027 // Capture the transformed variable.
16028 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16029 }
16030
16031 return S;
16032}
16033
16034template<typename Derived>
16038 TypeSourceInfo *T =
16039 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16040 if (!T)
16041 return ExprError();
16042
16043 bool ArgumentChanged = false;
16045 Args.reserve(E->getNumArgs());
16046 {
16050 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16051 &ArgumentChanged))
16052 return ExprError();
16053 }
16054
16055 if (!getDerived().AlwaysRebuild() &&
16056 T == E->getTypeSourceInfo() &&
16057 !ArgumentChanged)
16058 return E;
16059
16060 // FIXME: we're faking the locations of the commas
16061 return getDerived().RebuildCXXUnresolvedConstructExpr(
16062 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16063}
16064
16065template<typename Derived>
16069 // Transform the base of the expression.
16070 ExprResult Base((Expr*) nullptr);
16071 Expr *OldBase;
16072 QualType BaseType;
16073 QualType ObjectType;
16074 if (!E->isImplicitAccess()) {
16075 OldBase = E->getBase();
16076 Base = getDerived().TransformExpr(OldBase);
16077 if (Base.isInvalid())
16078 return ExprError();
16079
16080 // Start the member reference and compute the object's type.
16081 ParsedType ObjectTy;
16082 bool MayBePseudoDestructor = false;
16083 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16084 E->getOperatorLoc(),
16085 E->isArrow()? tok::arrow : tok::period,
16086 ObjectTy,
16087 MayBePseudoDestructor);
16088 if (Base.isInvalid())
16089 return ExprError();
16090
16091 ObjectType = ObjectTy.get();
16092 BaseType = ((Expr*) Base.get())->getType();
16093 } else {
16094 OldBase = nullptr;
16095 BaseType = getDerived().TransformType(E->getBaseType());
16096 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16097 }
16098
16099 // Transform the first part of the nested-name-specifier that qualifies
16100 // the member name.
16101 NamedDecl *FirstQualifierInScope
16102 = getDerived().TransformFirstQualifierInScope(
16103 E->getFirstQualifierFoundInScope(),
16104 E->getQualifierLoc().getBeginLoc());
16105
16106 NestedNameSpecifierLoc QualifierLoc;
16107 if (E->getQualifier()) {
16108 QualifierLoc
16109 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16110 ObjectType,
16111 FirstQualifierInScope);
16112 if (!QualifierLoc)
16113 return ExprError();
16114 }
16115
16116 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16117
16118 // TODO: If this is a conversion-function-id, verify that the
16119 // destination type name (if present) resolves the same way after
16120 // instantiation as it did in the local scope.
16121
16122 DeclarationNameInfo NameInfo
16123 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16124 if (!NameInfo.getName())
16125 return ExprError();
16126
16127 if (!E->hasExplicitTemplateArgs()) {
16128 // This is a reference to a member without an explicitly-specified
16129 // template argument list. Optimize for this common case.
16130 if (!getDerived().AlwaysRebuild() &&
16131 Base.get() == OldBase &&
16132 BaseType == E->getBaseType() &&
16133 QualifierLoc == E->getQualifierLoc() &&
16134 NameInfo.getName() == E->getMember() &&
16135 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16136 return E;
16137
16138 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16139 BaseType,
16140 E->isArrow(),
16141 E->getOperatorLoc(),
16142 QualifierLoc,
16143 TemplateKWLoc,
16144 FirstQualifierInScope,
16145 NameInfo,
16146 /*TemplateArgs*/nullptr);
16147 }
16148
16149 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16150 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16151 E->getNumTemplateArgs(),
16152 TransArgs))
16153 return ExprError();
16154
16155 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16156 BaseType,
16157 E->isArrow(),
16158 E->getOperatorLoc(),
16159 QualifierLoc,
16160 TemplateKWLoc,
16161 FirstQualifierInScope,
16162 NameInfo,
16163 &TransArgs);
16164}
16165
16166template <typename Derived>
16168 UnresolvedMemberExpr *Old) {
16169 // Transform the base of the expression.
16170 ExprResult Base((Expr *)nullptr);
16171 QualType BaseType;
16172 if (!Old->isImplicitAccess()) {
16173 Base = getDerived().TransformExpr(Old->getBase());
16174 if (Base.isInvalid())
16175 return ExprError();
16176 Base =
16177 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16178 if (Base.isInvalid())
16179 return ExprError();
16180 BaseType = Base.get()->getType();
16181 } else {
16182 BaseType = getDerived().TransformType(Old->getBaseType());
16183 }
16184
16185 NestedNameSpecifierLoc QualifierLoc;
16186 if (Old->getQualifierLoc()) {
16187 QualifierLoc =
16188 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16189 if (!QualifierLoc)
16190 return ExprError();
16191 }
16192
16193 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16194
16195 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16196
16197 // Transform the declaration set.
16198 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16199 return ExprError();
16200
16201 // Determine the naming class.
16202 if (Old->getNamingClass()) {
16203 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16204 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16205 if (!NamingClass)
16206 return ExprError();
16207
16208 R.setNamingClass(NamingClass);
16209 }
16210
16211 TemplateArgumentListInfo TransArgs;
16212 if (Old->hasExplicitTemplateArgs()) {
16213 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16214 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16215 if (getDerived().TransformTemplateArguments(
16216 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16217 return ExprError();
16218 }
16219
16220 // FIXME: to do this check properly, we will need to preserve the
16221 // first-qualifier-in-scope here, just in case we had a dependent
16222 // base (and therefore couldn't do the check) and a
16223 // nested-name-qualifier (and therefore could do the lookup).
16224 NamedDecl *FirstQualifierInScope = nullptr;
16225
16226 return getDerived().RebuildUnresolvedMemberExpr(
16227 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16228 TemplateKWLoc, FirstQualifierInScope, R,
16229 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16230}
16231
16232template<typename Derived>
16237 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16238 if (SubExpr.isInvalid())
16239 return ExprError();
16240
16241 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16242 return E;
16243
16244 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16245}
16246
16247template<typename Derived>
16250 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16251 if (Pattern.isInvalid())
16252 return ExprError();
16253
16254 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16255 return E;
16256
16257 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16258 E->getNumExpansions());
16259}
16260
16261template <typename Derived>
16263 ArrayRef<TemplateArgument> PackArgs) {
16265 for (const TemplateArgument &Arg : PackArgs) {
16266 if (!Arg.isPackExpansion()) {
16267 Result = *Result + 1;
16268 continue;
16269 }
16270
16271 TemplateArgumentLoc ArgLoc;
16272 InventTemplateArgumentLoc(Arg, ArgLoc);
16273
16274 // Find the pattern of the pack expansion.
16275 SourceLocation Ellipsis;
16276 UnsignedOrNone OrigNumExpansions = std::nullopt;
16277 TemplateArgumentLoc Pattern =
16278 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16279 OrigNumExpansions);
16280
16281 // Substitute under the pack expansion. Do not expand the pack (yet).
16282 TemplateArgumentLoc OutPattern;
16283 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16284 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16285 /*Uneval*/ true))
16286 return 1u;
16287
16288 // See if we can determine the number of arguments from the result.
16289 UnsignedOrNone NumExpansions =
16290 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16291 if (!NumExpansions) {
16292 // No: we must be in an alias template expansion, and we're going to
16293 // need to actually expand the packs.
16294 Result = std::nullopt;
16295 break;
16296 }
16297
16298 Result = *Result + *NumExpansions;
16299 }
16300 return Result;
16301}
16302
16303template<typename Derived>
16306 // If E is not value-dependent, then nothing will change when we transform it.
16307 // Note: This is an instantiation-centric view.
16308 if (!E->isValueDependent())
16309 return E;
16310
16313
16315 TemplateArgument ArgStorage;
16316
16317 // Find the argument list to transform.
16318 if (E->isPartiallySubstituted()) {
16319 PackArgs = E->getPartialArguments();
16320 } else if (E->isValueDependent()) {
16321 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16322 bool ShouldExpand = false;
16323 bool RetainExpansion = false;
16324 UnsignedOrNone NumExpansions = std::nullopt;
16325 if (getDerived().TryExpandParameterPacks(
16326 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16327 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16328 RetainExpansion, NumExpansions))
16329 return ExprError();
16330
16331 // If we need to expand the pack, build a template argument from it and
16332 // expand that.
16333 if (ShouldExpand) {
16334 auto *Pack = E->getPack();
16335 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16336 ArgStorage = getSema().Context.getPackExpansionType(
16337 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16338 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16339 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16340 } else {
16341 auto *VD = cast<ValueDecl>(Pack);
16342 ExprResult DRE = getSema().BuildDeclRefExpr(
16343 VD, VD->getType().getNonLValueExprType(getSema().Context),
16344 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16345 E->getPackLoc());
16346 if (DRE.isInvalid())
16347 return ExprError();
16348 ArgStorage = TemplateArgument(
16349 new (getSema().Context)
16350 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16351 /*IsCanonical=*/false);
16352 }
16353 PackArgs = ArgStorage;
16354 }
16355 }
16356
16357 // If we're not expanding the pack, just transform the decl.
16358 if (!PackArgs.size()) {
16359 auto *Pack = cast_or_null<NamedDecl>(
16360 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16361 if (!Pack)
16362 return ExprError();
16363 return getDerived().RebuildSizeOfPackExpr(
16364 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16365 std::nullopt, {});
16366 }
16367
16368 // Try to compute the result without performing a partial substitution.
16370 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16371
16372 // Common case: we could determine the number of expansions without
16373 // substituting.
16374 if (Result)
16375 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16376 E->getPackLoc(),
16377 E->getRParenLoc(), *Result, {});
16378
16379 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16380 E->getPackLoc());
16381 {
16382 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16384 Derived, const TemplateArgument*> PackLocIterator;
16385 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16386 PackLocIterator(*this, PackArgs.end()),
16387 TransformedPackArgs, /*Uneval*/true))
16388 return ExprError();
16389 }
16390
16391 // Check whether we managed to fully-expand the pack.
16392 // FIXME: Is it possible for us to do so and not hit the early exit path?
16394 bool PartialSubstitution = false;
16395 for (auto &Loc : TransformedPackArgs.arguments()) {
16396 Args.push_back(Loc.getArgument());
16397 if (Loc.getArgument().isPackExpansion())
16398 PartialSubstitution = true;
16399 }
16400
16401 if (PartialSubstitution)
16402 return getDerived().RebuildSizeOfPackExpr(
16403 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16404 std::nullopt, Args);
16405
16406 return getDerived().RebuildSizeOfPackExpr(
16407 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16408 /*Length=*/static_cast<unsigned>(Args.size()),
16409 /*PartialArgs=*/{});
16410}
16411
16412template <typename Derived>
16415 if (!E->isValueDependent())
16416 return E;
16417
16418 // Transform the index
16419 ExprResult IndexExpr;
16420 {
16421 EnterExpressionEvaluationContext ConstantContext(
16423 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16424 if (IndexExpr.isInvalid())
16425 return ExprError();
16426 }
16427
16428 SmallVector<Expr *, 5> ExpandedExprs;
16429 bool FullySubstituted = true;
16430 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16431 Expr *Pattern = E->getPackIdExpression();
16433 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16434 Unexpanded);
16435 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16436
16437 // Determine whether the set of unexpanded parameter packs can and should
16438 // be expanded.
16439 bool ShouldExpand = true;
16440 bool RetainExpansion = false;
16441 UnsignedOrNone OrigNumExpansions = std::nullopt,
16442 NumExpansions = std::nullopt;
16443 if (getDerived().TryExpandParameterPacks(
16444 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16445 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16446 RetainExpansion, NumExpansions))
16447 return true;
16448 if (!ShouldExpand) {
16449 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16450 ExprResult Pack = getDerived().TransformExpr(Pattern);
16451 if (Pack.isInvalid())
16452 return ExprError();
16453 return getDerived().RebuildPackIndexingExpr(
16454 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16455 {}, /*FullySubstituted=*/false);
16456 }
16457 for (unsigned I = 0; I != *NumExpansions; ++I) {
16458 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16459 ExprResult Out = getDerived().TransformExpr(Pattern);
16460 if (Out.isInvalid())
16461 return true;
16462 if (Out.get()->containsUnexpandedParameterPack()) {
16463 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16464 OrigNumExpansions);
16465 if (Out.isInvalid())
16466 return true;
16467 FullySubstituted = false;
16468 }
16469 ExpandedExprs.push_back(Out.get());
16470 }
16471 // If we're supposed to retain a pack expansion, do so by temporarily
16472 // forgetting the partially-substituted parameter pack.
16473 if (RetainExpansion) {
16474 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16475
16476 ExprResult Out = getDerived().TransformExpr(Pattern);
16477 if (Out.isInvalid())
16478 return true;
16479
16480 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16481 OrigNumExpansions);
16482 if (Out.isInvalid())
16483 return true;
16484 FullySubstituted = false;
16485 ExpandedExprs.push_back(Out.get());
16486 }
16487 } else if (!E->expandsToEmptyPack()) {
16488 if (getDerived().TransformExprs(E->getExpressions().data(),
16489 E->getExpressions().size(), false,
16490 ExpandedExprs))
16491 return ExprError();
16492 }
16493
16494 return getDerived().RebuildPackIndexingExpr(
16495 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16496 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16497}
16498
16499template <typename Derived>
16502 if (!getSema().ArgPackSubstIndex)
16503 // We aren't expanding the parameter pack, so just return ourselves.
16504 return E;
16505
16506 TemplateArgument Pack = E->getArgumentPack();
16508 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16509 E->getAssociatedDecl(), E->getParameterPack(),
16510 E->getParameterPackLocation(), Arg, SemaRef.getPackIndex(Pack),
16511 E->getFinal());
16512}
16513
16514template <typename Derived>
16517 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16518 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16519 if (Replacement.isInvalid())
16520 return true;
16521
16522 Decl *AssociatedDecl =
16523 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16524 if (!AssociatedDecl)
16525 return true;
16526
16527 if (Replacement.get() == OrigReplacement &&
16528 AssociatedDecl == E->getAssociatedDecl())
16529 return E;
16530
16531 auto getParamAndType = [E](Decl *AssociatedDecl)
16532 -> std::tuple<NonTypeTemplateParmDecl *, QualType> {
16533 auto [PDecl, Arg] =
16534 getReplacedTemplateParameter(AssociatedDecl, E->getIndex());
16535 auto *Param = cast<NonTypeTemplateParmDecl>(PDecl);
16536 if (Arg.isNull())
16537 return {Param, Param->getType()};
16538 if (UnsignedOrNone PackIndex = E->getPackIndex())
16539 Arg = Arg.getPackAsArray()[*PackIndex];
16540 return {Param, Arg.getNonTypeTemplateArgumentType()};
16541 };
16542
16543 // If the replacement expression did not change, and the parameter type
16544 // did not change, we can skip the semantic action because it would
16545 // produce the same result anyway.
16546 if (auto [Param, ParamType] = getParamAndType(AssociatedDecl);
16547 !SemaRef.Context.hasSameType(
16548 ParamType, std::get<1>(getParamAndType(E->getAssociatedDecl()))) ||
16549 Replacement.get() != OrigReplacement) {
16550 // When transforming the replacement expression previously, all Sema
16551 // specific annotations, such as implicit casts, are discarded. Calling the
16552 // corresponding sema action is necessary to recover those. Otherwise,
16553 // equivalency of the result would be lost.
16554 TemplateArgument SugaredConverted, CanonicalConverted;
16555 Replacement = SemaRef.CheckTemplateArgument(
16556 Param, ParamType, Replacement.get(), SugaredConverted,
16557 CanonicalConverted,
16558 /*StrictCheck=*/false, Sema::CTAK_Specified);
16559 if (Replacement.isInvalid())
16560 return true;
16561 } else {
16562 // Otherwise, the same expression would have been produced.
16563 Replacement = E->getReplacement();
16564 }
16565
16566 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16567 AssociatedDecl, E->getParameter(), E->getNameLoc(),
16568 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
16569 E->getPackIndex(), E->getFinal());
16570}
16571
16572template<typename Derived>
16575 // Default behavior is to do nothing with this transformation.
16576 return E;
16577}
16578
16579template<typename Derived>
16583 return getDerived().TransformExpr(E->getSubExpr());
16584}
16585
16586template<typename Derived>
16589 UnresolvedLookupExpr *Callee = nullptr;
16590 if (Expr *OldCallee = E->getCallee()) {
16591 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16592 if (CalleeResult.isInvalid())
16593 return ExprError();
16594 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16595 }
16596
16597 Expr *Pattern = E->getPattern();
16598
16600 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16601 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16602
16603 // Determine whether the set of unexpanded parameter packs can and should
16604 // be expanded.
16605 bool Expand = true;
16606 bool RetainExpansion = false;
16607 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16608 NumExpansions = OrigNumExpansions;
16609 if (getDerived().TryExpandParameterPacks(
16610 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16611 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16612 NumExpansions))
16613 return true;
16614
16615 if (!Expand) {
16616 // Do not expand any packs here, just transform and rebuild a fold
16617 // expression.
16618 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16619
16620 ExprResult LHS =
16621 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16622 if (LHS.isInvalid())
16623 return true;
16624
16625 ExprResult RHS =
16626 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16627 if (RHS.isInvalid())
16628 return true;
16629
16630 if (!getDerived().AlwaysRebuild() &&
16631 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16632 return E;
16633
16634 return getDerived().RebuildCXXFoldExpr(
16635 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16636 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16637 }
16638
16639 // Formally a fold expression expands to nested parenthesized expressions.
16640 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16641 // them.
16642 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16643 SemaRef.Diag(E->getEllipsisLoc(),
16644 clang::diag::err_fold_expression_limit_exceeded)
16645 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16646 << E->getSourceRange();
16647 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16648 return ExprError();
16649 }
16650
16651 // The transform has determined that we should perform an elementwise
16652 // expansion of the pattern. Do so.
16653 ExprResult Result = getDerived().TransformExpr(E->getInit());
16654 if (Result.isInvalid())
16655 return true;
16656 bool LeftFold = E->isLeftFold();
16657
16658 // If we're retaining an expansion for a right fold, it is the innermost
16659 // component and takes the init (if any).
16660 if (!LeftFold && RetainExpansion) {
16661 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16662
16663 ExprResult Out = getDerived().TransformExpr(Pattern);
16664 if (Out.isInvalid())
16665 return true;
16666
16667 Result = getDerived().RebuildCXXFoldExpr(
16668 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16669 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16670 if (Result.isInvalid())
16671 return true;
16672 }
16673
16674 bool WarnedOnComparison = false;
16675 for (unsigned I = 0; I != *NumExpansions; ++I) {
16676 Sema::ArgPackSubstIndexRAII SubstIndex(
16677 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16678 ExprResult Out = getDerived().TransformExpr(Pattern);
16679 if (Out.isInvalid())
16680 return true;
16681
16682 if (Out.get()->containsUnexpandedParameterPack()) {
16683 // We still have a pack; retain a pack expansion for this slice.
16684 Result = getDerived().RebuildCXXFoldExpr(
16685 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16686 E->getOperator(), E->getEllipsisLoc(),
16687 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16688 OrigNumExpansions);
16689 } else if (Result.isUsable()) {
16690 // We've got down to a single element; build a binary operator.
16691 Expr *LHS = LeftFold ? Result.get() : Out.get();
16692 Expr *RHS = LeftFold ? Out.get() : Result.get();
16693 if (Callee) {
16694 UnresolvedSet<16> Functions;
16695 Functions.append(Callee->decls_begin(), Callee->decls_end());
16696 Result = getDerived().RebuildCXXOperatorCallExpr(
16697 BinaryOperator::getOverloadedOperator(E->getOperator()),
16698 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16699 Functions, LHS, RHS);
16700 } else {
16701 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16702 E->getOperator(), LHS, RHS,
16703 /*ForFoldExpresion=*/true);
16704 if (!WarnedOnComparison && Result.isUsable()) {
16705 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16706 BO && BO->isComparisonOp()) {
16707 WarnedOnComparison = true;
16708 SemaRef.Diag(BO->getBeginLoc(),
16709 diag::warn_comparison_in_fold_expression)
16710 << BO->getOpcodeStr();
16711 }
16712 }
16713 }
16714 } else
16715 Result = Out;
16716
16717 if (Result.isInvalid())
16718 return true;
16719 }
16720
16721 // If we're retaining an expansion for a left fold, it is the outermost
16722 // component and takes the complete expansion so far as its init (if any).
16723 if (LeftFold && RetainExpansion) {
16724 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16725
16726 ExprResult Out = getDerived().TransformExpr(Pattern);
16727 if (Out.isInvalid())
16728 return true;
16729
16730 Result = getDerived().RebuildCXXFoldExpr(
16731 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16732 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16733 if (Result.isInvalid())
16734 return true;
16735 }
16736
16737 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16738 PE->setIsProducedByFoldExpansion();
16739
16740 // If we had no init and an empty pack, and we're not retaining an expansion,
16741 // then produce a fallback value or error.
16742 if (Result.isUnset())
16743 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16744 E->getOperator());
16745 return Result;
16746}
16747
16748template <typename Derived>
16751 SmallVector<Expr *, 4> TransformedInits;
16752 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16753
16754 QualType T = getDerived().TransformType(E->getType());
16755
16756 bool ArgChanged = false;
16757
16758 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16759 TransformedInits, &ArgChanged))
16760 return ExprError();
16761
16762 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16763 return E;
16764
16765 return getDerived().RebuildCXXParenListInitExpr(
16766 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16767 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16768}
16769
16770template<typename Derived>
16774 return getDerived().TransformExpr(E->getSubExpr());
16775}
16776
16777template<typename Derived>
16780 return SemaRef.MaybeBindToTemporary(E);
16781}
16782
16783template<typename Derived>
16786 return E;
16787}
16788
16789template<typename Derived>
16792 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16793 if (SubExpr.isInvalid())
16794 return ExprError();
16795
16796 if (!getDerived().AlwaysRebuild() &&
16797 SubExpr.get() == E->getSubExpr())
16798 return E;
16799
16800 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16801}
16802
16803template<typename Derived>
16806 // Transform each of the elements.
16807 SmallVector<Expr *, 8> Elements;
16808 bool ArgChanged = false;
16809 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
16810 /*IsCall=*/false, Elements, &ArgChanged))
16811 return ExprError();
16812
16813 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16814 return SemaRef.MaybeBindToTemporary(E);
16815
16816 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
16817 Elements.data(),
16818 Elements.size());
16819}
16820
16821template<typename Derived>
16825 // Transform each of the elements.
16827 bool ArgChanged = false;
16828 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
16829 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
16830
16831 if (OrigElement.isPackExpansion()) {
16832 // This key/value element is a pack expansion.
16834 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
16835 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
16836 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16837
16838 // Determine whether the set of unexpanded parameter packs can
16839 // and should be expanded.
16840 bool Expand = true;
16841 bool RetainExpansion = false;
16842 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
16843 UnsignedOrNone NumExpansions = OrigNumExpansions;
16844 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
16845 OrigElement.Value->getEndLoc());
16846 if (getDerived().TryExpandParameterPacks(
16847 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
16848 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16849 NumExpansions))
16850 return ExprError();
16851
16852 if (!Expand) {
16853 // The transform has determined that we should perform a simple
16854 // transformation on the pack expansion, producing another pack
16855 // expansion.
16856 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16857 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16858 if (Key.isInvalid())
16859 return ExprError();
16860
16861 if (Key.get() != OrigElement.Key)
16862 ArgChanged = true;
16863
16864 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16865 if (Value.isInvalid())
16866 return ExprError();
16867
16868 if (Value.get() != OrigElement.Value)
16869 ArgChanged = true;
16870
16871 ObjCDictionaryElement Expansion = {
16872 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
16873 };
16874 Elements.push_back(Expansion);
16875 continue;
16876 }
16877
16878 // Record right away that the argument was changed. This needs
16879 // to happen even if the array expands to nothing.
16880 ArgChanged = true;
16881
16882 // The transform has determined that we should perform an elementwise
16883 // expansion of the pattern. Do so.
16884 for (unsigned I = 0; I != *NumExpansions; ++I) {
16885 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16886 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16887 if (Key.isInvalid())
16888 return ExprError();
16889
16890 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16891 if (Value.isInvalid())
16892 return ExprError();
16893
16894 ObjCDictionaryElement Element = {
16895 Key.get(), Value.get(), SourceLocation(), NumExpansions
16896 };
16897
16898 // If any unexpanded parameter packs remain, we still have a
16899 // pack expansion.
16900 // FIXME: Can this really happen?
16901 if (Key.get()->containsUnexpandedParameterPack() ||
16902 Value.get()->containsUnexpandedParameterPack())
16903 Element.EllipsisLoc = OrigElement.EllipsisLoc;
16904
16905 Elements.push_back(Element);
16906 }
16907
16908 // FIXME: Retain a pack expansion if RetainExpansion is true.
16909
16910 // We've finished with this pack expansion.
16911 continue;
16912 }
16913
16914 // Transform and check key.
16915 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16916 if (Key.isInvalid())
16917 return ExprError();
16918
16919 if (Key.get() != OrigElement.Key)
16920 ArgChanged = true;
16921
16922 // Transform and check value.
16924 = getDerived().TransformExpr(OrigElement.Value);
16925 if (Value.isInvalid())
16926 return ExprError();
16927
16928 if (Value.get() != OrigElement.Value)
16929 ArgChanged = true;
16930
16931 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
16932 std::nullopt};
16933 Elements.push_back(Element);
16934 }
16935
16936 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16937 return SemaRef.MaybeBindToTemporary(E);
16938
16939 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
16940 Elements);
16941}
16942
16943template<typename Derived>
16946 TypeSourceInfo *EncodedTypeInfo
16947 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
16948 if (!EncodedTypeInfo)
16949 return ExprError();
16950
16951 if (!getDerived().AlwaysRebuild() &&
16952 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
16953 return E;
16954
16955 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
16956 EncodedTypeInfo,
16957 E->getRParenLoc());
16958}
16959
16960template<typename Derived>
16963 // This is a kind of implicit conversion, and it needs to get dropped
16964 // and recomputed for the same general reasons that ImplicitCastExprs
16965 // do, as well a more specific one: this expression is only valid when
16966 // it appears *immediately* as an argument expression.
16967 return getDerived().TransformExpr(E->getSubExpr());
16968}
16969
16970template<typename Derived>
16973 TypeSourceInfo *TSInfo
16974 = getDerived().TransformType(E->getTypeInfoAsWritten());
16975 if (!TSInfo)
16976 return ExprError();
16977
16978 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
16979 if (Result.isInvalid())
16980 return ExprError();
16981
16982 if (!getDerived().AlwaysRebuild() &&
16983 TSInfo == E->getTypeInfoAsWritten() &&
16984 Result.get() == E->getSubExpr())
16985 return E;
16986
16987 return SemaRef.ObjC().BuildObjCBridgedCast(
16988 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
16989 Result.get());
16990}
16991
16992template <typename Derived>
16995 return E;
16996}
16997
16998template<typename Derived>
17001 // Transform arguments.
17002 bool ArgChanged = false;
17004 Args.reserve(E->getNumArgs());
17005 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
17006 &ArgChanged))
17007 return ExprError();
17008
17009 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
17010 // Class message: transform the receiver type.
17011 TypeSourceInfo *ReceiverTypeInfo
17012 = getDerived().TransformType(E->getClassReceiverTypeInfo());
17013 if (!ReceiverTypeInfo)
17014 return ExprError();
17015
17016 // If nothing changed, just retain the existing message send.
17017 if (!getDerived().AlwaysRebuild() &&
17018 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
17019 return SemaRef.MaybeBindToTemporary(E);
17020
17021 // Build a new class message send.
17023 E->getSelectorLocs(SelLocs);
17024 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
17025 E->getSelector(),
17026 SelLocs,
17027 E->getMethodDecl(),
17028 E->getLeftLoc(),
17029 Args,
17030 E->getRightLoc());
17031 }
17032 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17033 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17034 if (!E->getMethodDecl())
17035 return ExprError();
17036
17037 // Build a new class message send to 'super'.
17039 E->getSelectorLocs(SelLocs);
17040 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17041 E->getSelector(),
17042 SelLocs,
17043 E->getReceiverType(),
17044 E->getMethodDecl(),
17045 E->getLeftLoc(),
17046 Args,
17047 E->getRightLoc());
17048 }
17049
17050 // Instance message: transform the receiver
17051 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17052 "Only class and instance messages may be instantiated");
17053 ExprResult Receiver
17054 = getDerived().TransformExpr(E->getInstanceReceiver());
17055 if (Receiver.isInvalid())
17056 return ExprError();
17057
17058 // If nothing changed, just retain the existing message send.
17059 if (!getDerived().AlwaysRebuild() &&
17060 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17061 return SemaRef.MaybeBindToTemporary(E);
17062
17063 // Build a new instance message send.
17065 E->getSelectorLocs(SelLocs);
17066 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17067 E->getSelector(),
17068 SelLocs,
17069 E->getMethodDecl(),
17070 E->getLeftLoc(),
17071 Args,
17072 E->getRightLoc());
17073}
17074
17075template<typename Derived>
17078 return E;
17079}
17080
17081template<typename Derived>
17084 return E;
17085}
17086
17087template<typename Derived>
17090 // Transform the base expression.
17091 ExprResult Base = getDerived().TransformExpr(E->getBase());
17092 if (Base.isInvalid())
17093 return ExprError();
17094
17095 // We don't need to transform the ivar; it will never change.
17096
17097 // If nothing changed, just retain the existing expression.
17098 if (!getDerived().AlwaysRebuild() &&
17099 Base.get() == E->getBase())
17100 return E;
17101
17102 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17103 E->getLocation(),
17104 E->isArrow(), E->isFreeIvar());
17105}
17106
17107template<typename Derived>
17110 // 'super' and types never change. Property never changes. Just
17111 // retain the existing expression.
17112 if (!E->isObjectReceiver())
17113 return E;
17114
17115 // Transform the base expression.
17116 ExprResult Base = getDerived().TransformExpr(E->getBase());
17117 if (Base.isInvalid())
17118 return ExprError();
17119
17120 // We don't need to transform the property; it will never change.
17121
17122 // If nothing changed, just retain the existing expression.
17123 if (!getDerived().AlwaysRebuild() &&
17124 Base.get() == E->getBase())
17125 return E;
17126
17127 if (E->isExplicitProperty())
17128 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17129 E->getExplicitProperty(),
17130 E->getLocation());
17131
17132 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17133 SemaRef.Context.PseudoObjectTy,
17134 E->getImplicitPropertyGetter(),
17135 E->getImplicitPropertySetter(),
17136 E->getLocation());
17137}
17138
17139template<typename Derived>
17142 // Transform the base expression.
17143 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17144 if (Base.isInvalid())
17145 return ExprError();
17146
17147 // Transform the key expression.
17148 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17149 if (Key.isInvalid())
17150 return ExprError();
17151
17152 // If nothing changed, just retain the existing expression.
17153 if (!getDerived().AlwaysRebuild() &&
17154 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17155 return E;
17156
17157 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17158 Base.get(), Key.get(),
17159 E->getAtIndexMethodDecl(),
17160 E->setAtIndexMethodDecl());
17161}
17162
17163template<typename Derived>
17166 // Transform the base expression.
17167 ExprResult Base = getDerived().TransformExpr(E->getBase());
17168 if (Base.isInvalid())
17169 return ExprError();
17170
17171 // If nothing changed, just retain the existing expression.
17172 if (!getDerived().AlwaysRebuild() &&
17173 Base.get() == E->getBase())
17174 return E;
17175
17176 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17177 E->getOpLoc(),
17178 E->isArrow());
17179}
17180
17181template<typename Derived>
17184 bool ArgumentChanged = false;
17185 SmallVector<Expr*, 8> SubExprs;
17186 SubExprs.reserve(E->getNumSubExprs());
17187 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17188 SubExprs, &ArgumentChanged))
17189 return ExprError();
17190
17191 if (!getDerived().AlwaysRebuild() &&
17192 !ArgumentChanged)
17193 return E;
17194
17195 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17196 SubExprs,
17197 E->getRParenLoc());
17198}
17199
17200template<typename Derived>
17203 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17204 if (SrcExpr.isInvalid())
17205 return ExprError();
17206
17207 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17208 if (!Type)
17209 return ExprError();
17210
17211 if (!getDerived().AlwaysRebuild() &&
17212 Type == E->getTypeSourceInfo() &&
17213 SrcExpr.get() == E->getSrcExpr())
17214 return E;
17215
17216 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17217 SrcExpr.get(), Type,
17218 E->getRParenLoc());
17219}
17220
17221template<typename Derived>
17224 BlockDecl *oldBlock = E->getBlockDecl();
17225
17226 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17227 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17228
17229 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17230 blockScope->TheDecl->setBlockMissingReturnType(
17231 oldBlock->blockMissingReturnType());
17232
17234 SmallVector<QualType, 4> paramTypes;
17235
17236 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17237
17238 // Parameter substitution.
17239 Sema::ExtParameterInfoBuilder extParamInfos;
17240 if (getDerived().TransformFunctionTypeParams(
17241 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17242 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17243 extParamInfos)) {
17244 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17245 return ExprError();
17246 }
17247
17248 QualType exprResultType =
17249 getDerived().TransformType(exprFunctionType->getReturnType());
17250
17251 auto epi = exprFunctionType->getExtProtoInfo();
17252 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17253
17255 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17256 blockScope->FunctionType = functionType;
17257
17258 // Set the parameters on the block decl.
17259 if (!params.empty())
17260 blockScope->TheDecl->setParams(params);
17261
17262 if (!oldBlock->blockMissingReturnType()) {
17263 blockScope->HasImplicitReturnType = false;
17264 blockScope->ReturnType = exprResultType;
17265 }
17266
17267 // Transform the body
17268 StmtResult body = getDerived().TransformStmt(E->getBody());
17269 if (body.isInvalid()) {
17270 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17271 return ExprError();
17272 }
17273
17274#ifndef NDEBUG
17275 // In builds with assertions, make sure that we captured everything we
17276 // captured before.
17277 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17278 for (const auto &I : oldBlock->captures()) {
17279 VarDecl *oldCapture = I.getVariable();
17280
17281 // Ignore parameter packs.
17282 if (oldCapture->isParameterPack())
17283 continue;
17284
17285 VarDecl *newCapture =
17286 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17287 oldCapture));
17288 assert(blockScope->CaptureMap.count(newCapture));
17289 }
17290
17291 // The this pointer may not be captured by the instantiated block, even when
17292 // it's captured by the original block, if the expression causing the
17293 // capture is in the discarded branch of a constexpr if statement.
17294 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17295 "this pointer isn't captured in the old block");
17296 }
17297#endif
17298
17299 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17300 /*Scope=*/nullptr);
17301}
17302
17303template<typename Derived>
17306 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17307 if (SrcExpr.isInvalid())
17308 return ExprError();
17309
17310 QualType Type = getDerived().TransformType(E->getType());
17311
17312 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17313 E->getRParenLoc());
17314}
17315
17316template<typename Derived>
17319 bool ArgumentChanged = false;
17320 SmallVector<Expr*, 8> SubExprs;
17321 SubExprs.reserve(E->getNumSubExprs());
17322 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17323 SubExprs, &ArgumentChanged))
17324 return ExprError();
17325
17326 if (!getDerived().AlwaysRebuild() &&
17327 !ArgumentChanged)
17328 return E;
17329
17330 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17331 E->getOp(), E->getRParenLoc());
17332}
17333
17334//===----------------------------------------------------------------------===//
17335// Type reconstruction
17336//===----------------------------------------------------------------------===//
17337
17338template<typename Derived>
17341 return SemaRef.BuildPointerType(PointeeType, Star,
17343}
17344
17345template<typename Derived>
17348 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17350}
17351
17352template<typename Derived>
17355 bool WrittenAsLValue,
17356 SourceLocation Sigil) {
17357 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17358 Sigil, getDerived().getBaseEntity());
17359}
17360
17361template <typename Derived>
17363 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17364 SourceLocation Sigil) {
17365 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17367}
17368
17369template<typename Derived>
17371 const ObjCTypeParamDecl *Decl,
17372 SourceLocation ProtocolLAngleLoc,
17374 ArrayRef<SourceLocation> ProtocolLocs,
17375 SourceLocation ProtocolRAngleLoc) {
17376 return SemaRef.ObjC().BuildObjCTypeParamType(
17377 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17378 /*FailOnError=*/true);
17379}
17380
17381template<typename Derived>
17383 QualType BaseType,
17384 SourceLocation Loc,
17385 SourceLocation TypeArgsLAngleLoc,
17387 SourceLocation TypeArgsRAngleLoc,
17388 SourceLocation ProtocolLAngleLoc,
17390 ArrayRef<SourceLocation> ProtocolLocs,
17391 SourceLocation ProtocolRAngleLoc) {
17392 return SemaRef.ObjC().BuildObjCObjectType(
17393 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17394 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17395 /*FailOnError=*/true,
17396 /*Rebuilding=*/true);
17397}
17398
17399template<typename Derived>
17401 QualType PointeeType,
17403 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17404}
17405
17406template <typename Derived>
17408 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17409 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17410 if (SizeExpr || !Size)
17411 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17412 IndexTypeQuals, BracketsRange,
17414
17415 QualType Types[] = {
17416 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17417 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17418 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17419 };
17420 QualType SizeType;
17421 for (const auto &T : Types)
17422 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17423 SizeType = T;
17424 break;
17425 }
17426
17427 // Note that we can return a VariableArrayType here in the case where
17428 // the element type was a dependent VariableArrayType.
17429 IntegerLiteral *ArraySize
17430 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17431 /*FIXME*/BracketsRange.getBegin());
17432 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17433 IndexTypeQuals, BracketsRange,
17435}
17436
17437template <typename Derived>
17439 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17440 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17441 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17442 IndexTypeQuals, BracketsRange);
17443}
17444
17445template <typename Derived>
17447 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17448 SourceRange BracketsRange) {
17449 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17450 IndexTypeQuals, BracketsRange);
17451}
17452
17453template <typename Derived>
17455 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17456 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17457 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17458 SizeExpr,
17459 IndexTypeQuals, BracketsRange);
17460}
17461
17462template <typename Derived>
17464 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17465 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17466 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17467 SizeExpr,
17468 IndexTypeQuals, BracketsRange);
17469}
17470
17471template <typename Derived>
17473 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17474 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17475 AttributeLoc);
17476}
17477
17478template <typename Derived>
17480 unsigned NumElements,
17481 VectorKind VecKind) {
17482 // FIXME: semantic checking!
17483 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17484}
17485
17486template <typename Derived>
17488 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17489 VectorKind VecKind) {
17490 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17491}
17492
17493template<typename Derived>
17495 unsigned NumElements,
17496 SourceLocation AttributeLoc) {
17497 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17498 NumElements, true);
17499 IntegerLiteral *VectorSize
17500 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17501 AttributeLoc);
17502 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17503}
17504
17505template<typename Derived>
17508 Expr *SizeExpr,
17509 SourceLocation AttributeLoc) {
17510 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17511}
17512
17513template <typename Derived>
17515 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17516 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17517 NumColumns);
17518}
17519
17520template <typename Derived>
17522 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17523 SourceLocation AttributeLoc) {
17524 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17525 AttributeLoc);
17526}
17527
17528template <typename Derived>
17532 return SemaRef.BuildFunctionType(T, ParamTypes,
17535 EPI);
17536}
17537
17538template<typename Derived>
17540 return SemaRef.Context.getFunctionNoProtoType(T);
17541}
17542
17543template <typename Derived>
17546 SourceLocation NameLoc, Decl *D) {
17547 assert(D && "no decl found");
17548 if (D->isInvalidDecl()) return QualType();
17549
17550 // FIXME: Doesn't account for ObjCInterfaceDecl!
17551 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17552 // A valid resolved using typename pack expansion decl can have multiple
17553 // UsingDecls, but they must each have exactly one type, and it must be
17554 // the same type in every case. But we must have at least one expansion!
17555 if (UPD->expansions().empty()) {
17556 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17557 << UPD->isCXXClassMember() << UPD;
17558 return QualType();
17559 }
17560
17561 // We might still have some unresolved types. Try to pick a resolved type
17562 // if we can. The final instantiation will check that the remaining
17563 // unresolved types instantiate to the type we pick.
17564 QualType FallbackT;
17565 QualType T;
17566 for (auto *E : UPD->expansions()) {
17567 QualType ThisT =
17568 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17569 if (ThisT.isNull())
17570 continue;
17571 if (ThisT->getAs<UnresolvedUsingType>())
17572 FallbackT = ThisT;
17573 else if (T.isNull())
17574 T = ThisT;
17575 else
17576 assert(getSema().Context.hasSameType(ThisT, T) &&
17577 "mismatched resolved types in using pack expansion");
17578 }
17579 return T.isNull() ? FallbackT : T;
17580 }
17581 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17582 assert(Using->hasTypename() &&
17583 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17584
17585 // A valid resolved using typename decl points to exactly one type decl.
17586 assert(++Using->shadow_begin() == Using->shadow_end());
17587
17588 UsingShadowDecl *Shadow = *Using->shadow_begin();
17589 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17590 return QualType();
17591 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17592 }
17594 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17595 return SemaRef.Context.getUnresolvedUsingType(
17597}
17598
17599template <typename Derived>
17601 TypeOfKind Kind) {
17602 return SemaRef.BuildTypeofExprType(E, Kind);
17603}
17604
17605template<typename Derived>
17607 TypeOfKind Kind) {
17608 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17609}
17610
17611template <typename Derived>
17613 return SemaRef.BuildDecltypeType(E);
17614}
17615
17616template <typename Derived>
17618 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17619 SourceLocation EllipsisLoc, bool FullySubstituted,
17620 ArrayRef<QualType> Expansions) {
17621 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17622 FullySubstituted, Expansions);
17623}
17624
17625template<typename Derived>
17627 UnaryTransformType::UTTKind UKind,
17628 SourceLocation Loc) {
17629 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17630}
17631
17632template <typename Derived>
17635 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17636 return SemaRef.CheckTemplateIdType(
17637 Keyword, Template, TemplateNameLoc, TemplateArgs,
17638 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17639}
17640
17641template<typename Derived>
17643 SourceLocation KWLoc) {
17644 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17645}
17646
17647template<typename Derived>
17649 SourceLocation KWLoc,
17650 bool isReadPipe) {
17651 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17652 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17653}
17654
17655template <typename Derived>
17657 unsigned NumBits,
17658 SourceLocation Loc) {
17659 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17660 NumBits, true);
17661 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17662 SemaRef.Context.IntTy, Loc);
17663 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17664}
17665
17666template <typename Derived>
17668 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17669 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17670}
17671
17672template <typename Derived>
17674 bool TemplateKW,
17675 TemplateName Name) {
17676 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17677 Name);
17678}
17679
17680template <typename Derived>
17682 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17683 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17685 TemplateName.setIdentifier(&Name, NameLoc);
17687 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17688 TemplateName, ParsedType::make(ObjectType),
17689 /*EnteringContext=*/false, Template,
17690 AllowInjectedClassName);
17691 return Template.get();
17692}
17693
17694template<typename Derived>
17697 SourceLocation TemplateKWLoc,
17698 OverloadedOperatorKind Operator,
17699 SourceLocation NameLoc,
17700 QualType ObjectType,
17701 bool AllowInjectedClassName) {
17702 UnqualifiedId Name;
17703 // FIXME: Bogus location information.
17704 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17705 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17707 getSema().ActOnTemplateName(
17708 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17709 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17710 return Template.get();
17711}
17712
17713template <typename Derived>
17716 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17717 Expr *Second) {
17718 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17719
17720 if (First->getObjectKind() == OK_ObjCProperty) {
17723 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17724 Opc, First, Second);
17725 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17726 if (Result.isInvalid())
17727 return ExprError();
17728 First = Result.get();
17729 }
17730
17731 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17732 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17733 if (Result.isInvalid())
17734 return ExprError();
17735 Second = Result.get();
17736 }
17737
17738 // Determine whether this should be a builtin operation.
17739 if (Op == OO_Subscript) {
17740 if (!First->getType()->isOverloadableType() &&
17741 !Second->getType()->isOverloadableType())
17742 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17743 OpLoc);
17744 } else if (Op == OO_Arrow) {
17745 // It is possible that the type refers to a RecoveryExpr created earlier
17746 // in the tree transformation.
17747 if (First->getType()->isDependentType())
17748 return ExprError();
17749 // -> is never a builtin operation.
17750 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17751 } else if (Second == nullptr || isPostIncDec) {
17752 if (!First->getType()->isOverloadableType() ||
17753 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17754 // The argument is not of overloadable type, or this is an expression
17755 // of the form &Class::member, so try to create a built-in unary
17756 // operation.
17758 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17759
17760 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17761 }
17762 } else {
17763 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17764 !First->getType()->isOverloadableType() &&
17765 !Second->getType()->isOverloadableType()) {
17766 // Neither of the arguments is type-dependent or has an overloadable
17767 // type, so try to create a built-in binary operation.
17770 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17771 if (Result.isInvalid())
17772 return ExprError();
17773
17774 return Result;
17775 }
17776 }
17777
17778 // Create the overloaded operator invocation for unary operators.
17779 if (!Second || isPostIncDec) {
17781 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17782 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17783 RequiresADL);
17784 }
17785
17786 // Create the overloaded operator invocation for binary operators.
17788 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17789 First, Second, RequiresADL);
17790 if (Result.isInvalid())
17791 return ExprError();
17792
17793 return Result;
17794}
17795
17796template<typename Derived>
17799 SourceLocation OperatorLoc,
17800 bool isArrow,
17801 CXXScopeSpec &SS,
17802 TypeSourceInfo *ScopeType,
17803 SourceLocation CCLoc,
17804 SourceLocation TildeLoc,
17805 PseudoDestructorTypeStorage Destroyed) {
17806 QualType CanonicalBaseType = Base->getType().getCanonicalType();
17807 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
17808 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
17809 (isArrow && isa<PointerType>(CanonicalBaseType) &&
17810 !cast<PointerType>(CanonicalBaseType)
17811 ->getPointeeType()
17812 ->getAsCanonical<RecordType>())) {
17813 // This pseudo-destructor expression is still a pseudo-destructor.
17814 return SemaRef.BuildPseudoDestructorExpr(
17815 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
17816 CCLoc, TildeLoc, Destroyed);
17817 }
17818
17819 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
17820 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
17821 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
17822 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
17823 NameInfo.setNamedTypeInfo(DestroyedType);
17824
17825 // The scope type is now known to be a valid nested name specifier
17826 // component. Tack it on to the nested name specifier.
17827 if (ScopeType) {
17828 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
17829 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
17830 diag::err_expected_class_or_namespace)
17831 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
17832 return ExprError();
17833 }
17834 SS.clear();
17835 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
17836 }
17837
17838 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
17839 return getSema().BuildMemberReferenceExpr(
17840 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
17841 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
17842 /*TemplateArgs*/ nullptr,
17843 /*S*/ nullptr);
17844}
17845
17846template<typename Derived>
17849 SourceLocation Loc = S->getBeginLoc();
17850 CapturedDecl *CD = S->getCapturedDecl();
17851 unsigned NumParams = CD->getNumParams();
17852 unsigned ContextParamPos = CD->getContextParamPosition();
17854 for (unsigned I = 0; I < NumParams; ++I) {
17855 if (I != ContextParamPos) {
17856 Params.push_back(
17857 std::make_pair(
17858 CD->getParam(I)->getName(),
17859 getDerived().TransformType(CD->getParam(I)->getType())));
17860 } else {
17861 Params.push_back(std::make_pair(StringRef(), QualType()));
17862 }
17863 }
17864 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
17865 S->getCapturedRegionKind(), Params);
17866 StmtResult Body;
17867 {
17868 Sema::CompoundScopeRAII CompoundScope(getSema());
17869 Body = getDerived().TransformStmt(S->getCapturedStmt());
17870 }
17871
17872 if (Body.isInvalid()) {
17873 getSema().ActOnCapturedRegionError();
17874 return StmtError();
17875 }
17876
17877 return getSema().ActOnCapturedRegionEnd(Body.get());
17878}
17879
17880template <typename Derived>
17883 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
17884 // function definition or instantiation of a function template specialization
17885 // and will therefore never appear in a dependent context.
17886 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
17887 "context");
17888}
17889
17890template <typename Derived>
17892 // We can transform the base expression and allow argument resolution to fill
17893 // in the rest.
17894 return getDerived().TransformExpr(E->getArgLValue());
17895}
17896
17897} // end namespace clang
17898
17899#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:4550
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:6021
Represents a loop initializing the elements of an array.
Definition Expr.h:5968
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1804
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7171
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:3723
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6685
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6880
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:2194
Stmt * getSubStmt()
Definition Stmt.h:2230
SourceLocation getAttrLoc() const
Definition Stmt.h:2225
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2226
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:4453
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4038
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:4174
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:8145
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:6624
Wrapper for source info for block pointers.
Definition TypeLoc.h:1497
BreakStmt - This represents a break.
Definition Stmt.h:3126
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:3969
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:2943
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:3918
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1455
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:4022
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:4113
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition Stmt.cpp:1470
CaseStmt - Represent a case statement.
Definition Stmt.h:1911
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:3726
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4848
Represents a 'co_await' expression.
Definition ExprCXX.h:5369
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4300
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3605
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1731
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Stmt.h:1781
body_range body()
Definition Stmt.h:1794
SourceLocation getLBracLoc() const
Definition Stmt.h:1848
bool hasStoredFPFeatures() const
Definition Stmt.h:1778
Stmt * body_back()
Definition Stmt.h:1799
SourceLocation getRBracLoc() const
Definition Stmt.h:1849
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:4391
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3761
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:4388
ContinueStmt - This represents a continue.
Definition Stmt.h:3110
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4719
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:3437
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:1622
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:3227
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:4062
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:4012
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2067
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4102
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition TypeBase.h:4435
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2039
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4228
Represents a single C99 designator.
Definition Expr.h:5594
Represents a C99 designated initializer expression.
Definition Expr.h:5551
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:208
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
Definition Designator.h:172
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
Definition Designator.h:142
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
Definition Designator.h:115
bool hasErrorOccurred() const
Definition Diagnostic.h:872
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2823
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Definition TypeBase.h:4989
Expr * getCondition() const
Definition TypeBase.h:4996
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:744
Represents a reference to emded data.
Definition Expr.h:5126
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:3950
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:6564
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:2879
Represents a function declaration or definition.
Definition Decl.h:2000
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2774
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5237
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4882
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5522
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5508
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5103
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4847
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:5269
param_type_iterator param_type_begin() const
Definition TypeBase.h:5713
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:4491
This represents a GCC inline-assembly statement extension.
Definition Stmt.h:3427
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition Expr.h:4923
Represents a C11 generic selection.
Definition Expr.h:6178
AssociationTy< false > Association
Definition Expr.h:6409
GotoStmt - This represents a direct goto.
Definition Stmt.h:2960
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:7349
One of these records is kept for each identifier that is lexed.
IfStmt - This represents an if/then/else.
Definition Stmt.h:2250
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:3853
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:6057
Represents a C array with an unspecified size.
Definition TypeBase.h:3910
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:2999
const TypeClass * getTypePtr() const
Definition TypeLoc.h:526
Describes an C or C++ initializer list.
Definition Expr.h:5299
InitListExpr * getSyntacticForm() const
Definition Expr.h:5472
Wrapper for source info for injected class names of class templates.
Definition TypeLoc.h:872
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition Expr.cpp:974
Represents the declaration of a label.
Definition Decl.h:524
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2137
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:3646
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
MatrixSingleSubscriptExpr - Matrix single subscript expression for the MatrixType extension when you ...
Definition Expr.h:2795
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2865
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2096
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3364
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:3654
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:5877
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h:1694
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:8111
bool isReadOnly() const
Definition TypeBase.h:8141
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:3329
[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:6756
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:8293
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition TypeBase.h:8333
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition TypeBase.h:8387
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8325
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:7455
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3574
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3590
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:3151
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition Stmt.cpp:1323
Represents a __leave statement.
Definition Stmt.h:3879
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:13604
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8434
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:12997
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:13016
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13004
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14001
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:855
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:9315
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9323
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9318
bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend)
Check that the expression co_await promise.final_suspend() shall not be potentially-throwing.
ExprResult CreateBuiltinMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx, SourceLocation RBLoc)
ExprResult ActOnConstantExpression(ExprResult Res)
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs)
ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E)
SemaOpenMP & OpenMP()
Definition Sema.h: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:7826
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7828
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7827
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:11947
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:923
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:926
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:919
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
SemaOpenACC & OpenACC()
Definition Sema.h:1491
@ ReuseLambdaContextDecl
Definition Sema.h:7004
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:11750
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:11745
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:13598
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:6717
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6727
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6696
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6722
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:8303
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:11036
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:7812
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:8643
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:4643
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:5017
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition Expr.h:5077
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:4595
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:1484
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:2500
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 RebuildMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx, SourceLocation RBracketLoc)
Build a new matrix single subscript expression.
ExprResult RebuildCXXNoexceptExpr(SourceRange Range, Expr *Arg)
Build a new noexcept expression.
QualType RebuildFunctionProtoType(QualType T, MutableArrayRef< QualType > ParamTypes, const FunctionProtoType::ExtProtoInfo &EPI)
Build a new function type.
ExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS, bool ForFoldExpression=false)
Build a new binary operator expression.
ExprResult RebuildObjCSubscriptRefExpr(SourceLocation RB, Expr *Base, Expr *Key, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
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:6180
A container of type source information.
Definition TypeBase.h:8264
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:8275
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:2783
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:9035
bool isObjCObjectPointerType() const
Definition TypeBase.h:8705
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9112
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:5985
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:4957
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:3967
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2016
Represents a GCC generic vector type.
Definition TypeBase.h:4176
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2688
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:652
@ 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:603
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
Definition Sema.h:237
@ 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:3720
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:5893
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:561
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:799
@ Exists
The symbol exists.
Definition Sema.h:792
@ Error
An error occurred.
Definition Sema.h:802
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:795
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:5004
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5868
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5889
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5879
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5886
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:5006
Holds information about the various types of exception specification.
Definition TypeBase.h:5326
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5342
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5328
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5331
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5334
Extra information about a function prototype.
Definition TypeBase.h:5354
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5359
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:3276
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:13074
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13105
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