clang 23.0.0git
TreeTransform.h
Go to the documentation of this file.
1//===------- TreeTransform.h - Semantic Tree Transformation -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//===----------------------------------------------------------------------===//
7//
8// This file implements a semantic tree transformation that takes a given
9// AST and rebuilds it, possibly transforming some nodes in the process.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
14#define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
15
17#include "TypeLocBuilder.h"
18#include "clang/AST/Decl.h"
19#include "clang/AST/DeclObjC.h"
21#include "clang/AST/Expr.h"
22#include "clang/AST/ExprCXX.h"
24#include "clang/AST/ExprObjC.h"
27#include "clang/AST/Stmt.h"
28#include "clang/AST/StmtCXX.h"
29#include "clang/AST/StmtObjC.h"
32#include "clang/AST/StmtSYCL.h"
37#include "clang/Sema/Lookup.h"
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 ForgetPartiallySubstitutedPackRAII(
143 const ForgetPartiallySubstitutedPackRAII &) = delete;
144 ForgetPartiallySubstitutedPackRAII &
145 operator=(const ForgetPartiallySubstitutedPackRAII &) = delete;
146 };
147
148protected:
150
151 /// The set of local declarations that have been transformed, for
152 /// cases where we are forced to build new declarations within the transformer
153 /// rather than in the subclass (e.g., lambda closure types).
154 llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls;
155
156public:
157 /// Initializes a new tree transformer.
159
160 /// Retrieves a reference to the derived class.
161 Derived &getDerived() { return static_cast<Derived&>(*this); }
162
163 /// Retrieves a reference to the derived class.
164 const Derived &getDerived() const {
165 return static_cast<const Derived&>(*this);
166 }
167
168 static inline ExprResult Owned(Expr *E) { return E; }
169 static inline StmtResult Owned(Stmt *S) { return S; }
170
171 /// Retrieves a reference to the semantic analysis object used for
172 /// this tree transform.
173 Sema &getSema() const { return SemaRef; }
174
175 /// Whether the transformation should always rebuild AST nodes, even
176 /// if none of the children have changed.
177 ///
178 /// Subclasses may override this function to specify when the transformation
179 /// should rebuild all AST nodes.
180 ///
181 /// We must always rebuild all AST nodes when performing variadic template
182 /// pack expansion, in order to avoid violating the AST invariant that each
183 /// statement node appears at most once in its containing declaration.
184 bool AlwaysRebuild() { return static_cast<bool>(SemaRef.ArgPackSubstIndex); }
185
186 /// Whether the transformation is forming an expression or statement that
187 /// replaces the original. In this case, we'll reuse mangling numbers from
188 /// existing lambdas.
189 bool ReplacingOriginal() { return false; }
190
191 /// Wether CXXConstructExpr can be skipped when they are implicit.
192 /// They will be reconstructed when used if needed.
193 /// This is useful when the user that cause rebuilding of the
194 /// CXXConstructExpr is outside of the expression at which the TreeTransform
195 /// started.
196 bool AllowSkippingCXXConstructExpr() { return true; }
197
198 /// Returns the location of the entity being transformed, if that
199 /// information was not available elsewhere in the AST.
200 ///
201 /// By default, returns no source-location information. Subclasses can
202 /// provide an alternative implementation that provides better location
203 /// information.
205
206 /// Returns the name of the entity being transformed, if that
207 /// information was not available elsewhere in the AST.
208 ///
209 /// By default, returns an empty name. Subclasses can provide an alternative
210 /// implementation with a more precise name.
212
213 /// Sets the "base" location and entity when that
214 /// information is known based on another transformation.
215 ///
216 /// By default, the source location and entity are ignored. Subclasses can
217 /// override this function to provide a customized implementation.
219
220 /// RAII object that temporarily sets the base location and entity
221 /// used for reporting diagnostics in types.
223 TreeTransform &Self;
224 SourceLocation OldLocation;
225 DeclarationName OldEntity;
226
227 public:
229 DeclarationName Entity) : Self(Self) {
230 OldLocation = Self.getDerived().getBaseLocation();
231 OldEntity = Self.getDerived().getBaseEntity();
232
233 if (Location.isValid())
234 Self.getDerived().setBase(Location, Entity);
235 }
236
238 Self.getDerived().setBase(OldLocation, OldEntity);
239 }
240 TemporaryBase(const TemporaryBase &) = delete;
242 };
243
244 /// Determine whether the given type \p T has already been
245 /// transformed.
246 ///
247 /// Subclasses can provide an alternative implementation of this routine
248 /// to short-circuit evaluation when it is known that a given type will
249 /// not change. For example, template instantiation need not traverse
250 /// non-dependent types.
252 return T.isNull();
253 }
254
255 /// Transform a template parameter depth level.
256 ///
257 /// During a transformation that transforms template parameters, this maps
258 /// an old template parameter depth to a new depth.
259 unsigned TransformTemplateDepth(unsigned Depth) {
260 return Depth;
261 }
262
263 /// Determine whether the given call argument should be dropped, e.g.,
264 /// because it is a default argument.
265 ///
266 /// Subclasses can provide an alternative implementation of this routine to
267 /// determine which kinds of call arguments get dropped. By default,
268 /// CXXDefaultArgument nodes are dropped (prior to transformation).
270 return E->isDefaultArgument();
271 }
272
273 /// Determine whether we should expand a pack expansion with the
274 /// given set of parameter packs into separate arguments by repeatedly
275 /// transforming the pattern.
276 ///
277 /// By default, the transformer never tries to expand pack expansions.
278 /// Subclasses can override this routine to provide different behavior.
279 ///
280 /// \param EllipsisLoc The location of the ellipsis that identifies the
281 /// pack expansion.
282 ///
283 /// \param PatternRange The source range that covers the entire pattern of
284 /// the pack expansion.
285 ///
286 /// \param Unexpanded The set of unexpanded parameter packs within the
287 /// pattern.
288 ///
289 /// \param ShouldExpand Will be set to \c true if the transformer should
290 /// expand the corresponding pack expansions into separate arguments. When
291 /// set, \c NumExpansions must also be set.
292 ///
293 /// \param RetainExpansion Whether the caller should add an unexpanded
294 /// pack expansion after all of the expanded arguments. This is used
295 /// when extending explicitly-specified template argument packs per
296 /// C++0x [temp.arg.explicit]p9.
297 ///
298 /// \param NumExpansions The number of separate arguments that will be in
299 /// the expanded form of the corresponding pack expansion. This is both an
300 /// input and an output parameter, which can be set by the caller if the
301 /// number of expansions is known a priori (e.g., due to a prior substitution)
302 /// and will be set by the callee when the number of expansions is known.
303 /// The callee must set this value when \c ShouldExpand is \c true; it may
304 /// set this value in other cases.
305 ///
306 /// \returns true if an error occurred (e.g., because the parameter packs
307 /// are to be instantiated with arguments of different lengths), false
308 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
309 /// must be set.
311 SourceRange PatternRange,
313 bool FailOnPackProducingTemplates,
314 bool &ShouldExpand, bool &RetainExpansion,
315 UnsignedOrNone &NumExpansions) {
316 ShouldExpand = false;
317 return false;
318 }
319
320 /// "Forget" about the partially-substituted pack template argument,
321 /// when performing an instantiation that must preserve the parameter pack
322 /// use.
323 ///
324 /// This routine is meant to be overridden by the template instantiator.
328
329 /// "Remember" the partially-substituted pack template argument
330 /// after performing an instantiation that must preserve the parameter pack
331 /// use.
332 ///
333 /// This routine is meant to be overridden by the template instantiator.
335
336 /// "Forget" the template substitution to allow transforming the AST without
337 /// any template instantiations. This is used to expand template packs when
338 /// their size is not known in advance (e.g. for builtins that produce type
339 /// packs).
342
343private:
344 struct ForgetSubstitutionRAII {
345 Derived &Self;
347
348 public:
349 ForgetSubstitutionRAII(Derived &Self) : Self(Self) {
350 Old = Self.ForgetSubstitution();
351 }
352
353 ~ForgetSubstitutionRAII() { Self.RememberSubstitution(std::move(Old)); }
354 };
355
356public:
357 /// Note to the derived class when a function parameter pack is
358 /// being expanded.
360
361 /// Transforms the given type into another type.
362 ///
363 /// By default, this routine transforms a type by creating a
364 /// TypeSourceInfo for it and delegating to the appropriate
365 /// function. This is expensive, but we don't mind, because
366 /// this method is deprecated anyway; all users should be
367 /// switched to storing TypeSourceInfos.
368 ///
369 /// \returns the transformed type.
371
372 /// Transforms the given type-with-location into a new
373 /// type-with-location.
374 ///
375 /// By default, this routine transforms a type by delegating to the
376 /// appropriate TransformXXXType to build a new type. Subclasses
377 /// may override this function (to take over all type
378 /// transformations) or some set of the TransformXXXType functions
379 /// to alter the transformation.
381
382 /// Transform the given type-with-location into a new
383 /// type, collecting location information in the given builder
384 /// as necessary.
385 ///
387
388 /// Transform a type that is permitted to produce a
389 /// DeducedTemplateSpecializationType.
390 ///
391 /// This is used in the (relatively rare) contexts where it is acceptable
392 /// for transformation to produce a class template type with deduced
393 /// template arguments.
394 /// @{
397 /// @}
398
399 /// The reason why the value of a statement is not discarded, if any.
405
406 /// Transform the given statement.
407 ///
408 /// By default, this routine transforms a statement by delegating to the
409 /// appropriate TransformXXXStmt function to transform a specific kind of
410 /// statement or the TransformExpr() function to transform an expression.
411 /// Subclasses may override this function to transform statements using some
412 /// other mechanism.
413 ///
414 /// \returns the transformed statement.
417
418 /// Transform the given statement.
419 ///
420 /// By default, this routine transforms a statement by delegating to the
421 /// appropriate TransformOMPXXXClause function to transform a specific kind
422 /// of clause. Subclasses may override this function to transform statements
423 /// using some other mechanism.
424 ///
425 /// \returns the transformed OpenMP clause.
427
428 /// Transform the given attribute.
429 ///
430 /// By default, this routine transforms a statement by delegating to the
431 /// appropriate TransformXXXAttr function to transform a specific kind
432 /// of attribute. Subclasses may override this function to transform
433 /// attributed statements/types using some other mechanism.
434 ///
435 /// \returns the transformed attribute
436 const Attr *TransformAttr(const Attr *S);
437
438 // Transform the given statement attribute.
439 //
440 // Delegates to the appropriate TransformXXXAttr function to transform a
441 // specific kind of statement attribute. Unlike the non-statement taking
442 // version of this, this implements all attributes, not just pragmas.
443 const Attr *TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS,
444 const Attr *A);
445
446 // Transform the specified attribute.
447 //
448 // Subclasses should override the transformation of attributes with a pragma
449 // spelling to transform expressions stored within the attribute.
450 //
451 // \returns the transformed attribute.
452#define ATTR(X) \
453 const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; }
454#include "clang/Basic/AttrList.inc"
455
456 // Transform the specified attribute.
457 //
458 // Subclasses should override the transformation of attributes to do
459 // transformation and checking of statement attributes. By default, this
460 // delegates to the non-statement taking version.
461 //
462 // \returns the transformed attribute.
463#define ATTR(X) \
464 const X##Attr *TransformStmt##X##Attr(const Stmt *, const Stmt *, \
465 const X##Attr *A) { \
466 return getDerived().Transform##X##Attr(A); \
467 }
468#include "clang/Basic/AttrList.inc"
469
470 /// Transform the given expression.
471 ///
472 /// By default, this routine transforms an expression by delegating to the
473 /// appropriate TransformXXXExpr function to build a new expression.
474 /// Subclasses may override this function to transform expressions using some
475 /// other mechanism.
476 ///
477 /// \returns the transformed expression.
479
480 /// Transform the given initializer.
481 ///
482 /// By default, this routine transforms an initializer by stripping off the
483 /// semantic nodes added by initialization, then passing the result to
484 /// TransformExpr or TransformExprs.
485 ///
486 /// \returns the transformed initializer.
488
489 /// Transform the given list of expressions.
490 ///
491 /// This routine transforms a list of expressions by invoking
492 /// \c TransformExpr() for each subexpression. However, it also provides
493 /// support for variadic templates by expanding any pack expansions (if the
494 /// derived class permits such expansion) along the way. When pack expansions
495 /// are present, the number of outputs may not equal the number of inputs.
496 ///
497 /// \param Inputs The set of expressions to be transformed.
498 ///
499 /// \param NumInputs The number of expressions in \c Inputs.
500 ///
501 /// \param IsCall If \c true, then this transform is being performed on
502 /// function-call arguments, and any arguments that should be dropped, will
503 /// be.
504 ///
505 /// \param Outputs The transformed input expressions will be added to this
506 /// vector.
507 ///
508 /// \param ArgChanged If non-NULL, will be set \c true if any argument changed
509 /// due to transformation.
510 ///
511 /// \returns true if an error occurred, false otherwise.
512 bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall,
514 bool *ArgChanged = nullptr);
515
516 /// Transform the given declaration, which is referenced from a type
517 /// or expression.
518 ///
519 /// By default, acts as the identity function on declarations, unless the
520 /// transformer has had to transform the declaration itself. Subclasses
521 /// may override this function to provide alternate behavior.
523 llvm::DenseMap<Decl *, Decl *>::iterator Known
524 = TransformedLocalDecls.find(D);
525 if (Known != TransformedLocalDecls.end())
526 return Known->second;
527
528 return D;
529 }
530
531 /// Transform the specified condition.
532 ///
533 /// By default, this transforms the variable and expression and rebuilds
534 /// the condition.
536 Expr *Expr,
538
539 /// Transform the attributes associated with the given declaration and
540 /// place them on the new declaration.
541 ///
542 /// By default, this operation does nothing. Subclasses may override this
543 /// behavior to transform attributes.
544 void transformAttrs(Decl *Old, Decl *New) { }
545
546 /// Note that a local declaration has been transformed by this
547 /// transformer.
548 ///
549 /// Local declarations are typically transformed via a call to
550 /// TransformDefinition. However, in some cases (e.g., lambda expressions),
551 /// the transformer itself has to transform the declarations. This routine
552 /// can be overridden by a subclass that keeps track of such mappings.
554 assert(New.size() == 1 &&
555 "must override transformedLocalDecl if performing pack expansion");
556 TransformedLocalDecls[Old] = New.front();
557 }
558
559 /// Transform the definition of the given declaration.
560 ///
561 /// By default, invokes TransformDecl() to transform the declaration.
562 /// Subclasses may override this function to provide alternate behavior.
564 return getDerived().TransformDecl(Loc, D);
565 }
566
567 /// Transform the given declaration, which was the first part of a
568 /// nested-name-specifier in a member access expression.
569 ///
570 /// This specific declaration transformation only applies to the first
571 /// identifier in a nested-name-specifier of a member access expression, e.g.,
572 /// the \c T in \c x->T::member
573 ///
574 /// By default, invokes TransformDecl() to transform the declaration.
575 /// Subclasses may override this function to provide alternate behavior.
577 return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D));
578 }
579
580 /// Transform the set of declarations in an OverloadExpr.
581 bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL,
582 LookupResult &R);
583
584 /// Transform the given nested-name-specifier with source-location
585 /// information.
586 ///
587 /// By default, transforms all of the types and declarations within the
588 /// nested-name-specifier. Subclasses may override this function to provide
589 /// alternate behavior.
592 QualType ObjectType = QualType(),
593 NamedDecl *FirstQualifierInScope = nullptr);
594
595 /// Transform the given declaration name.
596 ///
597 /// By default, transforms the types of conversion function, constructor,
598 /// and destructor names and then (if needed) rebuilds the declaration name.
599 /// Identifiers and selectors are returned unmodified. Subclasses may
600 /// override this function to provide alternate behavior.
603
613
614 /// Transform the given template name.
615 ///
616 /// \param SS The nested-name-specifier that qualifies the template
617 /// name. This nested-name-specifier must already have been transformed.
618 ///
619 /// \param Name The template name to transform.
620 ///
621 /// \param NameLoc The source location of the template name.
622 ///
623 /// \param ObjectType If we're translating a template name within a member
624 /// access expression, this is the type of the object whose member template
625 /// is being referenced.
626 ///
627 /// \param FirstQualifierInScope If the first part of a nested-name-specifier
628 /// also refers to a name within the current (lexical) scope, this is the
629 /// declaration it refers to.
630 ///
631 /// By default, transforms the template name by transforming the declarations
632 /// and nested-name-specifiers that occur within the template name.
633 /// Subclasses may override this function to provide alternate behavior.
635 SourceLocation TemplateKWLoc,
636 TemplateName Name, SourceLocation NameLoc,
637 QualType ObjectType = QualType(),
638 NamedDecl *FirstQualifierInScope = nullptr,
639 bool AllowInjectedClassName = false);
640
641 /// Transform the given template argument.
642 ///
643 /// By default, this operation transforms the type, expression, or
644 /// declaration stored within the template argument and constructs a
645 /// new template argument from the transformed result. Subclasses may
646 /// override this function to provide alternate behavior.
647 ///
648 /// Returns true if there was an error.
650 TemplateArgumentLoc &Output,
651 bool Uneval = false);
652
654 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
655 TemplateName Name, SourceLocation NameLoc);
656
657 /// Transform the given set of template arguments.
658 ///
659 /// By default, this operation transforms all of the template arguments
660 /// in the input set using \c TransformTemplateArgument(), and appends
661 /// the transformed arguments to the output list.
662 ///
663 /// Note that this overload of \c TransformTemplateArguments() is merely
664 /// a convenience function. Subclasses that wish to override this behavior
665 /// should override the iterator-based member template version.
666 ///
667 /// \param Inputs The set of template arguments to be transformed.
668 ///
669 /// \param NumInputs The number of template arguments in \p Inputs.
670 ///
671 /// \param Outputs The set of transformed template arguments output by this
672 /// routine.
673 ///
674 /// Returns true if an error occurred.
676 unsigned NumInputs,
678 bool Uneval = false) {
679 return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs,
680 Uneval);
681 }
682
683 /// Transform the given set of template arguments.
684 ///
685 /// By default, this operation transforms all of the template arguments
686 /// in the input set using \c TransformTemplateArgument(), and appends
687 /// the transformed arguments to the output list.
688 ///
689 /// \param First An iterator to the first template argument.
690 ///
691 /// \param Last An iterator one step past the last template argument.
692 ///
693 /// \param Outputs The set of transformed template arguments output by this
694 /// routine.
695 ///
696 /// Returns true if an error occurred.
697 template<typename InputIterator>
699 InputIterator Last,
701 bool Uneval = false);
702
703 template <typename InputIterator>
705 InputIterator Last,
707 bool Uneval = false);
708
709 /// Checks if the argument pack from \p In will need to be expanded and does
710 /// the necessary prework.
711 /// Whether the expansion is needed is captured in Info.Expand.
712 ///
713 /// - When the expansion is required, \p Out will be a template pattern that
714 /// would need to be expanded.
715 /// - When the expansion must not happen, \p Out will be a pack that must be
716 /// returned to the outputs directly.
717 ///
718 /// \return true iff the error occurred
721
722 /// Fakes up a TemplateArgumentLoc for a given TemplateArgument.
724 TemplateArgumentLoc &ArgLoc);
725
726 /// Fakes up a TypeSourceInfo for a type.
728 return SemaRef.Context.getTrivialTypeSourceInfo(T,
730 }
731
732#define ABSTRACT_TYPELOC(CLASS, PARENT)
733#define TYPELOC(CLASS, PARENT) \
734 QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
735#include "clang/AST/TypeLocNodes.def"
736
739 bool SuppressObjCLifetime);
743 bool SuppressObjCLifetime);
744
745 template<typename Fn>
748 CXXRecordDecl *ThisContext,
749 Qualifiers ThisTypeQuals,
751
754 SmallVectorImpl<QualType> &Exceptions,
755 bool &Changed);
756
758
761 QualType ObjectType,
762 NamedDecl *FirstQualifierInScope,
763 bool AllowInjectedClassName);
764
766
767 /// Transforms the parameters of a function type into the
768 /// given vectors.
769 ///
770 /// The result vectors should be kept in sync; null entries in the
771 /// variables vector are acceptable.
772 ///
773 /// LastParamTransformed, if non-null, will be set to the index of the last
774 /// parameter on which transformation was started. In the event of an error,
775 /// this will contain the parameter which failed to instantiate.
776 ///
777 /// Return true on error.
780 const QualType *ParamTypes,
781 const FunctionProtoType::ExtParameterInfo *ParamInfos,
783 Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed);
784
787 const QualType *ParamTypes,
788 const FunctionProtoType::ExtParameterInfo *ParamInfos,
791 return getDerived().TransformFunctionTypeParams(
792 Loc, Params, ParamTypes, ParamInfos, PTypes, PVars, PInfos, nullptr);
793 }
794
795 /// Transforms the parameters of a requires expresison into the given vectors.
796 ///
797 /// The result vectors should be kept in sync; null entries in the
798 /// variables vector are acceptable.
799 ///
800 /// Returns an unset ExprResult on success. Returns an ExprResult the 'not
801 /// satisfied' RequiresExpr if subsitution failed, OR an ExprError, both of
802 /// which are cases where transformation shouldn't continue.
804 SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
810 KWLoc, Params, /*ParamTypes=*/nullptr,
811 /*ParamInfos=*/nullptr, PTypes, &TransParams, PInfos))
812 return ExprError();
813
814 return ExprResult{};
815 }
816
817 /// Transforms a single function-type parameter. Return null
818 /// on error.
819 ///
820 /// \param indexAdjustment - A number to add to the parameter's
821 /// scope index; can be negative
823 int indexAdjustment,
824 UnsignedOrNone NumExpansions,
825 bool ExpectParameterPack);
826
827 /// Transform the body of a lambda-expression.
829 /// Alternative implementation of TransformLambdaBody that skips transforming
830 /// the body.
832
838
840
842
845
850
852
854 bool IsAddressOfOperand,
855 TypeSourceInfo **RecoveryTSI);
856
858 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
859 TypeSourceInfo **RecoveryTSI);
860
862 bool IsAddressOfOperand);
863
865
867
868// FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
869// amount of stack usage with clang.
870#define STMT(Node, Parent) \
871 LLVM_ATTRIBUTE_NOINLINE \
872 StmtResult Transform##Node(Node *S);
873#define VALUESTMT(Node, Parent) \
874 LLVM_ATTRIBUTE_NOINLINE \
875 StmtResult Transform##Node(Node *S, StmtDiscardKind SDK);
876#define EXPR(Node, Parent) \
877 LLVM_ATTRIBUTE_NOINLINE \
878 ExprResult Transform##Node(Node *E);
879#define ABSTRACT_STMT(Stmt)
880#include "clang/AST/StmtNodes.inc"
881
882#define GEN_CLANG_CLAUSE_CLASS
883#define CLAUSE_CLASS(Enum, Str, Class) \
884 LLVM_ATTRIBUTE_NOINLINE \
885 OMPClause *Transform##Class(Class *S);
886#include "llvm/Frontend/OpenMP/OMP.inc"
887
888 /// Build a new qualified type given its unqualified type and type location.
889 ///
890 /// By default, this routine adds type qualifiers only to types that can
891 /// have qualifiers, and silently suppresses those qualifiers that are not
892 /// permitted. Subclasses may override this routine to provide different
893 /// behavior.
895
896 /// Build a new pointer type given its pointee type.
897 ///
898 /// By default, performs semantic analysis when building the pointer type.
899 /// Subclasses may override this routine to provide different behavior.
901
902 /// Build a new block pointer type given its pointee type.
903 ///
904 /// By default, performs semantic analysis when building the block pointer
905 /// type. Subclasses may override this routine to provide different behavior.
907
908 /// Build a new reference type given the type it references.
909 ///
910 /// By default, performs semantic analysis when building the
911 /// reference type. Subclasses may override this routine to provide
912 /// different behavior.
913 ///
914 /// \param LValue whether the type was written with an lvalue sigil
915 /// or an rvalue sigil.
917 bool LValue,
918 SourceLocation Sigil);
919
920 /// Build a new member pointer type given the pointee type and the
921 /// qualifier it refers into.
922 ///
923 /// By default, performs semantic analysis when building the member pointer
924 /// type. Subclasses may override this routine to provide different behavior.
926 const CXXScopeSpec &SS, CXXRecordDecl *Cls,
927 SourceLocation Sigil);
928
930 SourceLocation ProtocolLAngleLoc,
932 ArrayRef<SourceLocation> ProtocolLocs,
933 SourceLocation ProtocolRAngleLoc);
934
935 /// Build an Objective-C object type.
936 ///
937 /// By default, performs semantic analysis when building the object type.
938 /// Subclasses may override this routine to provide different behavior.
940 SourceLocation Loc,
941 SourceLocation TypeArgsLAngleLoc,
943 SourceLocation TypeArgsRAngleLoc,
944 SourceLocation ProtocolLAngleLoc,
946 ArrayRef<SourceLocation> ProtocolLocs,
947 SourceLocation ProtocolRAngleLoc);
948
949 /// Build a new Objective-C object pointer type given the pointee type.
950 ///
951 /// By default, directly builds the pointer type, with no additional semantic
952 /// analysis.
955
956 /// Build a new array type given the element type, size
957 /// modifier, size of the array (if known), size expression, and index type
958 /// qualifiers.
959 ///
960 /// By default, performs semantic analysis when building the array type.
961 /// Subclasses may override this routine to provide different behavior.
962 /// Also by default, all of the other Rebuild*Array
964 const llvm::APInt *Size, Expr *SizeExpr,
965 unsigned IndexTypeQuals, SourceRange BracketsRange);
966
967 /// Build a new constant array type given the element type, size
968 /// modifier, (known) size of the array, and index type qualifiers.
969 ///
970 /// By default, performs semantic analysis when building the array type.
971 /// Subclasses may override this routine to provide different behavior.
973 ArraySizeModifier SizeMod,
974 const llvm::APInt &Size, Expr *SizeExpr,
975 unsigned IndexTypeQuals,
976 SourceRange BracketsRange);
977
978 /// Build a new incomplete array type given the element type, size
979 /// modifier, and index type qualifiers.
980 ///
981 /// By default, performs semantic analysis when building the array type.
982 /// Subclasses may override this routine to provide different behavior.
984 ArraySizeModifier SizeMod,
985 unsigned IndexTypeQuals,
986 SourceRange BracketsRange);
987
988 /// Build a new variable-length array type given the element type,
989 /// size modifier, size expression, and index type qualifiers.
990 ///
991 /// By default, performs semantic analysis when building the array type.
992 /// Subclasses may override this routine to provide different behavior.
994 ArraySizeModifier SizeMod, Expr *SizeExpr,
995 unsigned IndexTypeQuals,
996 SourceRange BracketsRange);
997
998 /// Build a new dependent-sized array type given the element type,
999 /// size modifier, size expression, and index type qualifiers.
1000 ///
1001 /// By default, performs semantic analysis when building the array type.
1002 /// Subclasses may override this routine to provide different behavior.
1004 ArraySizeModifier SizeMod,
1005 Expr *SizeExpr,
1006 unsigned IndexTypeQuals,
1007 SourceRange BracketsRange);
1008
1009 /// Build a new vector type given the element type and
1010 /// 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.
1014 QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
1015 VectorKind VecKind);
1016
1017 /// Build a new potentially dependently-sized extended vector type
1018 /// given the element type and 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.
1023 SourceLocation AttributeLoc, VectorKind);
1024
1025 /// Build a new extended vector type given the element type and
1026 /// 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.
1030 QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
1031 SourceLocation AttributeLoc);
1032
1033 /// Build a new potentially dependently-sized extended vector type
1034 /// given the element type and number of elements.
1035 ///
1036 /// By default, performs semantic analysis when building the vector type.
1037 /// Subclasses may override this routine to provide different behavior.
1039 Expr *SizeExpr,
1040 SourceLocation AttributeLoc);
1041
1042 /// Build a new matrix type given the element type and dimensions.
1043 QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows,
1044 unsigned NumColumns);
1045
1046 /// Build a new matrix type given the type and dependently-defined
1047 /// dimensions.
1049 Expr *ColumnExpr,
1050 SourceLocation AttributeLoc);
1051
1052 /// Build a new DependentAddressSpaceType or return the pointee
1053 /// type variable with the correct address space (retrieved from
1054 /// AddrSpaceExpr) applied to it. The former will be returned in cases
1055 /// where the address space remains dependent.
1056 ///
1057 /// By default, performs semantic analysis when building the type with address
1058 /// space applied. Subclasses may override this routine to provide different
1059 /// behavior.
1061 Expr *AddrSpaceExpr,
1062 SourceLocation AttributeLoc);
1063
1064 /// Build a new function type.
1065 ///
1066 /// By default, performs semantic analysis when building the function type.
1067 /// Subclasses may override this routine to provide different behavior.
1069 MutableArrayRef<QualType> ParamTypes,
1071
1072 /// Build a new unprototyped function type.
1074
1075 /// Rebuild an unresolved typename type, given the decl that
1076 /// the UnresolvedUsingTypenameDecl was transformed to.
1078 NestedNameSpecifier Qualifier,
1079 SourceLocation NameLoc, Decl *D);
1080
1081 /// Build a new type found via an alias.
1084 QualType UnderlyingType) {
1085 return SemaRef.Context.getUsingType(Keyword, Qualifier, D, UnderlyingType);
1086 }
1087
1088 /// Build a new typedef type.
1090 NestedNameSpecifier Qualifier,
1092 return SemaRef.Context.getTypedefType(Keyword, Qualifier, Typedef);
1093 }
1094
1095 /// Build a new MacroDefined type.
1097 const IdentifierInfo *MacroII) {
1098 return SemaRef.Context.getMacroQualifiedType(T, MacroII);
1099 }
1100
1101 /// Build a new class/struct/union/enum type.
1103 NestedNameSpecifier Qualifier, TagDecl *Tag) {
1104 return SemaRef.Context.getTagType(Keyword, Qualifier, Tag,
1105 /*OwnsTag=*/false);
1106 }
1108 return SemaRef.Context.getCanonicalTagType(Tag);
1109 }
1110
1111 /// Build a new typeof(expr) type.
1112 ///
1113 /// By default, performs semantic analysis when building the typeof type.
1114 /// Subclasses may override this routine to provide different behavior.
1116 TypeOfKind Kind);
1117
1118 /// Build a new typeof(type) type.
1119 ///
1120 /// By default, builds a new TypeOfType with the given underlying type.
1122
1123 /// Build a new unary transform type.
1125 UnaryTransformType::UTTKind UKind,
1126 SourceLocation Loc);
1127
1128 /// Build a new C++11 decltype type.
1129 ///
1130 /// By default, performs semantic analysis when building the decltype type.
1131 /// Subclasses may override this routine to provide different behavior.
1133
1135 SourceLocation Loc,
1136 SourceLocation EllipsisLoc,
1137 bool FullySubstituted,
1138 ArrayRef<QualType> Expansions = {});
1139
1140 /// Build a new C++11 auto type.
1141 ///
1142 /// By default, builds a new AutoType with the given deduced type.
1145 ConceptDecl *TypeConstraintConcept,
1146 ArrayRef<TemplateArgument> TypeConstraintArgs) {
1147 return SemaRef.Context.getAutoType(
1148 DK, DeducedAsType, Keyword, TypeConstraintConcept, TypeConstraintArgs);
1149 }
1150
1151 /// By default, builds a new DeducedTemplateSpecializationType with the given
1152 /// deduced type.
1156 return SemaRef.Context.getDeducedTemplateSpecializationType(
1157 DK, DeducedAsType, Keyword, Template);
1158 }
1159
1160 /// Build a new template specialization type.
1161 ///
1162 /// By default, performs semantic analysis when building the template
1163 /// specialization type. Subclasses may override this routine to provide
1164 /// different behavior.
1167 SourceLocation TemplateLoc,
1169
1170 /// Build a new parenthesized type.
1171 ///
1172 /// By default, builds a new ParenType type from the inner type.
1173 /// Subclasses may override this routine to provide different behavior.
1175 return SemaRef.BuildParenType(InnerType);
1176 }
1177
1178 /// Build a new typename type that refers to an identifier.
1179 ///
1180 /// By default, performs semantic analysis when building the typename type
1181 /// (or elaborated type). Subclasses may override this routine to provide
1182 /// different behavior.
1184 SourceLocation KeywordLoc,
1185 NestedNameSpecifierLoc QualifierLoc,
1186 const IdentifierInfo *Id,
1187 SourceLocation IdLoc,
1188 bool DeducedTSTContext) {
1189 CXXScopeSpec SS;
1190 SS.Adopt(QualifierLoc);
1191
1192 if (QualifierLoc.getNestedNameSpecifier().isDependent()) {
1193 // If the name is still dependent, just build a new dependent name type.
1194 if (!SemaRef.computeDeclContext(SS))
1195 return SemaRef.Context.getDependentNameType(Keyword,
1196 QualifierLoc.getNestedNameSpecifier(),
1197 Id);
1198 }
1199
1202 return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1203 *Id, IdLoc, DeducedTSTContext);
1204 }
1205
1207
1208 // We had a dependent elaborated-type-specifier that has been transformed
1209 // into a non-dependent elaborated-type-specifier. Find the tag we're
1210 // referring to.
1212 DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1213 if (!DC)
1214 return QualType();
1215
1216 if (SemaRef.RequireCompleteDeclContext(SS, DC))
1217 return QualType();
1218
1219 TagDecl *Tag = nullptr;
1220 SemaRef.LookupQualifiedName(Result, DC);
1221 switch (Result.getResultKind()) {
1224 break;
1225
1227 Tag = Result.getAsSingle<TagDecl>();
1228 break;
1229
1232 llvm_unreachable("Tag lookup cannot find non-tags");
1233
1235 // Let the LookupResult structure handle ambiguities.
1236 return QualType();
1237 }
1238
1239 if (!Tag) {
1240 // Check where the name exists but isn't a tag type and use that to emit
1241 // better diagnostics.
1243 SemaRef.LookupQualifiedName(Result, DC);
1244 switch (Result.getResultKind()) {
1248 NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1249 NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1250 SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag)
1251 << SomeDecl << NTK << Kind;
1252 SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1253 break;
1254 }
1255 default:
1256 SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1257 << Kind << Id << DC << QualifierLoc.getSourceRange();
1258 break;
1259 }
1260 return QualType();
1261 }
1262 if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1263 IdLoc, Id)) {
1264 SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1265 SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1266 return QualType();
1267 }
1268 return getDerived().RebuildTagType(
1269 Keyword, QualifierLoc.getNestedNameSpecifier(), Tag);
1270 }
1271
1272 /// Build a new pack expansion type.
1273 ///
1274 /// By default, builds a new PackExpansionType type from the given pattern.
1275 /// Subclasses may override this routine to provide different behavior.
1277 SourceLocation EllipsisLoc,
1278 UnsignedOrNone NumExpansions) {
1279 return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1280 NumExpansions);
1281 }
1282
1283 /// Build a new atomic type given its value type.
1284 ///
1285 /// By default, performs semantic analysis when building the atomic type.
1286 /// Subclasses may override this routine to provide different behavior.
1288
1289 /// Build a new pipe type given its value type.
1291 bool isReadPipe);
1292
1293 /// Build a bit-precise int given its value type.
1294 QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits,
1295 SourceLocation Loc);
1296
1297 /// Build a dependent bit-precise int given its value type.
1298 QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
1299 SourceLocation Loc);
1300
1301 /// Build a new template name given a nested name specifier, a flag
1302 /// indicating whether the "template" keyword was provided, and the template
1303 /// that the template name refers to.
1304 ///
1305 /// By default, builds the new template name directly. Subclasses may override
1306 /// this routine to provide different behavior.
1308 TemplateName Name);
1309
1310 /// Build a new template name given a nested name specifier and the
1311 /// name that is referred to as a template.
1312 ///
1313 /// By default, performs semantic analysis to determine whether the name can
1314 /// be resolved to a specific template, then builds the appropriate kind of
1315 /// template name. Subclasses may override this routine to provide different
1316 /// behavior.
1318 SourceLocation TemplateKWLoc,
1319 const IdentifierInfo &Name,
1320 SourceLocation NameLoc, QualType ObjectType,
1321 bool AllowInjectedClassName);
1322
1323 /// Build a new template name given a nested name specifier and the
1324 /// overloaded operator name that is referred to as a template.
1325 ///
1326 /// By default, performs semantic analysis to determine whether the name can
1327 /// be resolved to a specific template, then builds the appropriate kind of
1328 /// template name. Subclasses may override this routine to provide different
1329 /// behavior.
1331 SourceLocation TemplateKWLoc,
1332 OverloadedOperatorKind Operator,
1333 SourceLocation NameLoc, QualType ObjectType,
1334 bool AllowInjectedClassName);
1335
1337 SourceLocation TemplateKWLoc,
1339 SourceLocation NameLoc, QualType ObjectType,
1340 bool AllowInjectedClassName);
1341
1342 /// Build a new template name given a template template parameter pack
1343 /// and the
1344 ///
1345 /// By default, performs semantic analysis to determine whether the name can
1346 /// be resolved to a specific template, then builds the appropriate kind of
1347 /// template name. Subclasses may override this routine to provide different
1348 /// behavior.
1350 Decl *AssociatedDecl, unsigned Index,
1351 bool Final) {
1353 ArgPack, AssociatedDecl, Index, Final);
1354 }
1355
1356 /// Build a new compound statement.
1357 ///
1358 /// By default, performs semantic analysis to build the new statement.
1359 /// Subclasses may override this routine to provide different behavior.
1361 MultiStmtArg Statements,
1362 SourceLocation RBraceLoc,
1363 bool IsStmtExpr) {
1364 return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1365 IsStmtExpr);
1366 }
1367
1368 /// Build a new case statement.
1369 ///
1370 /// By default, performs semantic analysis to build the new statement.
1371 /// Subclasses may override this routine to provide different behavior.
1373 Expr *LHS,
1374 SourceLocation EllipsisLoc,
1375 Expr *RHS,
1376 SourceLocation ColonLoc) {
1377 return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1378 ColonLoc);
1379 }
1380
1381 /// Attach the body to a new case statement.
1382 ///
1383 /// By default, performs semantic analysis to build the new statement.
1384 /// Subclasses may override this routine to provide different behavior.
1386 getSema().ActOnCaseStmtBody(S, Body);
1387 return S;
1388 }
1389
1390 /// Build a new default statement.
1391 ///
1392 /// By default, performs semantic analysis to build the new statement.
1393 /// Subclasses may override this routine to provide different behavior.
1395 SourceLocation ColonLoc,
1396 Stmt *SubStmt) {
1397 return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1398 /*CurScope=*/nullptr);
1399 }
1400
1401 /// Build a new label statement.
1402 ///
1403 /// By default, performs semantic analysis to build the new statement.
1404 /// Subclasses may override this routine to provide different behavior.
1406 SourceLocation ColonLoc, Stmt *SubStmt) {
1407 return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1408 }
1409
1410 /// Build a new attributed statement.
1411 ///
1412 /// By default, performs semantic analysis to build the new statement.
1413 /// Subclasses may override this routine to provide different behavior.
1416 Stmt *SubStmt) {
1417 if (SemaRef.CheckRebuiltStmtAttributes(Attrs))
1418 return StmtError();
1419 return SemaRef.BuildAttributedStmt(AttrLoc, Attrs, SubStmt);
1420 }
1421
1422 /// Build a new "if" statement.
1423 ///
1424 /// By default, performs semantic analysis to build the new statement.
1425 /// Subclasses may override this routine to provide different behavior.
1428 SourceLocation RParenLoc, Stmt *Init, Stmt *Then,
1429 SourceLocation ElseLoc, Stmt *Else) {
1430 return getSema().ActOnIfStmt(IfLoc, Kind, LParenLoc, Init, Cond, RParenLoc,
1431 Then, ElseLoc, Else);
1432 }
1433
1434 /// Start building a new switch statement.
1435 ///
1436 /// By default, performs semantic analysis to build the new statement.
1437 /// Subclasses may override this routine to provide different behavior.
1439 SourceLocation LParenLoc, Stmt *Init,
1441 SourceLocation RParenLoc) {
1442 return getSema().ActOnStartOfSwitchStmt(SwitchLoc, LParenLoc, Init, Cond,
1443 RParenLoc);
1444 }
1445
1446 /// Attach the body to the switch statement.
1447 ///
1448 /// By default, performs semantic analysis to build the new statement.
1449 /// Subclasses may override this routine to provide different behavior.
1451 Stmt *Switch, Stmt *Body) {
1452 return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1453 }
1454
1455 /// Build a new while statement.
1456 ///
1457 /// By default, performs semantic analysis to build the new statement.
1458 /// Subclasses may override this routine to provide different behavior.
1461 SourceLocation RParenLoc, Stmt *Body) {
1462 return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body);
1463 }
1464
1465 /// Build a new do-while statement.
1466 ///
1467 /// By default, performs semantic analysis to build the new statement.
1468 /// Subclasses may override this routine to provide different behavior.
1470 SourceLocation WhileLoc, SourceLocation LParenLoc,
1471 Expr *Cond, SourceLocation RParenLoc) {
1472 return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1473 Cond, RParenLoc);
1474 }
1475
1476 /// Build a new for statement.
1477 ///
1478 /// By default, performs semantic analysis to build the new statement.
1479 /// Subclasses may override this routine to provide different behavior.
1482 Sema::FullExprArg Inc, SourceLocation RParenLoc,
1483 Stmt *Body) {
1484 return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1485 Inc, RParenLoc, Body);
1486 }
1487
1488 /// Build a new goto statement.
1489 ///
1490 /// By default, performs semantic analysis to build the new statement.
1491 /// Subclasses may override this routine to provide different behavior.
1493 LabelDecl *Label) {
1494 return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1495 }
1496
1497 /// Build a new indirect goto statement.
1498 ///
1499 /// By default, performs semantic analysis to build the new statement.
1500 /// Subclasses may override this routine to provide different behavior.
1502 SourceLocation StarLoc,
1503 Expr *Target) {
1504 return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1505 }
1506
1507 /// Build a new return statement.
1508 ///
1509 /// By default, performs semantic analysis to build the new statement.
1510 /// Subclasses may override this routine to provide different behavior.
1512 return getSema().BuildReturnStmt(ReturnLoc, Result);
1513 }
1514
1515 /// Build a new declaration statement.
1516 ///
1517 /// By default, performs semantic analysis to build the new statement.
1518 /// Subclasses may override this routine to provide different behavior.
1520 SourceLocation StartLoc, SourceLocation EndLoc) {
1522 return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1523 }
1524
1525 /// Build a new inline asm statement.
1526 ///
1527 /// By default, performs semantic analysis to build the new statement.
1528 /// Subclasses may override this routine to provide different behavior.
1530 bool IsVolatile, unsigned NumOutputs,
1531 unsigned NumInputs, IdentifierInfo **Names,
1532 MultiExprArg Constraints, MultiExprArg Exprs,
1533 Expr *AsmString, MultiExprArg Clobbers,
1534 unsigned NumLabels,
1535 SourceLocation RParenLoc) {
1536 return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1537 NumInputs, Names, Constraints, Exprs,
1538 AsmString, Clobbers, NumLabels, RParenLoc);
1539 }
1540
1541 /// Build a new MS style inline asm statement.
1542 ///
1543 /// By default, performs semantic analysis to build the new statement.
1544 /// Subclasses may override this routine to provide different behavior.
1546 ArrayRef<Token> AsmToks,
1547 StringRef AsmString,
1548 unsigned NumOutputs, unsigned NumInputs,
1549 ArrayRef<StringRef> Constraints,
1550 ArrayRef<StringRef> Clobbers,
1551 ArrayRef<Expr*> Exprs,
1552 SourceLocation EndLoc) {
1553 return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1554 NumOutputs, NumInputs,
1555 Constraints, Clobbers, Exprs, EndLoc);
1556 }
1557
1558 /// Build a new co_return statement.
1559 ///
1560 /// By default, performs semantic analysis to build the new statement.
1561 /// Subclasses may override this routine to provide different behavior.
1563 bool IsImplicit) {
1564 return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1565 }
1566
1567 /// Build a new co_await expression.
1568 ///
1569 /// By default, performs semantic analysis to build the new expression.
1570 /// Subclasses may override this routine to provide different behavior.
1572 UnresolvedLookupExpr *OpCoawaitLookup,
1573 bool IsImplicit) {
1574 // This function rebuilds a coawait-expr given its operator.
1575 // For an explicit coawait-expr, the rebuild involves the full set
1576 // of transformations performed by BuildUnresolvedCoawaitExpr(),
1577 // including calling await_transform().
1578 // For an implicit coawait-expr, we need to rebuild the "operator
1579 // coawait" but not await_transform(), so use BuildResolvedCoawaitExpr().
1580 // This mirrors how the implicit CoawaitExpr is originally created
1581 // in Sema::ActOnCoroutineBodyStart().
1582 if (IsImplicit) {
1584 CoawaitLoc, Operand, OpCoawaitLookup);
1585 if (Suspend.isInvalid())
1586 return ExprError();
1587 return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Operand,
1588 Suspend.get(), true);
1589 }
1590
1591 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Operand,
1592 OpCoawaitLookup);
1593 }
1594
1595 /// Build a new co_await expression.
1596 ///
1597 /// By default, performs semantic analysis to build the new expression.
1598 /// Subclasses may override this routine to provide different behavior.
1600 Expr *Result,
1601 UnresolvedLookupExpr *Lookup) {
1602 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1603 }
1604
1605 /// Build a new co_yield expression.
1606 ///
1607 /// By default, performs semantic analysis to build the new expression.
1608 /// Subclasses may override this routine to provide different behavior.
1610 return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1611 }
1612
1616
1617 /// Build a new Objective-C \@try statement.
1618 ///
1619 /// By default, performs semantic analysis to build the new statement.
1620 /// Subclasses may override this routine to provide different behavior.
1622 Stmt *TryBody,
1623 MultiStmtArg CatchStmts,
1624 Stmt *Finally) {
1625 return getSema().ObjC().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1626 Finally);
1627 }
1628
1629 /// Rebuild an Objective-C exception declaration.
1630 ///
1631 /// By default, performs semantic analysis to build the new declaration.
1632 /// Subclasses may override this routine to provide different behavior.
1634 TypeSourceInfo *TInfo, QualType T) {
1636 TInfo, T, ExceptionDecl->getInnerLocStart(),
1637 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
1638 }
1639
1640 /// Build a new Objective-C \@catch statement.
1641 ///
1642 /// By default, performs semantic analysis to build the new statement.
1643 /// Subclasses may override this routine to provide different behavior.
1645 SourceLocation RParenLoc,
1646 VarDecl *Var,
1647 Stmt *Body) {
1648 return getSema().ObjC().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, Var, Body);
1649 }
1650
1651 /// Build a new Objective-C \@finally statement.
1652 ///
1653 /// By default, performs semantic analysis to build the new statement.
1654 /// Subclasses may override this routine to provide different behavior.
1656 Stmt *Body) {
1657 return getSema().ObjC().ActOnObjCAtFinallyStmt(AtLoc, Body);
1658 }
1659
1660 /// Build a new Objective-C \@throw statement.
1661 ///
1662 /// By default, performs semantic analysis to build the new statement.
1663 /// Subclasses may override this routine to provide different behavior.
1665 Expr *Operand) {
1666 return getSema().ObjC().BuildObjCAtThrowStmt(AtLoc, Operand);
1667 }
1668
1669 /// Build a new OpenMP Canonical loop.
1670 ///
1671 /// Ensures that the outermost loop in @p LoopStmt is wrapped by a
1672 /// OMPCanonicalLoop.
1674 return getSema().OpenMP().ActOnOpenMPCanonicalLoop(LoopStmt);
1675 }
1676
1677 /// Build a new OpenMP executable directive.
1678 ///
1679 /// By default, performs semantic analysis to build the new statement.
1680 /// Subclasses may override this routine to provide different behavior.
1682 DeclarationNameInfo DirName,
1683 OpenMPDirectiveKind CancelRegion,
1684 ArrayRef<OMPClause *> Clauses,
1685 Stmt *AStmt, SourceLocation StartLoc,
1686 SourceLocation EndLoc) {
1687
1689 Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1690 }
1691
1692 /// Build a new OpenMP informational directive.
1694 DeclarationNameInfo DirName,
1695 ArrayRef<OMPClause *> Clauses,
1696 Stmt *AStmt,
1697 SourceLocation StartLoc,
1698 SourceLocation EndLoc) {
1699
1701 Kind, DirName, Clauses, AStmt, StartLoc, EndLoc);
1702 }
1703
1704 /// Build a new OpenMP 'if' clause.
1705 ///
1706 /// By default, performs semantic analysis to build the new OpenMP clause.
1707 /// Subclasses may override this routine to provide different behavior.
1709 Expr *Condition, SourceLocation StartLoc,
1710 SourceLocation LParenLoc,
1711 SourceLocation NameModifierLoc,
1712 SourceLocation ColonLoc,
1713 SourceLocation EndLoc) {
1715 NameModifier, Condition, StartLoc, LParenLoc, NameModifierLoc, ColonLoc,
1716 EndLoc);
1717 }
1718
1719 /// Build a new OpenMP 'final' clause.
1720 ///
1721 /// By default, performs semantic analysis to build the new OpenMP clause.
1722 /// Subclasses may override this routine to provide different behavior.
1724 SourceLocation LParenLoc,
1725 SourceLocation EndLoc) {
1726 return getSema().OpenMP().ActOnOpenMPFinalClause(Condition, StartLoc,
1727 LParenLoc, EndLoc);
1728 }
1729
1730 /// Build a new OpenMP 'num_threads' clause.
1731 ///
1732 /// By default, performs semantic analysis to build the new OpenMP clause.
1733 /// Subclasses may override this routine to provide different behavior.
1735 Expr *NumThreads,
1736 SourceLocation StartLoc,
1737 SourceLocation LParenLoc,
1738 SourceLocation ModifierLoc,
1739 SourceLocation EndLoc) {
1741 Modifier, NumThreads, StartLoc, LParenLoc, ModifierLoc, EndLoc);
1742 }
1743
1744 /// Build a new OpenMP 'safelen' clause.
1745 ///
1746 /// By default, performs semantic analysis to build the new OpenMP clause.
1747 /// Subclasses may override this routine to provide different behavior.
1749 SourceLocation LParenLoc,
1750 SourceLocation EndLoc) {
1751 return getSema().OpenMP().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc,
1752 EndLoc);
1753 }
1754
1755 /// Build a new OpenMP 'simdlen' clause.
1756 ///
1757 /// By default, performs semantic analysis to build the new OpenMP clause.
1758 /// Subclasses may override this routine to provide different behavior.
1760 SourceLocation LParenLoc,
1761 SourceLocation EndLoc) {
1762 return getSema().OpenMP().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc,
1763 EndLoc);
1764 }
1765
1767 SourceLocation StartLoc,
1768 SourceLocation LParenLoc,
1769 SourceLocation EndLoc) {
1770 return getSema().OpenMP().ActOnOpenMPSizesClause(Sizes, StartLoc, LParenLoc,
1771 EndLoc);
1772 }
1773
1775 SourceLocation StartLoc,
1776 SourceLocation LParenLoc,
1777 SourceLocation EndLoc,
1778 std::optional<unsigned> FillIdx,
1779 SourceLocation FillLoc) {
1780 unsigned FillCount = FillIdx ? 1 : 0;
1782 Counts, StartLoc, LParenLoc, EndLoc, FillIdx, FillLoc, FillCount);
1783 }
1784
1785 /// Build a new OpenMP 'permutation' clause.
1787 SourceLocation StartLoc,
1788 SourceLocation LParenLoc,
1789 SourceLocation EndLoc) {
1790 return getSema().OpenMP().ActOnOpenMPPermutationClause(PermExprs, StartLoc,
1791 LParenLoc, EndLoc);
1792 }
1793
1794 /// Build a new OpenMP 'full' clause.
1796 SourceLocation EndLoc) {
1797 return getSema().OpenMP().ActOnOpenMPFullClause(StartLoc, EndLoc);
1798 }
1799
1800 /// Build a new OpenMP 'partial' clause.
1802 SourceLocation LParenLoc,
1803 SourceLocation EndLoc) {
1804 return getSema().OpenMP().ActOnOpenMPPartialClause(Factor, StartLoc,
1805 LParenLoc, EndLoc);
1806 }
1807
1808 OMPClause *
1810 SourceLocation LParenLoc, SourceLocation FirstLoc,
1811 SourceLocation CountLoc, SourceLocation EndLoc) {
1813 First, Count, StartLoc, LParenLoc, FirstLoc, CountLoc, EndLoc);
1814 }
1815
1816 /// Build a new OpenMP 'allocator' clause.
1817 ///
1818 /// By default, performs semantic analysis to build the new OpenMP clause.
1819 /// Subclasses may override this routine to provide different behavior.
1821 SourceLocation LParenLoc,
1822 SourceLocation EndLoc) {
1823 return getSema().OpenMP().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc,
1824 EndLoc);
1825 }
1826
1827 /// Build a new OpenMP 'collapse' clause.
1828 ///
1829 /// By default, performs semantic analysis to build the new OpenMP clause.
1830 /// Subclasses may override this routine to provide different behavior.
1832 SourceLocation LParenLoc,
1833 SourceLocation EndLoc) {
1834 return getSema().OpenMP().ActOnOpenMPCollapseClause(Num, StartLoc,
1835 LParenLoc, EndLoc);
1836 }
1837
1838 /// Build a new OpenMP 'default' clause.
1839 ///
1840 /// By default, performs semantic analysis to build the new OpenMP clause.
1841 /// Subclasses may override this routine to provide different behavior.
1844 SourceLocation VCLoc,
1845 SourceLocation StartLoc,
1846 SourceLocation LParenLoc,
1847 SourceLocation EndLoc) {
1849 Kind, KindKwLoc, VCKind, VCLoc, StartLoc, LParenLoc, EndLoc);
1850 }
1851
1852 /// Build a new OpenMP 'proc_bind' clause.
1853 ///
1854 /// By default, performs semantic analysis to build the new OpenMP clause.
1855 /// Subclasses may override this routine to provide different behavior.
1857 SourceLocation KindKwLoc,
1858 SourceLocation StartLoc,
1859 SourceLocation LParenLoc,
1860 SourceLocation EndLoc) {
1862 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1863 }
1865 SourceLocation StartLoc,
1866 SourceLocation LParenLoc,
1867 SourceLocation EndLoc) {
1869 ImpexTypeArg, StartLoc, LParenLoc, EndLoc);
1870 }
1871
1872 /// Build a new OpenMP 'schedule' clause.
1873 ///
1874 /// By default, performs semantic analysis to build the new OpenMP clause.
1875 /// Subclasses may override this routine to provide different behavior.
1878 OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1879 SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1880 SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1882 M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1883 CommaLoc, EndLoc);
1884 }
1885
1886 /// Build a new OpenMP 'ordered' clause.
1887 ///
1888 /// By default, performs semantic analysis to build the new OpenMP clause.
1889 /// Subclasses may override this routine to provide different behavior.
1891 SourceLocation EndLoc,
1892 SourceLocation LParenLoc, Expr *Num) {
1893 return getSema().OpenMP().ActOnOpenMPOrderedClause(StartLoc, EndLoc,
1894 LParenLoc, Num);
1895 }
1896
1897 /// Build a new OpenMP 'nowait' 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 LParenLoc,
1903 SourceLocation EndLoc) {
1904 return getSema().OpenMP().ActOnOpenMPNowaitClause(StartLoc, EndLoc,
1905 LParenLoc, Condition);
1906 }
1907
1908 /// Build a new OpenMP 'private' clause.
1909 ///
1910 /// By default, performs semantic analysis to build the new OpenMP clause.
1911 /// Subclasses may override this routine to provide different behavior.
1913 SourceLocation StartLoc,
1914 SourceLocation LParenLoc,
1915 SourceLocation EndLoc) {
1916 return getSema().OpenMP().ActOnOpenMPPrivateClause(VarList, StartLoc,
1917 LParenLoc, EndLoc);
1918 }
1919
1920 /// Build a new OpenMP 'firstprivate' clause.
1921 ///
1922 /// By default, performs semantic analysis to build the new OpenMP clause.
1923 /// Subclasses may override this routine to provide different behavior.
1925 SourceLocation StartLoc,
1926 SourceLocation LParenLoc,
1927 SourceLocation EndLoc) {
1928 return getSema().OpenMP().ActOnOpenMPFirstprivateClause(VarList, StartLoc,
1929 LParenLoc, EndLoc);
1930 }
1931
1932 /// Build a new OpenMP 'lastprivate' clause.
1933 ///
1934 /// By default, performs semantic analysis to build the new OpenMP clause.
1935 /// Subclasses may override this routine to provide different behavior.
1938 SourceLocation LPKindLoc,
1939 SourceLocation ColonLoc,
1940 SourceLocation StartLoc,
1941 SourceLocation LParenLoc,
1942 SourceLocation EndLoc) {
1944 VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1945 }
1946
1947 /// Build a new OpenMP 'shared' clause.
1948 ///
1949 /// By default, performs semantic analysis to build the new OpenMP clause.
1950 /// Subclasses may override this routine to provide different behavior.
1952 SourceLocation StartLoc,
1953 SourceLocation LParenLoc,
1954 SourceLocation EndLoc) {
1955 return getSema().OpenMP().ActOnOpenMPSharedClause(VarList, StartLoc,
1956 LParenLoc, EndLoc);
1957 }
1958
1959 /// Build a new OpenMP 'reduction' clause.
1960 ///
1961 /// By default, performs semantic analysis to build the new statement.
1962 /// Subclasses may override this routine to provide different behavior.
1965 OpenMPOriginalSharingModifier OriginalSharingModifier,
1966 SourceLocation StartLoc, SourceLocation LParenLoc,
1967 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1968 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
1969 const DeclarationNameInfo &ReductionId,
1970 ArrayRef<Expr *> UnresolvedReductions) {
1972 VarList, {Modifier, OriginalSharingModifier}, StartLoc, LParenLoc,
1973 ModifierLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, ReductionId,
1974 UnresolvedReductions);
1975 }
1976
1977 /// Build a new OpenMP 'task_reduction' clause.
1978 ///
1979 /// By default, performs semantic analysis to build the new statement.
1980 /// Subclasses may override this routine to provide different behavior.
1982 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1983 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
1984 CXXScopeSpec &ReductionIdScopeSpec,
1985 const DeclarationNameInfo &ReductionId,
1986 ArrayRef<Expr *> UnresolvedReductions) {
1988 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1989 ReductionId, UnresolvedReductions);
1990 }
1991
1992 /// Build a new OpenMP 'in_reduction' clause.
1993 ///
1994 /// By default, performs semantic analysis to build the new statement.
1995 /// Subclasses may override this routine to provide different behavior.
1996 OMPClause *
1998 SourceLocation LParenLoc, SourceLocation ColonLoc,
1999 SourceLocation EndLoc,
2000 CXXScopeSpec &ReductionIdScopeSpec,
2001 const DeclarationNameInfo &ReductionId,
2002 ArrayRef<Expr *> UnresolvedReductions) {
2004 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
2005 ReductionId, UnresolvedReductions);
2006 }
2007
2008 /// Build a new OpenMP 'linear' clause.
2009 ///
2010 /// By default, performs semantic analysis to build the new OpenMP clause.
2011 /// Subclasses may override this routine to provide different behavior.
2013 ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc,
2014 SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier,
2015 SourceLocation ModifierLoc, SourceLocation ColonLoc,
2016 SourceLocation StepModifierLoc, SourceLocation EndLoc) {
2018 VarList, Step, StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc,
2019 StepModifierLoc, EndLoc);
2020 }
2021
2022 /// Build a new OpenMP 'aligned' clause.
2023 ///
2024 /// By default, performs semantic analysis to build the new OpenMP clause.
2025 /// Subclasses may override this routine to provide different behavior.
2027 SourceLocation StartLoc,
2028 SourceLocation LParenLoc,
2029 SourceLocation ColonLoc,
2030 SourceLocation EndLoc) {
2032 VarList, Alignment, StartLoc, LParenLoc, ColonLoc, EndLoc);
2033 }
2034
2035 /// Build a new OpenMP 'copyin' clause.
2036 ///
2037 /// By default, performs semantic analysis to build the new OpenMP clause.
2038 /// Subclasses may override this routine to provide different behavior.
2040 SourceLocation StartLoc,
2041 SourceLocation LParenLoc,
2042 SourceLocation EndLoc) {
2043 return getSema().OpenMP().ActOnOpenMPCopyinClause(VarList, StartLoc,
2044 LParenLoc, EndLoc);
2045 }
2046
2047 /// Build a new OpenMP 'copyprivate' clause.
2048 ///
2049 /// By default, performs semantic analysis to build the new OpenMP clause.
2050 /// Subclasses may override this routine to provide different behavior.
2052 SourceLocation StartLoc,
2053 SourceLocation LParenLoc,
2054 SourceLocation EndLoc) {
2055 return getSema().OpenMP().ActOnOpenMPCopyprivateClause(VarList, StartLoc,
2056 LParenLoc, EndLoc);
2057 }
2058
2059 /// Build a new OpenMP 'flush' 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 SourceLocation StartLoc,
2065 SourceLocation LParenLoc,
2066 SourceLocation EndLoc) {
2067 return getSema().OpenMP().ActOnOpenMPFlushClause(VarList, StartLoc,
2068 LParenLoc, EndLoc);
2069 }
2070
2071 /// Build a new OpenMP 'depobj' pseudo clause.
2072 ///
2073 /// By default, performs semantic analysis to build the new OpenMP clause.
2074 /// Subclasses may override this routine to provide different behavior.
2076 SourceLocation LParenLoc,
2077 SourceLocation EndLoc) {
2078 return getSema().OpenMP().ActOnOpenMPDepobjClause(Depobj, StartLoc,
2079 LParenLoc, EndLoc);
2080 }
2081
2082 /// Build a new OpenMP 'depend' pseudo clause.
2083 ///
2084 /// By default, performs semantic analysis to build the new OpenMP clause.
2085 /// Subclasses may override this routine to provide different behavior.
2087 Expr *DepModifier, ArrayRef<Expr *> VarList,
2088 SourceLocation StartLoc,
2089 SourceLocation LParenLoc,
2090 SourceLocation EndLoc) {
2092 Data, DepModifier, VarList, StartLoc, LParenLoc, EndLoc);
2093 }
2094
2095 /// Build a new OpenMP 'device' clause.
2096 ///
2097 /// By default, performs semantic analysis to build the new statement.
2098 /// Subclasses may override this routine to provide different behavior.
2100 Expr *Device, SourceLocation StartLoc,
2101 SourceLocation LParenLoc,
2102 SourceLocation ModifierLoc,
2103 SourceLocation EndLoc) {
2105 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2106 }
2107
2108 /// Build a new OpenMP 'map' clause.
2109 ///
2110 /// By default, performs semantic analysis to build the new OpenMP clause.
2111 /// Subclasses may override this routine to provide different behavior.
2113 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
2114 ArrayRef<SourceLocation> MapTypeModifiersLoc,
2115 CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId,
2116 OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
2117 SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
2118 const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) {
2120 IteratorModifier, MapTypeModifiers, MapTypeModifiersLoc,
2121 MapperIdScopeSpec, MapperId, MapType, IsMapTypeImplicit, MapLoc,
2122 ColonLoc, VarList, Locs,
2123 /*NoDiagnose=*/false, UnresolvedMappers);
2124 }
2125
2126 /// Build a new OpenMP 'allocate' clause.
2127 ///
2128 /// By default, performs semantic analysis to build the new OpenMP clause.
2129 /// Subclasses may override this routine to provide different behavior.
2130 OMPClause *
2131 RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment,
2132 OpenMPAllocateClauseModifier FirstModifier,
2133 SourceLocation FirstModifierLoc,
2134 OpenMPAllocateClauseModifier SecondModifier,
2135 SourceLocation SecondModifierLoc,
2136 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2137 SourceLocation LParenLoc, SourceLocation ColonLoc,
2138 SourceLocation EndLoc) {
2140 Allocate, Alignment, FirstModifier, FirstModifierLoc, SecondModifier,
2141 SecondModifierLoc, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc);
2142 }
2143
2144 /// Build a new OpenMP 'num_teams' clause.
2145 ///
2146 /// By default, performs semantic analysis to build the new statement.
2147 /// Subclasses may override this routine to provide different behavior.
2149 SourceLocation StartLoc,
2150 SourceLocation LParenLoc,
2151 SourceLocation EndLoc) {
2152 return getSema().OpenMP().ActOnOpenMPNumTeamsClause(VarList, StartLoc,
2153 LParenLoc, EndLoc);
2154 }
2155
2156 /// Build a new OpenMP 'thread_limit' clause.
2157 ///
2158 /// By default, performs semantic analysis to build the new statement.
2159 /// Subclasses may override this routine to provide different behavior.
2161 SourceLocation StartLoc,
2162 SourceLocation LParenLoc,
2163 SourceLocation EndLoc) {
2164 return getSema().OpenMP().ActOnOpenMPThreadLimitClause(VarList, StartLoc,
2165 LParenLoc, EndLoc);
2166 }
2167
2168 /// Build a new OpenMP 'priority' clause.
2169 ///
2170 /// By default, performs semantic analysis to build the new statement.
2171 /// Subclasses may override this routine to provide different behavior.
2173 SourceLocation LParenLoc,
2174 SourceLocation EndLoc) {
2175 return getSema().OpenMP().ActOnOpenMPPriorityClause(Priority, StartLoc,
2176 LParenLoc, EndLoc);
2177 }
2178
2179 /// Build a new OpenMP 'grainsize' clause.
2180 ///
2181 /// By default, performs semantic analysis to build the new statement.
2182 /// Subclasses may override this routine to provide different behavior.
2184 Expr *Device, SourceLocation StartLoc,
2185 SourceLocation LParenLoc,
2186 SourceLocation ModifierLoc,
2187 SourceLocation EndLoc) {
2189 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2190 }
2191
2192 /// Build a new OpenMP 'num_tasks' clause.
2193 ///
2194 /// By default, performs semantic analysis to build the new statement.
2195 /// Subclasses may override this routine to provide different behavior.
2197 Expr *NumTasks, SourceLocation StartLoc,
2198 SourceLocation LParenLoc,
2199 SourceLocation ModifierLoc,
2200 SourceLocation EndLoc) {
2202 Modifier, NumTasks, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2203 }
2204
2205 /// Build a new OpenMP 'hint' clause.
2206 ///
2207 /// By default, performs semantic analysis to build the new statement.
2208 /// Subclasses may override this routine to provide different behavior.
2210 SourceLocation LParenLoc,
2211 SourceLocation EndLoc) {
2212 return getSema().OpenMP().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc,
2213 EndLoc);
2214 }
2215
2216 /// Build a new OpenMP 'detach' clause.
2217 ///
2218 /// By default, performs semantic analysis to build the new statement.
2219 /// Subclasses may override this routine to provide different behavior.
2221 SourceLocation LParenLoc,
2222 SourceLocation EndLoc) {
2223 return getSema().OpenMP().ActOnOpenMPDetachClause(Evt, StartLoc, LParenLoc,
2224 EndLoc);
2225 }
2226
2227 /// Build a new OpenMP 'dist_schedule' clause.
2228 ///
2229 /// By default, performs semantic analysis to build the new OpenMP clause.
2230 /// Subclasses may override this routine to provide different behavior.
2231 OMPClause *
2233 Expr *ChunkSize, SourceLocation StartLoc,
2234 SourceLocation LParenLoc, SourceLocation KindLoc,
2235 SourceLocation CommaLoc, SourceLocation EndLoc) {
2237 Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
2238 }
2239
2240 /// Build a new OpenMP 'to' clause.
2241 ///
2242 /// By default, performs semantic analysis to build the new statement.
2243 /// Subclasses may override this routine to provide different behavior.
2244 OMPClause *
2246 ArrayRef<SourceLocation> MotionModifiersLoc,
2247 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2248 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2249 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2250 ArrayRef<Expr *> UnresolvedMappers) {
2252 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2253 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2254 UnresolvedMappers);
2255 }
2256
2257 /// Build a new OpenMP 'from' clause.
2258 ///
2259 /// By default, performs semantic analysis to build the new statement.
2260 /// Subclasses may override this routine to provide different behavior.
2261 OMPClause *
2263 ArrayRef<SourceLocation> MotionModifiersLoc,
2264 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2265 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2266 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2267 ArrayRef<Expr *> UnresolvedMappers) {
2269 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2270 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2271 UnresolvedMappers);
2272 }
2273
2274 /// Build a new OpenMP 'use_device_ptr' clause.
2275 ///
2276 /// By default, performs semantic analysis to build the new OpenMP clause.
2277 /// Subclasses may override this routine to provide different behavior.
2279 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2280 OpenMPUseDevicePtrFallbackModifier FallbackModifier,
2281 SourceLocation FallbackModifierLoc) {
2283 VarList, Locs, FallbackModifier, FallbackModifierLoc);
2284 }
2285
2286 /// Build a new OpenMP 'use_device_addr' clause.
2287 ///
2288 /// By default, performs semantic analysis to build the new OpenMP clause.
2289 /// Subclasses may override this routine to provide different behavior.
2294
2295 /// Build a new OpenMP 'is_device_ptr' clause.
2296 ///
2297 /// By default, performs semantic analysis to build the new OpenMP clause.
2298 /// Subclasses may override this routine to provide different behavior.
2300 const OMPVarListLocTy &Locs) {
2301 return getSema().OpenMP().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
2302 }
2303
2304 /// Build a new OpenMP 'has_device_addr' clause.
2305 ///
2306 /// By default, performs semantic analysis to build the new OpenMP clause.
2307 /// Subclasses may override this routine to provide different behavior.
2312
2313 /// Build a new OpenMP 'defaultmap' clause.
2314 ///
2315 /// By default, performs semantic analysis to build the new OpenMP clause.
2316 /// Subclasses may override this routine to provide different behavior.
2319 SourceLocation StartLoc,
2320 SourceLocation LParenLoc,
2321 SourceLocation MLoc,
2322 SourceLocation KindLoc,
2323 SourceLocation EndLoc) {
2325 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2326 }
2327
2328 /// Build a new OpenMP 'nontemporal' clause.
2329 ///
2330 /// By default, performs semantic analysis to build the new OpenMP clause.
2331 /// Subclasses may override this routine to provide different behavior.
2333 SourceLocation StartLoc,
2334 SourceLocation LParenLoc,
2335 SourceLocation EndLoc) {
2336 return getSema().OpenMP().ActOnOpenMPNontemporalClause(VarList, StartLoc,
2337 LParenLoc, EndLoc);
2338 }
2339
2340 /// Build a new OpenMP 'inclusive' clause.
2341 ///
2342 /// By default, performs semantic analysis to build the new OpenMP clause.
2343 /// Subclasses may override this routine to provide different behavior.
2345 SourceLocation StartLoc,
2346 SourceLocation LParenLoc,
2347 SourceLocation EndLoc) {
2348 return getSema().OpenMP().ActOnOpenMPInclusiveClause(VarList, StartLoc,
2349 LParenLoc, EndLoc);
2350 }
2351
2352 /// Build a new OpenMP 'exclusive' clause.
2353 ///
2354 /// By default, performs semantic analysis to build the new OpenMP clause.
2355 /// Subclasses may override this routine to provide different behavior.
2357 SourceLocation StartLoc,
2358 SourceLocation LParenLoc,
2359 SourceLocation EndLoc) {
2360 return getSema().OpenMP().ActOnOpenMPExclusiveClause(VarList, StartLoc,
2361 LParenLoc, EndLoc);
2362 }
2363
2364 /// Build a new OpenMP 'uses_allocators' clause.
2365 ///
2366 /// By default, performs semantic analysis to build the new OpenMP clause.
2367 /// Subclasses may override this routine to provide different behavior.
2374
2375 /// Build a new OpenMP 'affinity' clause.
2376 ///
2377 /// By default, performs semantic analysis to build the new OpenMP clause.
2378 /// Subclasses may override this routine to provide different behavior.
2380 SourceLocation LParenLoc,
2381 SourceLocation ColonLoc,
2382 SourceLocation EndLoc, Expr *Modifier,
2383 ArrayRef<Expr *> Locators) {
2385 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2386 }
2387
2388 /// Build a new OpenMP 'order' clause.
2389 ///
2390 /// By default, performs semantic analysis to build the new OpenMP clause.
2391 /// Subclasses may override this routine to provide different behavior.
2393 OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc,
2394 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
2395 OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc) {
2397 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2398 }
2399
2400 /// Build a new OpenMP 'init' clause.
2401 ///
2402 /// By default, performs semantic analysis to build the new OpenMP clause.
2403 /// Subclasses may override this routine to provide different behavior.
2405 SourceLocation StartLoc,
2406 SourceLocation LParenLoc,
2407 SourceLocation VarLoc,
2408 SourceLocation EndLoc) {
2410 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2411 }
2412
2413 /// Build a new OpenMP 'use' clause.
2414 ///
2415 /// By default, performs semantic analysis to build the new OpenMP clause.
2416 /// Subclasses may override this routine to provide different behavior.
2418 SourceLocation LParenLoc,
2419 SourceLocation VarLoc, SourceLocation EndLoc) {
2420 return getSema().OpenMP().ActOnOpenMPUseClause(InteropVar, StartLoc,
2421 LParenLoc, VarLoc, EndLoc);
2422 }
2423
2424 /// Build a new OpenMP 'destroy' clause.
2425 ///
2426 /// By default, performs semantic analysis to build the new OpenMP clause.
2427 /// Subclasses may override this routine to provide different behavior.
2429 SourceLocation LParenLoc,
2430 SourceLocation VarLoc,
2431 SourceLocation EndLoc) {
2433 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2434 }
2435
2436 /// Build a new OpenMP 'novariants' clause.
2437 ///
2438 /// By default, performs semantic analysis to build the new OpenMP clause.
2439 /// Subclasses may override this routine to provide different behavior.
2441 SourceLocation StartLoc,
2442 SourceLocation LParenLoc,
2443 SourceLocation EndLoc) {
2445 LParenLoc, EndLoc);
2446 }
2447
2448 /// Build a new OpenMP 'nocontext' clause.
2449 ///
2450 /// By default, performs semantic analysis to build the new OpenMP clause.
2451 /// Subclasses may override this routine to provide different behavior.
2453 SourceLocation LParenLoc,
2454 SourceLocation EndLoc) {
2456 LParenLoc, EndLoc);
2457 }
2458
2459 /// Build a new OpenMP 'filter' clause.
2460 ///
2461 /// By default, performs semantic analysis to build the new OpenMP clause.
2462 /// Subclasses may override this routine to provide different behavior.
2464 SourceLocation LParenLoc,
2465 SourceLocation EndLoc) {
2466 return getSema().OpenMP().ActOnOpenMPFilterClause(ThreadID, StartLoc,
2467 LParenLoc, EndLoc);
2468 }
2469
2470 /// Build a new OpenMP 'bind' clause.
2471 ///
2472 /// By default, performs semantic analysis to build the new OpenMP clause.
2473 /// Subclasses may override this routine to provide different behavior.
2475 SourceLocation KindLoc,
2476 SourceLocation StartLoc,
2477 SourceLocation LParenLoc,
2478 SourceLocation EndLoc) {
2479 return getSema().OpenMP().ActOnOpenMPBindClause(Kind, KindLoc, StartLoc,
2480 LParenLoc, EndLoc);
2481 }
2482
2483 /// Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
2484 ///
2485 /// By default, performs semantic analysis to build the new OpenMP clause.
2486 /// Subclasses may override this routine to provide different behavior.
2488 SourceLocation LParenLoc,
2489 SourceLocation EndLoc) {
2490 return getSema().OpenMP().ActOnOpenMPXDynCGroupMemClause(Size, StartLoc,
2491 LParenLoc, EndLoc);
2492 }
2493
2494 /// Build a new OpenMP 'dyn_groupprivate' clause.
2495 ///
2496 /// By default, performs semantic analysis to build the new OpenMP clause.
2497 /// Subclasses may override this routine to provide different behavior.
2501 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc,
2502 SourceLocation M2Loc, SourceLocation EndLoc) {
2504 M1, M2, Size, StartLoc, LParenLoc, M1Loc, M2Loc, EndLoc);
2505 }
2506
2507 /// Build a new OpenMP 'ompx_attribute' clause.
2508 ///
2509 /// By default, performs semantic analysis to build the new OpenMP clause.
2510 /// Subclasses may override this routine to provide different behavior.
2512 SourceLocation StartLoc,
2513 SourceLocation LParenLoc,
2514 SourceLocation EndLoc) {
2515 return getSema().OpenMP().ActOnOpenMPXAttributeClause(Attrs, StartLoc,
2516 LParenLoc, EndLoc);
2517 }
2518
2519 /// Build a new OpenMP 'ompx_bare' clause.
2520 ///
2521 /// By default, performs semantic analysis to build the new OpenMP clause.
2522 /// Subclasses may override this routine to provide different behavior.
2524 SourceLocation EndLoc) {
2525 return getSema().OpenMP().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2526 }
2527
2528 /// Build a new OpenMP 'align' clause.
2529 ///
2530 /// By default, performs semantic analysis to build the new OpenMP clause.
2531 /// Subclasses may override this routine to provide different behavior.
2533 SourceLocation LParenLoc,
2534 SourceLocation EndLoc) {
2535 return getSema().OpenMP().ActOnOpenMPAlignClause(A, StartLoc, LParenLoc,
2536 EndLoc);
2537 }
2538
2539 /// Build a new OpenMP 'at' clause.
2540 ///
2541 /// By default, performs semantic analysis to build the new OpenMP clause.
2542 /// Subclasses may override this routine to provide different behavior.
2544 SourceLocation StartLoc,
2545 SourceLocation LParenLoc,
2546 SourceLocation EndLoc) {
2547 return getSema().OpenMP().ActOnOpenMPAtClause(Kind, KwLoc, StartLoc,
2548 LParenLoc, EndLoc);
2549 }
2550
2551 /// Build a new OpenMP 'severity' clause.
2552 ///
2553 /// By default, performs semantic analysis to build the new OpenMP clause.
2554 /// Subclasses may override this routine to provide different behavior.
2556 SourceLocation KwLoc,
2557 SourceLocation StartLoc,
2558 SourceLocation LParenLoc,
2559 SourceLocation EndLoc) {
2560 return getSema().OpenMP().ActOnOpenMPSeverityClause(Kind, KwLoc, StartLoc,
2561 LParenLoc, EndLoc);
2562 }
2563
2564 /// Build a new OpenMP 'message' clause.
2565 ///
2566 /// By default, performs semantic analysis to build the new OpenMP clause.
2567 /// Subclasses may override this routine to provide different behavior.
2569 SourceLocation LParenLoc,
2570 SourceLocation EndLoc) {
2571 return getSema().OpenMP().ActOnOpenMPMessageClause(MS, StartLoc, LParenLoc,
2572 EndLoc);
2573 }
2574
2575 /// Build a new OpenMP 'doacross' clause.
2576 ///
2577 /// By default, performs semantic analysis to build the new OpenMP clause.
2578 /// Subclasses may override this routine to provide different behavior.
2579 OMPClause *
2581 SourceLocation DepLoc, SourceLocation ColonLoc,
2582 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2583 SourceLocation LParenLoc, SourceLocation EndLoc) {
2585 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2586 }
2587
2588 /// Build a new OpenMP 'holds' clause.
2590 SourceLocation LParenLoc,
2591 SourceLocation EndLoc) {
2592 return getSema().OpenMP().ActOnOpenMPHoldsClause(A, StartLoc, LParenLoc,
2593 EndLoc);
2594 }
2595
2596 /// Rebuild the operand to an Objective-C \@synchronized statement.
2597 ///
2598 /// By default, performs semantic analysis to build the new statement.
2599 /// Subclasses may override this routine to provide different behavior.
2604
2605 /// Build a new Objective-C \@synchronized statement.
2606 ///
2607 /// By default, performs semantic analysis to build the new statement.
2608 /// Subclasses may override this routine to provide different behavior.
2613
2614 /// Build a new Objective-C \@autoreleasepool statement.
2615 ///
2616 /// By default, performs semantic analysis to build the new statement.
2617 /// Subclasses may override this routine to provide different behavior.
2622
2623 /// Build a new Objective-C fast enumeration statement.
2624 ///
2625 /// By default, performs semantic analysis to build the new statement.
2626 /// Subclasses may override this routine to provide different behavior.
2628 Stmt *Element,
2629 Expr *Collection,
2630 SourceLocation RParenLoc,
2631 Stmt *Body) {
2633 ForLoc, Element, Collection, RParenLoc);
2634 if (ForEachStmt.isInvalid())
2635 return StmtError();
2636
2637 return getSema().ObjC().FinishObjCForCollectionStmt(ForEachStmt.get(),
2638 Body);
2639 }
2640
2641 /// Build a new C++ exception declaration.
2642 ///
2643 /// By default, performs semantic analysis to build the new decaration.
2644 /// Subclasses may override this routine to provide different behavior.
2647 SourceLocation StartLoc,
2648 SourceLocation IdLoc,
2649 IdentifierInfo *Id) {
2651 StartLoc, IdLoc, Id);
2652 if (Var)
2653 getSema().CurContext->addDecl(Var);
2654 return Var;
2655 }
2656
2657 /// Build a new C++ catch statement.
2658 ///
2659 /// By default, performs semantic analysis to build the new statement.
2660 /// Subclasses may override this routine to provide different behavior.
2662 VarDecl *ExceptionDecl,
2663 Stmt *Handler) {
2664 return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2665 Handler));
2666 }
2667
2668 /// Build a new C++ try statement.
2669 ///
2670 /// By default, performs semantic analysis to build the new statement.
2671 /// Subclasses may override this routine to provide different behavior.
2673 ArrayRef<Stmt *> Handlers) {
2674 return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2675 }
2676
2677 /// Build a new C++0x range-based for statement.
2678 ///
2679 /// By default, performs semantic analysis to build the new statement.
2680 /// Subclasses may override this routine to provide different behavior.
2682 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init,
2683 SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond,
2684 Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc,
2685 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
2686 // If we've just learned that the range is actually an Objective-C
2687 // collection, treat this as an Objective-C fast enumeration loop.
2688 if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2689 if (RangeStmt->isSingleDecl()) {
2690 if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2691 if (RangeVar->isInvalidDecl())
2692 return StmtError();
2693
2694 Expr *RangeExpr = RangeVar->getInit();
2695 if (!RangeExpr->isTypeDependent() &&
2696 RangeExpr->getType()->isObjCObjectPointerType()) {
2697 // FIXME: Support init-statements in Objective-C++20 ranged for
2698 // statement.
2699 if (Init) {
2700 return SemaRef.Diag(Init->getBeginLoc(),
2701 diag::err_objc_for_range_init_stmt)
2702 << Init->getSourceRange();
2703 }
2705 ForLoc, LoopVar, RangeExpr, RParenLoc);
2706 }
2707 }
2708 }
2709 }
2710
2712 ForLoc, CoawaitLoc, Init, ColonLoc, Range, Begin, End, Cond, Inc,
2713 LoopVar, RParenLoc, Sema::BFRK_Rebuild, LifetimeExtendTemps);
2714 }
2715
2716 /// Build a new C++0x range-based for statement.
2717 ///
2718 /// By default, performs semantic analysis to build the new statement.
2719 /// Subclasses may override this routine to provide different behavior.
2721 bool IsIfExists,
2722 NestedNameSpecifierLoc QualifierLoc,
2723 DeclarationNameInfo NameInfo,
2724 Stmt *Nested) {
2725 return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2726 QualifierLoc, NameInfo, Nested);
2727 }
2728
2729 /// Attach body to a C++0x range-based for statement.
2730 ///
2731 /// By default, performs semantic analysis to finish the new statement.
2732 /// Subclasses may override this routine to provide different behavior.
2734 return getSema().FinishCXXForRangeStmt(ForRange, Body);
2735 }
2736
2738 Stmt *TryBlock, Stmt *Handler) {
2739 return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2740 }
2741
2743 Stmt *Block) {
2744 return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2745 }
2746
2748 return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2749 }
2750
2752 SourceLocation LParen,
2753 SourceLocation RParen,
2754 TypeSourceInfo *TSI) {
2755 return getSema().SYCL().BuildUniqueStableNameExpr(OpLoc, LParen, RParen,
2756 TSI);
2757 }
2758
2759 /// Build a new predefined expression.
2760 ///
2761 /// By default, performs semantic analysis to build the new expression.
2762 /// Subclasses may override this routine to provide different behavior.
2766
2767 /// Build a new expression that references a declaration.
2768 ///
2769 /// By default, performs semantic analysis to build the new expression.
2770 /// Subclasses may override this routine to provide different behavior.
2772 LookupResult &R,
2773 bool RequiresADL) {
2774 return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2775 }
2776
2777
2778 /// Build a new expression that references a declaration.
2779 ///
2780 /// By default, performs semantic analysis to build the new expression.
2781 /// Subclasses may override this routine to provide different behavior.
2783 ValueDecl *VD,
2784 const DeclarationNameInfo &NameInfo,
2786 TemplateArgumentListInfo *TemplateArgs) {
2787 CXXScopeSpec SS;
2788 SS.Adopt(QualifierLoc);
2789 return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2790 TemplateArgs);
2791 }
2792
2793 /// Build a new expression in parentheses.
2794 ///
2795 /// By default, performs semantic analysis to build the new expression.
2796 /// Subclasses may override this routine to provide different behavior.
2798 SourceLocation RParen) {
2799 return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2800 }
2801
2802 /// Build a new pseudo-destructor expression.
2803 ///
2804 /// By default, performs semantic analysis to build the new expression.
2805 /// Subclasses may override this routine to provide different behavior.
2807 SourceLocation OperatorLoc,
2808 bool isArrow,
2809 CXXScopeSpec &SS,
2810 TypeSourceInfo *ScopeType,
2811 SourceLocation CCLoc,
2812 SourceLocation TildeLoc,
2813 PseudoDestructorTypeStorage Destroyed);
2814
2815 /// Build a new unary operator expression.
2816 ///
2817 /// By default, performs semantic analysis to build the new expression.
2818 /// Subclasses may override this routine to provide different behavior.
2821 Expr *SubExpr) {
2822 return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2823 }
2824
2825 /// Build a new builtin offsetof expression.
2826 ///
2827 /// By default, performs semantic analysis to build the new expression.
2828 /// Subclasses may override this routine to provide different behavior.
2832 SourceLocation RParenLoc) {
2833 return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2834 RParenLoc);
2835 }
2836
2837 /// Build a new sizeof, alignof or vec_step expression with a
2838 /// type argument.
2839 ///
2840 /// By default, performs semantic analysis to build the new expression.
2841 /// Subclasses may override this routine to provide different behavior.
2843 SourceLocation OpLoc,
2844 UnaryExprOrTypeTrait ExprKind,
2845 SourceRange R) {
2846 return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2847 }
2848
2849 /// Build a new sizeof, alignof or vec step expression with an
2850 /// expression argument.
2851 ///
2852 /// By default, performs semantic analysis to build the new expression.
2853 /// Subclasses may override this routine to provide different behavior.
2855 UnaryExprOrTypeTrait ExprKind,
2856 SourceRange R) {
2858 = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2859 if (Result.isInvalid())
2860 return ExprError();
2861
2862 return Result;
2863 }
2864
2865 /// Build a new array subscript expression.
2866 ///
2867 /// By default, performs semantic analysis to build the new expression.
2868 /// Subclasses may override this routine to provide different behavior.
2870 SourceLocation LBracketLoc,
2871 Expr *RHS,
2872 SourceLocation RBracketLoc) {
2873 return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2874 LBracketLoc, RHS,
2875 RBracketLoc);
2876 }
2877
2878 /// Build a new matrix single subscript expression.
2879 ///
2880 /// By default, performs semantic analysis to build the new expression.
2881 /// Subclasses may override this routine to provide different behavior.
2883 SourceLocation RBracketLoc) {
2885 RBracketLoc);
2886 }
2887
2888 /// Build a new matrix subscript expression.
2889 ///
2890 /// By default, performs semantic analysis to build the new expression.
2891 /// Subclasses may override this routine to provide different behavior.
2893 Expr *ColumnIdx,
2894 SourceLocation RBracketLoc) {
2895 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2896 RBracketLoc);
2897 }
2898
2899 /// Build a new array section expression.
2900 ///
2901 /// By default, performs semantic analysis to build the new expression.
2902 /// Subclasses may override this routine to provide different behavior.
2904 SourceLocation LBracketLoc,
2905 Expr *LowerBound,
2906 SourceLocation ColonLocFirst,
2907 SourceLocation ColonLocSecond,
2908 Expr *Length, Expr *Stride,
2909 SourceLocation RBracketLoc) {
2910 if (IsOMPArraySection)
2912 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2913 Stride, RBracketLoc);
2914
2915 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2916 "Stride/second colon not allowed for OpenACC");
2917
2919 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2920 }
2921
2922 /// Build a new array shaping expression.
2923 ///
2924 /// By default, performs semantic analysis to build the new expression.
2925 /// Subclasses may override this routine to provide different behavior.
2927 SourceLocation RParenLoc,
2928 ArrayRef<Expr *> Dims,
2929 ArrayRef<SourceRange> BracketsRanges) {
2931 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2932 }
2933
2934 /// Build a new iterator expression.
2935 ///
2936 /// By default, performs semantic analysis to build the new expression.
2937 /// Subclasses may override this routine to provide different behavior.
2940 SourceLocation RLoc,
2943 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2944 }
2945
2946 /// Build a new call expression.
2947 ///
2948 /// By default, performs semantic analysis to build the new expression.
2949 /// Subclasses may override this routine to provide different behavior.
2951 MultiExprArg Args,
2952 SourceLocation RParenLoc,
2953 Expr *ExecConfig = nullptr) {
2954 return getSema().ActOnCallExpr(
2955 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2956 }
2957
2959 MultiExprArg Args,
2960 SourceLocation RParenLoc) {
2962 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2963 }
2964
2965 /// Build a new member access expression.
2966 ///
2967 /// By default, performs semantic analysis to build the new expression.
2968 /// Subclasses may override this routine to provide different behavior.
2970 bool isArrow,
2971 NestedNameSpecifierLoc QualifierLoc,
2972 SourceLocation TemplateKWLoc,
2973 const DeclarationNameInfo &MemberNameInfo,
2975 NamedDecl *FoundDecl,
2976 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2977 NamedDecl *FirstQualifierInScope) {
2979 isArrow);
2980 if (!Member->getDeclName()) {
2981 // We have a reference to an unnamed field. This is always the
2982 // base of an anonymous struct/union member access, i.e. the
2983 // field is always of record type.
2984 assert(Member->getType()->isRecordType() &&
2985 "unnamed member not of record type?");
2986
2987 BaseResult =
2989 QualifierLoc.getNestedNameSpecifier(),
2990 FoundDecl, Member);
2991 if (BaseResult.isInvalid())
2992 return ExprError();
2993 Base = BaseResult.get();
2994
2995 // `TranformMaterializeTemporaryExpr()` removes materialized temporaries
2996 // from the AST, so we need to re-insert them if needed (since
2997 // `BuildFieldRefereneExpr()` doesn't do this).
2998 if (!isArrow && Base->isPRValue()) {
3000 if (BaseResult.isInvalid())
3001 return ExprError();
3002 Base = BaseResult.get();
3003 }
3004
3005 CXXScopeSpec EmptySS;
3007 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
3008 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
3009 MemberNameInfo);
3010 }
3011
3012 CXXScopeSpec SS;
3013 SS.Adopt(QualifierLoc);
3014
3015 Base = BaseResult.get();
3016 if (Base->containsErrors())
3017 return ExprError();
3018
3019 QualType BaseType = Base->getType();
3020
3021 if (isArrow && !BaseType->isPointerType())
3022 return ExprError();
3023
3024 // FIXME: this involves duplicating earlier analysis in a lot of
3025 // cases; we should avoid this when possible.
3026 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
3027 R.addDecl(FoundDecl);
3028 R.resolveKind();
3029
3030 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
3032 if (auto *ThisClass = cast<CXXThisExpr>(Base)
3033 ->getType()
3034 ->getPointeeType()
3035 ->getAsCXXRecordDecl()) {
3036 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
3037 // In unevaluated contexts, an expression supposed to be a member access
3038 // might reference a member in an unrelated class.
3039 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
3040 return getSema().BuildDeclRefExpr(Member, Member->getType(),
3041 VK_LValue, Member->getLocation());
3042 }
3043 }
3044
3045 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
3046 SS, TemplateKWLoc,
3047 FirstQualifierInScope,
3048 R, ExplicitTemplateArgs,
3049 /*S*/nullptr);
3050 }
3051
3052 /// Build a new binary operator expression.
3053 ///
3054 /// By default, performs semantic analysis to build the new expression.
3055 /// Subclasses may override this routine to provide different behavior.
3057 Expr *LHS, Expr *RHS,
3058 bool ForFoldExpression = false) {
3059 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS,
3060 ForFoldExpression);
3061 }
3062
3063 /// Build a new rewritten operator expression.
3064 ///
3065 /// By default, performs semantic analysis to build the new expression.
3066 /// Subclasses may override this routine to provide different behavior.
3068 SourceLocation OpLoc, BinaryOperatorKind Opcode,
3069 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
3070 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
3071 RHS, /*RequiresADL*/false);
3072 }
3073
3074 /// Build a new conditional operator expression.
3075 ///
3076 /// By default, performs semantic analysis to build the new expression.
3077 /// Subclasses may override this routine to provide different behavior.
3079 SourceLocation QuestionLoc,
3080 Expr *LHS,
3081 SourceLocation ColonLoc,
3082 Expr *RHS) {
3083 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
3084 LHS, RHS);
3085 }
3086
3087 /// Build a new C-style cast expression.
3088 ///
3089 /// By default, performs semantic analysis to build the new expression.
3090 /// Subclasses may override this routine to provide different behavior.
3092 TypeSourceInfo *TInfo,
3093 SourceLocation RParenLoc,
3094 Expr *SubExpr) {
3095 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
3096 SubExpr);
3097 }
3098
3099 /// Build a new compound literal expression.
3100 ///
3101 /// By default, performs semantic analysis to build the new expression.
3102 /// Subclasses may override this routine to provide different behavior.
3104 TypeSourceInfo *TInfo,
3105 SourceLocation RParenLoc,
3106 Expr *Init) {
3107 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
3108 Init);
3109 }
3110
3111 /// Build a new extended vector or matrix element access expression.
3112 ///
3113 /// By default, performs semantic analysis to build the new expression.
3114 /// Subclasses may override this routine to provide different behavior.
3116 SourceLocation OpLoc,
3117 bool IsArrow,
3118 SourceLocation AccessorLoc,
3119 IdentifierInfo &Accessor) {
3120
3121 CXXScopeSpec SS;
3122 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3124 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3125 /*FirstQualifierInScope*/ nullptr, NameInfo,
3126 /* TemplateArgs */ nullptr,
3127 /*S*/ nullptr);
3128 }
3129
3130 /// Build a new initializer list expression.
3131 ///
3132 /// By default, performs semantic analysis to build the new expression.
3133 /// Subclasses may override this routine to provide different behavior.
3135 SourceLocation RBraceLoc, bool IsExplicit) {
3136 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc, IsExplicit);
3137 }
3138
3139 /// Build a new designated initializer expression.
3140 ///
3141 /// By default, performs semantic analysis to build the new expression.
3142 /// Subclasses may override this routine to provide different behavior.
3144 MultiExprArg ArrayExprs,
3145 SourceLocation EqualOrColonLoc,
3146 bool GNUSyntax,
3147 Expr *Init) {
3149 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3150 Init);
3151 if (Result.isInvalid())
3152 return ExprError();
3153
3154 return Result;
3155 }
3156
3157 /// Build a new value-initialized expression.
3158 ///
3159 /// By default, builds the implicit value initialization without performing
3160 /// any semantic analysis. Subclasses may override this routine to provide
3161 /// different behavior.
3165
3166 /// Build a new \c va_arg expression.
3167 ///
3168 /// By default, performs semantic analysis to build the new expression.
3169 /// Subclasses may override this routine to provide different behavior.
3171 Expr *SubExpr, TypeSourceInfo *TInfo,
3172 SourceLocation RParenLoc) {
3173 return getSema().BuildVAArgExpr(BuiltinLoc,
3174 SubExpr, TInfo,
3175 RParenLoc);
3176 }
3177
3178 /// Build a new expression list in parentheses.
3179 ///
3180 /// By default, performs semantic analysis to build the new expression.
3181 /// Subclasses may override this routine to provide different behavior.
3183 MultiExprArg SubExprs,
3184 SourceLocation RParenLoc) {
3185 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3186 }
3187
3189 unsigned NumUserSpecifiedExprs,
3190 SourceLocation InitLoc,
3191 SourceLocation LParenLoc,
3192 SourceLocation RParenLoc) {
3193 return getSema().ActOnCXXParenListInitExpr(Args, T, NumUserSpecifiedExprs,
3194 InitLoc, LParenLoc, RParenLoc);
3195 }
3196
3197 /// Build a new address-of-label expression.
3198 ///
3199 /// By default, performs semantic analysis, using the name of the label
3200 /// rather than attempting to map the label statement itself.
3201 /// Subclasses may override this routine to provide different behavior.
3203 SourceLocation LabelLoc, LabelDecl *Label) {
3204 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3205 }
3206
3207 /// Build a new GNU statement expression.
3208 ///
3209 /// By default, performs semantic analysis to build the new expression.
3210 /// Subclasses may override this routine to provide different behavior.
3212 SourceLocation RParenLoc, unsigned TemplateDepth) {
3213 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3214 TemplateDepth);
3215 }
3216
3217 /// Build a new __builtin_choose_expr expression.
3218 ///
3219 /// By default, performs semantic analysis to build the new expression.
3220 /// Subclasses may override this routine to provide different behavior.
3222 Expr *Cond, Expr *LHS, Expr *RHS,
3223 SourceLocation RParenLoc) {
3224 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3225 Cond, LHS, RHS,
3226 RParenLoc);
3227 }
3228
3229 /// Build a new generic selection expression with an expression predicate.
3230 ///
3231 /// By default, performs semantic analysis to build the new expression.
3232 /// Subclasses may override this routine to provide different behavior.
3234 SourceLocation DefaultLoc,
3235 SourceLocation RParenLoc,
3236 Expr *ControllingExpr,
3238 ArrayRef<Expr *> Exprs) {
3239 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3240 /*PredicateIsExpr=*/true,
3241 ControllingExpr, Types, Exprs);
3242 }
3243
3244 /// Build a new generic selection expression with a type predicate.
3245 ///
3246 /// By default, performs semantic analysis to build the new expression.
3247 /// Subclasses may override this routine to provide different behavior.
3249 SourceLocation DefaultLoc,
3250 SourceLocation RParenLoc,
3251 TypeSourceInfo *ControllingType,
3253 ArrayRef<Expr *> Exprs) {
3254 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3255 /*PredicateIsExpr=*/false,
3256 ControllingType, Types, Exprs);
3257 }
3258
3259 /// Build a new overloaded operator call expression.
3260 ///
3261 /// By default, performs semantic analysis to build the new expression.
3262 /// The semantic analysis provides the behavior of template instantiation,
3263 /// copying with transformations that turn what looks like an overloaded
3264 /// operator call into a use of a builtin operator, performing
3265 /// argument-dependent lookup, etc. Subclasses may override this routine to
3266 /// provide different behavior.
3268 SourceLocation OpLoc,
3269 SourceLocation CalleeLoc,
3270 bool RequiresADL,
3271 const UnresolvedSetImpl &Functions,
3272 Expr *First, Expr *Second);
3273
3274 /// Build a new C++ "named" cast expression, such as static_cast or
3275 /// reinterpret_cast.
3276 ///
3277 /// By default, this routine dispatches to one of the more-specific routines
3278 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3279 /// Subclasses may override this routine to provide different behavior.
3282 SourceLocation LAngleLoc,
3283 TypeSourceInfo *TInfo,
3284 SourceLocation RAngleLoc,
3285 SourceLocation LParenLoc,
3286 Expr *SubExpr,
3287 SourceLocation RParenLoc) {
3288 switch (Class) {
3289 case Stmt::CXXStaticCastExprClass:
3290 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3291 RAngleLoc, LParenLoc,
3292 SubExpr, RParenLoc);
3293
3294 case Stmt::CXXDynamicCastExprClass:
3295 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3296 RAngleLoc, LParenLoc,
3297 SubExpr, RParenLoc);
3298
3299 case Stmt::CXXReinterpretCastExprClass:
3300 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3301 RAngleLoc, LParenLoc,
3302 SubExpr,
3303 RParenLoc);
3304
3305 case Stmt::CXXConstCastExprClass:
3306 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3307 RAngleLoc, LParenLoc,
3308 SubExpr, RParenLoc);
3309
3310 case Stmt::CXXAddrspaceCastExprClass:
3311 return getDerived().RebuildCXXAddrspaceCastExpr(
3312 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3313
3314 default:
3315 llvm_unreachable("Invalid C++ named cast");
3316 }
3317 }
3318
3319 /// Build a new C++ static_cast expression.
3320 ///
3321 /// By default, performs semantic analysis to build the new expression.
3322 /// Subclasses may override this routine to provide different behavior.
3324 SourceLocation LAngleLoc,
3325 TypeSourceInfo *TInfo,
3326 SourceLocation RAngleLoc,
3327 SourceLocation LParenLoc,
3328 Expr *SubExpr,
3329 SourceLocation RParenLoc) {
3330 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3331 TInfo, SubExpr,
3332 SourceRange(LAngleLoc, RAngleLoc),
3333 SourceRange(LParenLoc, RParenLoc));
3334 }
3335
3336 /// Build a new C++ dynamic_cast expression.
3337 ///
3338 /// By default, performs semantic analysis to build the new expression.
3339 /// Subclasses may override this routine to provide different behavior.
3341 SourceLocation LAngleLoc,
3342 TypeSourceInfo *TInfo,
3343 SourceLocation RAngleLoc,
3344 SourceLocation LParenLoc,
3345 Expr *SubExpr,
3346 SourceLocation RParenLoc) {
3347 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3348 TInfo, SubExpr,
3349 SourceRange(LAngleLoc, RAngleLoc),
3350 SourceRange(LParenLoc, RParenLoc));
3351 }
3352
3353 /// Build a new C++ reinterpret_cast expression.
3354 ///
3355 /// By default, performs semantic analysis to build the new expression.
3356 /// Subclasses may override this routine to provide different behavior.
3358 SourceLocation LAngleLoc,
3359 TypeSourceInfo *TInfo,
3360 SourceLocation RAngleLoc,
3361 SourceLocation LParenLoc,
3362 Expr *SubExpr,
3363 SourceLocation RParenLoc) {
3364 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3365 TInfo, SubExpr,
3366 SourceRange(LAngleLoc, RAngleLoc),
3367 SourceRange(LParenLoc, RParenLoc));
3368 }
3369
3370 /// Build a new C++ const_cast expression.
3371 ///
3372 /// By default, performs semantic analysis to build the new expression.
3373 /// Subclasses may override this routine to provide different behavior.
3375 SourceLocation LAngleLoc,
3376 TypeSourceInfo *TInfo,
3377 SourceLocation RAngleLoc,
3378 SourceLocation LParenLoc,
3379 Expr *SubExpr,
3380 SourceLocation RParenLoc) {
3381 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3382 TInfo, SubExpr,
3383 SourceRange(LAngleLoc, RAngleLoc),
3384 SourceRange(LParenLoc, RParenLoc));
3385 }
3386
3389 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3390 SourceLocation LParenLoc, Expr *SubExpr,
3391 SourceLocation RParenLoc) {
3392 return getSema().BuildCXXNamedCast(
3393 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3394 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3395 }
3396
3397 /// Build a new C++ functional-style 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 SourceLocation LParenLoc,
3403 Expr *Sub,
3404 SourceLocation RParenLoc,
3405 bool ListInitialization) {
3406 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3407 // CXXParenListInitExpr. Pass its expanded arguments so that the
3408 // CXXParenListInitExpr can be rebuilt.
3409 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3411 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3412 RParenLoc, ListInitialization);
3413
3414 if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub))
3416 TInfo, LParenLoc, PLE->getInitExprs(), RParenLoc, ListInitialization);
3417
3418 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3419 MultiExprArg(&Sub, 1), RParenLoc,
3420 ListInitialization);
3421 }
3422
3423 /// Build a new C++ __builtin_bit_cast expression.
3424 ///
3425 /// By default, performs semantic analysis to build the new expression.
3426 /// Subclasses may override this routine to provide different behavior.
3428 TypeSourceInfo *TSI, Expr *Sub,
3429 SourceLocation RParenLoc) {
3430 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3431 }
3432
3433 /// Build a new C++ typeid(type) expression.
3434 ///
3435 /// By default, performs semantic analysis to build the new expression.
3436 /// Subclasses may override this routine to provide different behavior.
3438 SourceLocation TypeidLoc,
3439 TypeSourceInfo *Operand,
3440 SourceLocation RParenLoc) {
3441 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3442 RParenLoc);
3443 }
3444
3445
3446 /// Build a new C++ typeid(expr) expression.
3447 ///
3448 /// By default, performs semantic analysis to build the new expression.
3449 /// Subclasses may override this routine to provide different behavior.
3451 SourceLocation TypeidLoc,
3452 Expr *Operand,
3453 SourceLocation RParenLoc) {
3454 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3455 RParenLoc);
3456 }
3457
3458 /// Build a new C++ __uuidof(type) expression.
3459 ///
3460 /// By default, performs semantic analysis to build the new expression.
3461 /// Subclasses may override this routine to provide different behavior.
3463 TypeSourceInfo *Operand,
3464 SourceLocation RParenLoc) {
3465 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3466 }
3467
3468 /// Build a new C++ __uuidof(expr) expression.
3469 ///
3470 /// By default, performs semantic analysis to build the new expression.
3471 /// Subclasses may override this routine to provide different behavior.
3473 Expr *Operand, SourceLocation RParenLoc) {
3474 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3475 }
3476
3477 /// Build a new C++ "this" expression.
3478 ///
3479 /// By default, performs semantic analysis to build a new "this" expression.
3480 /// Subclasses may override this routine to provide different behavior.
3482 QualType ThisType,
3483 bool isImplicit) {
3484 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3485 return ExprError();
3486 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3487 }
3488
3489 /// Build a new C++ throw expression.
3490 ///
3491 /// By default, performs semantic analysis to build the new expression.
3492 /// Subclasses may override this routine to provide different behavior.
3494 bool IsThrownVariableInScope) {
3495 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3496 }
3497
3498 /// Build a new C++ default-argument expression.
3499 ///
3500 /// By default, builds a new default-argument expression, which does not
3501 /// require any semantic analysis. Subclasses may override this routine to
3502 /// provide different behavior.
3504 Expr *RewrittenExpr) {
3505 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3506 RewrittenExpr, getSema().CurContext);
3507 }
3508
3509 /// Build a new C++11 default-initialization expression.
3510 ///
3511 /// By default, builds a new default field initialization expression, which
3512 /// does not require any semantic analysis. Subclasses may override this
3513 /// routine to provide different behavior.
3518
3519 /// Build a new C++ zero-initialization expression.
3520 ///
3521 /// By default, performs semantic analysis to build the new expression.
3522 /// Subclasses may override this routine to provide different behavior.
3524 SourceLocation LParenLoc,
3525 SourceLocation RParenLoc) {
3526 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3527 /*ListInitialization=*/false);
3528 }
3529
3530 /// Build a new C++ "new" expression.
3531 ///
3532 /// By default, performs semantic analysis to build the new expression.
3533 /// Subclasses may override this routine to provide different behavior.
3535 SourceLocation PlacementLParen,
3536 MultiExprArg PlacementArgs,
3537 SourceLocation PlacementRParen,
3538 SourceRange TypeIdParens, QualType AllocatedType,
3539 TypeSourceInfo *AllocatedTypeInfo,
3540 std::optional<Expr *> ArraySize,
3541 SourceRange DirectInitRange, Expr *Initializer) {
3542 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3543 PlacementLParen,
3544 PlacementArgs,
3545 PlacementRParen,
3546 TypeIdParens,
3547 AllocatedType,
3548 AllocatedTypeInfo,
3549 ArraySize,
3550 DirectInitRange,
3551 Initializer);
3552 }
3553
3554 /// Build a new C++ "delete" expression.
3555 ///
3556 /// By default, performs semantic analysis to build the new expression.
3557 /// Subclasses may override this routine to provide different behavior.
3559 bool IsGlobalDelete,
3560 bool IsArrayForm,
3561 Expr *Operand) {
3562 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3563 Operand);
3564 }
3565
3566 /// Build a new type trait expression.
3567 ///
3568 /// By default, performs semantic analysis to build the new expression.
3569 /// Subclasses may override this routine to provide different behavior.
3571 SourceLocation StartLoc,
3573 SourceLocation RParenLoc) {
3574 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3575 }
3576
3577 /// Build a new array type trait expression.
3578 ///
3579 /// By default, performs semantic analysis to build the new expression.
3580 /// Subclasses may override this routine to provide different behavior.
3582 SourceLocation StartLoc,
3583 TypeSourceInfo *TSInfo,
3584 Expr *DimExpr,
3585 SourceLocation RParenLoc) {
3586 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3587 }
3588
3589 /// Build a new expression trait expression.
3590 ///
3591 /// By default, performs semantic analysis to build the new expression.
3592 /// Subclasses may override this routine to provide different behavior.
3594 SourceLocation StartLoc,
3595 Expr *Queried,
3596 SourceLocation RParenLoc) {
3597 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3598 }
3599
3600 /// Build a new (previously unresolved) declaration reference
3601 /// expression.
3602 ///
3603 /// By default, performs semantic analysis to build the new expression.
3604 /// Subclasses may override this routine to provide different behavior.
3606 NestedNameSpecifierLoc QualifierLoc,
3607 SourceLocation TemplateKWLoc,
3608 const DeclarationNameInfo &NameInfo,
3609 const TemplateArgumentListInfo *TemplateArgs,
3610 bool IsAddressOfOperand,
3611 TypeSourceInfo **RecoveryTSI) {
3612 CXXScopeSpec SS;
3613 SS.Adopt(QualifierLoc);
3614
3615 if (TemplateArgs || TemplateKWLoc.isValid())
3617 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3618
3620 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3621 }
3622
3623 /// Build a new template-id expression.
3624 ///
3625 /// By default, performs semantic analysis to build the new expression.
3626 /// Subclasses may override this routine to provide different behavior.
3628 SourceLocation TemplateKWLoc,
3629 LookupResult &R,
3630 bool RequiresADL,
3631 const TemplateArgumentListInfo *TemplateArgs) {
3632 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3633 TemplateArgs);
3634 }
3635
3636 /// Build a new object-construction expression.
3637 ///
3638 /// By default, performs semantic analysis to build the new expression.
3639 /// Subclasses may override this routine to provide different behavior.
3642 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3643 bool ListInitialization, bool StdInitListInitialization,
3644 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3645 SourceRange ParenRange) {
3646 // Reconstruct the constructor we originally found, which might be
3647 // different if this is a call to an inherited constructor.
3648 CXXConstructorDecl *FoundCtor = Constructor;
3649 if (Constructor->isInheritingConstructor())
3650 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3651
3652 SmallVector<Expr *, 8> ConvertedArgs;
3653 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3654 ConvertedArgs))
3655 return ExprError();
3656
3657 return getSema().BuildCXXConstructExpr(Loc, T, Constructor,
3658 IsElidable,
3659 ConvertedArgs,
3660 HadMultipleCandidates,
3661 ListInitialization,
3662 StdInitListInitialization,
3663 RequiresZeroInit, ConstructKind,
3664 ParenRange);
3665 }
3666
3667 /// Build a new implicit construction via inherited constructor
3668 /// expression.
3671 bool ConstructsVBase,
3672 bool InheritedFromVBase) {
3674 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3675 }
3676
3677 /// Build a new object-construction expression.
3678 ///
3679 /// By default, performs semantic analysis to build the new expression.
3680 /// Subclasses may override this routine to provide different behavior.
3682 SourceLocation LParenOrBraceLoc,
3683 MultiExprArg Args,
3684 SourceLocation RParenOrBraceLoc,
3685 bool ListInitialization) {
3687 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3688 }
3689
3690 /// Build a new object-construction expression.
3691 ///
3692 /// By default, performs semantic analysis to build the new expression.
3693 /// Subclasses may override this routine to provide different behavior.
3695 SourceLocation LParenLoc,
3696 MultiExprArg Args,
3697 SourceLocation RParenLoc,
3698 bool ListInitialization) {
3699 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3700 RParenLoc, ListInitialization);
3701 }
3702
3703 /// Build a new member reference expression.
3704 ///
3705 /// By default, performs semantic analysis to build the new expression.
3706 /// Subclasses may override this routine to provide different behavior.
3708 QualType BaseType,
3709 bool IsArrow,
3710 SourceLocation OperatorLoc,
3711 NestedNameSpecifierLoc QualifierLoc,
3712 SourceLocation TemplateKWLoc,
3713 NamedDecl *FirstQualifierInScope,
3714 const DeclarationNameInfo &MemberNameInfo,
3715 const TemplateArgumentListInfo *TemplateArgs) {
3716 CXXScopeSpec SS;
3717 SS.Adopt(QualifierLoc);
3718
3719 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3720 OperatorLoc, IsArrow,
3721 SS, TemplateKWLoc,
3722 FirstQualifierInScope,
3723 MemberNameInfo,
3724 TemplateArgs, /*S*/nullptr);
3725 }
3726
3727 /// Build a new member reference expression.
3728 ///
3729 /// By default, performs semantic analysis to build the new expression.
3730 /// Subclasses may override this routine to provide different behavior.
3732 SourceLocation OperatorLoc,
3733 bool IsArrow,
3734 NestedNameSpecifierLoc QualifierLoc,
3735 SourceLocation TemplateKWLoc,
3736 NamedDecl *FirstQualifierInScope,
3737 LookupResult &R,
3738 const TemplateArgumentListInfo *TemplateArgs) {
3739 CXXScopeSpec SS;
3740 SS.Adopt(QualifierLoc);
3741
3742 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3743 OperatorLoc, IsArrow,
3744 SS, TemplateKWLoc,
3745 FirstQualifierInScope,
3746 R, TemplateArgs, /*S*/nullptr);
3747 }
3748
3749 /// Build a new noexcept expression.
3750 ///
3751 /// By default, performs semantic analysis to build the new expression.
3752 /// Subclasses may override this routine to provide different behavior.
3754 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3755 }
3756
3759
3760 /// Build a new expression to compute the length of a parameter pack.
3762 SourceLocation PackLoc,
3763 SourceLocation RParenLoc,
3764 UnsignedOrNone Length,
3765 ArrayRef<TemplateArgument> PartialArgs) {
3766 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3767 RParenLoc, Length, PartialArgs);
3768 }
3769
3771 SourceLocation RSquareLoc,
3772 Expr *PackIdExpression, Expr *IndexExpr,
3773 ArrayRef<Expr *> ExpandedExprs,
3774 bool FullySubstituted = false) {
3775 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3776 IndexExpr, RSquareLoc, ExpandedExprs,
3777 FullySubstituted);
3778 }
3779
3780 /// Build a new expression representing a call to a source location
3781 /// builtin.
3782 ///
3783 /// By default, performs semantic analysis to build the new expression.
3784 /// Subclasses may override this routine to provide different behavior.
3786 SourceLocation BuiltinLoc,
3787 SourceLocation RPLoc,
3788 DeclContext *ParentContext) {
3789 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3790 ParentContext);
3791 }
3792
3794 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3795 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3797 CXXScopeSpec SS;
3798 SS.Adopt(NNS);
3799 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3800 ConceptNameInfo,
3801 FoundDecl,
3802 NamedConcept, TALI);
3803 if (Result.isInvalid())
3804 return ExprError();
3805 return Result;
3806 }
3807
3808 /// \brief Build a new requires expression.
3809 ///
3810 /// By default, performs semantic analysis to build the new expression.
3811 /// Subclasses may override this routine to provide different behavior.
3814 SourceLocation LParenLoc,
3815 ArrayRef<ParmVarDecl *> LocalParameters,
3816 SourceLocation RParenLoc,
3818 SourceLocation ClosingBraceLoc) {
3819 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3820 LocalParameters, RParenLoc, Requirements,
3821 ClosingBraceLoc);
3822 }
3823
3827 return SemaRef.BuildTypeRequirement(SubstDiag);
3828 }
3829
3831 return SemaRef.BuildTypeRequirement(T);
3832 }
3833
3836 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3837 SourceLocation NoexceptLoc,
3839 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3840 std::move(Ret));
3841 }
3842
3844 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3846 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3847 std::move(Ret));
3848 }
3849
3851 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3852 const ASTConstraintSatisfaction &Satisfaction) {
3853 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3854 Satisfaction);
3855 }
3856
3858 return SemaRef.BuildNestedRequirement(Constraint);
3859 }
3860
3861 /// \brief Build a new Objective-C boxed expression.
3862 ///
3863 /// By default, performs semantic analysis to build the new expression.
3864 /// Subclasses may override this routine to provide different behavior.
3866 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3867 }
3868
3869 /// Build a new Objective-C array literal.
3870 ///
3871 /// By default, performs semantic analysis to build the new expression.
3872 /// Subclasses may override this routine to provide different behavior.
3874 Expr **Elements, unsigned NumElements) {
3876 Range, MultiExprArg(Elements, NumElements));
3877 }
3878
3880 Expr *Base, Expr *Key,
3881 ObjCMethodDecl *getterMethod,
3882 ObjCMethodDecl *setterMethod) {
3884 RB, Base, Key, getterMethod, setterMethod);
3885 }
3886
3887 /// Build a new Objective-C dictionary literal.
3888 ///
3889 /// By default, performs semantic analysis to build the new expression.
3890 /// Subclasses may override this routine to provide different behavior.
3895
3896 /// Build a new Objective-C \@encode expression.
3897 ///
3898 /// By default, performs semantic analysis to build the new expression.
3899 /// Subclasses may override this routine to provide different behavior.
3901 TypeSourceInfo *EncodeTypeInfo,
3902 SourceLocation RParenLoc) {
3903 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3904 RParenLoc);
3905 }
3906
3907 /// Build a new Objective-C class message.
3909 Selector Sel,
3910 ArrayRef<SourceLocation> SelectorLocs,
3912 SourceLocation LBracLoc,
3913 MultiExprArg Args,
3914 SourceLocation RBracLoc) {
3915 return SemaRef.ObjC().BuildClassMessage(
3916 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3917 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3918 RBracLoc, Args);
3919 }
3920
3921 /// Build a new Objective-C instance message.
3923 Selector Sel,
3924 ArrayRef<SourceLocation> SelectorLocs,
3926 SourceLocation LBracLoc,
3927 MultiExprArg Args,
3928 SourceLocation RBracLoc) {
3929 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3930 /*SuperLoc=*/SourceLocation(),
3931 Sel, Method, LBracLoc,
3932 SelectorLocs, RBracLoc, Args);
3933 }
3934
3935 /// Build a new Objective-C instance/class message to 'super'.
3937 Selector Sel,
3938 ArrayRef<SourceLocation> SelectorLocs,
3939 QualType SuperType,
3941 SourceLocation LBracLoc,
3942 MultiExprArg Args,
3943 SourceLocation RBracLoc) {
3944 return Method->isInstanceMethod()
3945 ? SemaRef.ObjC().BuildInstanceMessage(
3946 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3947 SelectorLocs, RBracLoc, Args)
3948 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3949 Sel, Method, LBracLoc,
3950 SelectorLocs, RBracLoc, Args);
3951 }
3952
3953 /// Build a new Objective-C ivar reference expression.
3954 ///
3955 /// By default, performs semantic analysis to build the new expression.
3956 /// Subclasses may override this routine to provide different behavior.
3958 SourceLocation IvarLoc,
3959 bool IsArrow, bool IsFreeIvar) {
3960 CXXScopeSpec SS;
3961 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3963 BaseArg, BaseArg->getType(),
3964 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3965 /*FirstQualifierInScope=*/nullptr, NameInfo,
3966 /*TemplateArgs=*/nullptr,
3967 /*S=*/nullptr);
3968 if (IsFreeIvar && Result.isUsable())
3969 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3970 return Result;
3971 }
3972
3973 /// Build a new Objective-C property reference expression.
3974 ///
3975 /// By default, performs semantic analysis to build the new expression.
3976 /// Subclasses may override this routine to provide different behavior.
3979 SourceLocation PropertyLoc) {
3980 CXXScopeSpec SS;
3981 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3982 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3983 /*FIXME:*/PropertyLoc,
3984 /*IsArrow=*/false,
3985 SS, SourceLocation(),
3986 /*FirstQualifierInScope=*/nullptr,
3987 NameInfo,
3988 /*TemplateArgs=*/nullptr,
3989 /*S=*/nullptr);
3990 }
3991
3992 /// Build a new Objective-C property reference expression.
3993 ///
3994 /// By default, performs semantic analysis to build the new expression.
3995 /// Subclasses may override this routine to provide different behavior.
3997 ObjCMethodDecl *Getter,
3998 ObjCMethodDecl *Setter,
3999 SourceLocation PropertyLoc) {
4000 // Since these expressions can only be value-dependent, we do not
4001 // need to perform semantic analysis again.
4002 return Owned(
4003 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
4005 PropertyLoc, Base));
4006 }
4007
4008 /// Build a new Objective-C "isa" expression.
4009 ///
4010 /// By default, performs semantic analysis to build the new expression.
4011 /// Subclasses may override this routine to provide different behavior.
4013 SourceLocation OpLoc, bool IsArrow) {
4014 CXXScopeSpec SS;
4015 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
4016 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
4017 OpLoc, IsArrow,
4018 SS, SourceLocation(),
4019 /*FirstQualifierInScope=*/nullptr,
4020 NameInfo,
4021 /*TemplateArgs=*/nullptr,
4022 /*S=*/nullptr);
4023 }
4024
4025 /// Build a new shuffle vector expression.
4026 ///
4027 /// By default, performs semantic analysis to build the new expression.
4028 /// Subclasses may override this routine to provide different behavior.
4030 MultiExprArg SubExprs,
4031 SourceLocation RParenLoc) {
4032 // Find the declaration for __builtin_shufflevector
4033 const IdentifierInfo &Name
4034 = SemaRef.Context.Idents.get("__builtin_shufflevector");
4035 TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
4036 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
4037 assert(!Lookup.empty() && "No __builtin_shufflevector?");
4038
4039 // Build a reference to the __builtin_shufflevector builtin
4041 Expr *Callee = new (SemaRef.Context)
4042 DeclRefExpr(SemaRef.Context, Builtin, false,
4043 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
4044 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
4045 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
4046 CK_BuiltinFnToFnPtr).get();
4047
4048 // Build the CallExpr
4049 ExprResult TheCall = CallExpr::Create(
4050 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
4051 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
4053
4054 // Type-check the __builtin_shufflevector expression.
4055 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
4056 }
4057
4058 /// Build a new convert vector expression.
4060 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
4061 SourceLocation RParenLoc) {
4062 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
4063 }
4064
4065 /// Build a new template argument pack expansion.
4066 ///
4067 /// By default, performs semantic analysis to build a new pack expansion
4068 /// for a template argument. Subclasses may override this routine to provide
4069 /// different behavior.
4071 SourceLocation EllipsisLoc,
4072 UnsignedOrNone NumExpansions) {
4073 switch (Pattern.getArgument().getKind()) {
4077 EllipsisLoc, NumExpansions);
4078 if (Result.isInvalid())
4079 return TemplateArgumentLoc();
4080
4082 /*IsCanonical=*/false),
4083 Result.get());
4084 }
4085
4087 return TemplateArgumentLoc(
4088 SemaRef.Context,
4090 NumExpansions),
4091 Pattern.getTemplateKWLoc(), Pattern.getTemplateQualifierLoc(),
4092 Pattern.getTemplateNameLoc(), EllipsisLoc);
4093
4101 llvm_unreachable("Pack expansion pattern has no parameter packs");
4102
4104 if (TypeSourceInfo *Expansion
4105 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4106 EllipsisLoc,
4107 NumExpansions))
4108 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4109 Expansion);
4110 break;
4111 }
4112
4113 return TemplateArgumentLoc();
4114 }
4115
4116 /// Build a new expression pack expansion.
4117 ///
4118 /// By default, performs semantic analysis to build a new pack expansion
4119 /// for an expression. Subclasses may override this routine to provide
4120 /// different behavior.
4122 UnsignedOrNone NumExpansions) {
4123 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4124 }
4125
4126 /// Build a new C++1z fold-expression.
4127 ///
4128 /// By default, performs semantic analysis in order to build a new fold
4129 /// expression.
4131 SourceLocation LParenLoc, Expr *LHS,
4132 BinaryOperatorKind Operator,
4133 SourceLocation EllipsisLoc, Expr *RHS,
4134 SourceLocation RParenLoc,
4135 UnsignedOrNone NumExpansions) {
4136 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4137 EllipsisLoc, RHS, RParenLoc,
4138 NumExpansions);
4139 }
4140
4142 LambdaScopeInfo *LSI) {
4143 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4144 if (Expr *Init = PVD->getInit())
4146 Init->containsUnexpandedParameterPack();
4147 else if (PVD->hasUninstantiatedDefaultArg())
4149 PVD->getUninstantiatedDefaultArg()
4150 ->containsUnexpandedParameterPack();
4151 }
4152 return getSema().BuildLambdaExpr(StartLoc, EndLoc);
4153 }
4154
4155 /// Build an empty C++1z fold-expression with the given operator.
4156 ///
4157 /// By default, produces the fallback value for the fold-expression, or
4158 /// produce an error if there is no fallback value.
4160 BinaryOperatorKind Operator) {
4161 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4162 }
4163
4164 /// Build a new atomic operation expression.
4165 ///
4166 /// By default, performs semantic analysis to build the new expression.
4167 /// Subclasses may override this routine to provide different behavior.
4170 SourceLocation RParenLoc) {
4171 // Use this for all of the locations, since we don't know the difference
4172 // between the call and the expr at this point.
4173 SourceRange Range{BuiltinLoc, RParenLoc};
4174 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4176 }
4177
4179 ArrayRef<Expr *> SubExprs, QualType Type) {
4180 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4181 }
4182
4184 SourceLocation BeginLoc,
4185 SourceLocation DirLoc,
4186 SourceLocation EndLoc,
4188 StmtResult StrBlock) {
4190 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4191 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, StrBlock);
4192 }
4193
4204
4206 SourceLocation BeginLoc,
4207 SourceLocation DirLoc,
4208 SourceLocation EndLoc,
4210 StmtResult Loop) {
4212 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4213 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, Loop);
4214 }
4215
4217 SourceLocation DirLoc,
4218 SourceLocation EndLoc,
4220 StmtResult StrBlock) {
4222 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4224 Clauses, StrBlock);
4225 }
4226
4236
4246
4248 SourceLocation DirLoc,
4249 SourceLocation EndLoc,
4251 StmtResult StrBlock) {
4255 Clauses, StrBlock);
4256 }
4257
4259 SourceLocation DirLoc,
4260 SourceLocation EndLoc,
4261 ArrayRef<OpenACCClause *> Clauses) {
4263 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4265 Clauses, {});
4266 }
4267
4277
4279 SourceLocation DirLoc,
4280 SourceLocation EndLoc,
4281 ArrayRef<OpenACCClause *> Clauses) {
4283 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4285 Clauses, {});
4286 }
4287
4289 SourceLocation DirLoc,
4290 SourceLocation EndLoc,
4291 ArrayRef<OpenACCClause *> Clauses) {
4293 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4295 Clauses, {});
4296 }
4297
4299 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4300 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4301 SourceLocation RParenLoc, SourceLocation EndLoc,
4302 ArrayRef<OpenACCClause *> Clauses) {
4304 Exprs.push_back(DevNumExpr);
4305 llvm::append_range(Exprs, QueueIdExprs);
4307 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4308 Exprs, OpenACCAtomicKind::None, RParenLoc, EndLoc, Clauses, {});
4309 }
4310
4312 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4313 SourceLocation ReadOnlyLoc, ArrayRef<Expr *> VarList,
4314 SourceLocation RParenLoc, SourceLocation EndLoc) {
4316 OpenACCDirectiveKind::Cache, BeginLoc, DirLoc, LParenLoc, ReadOnlyLoc,
4317 VarList, OpenACCAtomicKind::None, RParenLoc, EndLoc, {}, {});
4318 }
4319
4321 SourceLocation DirLoc,
4322 OpenACCAtomicKind AtKind,
4323 SourceLocation EndLoc,
4325 StmtResult AssociatedStmt) {
4327 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4328 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, Clauses,
4329 AssociatedStmt);
4330 }
4331
4335
4338 const NonTypeTemplateParmDecl *NTTP,
4340 UnsignedOrNone PackIndex, bool Final) {
4342 AssociatedDecl, NTTP, Loc, Arg, PackIndex, Final);
4343 }
4344
4346 SourceLocation StartLoc,
4347 SourceLocation LParenLoc,
4348 SourceLocation EndLoc) {
4349 return getSema().OpenMP().ActOnOpenMPTransparentClause(ImpexType, StartLoc,
4350 LParenLoc, EndLoc);
4351 }
4352
4353private:
4354 QualType TransformTypeInObjectScope(TypeLocBuilder &TLB, TypeLoc TL,
4355 QualType ObjectType,
4356 NamedDecl *FirstQualifierInScope);
4357
4358 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4359 QualType ObjectType,
4360 NamedDecl *FirstQualifierInScope) {
4361 if (getDerived().AlreadyTransformed(TSInfo->getType()))
4362 return TSInfo;
4363
4364 TypeLocBuilder TLB;
4365 QualType T = TransformTypeInObjectScope(TLB, TSInfo->getTypeLoc(),
4366 ObjectType, FirstQualifierInScope);
4367 if (T.isNull())
4368 return nullptr;
4369 return TLB.getTypeSourceInfo(SemaRef.Context, T);
4370 }
4371
4372 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4373 DependentNameTypeLoc TL,
4374 bool DeducibleTSTContext,
4375 QualType ObjectType = QualType(),
4376 NamedDecl *UnqualLookup = nullptr);
4377
4379 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4381
4382 OpenACCClause *
4383 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4384 OpenACCDirectiveKind DirKind,
4385 const OpenACCClause *OldClause);
4386};
4387
4388template <typename Derived>
4390 if (!S)
4391 return S;
4392
4393 switch (S->getStmtClass()) {
4394 case Stmt::NoStmtClass: break;
4395
4396 // Transform individual statement nodes
4397 // Pass SDK into statements that can produce a value
4398#define STMT(Node, Parent) \
4399 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4400#define VALUESTMT(Node, Parent) \
4401 case Stmt::Node##Class: \
4402 return getDerived().Transform##Node(cast<Node>(S), SDK);
4403#define ABSTRACT_STMT(Node)
4404#define EXPR(Node, Parent)
4405#include "clang/AST/StmtNodes.inc"
4406
4407 // Transform expressions by calling TransformExpr.
4408#define STMT(Node, Parent)
4409#define ABSTRACT_STMT(Stmt)
4410#define EXPR(Node, Parent) case Stmt::Node##Class:
4411#include "clang/AST/StmtNodes.inc"
4412 {
4413 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4414
4416 E = getSema().ActOnStmtExprResult(E);
4417 return getSema().ActOnExprStmt(E, SDK == StmtDiscardKind::Discarded);
4418 }
4419 }
4420
4421 return S;
4422}
4423
4424template<typename Derived>
4426 if (!S)
4427 return S;
4428
4429 switch (S->getClauseKind()) {
4430 default: break;
4431 // Transform individual clause nodes
4432#define GEN_CLANG_CLAUSE_CLASS
4433#define CLAUSE_CLASS(Enum, Str, Class) \
4434 case Enum: \
4435 return getDerived().Transform##Class(cast<Class>(S));
4436#include "llvm/Frontend/OpenMP/OMP.inc"
4437 }
4438
4439 return S;
4440}
4441
4442
4443template<typename Derived>
4445 if (!E)
4446 return E;
4447
4448 switch (E->getStmtClass()) {
4449 case Stmt::NoStmtClass: break;
4450#define STMT(Node, Parent) case Stmt::Node##Class: break;
4451#define ABSTRACT_STMT(Stmt)
4452#define EXPR(Node, Parent) \
4453 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4454#include "clang/AST/StmtNodes.inc"
4455 }
4456
4457 return E;
4458}
4459
4460template<typename Derived>
4462 bool NotCopyInit) {
4463 // Initializers are instantiated like expressions, except that various outer
4464 // layers are stripped.
4465 if (!Init)
4466 return Init;
4467
4468 if (auto *FE = dyn_cast<FullExpr>(Init))
4469 Init = FE->getSubExpr();
4470
4471 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4472 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4473 Init = OVE->getSourceExpr();
4474 }
4475
4476 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4477 Init = MTE->getSubExpr();
4478
4479 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4480 Init = Binder->getSubExpr();
4481
4482 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4483 Init = ICE->getSubExprAsWritten();
4484
4485 if (CXXStdInitializerListExpr *ILE =
4486 dyn_cast<CXXStdInitializerListExpr>(Init))
4487 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4488
4489 // If this is copy-initialization, we only need to reconstruct
4490 // InitListExprs. Other forms of copy-initialization will be a no-op if
4491 // the initializer is already the right type.
4492 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4493 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4494 return getDerived().TransformExpr(Init);
4495
4496 // Revert value-initialization back to empty parens.
4497 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4498 SourceRange Parens = VIE->getSourceRange();
4499 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4500 Parens.getEnd());
4501 }
4502
4503 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4505 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4506 SourceLocation());
4507
4508 // Revert initialization by constructor back to a parenthesized or braced list
4509 // of expressions. Any other form of initializer can just be reused directly.
4510 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4511 return getDerived().TransformExpr(Init);
4512
4513 // If the initialization implicitly converted an initializer list to a
4514 // std::initializer_list object, unwrap the std::initializer_list too.
4515 if (Construct && Construct->isStdInitListInitialization())
4516 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4517
4518 // Enter a list-init context if this was list initialization.
4521 Construct->isListInitialization());
4522
4523 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4524 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4525 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4526 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4527 SmallVector<Expr*, 8> NewArgs;
4528 bool ArgChanged = false;
4529 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4530 /*IsCall*/true, NewArgs, &ArgChanged))
4531 return ExprError();
4532
4533 // If this was list initialization, revert to syntactic list form.
4534 if (Construct->isListInitialization())
4535 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4536 Construct->getEndLoc(),
4537 /*IsExplicit=*/true);
4538
4539 // Build a ParenListExpr to represent anything else.
4541 if (Parens.isInvalid()) {
4542 // This was a variable declaration's initialization for which no initializer
4543 // was specified.
4544 assert(NewArgs.empty() &&
4545 "no parens or braces but have direct init with arguments?");
4546 return ExprEmpty();
4547 }
4548 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4549 Parens.getEnd());
4550}
4551
4552template<typename Derived>
4554 unsigned NumInputs,
4555 bool IsCall,
4556 SmallVectorImpl<Expr *> &Outputs,
4557 bool *ArgChanged) {
4558 for (unsigned I = 0; I != NumInputs; ++I) {
4559 // If requested, drop call arguments that need to be dropped.
4560 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4561 if (ArgChanged)
4562 *ArgChanged = true;
4563
4564 break;
4565 }
4566
4567 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4568 Expr *Pattern = Expansion->getPattern();
4569
4571 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4572 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4573
4574 // Determine whether the set of unexpanded parameter packs can and should
4575 // be expanded.
4576 bool Expand = true;
4577 bool RetainExpansion = false;
4578 UnsignedOrNone OrigNumExpansions = Expansion->getNumExpansions();
4579 UnsignedOrNone NumExpansions = OrigNumExpansions;
4581 Expansion->getEllipsisLoc(), Pattern->getSourceRange(),
4582 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
4583 RetainExpansion, NumExpansions))
4584 return true;
4585
4586 if (!Expand) {
4587 // The transform has determined that we should perform a simple
4588 // transformation on the pack expansion, producing another pack
4589 // expansion.
4590 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
4591 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4592 if (OutPattern.isInvalid())
4593 return true;
4594
4595 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4596 Expansion->getEllipsisLoc(),
4597 NumExpansions);
4598 if (Out.isInvalid())
4599 return true;
4600
4601 if (ArgChanged)
4602 *ArgChanged = true;
4603 Outputs.push_back(Out.get());
4604 continue;
4605 }
4606
4607 // Record right away that the argument was changed. This needs
4608 // to happen even if the array expands to nothing.
4609 if (ArgChanged) *ArgChanged = true;
4610
4611 // The transform has determined that we should perform an elementwise
4612 // expansion of the pattern. Do so.
4613 for (unsigned I = 0; I != *NumExpansions; ++I) {
4614 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
4615 ExprResult Out = getDerived().TransformExpr(Pattern);
4616 if (Out.isInvalid())
4617 return true;
4618
4619 if (Out.get()->containsUnexpandedParameterPack()) {
4620 Out = getDerived().RebuildPackExpansion(
4621 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4622 if (Out.isInvalid())
4623 return true;
4624 }
4625
4626 Outputs.push_back(Out.get());
4627 }
4628
4629 // If we're supposed to retain a pack expansion, do so by temporarily
4630 // forgetting the partially-substituted parameter pack.
4631 if (RetainExpansion) {
4632 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4633
4634 ExprResult Out = getDerived().TransformExpr(Pattern);
4635 if (Out.isInvalid())
4636 return true;
4637
4638 Out = getDerived().RebuildPackExpansion(
4639 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4640 if (Out.isInvalid())
4641 return true;
4642
4643 Outputs.push_back(Out.get());
4644 }
4645
4646 continue;
4647 }
4648
4650 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4651 : getDerived().TransformExpr(Inputs[I]);
4652 if (Result.isInvalid())
4653 return true;
4654
4655 if (Result.get() != Inputs[I] && ArgChanged)
4656 *ArgChanged = true;
4657
4658 Outputs.push_back(Result.get());
4659 }
4660
4661 return false;
4662}
4663
4664template <typename Derived>
4667
4670 /*LambdaContextDecl=*/nullptr,
4672 /*ShouldEnter=*/Kind == Sema::ConditionKind::ConstexprIf);
4673
4674 if (Var) {
4675 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4677
4678 if (!ConditionVar)
4679 return Sema::ConditionError();
4680
4681 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4682 }
4683
4684 if (Expr) {
4685 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4686
4687 if (CondExpr.isInvalid())
4688 return Sema::ConditionError();
4689
4690 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4691 /*MissingOK=*/true);
4692 }
4693
4694 return Sema::ConditionResult();
4695}
4696
4697template <typename Derived>
4699 NestedNameSpecifierLoc NNS, QualType ObjectType,
4700 NamedDecl *FirstQualifierInScope) {
4702
4703 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4704 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4705 Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix)
4706 Qualifiers.push_back(Qualifier);
4707 };
4708 insertNNS(NNS);
4709
4710 CXXScopeSpec SS;
4711 while (!Qualifiers.empty()) {
4712 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4714
4715 switch (QNNS.getKind()) {
4717 llvm_unreachable("unexpected null nested name specifier");
4718
4721 Q.getLocalBeginLoc(), const_cast<NamespaceBaseDecl *>(
4723 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4724 break;
4725 }
4726
4728 // There is no meaningful transformation that one could perform on the
4729 // global scope.
4730 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4731 break;
4732
4734 CXXRecordDecl *RD = cast_or_null<CXXRecordDecl>(
4736 SS.MakeMicrosoftSuper(SemaRef.Context, RD, Q.getBeginLoc(),
4737 Q.getEndLoc());
4738 break;
4739 }
4740
4742 assert(SS.isEmpty());
4743 TypeLoc TL = Q.castAsTypeLoc();
4744
4745 if (auto DNT = TL.getAs<DependentNameTypeLoc>()) {
4746 NestedNameSpecifierLoc QualifierLoc = DNT.getQualifierLoc();
4747 if (QualifierLoc) {
4748 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4749 QualifierLoc, ObjectType, FirstQualifierInScope);
4750 if (!QualifierLoc)
4751 return NestedNameSpecifierLoc();
4752 ObjectType = QualType();
4753 FirstQualifierInScope = nullptr;
4754 }
4755 SS.Adopt(QualifierLoc);
4757 const_cast<IdentifierInfo *>(DNT.getTypePtr()->getIdentifier()),
4758 DNT.getNameLoc(), Q.getLocalEndLoc(), ObjectType);
4759 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo,
4760 false, SS,
4761 FirstQualifierInScope, false))
4762 return NestedNameSpecifierLoc();
4763 return SS.getWithLocInContext(SemaRef.Context);
4764 }
4765
4766 QualType T = TL.getType();
4767 TypeLocBuilder TLB;
4768 if (!getDerived().AlreadyTransformed(T)) {
4769 T = TransformTypeInObjectScope(TLB, TL, ObjectType,
4770 FirstQualifierInScope);
4771 if (T.isNull())
4772 return NestedNameSpecifierLoc();
4773 TL = TLB.getTypeLocInContext(SemaRef.Context, T);
4774 }
4775
4776 if (T->isDependentType() || T->isRecordType() ||
4777 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4778 if (T->isEnumeralType())
4779 SemaRef.Diag(TL.getBeginLoc(),
4780 diag::warn_cxx98_compat_enum_nested_name_spec);
4781 SS.Make(SemaRef.Context, TL, Q.getLocalEndLoc());
4782 break;
4783 }
4784 // If the nested-name-specifier is an invalid type def, don't emit an
4785 // error because a previous error should have already been emitted.
4787 if (!TTL || !TTL.getDecl()->isInvalidDecl()) {
4788 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4789 << T << SS.getRange();
4790 }
4791 return NestedNameSpecifierLoc();
4792 }
4793 }
4794 }
4795
4796 // Don't rebuild the nested-name-specifier if we don't have to.
4797 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4799 return NNS;
4800
4801 // If we can re-use the source-location data from the original
4802 // nested-name-specifier, do so.
4803 if (SS.location_size() == NNS.getDataLength() &&
4804 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4806
4807 // Allocate new nested-name-specifier location information.
4808 return SS.getWithLocInContext(SemaRef.Context);
4809}
4810
4811template<typename Derived>
4815 DeclarationName Name = NameInfo.getName();
4816 if (!Name)
4817 return DeclarationNameInfo();
4818
4819 switch (Name.getNameKind()) {
4827 return NameInfo;
4828
4830 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4831 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4832 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4833 if (!NewTemplate)
4834 return DeclarationNameInfo();
4835
4836 DeclarationNameInfo NewNameInfo(NameInfo);
4837 NewNameInfo.setName(
4838 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
4839 return NewNameInfo;
4840 }
4841
4845 TypeSourceInfo *NewTInfo;
4846 CanQualType NewCanTy;
4847 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4848 NewTInfo = getDerived().TransformType(OldTInfo);
4849 if (!NewTInfo)
4850 return DeclarationNameInfo();
4851 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4852 }
4853 else {
4854 NewTInfo = nullptr;
4855 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4856 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4857 if (NewT.isNull())
4858 return DeclarationNameInfo();
4859 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4860 }
4861
4862 DeclarationName NewName
4863 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4864 NewCanTy);
4865 DeclarationNameInfo NewNameInfo(NameInfo);
4866 NewNameInfo.setName(NewName);
4867 NewNameInfo.setNamedTypeInfo(NewTInfo);
4868 return NewNameInfo;
4869 }
4870 }
4871
4872 llvm_unreachable("Unknown name kind.");
4873}
4874
4875template <typename Derived>
4877 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4879 QualType ObjectType, bool AllowInjectedClassName) {
4880 if (const IdentifierInfo *II = IO.getIdentifier())
4881 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, *II, NameLoc,
4882 ObjectType, AllowInjectedClassName);
4883 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, IO.getOperator(),
4884 NameLoc, ObjectType,
4885 AllowInjectedClassName);
4886}
4887
4888template <typename Derived>
4890 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
4891 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
4892 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
4894 TemplateName UnderlyingName = QTN->getUnderlyingTemplate();
4895
4896 if (QualifierLoc) {
4897 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4898 QualifierLoc, ObjectType, FirstQualifierInScope);
4899 if (!QualifierLoc)
4900 return TemplateName();
4901 }
4902
4903 NestedNameSpecifierLoc UnderlyingQualifier;
4904 TemplateName NewUnderlyingName = getDerived().TransformTemplateName(
4905 UnderlyingQualifier, TemplateKWLoc, UnderlyingName, NameLoc, ObjectType,
4906 FirstQualifierInScope, AllowInjectedClassName);
4907 if (NewUnderlyingName.isNull())
4908 return TemplateName();
4909 assert(!UnderlyingQualifier && "unexpected qualifier");
4910
4911 if (!getDerived().AlwaysRebuild() &&
4912 QualifierLoc.getNestedNameSpecifier() == QTN->getQualifier() &&
4913 NewUnderlyingName == UnderlyingName)
4914 return Name;
4915 CXXScopeSpec SS;
4916 SS.Adopt(QualifierLoc);
4917 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4918 NewUnderlyingName);
4919 }
4920
4922 if (QualifierLoc) {
4923 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4924 QualifierLoc, ObjectType, FirstQualifierInScope);
4925 if (!QualifierLoc)
4926 return TemplateName();
4927 // The qualifier-in-scope and object type only apply to the leftmost
4928 // entity.
4929 ObjectType = QualType();
4930 }
4931
4932 if (!getDerived().AlwaysRebuild() &&
4933 QualifierLoc.getNestedNameSpecifier() == DTN->getQualifier() &&
4934 ObjectType.isNull())
4935 return Name;
4936
4937 CXXScopeSpec SS;
4938 SS.Adopt(QualifierLoc);
4939 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, DTN->getName(),
4940 NameLoc, ObjectType,
4941 AllowInjectedClassName);
4942 }
4943
4946 assert(!QualifierLoc && "Unexpected qualified SubstTemplateTemplateParm");
4947
4948 NestedNameSpecifierLoc ReplacementQualifierLoc;
4949 TemplateName ReplacementName = S->getReplacement();
4950 if (NestedNameSpecifier Qualifier = ReplacementName.getQualifier()) {
4952 Builder.MakeTrivial(SemaRef.Context, Qualifier, NameLoc);
4953 ReplacementQualifierLoc = Builder.getWithLocInContext(SemaRef.Context);
4954 }
4955
4956 TemplateName NewName = getDerived().TransformTemplateName(
4957 ReplacementQualifierLoc, TemplateKWLoc, ReplacementName, NameLoc,
4958 ObjectType, FirstQualifierInScope, AllowInjectedClassName);
4959 if (NewName.isNull())
4960 return TemplateName();
4961 Decl *AssociatedDecl =
4962 getDerived().TransformDecl(NameLoc, S->getAssociatedDecl());
4963 if (!getDerived().AlwaysRebuild() && NewName == S->getReplacement() &&
4964 AssociatedDecl == S->getAssociatedDecl())
4965 return Name;
4966 return SemaRef.Context.getSubstTemplateTemplateParm(
4967 NewName, AssociatedDecl, S->getIndex(), S->getPackIndex(),
4968 S->getFinal());
4969 }
4970
4971 assert(!Name.getAsDeducedTemplateName() &&
4972 "DeducedTemplateName should not escape partial ordering");
4973
4974 // FIXME: Preserve UsingTemplateName.
4975 if (auto *Template = Name.getAsTemplateDecl()) {
4976 assert(!QualifierLoc && "Unexpected qualifier");
4977 return TemplateName(cast_or_null<TemplateDecl>(
4978 getDerived().TransformDecl(NameLoc, Template)));
4979 }
4980
4983 assert(!QualifierLoc &&
4984 "Unexpected qualified SubstTemplateTemplateParmPack");
4985 return getDerived().RebuildTemplateName(
4986 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4987 SubstPack->getIndex(), SubstPack->getFinal());
4988 }
4989
4990 // These should be getting filtered out before they reach the AST.
4991 llvm_unreachable("overloaded function decl survived to here");
4992}
4993
4994template <typename Derived>
4996 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
4997 TemplateName Name, SourceLocation NameLoc) {
4998 TemplateName TN = getDerived().TransformTemplateName(
4999 QualifierLoc, TemplateKeywordLoc, Name, NameLoc);
5000 if (TN.isNull())
5001 return TemplateArgument();
5002 return TemplateArgument(TN);
5003}
5004
5005template<typename Derived>
5007 const TemplateArgument &Arg,
5008 TemplateArgumentLoc &Output) {
5009 Output = getSema().getTrivialTemplateArgumentLoc(
5010 Arg, QualType(), getDerived().getBaseLocation());
5011}
5012
5013template <typename Derived>
5015 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
5016 bool Uneval) {
5017 const TemplateArgument &Arg = Input.getArgument();
5018 switch (Arg.getKind()) {
5021 llvm_unreachable("Unexpected TemplateArgument");
5022
5027 // Transform a resolved template argument straight to a resolved template
5028 // argument. We get here when substituting into an already-substituted
5029 // template type argument during concept satisfaction checking.
5031 QualType NewT = getDerived().TransformType(T);
5032 if (NewT.isNull())
5033 return true;
5034
5036 ? Arg.getAsDecl()
5037 : nullptr;
5038 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
5040 : nullptr;
5041 if (D && !NewD)
5042 return true;
5043
5044 if (NewT == T && D == NewD)
5045 Output = Input;
5046 else if (Arg.getKind() == TemplateArgument::Integral)
5047 Output = TemplateArgumentLoc(
5048 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
5050 else if (Arg.getKind() == TemplateArgument::NullPtr)
5051 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
5053 else if (Arg.getKind() == TemplateArgument::Declaration)
5054 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
5057 Output = TemplateArgumentLoc(
5058 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
5060 else
5061 llvm_unreachable("unexpected template argument kind");
5062
5063 return false;
5064 }
5065
5067 TypeSourceInfo *TSI = Input.getTypeSourceInfo();
5068 if (!TSI)
5070
5071 TSI = getDerived().TransformType(TSI);
5072 if (!TSI)
5073 return true;
5074
5075 Output = TemplateArgumentLoc(TemplateArgument(TSI->getType()), TSI);
5076 return false;
5077 }
5078
5080 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
5081
5082 TemplateArgument Out = getDerived().TransformNamedTemplateTemplateArgument(
5083 QualifierLoc, Input.getTemplateKWLoc(), Arg.getAsTemplate(),
5084 Input.getTemplateNameLoc());
5085 if (Out.isNull())
5086 return true;
5087 Output = TemplateArgumentLoc(SemaRef.Context, Out, Input.getTemplateKWLoc(),
5088 QualifierLoc, Input.getTemplateNameLoc());
5089 return false;
5090 }
5091
5093 llvm_unreachable("Caller should expand pack expansions");
5094
5096 // Template argument expressions are constant expressions.
5098 getSema(),
5101 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
5103
5104 Expr *InputExpr = Input.getSourceExpression();
5105 if (!InputExpr)
5106 InputExpr = Input.getArgument().getAsExpr();
5107
5108 ExprResult E = getDerived().TransformExpr(InputExpr);
5109 E = SemaRef.ActOnConstantExpression(E);
5110 if (E.isInvalid())
5111 return true;
5112 Output = TemplateArgumentLoc(
5113 TemplateArgument(E.get(), /*IsCanonical=*/false), E.get());
5114 return false;
5115 }
5116 }
5117
5118 // Work around bogus GCC warning
5119 return true;
5120}
5121
5122/// Iterator adaptor that invents template argument location information
5123/// for each of the template arguments in its underlying iterator.
5124template<typename Derived, typename InputIterator>
5127 InputIterator Iter;
5128
5129public:
5132 typedef typename std::iterator_traits<InputIterator>::difference_type
5134 typedef std::input_iterator_tag iterator_category;
5135
5136 class pointer {
5138
5139 public:
5140 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5141
5142 const TemplateArgumentLoc *operator->() const { return &Arg; }
5143 };
5144
5146 InputIterator Iter)
5147 : Self(Self), Iter(Iter) { }
5148
5150 ++Iter;
5151 return *this;
5152 }
5153
5156 ++(*this);
5157 return Old;
5158 }
5159
5162 Self.InventTemplateArgumentLoc(*Iter, Result);
5163 return Result;
5164 }
5165
5166 pointer operator->() const { return pointer(**this); }
5167
5170 return X.Iter == Y.Iter;
5171 }
5172
5175 return X.Iter != Y.Iter;
5176 }
5177};
5178
5179template<typename Derived>
5180template<typename InputIterator>
5182 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5183 bool Uneval) {
5184 for (TemplateArgumentLoc In : llvm::make_range(First, Last)) {
5186 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5187 // Unpack argument packs, which we translate them into separate
5188 // arguments.
5189 // FIXME: We could do much better if we could guarantee that the
5190 // TemplateArgumentLocInfo for the pack expansion would be usable for
5191 // all of the template arguments in the argument pack.
5192 typedef TemplateArgumentLocInventIterator<Derived,
5194 PackLocIterator;
5195
5196 TemplateArgumentListInfo *PackOutput = &Outputs;
5198
5200 PackLocIterator(*this, In.getArgument().pack_begin()),
5201 PackLocIterator(*this, In.getArgument().pack_end()), *PackOutput,
5202 Uneval))
5203 return true;
5204
5205 continue;
5206 }
5207
5208 if (In.getArgument().isPackExpansion()) {
5209 UnexpandedInfo Info;
5210 TemplateArgumentLoc Prepared;
5211 if (getDerived().PreparePackForExpansion(In, Uneval, Prepared, Info))
5212 return true;
5213 if (!Info.Expand) {
5214 Outputs.addArgument(Prepared);
5215 continue;
5216 }
5217
5218 // The transform has determined that we should perform an elementwise
5219 // expansion of the pattern. Do so.
5220 std::optional<ForgetSubstitutionRAII> ForgetSubst;
5222 ForgetSubst.emplace(getDerived());
5223 for (unsigned I = 0; I != *Info.NumExpansions; ++I) {
5224 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5225
5227 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5228 return true;
5229
5230 if (Out.getArgument().containsUnexpandedParameterPack()) {
5231 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5232 Info.OrigNumExpansions);
5233 if (Out.getArgument().isNull())
5234 return true;
5235 }
5236
5237 Outputs.addArgument(Out);
5238 }
5239
5240 // If we're supposed to retain a pack expansion, do so by temporarily
5241 // forgetting the partially-substituted parameter pack.
5242 if (Info.RetainExpansion) {
5243 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5244
5246 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5247 return true;
5248
5249 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5250 Info.OrigNumExpansions);
5251 if (Out.getArgument().isNull())
5252 return true;
5253
5254 Outputs.addArgument(Out);
5255 }
5256
5257 continue;
5258 }
5259
5260 // The simple case:
5261 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5262 return true;
5263
5264 Outputs.addArgument(Out);
5265 }
5266
5267 return false;
5268}
5269
5270template <typename Derived>
5271template <typename InputIterator>
5273 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5274 bool Uneval) {
5275
5276 // [C++26][temp.constr.normal]
5277 // any non-dependent concept template argument
5278 // is substituted into the constraint-expression of C.
5279 auto isNonDependentConceptArgument = [](const TemplateArgument &Arg) {
5280 return !Arg.isDependent() && Arg.isConceptOrConceptTemplateParameter();
5281 };
5282
5283 for (; First != Last; ++First) {
5286
5287 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5288 typedef TemplateArgumentLocInventIterator<Derived,
5290 PackLocIterator;
5292 PackLocIterator(*this, In.getArgument().pack_begin()),
5293 PackLocIterator(*this, In.getArgument().pack_end()), Outputs,
5294 Uneval))
5295 return true;
5296 continue;
5297 }
5298
5299 if (!isNonDependentConceptArgument(In.getArgument())) {
5300 Outputs.addArgument(In);
5301 continue;
5302 }
5303
5304 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5305 return true;
5306
5307 Outputs.addArgument(Out);
5308 }
5309
5310 return false;
5311}
5312
5313// FIXME: Find ways to reduce code duplication for pack expansions.
5314template <typename Derived>
5316 bool Uneval,
5318 UnexpandedInfo &Info) {
5319 auto ComputeInfo = [this](TemplateArgumentLoc Arg,
5320 bool IsLateExpansionAttempt, UnexpandedInfo &Info,
5321 TemplateArgumentLoc &Pattern) {
5322 assert(Arg.getArgument().isPackExpansion());
5323 // We have a pack expansion, for which we will be substituting into the
5324 // pattern.
5325 Pattern = getSema().getTemplateArgumentPackExpansionPattern(
5326 Arg, Info.Ellipsis, Info.OrigNumExpansions);
5328 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5329 if (IsLateExpansionAttempt) {
5330 // Request expansion only when there is an opportunity to expand a pack
5331 // that required a substituion first.
5332 bool SawPackTypes =
5333 llvm::any_of(Unexpanded, [](UnexpandedParameterPack P) {
5334 return P.first.dyn_cast<const SubstBuiltinTemplatePackType *>();
5335 });
5336 if (!SawPackTypes) {
5337 Info.Expand = false;
5338 return false;
5339 }
5340 }
5341 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5342
5343 // Determine whether the set of unexpanded parameter packs can and
5344 // should be expanded.
5345 Info.Expand = true;
5346 Info.RetainExpansion = false;
5347 Info.NumExpansions = Info.OrigNumExpansions;
5348 return getDerived().TryExpandParameterPacks(
5349 Info.Ellipsis, Pattern.getSourceRange(), Unexpanded,
5350 /*FailOnPackProducingTemplates=*/false, Info.Expand,
5351 Info.RetainExpansion, Info.NumExpansions);
5352 };
5353
5354 TemplateArgumentLoc Pattern;
5355 if (ComputeInfo(In, false, Info, Pattern))
5356 return true;
5357
5358 if (Info.Expand) {
5359 Out = Pattern;
5360 return false;
5361 }
5362
5363 // The transform has determined that we should perform a simple
5364 // transformation on the pack expansion, producing another pack
5365 // expansion.
5366 TemplateArgumentLoc OutPattern;
5367 std::optional<Sema::ArgPackSubstIndexRAII> SubstIndex(
5368 std::in_place, getSema(), std::nullopt);
5369 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5370 return true;
5371
5372 Out = getDerived().RebuildPackExpansion(OutPattern, Info.Ellipsis,
5373 Info.NumExpansions);
5374 if (Out.getArgument().isNull())
5375 return true;
5376 SubstIndex.reset();
5377
5378 if (!OutPattern.getArgument().containsUnexpandedParameterPack())
5379 return false;
5380
5381 // Some packs will learn their length after substitution, e.g.
5382 // __builtin_dedup_pack<T,int> has size 1 or 2, depending on the substitution
5383 // value of `T`.
5384 //
5385 // We only expand after we know sizes of all packs, check if this is the case
5386 // or not. However, we avoid a full template substitution and only do
5387 // expanstions after this point.
5388
5389 // E.g. when substituting template arguments of tuple with {T -> int} in the
5390 // following example:
5391 // template <class T>
5392 // struct TupleWithInt {
5393 // using type = std::tuple<__builtin_dedup_pack<T, int>...>;
5394 // };
5395 // TupleWithInt<int>::type y;
5396 // At this point we will see the `__builtin_dedup_pack<int, int>` with a known
5397 // length and run `ComputeInfo()` to provide the necessary information to our
5398 // caller.
5399 //
5400 // Note that we may still have situations where builtin is not going to be
5401 // expanded. For example:
5402 // template <class T>
5403 // struct Foo {
5404 // template <class U> using tuple_with_t =
5405 // std::tuple<__builtin_dedup_pack<T, U, int>...>; using type =
5406 // tuple_with_t<short>;
5407 // }
5408 // Because the substitution into `type` happens in dependent context, `type`
5409 // will be `tuple<builtin_dedup_pack<T, short, int>...>` after substitution
5410 // and the caller will not be able to expand it.
5411 ForgetSubstitutionRAII ForgetSubst(getDerived());
5412 if (ComputeInfo(Out, true, Info, OutPattern))
5413 return true;
5414 if (!Info.Expand)
5415 return false;
5416 Out = OutPattern;
5417 Info.ExpandUnderForgetSubstitions = true;
5418 return false;
5419}
5420
5421//===----------------------------------------------------------------------===//
5422// Type transformation
5423//===----------------------------------------------------------------------===//
5424
5425template<typename Derived>
5428 return T;
5429
5430 // Temporary workaround. All of these transformations should
5431 // eventually turn into transformations on TypeLocs.
5432 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5434
5435 TypeSourceInfo *NewTSI = getDerived().TransformType(TSI);
5436
5437 if (!NewTSI)
5438 return QualType();
5439
5440 return NewTSI->getType();
5441}
5442
5443template <typename Derived>
5445 // Refine the base location to the type's location.
5446 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5449 return TSI;
5450
5451 TypeLocBuilder TLB;
5452
5453 TypeLoc TL = TSI->getTypeLoc();
5454 TLB.reserve(TL.getFullDataSize());
5455
5456 QualType Result = getDerived().TransformType(TLB, TL);
5457 if (Result.isNull())
5458 return nullptr;
5459
5460 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5461}
5462
5463template<typename Derived>
5466 switch (T.getTypeLocClass()) {
5467#define ABSTRACT_TYPELOC(CLASS, PARENT)
5468#define TYPELOC(CLASS, PARENT) \
5469 case TypeLoc::CLASS: \
5470 return getDerived().Transform##CLASS##Type(TLB, \
5471 T.castAs<CLASS##TypeLoc>());
5472#include "clang/AST/TypeLocNodes.def"
5473 }
5474
5475 llvm_unreachable("unhandled type loc!");
5476}
5477
5478template<typename Derived>
5480 if (!isa<DependentNameType>(T))
5481 return TransformType(T);
5482
5484 return T;
5485 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5487 TypeSourceInfo *NewTSI = getDerived().TransformTypeWithDeducedTST(TSI);
5488 return NewTSI ? NewTSI->getType() : QualType();
5489}
5490
5491template <typename Derived>
5494 if (!isa<DependentNameType>(TSI->getType()))
5495 return TransformType(TSI);
5496
5497 // Refine the base location to the type's location.
5498 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5501 return TSI;
5502
5503 TypeLocBuilder TLB;
5504
5505 TypeLoc TL = TSI->getTypeLoc();
5506 TLB.reserve(TL.getFullDataSize());
5507
5508 auto QTL = TL.getAs<QualifiedTypeLoc>();
5509 if (QTL)
5510 TL = QTL.getUnqualifiedLoc();
5511
5512 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5513
5514 QualType Result = getDerived().TransformDependentNameType(
5515 TLB, DNTL, /*DeducedTSTContext*/true);
5516 if (Result.isNull())
5517 return nullptr;
5518
5519 if (QTL) {
5520 Result = getDerived().RebuildQualifiedType(Result, QTL);
5521 if (Result.isNull())
5522 return nullptr;
5524 }
5525
5526 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5527}
5528
5529template<typename Derived>
5532 QualifiedTypeLoc T) {
5534 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5535 auto SuppressObjCLifetime =
5537 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5538 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5539 SuppressObjCLifetime);
5540 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5541 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5542 TLB, STTP, SuppressObjCLifetime);
5543 } else {
5544 Result = getDerived().TransformType(TLB, UnqualTL);
5545 }
5546
5547 if (Result.isNull())
5548 return QualType();
5549
5550 Result = getDerived().RebuildQualifiedType(Result, T);
5551
5552 if (Result.isNull())
5553 return QualType();
5554
5555 // RebuildQualifiedType might have updated the type, but not in a way
5556 // that invalidates the TypeLoc. (There's no location information for
5557 // qualifiers.)
5559
5560 return Result;
5561}
5562
5563template <typename Derived>
5565 QualifiedTypeLoc TL) {
5566
5567 SourceLocation Loc = TL.getBeginLoc();
5568 Qualifiers Quals = TL.getType().getLocalQualifiers();
5569
5570 if ((T.getAddressSpace() != LangAS::Default &&
5571 Quals.getAddressSpace() != LangAS::Default) &&
5572 T.getAddressSpace() != Quals.getAddressSpace()) {
5573 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5574 << TL.getType() << T;
5575 return QualType();
5576 }
5577
5578 PointerAuthQualifier LocalPointerAuth = Quals.getPointerAuth();
5579 if (LocalPointerAuth.isPresent()) {
5580 if (T.getPointerAuth().isPresent()) {
5581 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_redundant) << TL.getType();
5582 return QualType();
5583 }
5584 if (!T->isDependentType()) {
5585 if (!T->isSignableType(SemaRef.getASTContext())) {
5586 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_invalid_target) << T;
5587 return QualType();
5588 }
5589 }
5590 }
5591 // C++ [dcl.fct]p7:
5592 // [When] adding cv-qualifications on top of the function type [...] the
5593 // cv-qualifiers are ignored.
5594 if (T->isFunctionType()) {
5595 T = SemaRef.getASTContext().getAddrSpaceQualType(T,
5596 Quals.getAddressSpace());
5597 return T;
5598 }
5599
5600 // C++ [dcl.ref]p1:
5601 // when the cv-qualifiers are introduced through the use of a typedef-name
5602 // or decltype-specifier [...] the cv-qualifiers are ignored.
5603 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5604 // applied to a reference type.
5605 if (T->isReferenceType()) {
5606 // The only qualifier that applies to a reference type is restrict.
5607 if (!Quals.hasRestrict())
5608 return T;
5610 }
5611
5612 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5613 // resulting type.
5614 if (Quals.hasObjCLifetime()) {
5615 if (!T->isObjCLifetimeType() && !T->isDependentType())
5616 Quals.removeObjCLifetime();
5617 else if (T.getObjCLifetime()) {
5618 // Objective-C ARC:
5619 // A lifetime qualifier applied to a substituted template parameter
5620 // overrides the lifetime qualifier from the template argument.
5621 const AutoType *AutoTy;
5622 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5623 // 'auto' types behave the same way as template parameters.
5624 QualType Deduced = AutoTy->getDeducedType();
5625 Qualifiers Qs = Deduced.getQualifiers();
5626 Qs.removeObjCLifetime();
5627 Deduced =
5628 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5629 T = SemaRef.Context.getAutoType(AutoTy->getDeducedKind(), Deduced,
5630 AutoTy->getKeyword(),
5631 AutoTy->getTypeConstraintConcept(),
5632 AutoTy->getTypeConstraintArguments());
5633 } else {
5634 // Otherwise, complain about the addition of a qualifier to an
5635 // already-qualified type.
5636 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5637 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5638 Quals.removeObjCLifetime();
5639 }
5640 }
5641 }
5642
5643 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5644}
5645
5646template <typename Derived>
5647QualType TreeTransform<Derived>::TransformTypeInObjectScope(
5648 TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType,
5649 NamedDecl *FirstQualifierInScope) {
5650 assert(!getDerived().AlreadyTransformed(TL.getType()));
5651
5652 switch (TL.getTypeLocClass()) {
5653 case TypeLoc::TemplateSpecialization:
5654 return getDerived().TransformTemplateSpecializationType(
5655 TLB, TL.castAs<TemplateSpecializationTypeLoc>(), ObjectType,
5656 FirstQualifierInScope, /*AllowInjectedClassName=*/true);
5657 case TypeLoc::DependentName:
5658 return getDerived().TransformDependentNameType(
5659 TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
5660 ObjectType, FirstQualifierInScope);
5661 default:
5662 // Any dependent canonical type can appear here, through type alias
5663 // templates.
5664 return getDerived().TransformType(TLB, TL);
5665 }
5666}
5667
5668template <class TyLoc> static inline
5670 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5671 NewT.setNameLoc(T.getNameLoc());
5672 return T.getType();
5673}
5674
5675template<typename Derived>
5676QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5677 BuiltinTypeLoc T) {
5678 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5679 NewT.setBuiltinLoc(T.getBuiltinLoc());
5680 if (T.needsExtraLocalData())
5681 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5682 return T.getType();
5683}
5684
5685template<typename Derived>
5687 ComplexTypeLoc T) {
5688 // FIXME: recurse?
5689 return TransformTypeSpecType(TLB, T);
5690}
5691
5692template <typename Derived>
5694 AdjustedTypeLoc TL) {
5695 // Adjustments applied during transformation are handled elsewhere.
5696 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5697}
5698
5699template<typename Derived>
5701 DecayedTypeLoc TL) {
5702 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5703 if (OriginalType.isNull())
5704 return QualType();
5705
5706 QualType Result = TL.getType();
5707 if (getDerived().AlwaysRebuild() ||
5708 OriginalType != TL.getOriginalLoc().getType())
5709 Result = SemaRef.Context.getDecayedType(OriginalType);
5710 TLB.push<DecayedTypeLoc>(Result);
5711 // Nothing to set for DecayedTypeLoc.
5712 return Result;
5713}
5714
5715template <typename Derived>
5719 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5720 if (OriginalType.isNull())
5721 return QualType();
5722
5723 QualType Result = TL.getType();
5724 if (getDerived().AlwaysRebuild() ||
5725 OriginalType != TL.getElementLoc().getType())
5726 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5727 TLB.push<ArrayParameterTypeLoc>(Result);
5728 // Nothing to set for ArrayParameterTypeLoc.
5729 return Result;
5730}
5731
5732template<typename Derived>
5734 PointerTypeLoc TL) {
5735 QualType PointeeType
5736 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5737 if (PointeeType.isNull())
5738 return QualType();
5739
5740 QualType Result = TL.getType();
5741 if (PointeeType->getAs<ObjCObjectType>()) {
5742 // A dependent pointer type 'T *' has is being transformed such
5743 // that an Objective-C class type is being replaced for 'T'. The
5744 // resulting pointer type is an ObjCObjectPointerType, not a
5745 // PointerType.
5746 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5747
5749 NewT.setStarLoc(TL.getStarLoc());
5750 return Result;
5751 }
5752
5753 if (getDerived().AlwaysRebuild() ||
5754 PointeeType != TL.getPointeeLoc().getType()) {
5755 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5756 if (Result.isNull())
5757 return QualType();
5758 }
5759
5760 // Objective-C ARC can add lifetime qualifiers to the type that we're
5761 // pointing to.
5762 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5763
5764 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5765 NewT.setSigilLoc(TL.getSigilLoc());
5766 return Result;
5767}
5768
5769template<typename Derived>
5773 QualType PointeeType
5774 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5775 if (PointeeType.isNull())
5776 return QualType();
5777
5778 QualType Result = TL.getType();
5779 if (getDerived().AlwaysRebuild() ||
5780 PointeeType != TL.getPointeeLoc().getType()) {
5781 Result = getDerived().RebuildBlockPointerType(PointeeType,
5782 TL.getSigilLoc());
5783 if (Result.isNull())
5784 return QualType();
5785 }
5786
5788 NewT.setSigilLoc(TL.getSigilLoc());
5789 return Result;
5790}
5791
5792/// Transforms a reference type. Note that somewhat paradoxically we
5793/// don't care whether the type itself is an l-value type or an r-value
5794/// type; we only care if the type was *written* as an l-value type
5795/// or an r-value type.
5796template<typename Derived>
5799 ReferenceTypeLoc TL) {
5800 const ReferenceType *T = TL.getTypePtr();
5801
5802 // Note that this works with the pointee-as-written.
5803 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5804 if (PointeeType.isNull())
5805 return QualType();
5806
5807 QualType Result = TL.getType();
5808 if (getDerived().AlwaysRebuild() ||
5809 PointeeType != T->getPointeeTypeAsWritten()) {
5810 Result = getDerived().RebuildReferenceType(PointeeType,
5811 T->isSpelledAsLValue(),
5812 TL.getSigilLoc());
5813 if (Result.isNull())
5814 return QualType();
5815 }
5816
5817 // Objective-C ARC can add lifetime qualifiers to the type that we're
5818 // referring to.
5821
5822 // r-value references can be rebuilt as l-value references.
5823 ReferenceTypeLoc NewTL;
5825 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5826 else
5827 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5828 NewTL.setSigilLoc(TL.getSigilLoc());
5829
5830 return Result;
5831}
5832
5833template<typename Derived>
5837 return TransformReferenceType(TLB, TL);
5838}
5839
5840template<typename Derived>
5841QualType
5842TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5843 RValueReferenceTypeLoc TL) {
5844 return TransformReferenceType(TLB, TL);
5845}
5846
5847template<typename Derived>
5851 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5852 if (PointeeType.isNull())
5853 return QualType();
5854
5855 const MemberPointerType *T = TL.getTypePtr();
5856
5857 NestedNameSpecifierLoc OldQualifierLoc = TL.getQualifierLoc();
5858 NestedNameSpecifierLoc NewQualifierLoc =
5859 getDerived().TransformNestedNameSpecifierLoc(OldQualifierLoc);
5860 if (!NewQualifierLoc)
5861 return QualType();
5862
5863 CXXRecordDecl *OldCls = T->getMostRecentCXXRecordDecl(), *NewCls = nullptr;
5864 if (OldCls) {
5865 NewCls = cast_or_null<CXXRecordDecl>(
5866 getDerived().TransformDecl(TL.getStarLoc(), OldCls));
5867 if (!NewCls)
5868 return QualType();
5869 }
5870
5871 QualType Result = TL.getType();
5872 if (getDerived().AlwaysRebuild() || PointeeType != T->getPointeeType() ||
5873 NewQualifierLoc.getNestedNameSpecifier() !=
5874 OldQualifierLoc.getNestedNameSpecifier() ||
5875 NewCls != OldCls) {
5876 CXXScopeSpec SS;
5877 SS.Adopt(NewQualifierLoc);
5878 Result = getDerived().RebuildMemberPointerType(PointeeType, SS, NewCls,
5879 TL.getStarLoc());
5880 if (Result.isNull())
5881 return QualType();
5882 }
5883
5884 // If we had to adjust the pointee type when building a member pointer, make
5885 // sure to push TypeLoc info for it.
5886 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5887 if (MPT && PointeeType != MPT->getPointeeType()) {
5888 assert(isa<AdjustedType>(MPT->getPointeeType()));
5889 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5890 }
5891
5893 NewTL.setSigilLoc(TL.getSigilLoc());
5894 NewTL.setQualifierLoc(NewQualifierLoc);
5895
5896 return Result;
5897}
5898
5899template<typename Derived>
5903 const ConstantArrayType *T = TL.getTypePtr();
5904 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5905 if (ElementType.isNull())
5906 return QualType();
5907
5908 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5909 Expr *OldSize = TL.getSizeExpr();
5910 if (!OldSize)
5911 OldSize = const_cast<Expr*>(T->getSizeExpr());
5912 Expr *NewSize = nullptr;
5913 if (OldSize) {
5916 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5917 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5918 }
5919
5920 QualType Result = TL.getType();
5921 if (getDerived().AlwaysRebuild() ||
5922 ElementType != T->getElementType() ||
5923 (T->getSizeExpr() && NewSize != OldSize)) {
5924 Result = getDerived().RebuildConstantArrayType(ElementType,
5925 T->getSizeModifier(),
5926 T->getSize(), NewSize,
5927 T->getIndexTypeCVRQualifiers(),
5928 TL.getBracketsRange());
5929 if (Result.isNull())
5930 return QualType();
5931 }
5932
5933 // We might have either a ConstantArrayType or a VariableArrayType now:
5934 // a ConstantArrayType is allowed to have an element type which is a
5935 // VariableArrayType if the type is dependent. Fortunately, all array
5936 // types have the same location layout.
5937 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5938 NewTL.setLBracketLoc(TL.getLBracketLoc());
5939 NewTL.setRBracketLoc(TL.getRBracketLoc());
5940 NewTL.setSizeExpr(NewSize);
5941
5942 return Result;
5943}
5944
5945template<typename Derived>
5947 TypeLocBuilder &TLB,
5949 const IncompleteArrayType *T = TL.getTypePtr();
5950 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5951 if (ElementType.isNull())
5952 return QualType();
5953
5954 QualType Result = TL.getType();
5955 if (getDerived().AlwaysRebuild() ||
5956 ElementType != T->getElementType()) {
5957 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5958 T->getSizeModifier(),
5959 T->getIndexTypeCVRQualifiers(),
5960 TL.getBracketsRange());
5961 if (Result.isNull())
5962 return QualType();
5963 }
5964
5966 NewTL.setLBracketLoc(TL.getLBracketLoc());
5967 NewTL.setRBracketLoc(TL.getRBracketLoc());
5968 NewTL.setSizeExpr(nullptr);
5969
5970 return Result;
5971}
5972
5973template<typename Derived>
5977 const VariableArrayType *T = TL.getTypePtr();
5978 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5979 if (ElementType.isNull())
5980 return QualType();
5981
5982 ExprResult SizeResult;
5983 {
5986 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5987 }
5988 if (SizeResult.isInvalid())
5989 return QualType();
5990 SizeResult =
5991 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5992 if (SizeResult.isInvalid())
5993 return QualType();
5994
5995 Expr *Size = SizeResult.get();
5996
5997 QualType Result = TL.getType();
5998 if (getDerived().AlwaysRebuild() ||
5999 ElementType != T->getElementType() ||
6000 Size != T->getSizeExpr()) {
6001 Result = getDerived().RebuildVariableArrayType(ElementType,
6002 T->getSizeModifier(),
6003 Size,
6004 T->getIndexTypeCVRQualifiers(),
6005 TL.getBracketsRange());
6006 if (Result.isNull())
6007 return QualType();
6008 }
6009
6010 // We might have constant size array now, but fortunately it has the same
6011 // location layout.
6012 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6013 NewTL.setLBracketLoc(TL.getLBracketLoc());
6014 NewTL.setRBracketLoc(TL.getRBracketLoc());
6015 NewTL.setSizeExpr(Size);
6016
6017 return Result;
6018}
6019
6020template<typename Derived>
6024 const DependentSizedArrayType *T = TL.getTypePtr();
6025 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6026 if (ElementType.isNull())
6027 return QualType();
6028
6029 // Array bounds are constant expressions.
6032
6033 // If we have a VLA then it won't be a constant.
6034 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
6035
6036 // Prefer the expression from the TypeLoc; the other may have been uniqued.
6037 Expr *origSize = TL.getSizeExpr();
6038 if (!origSize) origSize = T->getSizeExpr();
6039
6040 ExprResult sizeResult
6041 = getDerived().TransformExpr(origSize);
6042 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
6043 if (sizeResult.isInvalid())
6044 return QualType();
6045
6046 Expr *size = sizeResult.get();
6047
6048 QualType Result = TL.getType();
6049 if (getDerived().AlwaysRebuild() ||
6050 ElementType != T->getElementType() ||
6051 size != origSize) {
6052 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
6053 T->getSizeModifier(),
6054 size,
6055 T->getIndexTypeCVRQualifiers(),
6056 TL.getBracketsRange());
6057 if (Result.isNull())
6058 return QualType();
6059 }
6060
6061 // We might have any sort of array type now, but fortunately they
6062 // all have the same location layout.
6063 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6064 NewTL.setLBracketLoc(TL.getLBracketLoc());
6065 NewTL.setRBracketLoc(TL.getRBracketLoc());
6066 NewTL.setSizeExpr(size);
6067
6068 return Result;
6069}
6070
6071template <typename Derived>
6074 const DependentVectorType *T = TL.getTypePtr();
6075 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6076 if (ElementType.isNull())
6077 return QualType();
6078
6081
6082 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6083 Size = SemaRef.ActOnConstantExpression(Size);
6084 if (Size.isInvalid())
6085 return QualType();
6086
6087 QualType Result = TL.getType();
6088 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6089 Size.get() != T->getSizeExpr()) {
6090 Result = getDerived().RebuildDependentVectorType(
6091 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
6092 if (Result.isNull())
6093 return QualType();
6094 }
6095
6096 // Result might be dependent or not.
6099 TLB.push<DependentVectorTypeLoc>(Result);
6100 NewTL.setNameLoc(TL.getNameLoc());
6101 } else {
6102 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6103 NewTL.setNameLoc(TL.getNameLoc());
6104 }
6105
6106 return Result;
6107}
6108
6109template<typename Derived>
6111 TypeLocBuilder &TLB,
6113 const DependentSizedExtVectorType *T = TL.getTypePtr();
6114
6115 // FIXME: ext vector locs should be nested
6116 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6117 if (ElementType.isNull())
6118 return QualType();
6119
6120 // Vector sizes are constant expressions.
6123
6124 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6125 Size = SemaRef.ActOnConstantExpression(Size);
6126 if (Size.isInvalid())
6127 return QualType();
6128
6129 QualType Result = TL.getType();
6130 if (getDerived().AlwaysRebuild() ||
6131 ElementType != T->getElementType() ||
6132 Size.get() != T->getSizeExpr()) {
6133 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
6134 Size.get(),
6135 T->getAttributeLoc());
6136 if (Result.isNull())
6137 return QualType();
6138 }
6139
6140 // Result might be dependent or not.
6144 NewTL.setNameLoc(TL.getNameLoc());
6145 } else {
6146 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6147 NewTL.setNameLoc(TL.getNameLoc());
6148 }
6149
6150 return Result;
6151}
6152
6153template <typename Derived>
6157 const ConstantMatrixType *T = TL.getTypePtr();
6158 QualType ElementType = getDerived().TransformType(T->getElementType());
6159 if (ElementType.isNull())
6160 return QualType();
6161
6162 QualType Result = TL.getType();
6163 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
6164 Result = getDerived().RebuildConstantMatrixType(
6165 ElementType, T->getNumRows(), T->getNumColumns());
6166 if (Result.isNull())
6167 return QualType();
6168 }
6169
6171 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6172 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6173 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
6174 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
6175
6176 return Result;
6177}
6178
6179template <typename Derived>
6182 const DependentSizedMatrixType *T = TL.getTypePtr();
6183
6184 QualType ElementType = getDerived().TransformType(T->getElementType());
6185 if (ElementType.isNull()) {
6186 return QualType();
6187 }
6188
6189 // Matrix dimensions are constant expressions.
6192
6193 Expr *origRows = TL.getAttrRowOperand();
6194 if (!origRows)
6195 origRows = T->getRowExpr();
6196 Expr *origColumns = TL.getAttrColumnOperand();
6197 if (!origColumns)
6198 origColumns = T->getColumnExpr();
6199
6200 ExprResult rowResult = getDerived().TransformExpr(origRows);
6201 rowResult = SemaRef.ActOnConstantExpression(rowResult);
6202 if (rowResult.isInvalid())
6203 return QualType();
6204
6205 ExprResult columnResult = getDerived().TransformExpr(origColumns);
6206 columnResult = SemaRef.ActOnConstantExpression(columnResult);
6207 if (columnResult.isInvalid())
6208 return QualType();
6209
6210 Expr *rows = rowResult.get();
6211 Expr *columns = columnResult.get();
6212
6213 QualType Result = TL.getType();
6214 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6215 rows != origRows || columns != origColumns) {
6216 Result = getDerived().RebuildDependentSizedMatrixType(
6217 ElementType, rows, columns, T->getAttributeLoc());
6218
6219 if (Result.isNull())
6220 return QualType();
6221 }
6222
6223 // We might have any sort of matrix type now, but fortunately they
6224 // all have the same location layout.
6225 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
6226 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6227 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6228 NewTL.setAttrRowOperand(rows);
6229 NewTL.setAttrColumnOperand(columns);
6230 return Result;
6231}
6232
6233template <typename Derived>
6236 const DependentAddressSpaceType *T = TL.getTypePtr();
6237
6238 QualType pointeeType =
6239 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
6240
6241 if (pointeeType.isNull())
6242 return QualType();
6243
6244 // Address spaces are constant expressions.
6247
6248 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
6249 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
6250 if (AddrSpace.isInvalid())
6251 return QualType();
6252
6253 QualType Result = TL.getType();
6254 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
6255 AddrSpace.get() != T->getAddrSpaceExpr()) {
6256 Result = getDerived().RebuildDependentAddressSpaceType(
6257 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6258 if (Result.isNull())
6259 return QualType();
6260 }
6261
6262 // Result might be dependent or not.
6266
6267 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6268 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6269 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6270
6271 } else {
6272 TLB.TypeWasModifiedSafely(Result);
6273 }
6274
6275 return Result;
6276}
6277
6278template <typename Derived>
6280 VectorTypeLoc TL) {
6281 const VectorType *T = TL.getTypePtr();
6282 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6283 if (ElementType.isNull())
6284 return QualType();
6285
6286 QualType Result = TL.getType();
6287 if (getDerived().AlwaysRebuild() ||
6288 ElementType != T->getElementType()) {
6289 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6290 T->getVectorKind());
6291 if (Result.isNull())
6292 return QualType();
6293 }
6294
6295 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6296 NewTL.setNameLoc(TL.getNameLoc());
6297
6298 return Result;
6299}
6300
6301template<typename Derived>
6303 ExtVectorTypeLoc TL) {
6304 const VectorType *T = TL.getTypePtr();
6305 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6306 if (ElementType.isNull())
6307 return QualType();
6308
6309 QualType Result = TL.getType();
6310 if (getDerived().AlwaysRebuild() ||
6311 ElementType != T->getElementType()) {
6312 Result = getDerived().RebuildExtVectorType(ElementType,
6313 T->getNumElements(),
6314 /*FIXME*/ SourceLocation());
6315 if (Result.isNull())
6316 return QualType();
6317 }
6318
6319 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6320 NewTL.setNameLoc(TL.getNameLoc());
6321
6322 return Result;
6323}
6324
6325template <typename Derived>
6327 ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions,
6328 bool ExpectParameterPack) {
6329 TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
6330 TypeSourceInfo *NewTSI = nullptr;
6331
6332 if (NumExpansions && isa<PackExpansionType>(OldTSI->getType())) {
6333 // If we're substituting into a pack expansion type and we know the
6334 // length we want to expand to, just substitute for the pattern.
6335 TypeLoc OldTL = OldTSI->getTypeLoc();
6336 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6337
6338 TypeLocBuilder TLB;
6339 TypeLoc NewTL = OldTSI->getTypeLoc();
6340 TLB.reserve(NewTL.getFullDataSize());
6341
6342 QualType Result = getDerived().TransformType(TLB,
6343 OldExpansionTL.getPatternLoc());
6344 if (Result.isNull())
6345 return nullptr;
6346
6348 OldExpansionTL.getPatternLoc().getSourceRange(),
6349 OldExpansionTL.getEllipsisLoc(),
6350 NumExpansions);
6351 if (Result.isNull())
6352 return nullptr;
6353
6354 PackExpansionTypeLoc NewExpansionTL
6355 = TLB.push<PackExpansionTypeLoc>(Result);
6356 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6357 NewTSI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6358 } else
6359 NewTSI = getDerived().TransformType(OldTSI);
6360 if (!NewTSI)
6361 return nullptr;
6362
6363 if (NewTSI == OldTSI && indexAdjustment == 0)
6364 return OldParm;
6365
6367 SemaRef.Context, OldParm->getDeclContext(), OldParm->getInnerLocStart(),
6368 OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
6369 NewTSI, OldParm->getStorageClass(),
6370 /* DefArg */ nullptr);
6371 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6372 OldParm->getFunctionScopeIndex() + indexAdjustment);
6373 getDerived().transformedLocalDecl(OldParm, {newParm});
6374 return newParm;
6375}
6376
6377template <typename Derived>
6380 const QualType *ParamTypes,
6381 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6382 SmallVectorImpl<QualType> &OutParamTypes,
6385 unsigned *LastParamTransformed) {
6386 int indexAdjustment = 0;
6387
6388 unsigned NumParams = Params.size();
6389 for (unsigned i = 0; i != NumParams; ++i) {
6390 if (LastParamTransformed)
6391 *LastParamTransformed = i;
6392 if (ParmVarDecl *OldParm = Params[i]) {
6393 assert(OldParm->getFunctionScopeIndex() == i);
6394
6395 UnsignedOrNone NumExpansions = std::nullopt;
6396 ParmVarDecl *NewParm = nullptr;
6397 if (OldParm->isParameterPack()) {
6398 // We have a function parameter pack that may need to be expanded.
6400
6401 // Find the parameter packs that could be expanded.
6402 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6404 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6405 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6406
6407 // Determine whether we should expand the parameter packs.
6408 bool ShouldExpand = false;
6409 bool RetainExpansion = false;
6410 UnsignedOrNone OrigNumExpansions = std::nullopt;
6411 if (Unexpanded.size() > 0) {
6412 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6413 NumExpansions = OrigNumExpansions;
6415 ExpansionTL.getEllipsisLoc(), Pattern.getSourceRange(),
6416 Unexpanded, /*FailOnPackProducingTemplates=*/true,
6417 ShouldExpand, RetainExpansion, NumExpansions)) {
6418 return true;
6419 }
6420 } else {
6421#ifndef NDEBUG
6422 const AutoType *AT =
6423 Pattern.getType().getTypePtr()->getContainedAutoType();
6424 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6425 "Could not find parameter packs or undeduced auto type!");
6426#endif
6427 }
6428
6429 if (ShouldExpand) {
6430 // Expand the function parameter pack into multiple, separate
6431 // parameters.
6432 getDerived().ExpandingFunctionParameterPack(OldParm);
6433 for (unsigned I = 0; I != *NumExpansions; ++I) {
6434 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6435 ParmVarDecl *NewParm
6436 = getDerived().TransformFunctionTypeParam(OldParm,
6437 indexAdjustment++,
6438 OrigNumExpansions,
6439 /*ExpectParameterPack=*/false);
6440 if (!NewParm)
6441 return true;
6442
6443 if (ParamInfos)
6444 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6445 OutParamTypes.push_back(NewParm->getType());
6446 if (PVars)
6447 PVars->push_back(NewParm);
6448 }
6449
6450 // If we're supposed to retain a pack expansion, do so by temporarily
6451 // forgetting the partially-substituted parameter pack.
6452 if (RetainExpansion) {
6453 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6454 ParmVarDecl *NewParm
6455 = getDerived().TransformFunctionTypeParam(OldParm,
6456 indexAdjustment++,
6457 OrigNumExpansions,
6458 /*ExpectParameterPack=*/false);
6459 if (!NewParm)
6460 return true;
6461
6462 if (ParamInfos)
6463 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6464 OutParamTypes.push_back(NewParm->getType());
6465 if (PVars)
6466 PVars->push_back(NewParm);
6467 }
6468
6469 // The next parameter should have the same adjustment as the
6470 // last thing we pushed, but we post-incremented indexAdjustment
6471 // on every push. Also, if we push nothing, the adjustment should
6472 // go down by one.
6473 indexAdjustment--;
6474
6475 // We're done with the pack expansion.
6476 continue;
6477 }
6478
6479 // We'll substitute the parameter now without expanding the pack
6480 // expansion.
6481 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6482 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6483 indexAdjustment,
6484 NumExpansions,
6485 /*ExpectParameterPack=*/true);
6486 assert(NewParm->isParameterPack() &&
6487 "Parameter pack no longer a parameter pack after "
6488 "transformation.");
6489 } else {
6490 NewParm = getDerived().TransformFunctionTypeParam(
6491 OldParm, indexAdjustment, std::nullopt,
6492 /*ExpectParameterPack=*/false);
6493 }
6494
6495 if (!NewParm)
6496 return true;
6497
6498 if (ParamInfos)
6499 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6500 OutParamTypes.push_back(NewParm->getType());
6501 if (PVars)
6502 PVars->push_back(NewParm);
6503 continue;
6504 }
6505
6506 // Deal with the possibility that we don't have a parameter
6507 // declaration for this parameter.
6508 assert(ParamTypes);
6509 QualType OldType = ParamTypes[i];
6510 bool IsPackExpansion = false;
6511 UnsignedOrNone NumExpansions = std::nullopt;
6512 QualType NewType;
6513 if (const PackExpansionType *Expansion
6514 = dyn_cast<PackExpansionType>(OldType)) {
6515 // We have a function parameter pack that may need to be expanded.
6516 QualType Pattern = Expansion->getPattern();
6518 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6519
6520 // Determine whether we should expand the parameter packs.
6521 bool ShouldExpand = false;
6522 bool RetainExpansion = false;
6524 Loc, SourceRange(), Unexpanded,
6525 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
6526 RetainExpansion, NumExpansions)) {
6527 return true;
6528 }
6529
6530 if (ShouldExpand) {
6531 // Expand the function parameter pack into multiple, separate
6532 // parameters.
6533 for (unsigned I = 0; I != *NumExpansions; ++I) {
6534 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6535 QualType NewType = getDerived().TransformType(Pattern);
6536 if (NewType.isNull())
6537 return true;
6538
6539 if (NewType->containsUnexpandedParameterPack()) {
6540 NewType = getSema().getASTContext().getPackExpansionType(
6541 NewType, std::nullopt);
6542
6543 if (NewType.isNull())
6544 return true;
6545 }
6546
6547 if (ParamInfos)
6548 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6549 OutParamTypes.push_back(NewType);
6550 if (PVars)
6551 PVars->push_back(nullptr);
6552 }
6553
6554 // We're done with the pack expansion.
6555 continue;
6556 }
6557
6558 // If we're supposed to retain a pack expansion, do so by temporarily
6559 // forgetting the partially-substituted parameter pack.
6560 if (RetainExpansion) {
6561 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6562 QualType NewType = getDerived().TransformType(Pattern);
6563 if (NewType.isNull())
6564 return true;
6565
6566 if (ParamInfos)
6567 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6568 OutParamTypes.push_back(NewType);
6569 if (PVars)
6570 PVars->push_back(nullptr);
6571 }
6572
6573 // We'll substitute the parameter now without expanding the pack
6574 // expansion.
6575 OldType = Expansion->getPattern();
6576 IsPackExpansion = true;
6577 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6578 NewType = getDerived().TransformType(OldType);
6579 } else {
6580 NewType = getDerived().TransformType(OldType);
6581 }
6582
6583 if (NewType.isNull())
6584 return true;
6585
6586 if (IsPackExpansion)
6587 NewType = getSema().Context.getPackExpansionType(NewType,
6588 NumExpansions);
6589
6590 if (ParamInfos)
6591 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6592 OutParamTypes.push_back(NewType);
6593 if (PVars)
6594 PVars->push_back(nullptr);
6595 }
6596
6597#ifndef NDEBUG
6598 if (PVars) {
6599 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6600 if (ParmVarDecl *parm = (*PVars)[i])
6601 assert(parm->getFunctionScopeIndex() == i);
6602 }
6603#endif
6604
6605 return false;
6606}
6607
6608template<typename Derived>
6612 SmallVector<QualType, 4> ExceptionStorage;
6613 return getDerived().TransformFunctionProtoType(
6614 TLB, TL, nullptr, Qualifiers(),
6615 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6616 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6617 ExceptionStorage, Changed);
6618 });
6619}
6620
6621template<typename Derived> template<typename Fn>
6623 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6624 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6625
6626 // Transform the parameters and return type.
6627 //
6628 // We are required to instantiate the params and return type in source order.
6629 // When the function has a trailing return type, we instantiate the
6630 // parameters before the return type, since the return type can then refer
6631 // to the parameters themselves (via decltype, sizeof, etc.).
6632 //
6633 SmallVector<QualType, 4> ParamTypes;
6635 Sema::ExtParameterInfoBuilder ExtParamInfos;
6636 const FunctionProtoType *T = TL.getTypePtr();
6637
6638 QualType ResultType;
6639
6640 if (T->hasTrailingReturn()) {
6642 TL.getBeginLoc(), TL.getParams(),
6644 T->getExtParameterInfosOrNull(),
6645 ParamTypes, &ParamDecls, ExtParamInfos))
6646 return QualType();
6647
6648 {
6649 // C++11 [expr.prim.general]p3:
6650 // If a declaration declares a member function or member function
6651 // template of a class X, the expression this is a prvalue of type
6652 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6653 // and the end of the function-definition, member-declarator, or
6654 // declarator.
6655 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6656 Sema::CXXThisScopeRAII ThisScope(
6657 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6658
6659 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6660 if (ResultType.isNull())
6661 return QualType();
6662 }
6663 }
6664 else {
6665 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6666 if (ResultType.isNull())
6667 return QualType();
6668
6670 TL.getBeginLoc(), TL.getParams(),
6672 T->getExtParameterInfosOrNull(),
6673 ParamTypes, &ParamDecls, ExtParamInfos))
6674 return QualType();
6675 }
6676
6677 FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
6678
6679 bool EPIChanged = false;
6680 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6681 return QualType();
6682
6683 // Handle extended parameter information.
6684 if (auto NewExtParamInfos =
6685 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6686 if (!EPI.ExtParameterInfos ||
6688 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6689 EPIChanged = true;
6690 }
6691 EPI.ExtParameterInfos = NewExtParamInfos;
6692 } else if (EPI.ExtParameterInfos) {
6693 EPIChanged = true;
6694 EPI.ExtParameterInfos = nullptr;
6695 }
6696
6697 // Transform any function effects with unevaluated conditions.
6698 // Hold this set in a local for the rest of this function, since EPI
6699 // may need to hold a FunctionEffectsRef pointing into it.
6700 std::optional<FunctionEffectSet> NewFX;
6701 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6702 NewFX.emplace();
6705
6706 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6707 FunctionEffectWithCondition NewEC = PrevEC;
6708 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6709 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6710 if (NewExpr.isInvalid())
6711 return QualType();
6712 std::optional<FunctionEffectMode> Mode =
6713 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6714 if (!Mode)
6715 return QualType();
6716
6717 // The condition expression has been transformed, and re-evaluated.
6718 // It may or may not have become constant.
6719 switch (*Mode) {
6721 NewEC.Cond = {};
6722 break;
6724 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6725 NewEC.Cond = {};
6726 break;
6728 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6729 break;
6731 llvm_unreachable(
6732 "FunctionEffectMode::None shouldn't be possible here");
6733 }
6734 }
6735 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6736 TL.getBeginLoc())) {
6738 NewFX->insert(NewEC, Errs);
6739 assert(Errs.empty());
6740 }
6741 }
6742 EPI.FunctionEffects = *NewFX;
6743 EPIChanged = true;
6744 }
6745
6746 QualType Result = TL.getType();
6747 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6748 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6749 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6750 if (Result.isNull())
6751 return QualType();
6752 }
6753
6756 NewTL.setLParenLoc(TL.getLParenLoc());
6757 NewTL.setRParenLoc(TL.getRParenLoc());
6760 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6761 NewTL.setParam(i, ParamDecls[i]);
6762
6763 return Result;
6764}
6765
6766template<typename Derived>
6769 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6770 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6771
6772 // Instantiate a dynamic noexcept expression, if any.
6773 if (isComputedNoexcept(ESI.Type)) {
6774 // Update this scrope because ContextDecl in Sema will be used in
6775 // TransformExpr.
6776 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6777 Sema::CXXThisScopeRAII ThisScope(
6778 SemaRef, Method ? Method->getParent() : nullptr,
6779 Method ? Method->getMethodQualifiers() : Qualifiers{},
6780 Method != nullptr);
6783 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6784 if (NoexceptExpr.isInvalid())
6785 return true;
6786
6788 NoexceptExpr =
6789 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6790 if (NoexceptExpr.isInvalid())
6791 return true;
6792
6793 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6794 Changed = true;
6795 ESI.NoexceptExpr = NoexceptExpr.get();
6796 ESI.Type = EST;
6797 }
6798
6799 if (ESI.Type != EST_Dynamic)
6800 return false;
6801
6802 // Instantiate a dynamic exception specification's type.
6803 for (QualType T : ESI.Exceptions) {
6804 if (const PackExpansionType *PackExpansion =
6805 T->getAs<PackExpansionType>()) {
6806 Changed = true;
6807
6808 // We have a pack expansion. Instantiate it.
6810 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6811 Unexpanded);
6812 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6813
6814 // Determine whether the set of unexpanded parameter packs can and
6815 // should
6816 // be expanded.
6817 bool Expand = false;
6818 bool RetainExpansion = false;
6819 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
6820 // FIXME: Track the location of the ellipsis (and track source location
6821 // information for the types in the exception specification in general).
6823 Loc, SourceRange(), Unexpanded,
6824 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
6825 NumExpansions))
6826 return true;
6827
6828 if (!Expand) {
6829 // We can't expand this pack expansion into separate arguments yet;
6830 // just substitute into the pattern and create a new pack expansion
6831 // type.
6832 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6833 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6834 if (U.isNull())
6835 return true;
6836
6837 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6838 Exceptions.push_back(U);
6839 continue;
6840 }
6841
6842 // Substitute into the pack expansion pattern for each slice of the
6843 // pack.
6844 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6845 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
6846
6847 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6848 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6849 return true;
6850
6851 Exceptions.push_back(U);
6852 }
6853 } else {
6854 QualType U = getDerived().TransformType(T);
6855 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6856 return true;
6857 if (T != U)
6858 Changed = true;
6859
6860 Exceptions.push_back(U);
6861 }
6862 }
6863
6864 ESI.Exceptions = Exceptions;
6865 if (ESI.Exceptions.empty())
6866 ESI.Type = EST_DynamicNone;
6867 return false;
6868}
6869
6870template<typename Derived>
6872 TypeLocBuilder &TLB,
6874 const FunctionNoProtoType *T = TL.getTypePtr();
6875 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6876 if (ResultType.isNull())
6877 return QualType();
6878
6879 QualType Result = TL.getType();
6880 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6881 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6882
6885 NewTL.setLParenLoc(TL.getLParenLoc());
6886 NewTL.setRParenLoc(TL.getRParenLoc());
6888
6889 return Result;
6890}
6891
6892template <typename Derived>
6893QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6894 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6895
6896 const UnresolvedUsingType *T = TL.getTypePtr();
6897 bool Changed = false;
6898
6899 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6900 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6901 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6902 if (!QualifierLoc)
6903 return QualType();
6904 Changed |= QualifierLoc != OldQualifierLoc;
6905 }
6906
6907 auto *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6908 if (!D)
6909 return QualType();
6910 Changed |= D != T->getDecl();
6911
6912 QualType Result = TL.getType();
6913 if (getDerived().AlwaysRebuild() || Changed) {
6914 Result = getDerived().RebuildUnresolvedUsingType(
6915 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TL.getNameLoc(),
6916 D);
6917 if (Result.isNull())
6918 return QualType();
6919 }
6920
6922 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6923 QualifierLoc, TL.getNameLoc());
6924 else
6925 TLB.push<UnresolvedUsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6926 QualifierLoc, TL.getNameLoc());
6927 return Result;
6928}
6929
6930template <typename Derived>
6932 UsingTypeLoc TL) {
6933 const UsingType *T = TL.getTypePtr();
6934 bool Changed = false;
6935
6936 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6937 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6938 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6939 if (!QualifierLoc)
6940 return QualType();
6941 Changed |= QualifierLoc != OldQualifierLoc;
6942 }
6943
6944 auto *D = cast_or_null<UsingShadowDecl>(
6945 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6946 if (!D)
6947 return QualType();
6948 Changed |= D != T->getDecl();
6949
6950 QualType UnderlyingType = getDerived().TransformType(T->desugar());
6951 if (UnderlyingType.isNull())
6952 return QualType();
6953 Changed |= UnderlyingType != T->desugar();
6954
6955 QualType Result = TL.getType();
6956 if (getDerived().AlwaysRebuild() || Changed) {
6957 Result = getDerived().RebuildUsingType(
6958 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), D,
6959 UnderlyingType);
6960 if (Result.isNull())
6961 return QualType();
6962 }
6963 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(), QualifierLoc,
6964 TL.getNameLoc());
6965 return Result;
6966}
6967
6968template<typename Derived>
6970 TypedefTypeLoc TL) {
6971 const TypedefType *T = TL.getTypePtr();
6972 bool Changed = false;
6973
6974 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6975 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6976 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6977 if (!QualifierLoc)
6978 return QualType();
6979 Changed |= QualifierLoc != OldQualifierLoc;
6980 }
6981
6982 auto *Typedef = cast_or_null<TypedefNameDecl>(
6983 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6984 if (!Typedef)
6985 return QualType();
6986 Changed |= Typedef != T->getDecl();
6987
6988 // FIXME: Transform the UnderlyingType if different from decl.
6989
6990 QualType Result = TL.getType();
6991 if (getDerived().AlwaysRebuild() || Changed) {
6992 Result = getDerived().RebuildTypedefType(
6993 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), Typedef);
6994 if (Result.isNull())
6995 return QualType();
6996 }
6997
6998 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6999 QualifierLoc, TL.getNameLoc());
7000 return Result;
7001}
7002
7003template<typename Derived>
7005 TypeOfExprTypeLoc TL) {
7006 // typeof expressions are not potentially evaluated contexts
7010
7011 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
7012 if (E.isInvalid())
7013 return QualType();
7014
7015 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
7016 if (E.isInvalid())
7017 return QualType();
7018
7019 QualType Result = TL.getType();
7021 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
7022 Result =
7023 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
7024 if (Result.isNull())
7025 return QualType();
7026 }
7027
7028 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
7029 NewTL.setTypeofLoc(TL.getTypeofLoc());
7030 NewTL.setLParenLoc(TL.getLParenLoc());
7031 NewTL.setRParenLoc(TL.getRParenLoc());
7032
7033 return Result;
7034}
7035
7036template<typename Derived>
7038 TypeOfTypeLoc TL) {
7039 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
7040 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
7041 if (!New_Under_TI)
7042 return QualType();
7043
7044 QualType Result = TL.getType();
7045 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
7046 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
7047 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
7048 if (Result.isNull())
7049 return QualType();
7050 }
7051
7052 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
7053 NewTL.setTypeofLoc(TL.getTypeofLoc());
7054 NewTL.setLParenLoc(TL.getLParenLoc());
7055 NewTL.setRParenLoc(TL.getRParenLoc());
7056 NewTL.setUnmodifiedTInfo(New_Under_TI);
7057
7058 return Result;
7059}
7060
7061template<typename Derived>
7063 DecltypeTypeLoc TL) {
7064 const DecltypeType *T = TL.getTypePtr();
7065
7066 // decltype expressions are not potentially evaluated contexts
7070
7071 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
7072 if (E.isInvalid())
7073 return QualType();
7074
7075 E = getSema().ActOnDecltypeExpression(E.get());
7076 if (E.isInvalid())
7077 return QualType();
7078
7079 QualType Result = TL.getType();
7080 if (getDerived().AlwaysRebuild() ||
7081 E.get() != T->getUnderlyingExpr()) {
7082 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
7083 if (Result.isNull())
7084 return QualType();
7085 }
7086 else E.get();
7087
7088 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
7089 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
7090 NewTL.setRParenLoc(TL.getRParenLoc());
7091 return Result;
7092}
7093
7094template <typename Derived>
7098 // Transform the index
7099 ExprResult IndexExpr;
7100 {
7101 EnterExpressionEvaluationContext ConstantContext(
7103
7104 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
7105 if (IndexExpr.isInvalid())
7106 return QualType();
7107 }
7108 QualType Pattern = TL.getPattern();
7109
7110 const PackIndexingType *PIT = TL.getTypePtr();
7111 SmallVector<QualType, 5> SubtitutedTypes;
7112 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
7113
7114 bool NotYetExpanded = Types.empty();
7115 bool FullySubstituted = true;
7116
7117 if (Types.empty() && !PIT->expandsToEmptyPack())
7118 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
7119
7120 for (QualType T : Types) {
7121 if (!T->containsUnexpandedParameterPack()) {
7122 QualType Transformed = getDerived().TransformType(T);
7123 if (Transformed.isNull())
7124 return QualType();
7125 SubtitutedTypes.push_back(Transformed);
7126 continue;
7127 }
7128
7130 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
7131 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7132 // Determine whether the set of unexpanded parameter packs can and should
7133 // be expanded.
7134 bool ShouldExpand = true;
7135 bool RetainExpansion = false;
7136 UnsignedOrNone NumExpansions = std::nullopt;
7137 if (getDerived().TryExpandParameterPacks(
7138 TL.getEllipsisLoc(), SourceRange(), Unexpanded,
7139 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
7140 RetainExpansion, NumExpansions))
7141 return QualType();
7142 if (!ShouldExpand) {
7143 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7144 // FIXME: should we keep TypeLoc for individual expansions in
7145 // PackIndexingTypeLoc?
7146 TypeSourceInfo *TI =
7147 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
7148 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
7149 if (Pack.isNull())
7150 return QualType();
7151 if (NotYetExpanded) {
7152 FullySubstituted = false;
7153 QualType Out = getDerived().RebuildPackIndexingType(
7154 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7155 FullySubstituted);
7156 if (Out.isNull())
7157 return QualType();
7158
7160 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7161 return Out;
7162 }
7163 SubtitutedTypes.push_back(Pack);
7164 continue;
7165 }
7166 for (unsigned I = 0; I != *NumExpansions; ++I) {
7167 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
7168 QualType Out = getDerived().TransformType(T);
7169 if (Out.isNull())
7170 return QualType();
7171 SubtitutedTypes.push_back(Out);
7172 FullySubstituted &= !Out->containsUnexpandedParameterPack();
7173 }
7174 // If we're supposed to retain a pack expansion, do so by temporarily
7175 // forgetting the partially-substituted parameter pack.
7176 if (RetainExpansion) {
7177 FullySubstituted = false;
7178 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
7179 QualType Out = getDerived().TransformType(T);
7180 if (Out.isNull())
7181 return QualType();
7182 SubtitutedTypes.push_back(Out);
7183 }
7184 }
7185
7186 // A pack indexing type can appear in a larger pack expansion,
7187 // e.g. `Pack...[pack_of_indexes]...`
7188 // so we need to temporarily disable substitution of pack elements
7189 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7190 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
7191
7192 QualType Out = getDerived().RebuildPackIndexingType(
7193 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7194 FullySubstituted, SubtitutedTypes);
7195 if (Out.isNull())
7196 return Out;
7197
7199 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7200 return Out;
7201}
7202
7203template<typename Derived>
7205 TypeLocBuilder &TLB,
7207 QualType Result = TL.getType();
7208 TypeSourceInfo *NewBaseTSI = TL.getUnderlyingTInfo();
7209 if (Result->isDependentType()) {
7210 const UnaryTransformType *T = TL.getTypePtr();
7211
7212 NewBaseTSI = getDerived().TransformType(TL.getUnderlyingTInfo());
7213 if (!NewBaseTSI)
7214 return QualType();
7215 QualType NewBase = NewBaseTSI->getType();
7216
7217 Result = getDerived().RebuildUnaryTransformType(NewBase,
7218 T->getUTTKind(),
7219 TL.getKWLoc());
7220 if (Result.isNull())
7221 return QualType();
7222 }
7223
7225 NewTL.setKWLoc(TL.getKWLoc());
7226 NewTL.setParensRange(TL.getParensRange());
7227 NewTL.setUnderlyingTInfo(NewBaseTSI);
7228 return Result;
7229}
7230
7231template<typename Derived>
7234 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
7235
7236 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7237 TemplateName TemplateName = getDerived().TransformTemplateName(
7238 QualifierLoc, /*TemplateKELoc=*/SourceLocation(), T->getTemplateName(),
7239 TL.getTemplateNameLoc());
7240 if (TemplateName.isNull())
7241 return QualType();
7242
7243 QualType OldDeduced = T->getDeducedType();
7244 QualType NewDeduced;
7245 if (!OldDeduced.isNull()) {
7246 NewDeduced = getDerived().TransformType(OldDeduced);
7247 if (NewDeduced.isNull())
7248 return QualType();
7249 }
7250
7251 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
7252 NewDeduced.isNull() ? DeducedKind::Undeduced : DeducedKind::Deduced,
7253 NewDeduced, T->getKeyword(), TemplateName);
7254 if (Result.isNull())
7255 return QualType();
7256
7257 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7258 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7259 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7260 NewTL.setQualifierLoc(QualifierLoc);
7261 return Result;
7262}
7263
7264template <typename Derived>
7266 TagTypeLoc TL) {
7267 const TagType *T = TL.getTypePtr();
7268
7269 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7270 if (QualifierLoc) {
7271 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7272 if (!QualifierLoc)
7273 return QualType();
7274 }
7275
7276 auto *TD = cast_or_null<TagDecl>(
7277 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7278 if (!TD)
7279 return QualType();
7280
7281 QualType Result = TL.getType();
7282 if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() ||
7283 TD != T->getDecl()) {
7284 if (T->isCanonicalUnqualified())
7285 Result = getDerived().RebuildCanonicalTagType(TD);
7286 else
7287 Result = getDerived().RebuildTagType(
7288 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TD);
7289 if (Result.isNull())
7290 return QualType();
7291 }
7292
7293 TagTypeLoc NewTL = TLB.push<TagTypeLoc>(Result);
7295 NewTL.setQualifierLoc(QualifierLoc);
7296 NewTL.setNameLoc(TL.getNameLoc());
7297
7298 return Result;
7299}
7300
7301template <typename Derived>
7303 EnumTypeLoc TL) {
7304 return getDerived().TransformTagType(TLB, TL);
7305}
7306
7307template <typename Derived>
7308QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
7309 RecordTypeLoc TL) {
7310 return getDerived().TransformTagType(TLB, TL);
7311}
7312
7313template<typename Derived>
7315 TypeLocBuilder &TLB,
7317 return getDerived().TransformTagType(TLB, TL);
7318}
7319
7320template<typename Derived>
7322 TypeLocBuilder &TLB,
7324 return getDerived().TransformTemplateTypeParmType(
7325 TLB, TL,
7326 /*SuppressObjCLifetime=*/false);
7327}
7328
7329template <typename Derived>
7331 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7332 return TransformTypeSpecType(TLB, TL);
7333}
7334
7335template<typename Derived>
7336QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7337 TypeLocBuilder &TLB,
7338 SubstTemplateTypeParmTypeLoc TL) {
7339 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7340
7341 Decl *NewReplaced =
7342 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7343
7344 // Substitute into the replacement type, which itself might involve something
7345 // that needs to be transformed. This only tends to occur with default
7346 // template arguments of template template parameters.
7347 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7348 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7349 if (Replacement.isNull())
7350 return QualType();
7351
7352 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7353 Replacement, NewReplaced, T->getIndex(), T->getPackIndex(),
7354 T->getFinal());
7355
7356 // Propagate type-source information.
7357 SubstTemplateTypeParmTypeLoc NewTL
7358 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7359 NewTL.setNameLoc(TL.getNameLoc());
7360 return Result;
7361
7362}
7363template <typename Derived>
7366 return TransformTypeSpecType(TLB, TL);
7367}
7368
7369template<typename Derived>
7371 TypeLocBuilder &TLB,
7373 return getDerived().TransformSubstTemplateTypeParmPackType(
7374 TLB, TL, /*SuppressObjCLifetime=*/false);
7375}
7376
7377template <typename Derived>
7380 return TransformTypeSpecType(TLB, TL);
7381}
7382
7383template<typename Derived>
7384QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
7385 AtomicTypeLoc TL) {
7386 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7387 if (ValueType.isNull())
7388 return QualType();
7389
7390 QualType Result = TL.getType();
7391 if (getDerived().AlwaysRebuild() ||
7392 ValueType != TL.getValueLoc().getType()) {
7393 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7394 if (Result.isNull())
7395 return QualType();
7396 }
7397
7398 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7399 NewTL.setKWLoc(TL.getKWLoc());
7400 NewTL.setLParenLoc(TL.getLParenLoc());
7401 NewTL.setRParenLoc(TL.getRParenLoc());
7402
7403 return Result;
7404}
7405
7406template <typename Derived>
7408 PipeTypeLoc TL) {
7409 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7410 if (ValueType.isNull())
7411 return QualType();
7412
7413 QualType Result = TL.getType();
7414 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7415 const PipeType *PT = Result->castAs<PipeType>();
7416 bool isReadPipe = PT->isReadOnly();
7417 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7418 if (Result.isNull())
7419 return QualType();
7420 }
7421
7422 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7423 NewTL.setKWLoc(TL.getKWLoc());
7424
7425 return Result;
7426}
7427
7428template <typename Derived>
7430 BitIntTypeLoc TL) {
7431 const BitIntType *EIT = TL.getTypePtr();
7432 QualType Result = TL.getType();
7433
7434 if (getDerived().AlwaysRebuild()) {
7435 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7436 EIT->getNumBits(), TL.getNameLoc());
7437 if (Result.isNull())
7438 return QualType();
7439 }
7440
7441 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7442 NewTL.setNameLoc(TL.getNameLoc());
7443 return Result;
7444}
7445
7446template <typename Derived>
7449 const DependentBitIntType *EIT = TL.getTypePtr();
7450
7453 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7454 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7455
7456 if (BitsExpr.isInvalid())
7457 return QualType();
7458
7459 QualType Result = TL.getType();
7460
7461 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7462 Result = getDerived().RebuildDependentBitIntType(
7463 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7464
7465 if (Result.isNull())
7466 return QualType();
7467 }
7468
7471 NewTL.setNameLoc(TL.getNameLoc());
7472 } else {
7473 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7474 NewTL.setNameLoc(TL.getNameLoc());
7475 }
7476 return Result;
7477}
7478
7479template <typename Derived>
7482 llvm_unreachable("This type does not need to be transformed.");
7483}
7484
7485 /// Simple iterator that traverses the template arguments in a
7486 /// container that provides a \c getArgLoc() member function.
7487 ///
7488 /// This iterator is intended to be used with the iterator form of
7489 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7490 template<typename ArgLocContainer>
7492 ArgLocContainer *Container;
7493 unsigned Index;
7494
7495 public:
7498 typedef int difference_type;
7499 typedef std::input_iterator_tag iterator_category;
7500
7501 class pointer {
7503
7504 public:
7505 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7506
7508 return &Arg;
7509 }
7510 };
7511
7512
7514
7515 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7516 unsigned Index)
7517 : Container(&Container), Index(Index) { }
7518
7520 ++Index;
7521 return *this;
7522 }
7523
7526 ++(*this);
7527 return Old;
7528 }
7529
7531 return Container->getArgLoc(Index);
7532 }
7533
7535 return pointer(Container->getArgLoc(Index));
7536 }
7537
7540 return X.Container == Y.Container && X.Index == Y.Index;
7541 }
7542
7545 return !(X == Y);
7546 }
7547 };
7548
7549template<typename Derived>
7550QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7551 AutoTypeLoc TL) {
7552 const AutoType *T = TL.getTypePtr();
7553 QualType OldDeduced = T->getDeducedType();
7554 QualType NewDeduced;
7555 if (!OldDeduced.isNull()) {
7556 NewDeduced = getDerived().TransformType(OldDeduced);
7557 if (NewDeduced.isNull())
7558 return QualType();
7559 }
7560
7561 ConceptDecl *NewCD = nullptr;
7562 TemplateArgumentListInfo NewTemplateArgs;
7563 NestedNameSpecifierLoc NewNestedNameSpec;
7564 if (T->isConstrained()) {
7565 assert(TL.getConceptReference());
7566 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7567 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7568
7569 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7570 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7572 if (getDerived().TransformTemplateArguments(
7573 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7574 NewTemplateArgs))
7575 return QualType();
7576
7577 if (TL.getNestedNameSpecifierLoc()) {
7578 NewNestedNameSpec
7579 = getDerived().TransformNestedNameSpecifierLoc(
7580 TL.getNestedNameSpecifierLoc());
7581 if (!NewNestedNameSpec)
7582 return QualType();
7583 }
7584 }
7585
7586 QualType Result = TL.getType();
7587 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7588 T->isDependentType() || T->isConstrained()) {
7589 // FIXME: Maybe don't rebuild if all template arguments are the same.
7591 NewArgList.reserve(NewTemplateArgs.size());
7592 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7593 NewArgList.push_back(ArgLoc.getArgument());
7594 Result = getDerived().RebuildAutoType(
7595 NewDeduced.isNull() ? DeducedKind::Undeduced : DeducedKind::Deduced,
7596 NewDeduced, T->getKeyword(), NewCD, NewArgList);
7597 if (Result.isNull())
7598 return QualType();
7599 }
7600
7601 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7602 NewTL.setNameLoc(TL.getNameLoc());
7603 NewTL.setRParenLoc(TL.getRParenLoc());
7604 NewTL.setConceptReference(nullptr);
7605
7606 if (T->isConstrained()) {
7608 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7609 TL.getConceptNameLoc(),
7610 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7611 auto *CR = ConceptReference::Create(
7612 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7613 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7614 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7615 NewTL.setConceptReference(CR);
7616 }
7617
7618 return Result;
7619}
7620
7621template <typename Derived>
7624 return getDerived().TransformTemplateSpecializationType(
7625 TLB, TL, /*ObjectType=*/QualType(), /*FirstQualifierInScope=*/nullptr,
7626 /*AllowInjectedClassName=*/false);
7627}
7628
7629template <typename Derived>
7632 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
7633 const TemplateSpecializationType *T = TL.getTypePtr();
7634
7635 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7636 TemplateName Template = getDerived().TransformTemplateName(
7637 QualifierLoc, TL.getTemplateKeywordLoc(), T->getTemplateName(),
7638 TL.getTemplateNameLoc(), ObjectType, FirstQualifierInScope,
7639 AllowInjectedClassName);
7640 if (Template.isNull())
7641 return QualType();
7642
7643 TemplateArgumentListInfo NewTemplateArgs;
7644 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7645 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7647 ArgIterator;
7648 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7649 ArgIterator(TL, TL.getNumArgs()),
7650 NewTemplateArgs))
7651 return QualType();
7652
7653 // This needs to be rebuilt if either the arguments changed, or if the
7654 // original template changed. If the template changed, and even if the
7655 // arguments didn't change, these arguments might not correspond to their
7656 // respective parameters, therefore needing conversions.
7657 QualType Result = getDerived().RebuildTemplateSpecializationType(
7658 TL.getTypePtr()->getKeyword(), Template, TL.getTemplateNameLoc(),
7659 NewTemplateArgs);
7660
7661 if (!Result.isNull()) {
7663 TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getTemplateKeywordLoc(),
7664 TL.getTemplateNameLoc(), NewTemplateArgs);
7665 }
7666
7667 return Result;
7668}
7669
7670template <typename Derived>
7672 AttributedTypeLoc TL) {
7673 const AttributedType *oldType = TL.getTypePtr();
7674 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7675 if (modifiedType.isNull())
7676 return QualType();
7677
7678 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7679 const Attr *oldAttr = TL.getAttr();
7680 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7681 if (oldAttr && !newAttr)
7682 return QualType();
7683
7684 QualType result = TL.getType();
7685
7686 // FIXME: dependent operand expressions?
7687 if (getDerived().AlwaysRebuild() ||
7688 modifiedType != oldType->getModifiedType()) {
7689 // If the equivalent type is equal to the modified type, we don't want to
7690 // transform it as well because:
7691 //
7692 // 1. The transformation would yield the same result and is therefore
7693 // superfluous, and
7694 //
7695 // 2. Transforming the same type twice can cause problems, e.g. if it
7696 // is a FunctionProtoType, we may end up instantiating the function
7697 // parameters twice, which causes an assertion since the parameters
7698 // are already bound to their counterparts in the template for this
7699 // instantiation.
7700 //
7701 QualType equivalentType = modifiedType;
7702 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7703 TypeLocBuilder AuxiliaryTLB;
7704 AuxiliaryTLB.reserve(TL.getFullDataSize());
7705 equivalentType =
7706 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7707 if (equivalentType.isNull())
7708 return QualType();
7709 }
7710
7711 // Check whether we can add nullability; it is only represented as
7712 // type sugar, and therefore cannot be diagnosed in any other way.
7713 if (auto nullability = oldType->getImmediateNullability()) {
7714 if (!modifiedType->canHaveNullability()) {
7715 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7716 : TL.getModifiedLoc().getBeginLoc()),
7717 diag::err_nullability_nonpointer)
7718 << DiagNullabilityKind(*nullability, false) << modifiedType;
7719 return QualType();
7720 }
7721 }
7722
7723 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7724 modifiedType,
7725 equivalentType,
7726 TL.getAttr());
7727 }
7728
7729 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7730 newTL.setAttr(newAttr);
7731 return result;
7732}
7733
7734template <typename Derived>
7737 const CountAttributedType *OldTy = TL.getTypePtr();
7738 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7739 if (InnerTy.isNull())
7740 return QualType();
7741
7742 Expr *OldCount = TL.getCountExpr();
7743 Expr *NewCount = nullptr;
7744 if (OldCount) {
7745 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7746 if (CountResult.isInvalid())
7747 return QualType();
7748 NewCount = CountResult.get();
7749 }
7750
7751 QualType Result = TL.getType();
7752 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7753 OldCount != NewCount) {
7754 // Currently, CountAttributedType can only wrap incomplete array types.
7756 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7757 }
7758
7759 TLB.push<CountAttributedTypeLoc>(Result);
7760 return Result;
7761}
7762
7763template <typename Derived>
7766 // The BTFTagAttributedType is available for C only.
7767 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7768}
7769
7770template <typename Derived>
7773 const OverflowBehaviorType *OldTy = TL.getTypePtr();
7774 QualType InnerTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7775 if (InnerTy.isNull())
7776 return QualType();
7777
7778 QualType Result = TL.getType();
7779 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->getUnderlyingType()) {
7780 Result = SemaRef.Context.getOverflowBehaviorType(OldTy->getBehaviorKind(),
7781 InnerTy);
7782 if (Result.isNull())
7783 return QualType();
7784 }
7785
7787 NewTL.initializeLocal(SemaRef.Context, TL.getAttrLoc());
7788 return Result;
7789}
7790
7791template <typename Derived>
7794
7795 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7796
7797 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7798 if (WrappedTy.isNull())
7799 return QualType();
7800
7801 QualType ContainedTy = QualType();
7802 QualType OldContainedTy = oldType->getContainedType();
7803 TypeSourceInfo *ContainedTSI = nullptr;
7804 if (!OldContainedTy.isNull()) {
7805 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7806 if (!oldContainedTSI)
7807 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7808 OldContainedTy, SourceLocation());
7809 ContainedTSI = getDerived().TransformType(oldContainedTSI);
7810 if (!ContainedTSI)
7811 return QualType();
7812 ContainedTy = ContainedTSI->getType();
7813 }
7814
7815 QualType Result = TL.getType();
7816 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7817 ContainedTy != oldType->getContainedType()) {
7819 WrappedTy, ContainedTy, oldType->getAttrs());
7820 }
7821
7824 NewTL.setSourceRange(TL.getLocalSourceRange());
7825 NewTL.setContainedTypeSourceInfo(ContainedTSI);
7826 return Result;
7827}
7828
7829template <typename Derived>
7832 // No transformations needed.
7833 return TL.getType();
7834}
7835
7836template<typename Derived>
7839 ParenTypeLoc TL) {
7840 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7841 if (Inner.isNull())
7842 return QualType();
7843
7844 QualType Result = TL.getType();
7845 if (getDerived().AlwaysRebuild() ||
7846 Inner != TL.getInnerLoc().getType()) {
7847 Result = getDerived().RebuildParenType(Inner);
7848 if (Result.isNull())
7849 return QualType();
7850 }
7851
7852 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7853 NewTL.setLParenLoc(TL.getLParenLoc());
7854 NewTL.setRParenLoc(TL.getRParenLoc());
7855 return Result;
7856}
7857
7858template <typename Derived>
7862 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7863 if (Inner.isNull())
7864 return QualType();
7865
7866 QualType Result = TL.getType();
7867 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7868 Result =
7869 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7870 if (Result.isNull())
7871 return QualType();
7872 }
7873
7875 NewTL.setExpansionLoc(TL.getExpansionLoc());
7876 return Result;
7877}
7878
7879template<typename Derived>
7880QualType TreeTransform<Derived>::TransformDependentNameType(
7882 return TransformDependentNameType(TLB, TL, false);
7883}
7884
7885template <typename Derived>
7886QualType TreeTransform<Derived>::TransformDependentNameType(
7887 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext,
7888 QualType ObjectType, NamedDecl *UnqualLookup) {
7889 const DependentNameType *T = TL.getTypePtr();
7890
7891 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7892 if (QualifierLoc) {
7893 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
7894 QualifierLoc, ObjectType, UnqualLookup);
7895 if (!QualifierLoc)
7896 return QualType();
7897 } else {
7898 assert((ObjectType.isNull() && !UnqualLookup) &&
7899 "must be transformed by TransformNestedNameSpecifierLoc");
7900 }
7901
7903 = getDerived().RebuildDependentNameType(T->getKeyword(),
7904 TL.getElaboratedKeywordLoc(),
7905 QualifierLoc,
7906 T->getIdentifier(),
7907 TL.getNameLoc(),
7908 DeducedTSTContext);
7909 if (Result.isNull())
7910 return QualType();
7911
7912 if (isa<TagType>(Result)) {
7913 auto NewTL = TLB.push<TagTypeLoc>(Result);
7914 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7915 NewTL.setQualifierLoc(QualifierLoc);
7916 NewTL.setNameLoc(TL.getNameLoc());
7918 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7919 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7920 NewTL.setTemplateNameLoc(TL.getNameLoc());
7921 NewTL.setQualifierLoc(QualifierLoc);
7922 } else if (isa<TypedefType>(Result)) {
7923 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7924 QualifierLoc, TL.getNameLoc());
7925 } else if (isa<UnresolvedUsingType>(Result)) {
7926 auto NewTL = TLB.push<UnresolvedUsingTypeLoc>(Result);
7927 NewTL.set(TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getNameLoc());
7928 } else {
7929 auto NewTL = TLB.push<DependentNameTypeLoc>(Result);
7930 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7931 NewTL.setQualifierLoc(QualifierLoc);
7932 NewTL.setNameLoc(TL.getNameLoc());
7933 }
7934 return Result;
7935}
7936
7937template<typename Derived>
7940 QualType Pattern
7941 = getDerived().TransformType(TLB, TL.getPatternLoc());
7942 if (Pattern.isNull())
7943 return QualType();
7944
7945 QualType Result = TL.getType();
7946 if (getDerived().AlwaysRebuild() ||
7947 Pattern != TL.getPatternLoc().getType()) {
7948 Result = getDerived().RebuildPackExpansionType(Pattern,
7949 TL.getPatternLoc().getSourceRange(),
7950 TL.getEllipsisLoc(),
7951 TL.getTypePtr()->getNumExpansions());
7952 if (Result.isNull())
7953 return QualType();
7954 }
7955
7957 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7958 return Result;
7959}
7960
7961template<typename Derived>
7965 // ObjCInterfaceType is never dependent.
7966 TLB.pushFullCopy(TL);
7967 return TL.getType();
7968}
7969
7970template<typename Derived>
7974 const ObjCTypeParamType *T = TL.getTypePtr();
7975 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7976 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7977 if (!OTP)
7978 return QualType();
7979
7980 QualType Result = TL.getType();
7981 if (getDerived().AlwaysRebuild() ||
7982 OTP != T->getDecl()) {
7983 Result = getDerived().RebuildObjCTypeParamType(
7984 OTP, TL.getProtocolLAngleLoc(),
7985 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7986 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7987 if (Result.isNull())
7988 return QualType();
7989 }
7990
7992 if (TL.getNumProtocols()) {
7993 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7994 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7995 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7996 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7997 }
7998 return Result;
7999}
8000
8001template<typename Derived>
8004 ObjCObjectTypeLoc TL) {
8005 // Transform base type.
8006 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
8007 if (BaseType.isNull())
8008 return QualType();
8009
8010 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
8011
8012 // Transform type arguments.
8013 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
8014 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
8015 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
8016 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
8017 QualType TypeArg = TypeArgInfo->getType();
8018 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
8019 AnyChanged = true;
8020
8021 // We have a pack expansion. Instantiate it.
8022 const auto *PackExpansion = PackExpansionLoc.getType()
8023 ->castAs<PackExpansionType>();
8025 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
8026 Unexpanded);
8027 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
8028
8029 // Determine whether the set of unexpanded parameter packs can
8030 // and should be expanded.
8031 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
8032 bool Expand = false;
8033 bool RetainExpansion = false;
8034 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
8035 if (getDerived().TryExpandParameterPacks(
8036 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
8037 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
8038 RetainExpansion, NumExpansions))
8039 return QualType();
8040
8041 if (!Expand) {
8042 // We can't expand this pack expansion into separate arguments yet;
8043 // just substitute into the pattern and create a new pack expansion
8044 // type.
8045 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
8046
8047 TypeLocBuilder TypeArgBuilder;
8048 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8049 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
8050 PatternLoc);
8051 if (NewPatternType.isNull())
8052 return QualType();
8053
8054 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
8055 NewPatternType, NumExpansions);
8056 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
8057 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
8058 NewTypeArgInfos.push_back(
8059 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
8060 continue;
8061 }
8062
8063 // Substitute into the pack expansion pattern for each slice of the
8064 // pack.
8065 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
8066 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
8067
8068 TypeLocBuilder TypeArgBuilder;
8069 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8070
8071 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
8072 PatternLoc);
8073 if (NewTypeArg.isNull())
8074 return QualType();
8075
8076 NewTypeArgInfos.push_back(
8077 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8078 }
8079
8080 continue;
8081 }
8082
8083 TypeLocBuilder TypeArgBuilder;
8084 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
8085 QualType NewTypeArg =
8086 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
8087 if (NewTypeArg.isNull())
8088 return QualType();
8089
8090 // If nothing changed, just keep the old TypeSourceInfo.
8091 if (NewTypeArg == TypeArg) {
8092 NewTypeArgInfos.push_back(TypeArgInfo);
8093 continue;
8094 }
8095
8096 NewTypeArgInfos.push_back(
8097 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8098 AnyChanged = true;
8099 }
8100
8101 QualType Result = TL.getType();
8102 if (getDerived().AlwaysRebuild() || AnyChanged) {
8103 // Rebuild the type.
8104 Result = getDerived().RebuildObjCObjectType(
8105 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
8106 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
8107 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8108 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8109
8110 if (Result.isNull())
8111 return QualType();
8112 }
8113
8114 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
8115 NewT.setHasBaseTypeAsWritten(true);
8116 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
8117 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
8118 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
8119 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
8120 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8121 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8122 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
8123 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8124 return Result;
8125}
8126
8127template<typename Derived>
8131 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8132 if (PointeeType.isNull())
8133 return QualType();
8134
8135 QualType Result = TL.getType();
8136 if (getDerived().AlwaysRebuild() ||
8137 PointeeType != TL.getPointeeLoc().getType()) {
8138 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8139 TL.getStarLoc());
8140 if (Result.isNull())
8141 return QualType();
8142 }
8143
8145 NewT.setStarLoc(TL.getStarLoc());
8146 return Result;
8147}
8148
8149//===----------------------------------------------------------------------===//
8150// Statement transformation
8151//===----------------------------------------------------------------------===//
8152template<typename Derived>
8155 return S;
8156}
8157
8158template<typename Derived>
8161 return getDerived().TransformCompoundStmt(S, false);
8162}
8163
8164template<typename Derived>
8167 bool IsStmtExpr) {
8168 Sema::CompoundScopeRAII CompoundScope(getSema());
8169 Sema::FPFeaturesStateRAII FPSave(getSema());
8170 if (S->hasStoredFPFeatures())
8171 getSema().resetFPOptions(
8172 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8173
8174 bool SubStmtInvalid = false;
8175 bool SubStmtChanged = false;
8176 SmallVector<Stmt*, 8> Statements;
8177 for (auto *B : S->body()) {
8178 StmtResult Result = getDerived().TransformStmt(
8179 B, IsStmtExpr && B == S->body_back() ? StmtDiscardKind::StmtExprResult
8180 : StmtDiscardKind::Discarded);
8181
8182 if (Result.isInvalid()) {
8183 // Immediately fail if this was a DeclStmt, since it's very
8184 // likely that this will cause problems for future statements.
8185 if (isa<DeclStmt>(B))
8186 return StmtError();
8187
8188 // Otherwise, just keep processing substatements and fail later.
8189 SubStmtInvalid = true;
8190 continue;
8191 }
8192
8193 SubStmtChanged = SubStmtChanged || Result.get() != B;
8194 Statements.push_back(Result.getAs<Stmt>());
8195 }
8196
8197 if (SubStmtInvalid)
8198 return StmtError();
8199
8200 if (!getDerived().AlwaysRebuild() &&
8201 !SubStmtChanged)
8202 return S;
8203
8204 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8205 Statements,
8206 S->getRBracLoc(),
8207 IsStmtExpr);
8208}
8209
8210template<typename Derived>
8213 ExprResult LHS, RHS;
8214 {
8217
8218 // Transform the left-hand case value.
8219 LHS = getDerived().TransformExpr(S->getLHS());
8220 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8221 if (LHS.isInvalid())
8222 return StmtError();
8223
8224 // Transform the right-hand case value (for the GNU case-range extension).
8225 RHS = getDerived().TransformExpr(S->getRHS());
8226 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8227 if (RHS.isInvalid())
8228 return StmtError();
8229 }
8230
8231 // Build the case statement.
8232 // Case statements are always rebuilt so that they will attached to their
8233 // transformed switch statement.
8234 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8235 LHS.get(),
8236 S->getEllipsisLoc(),
8237 RHS.get(),
8238 S->getColonLoc());
8239 if (Case.isInvalid())
8240 return StmtError();
8241
8242 // Transform the statement following the case
8243 StmtResult SubStmt =
8244 getDerived().TransformStmt(S->getSubStmt());
8245 if (SubStmt.isInvalid())
8246 return StmtError();
8247
8248 // Attach the body to the case statement
8249 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8250}
8251
8252template <typename Derived>
8254 // Transform the statement following the default case
8255 StmtResult SubStmt =
8256 getDerived().TransformStmt(S->getSubStmt());
8257 if (SubStmt.isInvalid())
8258 return StmtError();
8259
8260 // Default statements are always rebuilt
8261 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8262 SubStmt.get());
8263}
8264
8265template<typename Derived>
8268 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8269 if (SubStmt.isInvalid())
8270 return StmtError();
8271
8272 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8273 S->getDecl());
8274 if (!LD)
8275 return StmtError();
8276
8277 // If we're transforming "in-place" (we're not creating new local
8278 // declarations), assume we're replacing the old label statement
8279 // and clear out the reference to it.
8280 if (LD == S->getDecl())
8281 S->getDecl()->setStmt(nullptr);
8282
8283 // FIXME: Pass the real colon location in.
8284 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8286 SubStmt.get());
8287}
8288
8289template <typename Derived>
8291 if (!R)
8292 return R;
8293
8294 switch (R->getKind()) {
8295// Transform attributes by calling TransformXXXAttr.
8296#define ATTR(X) \
8297 case attr::X: \
8298 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8299#include "clang/Basic/AttrList.inc"
8300 }
8301 return R;
8302}
8303
8304template <typename Derived>
8306 const Stmt *InstS,
8307 const Attr *R) {
8308 if (!R)
8309 return R;
8310
8311 switch (R->getKind()) {
8312// Transform attributes by calling TransformStmtXXXAttr.
8313#define ATTR(X) \
8314 case attr::X: \
8315 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8316#include "clang/Basic/AttrList.inc"
8317 }
8318 return TransformAttr(R);
8319}
8320
8321template <typename Derived>
8324 StmtDiscardKind SDK) {
8325 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8326 if (SubStmt.isInvalid())
8327 return StmtError();
8328
8329 bool AttrsChanged = false;
8331
8332 // Visit attributes and keep track if any are transformed.
8333 for (const auto *I : S->getAttrs()) {
8334 const Attr *R =
8335 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8336 AttrsChanged |= (I != R);
8337 if (R)
8338 Attrs.push_back(R);
8339 }
8340
8341 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8342 return S;
8343
8344 // If transforming the attributes failed for all of the attributes in the
8345 // statement, don't make an AttributedStmt without attributes.
8346 if (Attrs.empty())
8347 return SubStmt;
8348
8349 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8350 SubStmt.get());
8351}
8352
8353template<typename Derived>
8356 // Transform the initialization statement
8357 StmtResult Init = getDerived().TransformStmt(S->getInit());
8358 if (Init.isInvalid())
8359 return StmtError();
8360
8362 if (!S->isConsteval()) {
8363 // Transform the condition
8364 Cond = getDerived().TransformCondition(
8365 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8366 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8368 if (Cond.isInvalid())
8369 return StmtError();
8370 }
8371
8372 // If this is a constexpr if, determine which arm we should instantiate.
8373 std::optional<bool> ConstexprConditionValue;
8374 if (S->isConstexpr())
8375 ConstexprConditionValue = Cond.getKnownValue();
8376
8377 // Transform the "then" branch.
8378 StmtResult Then;
8379 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8383 S->isNonNegatedConsteval());
8384
8385 Then = getDerived().TransformStmt(S->getThen());
8386 if (Then.isInvalid())
8387 return StmtError();
8388 } else {
8389 // Discarded branch is replaced with empty CompoundStmt so we can keep
8390 // proper source location for start and end of original branch, so
8391 // subsequent transformations like CoverageMapping work properly
8392 Then = new (getSema().Context)
8393 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8394 }
8395
8396 // Transform the "else" branch.
8397 StmtResult Else;
8398 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8402 S->isNegatedConsteval());
8403
8404 Else = getDerived().TransformStmt(S->getElse());
8405 if (Else.isInvalid())
8406 return StmtError();
8407 } else if (S->getElse() && ConstexprConditionValue &&
8408 *ConstexprConditionValue) {
8409 // Same thing here as with <then> branch, we are discarding it, we can't
8410 // replace it with NULL nor NullStmt as we need to keep for source location
8411 // range, for CoverageMapping
8412 Else = new (getSema().Context)
8413 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8414 }
8415
8416 if (!getDerived().AlwaysRebuild() &&
8417 Init.get() == S->getInit() &&
8418 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8419 Then.get() == S->getThen() &&
8420 Else.get() == S->getElse())
8421 return S;
8422
8423 return getDerived().RebuildIfStmt(
8424 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8425 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8426}
8427
8428template<typename Derived>
8431 // Transform the initialization statement
8432 StmtResult Init = getDerived().TransformStmt(S->getInit());
8433 if (Init.isInvalid())
8434 return StmtError();
8435
8436 // Transform the condition.
8437 Sema::ConditionResult Cond = getDerived().TransformCondition(
8438 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8440 if (Cond.isInvalid())
8441 return StmtError();
8442
8443 // Rebuild the switch statement.
8445 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8446 Init.get(), Cond, S->getRParenLoc());
8447 if (Switch.isInvalid())
8448 return StmtError();
8449
8450 // Transform the body of the switch statement.
8451 StmtResult Body = getDerived().TransformStmt(S->getBody());
8452 if (Body.isInvalid())
8453 return StmtError();
8454
8455 // Complete the switch statement.
8456 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8457 Body.get());
8458}
8459
8460template<typename Derived>
8463 // Transform the condition
8464 Sema::ConditionResult Cond = getDerived().TransformCondition(
8465 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8467 if (Cond.isInvalid())
8468 return StmtError();
8469
8470 // OpenACC Restricts a while-loop inside of certain construct/clause
8471 // combinations, so diagnose that here in OpenACC mode.
8473 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8474
8475 // Transform the body
8476 StmtResult Body = getDerived().TransformStmt(S->getBody());
8477 if (Body.isInvalid())
8478 return StmtError();
8479
8480 if (!getDerived().AlwaysRebuild() &&
8481 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8482 Body.get() == S->getBody())
8483 return Owned(S);
8484
8485 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8486 Cond, S->getRParenLoc(), Body.get());
8487}
8488
8489template<typename Derived>
8492 // OpenACC Restricts a do-loop inside of certain construct/clause
8493 // combinations, so diagnose that here in OpenACC mode.
8495 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8496
8497 // Transform the body
8498 StmtResult Body = getDerived().TransformStmt(S->getBody());
8499 if (Body.isInvalid())
8500 return StmtError();
8501
8502 // Transform the condition
8503 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8504 if (Cond.isInvalid())
8505 return StmtError();
8506
8507 if (!getDerived().AlwaysRebuild() &&
8508 Cond.get() == S->getCond() &&
8509 Body.get() == S->getBody())
8510 return S;
8511
8512 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8513 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8514 S->getRParenLoc());
8515}
8516
8517template<typename Derived>
8520 if (getSema().getLangOpts().OpenMP)
8521 getSema().OpenMP().startOpenMPLoop();
8522
8523 // Transform the initialization statement
8524 StmtResult Init = getDerived().TransformStmt(S->getInit());
8525 if (Init.isInvalid())
8526 return StmtError();
8527
8528 // In OpenMP loop region loop control variable must be captured and be
8529 // private. Perform analysis of first part (if any).
8530 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8531 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8532 Init.get());
8533
8534 // Transform the condition
8535 Sema::ConditionResult Cond = getDerived().TransformCondition(
8536 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8538 if (Cond.isInvalid())
8539 return StmtError();
8540
8541 // Transform the increment
8542 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8543 if (Inc.isInvalid())
8544 return StmtError();
8545
8546 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8547 if (S->getInc() && !FullInc.get())
8548 return StmtError();
8549
8550 // OpenACC Restricts a for-loop inside of certain construct/clause
8551 // combinations, so diagnose that here in OpenACC mode.
8553 SemaRef.OpenACC().ActOnForStmtBegin(
8554 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8555 Cond.get().second, S->getInc(), Inc.get());
8556
8557 // Transform the body
8558 StmtResult Body = getDerived().TransformStmt(S->getBody());
8559 if (Body.isInvalid())
8560 return StmtError();
8561
8562 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8563
8564 if (!getDerived().AlwaysRebuild() &&
8565 Init.get() == S->getInit() &&
8566 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8567 Inc.get() == S->getInc() &&
8568 Body.get() == S->getBody())
8569 return S;
8570
8571 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8572 Init.get(), Cond, FullInc,
8573 S->getRParenLoc(), Body.get());
8574}
8575
8576template<typename Derived>
8579 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8580 S->getLabel());
8581 if (!LD)
8582 return StmtError();
8583
8584 // Goto statements must always be rebuilt, to resolve the label.
8585 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8586 cast<LabelDecl>(LD));
8587}
8588
8589template<typename Derived>
8592 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8593 if (Target.isInvalid())
8594 return StmtError();
8595 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8596
8597 if (!getDerived().AlwaysRebuild() &&
8598 Target.get() == S->getTarget())
8599 return S;
8600
8601 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8602 Target.get());
8603}
8604
8605template<typename Derived>
8608 if (!S->hasLabelTarget())
8609 return S;
8610
8611 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8612 S->getLabelDecl());
8613 if (!LD)
8614 return StmtError();
8615
8616 return new (SemaRef.Context)
8617 ContinueStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8618}
8619
8620template<typename Derived>
8623 if (!S->hasLabelTarget())
8624 return S;
8625
8626 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8627 S->getLabelDecl());
8628 if (!LD)
8629 return StmtError();
8630
8631 return new (SemaRef.Context)
8632 BreakStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8633}
8634
8635template <typename Derived>
8637 StmtResult Result = getDerived().TransformStmt(S->getBody());
8638 if (!Result.isUsable())
8639 return StmtError();
8640 return DeferStmt::Create(getSema().Context, S->getDeferLoc(), Result.get());
8641}
8642
8643template<typename Derived>
8646 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8647 /*NotCopyInit*/false);
8648 if (Result.isInvalid())
8649 return StmtError();
8650
8651 // FIXME: We always rebuild the return statement because there is no way
8652 // to tell whether the return type of the function has changed.
8653 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8654}
8655
8656template<typename Derived>
8659 bool DeclChanged = false;
8661 LambdaScopeInfo *LSI = getSema().getCurLambda();
8662 for (auto *D : S->decls()) {
8663 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8664 if (!Transformed)
8665 return StmtError();
8666
8667 if (Transformed != D)
8668 DeclChanged = true;
8669
8670 if (LSI) {
8671 if (auto *TD = dyn_cast<TypeDecl>(Transformed)) {
8672 if (auto *TN = dyn_cast<TypedefNameDecl>(TD)) {
8673 LSI->ContainsUnexpandedParameterPack |=
8674 TN->getUnderlyingType()->containsUnexpandedParameterPack();
8675 } else {
8676 LSI->ContainsUnexpandedParameterPack |=
8677 getSema()
8678 .getASTContext()
8679 .getTypeDeclType(TD)
8680 ->containsUnexpandedParameterPack();
8681 }
8682 }
8683 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8684 LSI->ContainsUnexpandedParameterPack |=
8685 VD->getType()->containsUnexpandedParameterPack();
8686 }
8687
8688 Decls.push_back(Transformed);
8689 }
8690
8691 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8692 return S;
8693
8694 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8695}
8696
8697template<typename Derived>
8700
8701 SmallVector<Expr*, 8> Constraints;
8704
8705 SmallVector<Expr*, 8> Clobbers;
8706
8707 bool ExprsChanged = false;
8708
8709 auto RebuildString = [&](Expr *E) {
8710 ExprResult Result = getDerived().TransformExpr(E);
8711 if (!Result.isUsable())
8712 return Result;
8713 if (Result.get() != E) {
8714 ExprsChanged = true;
8715 Result = SemaRef.ActOnGCCAsmStmtString(Result.get(), /*ForLabel=*/false);
8716 }
8717 return Result;
8718 };
8719
8720 // Go through the outputs.
8721 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8722 Names.push_back(S->getOutputIdentifier(I));
8723
8724 ExprResult Result = RebuildString(S->getOutputConstraintExpr(I));
8725 if (Result.isInvalid())
8726 return StmtError();
8727
8728 Constraints.push_back(Result.get());
8729
8730 // Transform the output expr.
8731 Expr *OutputExpr = S->getOutputExpr(I);
8732 Result = getDerived().TransformExpr(OutputExpr);
8733 if (Result.isInvalid())
8734 return StmtError();
8735
8736 ExprsChanged |= Result.get() != OutputExpr;
8737
8738 Exprs.push_back(Result.get());
8739 }
8740
8741 // Go through the inputs.
8742 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8743 Names.push_back(S->getInputIdentifier(I));
8744
8745 ExprResult Result = RebuildString(S->getInputConstraintExpr(I));
8746 if (Result.isInvalid())
8747 return StmtError();
8748
8749 Constraints.push_back(Result.get());
8750
8751 // Transform the input expr.
8752 Expr *InputExpr = S->getInputExpr(I);
8753 Result = getDerived().TransformExpr(InputExpr);
8754 if (Result.isInvalid())
8755 return StmtError();
8756
8757 ExprsChanged |= Result.get() != InputExpr;
8758
8759 Exprs.push_back(Result.get());
8760 }
8761
8762 // Go through the Labels.
8763 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8764 Names.push_back(S->getLabelIdentifier(I));
8765
8766 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8767 if (Result.isInvalid())
8768 return StmtError();
8769 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8770 Exprs.push_back(Result.get());
8771 }
8772
8773 // Go through the clobbers.
8774 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) {
8775 ExprResult Result = RebuildString(S->getClobberExpr(I));
8776 if (Result.isInvalid())
8777 return StmtError();
8778 Clobbers.push_back(Result.get());
8779 }
8780
8781 ExprResult AsmString = RebuildString(S->getAsmStringExpr());
8782 if (AsmString.isInvalid())
8783 return StmtError();
8784
8785 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8786 return S;
8787
8788 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8789 S->isVolatile(), S->getNumOutputs(),
8790 S->getNumInputs(), Names.data(),
8791 Constraints, Exprs, AsmString.get(),
8792 Clobbers, S->getNumLabels(),
8793 S->getRParenLoc());
8794}
8795
8796template<typename Derived>
8799 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8800
8801 bool HadError = false, HadChange = false;
8802
8803 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8804 SmallVector<Expr*, 8> TransformedExprs;
8805 TransformedExprs.reserve(SrcExprs.size());
8806 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8807 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8808 if (!Result.isUsable()) {
8809 HadError = true;
8810 } else {
8811 HadChange |= (Result.get() != SrcExprs[i]);
8812 TransformedExprs.push_back(Result.get());
8813 }
8814 }
8815
8816 if (HadError) return StmtError();
8817 if (!HadChange && !getDerived().AlwaysRebuild())
8818 return Owned(S);
8819
8820 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8821 AsmToks, S->getAsmString(),
8822 S->getNumOutputs(), S->getNumInputs(),
8823 S->getAllConstraints(), S->getClobbers(),
8824 TransformedExprs, S->getEndLoc());
8825}
8826
8827// C++ Coroutines
8828template<typename Derived>
8831 auto *ScopeInfo = SemaRef.getCurFunction();
8832 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8833 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8834 ScopeInfo->NeedsCoroutineSuspends &&
8835 ScopeInfo->CoroutineSuspends.first == nullptr &&
8836 ScopeInfo->CoroutineSuspends.second == nullptr &&
8837 "expected clean scope info");
8838
8839 // Set that we have (possibly-invalid) suspend points before we do anything
8840 // that may fail.
8841 ScopeInfo->setNeedsCoroutineSuspends(false);
8842
8843 // We re-build the coroutine promise object (and the coroutine parameters its
8844 // type and constructor depend on) based on the types used in our current
8845 // function. We must do so, and set it on the current FunctionScopeInfo,
8846 // before attempting to transform the other parts of the coroutine body
8847 // statement, such as the implicit suspend statements (because those
8848 // statements reference the FunctionScopeInfo::CoroutinePromise).
8849 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8850 return StmtError();
8851 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8852 if (!Promise)
8853 return StmtError();
8854 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8855 ScopeInfo->CoroutinePromise = Promise;
8856
8857 // Transform the implicit coroutine statements constructed using dependent
8858 // types during the previous parse: initial and final suspensions, the return
8859 // object, and others. We also transform the coroutine function's body.
8860 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8861 if (InitSuspend.isInvalid())
8862 return StmtError();
8863 StmtResult FinalSuspend =
8864 getDerived().TransformStmt(S->getFinalSuspendStmt());
8865 if (FinalSuspend.isInvalid() ||
8866 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8867 return StmtError();
8868 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8869 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8870
8871 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8872 if (BodyRes.isInvalid())
8873 return StmtError();
8874
8875 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8876 if (Builder.isInvalid())
8877 return StmtError();
8878
8879 Expr *ReturnObject = S->getReturnValueInit();
8880 assert(ReturnObject && "the return object is expected to be valid");
8881 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8882 /*NoCopyInit*/ false);
8883 if (Res.isInvalid())
8884 return StmtError();
8885 Builder.ReturnValue = Res.get();
8886
8887 // If during the previous parse the coroutine still had a dependent promise
8888 // statement, we may need to build some implicit coroutine statements
8889 // (such as exception and fallthrough handlers) for the first time.
8890 if (S->hasDependentPromiseType()) {
8891 // We can only build these statements, however, if the current promise type
8892 // is not dependent.
8893 if (!Promise->getType()->isDependentType()) {
8894 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8895 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8896 "these nodes should not have been built yet");
8897 if (!Builder.buildDependentStatements())
8898 return StmtError();
8899 }
8900 } else {
8901 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8902 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8903 if (Res.isInvalid())
8904 return StmtError();
8905 Builder.OnFallthrough = Res.get();
8906 }
8907
8908 if (auto *OnException = S->getExceptionHandler()) {
8909 StmtResult Res = getDerived().TransformStmt(OnException);
8910 if (Res.isInvalid())
8911 return StmtError();
8912 Builder.OnException = Res.get();
8913 }
8914
8915 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8916 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8917 if (Res.isInvalid())
8918 return StmtError();
8919 Builder.ReturnStmtOnAllocFailure = Res.get();
8920 }
8921
8922 // Transform any additional statements we may have already built
8923 assert(S->getAllocate() && S->getDeallocate() &&
8924 "allocation and deallocation calls must already be built");
8925 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8926 if (AllocRes.isInvalid())
8927 return StmtError();
8928 Builder.Allocate = AllocRes.get();
8929
8930 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8931 if (DeallocRes.isInvalid())
8932 return StmtError();
8933 Builder.Deallocate = DeallocRes.get();
8934
8935 if (auto *ResultDecl = S->getResultDecl()) {
8936 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8937 if (Res.isInvalid())
8938 return StmtError();
8939 Builder.ResultDecl = Res.get();
8940 }
8941
8942 if (auto *ReturnStmt = S->getReturnStmt()) {
8943 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8944 if (Res.isInvalid())
8945 return StmtError();
8946 Builder.ReturnStmt = Res.get();
8947 }
8948 }
8949
8950 return getDerived().RebuildCoroutineBodyStmt(Builder);
8951}
8952
8953template<typename Derived>
8956 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8957 /*NotCopyInit*/false);
8958 if (Result.isInvalid())
8959 return StmtError();
8960
8961 // Always rebuild; we don't know if this needs to be injected into a new
8962 // context or if the promise type has changed.
8963 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8964 S->isImplicit());
8965}
8966
8967template <typename Derived>
8969 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8970 /*NotCopyInit*/ false);
8971 if (Operand.isInvalid())
8972 return ExprError();
8973
8974 // Rebuild the common-expr from the operand rather than transforming it
8975 // separately.
8976
8977 // FIXME: getCurScope() should not be used during template instantiation.
8978 // We should pick up the set of unqualified lookup results for operator
8979 // co_await during the initial parse.
8980 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8981 getSema().getCurScope(), E->getKeywordLoc());
8982
8983 // Always rebuild; we don't know if this needs to be injected into a new
8984 // context or if the promise type has changed.
8985 return getDerived().RebuildCoawaitExpr(
8986 E->getKeywordLoc(), Operand.get(),
8987 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8988}
8989
8990template <typename Derived>
8993 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8994 /*NotCopyInit*/ false);
8995 if (OperandResult.isInvalid())
8996 return ExprError();
8997
8998 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8999 E->getOperatorCoawaitLookup());
9000
9001 if (LookupResult.isInvalid())
9002 return ExprError();
9003
9004 // Always rebuild; we don't know if this needs to be injected into a new
9005 // context or if the promise type has changed.
9006 return getDerived().RebuildDependentCoawaitExpr(
9007 E->getKeywordLoc(), OperandResult.get(),
9009}
9010
9011template<typename Derived>
9014 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
9015 /*NotCopyInit*/false);
9016 if (Result.isInvalid())
9017 return ExprError();
9018
9019 // Always rebuild; we don't know if this needs to be injected into a new
9020 // context or if the promise type has changed.
9021 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
9022}
9023
9024// Objective-C Statements.
9025
9026template<typename Derived>
9029 // Transform the body of the @try.
9030 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
9031 if (TryBody.isInvalid())
9032 return StmtError();
9033
9034 // Transform the @catch statements (if present).
9035 bool AnyCatchChanged = false;
9036 SmallVector<Stmt*, 8> CatchStmts;
9037 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
9038 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
9039 if (Catch.isInvalid())
9040 return StmtError();
9041 if (Catch.get() != S->getCatchStmt(I))
9042 AnyCatchChanged = true;
9043 CatchStmts.push_back(Catch.get());
9044 }
9045
9046 // Transform the @finally statement (if present).
9047 StmtResult Finally;
9048 if (S->getFinallyStmt()) {
9049 Finally = getDerived().TransformStmt(S->getFinallyStmt());
9050 if (Finally.isInvalid())
9051 return StmtError();
9052 }
9053
9054 // If nothing changed, just retain this statement.
9055 if (!getDerived().AlwaysRebuild() &&
9056 TryBody.get() == S->getTryBody() &&
9057 !AnyCatchChanged &&
9058 Finally.get() == S->getFinallyStmt())
9059 return S;
9060
9061 // Build a new statement.
9062 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
9063 CatchStmts, Finally.get());
9064}
9065
9066template<typename Derived>
9069 // Transform the @catch parameter, if there is one.
9070 VarDecl *Var = nullptr;
9071 if (VarDecl *FromVar = S->getCatchParamDecl()) {
9072 TypeSourceInfo *TSInfo = nullptr;
9073 if (FromVar->getTypeSourceInfo()) {
9074 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
9075 if (!TSInfo)
9076 return StmtError();
9077 }
9078
9079 QualType T;
9080 if (TSInfo)
9081 T = TSInfo->getType();
9082 else {
9083 T = getDerived().TransformType(FromVar->getType());
9084 if (T.isNull())
9085 return StmtError();
9086 }
9087
9088 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
9089 if (!Var)
9090 return StmtError();
9091 }
9092
9093 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
9094 if (Body.isInvalid())
9095 return StmtError();
9096
9097 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
9098 S->getRParenLoc(),
9099 Var, Body.get());
9100}
9101
9102template<typename Derived>
9105 // Transform the body.
9106 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
9107 if (Body.isInvalid())
9108 return StmtError();
9109
9110 // If nothing changed, just retain this statement.
9111 if (!getDerived().AlwaysRebuild() &&
9112 Body.get() == S->getFinallyBody())
9113 return S;
9114
9115 // Build a new statement.
9116 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
9117 Body.get());
9118}
9119
9120template<typename Derived>
9124 if (S->getThrowExpr()) {
9125 Operand = getDerived().TransformExpr(S->getThrowExpr());
9126 if (Operand.isInvalid())
9127 return StmtError();
9128 }
9129
9130 if (!getDerived().AlwaysRebuild() &&
9131 Operand.get() == S->getThrowExpr())
9132 return S;
9133
9134 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
9135}
9136
9137template<typename Derived>
9141 // Transform the object we are locking.
9142 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
9143 if (Object.isInvalid())
9144 return StmtError();
9145 Object =
9146 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
9147 Object.get());
9148 if (Object.isInvalid())
9149 return StmtError();
9150
9151 // Transform the body.
9152 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
9153 if (Body.isInvalid())
9154 return StmtError();
9155
9156 // If nothing change, just retain the current statement.
9157 if (!getDerived().AlwaysRebuild() &&
9158 Object.get() == S->getSynchExpr() &&
9159 Body.get() == S->getSynchBody())
9160 return S;
9161
9162 // Build a new statement.
9163 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
9164 Object.get(), Body.get());
9165}
9166
9167template<typename Derived>
9171 // Transform the body.
9172 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
9173 if (Body.isInvalid())
9174 return StmtError();
9175
9176 // If nothing changed, just retain this statement.
9177 if (!getDerived().AlwaysRebuild() &&
9178 Body.get() == S->getSubStmt())
9179 return S;
9180
9181 // Build a new statement.
9182 return getDerived().RebuildObjCAutoreleasePoolStmt(
9183 S->getAtLoc(), Body.get());
9184}
9185
9186template<typename Derived>
9190 // Transform the element statement.
9191 StmtResult Element = getDerived().TransformStmt(
9192 S->getElement(), StmtDiscardKind::NotDiscarded);
9193 if (Element.isInvalid())
9194 return StmtError();
9195
9196 // Transform the collection expression.
9197 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9198 if (Collection.isInvalid())
9199 return StmtError();
9200
9201 // Transform the body.
9202 StmtResult Body = getDerived().TransformStmt(S->getBody());
9203 if (Body.isInvalid())
9204 return StmtError();
9205
9206 // If nothing changed, just retain this statement.
9207 if (!getDerived().AlwaysRebuild() &&
9208 Element.get() == S->getElement() &&
9209 Collection.get() == S->getCollection() &&
9210 Body.get() == S->getBody())
9211 return S;
9212
9213 // Build a new statement.
9214 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9215 Element.get(),
9216 Collection.get(),
9217 S->getRParenLoc(),
9218 Body.get());
9219}
9220
9221template <typename Derived>
9223 // Transform the exception declaration, if any.
9224 VarDecl *Var = nullptr;
9225 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9226 TypeSourceInfo *T =
9227 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9228 if (!T)
9229 return StmtError();
9230
9231 Var = getDerived().RebuildExceptionDecl(
9232 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9233 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9234 if (!Var || Var->isInvalidDecl())
9235 return StmtError();
9236 }
9237
9238 // Transform the actual exception handler.
9239 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9240 if (Handler.isInvalid())
9241 return StmtError();
9242
9243 if (!getDerived().AlwaysRebuild() && !Var &&
9244 Handler.get() == S->getHandlerBlock())
9245 return S;
9246
9247 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9248}
9249
9250template <typename Derived>
9252 // Transform the try block itself.
9253 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9254 if (TryBlock.isInvalid())
9255 return StmtError();
9256
9257 // Transform the handlers.
9258 bool HandlerChanged = false;
9259 SmallVector<Stmt *, 8> Handlers;
9260 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9261 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9262 if (Handler.isInvalid())
9263 return StmtError();
9264
9265 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9266 Handlers.push_back(Handler.getAs<Stmt>());
9267 }
9268
9269 getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
9270
9271 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9272 !HandlerChanged)
9273 return S;
9274
9275 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9276 Handlers);
9277}
9278
9279template<typename Derived>
9282 EnterExpressionEvaluationContext ForRangeInitContext(
9284 /*LambdaContextDecl=*/nullptr,
9286 getSema().getLangOpts().CPlusPlus23);
9287
9288 // P2718R0 - Lifetime extension in range-based for loops.
9289 if (getSema().getLangOpts().CPlusPlus23) {
9290 auto &LastRecord = getSema().currentEvaluationContext();
9291 LastRecord.InLifetimeExtendingContext = true;
9292 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9293 }
9295 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9296 if (Init.isInvalid())
9297 return StmtError();
9298
9299 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9300 if (Range.isInvalid())
9301 return StmtError();
9302
9303 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9304 assert(getSema().getLangOpts().CPlusPlus23 ||
9305 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9306 auto ForRangeLifetimeExtendTemps =
9307 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9308
9309 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9310 if (Begin.isInvalid())
9311 return StmtError();
9312 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9313 if (End.isInvalid())
9314 return StmtError();
9315
9316 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9317 if (Cond.isInvalid())
9318 return StmtError();
9319 if (Cond.get())
9320 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9321 if (Cond.isInvalid())
9322 return StmtError();
9323 if (Cond.get())
9324 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9325
9326 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9327 if (Inc.isInvalid())
9328 return StmtError();
9329 if (Inc.get())
9330 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9331
9332 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9333 if (LoopVar.isInvalid())
9334 return StmtError();
9335
9336 StmtResult NewStmt = S;
9337 if (getDerived().AlwaysRebuild() ||
9338 Init.get() != S->getInit() ||
9339 Range.get() != S->getRangeStmt() ||
9340 Begin.get() != S->getBeginStmt() ||
9341 End.get() != S->getEndStmt() ||
9342 Cond.get() != S->getCond() ||
9343 Inc.get() != S->getInc() ||
9344 LoopVar.get() != S->getLoopVarStmt()) {
9345 NewStmt = getDerived().RebuildCXXForRangeStmt(
9346 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9347 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9348 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9349 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9350 // Might not have attached any initializer to the loop variable.
9351 getSema().ActOnInitializerError(
9352 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9353 return StmtError();
9354 }
9355 }
9356
9357 // OpenACC Restricts a while-loop inside of certain construct/clause
9358 // combinations, so diagnose that here in OpenACC mode.
9360 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9361
9362 StmtResult Body = getDerived().TransformStmt(S->getBody());
9363 if (Body.isInvalid())
9364 return StmtError();
9365
9366 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9367
9368 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9369 // it now so we have a new statement to attach the body to.
9370 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9371 NewStmt = getDerived().RebuildCXXForRangeStmt(
9372 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9373 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9374 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9375 if (NewStmt.isInvalid())
9376 return StmtError();
9377 }
9378
9379 if (NewStmt.get() == S)
9380 return S;
9381
9382 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9383}
9384
9385template<typename Derived>
9389 // Transform the nested-name-specifier, if any.
9390 NestedNameSpecifierLoc QualifierLoc;
9391 if (S->getQualifierLoc()) {
9392 QualifierLoc
9393 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9394 if (!QualifierLoc)
9395 return StmtError();
9396 }
9397
9398 // Transform the declaration name.
9399 DeclarationNameInfo NameInfo = S->getNameInfo();
9400 if (NameInfo.getName()) {
9401 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9402 if (!NameInfo.getName())
9403 return StmtError();
9404 }
9405
9406 // Check whether anything changed.
9407 if (!getDerived().AlwaysRebuild() &&
9408 QualifierLoc == S->getQualifierLoc() &&
9409 NameInfo.getName() == S->getNameInfo().getName())
9410 return S;
9411
9412 // Determine whether this name exists, if we can.
9413 CXXScopeSpec SS;
9414 SS.Adopt(QualifierLoc);
9415 bool Dependent = false;
9416 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9418 if (S->isIfExists())
9419 break;
9420
9421 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9422
9424 if (S->isIfNotExists())
9425 break;
9426
9427 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9428
9430 Dependent = true;
9431 break;
9432
9434 return StmtError();
9435 }
9436
9437 // We need to continue with the instantiation, so do so now.
9438 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9439 if (SubStmt.isInvalid())
9440 return StmtError();
9441
9442 // If we have resolved the name, just transform to the substatement.
9443 if (!Dependent)
9444 return SubStmt;
9445
9446 // The name is still dependent, so build a dependent expression again.
9447 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9448 S->isIfExists(),
9449 QualifierLoc,
9450 NameInfo,
9451 SubStmt.get());
9452}
9453
9454template<typename Derived>
9457 NestedNameSpecifierLoc QualifierLoc;
9458 if (E->getQualifierLoc()) {
9459 QualifierLoc
9460 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9461 if (!QualifierLoc)
9462 return ExprError();
9463 }
9464
9465 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9466 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9467 if (!PD)
9468 return ExprError();
9469
9470 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9471 if (Base.isInvalid())
9472 return ExprError();
9473
9474 return new (SemaRef.getASTContext())
9475 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9477 QualifierLoc, E->getMemberLoc());
9478}
9479
9480template <typename Derived>
9483 auto BaseRes = getDerived().TransformExpr(E->getBase());
9484 if (BaseRes.isInvalid())
9485 return ExprError();
9486 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9487 if (IdxRes.isInvalid())
9488 return ExprError();
9489
9490 if (!getDerived().AlwaysRebuild() &&
9491 BaseRes.get() == E->getBase() &&
9492 IdxRes.get() == E->getIdx())
9493 return E;
9494
9495 return getDerived().RebuildArraySubscriptExpr(
9496 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9497}
9498
9499template <typename Derived>
9501 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9502 if (TryBlock.isInvalid())
9503 return StmtError();
9504
9505 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9506 if (Handler.isInvalid())
9507 return StmtError();
9508
9509 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9510 Handler.get() == S->getHandler())
9511 return S;
9512
9513 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9514 TryBlock.get(), Handler.get());
9515}
9516
9517template <typename Derived>
9519 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9520 if (Block.isInvalid())
9521 return StmtError();
9522
9523 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9524}
9525
9526template <typename Derived>
9528 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9529 if (FilterExpr.isInvalid())
9530 return StmtError();
9531
9532 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9533 if (Block.isInvalid())
9534 return StmtError();
9535
9536 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9537 Block.get());
9538}
9539
9540template <typename Derived>
9542 if (isa<SEHFinallyStmt>(Handler))
9543 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9544 else
9545 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9546}
9547
9548template<typename Derived>
9551 return S;
9552}
9553
9554//===----------------------------------------------------------------------===//
9555// OpenMP directive transformation
9556//===----------------------------------------------------------------------===//
9557
9558template <typename Derived>
9559StmtResult
9560TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9561 // OMPCanonicalLoops are eliminated during transformation, since they will be
9562 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9563 // after transformation.
9564 return getDerived().TransformStmt(L->getLoopStmt());
9565}
9566
9567template <typename Derived>
9570
9571 // Transform the clauses
9573 ArrayRef<OMPClause *> Clauses = D->clauses();
9574 TClauses.reserve(Clauses.size());
9575 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9576 I != E; ++I) {
9577 if (*I) {
9578 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9579 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9580 getDerived().getSema().OpenMP().EndOpenMPClause();
9581 if (Clause)
9582 TClauses.push_back(Clause);
9583 } else {
9584 TClauses.push_back(nullptr);
9585 }
9586 }
9587 StmtResult AssociatedStmt;
9588 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9589 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9590 D->getDirectiveKind(),
9591 /*CurScope=*/nullptr);
9592 StmtResult Body;
9593 {
9594 Sema::CompoundScopeRAII CompoundScope(getSema());
9595 Stmt *CS;
9596 if (D->getDirectiveKind() == OMPD_atomic ||
9597 D->getDirectiveKind() == OMPD_critical ||
9598 D->getDirectiveKind() == OMPD_section ||
9599 D->getDirectiveKind() == OMPD_master)
9600 CS = D->getAssociatedStmt();
9601 else
9602 CS = D->getRawStmt();
9603 Body = getDerived().TransformStmt(CS);
9604 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9605 getSema().getLangOpts().OpenMPIRBuilder)
9606 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9607 }
9608 AssociatedStmt =
9609 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9610 if (AssociatedStmt.isInvalid()) {
9611 return StmtError();
9612 }
9613 }
9614 if (TClauses.size() != Clauses.size()) {
9615 return StmtError();
9616 }
9617
9618 // Transform directive name for 'omp critical' directive.
9619 DeclarationNameInfo DirName;
9620 if (D->getDirectiveKind() == OMPD_critical) {
9621 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9622 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9623 }
9624 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9625 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9626 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9627 } else if (D->getDirectiveKind() == OMPD_cancel) {
9628 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9629 }
9630
9631 return getDerived().RebuildOMPExecutableDirective(
9632 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9633 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
9634}
9635
9636/// This is mostly the same as above, but allows 'informational' class
9637/// directives when rebuilding the stmt. It still takes an
9638/// OMPExecutableDirective-type argument because we're reusing that as the
9639/// superclass for the 'assume' directive at present, instead of defining a
9640/// mostly-identical OMPInformationalDirective parent class.
9641template <typename Derived>
9644
9645 // Transform the clauses
9647 ArrayRef<OMPClause *> Clauses = D->clauses();
9648 TClauses.reserve(Clauses.size());
9649 for (OMPClause *C : Clauses) {
9650 if (C) {
9651 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
9652 OMPClause *Clause = getDerived().TransformOMPClause(C);
9653 getDerived().getSema().OpenMP().EndOpenMPClause();
9654 if (Clause)
9655 TClauses.push_back(Clause);
9656 } else {
9657 TClauses.push_back(nullptr);
9658 }
9659 }
9660 StmtResult AssociatedStmt;
9661 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9662 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9663 D->getDirectiveKind(),
9664 /*CurScope=*/nullptr);
9665 StmtResult Body;
9666 {
9667 Sema::CompoundScopeRAII CompoundScope(getSema());
9668 assert(D->getDirectiveKind() == OMPD_assume &&
9669 "Unexpected informational directive");
9670 Stmt *CS = D->getAssociatedStmt();
9671 Body = getDerived().TransformStmt(CS);
9672 }
9673 AssociatedStmt =
9674 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9675 if (AssociatedStmt.isInvalid())
9676 return StmtError();
9677 }
9678 if (TClauses.size() != Clauses.size())
9679 return StmtError();
9680
9681 DeclarationNameInfo DirName;
9682
9683 return getDerived().RebuildOMPInformationalDirective(
9684 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
9685 D->getBeginLoc(), D->getEndLoc());
9686}
9687
9688template <typename Derived>
9691 // TODO: Fix This
9692 unsigned OMPVersion = getDerived().getSema().getLangOpts().OpenMP;
9693 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9694 << getOpenMPDirectiveName(D->getDirectiveKind(), OMPVersion);
9695 return StmtError();
9696}
9697
9698template <typename Derived>
9699StmtResult
9700TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9701 DeclarationNameInfo DirName;
9702 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9703 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
9704 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9705 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9706 return Res;
9707}
9708
9709template <typename Derived>
9712 DeclarationNameInfo DirName;
9713 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9714 OMPD_simd, DirName, nullptr, D->getBeginLoc());
9715 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9716 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9717 return Res;
9718}
9719
9720template <typename Derived>
9723 DeclarationNameInfo DirName;
9724 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9725 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9726 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9727 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9728 return Res;
9729}
9730
9731template <typename Derived>
9734 DeclarationNameInfo DirName;
9735 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9736 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9737 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9738 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9739 return Res;
9740}
9741
9742template <typename Derived>
9745 DeclarationNameInfo DirName;
9746 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9747 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9748 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9749 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9750 return Res;
9751}
9752
9753template <typename Derived>
9756 DeclarationNameInfo DirName;
9757 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9758 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9759 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9760 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9761 return Res;
9762}
9763
9764template <typename Derived>
9766 OMPInterchangeDirective *D) {
9767 DeclarationNameInfo DirName;
9768 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9769 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9770 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9771 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9772 return Res;
9773}
9774
9775template <typename Derived>
9778 DeclarationNameInfo DirName;
9779 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9780 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9781 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9782 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9783 return Res;
9784}
9785
9786template <typename Derived>
9789 DeclarationNameInfo DirName;
9790 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9791 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9792 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9793 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9794 return Res;
9795}
9796
9797template <typename Derived>
9800 DeclarationNameInfo DirName;
9801 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9802 OMPD_for, DirName, nullptr, D->getBeginLoc());
9803 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9804 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9805 return Res;
9806}
9807
9808template <typename Derived>
9811 DeclarationNameInfo DirName;
9812 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9813 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
9814 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9815 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9816 return Res;
9817}
9818
9819template <typename Derived>
9822 DeclarationNameInfo DirName;
9823 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9824 OMPD_sections, DirName, nullptr, D->getBeginLoc());
9825 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9826 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9827 return Res;
9828}
9829
9830template <typename Derived>
9833 DeclarationNameInfo DirName;
9834 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9835 OMPD_section, DirName, nullptr, D->getBeginLoc());
9836 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9837 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9838 return Res;
9839}
9840
9841template <typename Derived>
9844 DeclarationNameInfo DirName;
9845 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9846 OMPD_scope, DirName, nullptr, D->getBeginLoc());
9847 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9848 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9849 return Res;
9850}
9851
9852template <typename Derived>
9855 DeclarationNameInfo DirName;
9856 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9857 OMPD_single, DirName, nullptr, D->getBeginLoc());
9858 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9859 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9860 return Res;
9861}
9862
9863template <typename Derived>
9866 DeclarationNameInfo DirName;
9867 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9868 OMPD_master, DirName, nullptr, D->getBeginLoc());
9869 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9870 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9871 return Res;
9872}
9873
9874template <typename Derived>
9877 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9878 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
9879 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9880 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9881 return Res;
9882}
9883
9884template <typename Derived>
9886 OMPParallelForDirective *D) {
9887 DeclarationNameInfo DirName;
9888 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9889 OMPD_parallel_for, DirName, nullptr, D->getBeginLoc());
9890 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9891 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9892 return Res;
9893}
9894
9895template <typename Derived>
9897 OMPParallelForSimdDirective *D) {
9898 DeclarationNameInfo DirName;
9899 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9900 OMPD_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9901 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9902 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9903 return Res;
9904}
9905
9906template <typename Derived>
9908 OMPParallelMasterDirective *D) {
9909 DeclarationNameInfo DirName;
9910 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9911 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
9912 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9913 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9914 return Res;
9915}
9916
9917template <typename Derived>
9919 OMPParallelMaskedDirective *D) {
9920 DeclarationNameInfo DirName;
9921 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9922 OMPD_parallel_masked, DirName, nullptr, D->getBeginLoc());
9923 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9924 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9925 return Res;
9926}
9927
9928template <typename Derived>
9930 OMPParallelSectionsDirective *D) {
9931 DeclarationNameInfo DirName;
9932 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9933 OMPD_parallel_sections, DirName, nullptr, D->getBeginLoc());
9934 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9935 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9936 return Res;
9937}
9938
9939template <typename Derived>
9942 DeclarationNameInfo DirName;
9943 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9944 OMPD_task, DirName, nullptr, D->getBeginLoc());
9945 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9946 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9947 return Res;
9948}
9949
9950template <typename Derived>
9952 OMPTaskyieldDirective *D) {
9953 DeclarationNameInfo DirName;
9954 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9955 OMPD_taskyield, DirName, nullptr, D->getBeginLoc());
9956 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9957 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9958 return Res;
9959}
9960
9961template <typename Derived>
9964 DeclarationNameInfo DirName;
9965 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9966 OMPD_barrier, DirName, nullptr, D->getBeginLoc());
9967 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9968 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9969 return Res;
9970}
9971
9972template <typename Derived>
9975 DeclarationNameInfo DirName;
9976 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9977 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
9978 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9979 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9980 return Res;
9981}
9982
9983template <typename Derived>
9986 DeclarationNameInfo DirName;
9987 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9988 OMPD_assume, DirName, nullptr, D->getBeginLoc());
9989 StmtResult Res = getDerived().TransformOMPInformationalDirective(D);
9990 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9991 return Res;
9992}
9993
9994template <typename Derived>
9997 DeclarationNameInfo DirName;
9998 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9999 OMPD_error, DirName, nullptr, D->getBeginLoc());
10000 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10001 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10002 return Res;
10003}
10004
10005template <typename Derived>
10007 OMPTaskgroupDirective *D) {
10008 DeclarationNameInfo DirName;
10009 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10010 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
10011 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10012 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10013 return Res;
10014}
10015
10016template <typename Derived>
10019 DeclarationNameInfo DirName;
10020 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10021 OMPD_flush, DirName, nullptr, D->getBeginLoc());
10022 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10023 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10024 return Res;
10025}
10026
10027template <typename Derived>
10030 DeclarationNameInfo DirName;
10031 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10032 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
10033 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10034 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10035 return Res;
10036}
10037
10038template <typename Derived>
10041 DeclarationNameInfo DirName;
10042 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10043 OMPD_scan, DirName, nullptr, D->getBeginLoc());
10044 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10045 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10046 return Res;
10047}
10048
10049template <typename Derived>
10052 DeclarationNameInfo DirName;
10053 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10054 OMPD_ordered, DirName, nullptr, D->getBeginLoc());
10055 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10056 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10057 return Res;
10058}
10059
10060template <typename Derived>
10063 DeclarationNameInfo DirName;
10064 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10065 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
10066 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10067 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10068 return Res;
10069}
10070
10071template <typename Derived>
10074 DeclarationNameInfo DirName;
10075 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10076 OMPD_target, DirName, nullptr, D->getBeginLoc());
10077 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10078 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10079 return Res;
10080}
10081
10082template <typename Derived>
10084 OMPTargetDataDirective *D) {
10085 DeclarationNameInfo DirName;
10086 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10087 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
10088 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10089 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10090 return Res;
10091}
10092
10093template <typename Derived>
10095 OMPTargetEnterDataDirective *D) {
10096 DeclarationNameInfo DirName;
10097 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10098 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
10099 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10100 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10101 return Res;
10102}
10103
10104template <typename Derived>
10106 OMPTargetExitDataDirective *D) {
10107 DeclarationNameInfo DirName;
10108 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10109 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
10110 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10111 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10112 return Res;
10113}
10114
10115template <typename Derived>
10117 OMPTargetParallelDirective *D) {
10118 DeclarationNameInfo DirName;
10119 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10120 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
10121 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10122 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10123 return Res;
10124}
10125
10126template <typename Derived>
10128 OMPTargetParallelForDirective *D) {
10129 DeclarationNameInfo DirName;
10130 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10131 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
10132 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10133 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10134 return Res;
10135}
10136
10137template <typename Derived>
10139 OMPTargetUpdateDirective *D) {
10140 DeclarationNameInfo DirName;
10141 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10142 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
10143 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10144 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10145 return Res;
10146}
10147
10148template <typename Derived>
10151 DeclarationNameInfo DirName;
10152 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10153 OMPD_teams, DirName, nullptr, D->getBeginLoc());
10154 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10155 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10156 return Res;
10157}
10158
10159template <typename Derived>
10161 OMPCancellationPointDirective *D) {
10162 DeclarationNameInfo DirName;
10163 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10164 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
10165 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10166 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10167 return Res;
10168}
10169
10170template <typename Derived>
10173 DeclarationNameInfo DirName;
10174 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10175 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
10176 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10177 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10178 return Res;
10179}
10180
10181template <typename Derived>
10184 DeclarationNameInfo DirName;
10185 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10186 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
10187 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10188 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10189 return Res;
10190}
10191
10192template <typename Derived>
10194 OMPTaskLoopSimdDirective *D) {
10195 DeclarationNameInfo DirName;
10196 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10197 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10198 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10199 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10200 return Res;
10201}
10202
10203template <typename Derived>
10205 OMPMasterTaskLoopDirective *D) {
10206 DeclarationNameInfo DirName;
10207 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10208 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
10209 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10210 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10211 return Res;
10212}
10213
10214template <typename Derived>
10216 OMPMaskedTaskLoopDirective *D) {
10217 DeclarationNameInfo DirName;
10218 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10219 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10220 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10221 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10222 return Res;
10223}
10224
10225template <typename Derived>
10227 OMPMasterTaskLoopSimdDirective *D) {
10228 DeclarationNameInfo DirName;
10229 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10230 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10231 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10232 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10233 return Res;
10234}
10235
10236template <typename Derived>
10238 OMPMaskedTaskLoopSimdDirective *D) {
10239 DeclarationNameInfo DirName;
10240 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10241 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10242 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10243 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10244 return Res;
10245}
10246
10247template <typename Derived>
10249 OMPParallelMasterTaskLoopDirective *D) {
10250 DeclarationNameInfo DirName;
10251 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10252 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10253 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10254 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10255 return Res;
10256}
10257
10258template <typename Derived>
10260 OMPParallelMaskedTaskLoopDirective *D) {
10261 DeclarationNameInfo DirName;
10262 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10263 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10264 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10265 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10266 return Res;
10267}
10268
10269template <typename Derived>
10272 OMPParallelMasterTaskLoopSimdDirective *D) {
10273 DeclarationNameInfo DirName;
10274 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10275 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10276 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10277 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10278 return Res;
10279}
10280
10281template <typename Derived>
10284 OMPParallelMaskedTaskLoopSimdDirective *D) {
10285 DeclarationNameInfo DirName;
10286 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10287 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10288 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10289 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10290 return Res;
10291}
10292
10293template <typename Derived>
10295 OMPDistributeDirective *D) {
10296 DeclarationNameInfo DirName;
10297 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10298 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10299 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10300 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10301 return Res;
10302}
10303
10304template <typename Derived>
10306 OMPDistributeParallelForDirective *D) {
10307 DeclarationNameInfo DirName;
10308 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10309 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10310 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10311 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10312 return Res;
10313}
10314
10315template <typename Derived>
10318 OMPDistributeParallelForSimdDirective *D) {
10319 DeclarationNameInfo DirName;
10320 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10321 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10322 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10323 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10324 return Res;
10325}
10326
10327template <typename Derived>
10329 OMPDistributeSimdDirective *D) {
10330 DeclarationNameInfo DirName;
10331 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10332 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
10333 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10334 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10335 return Res;
10336}
10337
10338template <typename Derived>
10340 OMPTargetParallelForSimdDirective *D) {
10341 DeclarationNameInfo DirName;
10342 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10343 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10344 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10345 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10346 return Res;
10347}
10348
10349template <typename Derived>
10351 OMPTargetSimdDirective *D) {
10352 DeclarationNameInfo DirName;
10353 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10354 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
10355 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10356 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10357 return Res;
10358}
10359
10360template <typename Derived>
10362 OMPTeamsDistributeDirective *D) {
10363 DeclarationNameInfo DirName;
10364 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10365 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10366 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10367 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10368 return Res;
10369}
10370
10371template <typename Derived>
10373 OMPTeamsDistributeSimdDirective *D) {
10374 DeclarationNameInfo DirName;
10375 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10376 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10377 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10378 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10379 return Res;
10380}
10381
10382template <typename Derived>
10384 OMPTeamsDistributeParallelForSimdDirective *D) {
10385 DeclarationNameInfo DirName;
10386 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10387 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10388 D->getBeginLoc());
10389 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10390 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10391 return Res;
10392}
10393
10394template <typename Derived>
10396 OMPTeamsDistributeParallelForDirective *D) {
10397 DeclarationNameInfo DirName;
10398 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10399 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10400 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10401 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10402 return Res;
10403}
10404
10405template <typename Derived>
10407 OMPTargetTeamsDirective *D) {
10408 DeclarationNameInfo DirName;
10409 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10410 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10411 auto Res = getDerived().TransformOMPExecutableDirective(D);
10412 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10413 return Res;
10414}
10415
10416template <typename Derived>
10418 OMPTargetTeamsDistributeDirective *D) {
10419 DeclarationNameInfo DirName;
10420 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10421 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10422 auto Res = getDerived().TransformOMPExecutableDirective(D);
10423 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10424 return Res;
10425}
10426
10427template <typename Derived>
10430 OMPTargetTeamsDistributeParallelForDirective *D) {
10431 DeclarationNameInfo DirName;
10432 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10433 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10434 D->getBeginLoc());
10435 auto Res = getDerived().TransformOMPExecutableDirective(D);
10436 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10437 return Res;
10438}
10439
10440template <typename Derived>
10443 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10444 DeclarationNameInfo DirName;
10445 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10446 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10447 D->getBeginLoc());
10448 auto Res = getDerived().TransformOMPExecutableDirective(D);
10449 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10450 return Res;
10451}
10452
10453template <typename Derived>
10456 OMPTargetTeamsDistributeSimdDirective *D) {
10457 DeclarationNameInfo DirName;
10458 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10459 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10460 auto Res = getDerived().TransformOMPExecutableDirective(D);
10461 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10462 return Res;
10463}
10464
10465template <typename Derived>
10468 DeclarationNameInfo DirName;
10469 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10470 OMPD_interop, DirName, nullptr, D->getBeginLoc());
10471 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10472 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10473 return Res;
10474}
10475
10476template <typename Derived>
10479 DeclarationNameInfo DirName;
10480 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10481 OMPD_dispatch, DirName, nullptr, D->getBeginLoc());
10482 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10483 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10484 return Res;
10485}
10486
10487template <typename Derived>
10490 DeclarationNameInfo DirName;
10491 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10492 OMPD_masked, DirName, nullptr, D->getBeginLoc());
10493 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10494 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10495 return Res;
10496}
10497
10498template <typename Derived>
10500 OMPGenericLoopDirective *D) {
10501 DeclarationNameInfo DirName;
10502 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10503 OMPD_loop, DirName, nullptr, D->getBeginLoc());
10504 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10505 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10506 return Res;
10507}
10508
10509template <typename Derived>
10511 OMPTeamsGenericLoopDirective *D) {
10512 DeclarationNameInfo DirName;
10513 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10514 OMPD_teams_loop, DirName, nullptr, D->getBeginLoc());
10515 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10516 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10517 return Res;
10518}
10519
10520template <typename Derived>
10522 OMPTargetTeamsGenericLoopDirective *D) {
10523 DeclarationNameInfo DirName;
10524 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10525 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
10526 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10527 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10528 return Res;
10529}
10530
10531template <typename Derived>
10533 OMPParallelGenericLoopDirective *D) {
10534 DeclarationNameInfo DirName;
10535 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10536 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
10537 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10538 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10539 return Res;
10540}
10541
10542template <typename Derived>
10545 OMPTargetParallelGenericLoopDirective *D) {
10546 DeclarationNameInfo DirName;
10547 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10548 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10549 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10550 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10551 return Res;
10552}
10553
10554//===----------------------------------------------------------------------===//
10555// OpenMP clause transformation
10556//===----------------------------------------------------------------------===//
10557template <typename Derived>
10559 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10560 if (Cond.isInvalid())
10561 return nullptr;
10562 return getDerived().RebuildOMPIfClause(
10563 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10564 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10565}
10566
10567template <typename Derived>
10569 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10570 if (Cond.isInvalid())
10571 return nullptr;
10572 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10573 C->getLParenLoc(), C->getEndLoc());
10574}
10575
10576template <typename Derived>
10577OMPClause *
10579 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
10580 if (NumThreads.isInvalid())
10581 return nullptr;
10582 return getDerived().RebuildOMPNumThreadsClause(
10583 C->getModifier(), NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(),
10584 C->getModifierLoc(), C->getEndLoc());
10585}
10586
10587template <typename Derived>
10588OMPClause *
10590 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10591 if (E.isInvalid())
10592 return nullptr;
10593 return getDerived().RebuildOMPSafelenClause(
10594 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10595}
10596
10597template <typename Derived>
10598OMPClause *
10600 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10601 if (E.isInvalid())
10602 return nullptr;
10603 return getDerived().RebuildOMPAllocatorClause(
10604 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10605}
10606
10607template <typename Derived>
10608OMPClause *
10610 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
10611 if (E.isInvalid())
10612 return nullptr;
10613 return getDerived().RebuildOMPSimdlenClause(
10614 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10615}
10616
10617template <typename Derived>
10619 SmallVector<Expr *, 4> TransformedSizes;
10620 TransformedSizes.reserve(C->getNumSizes());
10621 bool Changed = false;
10622 for (Expr *E : C->getSizesRefs()) {
10623 if (!E) {
10624 TransformedSizes.push_back(nullptr);
10625 continue;
10626 }
10627
10628 ExprResult T = getDerived().TransformExpr(E);
10629 if (T.isInvalid())
10630 return nullptr;
10631 if (E != T.get())
10632 Changed = true;
10633 TransformedSizes.push_back(T.get());
10634 }
10635
10636 if (!Changed && !getDerived().AlwaysRebuild())
10637 return C;
10638 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
10639 C->getLParenLoc(), C->getEndLoc());
10640}
10641
10642template <typename Derived>
10643OMPClause *
10645 SmallVector<Expr *, 4> TransformedCounts;
10646 TransformedCounts.reserve(C->getNumCounts());
10647 for (Expr *E : C->getCountsRefs()) {
10648 if (!E) {
10649 TransformedCounts.push_back(nullptr);
10650 continue;
10651 }
10652
10653 ExprResult T = getDerived().TransformExpr(E);
10654 if (T.isInvalid())
10655 return nullptr;
10656 TransformedCounts.push_back(T.get());
10657 }
10658
10659 return RebuildOMPCountsClause(TransformedCounts, C->getBeginLoc(),
10660 C->getLParenLoc(), C->getEndLoc(),
10661 C->getOmpFillIndex(), C->getOmpFillLoc());
10662}
10663
10664template <typename Derived>
10665OMPClause *
10667 SmallVector<Expr *> TransformedArgs;
10668 TransformedArgs.reserve(C->getNumLoops());
10669 bool Changed = false;
10670 for (Expr *E : C->getArgsRefs()) {
10671 if (!E) {
10672 TransformedArgs.push_back(nullptr);
10673 continue;
10674 }
10675
10676 ExprResult T = getDerived().TransformExpr(E);
10677 if (T.isInvalid())
10678 return nullptr;
10679 if (E != T.get())
10680 Changed = true;
10681 TransformedArgs.push_back(T.get());
10682 }
10683
10684 if (!Changed && !getDerived().AlwaysRebuild())
10685 return C;
10686 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
10687 C->getLParenLoc(), C->getEndLoc());
10688}
10689
10690template <typename Derived>
10692 if (!getDerived().AlwaysRebuild())
10693 return C;
10694 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10695}
10696
10697template <typename Derived>
10698OMPClause *
10700 ExprResult T = getDerived().TransformExpr(C->getFactor());
10701 if (T.isInvalid())
10702 return nullptr;
10703 Expr *Factor = T.get();
10704 bool Changed = Factor != C->getFactor();
10705
10706 if (!Changed && !getDerived().AlwaysRebuild())
10707 return C;
10708 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10709 C->getEndLoc());
10710}
10711
10712template <typename Derived>
10713OMPClause *
10715 ExprResult F = getDerived().TransformExpr(C->getFirst());
10716 if (F.isInvalid())
10717 return nullptr;
10718
10719 ExprResult Cn = getDerived().TransformExpr(C->getCount());
10720 if (Cn.isInvalid())
10721 return nullptr;
10722
10723 Expr *First = F.get();
10724 Expr *Count = Cn.get();
10725
10726 bool Changed = (First != C->getFirst()) || (Count != C->getCount());
10727
10728 // If no changes and AlwaysRebuild() is false, return the original clause
10729 if (!Changed && !getDerived().AlwaysRebuild())
10730 return C;
10731
10732 return RebuildOMPLoopRangeClause(First, Count, C->getBeginLoc(),
10733 C->getLParenLoc(), C->getFirstLoc(),
10734 C->getCountLoc(), C->getEndLoc());
10735}
10736
10737template <typename Derived>
10738OMPClause *
10740 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10741 if (E.isInvalid())
10742 return nullptr;
10743 return getDerived().RebuildOMPCollapseClause(
10744 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10745}
10746
10747template <typename Derived>
10748OMPClause *
10750 return getDerived().RebuildOMPDefaultClause(
10751 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getDefaultVC(),
10752 C->getDefaultVCLoc(), C->getBeginLoc(), C->getLParenLoc(),
10753 C->getEndLoc());
10754}
10755
10756template <typename Derived>
10757OMPClause *
10759 // No need to rebuild this clause, no template-dependent parameters.
10760 return C;
10761}
10762
10763template <typename Derived>
10764OMPClause *
10766 Expr *Impex = C->getImpexType();
10767 ExprResult TransformedImpex = getDerived().TransformExpr(Impex);
10768
10769 if (TransformedImpex.isInvalid())
10770 return nullptr;
10771
10772 return getDerived().RebuildOMPTransparentClause(
10773 TransformedImpex.get(), C->getBeginLoc(), C->getLParenLoc(),
10774 C->getEndLoc());
10775}
10776
10777template <typename Derived>
10778OMPClause *
10780 return getDerived().RebuildOMPProcBindClause(
10781 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10782 C->getLParenLoc(), C->getEndLoc());
10783}
10784
10785template <typename Derived>
10786OMPClause *
10788 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10789 if (E.isInvalid())
10790 return nullptr;
10791 return getDerived().RebuildOMPScheduleClause(
10792 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10793 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10794 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10795 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10796}
10797
10798template <typename Derived>
10799OMPClause *
10801 ExprResult E;
10802 if (auto *Num = C->getNumForLoops()) {
10803 E = getDerived().TransformExpr(Num);
10804 if (E.isInvalid())
10805 return nullptr;
10806 }
10807 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10808 C->getLParenLoc(), E.get());
10809}
10810
10811template <typename Derived>
10812OMPClause *
10814 ExprResult E;
10815 if (Expr *Evt = C->getEventHandler()) {
10816 E = getDerived().TransformExpr(Evt);
10817 if (E.isInvalid())
10818 return nullptr;
10819 }
10820 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10821 C->getLParenLoc(), C->getEndLoc());
10822}
10823
10824template <typename Derived>
10825OMPClause *
10828 if (auto *Condition = C->getCondition()) {
10829 Cond = getDerived().TransformExpr(Condition);
10830 if (Cond.isInvalid())
10831 return nullptr;
10832 }
10833 return getDerived().RebuildOMPNowaitClause(Cond.get(), C->getBeginLoc(),
10834 C->getLParenLoc(), C->getEndLoc());
10835}
10836
10837template <typename Derived>
10838OMPClause *
10840 // No need to rebuild this clause, no template-dependent parameters.
10841 return C;
10842}
10843
10844template <typename Derived>
10845OMPClause *
10847 // No need to rebuild this clause, no template-dependent parameters.
10848 return C;
10849}
10850
10851template <typename Derived>
10853 // No need to rebuild this clause, no template-dependent parameters.
10854 return C;
10855}
10856
10857template <typename Derived>
10859 // No need to rebuild this clause, no template-dependent parameters.
10860 return C;
10861}
10862
10863template <typename Derived>
10864OMPClause *
10866 // No need to rebuild this clause, no template-dependent parameters.
10867 return C;
10868}
10869
10870template <typename Derived>
10871OMPClause *
10873 // No need to rebuild this clause, no template-dependent parameters.
10874 return C;
10875}
10876
10877template <typename Derived>
10878OMPClause *
10880 // No need to rebuild this clause, no template-dependent parameters.
10881 return C;
10882}
10883
10884template <typename Derived>
10886 // No need to rebuild this clause, no template-dependent parameters.
10887 return C;
10888}
10889
10890template <typename Derived>
10891OMPClause *
10893 return C;
10894}
10895
10896template <typename Derived>
10898 ExprResult E = getDerived().TransformExpr(C->getExpr());
10899 if (E.isInvalid())
10900 return nullptr;
10901 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
10902 C->getLParenLoc(), C->getEndLoc());
10903}
10904
10905template <typename Derived>
10906OMPClause *
10908 return C;
10909}
10910
10911template <typename Derived>
10912OMPClause *
10914 return C;
10915}
10916template <typename Derived>
10918 OMPNoOpenMPRoutinesClause *C) {
10919 return C;
10920}
10921template <typename Derived>
10923 OMPNoOpenMPConstructsClause *C) {
10924 return C;
10925}
10926template <typename Derived>
10928 OMPNoParallelismClause *C) {
10929 return C;
10930}
10931
10932template <typename Derived>
10933OMPClause *
10935 // No need to rebuild this clause, no template-dependent parameters.
10936 return C;
10937}
10938
10939template <typename Derived>
10940OMPClause *
10942 // No need to rebuild this clause, no template-dependent parameters.
10943 return C;
10944}
10945
10946template <typename Derived>
10947OMPClause *
10949 // No need to rebuild this clause, no template-dependent parameters.
10950 return C;
10951}
10952
10953template <typename Derived>
10954OMPClause *
10956 // No need to rebuild this clause, no template-dependent parameters.
10957 return C;
10958}
10959
10960template <typename Derived>
10961OMPClause *
10963 // No need to rebuild this clause, no template-dependent parameters.
10964 return C;
10965}
10966
10967template <typename Derived>
10969 // No need to rebuild this clause, no template-dependent parameters.
10970 return C;
10971}
10972
10973template <typename Derived>
10974OMPClause *
10976 // No need to rebuild this clause, no template-dependent parameters.
10977 return C;
10978}
10979
10980template <typename Derived>
10982 // No need to rebuild this clause, no template-dependent parameters.
10983 return C;
10984}
10985
10986template <typename Derived>
10987OMPClause *
10989 // No need to rebuild this clause, no template-dependent parameters.
10990 return C;
10991}
10992
10993template <typename Derived>
10995 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
10996 if (IVR.isInvalid())
10997 return nullptr;
10998
10999 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
11000 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
11001 for (Expr *E : llvm::drop_begin(C->varlist())) {
11002 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
11003 if (ER.isInvalid())
11004 return nullptr;
11005 InteropInfo.PreferTypes.push_back(ER.get());
11006 }
11007 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
11008 C->getBeginLoc(), C->getLParenLoc(),
11009 C->getVarLoc(), C->getEndLoc());
11010}
11011
11012template <typename Derived>
11014 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
11015 if (ER.isInvalid())
11016 return nullptr;
11017 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
11018 C->getLParenLoc(), C->getVarLoc(),
11019 C->getEndLoc());
11020}
11021
11022template <typename Derived>
11023OMPClause *
11025 ExprResult ER;
11026 if (Expr *IV = C->getInteropVar()) {
11027 ER = getDerived().TransformExpr(IV);
11028 if (ER.isInvalid())
11029 return nullptr;
11030 }
11031 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
11032 C->getLParenLoc(), C->getVarLoc(),
11033 C->getEndLoc());
11034}
11035
11036template <typename Derived>
11037OMPClause *
11039 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11040 if (Cond.isInvalid())
11041 return nullptr;
11042 return getDerived().RebuildOMPNovariantsClause(
11043 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11044}
11045
11046template <typename Derived>
11047OMPClause *
11049 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11050 if (Cond.isInvalid())
11051 return nullptr;
11052 return getDerived().RebuildOMPNocontextClause(
11053 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11054}
11055
11056template <typename Derived>
11057OMPClause *
11059 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
11060 if (ThreadID.isInvalid())
11061 return nullptr;
11062 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
11063 C->getLParenLoc(), C->getEndLoc());
11064}
11065
11066template <typename Derived>
11068 ExprResult E = getDerived().TransformExpr(C->getAlignment());
11069 if (E.isInvalid())
11070 return nullptr;
11071 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
11072 C->getLParenLoc(), C->getEndLoc());
11073}
11074
11075template <typename Derived>
11077 OMPUnifiedAddressClause *C) {
11078 llvm_unreachable("unified_address clause cannot appear in dependent context");
11079}
11080
11081template <typename Derived>
11083 OMPUnifiedSharedMemoryClause *C) {
11084 llvm_unreachable(
11085 "unified_shared_memory clause cannot appear in dependent context");
11086}
11087
11088template <typename Derived>
11090 OMPReverseOffloadClause *C) {
11091 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
11092}
11093
11094template <typename Derived>
11096 OMPDynamicAllocatorsClause *C) {
11097 llvm_unreachable(
11098 "dynamic_allocators clause cannot appear in dependent context");
11099}
11100
11101template <typename Derived>
11103 OMPAtomicDefaultMemOrderClause *C) {
11104 llvm_unreachable(
11105 "atomic_default_mem_order clause cannot appear in dependent context");
11106}
11107
11108template <typename Derived>
11109OMPClause *
11111 llvm_unreachable("self_maps clause cannot appear in dependent context");
11112}
11113
11114template <typename Derived>
11116 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
11117 C->getBeginLoc(), C->getLParenLoc(),
11118 C->getEndLoc());
11119}
11120
11121template <typename Derived>
11122OMPClause *
11124 return getDerived().RebuildOMPSeverityClause(
11125 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
11126 C->getLParenLoc(), C->getEndLoc());
11127}
11128
11129template <typename Derived>
11130OMPClause *
11132 ExprResult E = getDerived().TransformExpr(C->getMessageString());
11133 if (E.isInvalid())
11134 return nullptr;
11135 return getDerived().RebuildOMPMessageClause(
11136 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11137}
11138
11139template <typename Derived>
11140OMPClause *
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 return getDerived().RebuildOMPPrivateClause(
11151 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11152}
11153
11154template <typename Derived>
11156 OMPFirstprivateClause *C) {
11158 Vars.reserve(C->varlist_size());
11159 for (auto *VE : C->varlist()) {
11160 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11161 if (EVar.isInvalid())
11162 return nullptr;
11163 Vars.push_back(EVar.get());
11164 }
11165 return getDerived().RebuildOMPFirstprivateClause(
11166 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11167}
11168
11169template <typename Derived>
11170OMPClause *
11173 Vars.reserve(C->varlist_size());
11174 for (auto *VE : C->varlist()) {
11175 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11176 if (EVar.isInvalid())
11177 return nullptr;
11178 Vars.push_back(EVar.get());
11179 }
11180 return getDerived().RebuildOMPLastprivateClause(
11181 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11182 C->getLParenLoc(), C->getEndLoc());
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 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11197 C->getLParenLoc(), C->getEndLoc());
11198}
11199
11200template <typename Derived>
11201OMPClause *
11204 Vars.reserve(C->varlist_size());
11205 for (auto *VE : C->varlist()) {
11206 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11207 if (EVar.isInvalid())
11208 return nullptr;
11209 Vars.push_back(EVar.get());
11210 }
11211 CXXScopeSpec ReductionIdScopeSpec;
11212 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11213
11214 DeclarationNameInfo NameInfo = C->getNameInfo();
11215 if (NameInfo.getName()) {
11216 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11217 if (!NameInfo.getName())
11218 return nullptr;
11219 }
11220 // Build a list of all UDR decls with the same names ranged by the Scopes.
11221 // The Scope boundary is a duplication of the previous decl.
11222 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11223 for (auto *E : C->reduction_ops()) {
11224 // Transform all the decls.
11225 if (E) {
11226 auto *ULE = cast<UnresolvedLookupExpr>(E);
11227 UnresolvedSet<8> Decls;
11228 for (auto *D : ULE->decls()) {
11229 NamedDecl *InstD =
11230 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11231 Decls.addDecl(InstD, InstD->getAccess());
11232 }
11233 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11234 SemaRef.Context, /*NamingClass=*/nullptr,
11235 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11236 /*ADL=*/true, Decls.begin(), Decls.end(),
11237 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11238 } else
11239 UnresolvedReductions.push_back(nullptr);
11240 }
11241 return getDerived().RebuildOMPReductionClause(
11242 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11243 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11244 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11245}
11246
11247template <typename Derived>
11249 OMPTaskReductionClause *C) {
11251 Vars.reserve(C->varlist_size());
11252 for (auto *VE : C->varlist()) {
11253 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11254 if (EVar.isInvalid())
11255 return nullptr;
11256 Vars.push_back(EVar.get());
11257 }
11258 CXXScopeSpec ReductionIdScopeSpec;
11259 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11260
11261 DeclarationNameInfo NameInfo = C->getNameInfo();
11262 if (NameInfo.getName()) {
11263 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11264 if (!NameInfo.getName())
11265 return nullptr;
11266 }
11267 // Build a list of all UDR decls with the same names ranged by the Scopes.
11268 // The Scope boundary is a duplication of the previous decl.
11269 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11270 for (auto *E : C->reduction_ops()) {
11271 // Transform all the decls.
11272 if (E) {
11273 auto *ULE = cast<UnresolvedLookupExpr>(E);
11274 UnresolvedSet<8> Decls;
11275 for (auto *D : ULE->decls()) {
11276 NamedDecl *InstD =
11277 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11278 Decls.addDecl(InstD, InstD->getAccess());
11279 }
11280 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11281 SemaRef.Context, /*NamingClass=*/nullptr,
11282 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11283 /*ADL=*/true, Decls.begin(), Decls.end(),
11284 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11285 } else
11286 UnresolvedReductions.push_back(nullptr);
11287 }
11288 return getDerived().RebuildOMPTaskReductionClause(
11289 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11290 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11291}
11292
11293template <typename Derived>
11294OMPClause *
11297 Vars.reserve(C->varlist_size());
11298 for (auto *VE : C->varlist()) {
11299 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11300 if (EVar.isInvalid())
11301 return nullptr;
11302 Vars.push_back(EVar.get());
11303 }
11304 CXXScopeSpec ReductionIdScopeSpec;
11305 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11306
11307 DeclarationNameInfo NameInfo = C->getNameInfo();
11308 if (NameInfo.getName()) {
11309 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11310 if (!NameInfo.getName())
11311 return nullptr;
11312 }
11313 // Build a list of all UDR decls with the same names ranged by the Scopes.
11314 // The Scope boundary is a duplication of the previous decl.
11315 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11316 for (auto *E : C->reduction_ops()) {
11317 // Transform all the decls.
11318 if (E) {
11319 auto *ULE = cast<UnresolvedLookupExpr>(E);
11320 UnresolvedSet<8> Decls;
11321 for (auto *D : ULE->decls()) {
11322 NamedDecl *InstD =
11323 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11324 Decls.addDecl(InstD, InstD->getAccess());
11325 }
11326 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11327 SemaRef.Context, /*NamingClass=*/nullptr,
11328 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11329 /*ADL=*/true, Decls.begin(), Decls.end(),
11330 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11331 } else
11332 UnresolvedReductions.push_back(nullptr);
11333 }
11334 return getDerived().RebuildOMPInReductionClause(
11335 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11336 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11337}
11338
11339template <typename Derived>
11340OMPClause *
11343 Vars.reserve(C->varlist_size());
11344 for (auto *VE : C->varlist()) {
11345 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11346 if (EVar.isInvalid())
11347 return nullptr;
11348 Vars.push_back(EVar.get());
11349 }
11350 ExprResult Step = getDerived().TransformExpr(C->getStep());
11351 if (Step.isInvalid())
11352 return nullptr;
11353 return getDerived().RebuildOMPLinearClause(
11354 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11355 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11356 C->getEndLoc());
11357}
11358
11359template <typename Derived>
11360OMPClause *
11363 Vars.reserve(C->varlist_size());
11364 for (auto *VE : C->varlist()) {
11365 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11366 if (EVar.isInvalid())
11367 return nullptr;
11368 Vars.push_back(EVar.get());
11369 }
11370 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11371 if (Alignment.isInvalid())
11372 return nullptr;
11373 return getDerived().RebuildOMPAlignedClause(
11374 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11375 C->getColonLoc(), C->getEndLoc());
11376}
11377
11378template <typename Derived>
11379OMPClause *
11382 Vars.reserve(C->varlist_size());
11383 for (auto *VE : C->varlist()) {
11384 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11385 if (EVar.isInvalid())
11386 return nullptr;
11387 Vars.push_back(EVar.get());
11388 }
11389 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11390 C->getLParenLoc(), C->getEndLoc());
11391}
11392
11393template <typename Derived>
11394OMPClause *
11397 Vars.reserve(C->varlist_size());
11398 for (auto *VE : C->varlist()) {
11399 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11400 if (EVar.isInvalid())
11401 return nullptr;
11402 Vars.push_back(EVar.get());
11403 }
11404 return getDerived().RebuildOMPCopyprivateClause(
11405 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11406}
11407
11408template <typename Derived>
11411 Vars.reserve(C->varlist_size());
11412 for (auto *VE : C->varlist()) {
11413 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11414 if (EVar.isInvalid())
11415 return nullptr;
11416 Vars.push_back(EVar.get());
11417 }
11418 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11419 C->getLParenLoc(), C->getEndLoc());
11420}
11421
11422template <typename Derived>
11423OMPClause *
11425 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11426 if (E.isInvalid())
11427 return nullptr;
11428 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11429 C->getLParenLoc(), C->getEndLoc());
11430}
11431
11432template <typename Derived>
11433OMPClause *
11436 Expr *DepModifier = C->getModifier();
11437 if (DepModifier) {
11438 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11439 if (DepModRes.isInvalid())
11440 return nullptr;
11441 DepModifier = DepModRes.get();
11442 }
11443 Vars.reserve(C->varlist_size());
11444 for (auto *VE : C->varlist()) {
11445 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11446 if (EVar.isInvalid())
11447 return nullptr;
11448 Vars.push_back(EVar.get());
11449 }
11450 return getDerived().RebuildOMPDependClause(
11451 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11452 C->getOmpAllMemoryLoc()},
11453 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11454}
11455
11456template <typename Derived>
11457OMPClause *
11459 ExprResult E = getDerived().TransformExpr(C->getDevice());
11460 if (E.isInvalid())
11461 return nullptr;
11462 return getDerived().RebuildOMPDeviceClause(
11463 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11464 C->getModifierLoc(), C->getEndLoc());
11465}
11466
11467template <typename Derived, class T>
11470 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11471 DeclarationNameInfo &MapperIdInfo,
11472 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11473 // Transform expressions in the list.
11474 Vars.reserve(C->varlist_size());
11475 for (auto *VE : C->varlist()) {
11476 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11477 if (EVar.isInvalid())
11478 return true;
11479 Vars.push_back(EVar.get());
11480 }
11481 // Transform mapper scope specifier and identifier.
11482 NestedNameSpecifierLoc QualifierLoc;
11483 if (C->getMapperQualifierLoc()) {
11484 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11485 C->getMapperQualifierLoc());
11486 if (!QualifierLoc)
11487 return true;
11488 }
11489 MapperIdScopeSpec.Adopt(QualifierLoc);
11490 MapperIdInfo = C->getMapperIdInfo();
11491 if (MapperIdInfo.getName()) {
11492 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11493 if (!MapperIdInfo.getName())
11494 return true;
11495 }
11496 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11497 // the previous user-defined mapper lookup in dependent environment.
11498 for (auto *E : C->mapperlists()) {
11499 // Transform all the decls.
11500 if (E) {
11501 auto *ULE = cast<UnresolvedLookupExpr>(E);
11502 UnresolvedSet<8> Decls;
11503 for (auto *D : ULE->decls()) {
11504 NamedDecl *InstD =
11505 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11506 Decls.addDecl(InstD, InstD->getAccess());
11507 }
11508 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11509 TT.getSema().Context, /*NamingClass=*/nullptr,
11510 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11511 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11512 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11513 } else {
11514 UnresolvedMappers.push_back(nullptr);
11515 }
11516 }
11517 return false;
11518}
11519
11520template <typename Derived>
11521OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11522 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11524 Expr *IteratorModifier = C->getIteratorModifier();
11525 if (IteratorModifier) {
11526 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11527 if (MapModRes.isInvalid())
11528 return nullptr;
11529 IteratorModifier = MapModRes.get();
11530 }
11531 CXXScopeSpec MapperIdScopeSpec;
11532 DeclarationNameInfo MapperIdInfo;
11533 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11535 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11536 return nullptr;
11537 return getDerived().RebuildOMPMapClause(
11538 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11539 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11540 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11541}
11542
11543template <typename Derived>
11544OMPClause *
11546 Expr *Allocator = C->getAllocator();
11547 if (Allocator) {
11548 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11549 if (AllocatorRes.isInvalid())
11550 return nullptr;
11551 Allocator = AllocatorRes.get();
11552 }
11553 Expr *Alignment = C->getAlignment();
11554 if (Alignment) {
11555 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11556 if (AlignmentRes.isInvalid())
11557 return nullptr;
11558 Alignment = AlignmentRes.get();
11559 }
11561 Vars.reserve(C->varlist_size());
11562 for (auto *VE : C->varlist()) {
11563 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11564 if (EVar.isInvalid())
11565 return nullptr;
11566 Vars.push_back(EVar.get());
11567 }
11568 return getDerived().RebuildOMPAllocateClause(
11569 Allocator, Alignment, C->getFirstAllocateModifier(),
11570 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11571 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11572 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11573}
11574
11575template <typename Derived>
11576OMPClause *
11579 Vars.reserve(C->varlist_size());
11580 for (auto *VE : C->varlist()) {
11581 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11582 if (EVar.isInvalid())
11583 return nullptr;
11584 Vars.push_back(EVar.get());
11585 }
11586 return getDerived().RebuildOMPNumTeamsClause(
11587 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11588}
11589
11590template <typename Derived>
11591OMPClause *
11594 Vars.reserve(C->varlist_size());
11595 for (auto *VE : C->varlist()) {
11596 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11597 if (EVar.isInvalid())
11598 return nullptr;
11599 Vars.push_back(EVar.get());
11600 }
11601 return getDerived().RebuildOMPThreadLimitClause(
11602 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11603}
11604
11605template <typename Derived>
11606OMPClause *
11608 ExprResult E = getDerived().TransformExpr(C->getPriority());
11609 if (E.isInvalid())
11610 return nullptr;
11611 return getDerived().RebuildOMPPriorityClause(
11612 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11613}
11614
11615template <typename Derived>
11616OMPClause *
11618 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11619 if (E.isInvalid())
11620 return nullptr;
11621 return getDerived().RebuildOMPGrainsizeClause(
11622 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11623 C->getModifierLoc(), C->getEndLoc());
11624}
11625
11626template <typename Derived>
11627OMPClause *
11629 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11630 if (E.isInvalid())
11631 return nullptr;
11632 return getDerived().RebuildOMPNumTasksClause(
11633 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11634 C->getModifierLoc(), C->getEndLoc());
11635}
11636
11637template <typename Derived>
11639 ExprResult E = getDerived().TransformExpr(C->getHint());
11640 if (E.isInvalid())
11641 return nullptr;
11642 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11643 C->getLParenLoc(), C->getEndLoc());
11644}
11645
11646template <typename Derived>
11648 OMPDistScheduleClause *C) {
11649 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11650 if (E.isInvalid())
11651 return nullptr;
11652 return getDerived().RebuildOMPDistScheduleClause(
11653 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11654 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11655}
11656
11657template <typename Derived>
11658OMPClause *
11660 // Rebuild Defaultmap Clause since we need to invoke the checking of
11661 // defaultmap(none:variable-category) after template initialization.
11662 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11663 C->getDefaultmapKind(),
11664 C->getBeginLoc(),
11665 C->getLParenLoc(),
11666 C->getDefaultmapModifierLoc(),
11667 C->getDefaultmapKindLoc(),
11668 C->getEndLoc());
11669}
11670
11671template <typename Derived>
11673 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11675 Expr *IteratorModifier = C->getIteratorModifier();
11676 if (IteratorModifier) {
11677 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11678 if (MapModRes.isInvalid())
11679 return nullptr;
11680 IteratorModifier = MapModRes.get();
11681 }
11682 CXXScopeSpec MapperIdScopeSpec;
11683 DeclarationNameInfo MapperIdInfo;
11684 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11686 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11687 return nullptr;
11688 return getDerived().RebuildOMPToClause(
11689 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11690 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11691 UnresolvedMappers);
11692}
11693
11694template <typename Derived>
11696 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11698 Expr *IteratorModifier = C->getIteratorModifier();
11699 if (IteratorModifier) {
11700 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11701 if (MapModRes.isInvalid())
11702 return nullptr;
11703 IteratorModifier = MapModRes.get();
11704 }
11705 CXXScopeSpec MapperIdScopeSpec;
11706 DeclarationNameInfo MapperIdInfo;
11707 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11709 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11710 return nullptr;
11711 return getDerived().RebuildOMPFromClause(
11712 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11713 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11714 UnresolvedMappers);
11715}
11716
11717template <typename Derived>
11719 OMPUseDevicePtrClause *C) {
11721 Vars.reserve(C->varlist_size());
11722 for (auto *VE : C->varlist()) {
11723 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11724 if (EVar.isInvalid())
11725 return nullptr;
11726 Vars.push_back(EVar.get());
11727 }
11728 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11729 return getDerived().RebuildOMPUseDevicePtrClause(
11730 Vars, Locs, C->getFallbackModifier(), C->getFallbackModifierLoc());
11731}
11732
11733template <typename Derived>
11735 OMPUseDeviceAddrClause *C) {
11737 Vars.reserve(C->varlist_size());
11738 for (auto *VE : C->varlist()) {
11739 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11740 if (EVar.isInvalid())
11741 return nullptr;
11742 Vars.push_back(EVar.get());
11743 }
11744 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11745 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11746}
11747
11748template <typename Derived>
11749OMPClause *
11752 Vars.reserve(C->varlist_size());
11753 for (auto *VE : C->varlist()) {
11754 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11755 if (EVar.isInvalid())
11756 return nullptr;
11757 Vars.push_back(EVar.get());
11758 }
11759 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11760 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11761}
11762
11763template <typename Derived>
11765 OMPHasDeviceAddrClause *C) {
11767 Vars.reserve(C->varlist_size());
11768 for (auto *VE : C->varlist()) {
11769 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11770 if (EVar.isInvalid())
11771 return nullptr;
11772 Vars.push_back(EVar.get());
11773 }
11774 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11775 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11776}
11777
11778template <typename Derived>
11779OMPClause *
11782 Vars.reserve(C->varlist_size());
11783 for (auto *VE : C->varlist()) {
11784 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11785 if (EVar.isInvalid())
11786 return nullptr;
11787 Vars.push_back(EVar.get());
11788 }
11789 return getDerived().RebuildOMPNontemporalClause(
11790 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11791}
11792
11793template <typename Derived>
11794OMPClause *
11797 Vars.reserve(C->varlist_size());
11798 for (auto *VE : C->varlist()) {
11799 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11800 if (EVar.isInvalid())
11801 return nullptr;
11802 Vars.push_back(EVar.get());
11803 }
11804 return getDerived().RebuildOMPInclusiveClause(
11805 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11806}
11807
11808template <typename Derived>
11809OMPClause *
11812 Vars.reserve(C->varlist_size());
11813 for (auto *VE : C->varlist()) {
11814 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11815 if (EVar.isInvalid())
11816 return nullptr;
11817 Vars.push_back(EVar.get());
11818 }
11819 return getDerived().RebuildOMPExclusiveClause(
11820 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11821}
11822
11823template <typename Derived>
11825 OMPUsesAllocatorsClause *C) {
11827 Data.reserve(C->getNumberOfAllocators());
11828 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11829 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11830 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11831 if (Allocator.isInvalid())
11832 continue;
11833 ExprResult AllocatorTraits;
11834 if (Expr *AT = D.AllocatorTraits) {
11835 AllocatorTraits = getDerived().TransformExpr(AT);
11836 if (AllocatorTraits.isInvalid())
11837 continue;
11838 }
11839 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11840 NewD.Allocator = Allocator.get();
11841 NewD.AllocatorTraits = AllocatorTraits.get();
11842 NewD.LParenLoc = D.LParenLoc;
11843 NewD.RParenLoc = D.RParenLoc;
11844 }
11845 return getDerived().RebuildOMPUsesAllocatorsClause(
11846 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11847}
11848
11849template <typename Derived>
11850OMPClause *
11852 SmallVector<Expr *, 4> Locators;
11853 Locators.reserve(C->varlist_size());
11854 ExprResult ModifierRes;
11855 if (Expr *Modifier = C->getModifier()) {
11856 ModifierRes = getDerived().TransformExpr(Modifier);
11857 if (ModifierRes.isInvalid())
11858 return nullptr;
11859 }
11860 for (Expr *E : C->varlist()) {
11861 ExprResult Locator = getDerived().TransformExpr(E);
11862 if (Locator.isInvalid())
11863 continue;
11864 Locators.push_back(Locator.get());
11865 }
11866 return getDerived().RebuildOMPAffinityClause(
11867 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11868 ModifierRes.get(), Locators);
11869}
11870
11871template <typename Derived>
11873 return getDerived().RebuildOMPOrderClause(
11874 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11875 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11876}
11877
11878template <typename Derived>
11880 return getDerived().RebuildOMPBindClause(
11881 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11882 C->getLParenLoc(), C->getEndLoc());
11883}
11884
11885template <typename Derived>
11887 OMPXDynCGroupMemClause *C) {
11888 ExprResult Size = getDerived().TransformExpr(C->getSize());
11889 if (Size.isInvalid())
11890 return nullptr;
11891 return getDerived().RebuildOMPXDynCGroupMemClause(
11892 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11893}
11894
11895template <typename Derived>
11897 OMPDynGroupprivateClause *C) {
11898 ExprResult Size = getDerived().TransformExpr(C->getSize());
11899 if (Size.isInvalid())
11900 return nullptr;
11901 return getDerived().RebuildOMPDynGroupprivateClause(
11902 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
11903 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
11904 C->getDynGroupprivateModifierLoc(),
11905 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
11906}
11907
11908template <typename Derived>
11909OMPClause *
11912 Vars.reserve(C->varlist_size());
11913 for (auto *VE : C->varlist()) {
11914 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11915 if (EVar.isInvalid())
11916 return nullptr;
11917 Vars.push_back(EVar.get());
11918 }
11919 return getDerived().RebuildOMPDoacrossClause(
11920 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11921 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11922}
11923
11924template <typename Derived>
11925OMPClause *
11928 for (auto *A : C->getAttrs())
11929 NewAttrs.push_back(getDerived().TransformAttr(A));
11930 return getDerived().RebuildOMPXAttributeClause(
11931 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11932}
11933
11934template <typename Derived>
11936 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11937}
11938
11939//===----------------------------------------------------------------------===//
11940// OpenACC transformation
11941//===----------------------------------------------------------------------===//
11942namespace {
11943template <typename Derived>
11944class OpenACCClauseTransform final
11945 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11946 TreeTransform<Derived> &Self;
11947 ArrayRef<const OpenACCClause *> ExistingClauses;
11948 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11949 OpenACCClause *NewClause = nullptr;
11950
11951 ExprResult VisitVar(Expr *VarRef) {
11952 ExprResult Res = Self.TransformExpr(VarRef);
11953
11954 if (!Res.isUsable())
11955 return Res;
11956
11957 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11958 ParsedClause.getClauseKind(),
11959 Res.get());
11960
11961 return Res;
11962 }
11963
11964 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11965 llvm::SmallVector<Expr *> InstantiatedVarList;
11966 for (Expr *CurVar : VarList) {
11967 ExprResult VarRef = VisitVar(CurVar);
11968
11969 if (VarRef.isUsable())
11970 InstantiatedVarList.push_back(VarRef.get());
11971 }
11972
11973 return InstantiatedVarList;
11974 }
11975
11976public:
11977 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11978 ArrayRef<const OpenACCClause *> ExistingClauses,
11979 SemaOpenACC::OpenACCParsedClause &PC)
11980 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
11981
11982 OpenACCClause *CreatedClause() const { return NewClause; }
11983
11984#define VISIT_CLAUSE(CLAUSE_NAME) \
11985 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11986#include "clang/Basic/OpenACCClauses.def"
11987};
11988
11989template <typename Derived>
11990void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11991 const OpenACCDefaultClause &C) {
11992 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
11993
11994 NewClause = OpenACCDefaultClause::Create(
11995 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
11996 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11997 ParsedClause.getEndLoc());
11998}
11999
12000template <typename Derived>
12001void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
12002 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12003 assert(Cond && "If constructed with invalid Condition");
12004 Sema::ConditionResult Res = Self.TransformCondition(
12005 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
12006
12007 if (Res.isInvalid() || !Res.get().second)
12008 return;
12009
12010 ParsedClause.setConditionDetails(Res.get().second);
12011
12012 NewClause = OpenACCIfClause::Create(
12013 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12014 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12015 ParsedClause.getEndLoc());
12016}
12017
12018template <typename Derived>
12019void OpenACCClauseTransform<Derived>::VisitSelfClause(
12020 const OpenACCSelfClause &C) {
12021
12022 // If this is an 'update' 'self' clause, this is actually a var list instead.
12023 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
12024 llvm::SmallVector<Expr *> InstantiatedVarList;
12025 for (Expr *CurVar : C.getVarList()) {
12026 ExprResult Res = Self.TransformExpr(CurVar);
12027
12028 if (!Res.isUsable())
12029 continue;
12030
12031 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
12032 ParsedClause.getClauseKind(),
12033 Res.get());
12034
12035 if (Res.isUsable())
12036 InstantiatedVarList.push_back(Res.get());
12037 }
12038
12039 ParsedClause.setVarListDetails(InstantiatedVarList,
12041
12042 NewClause = OpenACCSelfClause::Create(
12043 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12044 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12045 ParsedClause.getEndLoc());
12046 } else {
12047
12048 if (C.hasConditionExpr()) {
12049 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12051 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
12053
12054 if (Res.isInvalid() || !Res.get().second)
12055 return;
12056
12057 ParsedClause.setConditionDetails(Res.get().second);
12058 }
12059
12060 NewClause = OpenACCSelfClause::Create(
12061 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12062 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12063 ParsedClause.getEndLoc());
12064 }
12065}
12066
12067template <typename Derived>
12068void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
12069 const OpenACCNumGangsClause &C) {
12070 llvm::SmallVector<Expr *> InstantiatedIntExprs;
12071
12072 for (Expr *CurIntExpr : C.getIntExprs()) {
12073 ExprResult Res = Self.TransformExpr(CurIntExpr);
12074
12075 if (!Res.isUsable())
12076 return;
12077
12078 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12079 C.getClauseKind(),
12080 C.getBeginLoc(), Res.get());
12081 if (!Res.isUsable())
12082 return;
12083
12084 InstantiatedIntExprs.push_back(Res.get());
12085 }
12086
12087 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
12089 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12090 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12091 ParsedClause.getEndLoc());
12092}
12093
12094template <typename Derived>
12095void OpenACCClauseTransform<Derived>::VisitPrivateClause(
12096 const OpenACCPrivateClause &C) {
12097 llvm::SmallVector<Expr *> InstantiatedVarList;
12099
12100 for (const auto [RefExpr, InitRecipe] :
12101 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12102 ExprResult VarRef = VisitVar(RefExpr);
12103
12104 if (VarRef.isUsable()) {
12105 InstantiatedVarList.push_back(VarRef.get());
12106
12107 // We only have to create a new one if it is dependent, and Sema won't
12108 // make one of these unless the type is non-dependent.
12109 if (InitRecipe.isSet())
12110 InitRecipes.push_back(InitRecipe);
12111 else
12112 InitRecipes.push_back(
12113 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
12114 }
12115 }
12116 ParsedClause.setVarListDetails(InstantiatedVarList,
12118
12119 NewClause = OpenACCPrivateClause::Create(
12120 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12121 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12122 ParsedClause.getEndLoc());
12123}
12124
12125template <typename Derived>
12126void OpenACCClauseTransform<Derived>::VisitHostClause(
12127 const OpenACCHostClause &C) {
12128 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12130
12131 NewClause = OpenACCHostClause::Create(
12132 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12133 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12134 ParsedClause.getEndLoc());
12135}
12136
12137template <typename Derived>
12138void OpenACCClauseTransform<Derived>::VisitDeviceClause(
12139 const OpenACCDeviceClause &C) {
12140 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12142
12143 NewClause = OpenACCDeviceClause::Create(
12144 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12145 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12146 ParsedClause.getEndLoc());
12147}
12148
12149template <typename Derived>
12150void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
12152 llvm::SmallVector<Expr *> InstantiatedVarList;
12154
12155 for (const auto [RefExpr, InitRecipe] :
12156 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12157 ExprResult VarRef = VisitVar(RefExpr);
12158
12159 if (VarRef.isUsable()) {
12160 InstantiatedVarList.push_back(VarRef.get());
12161
12162 // We only have to create a new one if it is dependent, and Sema won't
12163 // make one of these unless the type is non-dependent.
12164 if (InitRecipe.isSet())
12165 InitRecipes.push_back(InitRecipe);
12166 else
12167 InitRecipes.push_back(
12168 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12169 VarRef.get()));
12170 }
12171 }
12172 ParsedClause.setVarListDetails(InstantiatedVarList,
12174
12176 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12177 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12178 ParsedClause.getEndLoc());
12179}
12180
12181template <typename Derived>
12182void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12183 const OpenACCNoCreateClause &C) {
12184 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12186
12188 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12189 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12190 ParsedClause.getEndLoc());
12191}
12192
12193template <typename Derived>
12194void OpenACCClauseTransform<Derived>::VisitPresentClause(
12195 const OpenACCPresentClause &C) {
12196 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12198
12199 NewClause = OpenACCPresentClause::Create(
12200 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12201 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12202 ParsedClause.getEndLoc());
12203}
12204
12205template <typename Derived>
12206void OpenACCClauseTransform<Derived>::VisitCopyClause(
12207 const OpenACCCopyClause &C) {
12208 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12209 C.getModifierList());
12210
12211 NewClause = OpenACCCopyClause::Create(
12212 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12213 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12214 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12215 ParsedClause.getEndLoc());
12216}
12217
12218template <typename Derived>
12219void OpenACCClauseTransform<Derived>::VisitLinkClause(
12220 const OpenACCLinkClause &C) {
12221 llvm_unreachable("link clause not valid unless a decl transform");
12222}
12223
12224template <typename Derived>
12225void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12227 llvm_unreachable("device_resident clause not valid unless a decl transform");
12228}
12229template <typename Derived>
12230void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12231 const OpenACCNoHostClause &C) {
12232 llvm_unreachable("nohost clause not valid unless a decl transform");
12233}
12234template <typename Derived>
12235void OpenACCClauseTransform<Derived>::VisitBindClause(
12236 const OpenACCBindClause &C) {
12237 llvm_unreachable("bind clause not valid unless a decl transform");
12238}
12239
12240template <typename Derived>
12241void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12242 const OpenACCCopyInClause &C) {
12243 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12244 C.getModifierList());
12245
12246 NewClause = OpenACCCopyInClause::Create(
12247 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12248 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12249 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12250 ParsedClause.getEndLoc());
12251}
12252
12253template <typename Derived>
12254void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12255 const OpenACCCopyOutClause &C) {
12256 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12257 C.getModifierList());
12258
12259 NewClause = OpenACCCopyOutClause::Create(
12260 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12261 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12262 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12263 ParsedClause.getEndLoc());
12264}
12265
12266template <typename Derived>
12267void OpenACCClauseTransform<Derived>::VisitCreateClause(
12268 const OpenACCCreateClause &C) {
12269 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12270 C.getModifierList());
12271
12272 NewClause = OpenACCCreateClause::Create(
12273 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12274 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12275 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12276 ParsedClause.getEndLoc());
12277}
12278template <typename Derived>
12279void OpenACCClauseTransform<Derived>::VisitAttachClause(
12280 const OpenACCAttachClause &C) {
12281 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12282
12283 // Ensure each var is a pointer type.
12284 llvm::erase_if(VarList, [&](Expr *E) {
12285 return Self.getSema().OpenACC().CheckVarIsPointerType(
12287 });
12288
12289 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12290 NewClause = OpenACCAttachClause::Create(
12291 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12292 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12293 ParsedClause.getEndLoc());
12294}
12295
12296template <typename Derived>
12297void OpenACCClauseTransform<Derived>::VisitDetachClause(
12298 const OpenACCDetachClause &C) {
12299 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12300
12301 // Ensure each var is a pointer type.
12302 llvm::erase_if(VarList, [&](Expr *E) {
12303 return Self.getSema().OpenACC().CheckVarIsPointerType(
12305 });
12306
12307 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12308 NewClause = OpenACCDetachClause::Create(
12309 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12310 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12311 ParsedClause.getEndLoc());
12312}
12313
12314template <typename Derived>
12315void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12316 const OpenACCDeleteClause &C) {
12317 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12319 NewClause = OpenACCDeleteClause::Create(
12320 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12321 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12322 ParsedClause.getEndLoc());
12323}
12324
12325template <typename Derived>
12326void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12327 const OpenACCUseDeviceClause &C) {
12328 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12331 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12332 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12333 ParsedClause.getEndLoc());
12334}
12335
12336template <typename Derived>
12337void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12338 const OpenACCDevicePtrClause &C) {
12339 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12340
12341 // Ensure each var is a pointer type.
12342 llvm::erase_if(VarList, [&](Expr *E) {
12343 return Self.getSema().OpenACC().CheckVarIsPointerType(
12345 });
12346
12347 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12349 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12350 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12351 ParsedClause.getEndLoc());
12352}
12353
12354template <typename Derived>
12355void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12356 const OpenACCNumWorkersClause &C) {
12357 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12358 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12359
12360 ExprResult Res = Self.TransformExpr(IntExpr);
12361 if (!Res.isUsable())
12362 return;
12363
12364 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12365 C.getClauseKind(),
12366 C.getBeginLoc(), Res.get());
12367 if (!Res.isUsable())
12368 return;
12369
12370 ParsedClause.setIntExprDetails(Res.get());
12372 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12373 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12374 ParsedClause.getEndLoc());
12375}
12376
12377template <typename Derived>
12378void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12379 const OpenACCDeviceNumClause &C) {
12380 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12381 assert(IntExpr && "device_num clause constructed with invalid int expr");
12382
12383 ExprResult Res = Self.TransformExpr(IntExpr);
12384 if (!Res.isUsable())
12385 return;
12386
12387 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12388 C.getClauseKind(),
12389 C.getBeginLoc(), Res.get());
12390 if (!Res.isUsable())
12391 return;
12392
12393 ParsedClause.setIntExprDetails(Res.get());
12395 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12396 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12397 ParsedClause.getEndLoc());
12398}
12399
12400template <typename Derived>
12401void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12403 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12404 assert(IntExpr && "default_async clause constructed with invalid int expr");
12405
12406 ExprResult Res = Self.TransformExpr(IntExpr);
12407 if (!Res.isUsable())
12408 return;
12409
12410 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12411 C.getClauseKind(),
12412 C.getBeginLoc(), Res.get());
12413 if (!Res.isUsable())
12414 return;
12415
12416 ParsedClause.setIntExprDetails(Res.get());
12418 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12419 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12420 ParsedClause.getEndLoc());
12421}
12422
12423template <typename Derived>
12424void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12426 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12427 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12428
12429 ExprResult Res = Self.TransformExpr(IntExpr);
12430 if (!Res.isUsable())
12431 return;
12432
12433 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12434 C.getClauseKind(),
12435 C.getBeginLoc(), Res.get());
12436 if (!Res.isUsable())
12437 return;
12438
12439 ParsedClause.setIntExprDetails(Res.get());
12441 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12442 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12443 ParsedClause.getEndLoc());
12444}
12445
12446template <typename Derived>
12447void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12448 const OpenACCAsyncClause &C) {
12449 if (C.hasIntExpr()) {
12450 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12451 if (!Res.isUsable())
12452 return;
12453
12454 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12455 C.getClauseKind(),
12456 C.getBeginLoc(), Res.get());
12457 if (!Res.isUsable())
12458 return;
12459 ParsedClause.setIntExprDetails(Res.get());
12460 }
12461
12462 NewClause = OpenACCAsyncClause::Create(
12463 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12464 ParsedClause.getLParenLoc(),
12465 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12466 : nullptr,
12467 ParsedClause.getEndLoc());
12468}
12469
12470template <typename Derived>
12471void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12472 const OpenACCWorkerClause &C) {
12473 if (C.hasIntExpr()) {
12474 // restrictions on this expression are all "does it exist in certain
12475 // situations" that are not possible to be dependent, so the only check we
12476 // have is that it transforms, and is an int expression.
12477 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12478 if (!Res.isUsable())
12479 return;
12480
12481 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12482 C.getClauseKind(),
12483 C.getBeginLoc(), Res.get());
12484 if (!Res.isUsable())
12485 return;
12486 ParsedClause.setIntExprDetails(Res.get());
12487 }
12488
12489 NewClause = OpenACCWorkerClause::Create(
12490 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12491 ParsedClause.getLParenLoc(),
12492 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12493 : nullptr,
12494 ParsedClause.getEndLoc());
12495}
12496
12497template <typename Derived>
12498void OpenACCClauseTransform<Derived>::VisitVectorClause(
12499 const OpenACCVectorClause &C) {
12500 if (C.hasIntExpr()) {
12501 // restrictions on this expression are all "does it exist in certain
12502 // situations" that are not possible to be dependent, so the only check we
12503 // have is that it transforms, and is an int expression.
12504 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12505 if (!Res.isUsable())
12506 return;
12507
12508 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12509 C.getClauseKind(),
12510 C.getBeginLoc(), Res.get());
12511 if (!Res.isUsable())
12512 return;
12513 ParsedClause.setIntExprDetails(Res.get());
12514 }
12515
12516 NewClause = OpenACCVectorClause::Create(
12517 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12518 ParsedClause.getLParenLoc(),
12519 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12520 : nullptr,
12521 ParsedClause.getEndLoc());
12522}
12523
12524template <typename Derived>
12525void OpenACCClauseTransform<Derived>::VisitWaitClause(
12526 const OpenACCWaitClause &C) {
12527 if (C.hasExprs()) {
12528 Expr *DevNumExpr = nullptr;
12529 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12530
12531 // Instantiate devnum expr if it exists.
12532 if (C.getDevNumExpr()) {
12533 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12534 if (!Res.isUsable())
12535 return;
12536 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12537 C.getClauseKind(),
12538 C.getBeginLoc(), Res.get());
12539 if (!Res.isUsable())
12540 return;
12541
12542 DevNumExpr = Res.get();
12543 }
12544
12545 // Instantiate queue ids.
12546 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12547 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12548 if (!Res.isUsable())
12549 return;
12550 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12551 C.getClauseKind(),
12552 C.getBeginLoc(), Res.get());
12553 if (!Res.isUsable())
12554 return;
12555
12556 InstantiatedQueueIdExprs.push_back(Res.get());
12557 }
12558
12559 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12560 std::move(InstantiatedQueueIdExprs));
12561 }
12562
12563 NewClause = OpenACCWaitClause::Create(
12564 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12565 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12566 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12567 ParsedClause.getEndLoc());
12568}
12569
12570template <typename Derived>
12571void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12572 const OpenACCDeviceTypeClause &C) {
12573 // Nothing to transform here, just create a new version of 'C'.
12575 Self.getSema().getASTContext(), C.getClauseKind(),
12576 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12577 C.getArchitectures(), ParsedClause.getEndLoc());
12578}
12579
12580template <typename Derived>
12581void OpenACCClauseTransform<Derived>::VisitAutoClause(
12582 const OpenACCAutoClause &C) {
12583 // Nothing to do, so just create a new node.
12584 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12585 ParsedClause.getBeginLoc(),
12586 ParsedClause.getEndLoc());
12587}
12588
12589template <typename Derived>
12590void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12591 const OpenACCIndependentClause &C) {
12592 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12593 ParsedClause.getBeginLoc(),
12594 ParsedClause.getEndLoc());
12595}
12596
12597template <typename Derived>
12598void OpenACCClauseTransform<Derived>::VisitSeqClause(
12599 const OpenACCSeqClause &C) {
12600 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12601 ParsedClause.getBeginLoc(),
12602 ParsedClause.getEndLoc());
12603}
12604template <typename Derived>
12605void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12606 const OpenACCFinalizeClause &C) {
12607 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12608 ParsedClause.getBeginLoc(),
12609 ParsedClause.getEndLoc());
12610}
12611
12612template <typename Derived>
12613void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12614 const OpenACCIfPresentClause &C) {
12615 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12616 ParsedClause.getBeginLoc(),
12617 ParsedClause.getEndLoc());
12618}
12619
12620template <typename Derived>
12621void OpenACCClauseTransform<Derived>::VisitReductionClause(
12622 const OpenACCReductionClause &C) {
12623 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12624 SmallVector<Expr *> ValidVars;
12626
12627 for (const auto [Var, OrigRecipe] :
12628 llvm::zip(TransformedVars, C.getRecipes())) {
12629 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12630 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12631 if (Res.isUsable()) {
12632 ValidVars.push_back(Res.get());
12633
12634 if (OrigRecipe.isSet())
12635 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
12636 else
12637 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
12638 C.getReductionOp(), Res.get()));
12639 }
12640 }
12641
12642 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12643 ExistingClauses, ParsedClause.getDirectiveKind(),
12644 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12645 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
12646}
12647
12648template <typename Derived>
12649void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12650 const OpenACCCollapseClause &C) {
12651 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12652 assert(LoopCount && "collapse clause constructed with invalid loop count");
12653
12654 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12655
12656 if (!NewLoopCount.isUsable())
12657 return;
12658
12659 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12660 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12661 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12662
12663 // FIXME: It isn't clear whether this is properly tested here, we should
12664 // probably see if we can come up with a test for this.
12665 if (!NewLoopCount.isUsable())
12666 return;
12667
12668 NewLoopCount =
12669 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12670
12671 // FIXME: It isn't clear whether this is properly tested here, we should
12672 // probably see if we can come up with a test for this.
12673 if (!NewLoopCount.isUsable())
12674 return;
12675
12676 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12678 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12679 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12680 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12681}
12682
12683template <typename Derived>
12684void OpenACCClauseTransform<Derived>::VisitTileClause(
12685 const OpenACCTileClause &C) {
12686
12687 llvm::SmallVector<Expr *> TransformedExprs;
12688
12689 for (Expr *E : C.getSizeExprs()) {
12690 ExprResult NewSizeExpr = Self.TransformExpr(E);
12691
12692 if (!NewSizeExpr.isUsable())
12693 return;
12694
12695 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12696 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12697 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12698
12699 // FIXME: It isn't clear whether this is properly tested here, we should
12700 // probably see if we can come up with a test for this.
12701 if (!NewSizeExpr.isUsable())
12702 return;
12703
12704 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12705
12706 if (!NewSizeExpr.isUsable())
12707 return;
12708 TransformedExprs.push_back(NewSizeExpr.get());
12709 }
12710
12711 ParsedClause.setIntExprDetails(TransformedExprs);
12712 NewClause = OpenACCTileClause::Create(
12713 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12714 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12715 ParsedClause.getEndLoc());
12716}
12717template <typename Derived>
12718void OpenACCClauseTransform<Derived>::VisitGangClause(
12719 const OpenACCGangClause &C) {
12720 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12721 llvm::SmallVector<Expr *> TransformedIntExprs;
12722
12723 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12724 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12725 if (!ER.isUsable())
12726 continue;
12727
12728 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12729 ParsedClause.getDirectiveKind(),
12730 C.getExpr(I).first, ER.get());
12731 if (!ER.isUsable())
12732 continue;
12733 TransformedGangKinds.push_back(C.getExpr(I).first);
12734 TransformedIntExprs.push_back(ER.get());
12735 }
12736
12737 NewClause = Self.getSema().OpenACC().CheckGangClause(
12738 ParsedClause.getDirectiveKind(), ExistingClauses,
12739 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12740 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12741}
12742} // namespace
12743template <typename Derived>
12744OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12745 ArrayRef<const OpenACCClause *> ExistingClauses,
12746 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12747
12749 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12750 ParsedClause.setEndLoc(OldClause->getEndLoc());
12751
12752 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12753 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12754
12755 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12756 ParsedClause};
12757 Transform.Visit(OldClause);
12758
12759 return Transform.CreatedClause();
12760}
12761
12762template <typename Derived>
12764TreeTransform<Derived>::TransformOpenACCClauseList(
12766 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12767 for (const auto *Clause : OldClauses) {
12768 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12769 TransformedClauses, DirKind, Clause))
12770 TransformedClauses.push_back(TransformedClause);
12771 }
12772 return TransformedClauses;
12773}
12774
12775template <typename Derived>
12778 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12779
12780 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12781 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12782 C->clauses());
12783
12784 if (getSema().OpenACC().ActOnStartStmtDirective(
12785 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12786 return StmtError();
12787
12788 // Transform Structured Block.
12789 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12790 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12791 C->clauses(), TransformedClauses);
12792 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12793 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12794 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12795
12796 return getDerived().RebuildOpenACCComputeConstruct(
12797 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12798 C->getEndLoc(), TransformedClauses, StrBlock);
12799}
12800
12801template <typename Derived>
12804
12805 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12806
12807 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12808 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12809 C->clauses());
12810
12811 if (getSema().OpenACC().ActOnStartStmtDirective(
12812 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12813 return StmtError();
12814
12815 // Transform Loop.
12816 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12817 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12818 C->clauses(), TransformedClauses);
12819 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12820 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12821 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12822
12823 return getDerived().RebuildOpenACCLoopConstruct(
12824 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12825 TransformedClauses, Loop);
12826}
12827
12828template <typename Derived>
12830 OpenACCCombinedConstruct *C) {
12831 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12832
12833 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12834 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12835 C->clauses());
12836
12837 if (getSema().OpenACC().ActOnStartStmtDirective(
12838 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12839 return StmtError();
12840
12841 // Transform Loop.
12842 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12843 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12844 C->clauses(), TransformedClauses);
12845 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12846 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12847 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12848
12849 return getDerived().RebuildOpenACCCombinedConstruct(
12850 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12851 C->getEndLoc(), TransformedClauses, Loop);
12852}
12853
12854template <typename Derived>
12857 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12858
12859 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12860 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12861 C->clauses());
12862 if (getSema().OpenACC().ActOnStartStmtDirective(
12863 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12864 return StmtError();
12865
12866 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12867 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12868 C->clauses(), TransformedClauses);
12869 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12870 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12871 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12872
12873 return getDerived().RebuildOpenACCDataConstruct(
12874 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12875 TransformedClauses, StrBlock);
12876}
12877
12878template <typename Derived>
12880 OpenACCEnterDataConstruct *C) {
12881 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12882
12883 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12884 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12885 C->clauses());
12886 if (getSema().OpenACC().ActOnStartStmtDirective(
12887 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12888 return StmtError();
12889
12890 return getDerived().RebuildOpenACCEnterDataConstruct(
12891 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12892 TransformedClauses);
12893}
12894
12895template <typename Derived>
12897 OpenACCExitDataConstruct *C) {
12898 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12899
12900 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12901 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12902 C->clauses());
12903 if (getSema().OpenACC().ActOnStartStmtDirective(
12904 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12905 return StmtError();
12906
12907 return getDerived().RebuildOpenACCExitDataConstruct(
12908 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12909 TransformedClauses);
12910}
12911
12912template <typename Derived>
12914 OpenACCHostDataConstruct *C) {
12915 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12916
12917 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12918 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12919 C->clauses());
12920 if (getSema().OpenACC().ActOnStartStmtDirective(
12921 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12922 return StmtError();
12923
12924 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12925 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12926 C->clauses(), TransformedClauses);
12927 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12928 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12929 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12930
12931 return getDerived().RebuildOpenACCHostDataConstruct(
12932 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12933 TransformedClauses, StrBlock);
12934}
12935
12936template <typename Derived>
12939 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12940
12941 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12942 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12943 C->clauses());
12944 if (getSema().OpenACC().ActOnStartStmtDirective(
12945 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12946 return StmtError();
12947
12948 return getDerived().RebuildOpenACCInitConstruct(
12949 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12950 TransformedClauses);
12951}
12952
12953template <typename Derived>
12955 OpenACCShutdownConstruct *C) {
12956 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12957
12958 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12959 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12960 C->clauses());
12961 if (getSema().OpenACC().ActOnStartStmtDirective(
12962 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12963 return StmtError();
12964
12965 return getDerived().RebuildOpenACCShutdownConstruct(
12966 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12967 TransformedClauses);
12968}
12969template <typename Derived>
12972 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12973
12974 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12975 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12976 C->clauses());
12977 if (getSema().OpenACC().ActOnStartStmtDirective(
12978 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12979 return StmtError();
12980
12981 return getDerived().RebuildOpenACCSetConstruct(
12982 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12983 TransformedClauses);
12984}
12985
12986template <typename Derived>
12988 OpenACCUpdateConstruct *C) {
12989 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12990
12991 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12992 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12993 C->clauses());
12994 if (getSema().OpenACC().ActOnStartStmtDirective(
12995 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12996 return StmtError();
12997
12998 return getDerived().RebuildOpenACCUpdateConstruct(
12999 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
13000 TransformedClauses);
13001}
13002
13003template <typename Derived>
13006 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13007
13008 ExprResult DevNumExpr;
13009 if (C->hasDevNumExpr()) {
13010 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
13011
13012 if (DevNumExpr.isUsable())
13013 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
13015 C->getBeginLoc(), DevNumExpr.get());
13016 }
13017
13018 llvm::SmallVector<Expr *> QueueIdExprs;
13019
13020 for (Expr *QE : C->getQueueIdExprs()) {
13021 assert(QE && "Null queue id expr?");
13022 ExprResult NewEQ = getDerived().TransformExpr(QE);
13023
13024 if (!NewEQ.isUsable())
13025 break;
13026 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
13028 C->getBeginLoc(), NewEQ.get());
13029 if (NewEQ.isUsable())
13030 QueueIdExprs.push_back(NewEQ.get());
13031 }
13032
13033 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13034 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13035 C->clauses());
13036
13037 if (getSema().OpenACC().ActOnStartStmtDirective(
13038 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13039 return StmtError();
13040
13041 return getDerived().RebuildOpenACCWaitConstruct(
13042 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13043 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
13044 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
13045}
13046template <typename Derived>
13048 OpenACCCacheConstruct *C) {
13049 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13050
13051 llvm::SmallVector<Expr *> TransformedVarList;
13052 for (Expr *Var : C->getVarList()) {
13053 assert(Var && "Null var listexpr?");
13054
13055 ExprResult NewVar = getDerived().TransformExpr(Var);
13056
13057 if (!NewVar.isUsable())
13058 break;
13059
13060 NewVar = getSema().OpenACC().ActOnVar(
13061 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
13062 if (!NewVar.isUsable())
13063 break;
13064
13065 TransformedVarList.push_back(NewVar.get());
13066 }
13067
13068 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13069 C->getBeginLoc(), {}))
13070 return StmtError();
13071
13072 return getDerived().RebuildOpenACCCacheConstruct(
13073 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13074 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
13075 C->getEndLoc());
13076}
13077
13078template <typename Derived>
13080 OpenACCAtomicConstruct *C) {
13081 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13082
13083 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13084 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13085 C->clauses());
13086
13087 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13088 C->getBeginLoc(), {}))
13089 return StmtError();
13090
13091 // Transform Associated Stmt.
13092 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13093 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
13094
13095 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
13096 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
13097 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
13098 AssocStmt);
13099
13100 return getDerived().RebuildOpenACCAtomicConstruct(
13101 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
13102 C->getEndLoc(), TransformedClauses, AssocStmt);
13103}
13104
13105template <typename Derived>
13108 if (getDerived().AlwaysRebuild())
13109 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
13110 // Nothing can ever change, so there is never anything to transform.
13111 return E;
13112}
13113
13114//===----------------------------------------------------------------------===//
13115// Expression transformation
13116//===----------------------------------------------------------------------===//
13117template<typename Derived>
13120 return TransformExpr(E->getSubExpr());
13121}
13122
13123template <typename Derived>
13126 if (!E->isTypeDependent())
13127 return E;
13128
13129 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
13130
13131 if (!NewT)
13132 return ExprError();
13133
13134 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
13135 return E;
13136
13137 return getDerived().RebuildSYCLUniqueStableNameExpr(
13138 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
13139}
13140
13141template <typename Derived>
13144 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
13145 const auto *SKEPAttr = FD->template getAttr<SYCLKernelEntryPointAttr>();
13146 if (!SKEPAttr || SKEPAttr->isInvalidAttr())
13147 return StmtError();
13148
13149 ExprResult IdExpr = getDerived().TransformExpr(S->getKernelLaunchIdExpr());
13150 if (IdExpr.isInvalid())
13151 return StmtError();
13152
13153 StmtResult Body = getDerived().TransformStmt(S->getOriginalStmt());
13154 if (Body.isInvalid())
13155 return StmtError();
13156
13158 cast<FunctionDecl>(SemaRef.CurContext), cast<CompoundStmt>(Body.get()),
13159 IdExpr.get());
13160 if (SR.isInvalid())
13161 return StmtError();
13162
13163 return SR;
13164}
13165
13166template <typename Derived>
13168 // TODO(reflection): Implement its transform
13169 assert(false && "not implemented yet");
13170 return ExprError();
13171}
13172
13173template<typename Derived>
13176 if (!E->isTypeDependent())
13177 return E;
13178
13179 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13180 E->getIdentKind());
13181}
13182
13183template<typename Derived>
13186 NestedNameSpecifierLoc QualifierLoc;
13187 if (E->getQualifierLoc()) {
13188 QualifierLoc
13189 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13190 if (!QualifierLoc)
13191 return ExprError();
13192 }
13193
13194 ValueDecl *ND
13195 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13196 E->getDecl()));
13197 if (!ND || ND->isInvalidDecl())
13198 return ExprError();
13199
13200 NamedDecl *Found = ND;
13201 if (E->getFoundDecl() != E->getDecl()) {
13202 Found = cast_or_null<NamedDecl>(
13203 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13204 if (!Found)
13205 return ExprError();
13206 }
13207
13208 DeclarationNameInfo NameInfo = E->getNameInfo();
13209 if (NameInfo.getName()) {
13210 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13211 if (!NameInfo.getName())
13212 return ExprError();
13213 }
13214
13215 if (!getDerived().AlwaysRebuild() &&
13216 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13217 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13218 Found == E->getFoundDecl() &&
13219 NameInfo.getName() == E->getDecl()->getDeclName() &&
13220 !E->hasExplicitTemplateArgs()) {
13221
13222 // Mark it referenced in the new context regardless.
13223 // FIXME: this is a bit instantiation-specific.
13224 SemaRef.MarkDeclRefReferenced(E);
13225
13226 return E;
13227 }
13228
13229 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13230 if (E->hasExplicitTemplateArgs()) {
13231 TemplateArgs = &TransArgs;
13232 TransArgs.setLAngleLoc(E->getLAngleLoc());
13233 TransArgs.setRAngleLoc(E->getRAngleLoc());
13234 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13235 E->getNumTemplateArgs(),
13236 TransArgs))
13237 return ExprError();
13238 }
13239
13240 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13241 Found, TemplateArgs);
13242}
13243
13244template<typename Derived>
13247 return E;
13248}
13249
13250template <typename Derived>
13252 FixedPointLiteral *E) {
13253 return E;
13254}
13255
13256template<typename Derived>
13259 return E;
13260}
13261
13262template<typename Derived>
13265 return E;
13266}
13267
13268template<typename Derived>
13271 return E;
13272}
13273
13274template<typename Derived>
13277 return E;
13278}
13279
13280template<typename Derived>
13283 return getDerived().TransformCallExpr(E);
13284}
13285
13286template<typename Derived>
13289 ExprResult ControllingExpr;
13290 TypeSourceInfo *ControllingType = nullptr;
13291 if (E->isExprPredicate())
13292 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13293 else
13294 ControllingType = getDerived().TransformType(E->getControllingType());
13295
13296 if (ControllingExpr.isInvalid() && !ControllingType)
13297 return ExprError();
13298
13299 SmallVector<Expr *, 4> AssocExprs;
13301 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13302 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13303 if (TSI) {
13304 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13305 if (!AssocType)
13306 return ExprError();
13307 AssocTypes.push_back(AssocType);
13308 } else {
13309 AssocTypes.push_back(nullptr);
13310 }
13311
13312 ExprResult AssocExpr =
13313 getDerived().TransformExpr(Assoc.getAssociationExpr());
13314 if (AssocExpr.isInvalid())
13315 return ExprError();
13316 AssocExprs.push_back(AssocExpr.get());
13317 }
13318
13319 if (!ControllingType)
13320 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13321 E->getDefaultLoc(),
13322 E->getRParenLoc(),
13323 ControllingExpr.get(),
13324 AssocTypes,
13325 AssocExprs);
13326 return getDerived().RebuildGenericSelectionExpr(
13327 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13328 ControllingType, AssocTypes, AssocExprs);
13329}
13330
13331template<typename Derived>
13334 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13335 if (SubExpr.isInvalid())
13336 return ExprError();
13337
13338 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13339 return E;
13340
13341 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13342 E->getRParen());
13343}
13344
13345/// The operand of a unary address-of operator has special rules: it's
13346/// allowed to refer to a non-static member of a class even if there's no 'this'
13347/// object available.
13348template<typename Derived>
13351 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13352 return getDerived().TransformDependentScopeDeclRefExpr(
13353 DRE, /*IsAddressOfOperand=*/true, nullptr);
13354 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13355 return getDerived().TransformUnresolvedLookupExpr(
13356 ULE, /*IsAddressOfOperand=*/true);
13357 else
13358 return getDerived().TransformExpr(E);
13359}
13360
13361template<typename Derived>
13364 ExprResult SubExpr;
13365 if (E->getOpcode() == UO_AddrOf)
13366 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13367 else
13368 SubExpr = TransformExpr(E->getSubExpr());
13369 if (SubExpr.isInvalid())
13370 return ExprError();
13371
13372 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13373 return E;
13374
13375 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13376 E->getOpcode(),
13377 SubExpr.get());
13378}
13379
13380template<typename Derived>
13382TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13383 // Transform the type.
13384 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13385 if (!Type)
13386 return ExprError();
13387
13388 // Transform all of the components into components similar to what the
13389 // parser uses.
13390 // FIXME: It would be slightly more efficient in the non-dependent case to
13391 // just map FieldDecls, rather than requiring the rebuilder to look for
13392 // the fields again. However, __builtin_offsetof is rare enough in
13393 // template code that we don't care.
13394 bool ExprChanged = false;
13395 typedef Sema::OffsetOfComponent Component;
13396 SmallVector<Component, 4> Components;
13397 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13398 const OffsetOfNode &ON = E->getComponent(I);
13399 Component Comp;
13400 Comp.isBrackets = true;
13401 Comp.LocStart = ON.getSourceRange().getBegin();
13402 Comp.LocEnd = ON.getSourceRange().getEnd();
13403 switch (ON.getKind()) {
13404 case OffsetOfNode::Array: {
13405 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13406 ExprResult Index = getDerived().TransformExpr(FromIndex);
13407 if (Index.isInvalid())
13408 return ExprError();
13409
13410 ExprChanged = ExprChanged || Index.get() != FromIndex;
13411 Comp.isBrackets = true;
13412 Comp.U.E = Index.get();
13413 break;
13414 }
13415
13418 Comp.isBrackets = false;
13419 Comp.U.IdentInfo = ON.getFieldName();
13420 if (!Comp.U.IdentInfo)
13421 continue;
13422
13423 break;
13424
13425 case OffsetOfNode::Base:
13426 // Will be recomputed during the rebuild.
13427 continue;
13428 }
13429
13430 Components.push_back(Comp);
13431 }
13432
13433 // If nothing changed, retain the existing expression.
13434 if (!getDerived().AlwaysRebuild() &&
13435 Type == E->getTypeSourceInfo() &&
13436 !ExprChanged)
13437 return E;
13438
13439 // Build a new offsetof expression.
13440 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13441 Components, E->getRParenLoc());
13442}
13443
13444template<typename Derived>
13447 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13448 "opaque value expression requires transformation");
13449 return E;
13450}
13451
13452template <typename Derived>
13455 bool Changed = false;
13456 for (Expr *C : E->subExpressions()) {
13457 ExprResult NewC = getDerived().TransformExpr(C);
13458 if (NewC.isInvalid())
13459 return ExprError();
13460 Children.push_back(NewC.get());
13461
13462 Changed |= NewC.get() != C;
13463 }
13464 if (!getDerived().AlwaysRebuild() && !Changed)
13465 return E;
13466 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13467 Children, E->getType());
13468}
13469
13470template<typename Derived>
13473 // Rebuild the syntactic form. The original syntactic form has
13474 // opaque-value expressions in it, so strip those away and rebuild
13475 // the result. This is a really awful way of doing this, but the
13476 // better solution (rebuilding the semantic expressions and
13477 // rebinding OVEs as necessary) doesn't work; we'd need
13478 // TreeTransform to not strip away implicit conversions.
13479 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13480 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13481 if (result.isInvalid()) return ExprError();
13482
13483 // If that gives us a pseudo-object result back, the pseudo-object
13484 // expression must have been an lvalue-to-rvalue conversion which we
13485 // should reapply.
13486 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13487 result = SemaRef.PseudoObject().checkRValue(result.get());
13488
13489 return result;
13490}
13491
13492template<typename Derived>
13496 if (E->isArgumentType()) {
13497 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13498
13499 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13500 if (!NewT)
13501 return ExprError();
13502
13503 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13504 return E;
13505
13506 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13507 E->getKind(),
13508 E->getSourceRange());
13509 }
13510
13511 // C++0x [expr.sizeof]p1:
13512 // The operand is either an expression, which is an unevaluated operand
13513 // [...]
13517
13518 // Try to recover if we have something like sizeof(T::X) where X is a type.
13519 // Notably, there must be *exactly* one set of parens if X is a type.
13520 TypeSourceInfo *RecoveryTSI = nullptr;
13521 ExprResult SubExpr;
13522 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13523 if (auto *DRE =
13524 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13525 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13526 PE, DRE, false, &RecoveryTSI);
13527 else
13528 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13529
13530 if (RecoveryTSI) {
13531 return getDerived().RebuildUnaryExprOrTypeTrait(
13532 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13533 } else if (SubExpr.isInvalid())
13534 return ExprError();
13535
13536 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13537 return E;
13538
13539 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13540 E->getOperatorLoc(),
13541 E->getKind(),
13542 E->getSourceRange());
13543}
13544
13545template<typename Derived>
13548 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13549 if (LHS.isInvalid())
13550 return ExprError();
13551
13552 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13553 if (RHS.isInvalid())
13554 return ExprError();
13555
13556
13557 if (!getDerived().AlwaysRebuild() &&
13558 LHS.get() == E->getLHS() &&
13559 RHS.get() == E->getRHS())
13560 return E;
13561
13562 return getDerived().RebuildArraySubscriptExpr(
13563 LHS.get(),
13564 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13565}
13566
13567template <typename Derived>
13570 ExprResult Base = getDerived().TransformExpr(E->getBase());
13571 if (Base.isInvalid())
13572 return ExprError();
13573
13574 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13575 if (RowIdx.isInvalid())
13576 return ExprError();
13577
13578 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13579 RowIdx.get() == E->getRowIdx())
13580 return E;
13581
13582 return getDerived().RebuildMatrixSingleSubscriptExpr(Base.get(), RowIdx.get(),
13583 E->getRBracketLoc());
13584}
13585
13586template <typename Derived>
13589 ExprResult Base = getDerived().TransformExpr(E->getBase());
13590 if (Base.isInvalid())
13591 return ExprError();
13592
13593 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13594 if (RowIdx.isInvalid())
13595 return ExprError();
13596
13597 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13598 if (ColumnIdx.isInvalid())
13599 return ExprError();
13600
13601 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13602 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13603 return E;
13604
13605 return getDerived().RebuildMatrixSubscriptExpr(
13606 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13607}
13608
13609template <typename Derived>
13612 ExprResult Base = getDerived().TransformExpr(E->getBase());
13613 if (Base.isInvalid())
13614 return ExprError();
13615
13616 ExprResult LowerBound;
13617 if (E->getLowerBound()) {
13618 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13619 if (LowerBound.isInvalid())
13620 return ExprError();
13621 }
13622
13623 ExprResult Length;
13624 if (E->getLength()) {
13625 Length = getDerived().TransformExpr(E->getLength());
13626 if (Length.isInvalid())
13627 return ExprError();
13628 }
13629
13630 ExprResult Stride;
13631 if (E->isOMPArraySection()) {
13632 if (Expr *Str = E->getStride()) {
13633 Stride = getDerived().TransformExpr(Str);
13634 if (Stride.isInvalid())
13635 return ExprError();
13636 }
13637 }
13638
13639 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13640 LowerBound.get() == E->getLowerBound() &&
13641 Length.get() == E->getLength() &&
13642 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13643 return E;
13644
13645 return getDerived().RebuildArraySectionExpr(
13646 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13647 LowerBound.get(), E->getColonLocFirst(),
13648 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13649 Length.get(), Stride.get(), E->getRBracketLoc());
13650}
13651
13652template <typename Derived>
13655 ExprResult Base = getDerived().TransformExpr(E->getBase());
13656 if (Base.isInvalid())
13657 return ExprError();
13658
13660 bool ErrorFound = false;
13661 for (Expr *Dim : E->getDimensions()) {
13662 ExprResult DimRes = getDerived().TransformExpr(Dim);
13663 if (DimRes.isInvalid()) {
13664 ErrorFound = true;
13665 continue;
13666 }
13667 Dims.push_back(DimRes.get());
13668 }
13669
13670 if (ErrorFound)
13671 return ExprError();
13672 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13673 E->getRParenLoc(), Dims,
13674 E->getBracketsRanges());
13675}
13676
13677template <typename Derived>
13680 unsigned NumIterators = E->numOfIterators();
13682
13683 bool ErrorFound = false;
13684 bool NeedToRebuild = getDerived().AlwaysRebuild();
13685 for (unsigned I = 0; I < NumIterators; ++I) {
13686 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13687 Data[I].DeclIdent = D->getIdentifier();
13688 Data[I].DeclIdentLoc = D->getLocation();
13689 if (D->getLocation() == D->getBeginLoc()) {
13690 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13691 "Implicit type must be int.");
13692 } else {
13693 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13694 QualType DeclTy = getDerived().TransformType(D->getType());
13695 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13696 }
13697 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13698 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13699 ExprResult End = getDerived().TransformExpr(Range.End);
13700 ExprResult Step = getDerived().TransformExpr(Range.Step);
13701 ErrorFound = ErrorFound ||
13702 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13703 !Data[I].Type.get().isNull())) ||
13704 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13705 if (ErrorFound)
13706 continue;
13707 Data[I].Range.Begin = Begin.get();
13708 Data[I].Range.End = End.get();
13709 Data[I].Range.Step = Step.get();
13710 Data[I].AssignLoc = E->getAssignLoc(I);
13711 Data[I].ColonLoc = E->getColonLoc(I);
13712 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13713 NeedToRebuild =
13714 NeedToRebuild ||
13715 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13716 D->getType().getTypePtrOrNull()) ||
13717 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13718 Range.Step != Data[I].Range.Step;
13719 }
13720 if (ErrorFound)
13721 return ExprError();
13722 if (!NeedToRebuild)
13723 return E;
13724
13725 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13726 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13727 if (!Res.isUsable())
13728 return Res;
13729 auto *IE = cast<OMPIteratorExpr>(Res.get());
13730 for (unsigned I = 0; I < NumIterators; ++I)
13731 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13732 IE->getIteratorDecl(I));
13733 return Res;
13734}
13735
13736template<typename Derived>
13739 // Transform the callee.
13740 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13741 if (Callee.isInvalid())
13742 return ExprError();
13743
13744 // Transform arguments.
13745 bool ArgChanged = false;
13747 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13748 &ArgChanged))
13749 return ExprError();
13750
13751 if (!getDerived().AlwaysRebuild() &&
13752 Callee.get() == E->getCallee() &&
13753 !ArgChanged)
13754 return SemaRef.MaybeBindToTemporary(E);
13755
13756 // FIXME: Wrong source location information for the '('.
13757 SourceLocation FakeLParenLoc
13758 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13759
13760 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13761 if (E->hasStoredFPFeatures()) {
13762 FPOptionsOverride NewOverrides = E->getFPFeatures();
13763 getSema().CurFPFeatures =
13764 NewOverrides.applyOverrides(getSema().getLangOpts());
13765 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13766 }
13767
13768 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13769 Args,
13770 E->getRParenLoc());
13771}
13772
13773template<typename Derived>
13776 ExprResult Base = getDerived().TransformExpr(E->getBase());
13777 if (Base.isInvalid())
13778 return ExprError();
13779
13780 NestedNameSpecifierLoc QualifierLoc;
13781 if (E->hasQualifier()) {
13782 QualifierLoc
13783 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13784
13785 if (!QualifierLoc)
13786 return ExprError();
13787 }
13788 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13789
13791 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13792 E->getMemberDecl()));
13793 if (!Member)
13794 return ExprError();
13795
13796 NamedDecl *FoundDecl = E->getFoundDecl();
13797 if (FoundDecl == E->getMemberDecl()) {
13798 FoundDecl = Member;
13799 } else {
13800 FoundDecl = cast_or_null<NamedDecl>(
13801 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13802 if (!FoundDecl)
13803 return ExprError();
13804 }
13805
13806 if (!getDerived().AlwaysRebuild() &&
13807 Base.get() == E->getBase() &&
13808 QualifierLoc == E->getQualifierLoc() &&
13809 Member == E->getMemberDecl() &&
13810 FoundDecl == E->getFoundDecl() &&
13811 !E->hasExplicitTemplateArgs()) {
13812
13813 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13814 // for Openmp where the field need to be privatizized in the case.
13815 if (!(isa<CXXThisExpr>(E->getBase()) &&
13816 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13818 // Mark it referenced in the new context regardless.
13819 // FIXME: this is a bit instantiation-specific.
13820 SemaRef.MarkMemberReferenced(E);
13821 return E;
13822 }
13823 }
13824
13825 TemplateArgumentListInfo TransArgs;
13826 if (E->hasExplicitTemplateArgs()) {
13827 TransArgs.setLAngleLoc(E->getLAngleLoc());
13828 TransArgs.setRAngleLoc(E->getRAngleLoc());
13829 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13830 E->getNumTemplateArgs(),
13831 TransArgs))
13832 return ExprError();
13833 }
13834
13835 // FIXME: Bogus source location for the operator
13836 SourceLocation FakeOperatorLoc =
13837 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13838
13839 // FIXME: to do this check properly, we will need to preserve the
13840 // first-qualifier-in-scope here, just in case we had a dependent
13841 // base (and therefore couldn't do the check) and a
13842 // nested-name-qualifier (and therefore could do the lookup).
13843 NamedDecl *FirstQualifierInScope = nullptr;
13844 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13845 if (MemberNameInfo.getName()) {
13846 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13847 if (!MemberNameInfo.getName())
13848 return ExprError();
13849 }
13850
13851 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13852 E->isArrow(),
13853 QualifierLoc,
13854 TemplateKWLoc,
13855 MemberNameInfo,
13856 Member,
13857 FoundDecl,
13858 (E->hasExplicitTemplateArgs()
13859 ? &TransArgs : nullptr),
13860 FirstQualifierInScope);
13861}
13862
13863template<typename Derived>
13866 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13867 if (LHS.isInvalid())
13868 return ExprError();
13869
13870 ExprResult RHS =
13871 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13872 if (RHS.isInvalid())
13873 return ExprError();
13874
13875 if (!getDerived().AlwaysRebuild() &&
13876 LHS.get() == E->getLHS() &&
13877 RHS.get() == E->getRHS())
13878 return E;
13879
13880 if (E->isCompoundAssignmentOp())
13881 // FPFeatures has already been established from trailing storage
13882 return getDerived().RebuildBinaryOperator(
13883 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13884 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13885 FPOptionsOverride NewOverrides(E->getFPFeatures());
13886 getSema().CurFPFeatures =
13887 NewOverrides.applyOverrides(getSema().getLangOpts());
13888 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13889 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13890 LHS.get(), RHS.get());
13891}
13892
13893template <typename Derived>
13896 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13897
13898 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13899 if (LHS.isInvalid())
13900 return ExprError();
13901
13902 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13903 if (RHS.isInvalid())
13904 return ExprError();
13905
13906 // Extract the already-resolved callee declarations so that we can restrict
13907 // ourselves to using them as the unqualified lookup results when rebuilding.
13908 UnresolvedSet<2> UnqualLookups;
13909 bool ChangedAnyLookups = false;
13910 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13911 const_cast<Expr *>(Decomp.InnerBinOp)};
13912 for (Expr *PossibleBinOp : PossibleBinOps) {
13913 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13914 if (!Op)
13915 continue;
13916 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13917 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13918 continue;
13919
13920 // Transform the callee in case we built a call to a local extern
13921 // declaration.
13922 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13923 E->getOperatorLoc(), Callee->getFoundDecl()));
13924 if (!Found)
13925 return ExprError();
13926 if (Found != Callee->getFoundDecl())
13927 ChangedAnyLookups = true;
13928 UnqualLookups.addDecl(Found);
13929 }
13930
13931 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13932 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13933 // Mark all functions used in the rewrite as referenced. Note that when
13934 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13935 // function calls, and/or there might be a user-defined conversion sequence
13936 // applied to the operands of the <.
13937 // FIXME: this is a bit instantiation-specific.
13938 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13939 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13940 return E;
13941 }
13942
13943 return getDerived().RebuildCXXRewrittenBinaryOperator(
13944 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13945}
13946
13947template<typename Derived>
13951 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13952 FPOptionsOverride NewOverrides(E->getFPFeatures());
13953 getSema().CurFPFeatures =
13954 NewOverrides.applyOverrides(getSema().getLangOpts());
13955 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13956 return getDerived().TransformBinaryOperator(E);
13957}
13958
13959template<typename Derived>
13962 // Just rebuild the common and RHS expressions and see whether we
13963 // get any changes.
13964
13965 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13966 if (commonExpr.isInvalid())
13967 return ExprError();
13968
13969 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13970 if (rhs.isInvalid())
13971 return ExprError();
13972
13973 if (!getDerived().AlwaysRebuild() &&
13974 commonExpr.get() == e->getCommon() &&
13975 rhs.get() == e->getFalseExpr())
13976 return e;
13977
13978 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13979 e->getQuestionLoc(),
13980 nullptr,
13981 e->getColonLoc(),
13982 rhs.get());
13983}
13984
13985template<typename Derived>
13988 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13989 if (Cond.isInvalid())
13990 return ExprError();
13991
13992 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13993 if (LHS.isInvalid())
13994 return ExprError();
13995
13996 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13997 if (RHS.isInvalid())
13998 return ExprError();
13999
14000 if (!getDerived().AlwaysRebuild() &&
14001 Cond.get() == E->getCond() &&
14002 LHS.get() == E->getLHS() &&
14003 RHS.get() == E->getRHS())
14004 return E;
14005
14006 return getDerived().RebuildConditionalOperator(Cond.get(),
14007 E->getQuestionLoc(),
14008 LHS.get(),
14009 E->getColonLoc(),
14010 RHS.get());
14011}
14012
14013template<typename Derived>
14016 // Implicit casts are eliminated during transformation, since they
14017 // will be recomputed by semantic analysis after transformation.
14018 return getDerived().TransformExpr(E->getSubExprAsWritten());
14019}
14020
14021template<typename Derived>
14024 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14025 if (!Type)
14026 return ExprError();
14027
14028 ExprResult SubExpr
14029 = getDerived().TransformExpr(E->getSubExprAsWritten());
14030 if (SubExpr.isInvalid())
14031 return ExprError();
14032
14033 if (!getDerived().AlwaysRebuild() &&
14034 Type == E->getTypeInfoAsWritten() &&
14035 SubExpr.get() == E->getSubExpr())
14036 return E;
14037
14038 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
14039 Type,
14040 E->getRParenLoc(),
14041 SubExpr.get());
14042}
14043
14044template<typename Derived>
14047 TypeSourceInfo *OldT = E->getTypeSourceInfo();
14048 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
14049 if (!NewT)
14050 return ExprError();
14051
14052 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
14053 if (Init.isInvalid())
14054 return ExprError();
14055
14056 if (!getDerived().AlwaysRebuild() &&
14057 OldT == NewT &&
14058 Init.get() == E->getInitializer())
14059 return SemaRef.MaybeBindToTemporary(E);
14060
14061 // Note: the expression type doesn't necessarily match the
14062 // type-as-written, but that's okay, because it should always be
14063 // derivable from the initializer.
14064
14065 return getDerived().RebuildCompoundLiteralExpr(
14066 E->getLParenLoc(), NewT,
14067 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
14068}
14069
14070template<typename Derived>
14073 ExprResult Base = getDerived().TransformExpr(E->getBase());
14074 if (Base.isInvalid())
14075 return ExprError();
14076
14077 if (!getDerived().AlwaysRebuild() &&
14078 Base.get() == E->getBase())
14079 return E;
14080
14081 // FIXME: Bad source location
14082 SourceLocation FakeOperatorLoc =
14083 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14084 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14085 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
14086 E->getAccessor());
14087}
14088
14089template <typename Derived>
14092 ExprResult Base = getDerived().TransformExpr(E->getBase());
14093 if (Base.isInvalid())
14094 return ExprError();
14095
14096 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase())
14097 return E;
14098
14099 // FIXME: Bad source location
14100 SourceLocation FakeOperatorLoc =
14101 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14102 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14103 Base.get(), FakeOperatorLoc, /*isArrow*/ false, E->getAccessorLoc(),
14104 E->getAccessor());
14105}
14106
14107template<typename Derived>
14110 if (InitListExpr *Syntactic = E->getSyntacticForm())
14111 E = Syntactic;
14112
14113 bool InitChanged = false;
14114
14117
14119 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
14120 Inits, &InitChanged))
14121 return ExprError();
14122
14123 if (!getDerived().AlwaysRebuild() && !InitChanged) {
14124 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
14125 // in some cases. We can't reuse it in general, because the syntactic and
14126 // semantic forms are linked, and we can't know that semantic form will
14127 // match even if the syntactic form does.
14128 }
14129
14130 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
14131 E->getRBraceLoc(), E->isExplicit());
14132}
14133
14134template<typename Derived>
14137 Designation Desig;
14138
14139 // transform the initializer value
14140 ExprResult Init = getDerived().TransformExpr(E->getInit());
14141 if (Init.isInvalid())
14142 return ExprError();
14143
14144 // transform the designators.
14145 SmallVector<Expr*, 4> ArrayExprs;
14146 bool ExprChanged = false;
14147 for (const DesignatedInitExpr::Designator &D : E->designators()) {
14148 if (D.isFieldDesignator()) {
14149 if (D.getFieldDecl()) {
14150 FieldDecl *Field = cast_or_null<FieldDecl>(
14151 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
14152 if (Field != D.getFieldDecl())
14153 // Rebuild the expression when the transformed FieldDecl is
14154 // different to the already assigned FieldDecl.
14155 ExprChanged = true;
14156 if (Field->isAnonymousStructOrUnion())
14157 continue;
14158 } else {
14159 // Ensure that the designator expression is rebuilt when there isn't
14160 // a resolved FieldDecl in the designator as we don't want to assign
14161 // a FieldDecl to a pattern designator that will be instantiated again.
14162 ExprChanged = true;
14163 }
14164 Desig.AddDesignator(Designator::CreateFieldDesignator(
14165 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
14166 continue;
14167 }
14168
14169 if (D.isArrayDesignator()) {
14170 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
14171 if (Index.isInvalid())
14172 return ExprError();
14173
14174 Desig.AddDesignator(
14175 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
14176
14177 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
14178 ArrayExprs.push_back(Index.get());
14179 continue;
14180 }
14181
14182 assert(D.isArrayRangeDesignator() && "New kind of designator?");
14183 ExprResult Start
14184 = getDerived().TransformExpr(E->getArrayRangeStart(D));
14185 if (Start.isInvalid())
14186 return ExprError();
14187
14188 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
14189 if (End.isInvalid())
14190 return ExprError();
14191
14192 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
14193 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
14194
14195 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
14196 End.get() != E->getArrayRangeEnd(D);
14197
14198 ArrayExprs.push_back(Start.get());
14199 ArrayExprs.push_back(End.get());
14200 }
14201
14202 if (!getDerived().AlwaysRebuild() &&
14203 Init.get() == E->getInit() &&
14204 !ExprChanged)
14205 return E;
14206
14207 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14208 E->getEqualOrColonLoc(),
14209 E->usesGNUSyntax(), Init.get());
14210}
14211
14212// Seems that if TransformInitListExpr() only works on the syntactic form of an
14213// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14214template<typename Derived>
14218 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14219 "initializer");
14220 return ExprError();
14221}
14222
14223template<typename Derived>
14226 NoInitExpr *E) {
14227 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14228 return ExprError();
14229}
14230
14231template<typename Derived>
14234 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14235 return ExprError();
14236}
14237
14238template<typename Derived>
14241 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14242 return ExprError();
14243}
14244
14245template<typename Derived>
14249 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14250
14251 // FIXME: Will we ever have proper type location here? Will we actually
14252 // need to transform the type?
14253 QualType T = getDerived().TransformType(E->getType());
14254 if (T.isNull())
14255 return ExprError();
14256
14257 if (!getDerived().AlwaysRebuild() &&
14258 T == E->getType())
14259 return E;
14260
14261 return getDerived().RebuildImplicitValueInitExpr(T);
14262}
14263
14264template<typename Derived>
14267 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14268 if (!TInfo)
14269 return ExprError();
14270
14271 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14272 if (SubExpr.isInvalid())
14273 return ExprError();
14274
14275 if (!getDerived().AlwaysRebuild() &&
14276 TInfo == E->getWrittenTypeInfo() &&
14277 SubExpr.get() == E->getSubExpr())
14278 return E;
14279
14280 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14281 TInfo, E->getRParenLoc());
14282}
14283
14284template<typename Derived>
14287 bool ArgumentChanged = false;
14289 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14290 &ArgumentChanged))
14291 return ExprError();
14292
14293 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14294 Inits,
14295 E->getRParenLoc());
14296}
14297
14298/// Transform an address-of-label expression.
14299///
14300/// By default, the transformation of an address-of-label expression always
14301/// rebuilds the expression, so that the label identifier can be resolved to
14302/// the corresponding label statement by semantic analysis.
14303template<typename Derived>
14306 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14307 E->getLabel());
14308 if (!LD)
14309 return ExprError();
14310
14311 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14312 cast<LabelDecl>(LD));
14313}
14314
14315template<typename Derived>
14318 SemaRef.ActOnStartStmtExpr();
14319 StmtResult SubStmt
14320 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14321 if (SubStmt.isInvalid()) {
14322 SemaRef.ActOnStmtExprError();
14323 return ExprError();
14324 }
14325
14326 unsigned OldDepth = E->getTemplateDepth();
14327 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14328
14329 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14330 SubStmt.get() == E->getSubStmt()) {
14331 // Calling this an 'error' is unintuitive, but it does the right thing.
14332 SemaRef.ActOnStmtExprError();
14333 return SemaRef.MaybeBindToTemporary(E);
14334 }
14335
14336 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14337 E->getRParenLoc(), NewDepth);
14338}
14339
14340template<typename Derived>
14343 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14344 if (Cond.isInvalid())
14345 return ExprError();
14346
14347 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14348 if (LHS.isInvalid())
14349 return ExprError();
14350
14351 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14352 if (RHS.isInvalid())
14353 return ExprError();
14354
14355 if (!getDerived().AlwaysRebuild() &&
14356 Cond.get() == E->getCond() &&
14357 LHS.get() == E->getLHS() &&
14358 RHS.get() == E->getRHS())
14359 return E;
14360
14361 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14362 Cond.get(), LHS.get(), RHS.get(),
14363 E->getRParenLoc());
14364}
14365
14366template<typename Derived>
14369 return E;
14370}
14371
14372template<typename Derived>
14375 switch (E->getOperator()) {
14376 case OO_New:
14377 case OO_Delete:
14378 case OO_Array_New:
14379 case OO_Array_Delete:
14380 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14381
14382 case OO_Subscript:
14383 case OO_Call: {
14384 // This is a call to an object's operator().
14385 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14386
14387 // Transform the object itself.
14388 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14389 if (Object.isInvalid())
14390 return ExprError();
14391
14392 // FIXME: Poor location information. Also, if the location for the end of
14393 // the token is within a macro expansion, getLocForEndOfToken() will return
14394 // an invalid source location. If that happens and we have an otherwise
14395 // valid end location, use the valid one instead of the invalid one.
14396 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14397 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14398 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14399 FakeLParenLoc = EndLoc;
14400
14401 // Transform the call arguments.
14403 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14404 Args))
14405 return ExprError();
14406
14407 if (E->getOperator() == OO_Subscript)
14408 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14409 Args, E->getEndLoc());
14410
14411 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14412 E->getEndLoc());
14413 }
14414
14415#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14416 case OO_##Name: \
14417 break;
14418
14419#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14420#include "clang/Basic/OperatorKinds.def"
14421
14422 case OO_Conditional:
14423 llvm_unreachable("conditional operator is not actually overloadable");
14424
14425 case OO_None:
14427 llvm_unreachable("not an overloaded operator?");
14428 }
14429
14431 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14432 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14433 else
14434 First = getDerived().TransformExpr(E->getArg(0));
14435 if (First.isInvalid())
14436 return ExprError();
14437
14438 ExprResult Second;
14439 if (E->getNumArgs() == 2) {
14440 Second =
14441 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14442 if (Second.isInvalid())
14443 return ExprError();
14444 }
14445
14446 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14447 FPOptionsOverride NewOverrides(E->getFPFeatures());
14448 getSema().CurFPFeatures =
14449 NewOverrides.applyOverrides(getSema().getLangOpts());
14450 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14451
14452 Expr *Callee = E->getCallee();
14453 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14454 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14456 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14457 return ExprError();
14458
14459 return getDerived().RebuildCXXOperatorCallExpr(
14460 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14461 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14462 }
14463
14464 UnresolvedSet<1> Functions;
14465 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14466 Callee = ICE->getSubExprAsWritten();
14467 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14468 ValueDecl *VD = cast_or_null<ValueDecl>(
14469 getDerived().TransformDecl(DR->getLocation(), DR));
14470 if (!VD)
14471 return ExprError();
14472
14473 if (!isa<CXXMethodDecl>(VD))
14474 Functions.addDecl(VD);
14475
14476 return getDerived().RebuildCXXOperatorCallExpr(
14477 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14478 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14479}
14480
14481template<typename Derived>
14484 return getDerived().TransformCallExpr(E);
14485}
14486
14487template <typename Derived>
14489 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14490 getSema().CurContext != E->getParentContext();
14491
14492 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14493 return E;
14494
14495 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14496 E->getBeginLoc(), E->getEndLoc(),
14497 getSema().CurContext);
14498}
14499
14500template <typename Derived>
14502 return E;
14503}
14504
14505template<typename Derived>
14508 // Transform the callee.
14509 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14510 if (Callee.isInvalid())
14511 return ExprError();
14512
14513 // Transform exec config.
14514 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14515 if (EC.isInvalid())
14516 return ExprError();
14517
14518 // Transform arguments.
14519 bool ArgChanged = false;
14521 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14522 &ArgChanged))
14523 return ExprError();
14524
14525 if (!getDerived().AlwaysRebuild() &&
14526 Callee.get() == E->getCallee() &&
14527 !ArgChanged)
14528 return SemaRef.MaybeBindToTemporary(E);
14529
14530 // FIXME: Wrong source location information for the '('.
14531 SourceLocation FakeLParenLoc
14532 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14533 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14534 Args,
14535 E->getRParenLoc(), EC.get());
14536}
14537
14538template<typename Derived>
14541 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14542 if (!Type)
14543 return ExprError();
14544
14545 ExprResult SubExpr
14546 = getDerived().TransformExpr(E->getSubExprAsWritten());
14547 if (SubExpr.isInvalid())
14548 return ExprError();
14549
14550 if (!getDerived().AlwaysRebuild() &&
14551 Type == E->getTypeInfoAsWritten() &&
14552 SubExpr.get() == E->getSubExpr())
14553 return E;
14554 return getDerived().RebuildCXXNamedCastExpr(
14557 // FIXME. this should be '(' location
14558 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14559}
14560
14561template<typename Derived>
14564 TypeSourceInfo *TSI =
14565 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14566 if (!TSI)
14567 return ExprError();
14568
14569 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14570 if (Sub.isInvalid())
14571 return ExprError();
14572
14573 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14574 Sub.get(), BCE->getEndLoc());
14575}
14576
14577template<typename Derived>
14579TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14580 return getDerived().TransformCXXNamedCastExpr(E);
14581}
14582
14583template<typename Derived>
14586 return getDerived().TransformCXXNamedCastExpr(E);
14587}
14588
14589template<typename Derived>
14593 return getDerived().TransformCXXNamedCastExpr(E);
14594}
14595
14596template<typename Derived>
14599 return getDerived().TransformCXXNamedCastExpr(E);
14600}
14601
14602template<typename Derived>
14605 return getDerived().TransformCXXNamedCastExpr(E);
14606}
14607
14608template<typename Derived>
14613 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14614 if (!Type)
14615 return ExprError();
14616
14617 ExprResult SubExpr
14618 = getDerived().TransformExpr(E->getSubExprAsWritten());
14619 if (SubExpr.isInvalid())
14620 return ExprError();
14621
14622 if (!getDerived().AlwaysRebuild() &&
14623 Type == E->getTypeInfoAsWritten() &&
14624 SubExpr.get() == E->getSubExpr())
14625 return E;
14626
14627 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14628 E->getLParenLoc(),
14629 SubExpr.get(),
14630 E->getRParenLoc(),
14631 E->isListInitialization());
14632}
14633
14634template<typename Derived>
14637 if (E->isTypeOperand()) {
14638 TypeSourceInfo *TInfo
14639 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14640 if (!TInfo)
14641 return ExprError();
14642
14643 if (!getDerived().AlwaysRebuild() &&
14644 TInfo == E->getTypeOperandSourceInfo())
14645 return E;
14646
14647 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14648 TInfo, E->getEndLoc());
14649 }
14650
14651 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14652 // type. We must not unilaterally enter unevaluated context here, as then
14653 // semantic processing can re-transform an already transformed operand.
14654 Expr *Op = E->getExprOperand();
14656 if (E->isGLValue()) {
14657 QualType OpType = Op->getType();
14658 if (auto *RD = OpType->getAsCXXRecordDecl()) {
14659 if (SemaRef.RequireCompleteType(E->getBeginLoc(), OpType,
14660 diag::err_incomplete_typeid))
14661 return ExprError();
14662
14663 if (RD->isPolymorphic())
14664 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14665 }
14666 }
14667
14670
14671 ExprResult SubExpr = getDerived().TransformExpr(Op);
14672 if (SubExpr.isInvalid())
14673 return ExprError();
14674
14675 if (!getDerived().AlwaysRebuild() &&
14676 SubExpr.get() == E->getExprOperand())
14677 return E;
14678
14679 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14680 SubExpr.get(), E->getEndLoc());
14681}
14682
14683template<typename Derived>
14686 if (E->isTypeOperand()) {
14687 TypeSourceInfo *TInfo
14688 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14689 if (!TInfo)
14690 return ExprError();
14691
14692 if (!getDerived().AlwaysRebuild() &&
14693 TInfo == E->getTypeOperandSourceInfo())
14694 return E;
14695
14696 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14697 TInfo, E->getEndLoc());
14698 }
14699
14702
14703 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14704 if (SubExpr.isInvalid())
14705 return ExprError();
14706
14707 if (!getDerived().AlwaysRebuild() &&
14708 SubExpr.get() == E->getExprOperand())
14709 return E;
14710
14711 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14712 SubExpr.get(), E->getEndLoc());
14713}
14714
14715template<typename Derived>
14718 return E;
14719}
14720
14721template<typename Derived>
14725 return E;
14726}
14727
14728template<typename Derived>
14731
14732 // In lambdas, the qualifiers of the type depends of where in
14733 // the call operator `this` appear, and we do not have a good way to
14734 // rebuild this information, so we transform the type.
14735 //
14736 // In other contexts, the type of `this` may be overrided
14737 // for type deduction, so we need to recompute it.
14738 //
14739 // Always recompute the type if we're in the body of a lambda, and
14740 // 'this' is dependent on a lambda's explicit object parameter; we
14741 // also need to always rebuild the expression in this case to clear
14742 // the flag.
14743 QualType T = [&]() {
14744 auto &S = getSema();
14745 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14746 return S.getCurrentThisType();
14747 if (S.getCurLambda())
14748 return getDerived().TransformType(E->getType());
14749 return S.getCurrentThisType();
14750 }();
14751
14752 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14753 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14754 // Mark it referenced in the new context regardless.
14755 // FIXME: this is a bit instantiation-specific.
14756 getSema().MarkThisReferenced(E);
14757 return E;
14758 }
14759
14760 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14761}
14762
14763template<typename Derived>
14766 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14767 if (SubExpr.isInvalid())
14768 return ExprError();
14769
14770 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14771
14772 if (!getDerived().AlwaysRebuild() &&
14773 SubExpr.get() == E->getSubExpr())
14774 return E;
14775
14776 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14777 E->isThrownVariableInScope());
14778}
14779
14780template<typename Derived>
14783 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14784 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14785 if (!Param)
14786 return ExprError();
14787
14788 ExprResult InitRes;
14789 if (E->hasRewrittenInit()) {
14790 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14791 if (InitRes.isInvalid())
14792 return ExprError();
14793 }
14794
14795 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14796 E->getUsedContext() == SemaRef.CurContext &&
14797 InitRes.get() == E->getRewrittenExpr())
14798 return E;
14799
14800 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14801 InitRes.get());
14802}
14803
14804template<typename Derived>
14807 FieldDecl *Field = cast_or_null<FieldDecl>(
14808 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14809 if (!Field)
14810 return ExprError();
14811
14812 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14813 E->getUsedContext() == SemaRef.CurContext)
14814 return E;
14815
14816 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14817}
14818
14819template<typename Derived>
14823 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14824 if (!T)
14825 return ExprError();
14826
14827 if (!getDerived().AlwaysRebuild() &&
14828 T == E->getTypeSourceInfo())
14829 return E;
14830
14831 return getDerived().RebuildCXXScalarValueInitExpr(T,
14832 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14833 E->getRParenLoc());
14834}
14835
14836template<typename Derived>
14839 // Transform the type that we're allocating
14840 TypeSourceInfo *AllocTypeInfo =
14841 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14842 if (!AllocTypeInfo)
14843 return ExprError();
14844
14845 // Transform the size of the array we're allocating (if any).
14846 std::optional<Expr *> ArraySize;
14847 if (E->isArray()) {
14848 ExprResult NewArraySize;
14849 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14850 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14851 if (NewArraySize.isInvalid())
14852 return ExprError();
14853 }
14854 ArraySize = NewArraySize.get();
14855 }
14856
14857 // Transform the placement arguments (if any).
14858 bool ArgumentChanged = false;
14859 SmallVector<Expr*, 8> PlacementArgs;
14860 if (getDerived().TransformExprs(E->getPlacementArgs(),
14861 E->getNumPlacementArgs(), true,
14862 PlacementArgs, &ArgumentChanged))
14863 return ExprError();
14864
14865 // Transform the initializer (if any).
14866 Expr *OldInit = E->getInitializer();
14867 ExprResult NewInit;
14868 if (OldInit)
14869 NewInit = getDerived().TransformInitializer(OldInit, true);
14870 if (NewInit.isInvalid())
14871 return ExprError();
14872
14873 // Transform new operator and delete operator.
14874 FunctionDecl *OperatorNew = nullptr;
14875 if (E->getOperatorNew()) {
14876 OperatorNew = cast_or_null<FunctionDecl>(
14877 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14878 if (!OperatorNew)
14879 return ExprError();
14880 }
14881
14882 FunctionDecl *OperatorDelete = nullptr;
14883 if (E->getOperatorDelete()) {
14884 OperatorDelete = cast_or_null<FunctionDecl>(
14885 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14886 if (!OperatorDelete)
14887 return ExprError();
14888 }
14889
14890 if (!getDerived().AlwaysRebuild() &&
14891 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14892 ArraySize == E->getArraySize() &&
14893 NewInit.get() == OldInit &&
14894 OperatorNew == E->getOperatorNew() &&
14895 OperatorDelete == E->getOperatorDelete() &&
14896 !ArgumentChanged) {
14897 // Mark any declarations we need as referenced.
14898 // FIXME: instantiation-specific.
14899 if (OperatorNew)
14900 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14901 if (OperatorDelete)
14902 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14903
14904 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14905 QualType ElementType
14906 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14907 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14909 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14910 }
14911 }
14912
14913 return E;
14914 }
14915
14916 QualType AllocType = AllocTypeInfo->getType();
14917 if (!ArraySize) {
14918 // If no array size was specified, but the new expression was
14919 // instantiated with an array type (e.g., "new T" where T is
14920 // instantiated with "int[4]"), extract the outer bound from the
14921 // array type as our array size. We do this with constant and
14922 // dependently-sized array types.
14923 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14924 if (!ArrayT) {
14925 // Do nothing
14926 } else if (const ConstantArrayType *ConsArrayT
14927 = dyn_cast<ConstantArrayType>(ArrayT)) {
14928 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14929 SemaRef.Context.getSizeType(),
14930 /*FIXME:*/ E->getBeginLoc());
14931 AllocType = ConsArrayT->getElementType();
14932 } else if (const DependentSizedArrayType *DepArrayT
14933 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14934 if (DepArrayT->getSizeExpr()) {
14935 ArraySize = DepArrayT->getSizeExpr();
14936 AllocType = DepArrayT->getElementType();
14937 }
14938 }
14939 }
14940
14941 return getDerived().RebuildCXXNewExpr(
14942 E->getBeginLoc(), E->isGlobalNew(),
14943 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14944 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14945 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14946}
14947
14948template<typename Derived>
14951 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14952 if (Operand.isInvalid())
14953 return ExprError();
14954
14955 // Transform the delete operator, if known.
14956 FunctionDecl *OperatorDelete = nullptr;
14957 if (E->getOperatorDelete()) {
14958 OperatorDelete = cast_or_null<FunctionDecl>(
14959 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14960 if (!OperatorDelete)
14961 return ExprError();
14962 }
14963
14964 if (!getDerived().AlwaysRebuild() &&
14965 Operand.get() == E->getArgument() &&
14966 OperatorDelete == E->getOperatorDelete()) {
14967 // Mark any declarations we need as referenced.
14968 // FIXME: instantiation-specific.
14969 if (OperatorDelete)
14970 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14971
14972 if (!E->getArgument()->isTypeDependent()) {
14974 E->getDestroyedType());
14975 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14976 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14977 SemaRef.LookupDestructor(Record));
14978 }
14979
14980 return E;
14981 }
14982
14983 return getDerived().RebuildCXXDeleteExpr(
14984 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14985}
14986
14987template<typename Derived>
14991 ExprResult Base = getDerived().TransformExpr(E->getBase());
14992 if (Base.isInvalid())
14993 return ExprError();
14994
14995 ParsedType ObjectTypePtr;
14996 bool MayBePseudoDestructor = false;
14997 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14998 E->getOperatorLoc(),
14999 E->isArrow()? tok::arrow : tok::period,
15000 ObjectTypePtr,
15001 MayBePseudoDestructor);
15002 if (Base.isInvalid())
15003 return ExprError();
15004
15005 QualType ObjectType = ObjectTypePtr.get();
15006 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
15007 if (QualifierLoc) {
15008 QualifierLoc
15009 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
15010 if (!QualifierLoc)
15011 return ExprError();
15012 }
15013 CXXScopeSpec SS;
15014 SS.Adopt(QualifierLoc);
15015
15017 if (E->getDestroyedTypeInfo()) {
15018 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
15019 E->getDestroyedTypeInfo(), ObjectType,
15020 /*FirstQualifierInScope=*/nullptr);
15021 if (!DestroyedTypeInfo)
15022 return ExprError();
15023 Destroyed = DestroyedTypeInfo;
15024 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
15025 // We aren't likely to be able to resolve the identifier down to a type
15026 // now anyway, so just retain the identifier.
15027 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
15028 E->getDestroyedTypeLoc());
15029 } else {
15030 // Look for a destructor known with the given name.
15031 ParsedType T = SemaRef.getDestructorName(
15032 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
15033 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
15034 if (!T)
15035 return ExprError();
15036
15037 Destroyed
15039 E->getDestroyedTypeLoc());
15040 }
15041
15042 TypeSourceInfo *ScopeTypeInfo = nullptr;
15043 if (E->getScopeTypeInfo()) {
15044 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
15045 E->getScopeTypeInfo(), ObjectType, nullptr);
15046 if (!ScopeTypeInfo)
15047 return ExprError();
15048 }
15049
15050 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
15051 E->getOperatorLoc(),
15052 E->isArrow(),
15053 SS,
15054 ScopeTypeInfo,
15055 E->getColonColonLoc(),
15056 E->getTildeLoc(),
15057 Destroyed);
15058}
15059
15060template <typename Derived>
15062 bool RequiresADL,
15063 LookupResult &R) {
15064 // Transform all the decls.
15065 bool AllEmptyPacks = true;
15066 for (auto *OldD : Old->decls()) {
15067 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
15068 if (!InstD) {
15069 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
15070 // This can happen because of dependent hiding.
15071 if (isa<UsingShadowDecl>(OldD))
15072 continue;
15073 else {
15074 R.clear();
15075 return true;
15076 }
15077 }
15078
15079 // Expand using pack declarations.
15080 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
15081 ArrayRef<NamedDecl*> Decls = SingleDecl;
15082 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
15083 Decls = UPD->expansions();
15084
15085 // Expand using declarations.
15086 for (auto *D : Decls) {
15087 if (auto *UD = dyn_cast<UsingDecl>(D)) {
15088 for (auto *SD : UD->shadows())
15089 R.addDecl(SD);
15090 } else {
15091 R.addDecl(D);
15092 }
15093 }
15094
15095 AllEmptyPacks &= Decls.empty();
15096 }
15097
15098 // C++ [temp.res]/8.4.2:
15099 // The program is ill-formed, no diagnostic required, if [...] lookup for
15100 // a name in the template definition found a using-declaration, but the
15101 // lookup in the corresponding scope in the instantiation odoes not find
15102 // any declarations because the using-declaration was a pack expansion and
15103 // the corresponding pack is empty
15104 if (AllEmptyPacks && !RequiresADL) {
15105 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
15106 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
15107 return true;
15108 }
15109
15110 // Resolve a kind, but don't do any further analysis. If it's
15111 // ambiguous, the callee needs to deal with it.
15112 R.resolveKind();
15113
15114 if (Old->hasTemplateKeyword() && !R.empty()) {
15115 NamedDecl *FoundDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
15116 getSema().FilterAcceptableTemplateNames(R,
15117 /*AllowFunctionTemplates=*/true,
15118 /*AllowDependent=*/true);
15119 if (R.empty()) {
15120 // If a 'template' keyword was used, a lookup that finds only non-template
15121 // names is an error.
15122 getSema().Diag(R.getNameLoc(),
15123 diag::err_template_kw_refers_to_non_template)
15124 << R.getLookupName() << Old->getQualifierLoc().getSourceRange()
15125 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
15126 getSema().Diag(FoundDecl->getLocation(),
15127 diag::note_template_kw_refers_to_non_template)
15128 << R.getLookupName();
15129 return true;
15130 }
15131 }
15132
15133 return false;
15134}
15135
15136template <typename Derived>
15141
15142template <typename Derived>
15145 bool IsAddressOfOperand) {
15146 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
15148
15149 // Transform the declaration set.
15150 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
15151 return ExprError();
15152
15153 // Rebuild the nested-name qualifier, if present.
15154 CXXScopeSpec SS;
15155 if (Old->getQualifierLoc()) {
15156 NestedNameSpecifierLoc QualifierLoc
15157 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
15158 if (!QualifierLoc)
15159 return ExprError();
15160
15161 SS.Adopt(QualifierLoc);
15162 }
15163
15164 if (Old->getNamingClass()) {
15165 CXXRecordDecl *NamingClass
15166 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
15167 Old->getNameLoc(),
15168 Old->getNamingClass()));
15169 if (!NamingClass) {
15170 R.clear();
15171 return ExprError();
15172 }
15173
15174 R.setNamingClass(NamingClass);
15175 }
15176
15177 // Rebuild the template arguments, if any.
15178 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
15179 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
15180 if (Old->hasExplicitTemplateArgs() &&
15181 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15182 Old->getNumTemplateArgs(),
15183 TransArgs)) {
15184 R.clear();
15185 return ExprError();
15186 }
15187
15188 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
15189 // a non-static data member is named in an unevaluated operand, or when
15190 // a member is named in a dependent class scope function template explicit
15191 // specialization that is neither declared static nor with an explicit object
15192 // parameter.
15193 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
15194 return SemaRef.BuildPossibleImplicitMemberExpr(
15195 SS, TemplateKWLoc, R,
15196 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
15197 /*S=*/nullptr);
15198
15199 // If we have neither explicit template arguments, nor the template keyword,
15200 // it's a normal declaration name or member reference.
15201 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
15202 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
15203
15204 // If we have template arguments, then rebuild the template-id expression.
15205 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
15206 Old->requiresADL(), &TransArgs);
15207}
15208
15209template<typename Derived>
15212 bool ArgChanged = false;
15214 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15215 TypeSourceInfo *From = E->getArg(I);
15216 TypeLoc FromTL = From->getTypeLoc();
15217 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15218 TypeLocBuilder TLB;
15219 TLB.reserve(FromTL.getFullDataSize());
15220 QualType To = getDerived().TransformType(TLB, FromTL);
15221 if (To.isNull())
15222 return ExprError();
15223
15224 if (To == From->getType())
15225 Args.push_back(From);
15226 else {
15227 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15228 ArgChanged = true;
15229 }
15230 continue;
15231 }
15232
15233 ArgChanged = true;
15234
15235 // We have a pack expansion. Instantiate it.
15236 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15237 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15239 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15240
15241 // Determine whether the set of unexpanded parameter packs can and should
15242 // be expanded.
15243 bool Expand = true;
15244 bool RetainExpansion = false;
15245 UnsignedOrNone OrigNumExpansions =
15246 ExpansionTL.getTypePtr()->getNumExpansions();
15247 UnsignedOrNone NumExpansions = OrigNumExpansions;
15248 if (getDerived().TryExpandParameterPacks(
15249 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15250 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15251 RetainExpansion, NumExpansions))
15252 return ExprError();
15253
15254 if (!Expand) {
15255 // The transform has determined that we should perform a simple
15256 // transformation on the pack expansion, producing another pack
15257 // expansion.
15258 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15259
15260 TypeLocBuilder TLB;
15261 TLB.reserve(From->getTypeLoc().getFullDataSize());
15262
15263 QualType To = getDerived().TransformType(TLB, PatternTL);
15264 if (To.isNull())
15265 return ExprError();
15266
15267 To = getDerived().RebuildPackExpansionType(To,
15268 PatternTL.getSourceRange(),
15269 ExpansionTL.getEllipsisLoc(),
15270 NumExpansions);
15271 if (To.isNull())
15272 return ExprError();
15273
15274 PackExpansionTypeLoc ToExpansionTL
15275 = TLB.push<PackExpansionTypeLoc>(To);
15276 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15277 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15278 continue;
15279 }
15280
15281 // Expand the pack expansion by substituting for each argument in the
15282 // pack(s).
15283 for (unsigned I = 0; I != *NumExpansions; ++I) {
15284 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15285 TypeLocBuilder TLB;
15286 TLB.reserve(PatternTL.getFullDataSize());
15287 QualType To = getDerived().TransformType(TLB, PatternTL);
15288 if (To.isNull())
15289 return ExprError();
15290
15291 if (To->containsUnexpandedParameterPack()) {
15292 To = getDerived().RebuildPackExpansionType(To,
15293 PatternTL.getSourceRange(),
15294 ExpansionTL.getEllipsisLoc(),
15295 NumExpansions);
15296 if (To.isNull())
15297 return ExprError();
15298
15299 PackExpansionTypeLoc ToExpansionTL
15300 = TLB.push<PackExpansionTypeLoc>(To);
15301 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15302 }
15303
15304 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15305 }
15306
15307 if (!RetainExpansion)
15308 continue;
15309
15310 // If we're supposed to retain a pack expansion, do so by temporarily
15311 // forgetting the partially-substituted parameter pack.
15312 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15313
15314 TypeLocBuilder TLB;
15315 TLB.reserve(From->getTypeLoc().getFullDataSize());
15316
15317 QualType To = getDerived().TransformType(TLB, PatternTL);
15318 if (To.isNull())
15319 return ExprError();
15320
15321 To = getDerived().RebuildPackExpansionType(To,
15322 PatternTL.getSourceRange(),
15323 ExpansionTL.getEllipsisLoc(),
15324 NumExpansions);
15325 if (To.isNull())
15326 return ExprError();
15327
15328 PackExpansionTypeLoc ToExpansionTL
15329 = TLB.push<PackExpansionTypeLoc>(To);
15330 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15331 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15332 }
15333
15334 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15335 return E;
15336
15337 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15338 E->getEndLoc());
15339}
15340
15341template<typename Derived>
15345 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15346 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15347 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15348 Old->NumTemplateArgs, TransArgs))
15349 return ExprError();
15350
15351 return getDerived().RebuildConceptSpecializationExpr(
15352 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15353 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15354 &TransArgs);
15355}
15356
15357template<typename Derived>
15360 SmallVector<ParmVarDecl*, 4> TransParams;
15361 SmallVector<QualType, 4> TransParamTypes;
15362 Sema::ExtParameterInfoBuilder ExtParamInfos;
15363
15364 // C++2a [expr.prim.req]p2
15365 // Expressions appearing within a requirement-body are unevaluated operands.
15369
15371 getSema().Context, getSema().CurContext,
15372 E->getBody()->getBeginLoc());
15373
15374 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15375
15376 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15377 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15378 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15379
15380 for (ParmVarDecl *Param : TransParams)
15381 if (Param)
15382 Param->setDeclContext(Body);
15383
15384 // On failure to transform, TransformRequiresTypeParams returns an expression
15385 // in the event that the transformation of the type params failed in some way.
15386 // It is expected that this will result in a 'not satisfied' Requires clause
15387 // when instantiating.
15388 if (!TypeParamResult.isUnset())
15389 return TypeParamResult;
15390
15392 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15393 TransReqs))
15394 return ExprError();
15395
15396 for (concepts::Requirement *Req : TransReqs) {
15397 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15398 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15399 ER->getReturnTypeRequirement()
15400 .getTypeConstraintTemplateParameterList()->getParam(0)
15401 ->setDeclContext(Body);
15402 }
15403 }
15404 }
15405
15406 return getDerived().RebuildRequiresExpr(
15407 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15408 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15409}
15410
15411template<typename Derived>
15415 for (concepts::Requirement *Req : Reqs) {
15416 concepts::Requirement *TransReq = nullptr;
15417 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15418 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15419 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15420 TransReq = getDerived().TransformExprRequirement(ExprReq);
15421 else
15422 TransReq = getDerived().TransformNestedRequirement(
15424 if (!TransReq)
15425 return true;
15426 Transformed.push_back(TransReq);
15427 }
15428 return false;
15429}
15430
15431template<typename Derived>
15435 if (Req->isSubstitutionFailure()) {
15436 if (getDerived().AlwaysRebuild())
15437 return getDerived().RebuildTypeRequirement(
15439 return Req;
15440 }
15441 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15442 if (!TransType)
15443 return nullptr;
15444 return getDerived().RebuildTypeRequirement(TransType);
15445}
15446
15447template<typename Derived>
15450 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15451 if (Req->isExprSubstitutionFailure())
15452 TransExpr = Req->getExprSubstitutionDiagnostic();
15453 else {
15454 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15455 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15456 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15457 if (TransExprRes.isInvalid())
15458 return nullptr;
15459 TransExpr = TransExprRes.get();
15460 }
15461
15462 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15463 const auto &RetReq = Req->getReturnTypeRequirement();
15464 if (RetReq.isEmpty())
15465 TransRetReq.emplace();
15466 else if (RetReq.isSubstitutionFailure())
15467 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15468 else if (RetReq.isTypeConstraint()) {
15469 TemplateParameterList *OrigTPL =
15470 RetReq.getTypeConstraintTemplateParameterList();
15472 getDerived().TransformTemplateParameterList(OrigTPL);
15473 if (!TPL)
15474 return nullptr;
15475 TransRetReq.emplace(TPL);
15476 }
15477 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15478 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15479 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15480 Req->getNoexceptLoc(),
15481 std::move(*TransRetReq));
15482 return getDerived().RebuildExprRequirement(
15484 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15485}
15486
15487template<typename Derived>
15491 if (Req->hasInvalidConstraint()) {
15492 if (getDerived().AlwaysRebuild())
15493 return getDerived().RebuildNestedRequirement(
15495 return Req;
15496 }
15497 ExprResult TransConstraint =
15498 getDerived().TransformExpr(Req->getConstraintExpr());
15499 if (TransConstraint.isInvalid())
15500 return nullptr;
15501 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15502}
15503
15504template<typename Derived>
15507 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15508 if (!T)
15509 return ExprError();
15510
15511 if (!getDerived().AlwaysRebuild() &&
15512 T == E->getQueriedTypeSourceInfo())
15513 return E;
15514
15515 ExprResult SubExpr;
15516 {
15519 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15520 if (SubExpr.isInvalid())
15521 return ExprError();
15522 }
15523
15524 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15525 SubExpr.get(), E->getEndLoc());
15526}
15527
15528template<typename Derived>
15531 ExprResult SubExpr;
15532 {
15535 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15536 if (SubExpr.isInvalid())
15537 return ExprError();
15538
15539 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15540 return E;
15541 }
15542
15543 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15544 SubExpr.get(), E->getEndLoc());
15545}
15546
15547template <typename Derived>
15549 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15550 TypeSourceInfo **RecoveryTSI) {
15551 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15552 DRE, AddrTaken, RecoveryTSI);
15553
15554 // Propagate both errors and recovered types, which return ExprEmpty.
15555 if (!NewDRE.isUsable())
15556 return NewDRE;
15557
15558 // We got an expr, wrap it up in parens.
15559 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15560 return PE;
15561 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15562 PE->getRParen());
15563}
15564
15565template <typename Derived>
15571
15572template <typename Derived>
15574 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15575 TypeSourceInfo **RecoveryTSI) {
15576 assert(E->getQualifierLoc());
15577 NestedNameSpecifierLoc QualifierLoc =
15578 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15579 if (!QualifierLoc)
15580 return ExprError();
15581 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15582
15583 // TODO: If this is a conversion-function-id, verify that the
15584 // destination type name (if present) resolves the same way after
15585 // instantiation as it did in the local scope.
15586
15587 DeclarationNameInfo NameInfo =
15588 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15589 if (!NameInfo.getName())
15590 return ExprError();
15591
15592 if (!E->hasExplicitTemplateArgs()) {
15593 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15594 // Note: it is sufficient to compare the Name component of NameInfo:
15595 // if name has not changed, DNLoc has not changed either.
15596 NameInfo.getName() == E->getDeclName())
15597 return E;
15598
15599 return getDerived().RebuildDependentScopeDeclRefExpr(
15600 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15601 IsAddressOfOperand, RecoveryTSI);
15602 }
15603
15604 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15605 if (getDerived().TransformTemplateArguments(
15606 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15607 return ExprError();
15608
15609 return getDerived().RebuildDependentScopeDeclRefExpr(
15610 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15611 RecoveryTSI);
15612}
15613
15614template<typename Derived>
15617 // CXXConstructExprs other than for list-initialization and
15618 // CXXTemporaryObjectExpr are always implicit, so when we have
15619 // a 1-argument construction we just transform that argument.
15620 if (getDerived().AllowSkippingCXXConstructExpr() &&
15621 ((E->getNumArgs() == 1 ||
15622 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15623 (!getDerived().DropCallArgument(E->getArg(0))) &&
15624 !E->isListInitialization()))
15625 return getDerived().TransformInitializer(E->getArg(0),
15626 /*DirectInit*/ false);
15627
15628 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15629
15630 QualType T = getDerived().TransformType(E->getType());
15631 if (T.isNull())
15632 return ExprError();
15633
15634 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15635 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15636 if (!Constructor)
15637 return ExprError();
15638
15639 bool ArgumentChanged = false;
15641 {
15644 E->isListInitialization());
15645 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15646 &ArgumentChanged))
15647 return ExprError();
15648 }
15649
15650 if (!getDerived().AlwaysRebuild() &&
15651 T == E->getType() &&
15652 Constructor == E->getConstructor() &&
15653 !ArgumentChanged) {
15654 // Mark the constructor as referenced.
15655 // FIXME: Instantiation-specific
15656 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15657 return E;
15658 }
15659
15660 return getDerived().RebuildCXXConstructExpr(
15661 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15662 E->hadMultipleCandidates(), E->isListInitialization(),
15663 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15664 E->getConstructionKind(), E->getParenOrBraceRange());
15665}
15666
15667template<typename Derived>
15670 QualType T = getDerived().TransformType(E->getType());
15671 if (T.isNull())
15672 return ExprError();
15673
15674 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15675 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15676 if (!Constructor)
15677 return ExprError();
15678
15679 if (!getDerived().AlwaysRebuild() &&
15680 T == E->getType() &&
15681 Constructor == E->getConstructor()) {
15682 // Mark the constructor as referenced.
15683 // FIXME: Instantiation-specific
15684 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15685 return E;
15686 }
15687
15688 return getDerived().RebuildCXXInheritedCtorInitExpr(
15689 T, E->getLocation(), Constructor,
15690 E->constructsVBase(), E->inheritedFromVBase());
15691}
15692
15693/// Transform a C++ temporary-binding expression.
15694///
15695/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15696/// transform the subexpression and return that.
15697template<typename Derived>
15700 if (auto *Dtor = E->getTemporary()->getDestructor())
15701 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15702 const_cast<CXXDestructorDecl *>(Dtor));
15703 return getDerived().TransformExpr(E->getSubExpr());
15704}
15705
15706/// Transform a C++ expression that contains cleanups that should
15707/// be run after the expression is evaluated.
15708///
15709/// Since ExprWithCleanups nodes are implicitly generated, we
15710/// just transform the subexpression and return that.
15711template<typename Derived>
15714 return getDerived().TransformExpr(E->getSubExpr());
15715}
15716
15717template<typename Derived>
15721 TypeSourceInfo *T =
15722 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15723 if (!T)
15724 return ExprError();
15725
15726 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15727 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15728 if (!Constructor)
15729 return ExprError();
15730
15731 bool ArgumentChanged = false;
15733 Args.reserve(E->getNumArgs());
15734 {
15737 E->isListInitialization());
15738 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15739 &ArgumentChanged))
15740 return ExprError();
15741
15742 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15743 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc(),
15744 /*IsExplicit=*/true);
15745 if (Res.isInvalid())
15746 return ExprError();
15747 Args = {Res.get()};
15748 }
15749 }
15750
15751 if (!getDerived().AlwaysRebuild() &&
15752 T == E->getTypeSourceInfo() &&
15753 Constructor == E->getConstructor() &&
15754 !ArgumentChanged) {
15755 // FIXME: Instantiation-specific
15756 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15757 return SemaRef.MaybeBindToTemporary(E);
15758 }
15759
15760 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15761 return getDerived().RebuildCXXTemporaryObjectExpr(
15762 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15763}
15764
15765template<typename Derived>
15768 // Transform any init-capture expressions before entering the scope of the
15769 // lambda body, because they are not semantically within that scope.
15770 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15771 struct TransformedInitCapture {
15772 // The location of the ... if the result is retaining a pack expansion.
15773 SourceLocation EllipsisLoc;
15774 // Zero or more expansions of the init-capture.
15775 SmallVector<InitCaptureInfoTy, 4> Expansions;
15776 };
15778 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15779 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15780 CEnd = E->capture_end();
15781 C != CEnd; ++C) {
15782 if (!E->isInitCapture(C))
15783 continue;
15784
15785 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15786 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15787
15788 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15789 UnsignedOrNone NumExpansions) {
15790 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15791 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15792
15793 if (NewExprInitResult.isInvalid()) {
15794 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15795 return;
15796 }
15797 Expr *NewExprInit = NewExprInitResult.get();
15798
15799 QualType NewInitCaptureType =
15800 getSema().buildLambdaInitCaptureInitialization(
15801 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15802 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15803 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15805 NewExprInit);
15806 Result.Expansions.push_back(
15807 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15808 };
15809
15810 // If this is an init-capture pack, consider expanding the pack now.
15811 if (OldVD->isParameterPack()) {
15812 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15813 ->getTypeLoc()
15816 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15817
15818 // Determine whether the set of unexpanded parameter packs can and should
15819 // be expanded.
15820 bool Expand = true;
15821 bool RetainExpansion = false;
15822 UnsignedOrNone OrigNumExpansions =
15823 ExpansionTL.getTypePtr()->getNumExpansions();
15824 UnsignedOrNone NumExpansions = OrigNumExpansions;
15825 if (getDerived().TryExpandParameterPacks(
15826 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15827 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15828 RetainExpansion, NumExpansions))
15829 return ExprError();
15830 assert(!RetainExpansion && "Should not need to retain expansion after a "
15831 "capture since it cannot be extended");
15832 if (Expand) {
15833 for (unsigned I = 0; I != *NumExpansions; ++I) {
15834 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15835 SubstInitCapture(SourceLocation(), std::nullopt);
15836 }
15837 } else {
15838 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15839 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15840 }
15841 } else {
15842 SubstInitCapture(SourceLocation(), std::nullopt);
15843 }
15844 }
15845
15846 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15847 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15848
15849 // Create the local class that will describe the lambda.
15850
15851 // FIXME: DependencyKind below is wrong when substituting inside a templated
15852 // context that isn't a DeclContext (such as a variable template), or when
15853 // substituting an unevaluated lambda inside of a function's parameter's type
15854 // - as parameter types are not instantiated from within a function's DC. We
15855 // use evaluation contexts to distinguish the function parameter case.
15858 DeclContext *DC = getSema().CurContext;
15859 // A RequiresExprBodyDecl is not interesting for dependencies.
15860 // For the following case,
15861 //
15862 // template <typename>
15863 // concept C = requires { [] {}; };
15864 //
15865 // template <class F>
15866 // struct Widget;
15867 //
15868 // template <C F>
15869 // struct Widget<F> {};
15870 //
15871 // While we are substituting Widget<F>, the parent of DC would be
15872 // the template specialization itself. Thus, the lambda expression
15873 // will be deemed as dependent even if there are no dependent template
15874 // arguments.
15875 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15876 while (DC->isRequiresExprBody())
15877 DC = DC->getParent();
15878 if ((getSema().isUnevaluatedContext() ||
15879 getSema().isConstantEvaluatedContext()) &&
15880 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15881 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
15882 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15883 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15884
15885 CXXRecordDecl *OldClass = E->getLambdaClass();
15886 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15887 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15888 E->getCaptureDefault());
15889 getDerived().transformedLocalDecl(OldClass, {Class});
15890
15891 CXXMethodDecl *NewCallOperator =
15892 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15893
15894 // Enter the scope of the lambda.
15895 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15896 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15897 E->hasExplicitParameters(), E->isMutable());
15898
15899 // Introduce the context of the call operator.
15900 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15901 /*NewThisContext*/false);
15902
15903 bool Invalid = false;
15904
15905 // Transform captures.
15906 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15907 CEnd = E->capture_end();
15908 C != CEnd; ++C) {
15909 // When we hit the first implicit capture, tell Sema that we've finished
15910 // the list of explicit captures.
15911 if (C->isImplicit())
15912 break;
15913
15914 // Capturing 'this' is trivial.
15915 if (C->capturesThis()) {
15916 // If this is a lambda that is part of a default member initialiser
15917 // and which we're instantiating outside the class that 'this' is
15918 // supposed to refer to, adjust the type of 'this' accordingly.
15919 //
15920 // Otherwise, leave the type of 'this' as-is.
15921 Sema::CXXThisScopeRAII ThisScope(
15922 getSema(),
15923 dyn_cast_if_present<CXXRecordDecl>(
15924 getSema().getFunctionLevelDeclContext()),
15925 Qualifiers());
15926 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15927 /*BuildAndDiagnose*/ true, nullptr,
15928 C->getCaptureKind() == LCK_StarThis);
15929 continue;
15930 }
15931 // Captured expression will be recaptured during captured variables
15932 // rebuilding.
15933 if (C->capturesVLAType())
15934 continue;
15935
15936 // Rebuild init-captures, including the implied field declaration.
15937 if (E->isInitCapture(C)) {
15938 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15939
15940 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15942
15943 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15944 ExprResult Init = Info.first;
15945 QualType InitQualType = Info.second;
15946 if (Init.isInvalid() || InitQualType.isNull()) {
15947 Invalid = true;
15948 break;
15949 }
15950 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15951 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15952 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15953 getSema().CurContext);
15954 if (!NewVD) {
15955 Invalid = true;
15956 break;
15957 }
15958 NewVDs.push_back(NewVD);
15959 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15960 // Cases we want to tackle:
15961 // ([C(Pack)] {}, ...)
15962 // But rule out cases e.g.
15963 // [...C = Pack()] {}
15964 if (NewC.EllipsisLoc.isInvalid())
15965 LSI->ContainsUnexpandedParameterPack |=
15966 Init.get()->containsUnexpandedParameterPack();
15967 }
15968
15969 if (Invalid)
15970 break;
15971
15972 getDerived().transformedLocalDecl(OldVD, NewVDs);
15973 continue;
15974 }
15975
15976 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15977
15978 // Determine the capture kind for Sema.
15980 : C->getCaptureKind() == LCK_ByCopy
15983 SourceLocation EllipsisLoc;
15984 if (C->isPackExpansion()) {
15985 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15986 bool ShouldExpand = false;
15987 bool RetainExpansion = false;
15988 UnsignedOrNone NumExpansions = std::nullopt;
15989 if (getDerived().TryExpandParameterPacks(
15990 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
15991 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
15992 RetainExpansion, NumExpansions)) {
15993 Invalid = true;
15994 continue;
15995 }
15996
15997 if (ShouldExpand) {
15998 // The transform has determined that we should perform an expansion;
15999 // transform and capture each of the arguments.
16000 // expansion of the pattern. Do so.
16001 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
16002 for (unsigned I = 0; I != *NumExpansions; ++I) {
16003 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16004 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
16005 getDerived().TransformDecl(C->getLocation(), Pack));
16006 if (!CapturedVar) {
16007 Invalid = true;
16008 continue;
16009 }
16010
16011 // Capture the transformed variable.
16012 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
16013 }
16014
16015 // FIXME: Retain a pack expansion if RetainExpansion is true.
16016
16017 continue;
16018 }
16019
16020 EllipsisLoc = C->getEllipsisLoc();
16021 }
16022
16023 // Transform the captured variable.
16024 auto *CapturedVar = cast_or_null<ValueDecl>(
16025 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16026 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
16027 Invalid = true;
16028 continue;
16029 }
16030
16031 // This is not an init-capture; however it contains an unexpanded pack e.g.
16032 // ([Pack] {}(), ...)
16033 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
16034 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
16035
16036 // Capture the transformed variable.
16037 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
16038 EllipsisLoc);
16039 }
16040 getSema().finishLambdaExplicitCaptures(LSI);
16041
16042 // Transform the template parameters, and add them to the current
16043 // instantiation scope. The null case is handled correctly.
16044 auto TPL = getDerived().TransformTemplateParameterList(
16045 E->getTemplateParameterList());
16046 LSI->GLTemplateParameterList = TPL;
16047 if (TPL) {
16048 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
16049 TPL);
16050 LSI->ContainsUnexpandedParameterPack |=
16051 TPL->containsUnexpandedParameterPack();
16052 }
16053
16054 TypeLocBuilder NewCallOpTLBuilder;
16055 TypeLoc OldCallOpTypeLoc =
16056 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
16057 QualType NewCallOpType =
16058 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
16059 if (NewCallOpType.isNull())
16060 return ExprError();
16061 LSI->ContainsUnexpandedParameterPack |=
16062 NewCallOpType->containsUnexpandedParameterPack();
16063 TypeSourceInfo *NewCallOpTSI =
16064 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
16065
16066 // The type may be an AttributedType or some other kind of sugar;
16067 // get the actual underlying FunctionProtoType.
16068 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
16069 assert(FPTL && "Not a FunctionProtoType?");
16070
16071 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
16072 if (TRC) {
16073 ExprResult E = getDerived().TransformConstraint(
16074 const_cast<Expr *>(TRC.ConstraintExpr));
16075 if (E.isInvalid())
16076 return E;
16077 TRC.ConstraintExpr = E.get();
16078 }
16079 // If the concept refers to any outer parameter packs, we track the
16080 // SubstIndex for evaluation.
16081 // FIXME: This seems unnecessary after transforming lambda constraints.
16082 if (TRC && TRC.ConstraintExpr->containsUnexpandedParameterPack() &&
16083 !TRC.ArgPackSubstIndex)
16085
16086 getSema().CompleteLambdaCallOperator(
16087 NewCallOperator, E->getCallOperator()->getLocation(),
16088 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
16089 E->getCallOperator()->getConstexprKind(),
16090 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
16091 E->hasExplicitResultType());
16092
16093 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
16094 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
16095
16096 {
16097 // Number the lambda for linkage purposes if necessary.
16098 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
16099
16100 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
16101 if (getDerived().ReplacingOriginal()) {
16102 Numbering = OldClass->getLambdaNumbering();
16103 }
16104
16105 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
16106 }
16107
16108 // FIXME: Sema's lambda-building mechanism expects us to push an expression
16109 // evaluation context even if we're not transforming the function body.
16110 getSema().PushExpressionEvaluationContextForFunction(
16112 E->getCallOperator());
16113
16114 StmtResult Body;
16115 {
16116 Sema::NonSFINAEContext _(getSema());
16119 C.PointOfInstantiation = E->getBody()->getBeginLoc();
16120 getSema().pushCodeSynthesisContext(C);
16121
16122 // Instantiate the body of the lambda expression.
16123 Body = Invalid ? StmtError()
16124 : getDerived().TransformLambdaBody(E, E->getBody());
16125
16126 getSema().popCodeSynthesisContext();
16127 }
16128
16129 // ActOnLambda* will pop the function scope for us.
16130 FuncScopeCleanup.disable();
16131
16132 if (Body.isInvalid()) {
16133 SavedContext.pop();
16134 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
16135 /*IsInstantiation=*/true);
16136 return ExprError();
16137 }
16138
16139 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
16140 /*IsInstantiation=*/true,
16141 /*RetainFunctionScopeInfo=*/true);
16142 SavedContext.pop();
16143
16144 // Recompute the dependency of the lambda so that we can defer the lambda call
16145 // construction until after we have all the necessary template arguments. For
16146 // example, given
16147 //
16148 // template <class> struct S {
16149 // template <class U>
16150 // using Type = decltype([](U){}(42.0));
16151 // };
16152 // void foo() {
16153 // using T = S<int>::Type<float>;
16154 // ^~~~~~
16155 // }
16156 //
16157 // We would end up here from instantiating S<int> when ensuring its
16158 // completeness. That would transform the lambda call expression regardless of
16159 // the absence of the corresponding argument for U.
16160 //
16161 // Going ahead with unsubstituted type U makes things worse: we would soon
16162 // compare the argument type (which is float) against the parameter U
16163 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
16164 // error suggesting unmatched types 'U' and 'float'!
16165 //
16166 // That said, everything will be fine if we defer that semantic checking.
16167 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
16168 // dependent. Since the CallExpr's dependency boils down to the lambda's
16169 // dependency in this case, we can harness that by recomputing the dependency
16170 // from the instantiation arguments.
16171 //
16172 // FIXME: Creating the type of a lambda requires us to have a dependency
16173 // value, which happens before its substitution. We update its dependency
16174 // *after* the substitution in case we can't decide the dependency
16175 // so early, e.g. because we want to see if any of the *substituted*
16176 // parameters are dependent.
16177 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
16178 Class->setLambdaDependencyKind(DependencyKind);
16179
16180 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
16181 Body.get()->getEndLoc(), LSI);
16182}
16183
16184template<typename Derived>
16189
16190template<typename Derived>
16193 // Transform captures.
16195 CEnd = E->capture_end();
16196 C != CEnd; ++C) {
16197 // When we hit the first implicit capture, tell Sema that we've finished
16198 // the list of explicit captures.
16199 if (!C->isImplicit())
16200 continue;
16201
16202 // Capturing 'this' is trivial.
16203 if (C->capturesThis()) {
16204 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16205 /*BuildAndDiagnose*/ true, nullptr,
16206 C->getCaptureKind() == LCK_StarThis);
16207 continue;
16208 }
16209 // Captured expression will be recaptured during captured variables
16210 // rebuilding.
16211 if (C->capturesVLAType())
16212 continue;
16213
16214 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16215 assert(!E->isInitCapture(C) && "implicit init-capture?");
16216
16217 // Transform the captured variable.
16218 VarDecl *CapturedVar = cast_or_null<VarDecl>(
16219 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16220 if (!CapturedVar || CapturedVar->isInvalidDecl())
16221 return StmtError();
16222
16223 // Capture the transformed variable.
16224 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16225 }
16226
16227 return S;
16228}
16229
16230template<typename Derived>
16234 TypeSourceInfo *T =
16235 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16236 if (!T)
16237 return ExprError();
16238
16239 bool ArgumentChanged = false;
16241 Args.reserve(E->getNumArgs());
16242 {
16246 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16247 &ArgumentChanged))
16248 return ExprError();
16249 }
16250
16251 if (!getDerived().AlwaysRebuild() &&
16252 T == E->getTypeSourceInfo() &&
16253 !ArgumentChanged)
16254 return E;
16255
16256 // FIXME: we're faking the locations of the commas
16257 return getDerived().RebuildCXXUnresolvedConstructExpr(
16258 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16259}
16260
16261template<typename Derived>
16265 // Transform the base of the expression.
16266 ExprResult Base((Expr*) nullptr);
16267 Expr *OldBase;
16268 QualType BaseType;
16269 QualType ObjectType;
16270 if (!E->isImplicitAccess()) {
16271 OldBase = E->getBase();
16272 Base = getDerived().TransformExpr(OldBase);
16273 if (Base.isInvalid())
16274 return ExprError();
16275
16276 // Start the member reference and compute the object's type.
16277 ParsedType ObjectTy;
16278 bool MayBePseudoDestructor = false;
16279 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16280 E->getOperatorLoc(),
16281 E->isArrow()? tok::arrow : tok::period,
16282 ObjectTy,
16283 MayBePseudoDestructor);
16284 if (Base.isInvalid())
16285 return ExprError();
16286
16287 ObjectType = ObjectTy.get();
16288 BaseType = ((Expr*) Base.get())->getType();
16289 } else {
16290 OldBase = nullptr;
16291 BaseType = getDerived().TransformType(E->getBaseType());
16292 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16293 }
16294
16295 // Transform the first part of the nested-name-specifier that qualifies
16296 // the member name.
16297 NamedDecl *FirstQualifierInScope
16298 = getDerived().TransformFirstQualifierInScope(
16299 E->getFirstQualifierFoundInScope(),
16300 E->getQualifierLoc().getBeginLoc());
16301
16302 NestedNameSpecifierLoc QualifierLoc;
16303 if (E->getQualifier()) {
16304 QualifierLoc
16305 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16306 ObjectType,
16307 FirstQualifierInScope);
16308 if (!QualifierLoc)
16309 return ExprError();
16310 }
16311
16312 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16313
16314 // TODO: If this is a conversion-function-id, verify that the
16315 // destination type name (if present) resolves the same way after
16316 // instantiation as it did in the local scope.
16317
16318 DeclarationNameInfo NameInfo
16319 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16320 if (!NameInfo.getName())
16321 return ExprError();
16322
16323 if (!E->hasExplicitTemplateArgs()) {
16324 // This is a reference to a member without an explicitly-specified
16325 // template argument list. Optimize for this common case.
16326 if (!getDerived().AlwaysRebuild() &&
16327 Base.get() == OldBase &&
16328 BaseType == E->getBaseType() &&
16329 QualifierLoc == E->getQualifierLoc() &&
16330 NameInfo.getName() == E->getMember() &&
16331 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16332 return E;
16333
16334 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16335 BaseType,
16336 E->isArrow(),
16337 E->getOperatorLoc(),
16338 QualifierLoc,
16339 TemplateKWLoc,
16340 FirstQualifierInScope,
16341 NameInfo,
16342 /*TemplateArgs*/nullptr);
16343 }
16344
16345 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16346 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16347 E->getNumTemplateArgs(),
16348 TransArgs))
16349 return ExprError();
16350
16351 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16352 BaseType,
16353 E->isArrow(),
16354 E->getOperatorLoc(),
16355 QualifierLoc,
16356 TemplateKWLoc,
16357 FirstQualifierInScope,
16358 NameInfo,
16359 &TransArgs);
16360}
16361
16362template <typename Derived>
16364 UnresolvedMemberExpr *Old) {
16365 // Transform the base of the expression.
16366 ExprResult Base((Expr *)nullptr);
16367 QualType BaseType;
16368 if (!Old->isImplicitAccess()) {
16369 Base = getDerived().TransformExpr(Old->getBase());
16370 if (Base.isInvalid())
16371 return ExprError();
16372 Base =
16373 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16374 if (Base.isInvalid())
16375 return ExprError();
16376 BaseType = Base.get()->getType();
16377 } else {
16378 BaseType = getDerived().TransformType(Old->getBaseType());
16379 }
16380
16381 NestedNameSpecifierLoc QualifierLoc;
16382 if (Old->getQualifierLoc()) {
16383 QualifierLoc =
16384 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16385 if (!QualifierLoc)
16386 return ExprError();
16387 }
16388
16389 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16390
16391 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16392
16393 // Transform the declaration set.
16394 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16395 return ExprError();
16396
16397 // Determine the naming class.
16398 if (Old->getNamingClass()) {
16399 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16400 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16401 if (!NamingClass)
16402 return ExprError();
16403
16404 R.setNamingClass(NamingClass);
16405 }
16406
16407 TemplateArgumentListInfo TransArgs;
16408 if (Old->hasExplicitTemplateArgs()) {
16409 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16410 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16411 if (getDerived().TransformTemplateArguments(
16412 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16413 return ExprError();
16414 }
16415
16416 // FIXME: to do this check properly, we will need to preserve the
16417 // first-qualifier-in-scope here, just in case we had a dependent
16418 // base (and therefore couldn't do the check) and a
16419 // nested-name-qualifier (and therefore could do the lookup).
16420 NamedDecl *FirstQualifierInScope = nullptr;
16421
16422 return getDerived().RebuildUnresolvedMemberExpr(
16423 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16424 TemplateKWLoc, FirstQualifierInScope, R,
16425 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16426}
16427
16428template<typename Derived>
16433 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16434 if (SubExpr.isInvalid())
16435 return ExprError();
16436
16437 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16438 return E;
16439
16440 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16441}
16442
16443template<typename Derived>
16446 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16447 if (Pattern.isInvalid())
16448 return ExprError();
16449
16450 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16451 return E;
16452
16453 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16454 E->getNumExpansions());
16455}
16456
16457template <typename Derived>
16459 ArrayRef<TemplateArgument> PackArgs) {
16461 for (const TemplateArgument &Arg : PackArgs) {
16462 if (!Arg.isPackExpansion()) {
16463 Result = *Result + 1;
16464 continue;
16465 }
16466
16467 TemplateArgumentLoc ArgLoc;
16468 InventTemplateArgumentLoc(Arg, ArgLoc);
16469
16470 // Find the pattern of the pack expansion.
16471 SourceLocation Ellipsis;
16472 UnsignedOrNone OrigNumExpansions = std::nullopt;
16473 TemplateArgumentLoc Pattern =
16474 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16475 OrigNumExpansions);
16476
16477 // Substitute under the pack expansion. Do not expand the pack (yet).
16478 TemplateArgumentLoc OutPattern;
16479 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16480 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16481 /*Uneval*/ true))
16482 return 1u;
16483
16484 // See if we can determine the number of arguments from the result.
16485 UnsignedOrNone NumExpansions =
16486 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16487 if (!NumExpansions) {
16488 // No: we must be in an alias template expansion, and we're going to
16489 // need to actually expand the packs.
16490 Result = std::nullopt;
16491 break;
16492 }
16493
16494 Result = *Result + *NumExpansions;
16495 }
16496 return Result;
16497}
16498
16499template<typename Derived>
16502 // If E is not value-dependent, then nothing will change when we transform it.
16503 // Note: This is an instantiation-centric view.
16504 if (!E->isValueDependent())
16505 return E;
16506
16509
16511 TemplateArgument ArgStorage;
16512
16513 // Find the argument list to transform.
16514 if (E->isPartiallySubstituted()) {
16515 PackArgs = E->getPartialArguments();
16516 } else if (E->isValueDependent()) {
16517 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16518 bool ShouldExpand = false;
16519 bool RetainExpansion = false;
16520 UnsignedOrNone NumExpansions = std::nullopt;
16521 if (getDerived().TryExpandParameterPacks(
16522 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16523 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16524 RetainExpansion, NumExpansions))
16525 return ExprError();
16526
16527 // If we need to expand the pack, build a template argument from it and
16528 // expand that.
16529 if (ShouldExpand) {
16530 auto *Pack = E->getPack();
16531 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16532 ArgStorage = getSema().Context.getPackExpansionType(
16533 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16534 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16535 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16536 } else {
16537 auto *VD = cast<ValueDecl>(Pack);
16538 ExprResult DRE = getSema().BuildDeclRefExpr(
16539 VD, VD->getType().getNonLValueExprType(getSema().Context),
16540 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16541 E->getPackLoc());
16542 if (DRE.isInvalid())
16543 return ExprError();
16544 ArgStorage = TemplateArgument(
16545 new (getSema().Context)
16546 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16547 /*IsCanonical=*/false);
16548 }
16549 PackArgs = ArgStorage;
16550 }
16551 }
16552
16553 // If we're not expanding the pack, just transform the decl.
16554 if (!PackArgs.size()) {
16555 auto *Pack = cast_or_null<NamedDecl>(
16556 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16557 if (!Pack)
16558 return ExprError();
16559 return getDerived().RebuildSizeOfPackExpr(
16560 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16561 std::nullopt, {});
16562 }
16563
16564 // Try to compute the result without performing a partial substitution.
16566 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16567
16568 // Common case: we could determine the number of expansions without
16569 // substituting.
16570 if (Result)
16571 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16572 E->getPackLoc(),
16573 E->getRParenLoc(), *Result, {});
16574
16575 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16576 E->getPackLoc());
16577 {
16578 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16580 Derived, const TemplateArgument*> PackLocIterator;
16581 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16582 PackLocIterator(*this, PackArgs.end()),
16583 TransformedPackArgs, /*Uneval*/true))
16584 return ExprError();
16585 }
16586
16587 // Check whether we managed to fully-expand the pack.
16588 // FIXME: Is it possible for us to do so and not hit the early exit path?
16590 bool PartialSubstitution = false;
16591 for (auto &Loc : TransformedPackArgs.arguments()) {
16592 Args.push_back(Loc.getArgument());
16593 if (Loc.getArgument().isPackExpansion())
16594 PartialSubstitution = true;
16595 }
16596
16597 if (PartialSubstitution)
16598 return getDerived().RebuildSizeOfPackExpr(
16599 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16600 std::nullopt, Args);
16601
16602 return getDerived().RebuildSizeOfPackExpr(
16603 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16604 /*Length=*/static_cast<unsigned>(Args.size()),
16605 /*PartialArgs=*/{});
16606}
16607
16608template <typename Derived>
16611 if (!E->isValueDependent())
16612 return E;
16613
16614 // Transform the index
16615 ExprResult IndexExpr;
16616 {
16617 EnterExpressionEvaluationContext ConstantContext(
16619 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16620 if (IndexExpr.isInvalid())
16621 return ExprError();
16622 }
16623
16624 SmallVector<Expr *, 5> ExpandedExprs;
16625 bool FullySubstituted = true;
16626 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16627 Expr *Pattern = E->getPackIdExpression();
16629 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16630 Unexpanded);
16631 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16632
16633 // Determine whether the set of unexpanded parameter packs can and should
16634 // be expanded.
16635 bool ShouldExpand = true;
16636 bool RetainExpansion = false;
16637 UnsignedOrNone OrigNumExpansions = std::nullopt,
16638 NumExpansions = std::nullopt;
16639 if (getDerived().TryExpandParameterPacks(
16640 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16641 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16642 RetainExpansion, NumExpansions))
16643 return true;
16644 if (!ShouldExpand) {
16645 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16646 ExprResult Pack = getDerived().TransformExpr(Pattern);
16647 if (Pack.isInvalid())
16648 return ExprError();
16649 return getDerived().RebuildPackIndexingExpr(
16650 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16651 {}, /*FullySubstituted=*/false);
16652 }
16653 for (unsigned I = 0; I != *NumExpansions; ++I) {
16654 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16655 ExprResult Out = getDerived().TransformExpr(Pattern);
16656 if (Out.isInvalid())
16657 return true;
16658 if (Out.get()->containsUnexpandedParameterPack()) {
16659 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16660 OrigNumExpansions);
16661 if (Out.isInvalid())
16662 return true;
16663 FullySubstituted = false;
16664 }
16665 ExpandedExprs.push_back(Out.get());
16666 }
16667 // If we're supposed to retain a pack expansion, do so by temporarily
16668 // forgetting the partially-substituted parameter pack.
16669 if (RetainExpansion) {
16670 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16671
16672 ExprResult Out = getDerived().TransformExpr(Pattern);
16673 if (Out.isInvalid())
16674 return true;
16675
16676 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16677 OrigNumExpansions);
16678 if (Out.isInvalid())
16679 return true;
16680 FullySubstituted = false;
16681 ExpandedExprs.push_back(Out.get());
16682 }
16683 } else if (!E->expandsToEmptyPack()) {
16684 if (getDerived().TransformExprs(E->getExpressions().data(),
16685 E->getExpressions().size(), false,
16686 ExpandedExprs))
16687 return ExprError();
16688 }
16689
16690 return getDerived().RebuildPackIndexingExpr(
16691 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16692 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16693}
16694
16695template <typename Derived>
16698 if (!getSema().ArgPackSubstIndex)
16699 // We aren't expanding the parameter pack, so just return ourselves.
16700 return E;
16701
16702 TemplateArgument Pack = E->getArgumentPack();
16704 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16705 E->getAssociatedDecl(), E->getParameterPack(),
16706 E->getParameterPackLocation(), Arg, SemaRef.getPackIndex(Pack),
16707 E->getFinal());
16708}
16709
16710template <typename Derived>
16713 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16714 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16715 if (Replacement.isInvalid())
16716 return true;
16717
16718 Decl *AssociatedDecl =
16719 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16720 if (!AssociatedDecl)
16721 return true;
16722
16723 if (Replacement.get() == OrigReplacement &&
16724 AssociatedDecl == E->getAssociatedDecl())
16725 return E;
16726
16727 auto getParamAndType = [E](Decl *AssociatedDecl)
16728 -> std::tuple<NonTypeTemplateParmDecl *, QualType> {
16729 auto [PDecl, Arg] =
16730 getReplacedTemplateParameter(AssociatedDecl, E->getIndex());
16731 auto *Param = cast<NonTypeTemplateParmDecl>(PDecl);
16732 if (Arg.isNull())
16733 return {Param, Param->getType()};
16734 if (UnsignedOrNone PackIndex = E->getPackIndex())
16735 Arg = Arg.getPackAsArray()[*PackIndex];
16736 return {Param, Arg.getNonTypeTemplateArgumentType()};
16737 };
16738
16739 // If the replacement expression did not change, and the parameter type
16740 // did not change, we can skip the semantic action because it would
16741 // produce the same result anyway.
16742 if (auto [Param, ParamType] = getParamAndType(AssociatedDecl);
16743 !SemaRef.Context.hasSameType(
16744 ParamType, std::get<1>(getParamAndType(E->getAssociatedDecl()))) ||
16745 Replacement.get() != OrigReplacement) {
16746 // When transforming the replacement expression previously, all Sema
16747 // specific annotations, such as implicit casts, are discarded. Calling the
16748 // corresponding sema action is necessary to recover those. Otherwise,
16749 // equivalency of the result would be lost.
16750 TemplateArgument SugaredConverted, CanonicalConverted;
16751 Replacement = SemaRef.CheckTemplateArgument(
16752 Param, ParamType, Replacement.get(), SugaredConverted,
16753 CanonicalConverted,
16754 /*StrictCheck=*/false, Sema::CTAK_Specified);
16755 if (Replacement.isInvalid())
16756 return true;
16757 } else {
16758 // Otherwise, the same expression would have been produced.
16759 Replacement = E->getReplacement();
16760 }
16761
16762 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16763 AssociatedDecl, E->getParameter(), E->getNameLoc(),
16764 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
16765 E->getPackIndex(), E->getFinal());
16766}
16767
16768template<typename Derived>
16771 // Default behavior is to do nothing with this transformation.
16772 return E;
16773}
16774
16775template<typename Derived>
16779 return getDerived().TransformExpr(E->getSubExpr());
16780}
16781
16782template<typename Derived>
16785 UnresolvedLookupExpr *Callee = nullptr;
16786 if (Expr *OldCallee = E->getCallee()) {
16787 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16788 if (CalleeResult.isInvalid())
16789 return ExprError();
16790 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16791 }
16792
16793 Expr *Pattern = E->getPattern();
16794
16796 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16797 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16798
16799 // Determine whether the set of unexpanded parameter packs can and should
16800 // be expanded.
16801 bool Expand = true;
16802 bool RetainExpansion = false;
16803 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16804 NumExpansions = OrigNumExpansions;
16805 if (getDerived().TryExpandParameterPacks(
16806 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16807 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16808 NumExpansions))
16809 return true;
16810
16811 if (!Expand) {
16812 // Do not expand any packs here, just transform and rebuild a fold
16813 // expression.
16814 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16815
16816 ExprResult LHS =
16817 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16818 if (LHS.isInvalid())
16819 return true;
16820
16821 ExprResult RHS =
16822 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16823 if (RHS.isInvalid())
16824 return true;
16825
16826 if (!getDerived().AlwaysRebuild() &&
16827 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16828 return E;
16829
16830 return getDerived().RebuildCXXFoldExpr(
16831 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16832 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16833 }
16834
16835 // Formally a fold expression expands to nested parenthesized expressions.
16836 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16837 // them.
16838 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16839 SemaRef.Diag(E->getEllipsisLoc(),
16840 clang::diag::err_fold_expression_limit_exceeded)
16841 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16842 << E->getSourceRange();
16843 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16844 return ExprError();
16845 }
16846
16847 // The transform has determined that we should perform an elementwise
16848 // expansion of the pattern. Do so.
16849 ExprResult Result = getDerived().TransformExpr(E->getInit());
16850 if (Result.isInvalid())
16851 return true;
16852 bool LeftFold = E->isLeftFold();
16853
16854 // If we're retaining an expansion for a right fold, it is the innermost
16855 // component and takes the init (if any).
16856 if (!LeftFold && RetainExpansion) {
16857 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16858
16859 ExprResult Out = getDerived().TransformExpr(Pattern);
16860 if (Out.isInvalid())
16861 return true;
16862
16863 Result = getDerived().RebuildCXXFoldExpr(
16864 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16865 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16866 if (Result.isInvalid())
16867 return true;
16868 }
16869
16870 bool WarnedOnComparison = false;
16871 for (unsigned I = 0; I != *NumExpansions; ++I) {
16872 Sema::ArgPackSubstIndexRAII SubstIndex(
16873 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16874 ExprResult Out = getDerived().TransformExpr(Pattern);
16875 if (Out.isInvalid())
16876 return true;
16877
16878 if (Out.get()->containsUnexpandedParameterPack()) {
16879 // We still have a pack; retain a pack expansion for this slice.
16880 Result = getDerived().RebuildCXXFoldExpr(
16881 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16882 E->getOperator(), E->getEllipsisLoc(),
16883 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16884 OrigNumExpansions);
16885 } else if (Result.isUsable()) {
16886 // We've got down to a single element; build a binary operator.
16887 Expr *LHS = LeftFold ? Result.get() : Out.get();
16888 Expr *RHS = LeftFold ? Out.get() : Result.get();
16889 if (Callee) {
16890 UnresolvedSet<16> Functions;
16891 Functions.append(Callee->decls_begin(), Callee->decls_end());
16892 Result = getDerived().RebuildCXXOperatorCallExpr(
16893 BinaryOperator::getOverloadedOperator(E->getOperator()),
16894 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16895 Functions, LHS, RHS);
16896 } else {
16897 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16898 E->getOperator(), LHS, RHS,
16899 /*ForFoldExpresion=*/true);
16900 if (!WarnedOnComparison && Result.isUsable()) {
16901 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16902 BO && BO->isComparisonOp()) {
16903 WarnedOnComparison = true;
16904 SemaRef.Diag(BO->getBeginLoc(),
16905 diag::warn_comparison_in_fold_expression)
16906 << BO->getOpcodeStr();
16907 }
16908 }
16909 }
16910 } else
16911 Result = Out;
16912
16913 if (Result.isInvalid())
16914 return true;
16915 }
16916
16917 // If we're retaining an expansion for a left fold, it is the outermost
16918 // component and takes the complete expansion so far as its init (if any).
16919 if (LeftFold && RetainExpansion) {
16920 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16921
16922 ExprResult Out = getDerived().TransformExpr(Pattern);
16923 if (Out.isInvalid())
16924 return true;
16925
16926 Result = getDerived().RebuildCXXFoldExpr(
16927 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16928 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16929 if (Result.isInvalid())
16930 return true;
16931 }
16932
16933 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16934 PE->setIsProducedByFoldExpansion();
16935
16936 // If we had no init and an empty pack, and we're not retaining an expansion,
16937 // then produce a fallback value or error.
16938 if (Result.isUnset())
16939 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16940 E->getOperator());
16941 return Result;
16942}
16943
16944template <typename Derived>
16947 SmallVector<Expr *, 4> TransformedInits;
16948 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16949
16950 QualType T = getDerived().TransformType(E->getType());
16951
16952 bool ArgChanged = false;
16953
16954 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16955 TransformedInits, &ArgChanged))
16956 return ExprError();
16957
16958 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16959 return E;
16960
16961 return getDerived().RebuildCXXParenListInitExpr(
16962 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16963 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16964}
16965
16966template<typename Derived>
16970 return getDerived().TransformExpr(E->getSubExpr());
16971}
16972
16973template<typename Derived>
16976 return SemaRef.MaybeBindToTemporary(E);
16977}
16978
16979template<typename Derived>
16982 return E;
16983}
16984
16985template<typename Derived>
16988 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16989 if (SubExpr.isInvalid())
16990 return ExprError();
16991
16992 if (!getDerived().AlwaysRebuild() &&
16993 SubExpr.get() == E->getSubExpr())
16994 return E;
16995
16996 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16997}
16998
16999template<typename Derived>
17002 // Transform each of the elements.
17003 SmallVector<Expr *, 8> Elements;
17004 bool ArgChanged = false;
17005 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
17006 /*IsCall=*/false, Elements, &ArgChanged))
17007 return ExprError();
17008
17009 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17010 return SemaRef.MaybeBindToTemporary(E);
17011
17012 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
17013 Elements.data(),
17014 Elements.size());
17015}
17016
17017template<typename Derived>
17021 // Transform each of the elements.
17023 bool ArgChanged = false;
17024 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
17025 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
17026
17027 if (OrigElement.isPackExpansion()) {
17028 // This key/value element is a pack expansion.
17030 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
17031 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
17032 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
17033
17034 // Determine whether the set of unexpanded parameter packs can
17035 // and should be expanded.
17036 bool Expand = true;
17037 bool RetainExpansion = false;
17038 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
17039 UnsignedOrNone NumExpansions = OrigNumExpansions;
17040 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
17041 OrigElement.Value->getEndLoc());
17042 if (getDerived().TryExpandParameterPacks(
17043 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
17044 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
17045 NumExpansions))
17046 return ExprError();
17047
17048 if (!Expand) {
17049 // The transform has determined that we should perform a simple
17050 // transformation on the pack expansion, producing another pack
17051 // expansion.
17052 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
17053 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17054 if (Key.isInvalid())
17055 return ExprError();
17056
17057 if (Key.get() != OrigElement.Key)
17058 ArgChanged = true;
17059
17060 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17061 if (Value.isInvalid())
17062 return ExprError();
17063
17064 if (Value.get() != OrigElement.Value)
17065 ArgChanged = true;
17066
17067 ObjCDictionaryElement Expansion = {
17068 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
17069 };
17070 Elements.push_back(Expansion);
17071 continue;
17072 }
17073
17074 // Record right away that the argument was changed. This needs
17075 // to happen even if the array expands to nothing.
17076 ArgChanged = true;
17077
17078 // The transform has determined that we should perform an elementwise
17079 // expansion of the pattern. Do so.
17080 for (unsigned I = 0; I != *NumExpansions; ++I) {
17081 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
17082 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17083 if (Key.isInvalid())
17084 return ExprError();
17085
17086 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17087 if (Value.isInvalid())
17088 return ExprError();
17089
17090 ObjCDictionaryElement Element = {
17091 Key.get(), Value.get(), SourceLocation(), NumExpansions
17092 };
17093
17094 // If any unexpanded parameter packs remain, we still have a
17095 // pack expansion.
17096 // FIXME: Can this really happen?
17097 if (Key.get()->containsUnexpandedParameterPack() ||
17098 Value.get()->containsUnexpandedParameterPack())
17099 Element.EllipsisLoc = OrigElement.EllipsisLoc;
17100
17101 Elements.push_back(Element);
17102 }
17103
17104 // FIXME: Retain a pack expansion if RetainExpansion is true.
17105
17106 // We've finished with this pack expansion.
17107 continue;
17108 }
17109
17110 // Transform and check key.
17111 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17112 if (Key.isInvalid())
17113 return ExprError();
17114
17115 if (Key.get() != OrigElement.Key)
17116 ArgChanged = true;
17117
17118 // Transform and check value.
17120 = getDerived().TransformExpr(OrigElement.Value);
17121 if (Value.isInvalid())
17122 return ExprError();
17123
17124 if (Value.get() != OrigElement.Value)
17125 ArgChanged = true;
17126
17127 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
17128 std::nullopt};
17129 Elements.push_back(Element);
17130 }
17131
17132 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17133 return SemaRef.MaybeBindToTemporary(E);
17134
17135 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
17136 Elements);
17137}
17138
17139template<typename Derived>
17142 TypeSourceInfo *EncodedTypeInfo
17143 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
17144 if (!EncodedTypeInfo)
17145 return ExprError();
17146
17147 if (!getDerived().AlwaysRebuild() &&
17148 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
17149 return E;
17150
17151 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
17152 EncodedTypeInfo,
17153 E->getRParenLoc());
17154}
17155
17156template<typename Derived>
17159 // This is a kind of implicit conversion, and it needs to get dropped
17160 // and recomputed for the same general reasons that ImplicitCastExprs
17161 // do, as well a more specific one: this expression is only valid when
17162 // it appears *immediately* as an argument expression.
17163 return getDerived().TransformExpr(E->getSubExpr());
17164}
17165
17166template<typename Derived>
17169 TypeSourceInfo *TSInfo
17170 = getDerived().TransformType(E->getTypeInfoAsWritten());
17171 if (!TSInfo)
17172 return ExprError();
17173
17174 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
17175 if (Result.isInvalid())
17176 return ExprError();
17177
17178 if (!getDerived().AlwaysRebuild() &&
17179 TSInfo == E->getTypeInfoAsWritten() &&
17180 Result.get() == E->getSubExpr())
17181 return E;
17182
17183 return SemaRef.ObjC().BuildObjCBridgedCast(
17184 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
17185 Result.get());
17186}
17187
17188template <typename Derived>
17191 return E;
17192}
17193
17194template<typename Derived>
17197 // Transform arguments.
17198 bool ArgChanged = false;
17200 Args.reserve(E->getNumArgs());
17201 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
17202 &ArgChanged))
17203 return ExprError();
17204
17205 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
17206 // Class message: transform the receiver type.
17207 TypeSourceInfo *ReceiverTypeInfo
17208 = getDerived().TransformType(E->getClassReceiverTypeInfo());
17209 if (!ReceiverTypeInfo)
17210 return ExprError();
17211
17212 // If nothing changed, just retain the existing message send.
17213 if (!getDerived().AlwaysRebuild() &&
17214 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
17215 return SemaRef.MaybeBindToTemporary(E);
17216
17217 // Build a new class message send.
17219 E->getSelectorLocs(SelLocs);
17220 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
17221 E->getSelector(),
17222 SelLocs,
17223 E->getMethodDecl(),
17224 E->getLeftLoc(),
17225 Args,
17226 E->getRightLoc());
17227 }
17228 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17229 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17230 if (!E->getMethodDecl())
17231 return ExprError();
17232
17233 // Build a new class message send to 'super'.
17235 E->getSelectorLocs(SelLocs);
17236 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17237 E->getSelector(),
17238 SelLocs,
17239 E->getReceiverType(),
17240 E->getMethodDecl(),
17241 E->getLeftLoc(),
17242 Args,
17243 E->getRightLoc());
17244 }
17245
17246 // Instance message: transform the receiver
17247 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17248 "Only class and instance messages may be instantiated");
17249 ExprResult Receiver
17250 = getDerived().TransformExpr(E->getInstanceReceiver());
17251 if (Receiver.isInvalid())
17252 return ExprError();
17253
17254 // If nothing changed, just retain the existing message send.
17255 if (!getDerived().AlwaysRebuild() &&
17256 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17257 return SemaRef.MaybeBindToTemporary(E);
17258
17259 // Build a new instance message send.
17261 E->getSelectorLocs(SelLocs);
17262 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17263 E->getSelector(),
17264 SelLocs,
17265 E->getMethodDecl(),
17266 E->getLeftLoc(),
17267 Args,
17268 E->getRightLoc());
17269}
17270
17271template<typename Derived>
17274 return E;
17275}
17276
17277template<typename Derived>
17280 return E;
17281}
17282
17283template<typename Derived>
17286 // Transform the base expression.
17287 ExprResult Base = getDerived().TransformExpr(E->getBase());
17288 if (Base.isInvalid())
17289 return ExprError();
17290
17291 // We don't need to transform the ivar; it will never change.
17292
17293 // If nothing changed, just retain the existing expression.
17294 if (!getDerived().AlwaysRebuild() &&
17295 Base.get() == E->getBase())
17296 return E;
17297
17298 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17299 E->getLocation(),
17300 E->isArrow(), E->isFreeIvar());
17301}
17302
17303template<typename Derived>
17306 // 'super' and types never change. Property never changes. Just
17307 // retain the existing expression.
17308 if (!E->isObjectReceiver())
17309 return E;
17310
17311 // Transform the base expression.
17312 ExprResult Base = getDerived().TransformExpr(E->getBase());
17313 if (Base.isInvalid())
17314 return ExprError();
17315
17316 // We don't need to transform the property; it will never change.
17317
17318 // If nothing changed, just retain the existing expression.
17319 if (!getDerived().AlwaysRebuild() &&
17320 Base.get() == E->getBase())
17321 return E;
17322
17323 if (E->isExplicitProperty())
17324 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17325 E->getExplicitProperty(),
17326 E->getLocation());
17327
17328 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17329 SemaRef.Context.PseudoObjectTy,
17330 E->getImplicitPropertyGetter(),
17331 E->getImplicitPropertySetter(),
17332 E->getLocation());
17333}
17334
17335template<typename Derived>
17338 // Transform the base expression.
17339 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17340 if (Base.isInvalid())
17341 return ExprError();
17342
17343 // Transform the key expression.
17344 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17345 if (Key.isInvalid())
17346 return ExprError();
17347
17348 // If nothing changed, just retain the existing expression.
17349 if (!getDerived().AlwaysRebuild() &&
17350 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17351 return E;
17352
17353 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17354 Base.get(), Key.get(),
17355 E->getAtIndexMethodDecl(),
17356 E->setAtIndexMethodDecl());
17357}
17358
17359template<typename Derived>
17362 // Transform the base expression.
17363 ExprResult Base = getDerived().TransformExpr(E->getBase());
17364 if (Base.isInvalid())
17365 return ExprError();
17366
17367 // If nothing changed, just retain the existing expression.
17368 if (!getDerived().AlwaysRebuild() &&
17369 Base.get() == E->getBase())
17370 return E;
17371
17372 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17373 E->getOpLoc(),
17374 E->isArrow());
17375}
17376
17377template<typename Derived>
17380 bool ArgumentChanged = false;
17381 SmallVector<Expr*, 8> SubExprs;
17382 SubExprs.reserve(E->getNumSubExprs());
17383 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17384 SubExprs, &ArgumentChanged))
17385 return ExprError();
17386
17387 if (!getDerived().AlwaysRebuild() &&
17388 !ArgumentChanged)
17389 return E;
17390
17391 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17392 SubExprs,
17393 E->getRParenLoc());
17394}
17395
17396template<typename Derived>
17399 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17400 if (SrcExpr.isInvalid())
17401 return ExprError();
17402
17403 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17404 if (!Type)
17405 return ExprError();
17406
17407 if (!getDerived().AlwaysRebuild() &&
17408 Type == E->getTypeSourceInfo() &&
17409 SrcExpr.get() == E->getSrcExpr())
17410 return E;
17411
17412 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17413 SrcExpr.get(), Type,
17414 E->getRParenLoc());
17415}
17416
17417template<typename Derived>
17420 BlockDecl *oldBlock = E->getBlockDecl();
17421
17422 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17423 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17424
17425 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17426 blockScope->TheDecl->setBlockMissingReturnType(
17427 oldBlock->blockMissingReturnType());
17428
17430 SmallVector<QualType, 4> paramTypes;
17431
17432 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17433
17434 // Parameter substitution.
17435 Sema::ExtParameterInfoBuilder extParamInfos;
17436 if (getDerived().TransformFunctionTypeParams(
17437 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17438 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17439 extParamInfos)) {
17440 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17441 return ExprError();
17442 }
17443
17444 QualType exprResultType =
17445 getDerived().TransformType(exprFunctionType->getReturnType());
17446
17447 auto epi = exprFunctionType->getExtProtoInfo();
17448 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17449
17451 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17452 blockScope->FunctionType = functionType;
17453
17454 // Set the parameters on the block decl.
17455 if (!params.empty())
17456 blockScope->TheDecl->setParams(params);
17457
17458 if (!oldBlock->blockMissingReturnType()) {
17459 blockScope->HasImplicitReturnType = false;
17460 blockScope->ReturnType = exprResultType;
17461 }
17462
17463 // Transform the body
17464 StmtResult body = getDerived().TransformStmt(E->getBody());
17465 if (body.isInvalid()) {
17466 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17467 return ExprError();
17468 }
17469
17470#ifndef NDEBUG
17471 // In builds with assertions, make sure that we captured everything we
17472 // captured before.
17473 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17474 for (const auto &I : oldBlock->captures()) {
17475 VarDecl *oldCapture = I.getVariable();
17476
17477 // Ignore parameter packs.
17478 if (oldCapture->isParameterPack())
17479 continue;
17480
17481 VarDecl *newCapture =
17482 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17483 oldCapture));
17484 assert(blockScope->CaptureMap.count(newCapture));
17485 }
17486
17487 // The this pointer may not be captured by the instantiated block, even when
17488 // it's captured by the original block, if the expression causing the
17489 // capture is in the discarded branch of a constexpr if statement.
17490 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17491 "this pointer isn't captured in the old block");
17492 }
17493#endif
17494
17495 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17496 /*Scope=*/nullptr);
17497}
17498
17499template<typename Derived>
17502 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17503 if (SrcExpr.isInvalid())
17504 return ExprError();
17505
17506 QualType Type = getDerived().TransformType(E->getType());
17507
17508 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17509 E->getRParenLoc());
17510}
17511
17512template<typename Derived>
17515 bool ArgumentChanged = false;
17516 SmallVector<Expr*, 8> SubExprs;
17517 SubExprs.reserve(E->getNumSubExprs());
17518 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17519 SubExprs, &ArgumentChanged))
17520 return ExprError();
17521
17522 if (!getDerived().AlwaysRebuild() &&
17523 !ArgumentChanged)
17524 return E;
17525
17526 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17527 E->getOp(), E->getRParenLoc());
17528}
17529
17530//===----------------------------------------------------------------------===//
17531// Type reconstruction
17532//===----------------------------------------------------------------------===//
17533
17534template<typename Derived>
17537 return SemaRef.BuildPointerType(PointeeType, Star,
17539}
17540
17541template<typename Derived>
17544 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17546}
17547
17548template<typename Derived>
17551 bool WrittenAsLValue,
17552 SourceLocation Sigil) {
17553 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17554 Sigil, getDerived().getBaseEntity());
17555}
17556
17557template <typename Derived>
17559 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17560 SourceLocation Sigil) {
17561 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17563}
17564
17565template<typename Derived>
17567 const ObjCTypeParamDecl *Decl,
17568 SourceLocation ProtocolLAngleLoc,
17570 ArrayRef<SourceLocation> ProtocolLocs,
17571 SourceLocation ProtocolRAngleLoc) {
17572 return SemaRef.ObjC().BuildObjCTypeParamType(
17573 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17574 /*FailOnError=*/true);
17575}
17576
17577template<typename Derived>
17579 QualType BaseType,
17580 SourceLocation Loc,
17581 SourceLocation TypeArgsLAngleLoc,
17583 SourceLocation TypeArgsRAngleLoc,
17584 SourceLocation ProtocolLAngleLoc,
17586 ArrayRef<SourceLocation> ProtocolLocs,
17587 SourceLocation ProtocolRAngleLoc) {
17588 return SemaRef.ObjC().BuildObjCObjectType(
17589 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17590 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17591 /*FailOnError=*/true,
17592 /*Rebuilding=*/true);
17593}
17594
17595template<typename Derived>
17597 QualType PointeeType,
17599 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17600}
17601
17602template <typename Derived>
17604 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17605 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17606 if (SizeExpr || !Size)
17607 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17608 IndexTypeQuals, BracketsRange,
17610
17611 QualType Types[] = {
17612 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17613 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17614 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17615 };
17616 QualType SizeType;
17617 for (const auto &T : Types)
17618 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17619 SizeType = T;
17620 break;
17621 }
17622
17623 // Note that we can return a VariableArrayType here in the case where
17624 // the element type was a dependent VariableArrayType.
17625 IntegerLiteral *ArraySize
17626 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17627 /*FIXME*/BracketsRange.getBegin());
17628 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17629 IndexTypeQuals, BracketsRange,
17631}
17632
17633template <typename Derived>
17635 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17636 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17637 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17638 IndexTypeQuals, BracketsRange);
17639}
17640
17641template <typename Derived>
17643 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17644 SourceRange BracketsRange) {
17645 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17646 IndexTypeQuals, BracketsRange);
17647}
17648
17649template <typename Derived>
17651 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17652 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17653 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17654 SizeExpr,
17655 IndexTypeQuals, BracketsRange);
17656}
17657
17658template <typename Derived>
17660 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17661 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17662 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17663 SizeExpr,
17664 IndexTypeQuals, BracketsRange);
17665}
17666
17667template <typename Derived>
17669 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17670 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17671 AttributeLoc);
17672}
17673
17674template <typename Derived>
17676 unsigned NumElements,
17677 VectorKind VecKind) {
17678 // FIXME: semantic checking!
17679 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17680}
17681
17682template <typename Derived>
17684 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17685 VectorKind VecKind) {
17686 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17687}
17688
17689template<typename Derived>
17691 unsigned NumElements,
17692 SourceLocation AttributeLoc) {
17693 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17694 NumElements, true);
17695 IntegerLiteral *VectorSize
17696 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17697 AttributeLoc);
17698 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17699}
17700
17701template<typename Derived>
17704 Expr *SizeExpr,
17705 SourceLocation AttributeLoc) {
17706 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17707}
17708
17709template <typename Derived>
17711 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17712 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17713 NumColumns);
17714}
17715
17716template <typename Derived>
17718 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17719 SourceLocation AttributeLoc) {
17720 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17721 AttributeLoc);
17722}
17723
17724template <typename Derived>
17726 QualType T, MutableArrayRef<QualType> ParamTypes,
17728 return SemaRef.BuildFunctionType(T, ParamTypes,
17731 EPI);
17732}
17733
17734template<typename Derived>
17736 return SemaRef.Context.getFunctionNoProtoType(T);
17737}
17738
17739template <typename Derived>
17742 SourceLocation NameLoc, Decl *D) {
17743 assert(D && "no decl found");
17744 if (D->isInvalidDecl()) return QualType();
17745
17746 // FIXME: Doesn't account for ObjCInterfaceDecl!
17747 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17748 // A valid resolved using typename pack expansion decl can have multiple
17749 // UsingDecls, but they must each have exactly one type, and it must be
17750 // the same type in every case. But we must have at least one expansion!
17751 if (UPD->expansions().empty()) {
17752 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17753 << UPD->isCXXClassMember() << UPD;
17754 return QualType();
17755 }
17756
17757 // We might still have some unresolved types. Try to pick a resolved type
17758 // if we can. The final instantiation will check that the remaining
17759 // unresolved types instantiate to the type we pick.
17760 QualType FallbackT;
17761 QualType T;
17762 for (auto *E : UPD->expansions()) {
17763 QualType ThisT =
17764 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17765 if (ThisT.isNull())
17766 continue;
17767 if (ThisT->getAs<UnresolvedUsingType>())
17768 FallbackT = ThisT;
17769 else if (T.isNull())
17770 T = ThisT;
17771 else
17772 assert(getSema().Context.hasSameType(ThisT, T) &&
17773 "mismatched resolved types in using pack expansion");
17774 }
17775 return T.isNull() ? FallbackT : T;
17776 }
17777 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17778 assert(Using->hasTypename() &&
17779 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17780
17781 // A valid resolved using typename decl points to exactly one type decl.
17782 assert(++Using->shadow_begin() == Using->shadow_end());
17783
17784 UsingShadowDecl *Shadow = *Using->shadow_begin();
17785 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17786 return QualType();
17787 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17788 }
17790 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17791 return SemaRef.Context.getUnresolvedUsingType(
17793}
17794
17795template <typename Derived>
17797 TypeOfKind Kind) {
17798 return SemaRef.BuildTypeofExprType(E, Kind);
17799}
17800
17801template<typename Derived>
17803 TypeOfKind Kind) {
17804 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17805}
17806
17807template <typename Derived>
17809 return SemaRef.BuildDecltypeType(E);
17810}
17811
17812template <typename Derived>
17814 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17815 SourceLocation EllipsisLoc, bool FullySubstituted,
17816 ArrayRef<QualType> Expansions) {
17817 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17818 FullySubstituted, Expansions);
17819}
17820
17821template<typename Derived>
17823 UnaryTransformType::UTTKind UKind,
17824 SourceLocation Loc) {
17825 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17826}
17827
17828template <typename Derived>
17831 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17832 return SemaRef.CheckTemplateIdType(
17833 Keyword, Template, TemplateNameLoc, TemplateArgs,
17834 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17835}
17836
17837template<typename Derived>
17839 SourceLocation KWLoc) {
17840 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17841}
17842
17843template<typename Derived>
17845 SourceLocation KWLoc,
17846 bool isReadPipe) {
17847 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17848 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17849}
17850
17851template <typename Derived>
17853 unsigned NumBits,
17854 SourceLocation Loc) {
17855 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17856 NumBits, true);
17857 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17858 SemaRef.Context.IntTy, Loc);
17859 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17860}
17861
17862template <typename Derived>
17864 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17865 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17866}
17867
17868template <typename Derived>
17870 bool TemplateKW,
17871 TemplateName Name) {
17872 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17873 Name);
17874}
17875
17876template <typename Derived>
17878 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17879 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17881 TemplateName.setIdentifier(&Name, NameLoc);
17883 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17884 TemplateName, ParsedType::make(ObjectType),
17885 /*EnteringContext=*/false, Template,
17886 AllowInjectedClassName);
17887 return Template.get();
17888}
17889
17890template<typename Derived>
17893 SourceLocation TemplateKWLoc,
17894 OverloadedOperatorKind Operator,
17895 SourceLocation NameLoc,
17896 QualType ObjectType,
17897 bool AllowInjectedClassName) {
17898 UnqualifiedId Name;
17899 // FIXME: Bogus location information.
17900 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17901 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17903 getSema().ActOnTemplateName(
17904 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17905 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17906 return Template.get();
17907}
17908
17909template <typename Derived>
17912 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17913 Expr *Second) {
17914 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17915
17916 if (First->getObjectKind() == OK_ObjCProperty) {
17919 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17920 Opc, First, Second);
17921 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17922 if (Result.isInvalid())
17923 return ExprError();
17924 First = Result.get();
17925 }
17926
17927 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17928 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17929 if (Result.isInvalid())
17930 return ExprError();
17931 Second = Result.get();
17932 }
17933
17934 // Determine whether this should be a builtin operation.
17935 if (Op == OO_Subscript) {
17936 if (!First->getType()->isOverloadableType() &&
17937 !Second->getType()->isOverloadableType())
17938 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17939 OpLoc);
17940 } else if (Op == OO_Arrow) {
17941 // It is possible that the type refers to a RecoveryExpr created earlier
17942 // in the tree transformation.
17943 if (First->getType()->isDependentType())
17944 return ExprError();
17945 // -> is never a builtin operation.
17946 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17947 } else if (Second == nullptr || isPostIncDec) {
17948 if (!First->getType()->isOverloadableType() ||
17949 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17950 // The argument is not of overloadable type, or this is an expression
17951 // of the form &Class::member, so try to create a built-in unary
17952 // operation.
17954 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17955
17956 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17957 }
17958 } else {
17959 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17960 !First->getType()->isOverloadableType() &&
17961 !Second->getType()->isOverloadableType()) {
17962 // Neither of the arguments is type-dependent or has an overloadable
17963 // type, so try to create a built-in binary operation.
17966 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17967 if (Result.isInvalid())
17968 return ExprError();
17969
17970 return Result;
17971 }
17972 }
17973
17974 // Create the overloaded operator invocation for unary operators.
17975 if (!Second || isPostIncDec) {
17977 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17978 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17979 RequiresADL);
17980 }
17981
17982 // Create the overloaded operator invocation for binary operators.
17984 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17985 First, Second, RequiresADL);
17986 if (Result.isInvalid())
17987 return ExprError();
17988
17989 return Result;
17990}
17991
17992template<typename Derived>
17995 SourceLocation OperatorLoc,
17996 bool isArrow,
17997 CXXScopeSpec &SS,
17998 TypeSourceInfo *ScopeType,
17999 SourceLocation CCLoc,
18000 SourceLocation TildeLoc,
18001 PseudoDestructorTypeStorage Destroyed) {
18002 QualType CanonicalBaseType = Base->getType().getCanonicalType();
18003 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
18004 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
18005 (isArrow && isa<PointerType>(CanonicalBaseType) &&
18006 !cast<PointerType>(CanonicalBaseType)
18007 ->getPointeeType()
18008 ->getAsCanonical<RecordType>())) {
18009 // This pseudo-destructor expression is still a pseudo-destructor.
18010 return SemaRef.BuildPseudoDestructorExpr(
18011 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
18012 CCLoc, TildeLoc, Destroyed);
18013 }
18014
18015 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
18016 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
18017 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
18018 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
18019 NameInfo.setNamedTypeInfo(DestroyedType);
18020
18021 // The scope type is now known to be a valid nested name specifier
18022 // component. Tack it on to the nested name specifier.
18023 if (ScopeType) {
18024 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
18025 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
18026 diag::err_expected_class_or_namespace)
18027 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
18028 return ExprError();
18029 }
18030 SS.clear();
18031 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
18032 }
18033
18034 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
18035 return getSema().BuildMemberReferenceExpr(
18036 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
18037 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
18038 /*TemplateArgs*/ nullptr,
18039 /*S*/ nullptr);
18040}
18041
18042template<typename Derived>
18045 SourceLocation Loc = S->getBeginLoc();
18046 CapturedDecl *CD = S->getCapturedDecl();
18047 unsigned NumParams = CD->getNumParams();
18048 unsigned ContextParamPos = CD->getContextParamPosition();
18050 for (unsigned I = 0; I < NumParams; ++I) {
18051 if (I != ContextParamPos) {
18052 Params.push_back(
18053 std::make_pair(
18054 CD->getParam(I)->getName(),
18055 getDerived().TransformType(CD->getParam(I)->getType())));
18056 } else {
18057 Params.push_back(std::make_pair(StringRef(), QualType()));
18058 }
18059 }
18060 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
18061 S->getCapturedRegionKind(), Params);
18062 StmtResult Body;
18063 {
18064 Sema::CompoundScopeRAII CompoundScope(getSema());
18065 Body = getDerived().TransformStmt(S->getCapturedStmt());
18066 }
18067
18068 if (Body.isInvalid()) {
18069 getSema().ActOnCapturedRegionError();
18070 return StmtError();
18071 }
18072
18073 return getSema().ActOnCapturedRegionEnd(Body.get());
18074}
18075
18076template <typename Derived>
18079 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
18080 // function definition or instantiation of a function template specialization
18081 // and will therefore never appear in a dependent context.
18082 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
18083 "context");
18084}
18085
18086template <typename Derived>
18088 // We can transform the base expression and allow argument resolution to fill
18089 // in the rest.
18090 return getDerived().TransformExpr(E->getArgLValue());
18091}
18092
18093} // end namespace clang
18094
18095#endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
static Decl::Kind getKind(const Decl *D)
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
TokenType getType() const
Returns the token's type, e.g.
SmallVector< AnnotatedLine *, 1 > Children
If this token starts a block, this contains all the unwrapped lines in it.
Result
Implement __builtin_bit_cast and related operations.
#define X(type, name)
Definition Value.h:97
llvm::MachO::Record Record
Definition MachO.h:31
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
llvm::json::Object Object
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenACC constructs and clauses.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis for expressions involving.
This file declares semantic analysis for SYCL constructs.
static bool PreparePackForExpansion(Sema &S, const CXXBaseSpecifier &Base, const MultiLevelTemplateArgumentList &TemplateArgs, TypeSourceInfo *&Out, UnexpandedInfo &Info)
Defines the Objective-C statement AST node classes.
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
static QualType getPointeeType(const MemRegion *R)
This represents clause 'map' in the 'pragma omp ...' directives.
This represents clauses with a list of expressions that are mappable. Examples of these clauses are '...
This represents 'pragma omp metadirective' directive.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType IntTy
CanQualType PseudoObjectTy
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
QualType getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
PtrTy get() const
Definition Ownership.h:171
bool isInvalid() const
Definition Ownership.h:167
bool isUsable() const
Definition Ownership.h:169
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition Expr.h:4553
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:6021
Represents a loop initializing the elements of an array.
Definition Expr.h:5968
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1833
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7219
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2724
Wrapper for source info for arrays.
Definition TypeLoc.h:1777
void setLBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1783
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition ExprCXX.h:3000
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:3038
ArrayTypeTrait getTrait() const
Definition ExprCXX.h:3040
Expr * getDimensionExpression() const
Definition ExprCXX.h:3050
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition ExprCXX.h:3046
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:3037
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3784
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6733
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6928
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2673
Attr - This represents one attribute.
Definition Attr.h:46
Represents an attribute applied to a statement.
Definition Stmt.h:2213
Stmt * getSubStmt()
Definition Stmt.h:2249
SourceLocation getAttrLoc() const
Definition Stmt.h:2244
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2245
Type source information for an attributed type.
Definition TypeLoc.h:1008
void setAttr(const Attr *A)
Definition TypeLoc.h:1034
Type source information for an btf_tag attributed type.
Definition TypeLoc.h:1058
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition Expr.h:4456
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4041
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition Expr.cpp:2185
static bool isAssignmentOp(Opcode Opc)
Definition Expr.h:4177
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:2147
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8297
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4690
void setIsVariadic(bool value)
Definition Decl.h:4766
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6672
Wrapper for source info for block pointers.
Definition TypeLoc.h:1526
BreakStmt - This represents a break.
Definition Stmt.h:3145
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5472
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:5491
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:5490
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition Expr.h:3972
Represents a call to a CUDA kernel function.
Definition ExprCXX.h:238
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition ExprCXX.h:608
Represents binding an expression to a temporary.
Definition ExprCXX.h:1497
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition ExprCXX.h:727
CXXCatchStmt - This represents a C++ catch block.
Definition StmtCXX.h:28
A C++ const_cast expression (C++ [expr.const.cast]).
Definition ExprCXX.h:570
Represents a call to a C++ constructor.
Definition ExprCXX.h:1552
SourceRange getParenOrBraceRange() const
Definition ExprCXX.h:1733
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition ExprCXX.h:1695
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition ExprCXX.h:1645
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:586
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:580
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition ExprCXX.h:1634
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition ExprCXX.h:1692
Represents a C++ constructor within a class.
Definition DeclCXX.h:2620
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1274
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition ExprCXX.cpp:1046
A use of a default initializer in a constructor or in aggregate initialization.
Definition ExprCXX.h:1381
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2630
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition ExprCXX.h:3870
Represents a C++ destructor within a class.
Definition DeclCXX.h:2882
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:485
Represents a folding of a pack over an operator.
Definition ExprCXX.h:5032
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition StmtCXX.h:135
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition ExprCXX.h:1835
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition ExprCXX.h:1755
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:183
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2132
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition ExprCXX.h:379
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition ExprCXX.h:410
SourceRange getAngleBrackets() const LLVM_READONLY
Definition ExprCXX.h:417
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition ExprCXX.h:413
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition ExprCXX.h:2359
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition ExprCXX.h:4309
The null pointer literal (C++11 [lex.nullptr])
Definition ExprCXX.h:772
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:85
Represents a list-initialization with parenthesis.
Definition ExprCXX.h:5141
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition ExprCXX.h:2749
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
unsigned getLambdaDependencyKind() const
Definition DeclCXX.h:1861
Represents a C++26 reflect expression [expr.reflect].
Definition ExprCXX.h:5504
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition ExprCXX.h:530
A rewritten comparison expression that was originally written using operator syntax.
Definition ExprCXX.h:290
An expression "T()" which creates an rvalue of a non-class type T.
Definition ExprCXX.h:2200
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:76
void Make(ASTContext &Context, TypeLoc TL, SourceLocation ColonColonLoc)
Make a nested-name-specifier of the form 'type::'.
Definition DeclSpec.cpp:51
char * location_data() const
Retrieve the data associated with the source-location information.
Definition DeclSpec.h:209
SourceRange getRange() const
Definition DeclSpec.h:82
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition DeclSpec.cpp:75
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition DeclSpec.h:97
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition DeclSpec.cpp:123
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition DeclSpec.h:213
void Extend(ASTContext &Context, NamespaceBaseDecl *Namespace, SourceLocation NamespaceLoc, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'name...
Definition DeclSpec.cpp:62
void MakeMicrosoftSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition DeclSpec.cpp:85
bool isEmpty() const
No scope specifier.
Definition DeclSpec.h:181
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition DeclSpec.cpp:103
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition ExprCXX.h:804
Represents a C++ functional cast expression that builds a temporary object.
Definition ExprCXX.h:1903
Represents the this expression in C++.
Definition ExprCXX.h:1158
A C++ throw-expression (C++ [except.throw]).
Definition ExprCXX.h:1212
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:69
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition ExprCXX.h:852
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition ExprCXX.h:3744
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition ExprCXX.h:3788
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition ExprCXX.h:3799
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition ExprCXX.h:3782
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition ExprCXX.h:3793
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition ExprCXX.h:3802
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1072
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2946
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
Definition Expr.cpp:1522
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4962
unsigned getNumParams() const
Definition Decl.h:5000
unsigned getContextParamPosition() const
Definition Decl.h:5029
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5002
This captures a statement into a function.
Definition Stmt.h:3947
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1493
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:4051
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:4142
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition Stmt.cpp:1508
CaseStmt - Represent a case statement.
Definition Stmt.h:1930
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition Expr.cpp:1985
Expr * getSubExpr()
Definition Expr.h:3729
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4851
Represents a 'co_await' expression.
Definition ExprCXX.h:5365
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4303
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3608
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1750
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Stmt.h:1800
body_range body()
Definition Stmt.h:1813
SourceLocation getLBracLoc() const
Definition Stmt.h:1867
bool hasStoredFPFeatures() const
Definition Stmt.h:1797
Stmt * body_back()
Definition Stmt.h:1818
SourceLocation getRBracLoc() const
Definition Stmt.h:1868
Declaration of a C++20 concept.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
Represents the specialization of a concept - evaluates to a prvalue of type bool.
const TypeClass * getTypePtr() const
Definition TypeLoc.h:433
ConditionalOperator - The ?
Definition Expr.h:4394
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3822
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition Expr.h:1085
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4449
ContinueStmt - This represents a continue.
Definition Stmt.h:3129
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4722
Represents a 'co_return' statement in the C++ Coroutines TS.
Definition StmtCXX.h:473
Represents the body of a coroutine.
Definition StmtCXX.h:320
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
Definition TypeBase.h:3498
Represents a 'co_yield' expression.
Definition ExprCXX.h:5446
Wrapper for source info for pointers decayed from arrays and functions.
Definition TypeLoc.h:1474
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1462
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2122
DeclContextLookupResult lookup_result
Definition DeclBase.h:2590
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addDecl(Decl *D)
Add the declaration D into this context.
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1273
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1641
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
bool isInvalidDecl() const
Definition DeclBase.h:596
SourceLocation getLocation() const
Definition DeclBase.h:447
DeclContext * getDeclContext()
Definition DeclBase.h:456
AccessSpecifier getAccess() const
Definition DeclBase.h:515
The name of a declaration.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition Decl.h:822
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:809
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:1948
void setDecltypeLoc(SourceLocation Loc)
Definition TypeLoc.h:2288
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2513
DeferStmt - This represents a deferred statement.
Definition Stmt.h:3246
static DeferStmt * Create(ASTContext &Context, SourceLocation DeferLoc, Stmt *Body)
Definition Stmt.cpp:1552
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:1998
Represents an extended address space qualifier where the input address space value is dependent.
Definition TypeBase.h:4123
Represents a 'co_await' expression while the type of the promise is dependent.
Definition ExprCXX.h:5397
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2581
A qualified reference to a name whose declaration cannot yet be resolved.
Definition ExprCXX.h:3510
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3584
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition ExprCXX.h:3558
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3576
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition ExprCXX.h:3594
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3568
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3611
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3549
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3604
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3546
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4073
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2096
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4163
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition TypeBase.h:4535
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2068
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4289
Represents a single C99 designator.
Definition Expr.h:5594
Represents a C99 designated initializer expression.
Definition Expr.h:5551
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:208
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
Definition Designator.h:172
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
Definition Designator.h:142
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
Definition Designator.h:115
bool hasErrorOccurred() const
Definition Diagnostic.h:881
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2842
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Definition TypeBase.h:5089
Expr * getCondition() const
Definition TypeBase.h:5096
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:744
Represents a reference to emded data.
Definition Expr.h:5129
RAII object that enters a new expression evaluation context.
Wrapper for source info for enum types.
Definition TypeLoc.h:863
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Definition Expr.h:3953
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition ExprCXX.h:3661
This represents one expression.
Definition Expr.h:112
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition Expr.h:177
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:194
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition Expr.h:454
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3089
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3221
QualType getType() const
Definition Expr.h:144
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition Expr.h:526
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition Expr.h:437
An expression trait intrinsic.
Definition ExprCXX.h:3073
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h:6610
Represents difference between two FPOptions values.
FPOptions applyOverrides(FPOptions Base)
Represents a member of a struct/union/class.
Definition Decl.h:3178
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2898
Represents a function declaration or definition.
Definition Decl.h:2018
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2792
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5337
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4982
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5718
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5704
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5203
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4947
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4841
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5369
param_type_iterator param_type_begin() const
Definition TypeBase.h:5813
unsigned getNumParams() const
Definition TypeLoc.h:1716
SourceLocation getLocalRangeEnd() const
Definition TypeLoc.h:1668
void setLocalRangeBegin(SourceLocation L)
Definition TypeLoc.h:1664
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1680
SourceRange getExceptionSpecRange() const
Definition TypeLoc.h:1696
void setParam(unsigned i, ParmVarDecl *VD)
Definition TypeLoc.h:1723
ArrayRef< ParmVarDecl * > getParams() const
Definition TypeLoc.h:1707
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1688
void setLocalRangeEnd(SourceLocation L)
Definition TypeLoc.h:1672
void setExceptionSpecRange(SourceRange R)
Definition TypeLoc.h:1702
TypeLoc getReturnLoc() const
Definition TypeLoc.h:1725
SourceLocation getLocalRangeBegin() const
Definition TypeLoc.h:1660
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1676
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1684
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4591
This represents a GCC inline-assembly statement extension.
Definition Stmt.h:3456
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition Expr.h:4926
Represents a C11 generic selection.
Definition Expr.h:6182
AssociationTy< false > Association
Definition Expr.h:6415
GotoStmt - This represents a direct goto.
Definition Stmt.h:2979
Type source information for HLSL attributed resource type.
Definition TypeLoc.h:1113
void setSourceRange(const SourceRange &R)
Definition TypeLoc.h:1124
This class represents temporary values used to represent inout and out arguments in HLSL.
Definition Expr.h:7397
One of these records is kept for each identifier that is lexed.
IfStmt - This represents an if/then/else.
Definition Stmt.h:2269
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition Expr.h:1734
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition Expr.h:3856
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:6057
Represents a C array with an unspecified size.
Definition TypeBase.h:3971
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:3018
const TypeClass * getTypePtr() const
Definition TypeLoc.h:526
Describes an C or C++ initializer list.
Definition Expr.h:5302
InitListExpr * getSyntacticForm() const
Definition Expr.h:5472
Wrapper for source info for injected class names of class templates.
Definition TypeLoc.h:872
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition Expr.cpp:980
Represents the declaration of a label.
Definition Decl.h:524
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2156
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition ExprCXX.h:1972
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition ExprCXX.cpp:1370
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1365
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1374
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition ExprCXX.h:2037
Represents the results of name lookup.
Definition Lookup.h:147
This represents a Microsoft inline-assembly statement extension.
Definition Stmt.h:3675
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition StmtCXX.h:253
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4349
A member reference to an MSPropertyDecl.
Definition ExprCXX.h:940
MS property subscript expression.
Definition ExprCXX.h:1010
void setExpansionLoc(SourceLocation Loc)
Definition TypeLoc.h:1383
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4920
MatrixSingleSubscriptExpr - Matrix single subscript expression for the MatrixType extension when you ...
Definition Expr.h:2798
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2868
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2125
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3367
Wrapper for source info for member pointers.
Definition TypeLoc.h:1544
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3715
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition Template.h:76
This represents a decl that may have a name.
Definition Decl.h:274
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition Decl.h:295
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:301
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:340
Represents C++ namespaces and their aliases.
Definition Decl.h:573
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents a place-holder for an object not to be initialized by anything.
Definition Expr.h:5877
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h:1713
This represents the 'align' clause in the 'pragma omp allocate' directive.
This represents clause 'allocate' in the 'pragma omp ...' directives.
This represents 'allocator' clause in the 'pragma omp ...' directive.
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
Definition ExprOpenMP.h:24
This is a basic class for representing single OpenMP clause.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
This represents 'collapse' clause in the 'pragma omp ...' directive.
This represents the 'counts' clause in the 'pragma omp split' directive.
This represents 'default' clause in the 'pragma omp ...' directive.
This represents 'final' clause in the 'pragma omp ...' directive.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
This represents 'if' clause in the 'pragma omp ...' directive.
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
Definition ExprOpenMP.h:151
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
Representation of the 'partial' clause of the 'pragma omp unroll' directive.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
This represents 'safelen' clause in the 'pragma omp ...' directive.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition ExprObjC.h:220
Represents Objective-C's @catch statement.
Definition StmtObjC.h:77
Represents Objective-C's @finally statement.
Definition StmtObjC.h:127
Represents Objective-C's @synchronized statement.
Definition StmtObjC.h:303
Represents Objective-C's @throw statement.
Definition StmtObjC.h:358
Represents Objective-C's @try ... @catch ... @finally statement.
Definition StmtObjC.h:167
Represents Objective-C's @autoreleasepool Statement.
Definition StmtObjC.h:394
A runtime availability query.
Definition ExprObjC.h:1734
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition ExprObjC.h:119
ObjCBoxedExpr - used for generalized expression boxing.
Definition ExprObjC.h:159
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition ExprObjC.h:1674
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition ExprObjC.h:342
ObjCEncodeExpr, used for @encode in Objective-C.
Definition ExprObjC.h:441
Represents Objective-C's collection statement.
Definition StmtObjC.h:23
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition ExprObjC.h:1613
Wrapper for source info for ObjC interfaces.
Definition TypeLoc.h:1303
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition ExprObjC.h:1529
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1952
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:580
An expression that sends a message to the given Objective-C object or class.
Definition ExprObjC.h:971
@ SuperInstance
The receiver is the instance of the superclass object.
Definition ExprObjC.h:985
@ Instance
The receiver is an object instance.
Definition ExprObjC.h:979
@ SuperClass
The receiver is a superclass.
Definition ExprObjC.h:982
@ Class
The receiver is a class.
Definition ExprObjC.h:976
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Wraps an ObjCPointerType with source location information.
Definition TypeLoc.h:1586
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1592
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition TypeLoc.h:1258
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:731
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition ExprObjC.h:648
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition ExprObjC.h:536
ObjCSelectorExpr used for @selector in Objective-C.
Definition ExprObjC.h:486
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition ExprObjC.h:84
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition ExprObjC.h:870
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:578
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition TypeLoc.h:895
@ Array
An index into an array.
Definition Expr.h:2429
@ Identifier
A field in a dependent type, known only by its name.
Definition Expr.h:2433
@ Field
A field.
Definition Expr.h:2431
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition Expr.h:2436
static OpaquePtr make(QualType P)
Definition Ownership.h:61
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition Expr.h:1181
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1231
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition Expr.h:2093
static OpenACCAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCAttachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCAutoClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
This is the base type for all OpenACC Clauses.
Represents a 'collapse' clause on a 'loop' construct.
static OpenACCCollapseClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, bool HasForce, Expr *LoopCount, SourceLocation EndLoc)
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A 'default' clause, has the optional 'none' or 'present' argument.
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCDeleteClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDetachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceNumClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCFinalizeClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCFirstPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCHostClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
An 'if' clause, which has a required condition expression.
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCIfPresentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCIndependentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCNoCreateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCPrivateRecipe > InitRecipes, SourceLocation EndLoc)
A 'self' clause, which has an optional condition expression, or, in the event of an 'update' directiv...
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCTileClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > SizeExprs, SourceLocation EndLoc)
static OpenACCUseDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWaitClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1093
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition ExprCXX.h:3132
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition ExprCXX.h:3284
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3266
SourceLocation getNameLoc() const
Gets the location of the name.
Definition ExprCXX.h:3245
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3258
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition ExprCXX.h:3254
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3324
llvm::iterator_range< decls_iterator > decls() const
Definition ExprCXX.h:3231
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3330
DeclarationName getName() const
Gets the name looked up.
Definition ExprCXX.h:3242
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3274
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition ExprCXX.h:3281
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition ExprCXX.h:4363
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2633
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2629
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2645
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2316
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2185
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition Expr.h:2210
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition Expr.h:2214
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1411
Represents a parameter to a function.
Definition Decl.h:1808
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1868
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1841
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition Decl.cpp:2952
unsigned getFunctionScopeDepth() const
Definition Decl.h:1858
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2725
PipeType - OpenCL20.
Definition TypeBase.h:8263
bool isReadOnly() const
Definition TypeBase.h:8293
Pointer-authentication qualifiers.
Definition TypeBase.h:152
void setSigilLoc(SourceLocation Loc)
Definition TypeLoc.h:1490
TypeLoc getPointeeLoc() const
Definition TypeLoc.h:1494
SourceLocation getSigilLoc() const
Definition TypeLoc.h:1486
Wrapper for source info for pointers.
Definition TypeLoc.h:1513
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3390
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2008
Stores the type being destroyed by a pseudo-destructor expression.
Definition ExprCXX.h:2698
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h:6804
A (possibly-)qualified type.
Definition TypeBase.h:937
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition TypeBase.h:1004
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition TypeBase.h:8445
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8477
Represents a template name as written in source code.
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition TypeLoc.h:300
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
void removeObjCLifetime()
Definition TypeBase.h:551
bool hasRestrict() const
Definition TypeBase.h:477
static Qualifiers fromCVRMask(unsigned CVR)
Definition TypeBase.h:435
PointerAuthQualifier getPointerAuth() const
Definition TypeBase.h:603
bool hasObjCLifetime() const
Definition TypeBase.h:544
bool empty() const
Definition TypeBase.h:647
LangAS getAddressSpace() const
Definition TypeBase.h:571
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition Expr.h:7503
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3635
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3651
Represents the body of a requires-expression.
Definition DeclCXX.h:2101
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition DeclCXX.cpp:2407
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3170
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition Stmt.cpp:1361
Represents a __leave statement.
Definition Stmt.h:3908
SYCLKernelCallStmt represents the transformation that is applied to the body of a function declared w...
Definition StmtSYCL.h:36
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
Definition SemaObjC.cpp:36
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
Definition SemaObjC.cpp:193
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition SemaObjC.cpp:320
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
Definition SemaObjC.cpp:218
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:213
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition SemaObjC.cpp:238
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition SemaObjC.cpp:282
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Definition SemaObjC.cpp:202
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:329
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
Helper type for the registration/assignment of constructs that need to 'know' about their parent cons...
Helper type to restore the state of various 'loop' constructs when we run into a loop (for,...
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
void ActOnWhileStmt(SourceLocation WhileLoc)
ExprResult ActOnOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
void ActOnDoStmt(SourceLocation DoLoc)
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *OldRangeFor, const Stmt *RangeFor)
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation MiscLoc, ArrayRef< Expr * > Exprs, OpenACCAtomicKind AK, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
void ActOnForStmtEnd(SourceLocation ForLoc, StmtResult Body)
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *First, const Stmt *Second, const Stmt *Third)
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
OMPClause * ActOnOpenMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nocontext' clause.
OMPClause * ActOnOpenMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_dyn_cgroup_mem' clause.
OMPClause * ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'safelen' clause.
OMPClause * ActOnOpenMPHoldsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'holds' clause.
OMPClause * ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'filter' clause.
OMPClause * ActOnOpenMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on well-form 'full' clauses.
OMPClause * ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'detach' clause.
OMPClause * ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'use' clause.
OMPClause * ActOnOpenMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'private' clause.
OMPClause * ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc=SourceLocation(), Expr *NumForLoops=nullptr)
Called on well-formed 'ordered' clause.
OMPClause * ActOnOpenMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'is_device_ptr' clause.
OMPClause * ActOnOpenMPCountsClause(ArrayRef< Expr * > CountExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, std::optional< unsigned > FillIdx, SourceLocation FillLoc, unsigned FillCount)
Called on well-formed 'counts' clause after parsing its arguments.
OMPClause * ActOnOpenMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'has_device_addr' clause.
OMPClause * ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'partial' clauses.
OMPClause * ActOnOpenMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'lastprivate' clause.
OMPClause * ActOnOpenMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'firstprivate' clause.
OMPClause * ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'priority' clause.
OMPClause * ActOnOpenMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'dist_schedule' clause.
OMPClause * ActOnOpenMPLoopRangeClause(Expr *First, Expr *Count, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc)
Called on well-form 'looprange' clause after parsing its arguments.
OMPClause * ActOnOpenMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'permutation' clause after parsing its arguments.
OMPClause * ActOnOpenMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nontemporal' clause.
OMPClause * ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'bind' clause.
OMPClause * ActOnOpenMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' clause.
OMPClause * ActOnOpenMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'shared' clause.
OMPClause * ActOnOpenMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyin' clause.
OMPClause * ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'destroy' clause.
OMPClause * ActOnOpenMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Called on well-formed 'affinity' clause.
OMPClause * ActOnOpenMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' clause.
OMPClause * ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depend' clause.
OMPClause * ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'doacross' clause.
OMPClause * ActOnOpenMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, OpenMPUseDevicePtrFallbackModifier FallbackModifier, SourceLocation FallbackModifierLoc)
Called on well-formed 'use_device_ptr' clause.
OMPClause * ActOnOpenMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'grainsize' clause.
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
ExprResult ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< OMPIteratorData > Data)
OMPClause * ActOnOpenMPUsesAllocatorClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< UsesAllocatorsData > Data)
Called on well-formed 'uses_allocators' clause.
OMPClause * ActOnOpenMPAllocatorClause(Expr *Allocator, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocator' clause.
OMPClause * ActOnOpenMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'inclusive' clause.
OMPClause * ActOnOpenMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'task_reduction' clause.
OMPClause * ActOnOpenMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Condition)
Called on well-formed 'nowait' clause.
OMPClause * ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, OpenMPOrderClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'order' clause.
OMPClause * ActOnOpenMPSizesClause(ArrayRef< Expr * > SizeExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'sizes' clause.
OMPClause * ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'device' clause.
OMPClause * ActOnOpenMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'in_reduction' clause.
OMPClause * ActOnOpenMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'flush' pseudo clause.
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
OMPClause * ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'message' clause.
OMPClause * ActOnOpenMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'schedule' clause.
OMPClause * ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'simdlen' clause.
OMPClause * ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'proc_bind' clause.
OMPClause * ActOnOpenMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_bare' clause.
StmtResult ActOnOpenMPInformationalDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Process an OpenMP informational directive.
StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt)
Called for syntactical loops (ForStmt or CXXForRangeStmt) associated to an OpenMP loop directive.
OMPClause * ActOnOpenMPTransparentClause(Expr *Transparent, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'transparent' clause.
OMPClause * ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'hint' clause.
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
OMPClause * ActOnOpenMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_threads' clause.
OMPClause * ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'at' clause.
OMPClause * ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'init' clause.
OMPClause * ActOnOpenMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_addr' clause.
OMPClause * ActOnOpenMPAllocateClause(Expr *Allocator, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocate' clause.
OMPClause * ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'final' clause.
OMPClause * ActOnOpenMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, bool NoDiagnose=false, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'map' clause.
OMPClause * ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_tasks' clause.
OMPClause * ActOnOpenMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'from' clause.
OMPClause * ActOnOpenMPDynGroupprivateClause(OpenMPDynGroupprivateClauseModifier M1, OpenMPDynGroupprivateClauseFallbackModifier M2, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation EndLoc)
Called on a well-formed 'dyn_groupprivate' clause.
void StartOpenMPDSABlock(OpenMPDirectiveKind K, const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc)
Called on start of new data sharing attribute block.
OMPClause * ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'severity' clause.
OMPClause * ActOnOpenMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'to' clause.
OMPClause * ActOnOpenMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind LinKind, SourceLocation LinLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Called on well-formed 'linear' clause.
OMPClause * ActOnOpenMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'defaultmap' clause.
OMPClause * ActOnOpenMPReductionClause(ArrayRef< Expr * > VarList, OpenMPVarListDataTy::OpenMPReductionClauseModifiers Modifiers, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'reduction' clause.
OMPClause * ActOnOpenMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'aligned' clause.
OMPClause * ActOnOpenMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depobj' pseudo clause.
OMPClause * ActOnOpenMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'novariants' clause.
OMPClause * ActOnOpenMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyprivate' clause.
OMPClause * ActOnOpenMPCollapseClause(Expr *NumForLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'collapse' clause.
OMPClause * ActOnOpenMPDefaultClause(llvm::omp::DefaultKind M, SourceLocation MLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCKindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'default' clause.
OMPClause * ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'align' clause.
OMPClause * ActOnOpenMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_attribute' clause.
OMPClause * ActOnOpenMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'exclusive' clause.
OMPClause * ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'if' clause.
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
Given a pseudo-object expression, recreate what it looks like syntactically without the attendant Opa...
ExprResult checkRValue(Expr *E)
StmtResult BuildSYCLKernelCallStmt(FunctionDecl *FD, CompoundStmt *Body, Expr *LaunchIdExpr)
Builds a SYCLKernelCallStmt to wrap 'Body' and to be used as the body of 'FD'.
Definition SemaSYCL.cpp:670
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition SemaSYCL.cpp:153
RAII object used to change the argument pack substitution index within a Sema object.
Definition Sema.h:13751
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8534
A RAII object to enter scope of a compound statement.
Definition Sema.h:1315
A RAII object to temporarily push a declaration context.
Definition Sema.h:3526
A helper class for building up ExtParameterInfos.
Definition Sema.h:13121
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:13140
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13128
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14156
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:868
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
ExprResult ActOnCXXParenListInitExpr(ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
ExprResult BuildOperatorCoawaitCall(SourceLocation Loc, Expr *E, UnresolvedLookupExpr *Lookup)
Build a call to 'operator co_await' if there is a suitable operator for the given expression.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition Sema.h:9417
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9425
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9420
bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend)
Check that the expression co_await promise.final_suspend() shall not be potentially-throwing.
ExprResult CreateBuiltinMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx, SourceLocation RBLoc)
ExprResult ActOnConstantExpression(ExprResult Res)
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs)
ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E)
SemaOpenMP & OpenMP()
Definition Sema.h:1533
void ActOnStartStmtExpr()
void ActOnStmtExprError()
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt={})
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
VarDecl * buildCoroutinePromise(SourceLocation Loc)
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
Definition Sema.h:7924
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7926
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7925
ExprResult 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:439
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E, bool IsImplicit=false)
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition SemaStmt.cpp:485
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition Sema.h:1558
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition Sema.h:12066
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
ASTContext & Context
Definition Sema.h:1308
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
DiagnosticsEngine & getDiagnostics() const
Definition Sema.h:936
SemaObjC & ObjC()
Definition Sema.h:1518
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool FullySubstituted=false)
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
ASTContext & getASTContext() const
Definition Sema.h:939
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, bool DoCheckConstraintSatisfaction=true)
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition Sema.cpp:84
const LangOptions & getLangOpts() const
Definition Sema.h:932
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
SemaOpenACC & OpenACC()
Definition Sema.h:1523
@ ReuseLambdaContextDecl
Definition Sema.h:7103
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)
Check whether an expression might be an implicit class member access.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc, bool ListInitialization)
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
TemplateArgument getPackSubstitutedTemplateArgument(TemplateArgument Arg) const
Definition Sema.h:11869
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
bool buildCoroutineParameterMoves(SourceLocation Loc)
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a Microsoft __uuidof expression with a type operand.
sema::FunctionScopeInfo * getCurFunction() const
Definition Sema.h:1341
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
UnsignedOrNone getPackIndex(TemplateArgument Pack) const
Definition Sema.h:11864
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition Sema.cpp:2601
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1446
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
ExprResult 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:13745
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc, BuildForRangeKind Kind, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
Definition Sema.h:6813
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6823
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6792
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6818
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:75
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition Sema.h:8403
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc)
Complete a lambda-expression having processed and attached the lambda body.
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition Sema.h:11153
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition SemaStmt.cpp:563
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParen)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition SemaCast.cpp:338
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel)
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition SemaStmt.cpp:950
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, SourceLocation RParenLoc, MultiExprArg Args, AtomicExpr::AtomicOp Op, AtomicArgumentOrder ArgOrder=AtomicArgumentOrder::API)
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
OpaquePtr< TemplateName > TemplateTy
Definition Sema.h:1300
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static ConditionResult ConditionError()
Definition Sema.h:7910
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:436
SemaPseudoObject & PseudoObject()
Definition Sema.h:1543
StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
ActOnCXXTryBlock - Takes a try compound-statement and a number of handlers and creates a try statemen...
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition Sema.h:1299
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition SemaStmt.cpp:568
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition SemaStmt.cpp:532
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Definition Sema.h:8745
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition Expr.h:4646
Represents an expression that computes the length of a parameter pack.
Definition ExprCXX.h:4441
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition ExprCXX.h:4503
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
Definition ExprCXX.h:4526
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Definition ExprCXX.cpp:1716
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition ExprCXX.h:4531
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
Definition ExprCXX.h:4500
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition ExprCXX.h:4506
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition ExprCXX.h:4509
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition Expr.h:5020
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition Expr.h:5080
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition Expr.h:4598
Stmt - This represents one statement.
Definition Stmt.h:86
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.cpp:367
@ NoStmtClass
Definition Stmt.h:89
StmtClass getStmtClass() const
Definition Stmt.h:1503
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:343
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1802
Wrapper for substituted template type parameters.
Definition TypeLoc.h:998
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition ExprCXX.h:4664
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition ExprCXX.h:4754
A structure for storing an already-substituted template template parameter pack.
A structure for storing the information associated with a substituted template template parameter.
Wrapper for substituted template type parameters.
Definition TypeLoc.h:992
SwitchStmt - This represents a 'switch' stmt.
Definition Stmt.h:2519
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3735
SourceLocation getNameLoc() const
Definition TypeLoc.h:822
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:801
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:809
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:816
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:824
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:805
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
const TemplateArgumentLoc * operator->() const
Simple iterator that traverses the template arguments in a container that provides a getArgLoc() memb...
TemplateArgumentLocContainerIterator operator++(int)
friend bool operator!=(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator(ArgLocContainer &Container, unsigned Index)
friend bool operator==(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator & operator++()
const TemplateArgumentLoc * operator->() const
Iterator adaptor that invents template argument location information for each of the template argumen...
TemplateArgumentLocInventIterator & operator++()
std::iterator_traits< InputIterator >::difference_type difference_type
TemplateArgumentLocInventIterator operator++(int)
friend bool operator==(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
TemplateArgumentLocInventIterator(TreeTransform< Derived > &Self, InputIterator Iter)
friend bool operator!=(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
TypeSourceInfo * getTypeSourceInfo() const
Expr * getSourceExpression() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
const TemplateArgument * pack_iterator
Iterator that traverses the elements of a template argument pack.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DeducedTemplateStorage * getAsDeducedTemplateName() const
Retrieve the deduced template info, if any.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
NestedNameSpecifier getQualifier() const
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceLocation getLAngleLoc() const
Definition TypeLoc.h:1907
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:1922
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:1905
SourceLocation getTemplateKeywordLoc() const
Definition TypeLoc.h:1901
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1891
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:1887
Wrapper for template type parameters.
Definition TypeLoc.h:881
The top declaration context.
Definition Decl.h:105
RAII object that temporarily sets the base location and entity used for reporting diagnostics in type...
TemporaryBase(const TemporaryBase &)=delete
TemporaryBase(TreeTransform &Self, SourceLocation Location, DeclarationName Entity)
TemporaryBase & operator=(const TemporaryBase &)=delete
A semantic tree transformation that allows one to transform one abstract syntax tree into another.
ExprResult RebuildObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *object)
Rebuild the operand to an Objective-C @synchronized statement.
OMPClause * RebuildOMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nontemporal' clause.
StmtResult RebuildOpenACCDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
TemplateArgument TransformNamedTemplateTemplateArgument(NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName Name, SourceLocation NameLoc)
ExprResult TransformInitializer(Expr *Init, bool NotCopyInit)
Transform the given initializer.
StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new label statement.
StmtResult RebuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs Args)
StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @autoreleasepool statement.
OMPClause * RebuildOMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP 'dist_schedule' clause.
ExprResult RebuildUnaryOperator(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *SubExpr)
Build a new unary operator expression.
OMPClause * RebuildOMPProcBindClause(ProcBindKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'proc_bind' clause.
ParmVarDecl * TransformFunctionTypeParam(ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack)
Transforms a single function-type parameter.
StmtResult RebuildOMPInformationalDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP informational directive.
ExprResult RebuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Build a new C++11 default-initialization expression.
OMPClause * RebuildOMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'priority' clause.
StmtResult RebuildOpenACCSetConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc, TypeSourceInfo *EncodeTypeInfo, SourceLocation RParenLoc)
Build a new Objective-C @encode expression.
StmtResult RebuildOpenACCCombinedConstruct(OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult Loop)
StmtResult SkipLambdaBody(LambdaExpr *E, Stmt *Body)
Alternative implementation of TransformLambdaBody that skips transforming the body.
StmtResult RebuildOpenACCExitDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
StmtResult RebuildOpenACCShutdownConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
OMPClause * RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocate' clause.
ExprResult RebuildObjCIsaExpr(Expr *BaseArg, SourceLocation IsaLoc, SourceLocation OpLoc, bool IsArrow)
Build a new Objective-C "isa" expression.
StmtResult RebuildObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @finally statement.
SourceLocation getBaseLocation()
Returns the location of the entity being transformed, if that information was not available elsewhere...
ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
Build a new call expression.
ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar, SourceLocation IvarLoc, bool IsArrow, bool IsFreeIvar)
Build a new Objective-C ivar reference expression.
OMPClause * RebuildOMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'at' clause.
StmtResult RebuildCoreturnStmt(SourceLocation CoreturnLoc, Expr *Result, bool IsImplicit)
Build a new co_return statement.
OMPClause * RebuildOMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'in_reduction' clause.
ExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *Init)
Build a new compound literal expression.
ExprResult TransformAddressOfOperand(Expr *E)
The operand of a unary address-of operator has special rules: it's allowed to refer to a non-static m...
ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc, QualType ThisType, bool isImplicit)
Build a new C++ "this" expression.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(expr) expression.
TreeTransform(Sema &SemaRef)
Initializes a new tree transformer.
QualType RebuildDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttributeLoc)
Build a new matrix type given the type and dependently-defined dimensions.
QualType RebuildTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, TagDecl *Tag)
Build a new class/struct/union/enum type.
QualType RebuildUnaryTransformType(QualType BaseType, UnaryTransformType::UTTKind UKind, SourceLocation Loc)
Build a new unary transform type.
ExprResult RebuildObjCPropertyRefExpr(Expr *BaseArg, ObjCPropertyDecl *Property, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
void InventTemplateArgumentLoc(const TemplateArgument &Arg, TemplateArgumentLoc &ArgLoc)
Fakes up a TemplateArgumentLoc for a given TemplateArgument.
OMPClause * RebuildOMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'use' clause.
StmtResult RebuildOpenACCEnterDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL)
Transform the given type-with-location into a new type, collecting location information in the given ...
ExprResult RebuildCXXRewrittenBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opcode, const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS)
Build a new rewritten operator expression.
ExprResult RebuildPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new expression pack expansion.
ExprResult TransformUnresolvedLookupExpr(UnresolvedLookupExpr *E, bool IsAddressOfOperand)
ExprResult RebuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
Build a new expression representing a call to a source location builtin.
TemplateName RebuildTemplateName(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final)
Build a new template name given a template template parameter pack and the.
QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL)
Transforms a reference type.
OMPClause * RebuildOMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'message' clause.
ExprResult RebuildCXXAddrspaceCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
QualType RebuildTypeOfType(QualType Underlying, TypeOfKind Kind)
Build a new typeof(type) type.
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, Expr *SubExpr, TypeSourceInfo *TInfo, SourceLocation RParenLoc)
Build a new va_arg expression.
ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, SourceLocation RParenLoc)
Build a new C++ zero-initialization expression.
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr)
OMPClause * RebuildOMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'thread_limit' clause.
StmtResult RebuildSEHFinallyStmt(SourceLocation Loc, Stmt *Block)
OMPClause * RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'simdlen' clause.
StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
Build a new C++ try statement.
StmtDiscardKind
The reason why the value of a statement is not discarded, if any.
ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, UnresolvedLookupExpr *OpCoawaitLookup, bool IsImplicit)
Build a new co_await expression.
bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, unsigned NumInputs, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
ExprResult RebuildDesignatedInitExpr(Designation &Desig, MultiExprArg ArrayExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Build a new designated initializer expression.
QualType RebuildUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, SourceLocation NameLoc, Decl *D)
Rebuild an unresolved typename type, given the decl that the UnresolvedUsingTypenameDecl was transfor...
OMPClause * RebuildOMPSizesClause(ArrayRef< Expr * > Sizes, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
ExprResult RebuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
Build a new predefined expression.
ExprResult RebuildInitList(SourceLocation LBraceLoc, MultiExprArg Inits, SourceLocation RBraceLoc, bool IsExplicit)
Build a new initializer list expression.
ExprResult RebuildCXXStaticCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ static_cast expression.
StmtResult RebuildForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *Init, Sema::ConditionResult Cond, Sema::FullExprArg Inc, SourceLocation RParenLoc, Stmt *Body)
Build a new for statement.
StmtResult RebuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Build a new C++0x range-based for statement.
ExprResult RebuildStmtExpr(SourceLocation LParenLoc, Stmt *SubStmt, SourceLocation RParenLoc, unsigned TemplateDepth)
Build a new GNU statement expression.
QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo *Id, SourceLocation IdLoc, bool DeducedTSTContext)
Build a new typename type that refers to an identifier.
OMPClause * RebuildOpenMPTransparentClause(Expr *ImpexType, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Sema & getSema() const
Retrieves a reference to the semantic analysis object used for this tree transform.
ExprResult RebuildShuffleVectorExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new shuffle vector expression.
OMPClause * RebuildOMPNowaitClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nowait' clause.
QualType TransformType(QualType T)
Transforms the given type into another type.
UnsignedOrNone ComputeSizeOfPackExprWithoutSubstitution(ArrayRef< TemplateArgument > PackArgs)
OMPClause * RebuildOMPOrderClause(OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc)
Build a new OpenMP 'order' clause.
QualType RebuildReferenceType(QualType ReferentType, bool LValue, SourceLocation Sigil)
Build a new reference type given the type it references.
ExprResult TransformRequiresTypeParams(SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE, RequiresExprBodyDecl *Body, ArrayRef< ParmVarDecl * > Params, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > &TransParams, Sema::ExtParameterInfoBuilder &PInfos)
Transforms the parameters of a requires expresison into the given vectors.
QualType RebuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
StmtResult RebuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Operand)
Build a new Objective-C @throw statement.
OMPClause * RebuildOMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'task_reduction' clause.
StmtResult RebuildOpenACCWaitConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
OMPClause * RebuildOMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'copyin' clause.
QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc, bool isReadPipe)
Build a new pipe type given its value type.
StmtResult RebuildCaseStmt(SourceLocation CaseLoc, Expr *LHS, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation ColonLoc)
Build a new case statement.
ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
Build a new template-id expression.
StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc, VarDecl *ExceptionDecl, Stmt *Handler)
Build a new C++ catch statement.
OMPClause * RebuildOMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'destroy' clause.
ExprResult RebuildUnaryExprOrTypeTrait(Expr *SubExpr, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec step expression with an expression argument.
ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new address-of-label expression.
ExprResult RebuildCxxSubscriptExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
OMPClause * RebuildOMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_bare' clause.
const Attr * TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS, const Attr *A)
ExprResult RebuildConditionalOperator(Expr *Cond, SourceLocation QuestionLoc, Expr *LHS, SourceLocation ColonLoc, Expr *RHS)
Build a new conditional operator expression.
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
Attach body to a C++0x range-based for statement.
StmtResult RebuildOpenACCUpdateConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *Object, Stmt *Body)
Build a new Objective-C @synchronized statement.
ExprResult RebuildOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
OMPClause * RebuildOMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'device' clause.
OMPClause * RebuildOMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'has_device_addr' clause.
bool TryExpandParameterPacks(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions)
Determine whether we should expand a pack expansion with the given set of parameter packs into separa...
QualType RebuildDependentSizedExtVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
OMPClause * RebuildOMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_threads' clause.
void RememberPartiallySubstitutedPack(TemplateArgument Arg)
"Remember" the partially-substituted pack template argument after performing an instantiation that mu...
Decl * TransformDefinition(SourceLocation Loc, Decl *D)
Transform the definition of the given declaration.
ExprResult RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, UnresolvedLookupExpr *Lookup)
Build a new co_await expression.
StmtResult RebuildReturnStmt(SourceLocation ReturnLoc, Expr *Result)
Build a new return statement.
QualType TransformTemplateSpecializationType(TypeLocBuilder &TLB, TemplateSpecializationTypeLoc TL, QualType ObjectType, NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName)
TemplateArgument ForgetPartiallySubstitutedPack()
"Forget" about the partially-substituted pack template argument, when performing an instantiation tha...
OMPClause * RebuildOMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nocontext' clause.
ExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ reinterpret_cast expression.
QualType RebuildVectorType(QualType ElementType, unsigned NumElements, VectorKind VecKind)
Build a new vector type given the element type and number of elements.
ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc, TypeSourceInfo *Type, ArrayRef< Sema::OffsetOfComponent > Components, SourceLocation RParenLoc)
Build a new builtin offsetof expression.
QualType RebuildParenType(QualType InnerType)
Build a new parenthesized type.
QualType RebuildAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, ConceptDecl *TypeConstraintConcept, ArrayRef< TemplateArgument > TypeConstraintArgs)
Build a new C++11 auto type.
static StmtResult Owned(Stmt *S)
OMPClause * RebuildOMPPartialClause(Expr *Factor, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'partial' clause.
OMPClause * RebuildOMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP 'schedule' clause.
StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body)
Transform the body of a lambda-expression.
StmtResult RebuildSEHTryStmt(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
OMPClause * RebuildOMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'exclusive' clause.
QualType RebuildDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc)
Build a new DependentAddressSpaceType or return the pointee type variable with the correct address sp...
StmtResult RebuildAttributedStmt(SourceLocation AttrLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Build a new attributed statement.
QualType RebuildMemberPointerType(QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls, SourceLocation Sigil)
Build a new member pointer type given the pointee type and the qualifier it refers into.
ExprResult RebuildConceptSpecializationExpr(NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, TemplateArgumentListInfo *TALI)
OMPClause * RebuildOMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Build a new OpenMP 'defaultmap' clause.
StmtResult RebuildOpenACCCacheConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation ReadOnlyLoc, ArrayRef< Expr * > VarList, SourceLocation RParenLoc, SourceLocation EndLoc)
StmtResult RebuildOpenACCLoopConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult Loop)
ExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr)
Build a new C++ default-argument expression.
OMPClause * RebuildOMPDefaultClause(DefaultKind Kind, SourceLocation KindKwLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'default' clause.
StmtResult RebuildWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, Sema::ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
Build a new while statement.
OMPClause * RebuildOMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_teams' clause.
OMPClause * RebuildOMPDynGroupprivateClause(OpenMPDynGroupprivateClauseModifier M1, OpenMPDynGroupprivateClauseFallbackModifier M2, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation EndLoc)
Build a new OpenMP 'dyn_groupprivate' clause.
ExprResult RebuildImplicitValueInitExpr(QualType T)
Build a new value-initialized expression.
bool TransformFunctionTypeParams(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const QualType *ParamTypes, const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > *PVars, Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed)
Transforms the parameters of a function type into the given vectors.
StmtResult RebuildGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
Build a new inline asm statement.
StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S)
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
Build a new template name given a nested name specifier and the name that is referred to as a templat...
TemplateName RebuildTemplateName(CXXScopeSpec &SS, bool TemplateKW, TemplateName Name)
Build a new template name given a nested name specifier, a flag indicating whether the "template" key...
ExprResult RebuildObjCMessageExpr(Expr *Receiver, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C instance message.
QualType TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB, SubstTemplateTypeParmPackTypeLoc TL, bool SuppressObjCLifetime)
ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool RequiresADL)
Build a new expression that references a declaration.
bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall, SmallVectorImpl< Expr * > &Outputs, bool *ArgChanged=nullptr)
Transform the given list of expressions.
StmtResult TransformSEHHandler(Stmt *Handler)
NestedNameSpecifierLoc TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr)
Transform the given nested-name-specifier with source-location information.
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, OverloadedOperatorKind Operator, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
Build a new template name given a nested name specifier and the overloaded operator name that is refe...
StmtResult RebuildOpenACCHostDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc)
Build a new C++11 decltype type.
void ExpandingFunctionParameterPack(ParmVarDecl *Pack)
Note to the derived class when a function parameter pack is being expanded.
void setBase(SourceLocation Loc, DeclarationName Entity)
Sets the "base" location and entity when that information is known based on another transformation.
concepts::TypeRequirement * TransformTypeRequirement(concepts::TypeRequirement *Req)
const Derived & getDerived() const
Retrieves a reference to the derived class.
ExprResult RebuildParenExpr(Expr *SubExpr, SourceLocation LParen, SourceLocation RParen)
Build a new expression in parentheses.
QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new block pointer type given its pointee type.
ExprResult RebuildMemberExpr(Expr *Base, SourceLocation OpLoc, bool isArrow, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, ValueDecl *Member, NamedDecl *FoundDecl, const TemplateArgumentListInfo *ExplicitTemplateArgs, NamedDecl *FirstQualifierInScope)
Build a new member access expression.
OMPClause * RebuildOMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'shared' clause.
ExprResult RebuildCXXConstructExpr(QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor, bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
Build a new object-construction expression.
bool TransformFunctionTypeParams(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const QualType *ParamTypes, const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > *PVars, Sema::ExtParameterInfoBuilder &PInfos)
OMPClause * RebuildOMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'linear' clause.
VarDecl * RebuildExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *Declarator, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Build a new C++ exception declaration.
ExprResult RebuildMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx, SourceLocation RBracketLoc)
Build a new matrix single subscript expression.
ExprResult RebuildCXXNoexceptExpr(SourceRange Range, Expr *Arg)
Build a new noexcept expression.
QualType RebuildFunctionProtoType(QualType T, MutableArrayRef< QualType > ParamTypes, const FunctionProtoType::ExtProtoInfo &EPI)
Build a new function type.
ExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS, bool ForFoldExpression=false)
Build a new binary operator expression.
ExprResult RebuildObjCSubscriptRefExpr(SourceLocation RB, Expr *Base, Expr *Key, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
OMPClause * RebuildOMPCountsClause(ArrayRef< Expr * > Counts, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, std::optional< unsigned > FillIdx, SourceLocation FillLoc)
ExprResult RebuildRecoveryExpr(SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< Expr * > SubExprs, QualType Type)
ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, LambdaScopeInfo *LSI)
QualType RebuildIncompleteArrayType(QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new incomplete array type given the element type, size modifier, and index type qualifiers.
CXXRecordDecl::LambdaDependencyKind ComputeLambdaDependency(LambdaScopeInfo *LSI)
ExprResult RebuildPackIndexingExpr(SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpression, Expr *IndexExpr, ArrayRef< Expr * > ExpandedExprs, bool FullySubstituted=false)
StmtResult RebuildOpenACCInitConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, SourceLocation LParenLoc, Expr *Sub, SourceLocation RParenLoc, bool ListInitialization)
Build a new C++ functional-style cast expression.
QualType RebuildCanonicalTagType(TagDecl *Tag)
ExprResult RebuildObjCDictionaryLiteral(SourceRange Range, MutableArrayRef< ObjCDictionaryElement > Elements)
Build a new Objective-C dictionary literal.
StmtResult RebuildIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *Target)
Build a new indirect goto statement.
ExprResult RebuildParenListExpr(SourceLocation LParenLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new expression list in parentheses.
OMPClause * RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocator' clause.
QualType RebuildDependentSizedArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new dependent-sized array type given the element type, size modifier, size expression,...
NamedDecl * TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc)
Transform the given declaration, which was the first part of a nested-name-specifier in a member acce...
OMPClause * RebuildOMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'inclusive' clause.
StmtResult TransformOMPInformationalDirective(OMPExecutableDirective *S)
This is mostly the same as above, but allows 'informational' class directives when rebuilding the stm...
concepts::ExprRequirement * RebuildExprRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
OMPClause * RebuildOMPTransparentClause(Expr *ImpexTypeArg, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
ExprResult RebuildCXXFoldExpr(UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
Build a new C++1z fold-expression.
OMPClause * TransformOMPClause(OMPClause *S)
Transform the given statement.
QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc)
Build a new atomic type given its value type.
ExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *SubExpr)
Build a new C-style cast expression.
QualType RebuildObjCObjectPointerType(QualType PointeeType, SourceLocation Star)
Build a new Objective-C object pointer type given the pointee type.
OMPClause * RebuildOMPLoopRangeClause(Expr *First, Expr *Count, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc)
bool PreparePackForExpansion(TemplateArgumentLoc In, bool Uneval, TemplateArgumentLoc &Out, UnexpandedInfo &Info)
Checks if the argument pack from In will need to be expanded and does the necessary prework.
ExprResult TransformExpr(Expr *E)
Transform the given expression.
bool AlreadyTransformed(QualType T)
Determine whether the given type T has already been transformed.
concepts::TypeRequirement * RebuildTypeRequirement(TypeSourceInfo *T)
ExprResult RebuildOMPIteratorExpr(SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< SemaOpenMP::OMPIteratorData > Data)
Build a new iterator expression.
ExprResult RebuildSYCLUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
OMPClause * RebuildOMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'grainsize' clause.
OMPClause * RebuildOMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
bool TransformTemplateArguments(InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
OMPClause * RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'collapse' clause.
static ExprResult Owned(Expr *E)
ExprResult RebuildCXXUuidofExpr(QualType Type, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(expr) expression.
OMPClause * RebuildOMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_tasks' clause.
OMPClause * RebuildOMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'depobj' pseudo clause.
ExprResult RebuildChooseExpr(SourceLocation BuiltinLoc, Expr *Cond, Expr *LHS, Expr *RHS, SourceLocation RParenLoc)
Build a new __builtin_choose_expr expression.
OMPClause * RebuildOMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'align' clause.
ExprResult RebuildObjCMessageExpr(TypeSourceInfo *ReceiverTypeInfo, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C class message.
bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL, LookupResult &R)
Transform the set of declarations in an OverloadExpr.
QualType RebuildUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, UsingShadowDecl *D, QualType UnderlyingType)
Build a new type found via an alias.
ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, SourceLocation LParenOrBraceLoc, MultiExprArg Args, SourceLocation RParenOrBraceLoc, bool ListInitialization)
Build a new object-construction expression.
StmtResult RebuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init, SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps)
Build a new C++0x range-based for statement.
OMPClause * RebuildOMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Num)
Build a new OpenMP 'ordered' clause.
ExprResult RebuildCoyieldExpr(SourceLocation CoyieldLoc, Expr *Result)
Build a new co_yield expression.
StmtResult TransformStmt(Stmt *S, StmtDiscardKind SDK=StmtDiscardKind::Discarded)
Transform the given statement.
QualType RebuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo * > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build an Objective-C object type.
llvm::DenseMap< Decl *, Decl * > TransformedLocalDecls
OMPClause * RebuildOMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'novariants' clause.
StmtResult RebuildOpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E)
ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocatedType, TypeSourceInfo *AllocatedTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
Build a new C++ "new" expression.
StmtResult RebuildObjCForCollectionStmt(SourceLocation ForLoc, Stmt *Element, Expr *Collection, SourceLocation RParenLoc, Stmt *Body)
Build a new Objective-C fast enumeration statement.
ExprResult RebuildDependentScopeDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
Build a new (previously unresolved) declaration reference expression.
StmtResult RebuildObjCAtTryStmt(SourceLocation AtLoc, Stmt *TryBody, MultiStmtArg CatchStmts, Stmt *Finally)
Build a new Objective-C @try statement.
DeclarationName getBaseEntity()
Returns the name of the entity being transformed, if that information was not available elsewhere in ...
ExprResult RebuildExtVectorOrMatrixElementExpr(Expr *Base, SourceLocation OpLoc, bool IsArrow, SourceLocation AccessorLoc, IdentifierInfo &Accessor)
Build a new extended vector or matrix element access expression.
ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, bool ListInitialization)
Build a new object-construction expression.
ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, SourceLocation OpLoc, SourceLocation CalleeLoc, bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First, Expr *Second)
Build a new overloaded operator call expression.
OMPClause * RebuildOMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'use_device_addr' clause.
QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc)
Build a dependent bit-precise int given its value type.
OMPClause * RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'hint' clause.
Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var, Expr *Expr, Sema::ConditionKind Kind)
Transform the specified condition.
OMPClause * RebuildOMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'severity' clause.
OMPClause * RebuildOMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'firstprivate' clause.
StmtResult RebuildMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
Build a new MS style inline asm statement.
VarDecl * RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TInfo, QualType T)
Rebuild an Objective-C exception declaration.
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, IdentifierOrOverloadedOperator IO, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
concepts::NestedRequirement * TransformNestedRequirement(concepts::NestedRequirement *Req)
QualType RebuildConstantArrayType(QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new constant array type given the element type, size modifier, (known) size of the array,...
ExprResult RebuildOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > BracketsRanges)
Build a new array shaping expression.
MultiLevelTemplateArgumentList ForgetSubstitution()
"Forget" the template substitution to allow transforming the AST without any template instantiations.
ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc, bool IsGlobalDelete, bool IsArrayForm, Expr *Operand)
Build a new C++ "delete" expression.
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.
QualType RebuildDeducedTemplateSpecializationType(DeducedKind DK, QualType DeducedAsType, ElaboratedTypeKeyword Keyword, TemplateName Template)
By default, builds a new DeducedTemplateSpecializationType with the given deduced type.
ExprResult RebuildObjCArrayLiteral(SourceRange Range, Expr **Elements, unsigned NumElements)
Build a new Objective-C array literal.
ExprResult RebuildCXXUuidofExpr(QualType Type, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(type) expression.
ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE, QualType BaseType, SourceLocation OperatorLoc, bool IsArrow, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs)
Build a new member reference expression.
OMPClause * RebuildOMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'bind' clause.
concepts::NestedRequirement * RebuildNestedRequirement(StringRef InvalidConstraintEntity, const ASTConstraintSatisfaction &Satisfaction)
OMPClause * RebuildOMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'copyprivate' clause.
QualType RebuildPackExpansionType(QualType Pattern, SourceRange PatternRange, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new pack expansion type.
QualType RebuildVariableArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new variable-length array type given the element type, size modifier, size expression,...
ExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ dynamic_cast expression.
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, TypeSourceInfo *ControllingType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
Build a new generic selection expression with a type predicate.
QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new pointer type given its pointee type.
concepts::TypeRequirement * RebuildTypeRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag)
OMPClause * RebuildOMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'permutation' clause.
OMPClause * RebuildOMPUsesAllocatorsClause(ArrayRef< SemaOpenMP::UsesAllocatorsData > Data, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'uses_allocators' clause.
ExprResult RebuildCXXInheritedCtorInitExpr(QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor, bool ConstructsVBase, bool InheritedFromVBase)
Build a new implicit construction via inherited constructor expression.
ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ const_cast expression.
OMPClause * RebuildOMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'to' clause.
ExprResult RebuildCXXParenListInitExpr(ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
TypeSourceInfo * TransformTypeWithDeducedTST(TypeSourceInfo *TSI)
ExprResult RebuildAtomicExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, AtomicExpr::AtomicOp Op, SourceLocation RParenLoc)
Build a new atomic operation expression.
DeclarationNameInfo TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
Transform the given declaration name.
OMPClause * RebuildOMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_attribute' clause.
void RememberSubstitution(MultiLevelTemplateArgumentList)
StmtResult RebuildDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation LParenLoc, Expr *Cond, SourceLocation RParenLoc)
Build a new do-while statement.
OMPClause * RebuildOMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'if' clause.
StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body)
Attach the body to a new case statement.
ExprResult RebuildTypeTrait(TypeTrait Trait, SourceLocation StartLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
Build a new type trait expression.
ExprResult RebuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Build an empty C++1z fold-expression with the given operator.
QualType TransformTypeWithDeducedTST(QualType T)
Transform a type that is permitted to produce a DeducedTemplateSpecializationType.
ExprResult TransformConstraint(Expr *AC)
OMPClause * RebuildOMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'init' clause.
OMPClause * RebuildOMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'detach' clause.
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, MultiStmtArg Statements, SourceLocation RBraceLoc, bool IsStmtExpr)
Build a new compound statement.
ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, ValueDecl *VD, const DeclarationNameInfo &NameInfo, NamedDecl *Found, TemplateArgumentListInfo *TemplateArgs)
Build a new expression that references a declaration.
QualType RebuildArrayType(QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new array type given the element type, size modifier, size of the array (if known),...
StmtResult RebuildDeclStmt(MutableArrayRef< Decl * > Decls, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new declaration statement.
ExprResult RebuildConvertVectorExpr(SourceLocation BuiltinLoc, Expr *SrcExpr, TypeSourceInfo *DstTInfo, SourceLocation RParenLoc)
Build a new convert vector expression.
QualType RebuildQualifiedType(QualType T, QualifiedTypeLoc TL)
Build a new qualified type given its unqualified type and type location.
OMPClause * RebuildOMPDependClause(OMPDependClause::DependDataTy Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'depend' pseudo clause.
OMPClause * RebuildOMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'aligned' clause.
unsigned TransformTemplateDepth(unsigned Depth)
Transform a template parameter depth level.
QualType RebuildFunctionNoProtoType(QualType ResultType)
Build a new unprototyped function type.
QualType RebuildTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, TypedefNameDecl *Typedef)
Build a new typedef type.
QualType TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, Fn TransformExceptionSpec)
OMPClause * RebuildOMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, OpenMPUseDevicePtrFallbackModifier FallbackModifier, SourceLocation FallbackModifierLoc)
Build a new OpenMP 'use_device_ptr' clause.
TemplateArgumentLoc RebuildPackExpansion(TemplateArgumentLoc Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new template argument pack expansion.
const Attr * TransformAttr(const Attr *S)
Transform the given attribute.
QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns)
Build a new matrix type given the element type and dimensions.
OMPClause * RebuildOMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'map' clause.
ExprResult RebuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Sub, SourceLocation RParenLoc)
Build a new C++ __builtin_bit_cast expression.
QualType RebuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted, ArrayRef< QualType > Expansions={})
StmtResult RebuildOMPCanonicalLoop(Stmt *LoopStmt)
Build a new OpenMP Canonical loop.
StmtResult RebuildOMPExecutableDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP executable directive.
concepts::ExprRequirement * RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
TypeSourceInfo * TransformType(TypeSourceInfo *TSI)
Transforms the given type-with-location into a new type-with-location.
ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
OMPClause * RebuildOMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP 'full' clause.
StmtResult RebuildSEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
OMPClause * RebuildOMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Build a new OpenMP 'affinity' clause.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(type) expression.
ExprResult RebuildCXXDependentScopeMemberExpr(Expr *BaseE, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Build a new member reference expression.
ExprResult RebuildCXXNamedCastExpr(SourceLocation OpLoc, Stmt::StmtClass Class, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ "named" cast expression, such as static_cast or reinterpret_cast.
StmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Attach the body to the switch statement.
TypeSourceInfo * InventTypeSourceInfo(QualType T)
Fakes up a TypeSourceInfo for a type.
ExprResult RebuildUnaryExprOrTypeTrait(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec_step expression with a type argument.
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
Build a new generic selection expression with an expression predicate.
QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool SuppressObjCLifetime)
Derived & getDerived()
Retrieves a reference to the derived class.
OMPClause * RebuildOMPHoldsClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'holds' clause.
StmtResult RebuildOpenACCAtomicConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, OpenACCAtomicKind AtKind, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssociatedStmt)
ExprResult RebuildArraySectionExpr(bool IsOMPArraySection, Expr *Base, SourceLocation LBracketLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBracketLoc)
Build a new array section expression.
concepts::ExprRequirement * TransformExprRequirement(concepts::ExprRequirement *Req)
QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc, TypeOfKind Kind)
Build a new typeof(expr) type.
bool ReplacingOriginal()
Whether the transformation is forming an expression or statement that replaces the original.
OMPClause * RebuildOMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'flush' pseudo clause.
bool TransformTemplateArgument(const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output, bool Uneval=false)
Transform the given template argument.
ExprResult RebuildArraySubscriptExpr(Expr *LHS, SourceLocation LBracketLoc, Expr *RHS, SourceLocation RBracketLoc)
Build a new array subscript expression.
OMPClause * RebuildOMPReductionClause(ArrayRef< Expr * > VarList, OpenMPReductionClauseModifier Modifier, OpenMPOriginalSharingModifier OriginalSharingModifier, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'reduction' clause.
QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements, SourceLocation AttributeLoc)
Build a new extended vector type given the element type and number of elements.
void transformedLocalDecl(Decl *Old, ArrayRef< Decl * > New)
Note that a local declaration has been transformed by this transformer.
ExprResult RebuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
Build a new Objective-C boxed expression.
ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub, bool IsThrownVariableInScope)
Build a new C++ throw expression.
bool TransformRequiresExprRequirements(ArrayRef< concepts::Requirement * > Reqs, llvm::SmallVectorImpl< concepts::Requirement * > &Transformed)
TemplateName TransformTemplateName(NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc, TemplateName Name, SourceLocation NameLoc, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr, bool AllowInjectedClassName=false)
Transform the given template name.
bool DropCallArgument(Expr *E)
Determine whether the given call argument should be dropped, e.g., because it is a default argument.
StmtResult RebuildGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new goto statement.
OMPClause * RebuildOMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'private' clause.
ExprResult RebuildObjCPropertyRefExpr(Expr *Base, QualType T, ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
ExprResult RebuildRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation ClosingBraceLoc)
Build a new requires expression.
ExprResult RebuildExpressionTrait(ExpressionTrait Trait, SourceLocation StartLoc, Expr *Queried, SourceLocation RParenLoc)
Build a new expression trait expression.
OMPClause * RebuildOMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'doacross' clause.
OMPClause * RebuildOMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'final' clause.
StmtResult RebuildIfStmt(SourceLocation IfLoc, IfStatementKind Kind, SourceLocation LParenLoc, Sema::ConditionResult Cond, SourceLocation RParenLoc, Stmt *Init, Stmt *Then, SourceLocation ElseLoc, Stmt *Else)
Build a new "if" statement.
OMPClause * RebuildOMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'from' clause.
bool TransformConceptTemplateArguments(InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs, bool Uneval=false)
TypeLoc getTypeLocInContext(ASTContext &Context, QualType T)
Copies the type-location information to the given AST context and returns a TypeLoc referring into th...
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
void TypeWasModifiedSafely(QualType T)
Tell the TypeLocBuilder that the type it is storing has been modified in some safe way that doesn't a...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
Definition TypeLoc.h:59
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition TypeLoc.h:349
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition TypeLoc.h:133
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition TypeLoc.h:89
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition TypeLoc.h:78
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition TypeLoc.h:154
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition TypeLoc.h:165
TypeLocClass getTypeLocClass() const
Definition TypeLoc.h:116
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition TypeLoc.h:2735
SourceLocation getBeginLoc() const
Get the begin source location.
Definition TypeLoc.cpp:193
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Definition TypeBase.h:6280
A container of type source information.
Definition TypeBase.h:8416
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition TypeLoc.h:267
QualType getType() const
Return the type wrapped by this type source info.
Definition TypeBase.h:8427
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:551
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition ExprCXX.h:2900
The base class of the type hierarchy.
Definition TypeBase.h:1875
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition TypeBase.h:2465
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition TypeBase.h:9198
bool isObjCObjectPointerType() const
Definition TypeBase.h:8861
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9275
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3580
Wrapper for source info for typedefs.
Definition TypeLoc.h:777
void setTypeofLoc(SourceLocation Loc)
Definition TypeLoc.h:2200
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2628
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2247
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition Expr.h:2292
Expr * getSubExpr() const
Definition Expr.h:2288
Opcode getOpcode() const
Definition Expr.h:2283
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:1420
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2344
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:1035
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3390
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition ExprCXX.h:3464
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition ExprCXX.h:3459
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Definition ExprCXX.cpp:437
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4126
A set of unresolved declarations.
void append(iterator I, iterator E)
A set of unresolved declarations.
Wrapper for source info for unresolved typename using decls.
Definition TypeLoc.h:782
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition TypeBase.h:6085
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition ExprCXX.h:644
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3404
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3468
Wrapper for source info for types used via transparent aliases.
Definition TypeLoc.h:785
Represents a call to the builtin function __builtin_va_arg.
Definition Expr.h:4960
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
QualType getType() const
Definition Decl.h:723
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Definition Decl.cpp:5588
Value()=default
Represents a variable declaration or definition.
Definition Decl.h:924
@ CInit
C-style initialization with assignment.
Definition Decl.h:929
@ CallInit
Call-style initialization (C++98)
Definition Decl.h:932
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1166
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:4028
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2045
Represents a GCC generic vector type.
Definition TypeBase.h:4237
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2707
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
SourceLocation getNoexceptLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
Retains information about a block that is currently being parsed.
Definition ScopeInfo.h:794
bool ContainsUnexpandedParameterPack
Whether this contains an unexpanded parameter pack.
Definition ScopeInfo.h:732
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition ScopeInfo.h:875
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Definition ScopeInfo.h:878
@ 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:1160
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:944
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OpenMPOriginalSharingModifier
OpenMP 6.0 original sharing modifiers.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
OpenACCDirectiveKind
bool isa(CodeGen::Address addr)
Definition Address.h:330
ArrayTypeTrait
Names for the array type traits.
Definition TypeTraits.h:42
@ CPlusPlus23
OpenACCAtomicKind
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition TypeBase.h:1834
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
TryCaptureKind
Definition Sema.h:653
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
Definition Lookup.h:64
@ NotFound
No entity found met the criteria.
Definition Lookup.h:41
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
Definition Lookup.h:54
@ Found
Name lookup found a single declaration that met the criteria.
Definition Lookup.h:50
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
Definition Lookup.h:59
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Definition Lookup.h:46
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
Definition Specifiers.h:40
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:61
CXXConstructionKind
Definition ExprCXX.h:1544
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
Definition Specifiers.h:162
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
Definition Lambda.h:36
@ LCK_ByRef
Capturing by reference.
Definition Lambda.h:37
@ LCK_StarThis
Capturing the *this object by copy.
Definition Lambda.h:35
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition Sema.h:604
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
Definition Sema.h:238
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ Detach
'detach' clause, allowed on the 'exit data' construct.
TypeOfKind
The kind of 'typeof' expression we're after.
Definition TypeBase.h:918
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
Definition OpenMPKinds.h:39
OpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
Expr * Cond
};
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
Definition Parser.h:142
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition TypeTraits.h:51
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
ExprResult ExprEmpty()
Definition Ownership.h:272
OpenMPDynGroupprivateClauseFallbackModifier
MutableArrayRef< Expr * > MultiExprArg
Definition Ownership.h:259
StmtResult StmtError()
Definition Ownership.h:266
@ Property
The type of a property.
Definition TypeBase.h:911
@ Result
The result type of a method or function.
Definition TypeBase.h:905
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3781
OptionalUnsigned< unsigned > UnsignedOrNone
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
@ Template
We are parsing a template declaration.
Definition Parser.h:81
ActionResult< CXXBaseSpecifier * > BaseResult
Definition Ownership.h:252
OpenMPGrainsizeClauseModifier
OpenMPNumTasksClauseModifier
TagTypeKind
The kind of a tag type.
Definition TypeBase.h:5993
bool transformOMPMappableExprListClause(TreeTransform< Derived > &TT, OMPMappableExprListClause< T > *C, llvm::SmallVectorImpl< Expr * > &Vars, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperIdInfo, llvm::SmallVectorImpl< Expr * > &UnresolvedMappers)
OpenMPUseDevicePtrFallbackModifier
OpenMP 6.1 use_device_ptr fallback modifier.
ExprResult ExprError()
Definition Ownership.h:265
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:562
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
DeducedKind
Definition TypeBase.h:1807
@ Deduced
The normal deduced case.
Definition TypeBase.h:1814
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
Definition TypeBase.h:1809
std::tuple< NamedDecl *, TemplateArgument > getReplacedTemplateParameter(Decl *D, unsigned Index)
Internal helper used by Subst* nodes to retrieve a parameter from the AssociatedDecl,...
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
OpenMPAllocateClauseModifier
OpenMP modifiers for 'allocate' clause.
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition OpenMPKinds.h:63
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition OpenMPKinds.h:25
OpenMPDynGroupprivateClauseModifier
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:136
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition Specifiers.h:140
@ Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition Sema.h:812
@ Exists
The symbol exists.
Definition Sema.h:805
@ Error
An error occurred.
Definition Sema.h:815
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:808
MutableArrayRef< Stmt * > MultiStmtArg
Definition Ownership.h:260
OpenMPNumThreadsClauseModifier
U cast(CodeGen::Address addr)
Definition Address.h:327
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition OpenMPKinds.h:48
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition Ownership.h:230
SourceLocIdentKind
Definition Expr.h:5007
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5968
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5989
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5979
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5986
ActionResult< Expr * > ExprResult
Definition Ownership.h:249
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
TypeTrait
Names for traits that operate specifically on types.
Definition TypeTraits.h:21
@ Parens
New-expression has a C++98 paren-delimited initializer.
Definition ExprCXX.h:2249
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Uninstantiated
not instantiated yet
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition Expr.h:1992
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition OpenMPKinds.h:31
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition OpenMPKinds.h:71
Expr * AllocatorTraits
Allocator traits.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition ASTConcept.h:91
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:89
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
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:5106
Holds information about the various types of exception specification.
Definition TypeBase.h:5426
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5442
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5428
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5431
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5434
Extra information about a function prototype.
Definition TypeBase.h:5454
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5459
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
Definition Type.cpp:3398
const NamespaceBaseDecl * Namespace
Iterator range representation begin:end[:step].
Definition ExprOpenMP.h:154
This structure contains most locations needed for by an OMPVarListClause.
An element in an Objective-C dictionary literal.
Definition ExprObjC.h:295
Data for list of allocators.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition Sema.h:13201
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13232
An RAII helper that pops function a function scope on exit.
Definition Sema.h:1330
Keeps information about an identifier in a nested-name-spec.
Definition Sema.h:3326
Location information for a TemplateArgument.
UnsignedOrNone OrigNumExpansions
SourceLocation Ellipsis
UnsignedOrNone NumExpansions