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
843
848
850
852 bool IsAddressOfOperand,
853 TypeSourceInfo **RecoveryTSI);
854
856 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
857 TypeSourceInfo **RecoveryTSI);
858
860 bool IsAddressOfOperand);
861
863
865
866// FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
867// amount of stack usage with clang.
868#define STMT(Node, Parent) \
869 LLVM_ATTRIBUTE_NOINLINE \
870 StmtResult Transform##Node(Node *S);
871#define VALUESTMT(Node, Parent) \
872 LLVM_ATTRIBUTE_NOINLINE \
873 StmtResult Transform##Node(Node *S, StmtDiscardKind SDK);
874#define EXPR(Node, Parent) \
875 LLVM_ATTRIBUTE_NOINLINE \
876 ExprResult Transform##Node(Node *E);
877#define ABSTRACT_STMT(Stmt)
878#include "clang/AST/StmtNodes.inc"
879
880#define GEN_CLANG_CLAUSE_CLASS
881#define CLAUSE_CLASS(Enum, Str, Class) \
882 LLVM_ATTRIBUTE_NOINLINE \
883 OMPClause *Transform##Class(Class *S);
884#include "llvm/Frontend/OpenMP/OMP.inc"
885
886 /// Build a new qualified type given its unqualified type and type location.
887 ///
888 /// By default, this routine adds type qualifiers only to types that can
889 /// have qualifiers, and silently suppresses those qualifiers that are not
890 /// permitted. Subclasses may override this routine to provide different
891 /// behavior.
893
894 /// Build a new pointer type given its pointee type.
895 ///
896 /// By default, performs semantic analysis when building the pointer type.
897 /// Subclasses may override this routine to provide different behavior.
899
900 /// Build a new block pointer type given its pointee type.
901 ///
902 /// By default, performs semantic analysis when building the block pointer
903 /// type. Subclasses may override this routine to provide different behavior.
905
906 /// Build a new reference type given the type it references.
907 ///
908 /// By default, performs semantic analysis when building the
909 /// reference type. Subclasses may override this routine to provide
910 /// different behavior.
911 ///
912 /// \param LValue whether the type was written with an lvalue sigil
913 /// or an rvalue sigil.
915 bool LValue,
916 SourceLocation Sigil);
917
918 /// Build a new member pointer type given the pointee type and the
919 /// qualifier it refers into.
920 ///
921 /// By default, performs semantic analysis when building the member pointer
922 /// type. Subclasses may override this routine to provide different behavior.
924 const CXXScopeSpec &SS, CXXRecordDecl *Cls,
925 SourceLocation Sigil);
926
928 SourceLocation ProtocolLAngleLoc,
930 ArrayRef<SourceLocation> ProtocolLocs,
931 SourceLocation ProtocolRAngleLoc);
932
933 /// Build an Objective-C object type.
934 ///
935 /// By default, performs semantic analysis when building the object type.
936 /// Subclasses may override this routine to provide different behavior.
938 SourceLocation Loc,
939 SourceLocation TypeArgsLAngleLoc,
941 SourceLocation TypeArgsRAngleLoc,
942 SourceLocation ProtocolLAngleLoc,
944 ArrayRef<SourceLocation> ProtocolLocs,
945 SourceLocation ProtocolRAngleLoc);
946
947 /// Build a new Objective-C object pointer type given the pointee type.
948 ///
949 /// By default, directly builds the pointer type, with no additional semantic
950 /// analysis.
953
954 /// Build a new array type given the element type, size
955 /// modifier, size of the array (if known), size expression, and index type
956 /// qualifiers.
957 ///
958 /// By default, performs semantic analysis when building the array type.
959 /// Subclasses may override this routine to provide different behavior.
960 /// Also by default, all of the other Rebuild*Array
962 const llvm::APInt *Size, Expr *SizeExpr,
963 unsigned IndexTypeQuals, SourceRange BracketsRange);
964
965 /// Build a new constant array type given the element type, size
966 /// modifier, (known) size of the array, and index type qualifiers.
967 ///
968 /// By default, performs semantic analysis when building the array type.
969 /// Subclasses may override this routine to provide different behavior.
971 ArraySizeModifier SizeMod,
972 const llvm::APInt &Size, Expr *SizeExpr,
973 unsigned IndexTypeQuals,
974 SourceRange BracketsRange);
975
976 /// Build a new incomplete array type given the element type, size
977 /// modifier, and index type qualifiers.
978 ///
979 /// By default, performs semantic analysis when building the array type.
980 /// Subclasses may override this routine to provide different behavior.
982 ArraySizeModifier SizeMod,
983 unsigned IndexTypeQuals,
984 SourceRange BracketsRange);
985
986 /// Build a new variable-length array type given the element type,
987 /// size modifier, size expression, and index type qualifiers.
988 ///
989 /// By default, performs semantic analysis when building the array type.
990 /// Subclasses may override this routine to provide different behavior.
992 ArraySizeModifier SizeMod, Expr *SizeExpr,
993 unsigned IndexTypeQuals,
994 SourceRange BracketsRange);
995
996 /// Build a new dependent-sized array type given the element type,
997 /// size modifier, size expression, and index type qualifiers.
998 ///
999 /// By default, performs semantic analysis when building the array type.
1000 /// Subclasses may override this routine to provide different behavior.
1002 ArraySizeModifier SizeMod,
1003 Expr *SizeExpr,
1004 unsigned IndexTypeQuals,
1005 SourceRange BracketsRange);
1006
1007 /// Build a new vector type given the element type and
1008 /// number of elements.
1009 ///
1010 /// By default, performs semantic analysis when building the vector type.
1011 /// Subclasses may override this routine to provide different behavior.
1012 QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
1013 VectorKind VecKind);
1014
1015 /// Build a new potentially dependently-sized extended vector type
1016 /// given the element type and number of elements.
1017 ///
1018 /// By default, performs semantic analysis when building the vector type.
1019 /// Subclasses may override this routine to provide different behavior.
1021 SourceLocation AttributeLoc, VectorKind);
1022
1023 /// Build a new extended vector type given the element type and
1024 /// number of elements.
1025 ///
1026 /// By default, performs semantic analysis when building the vector type.
1027 /// Subclasses may override this routine to provide different behavior.
1028 QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
1029 SourceLocation AttributeLoc);
1030
1031 /// Build a new potentially dependently-sized extended vector type
1032 /// given the element type and number of elements.
1033 ///
1034 /// By default, performs semantic analysis when building the vector type.
1035 /// Subclasses may override this routine to provide different behavior.
1037 Expr *SizeExpr,
1038 SourceLocation AttributeLoc);
1039
1040 /// Build a new matrix type given the element type and dimensions.
1041 QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows,
1042 unsigned NumColumns);
1043
1044 /// Build a new matrix type given the type and dependently-defined
1045 /// dimensions.
1047 Expr *ColumnExpr,
1048 SourceLocation AttributeLoc);
1049
1050 /// Build a new DependentAddressSpaceType or return the pointee
1051 /// type variable with the correct address space (retrieved from
1052 /// AddrSpaceExpr) applied to it. The former will be returned in cases
1053 /// where the address space remains dependent.
1054 ///
1055 /// By default, performs semantic analysis when building the type with address
1056 /// space applied. Subclasses may override this routine to provide different
1057 /// behavior.
1059 Expr *AddrSpaceExpr,
1060 SourceLocation AttributeLoc);
1061
1062 /// Build a new function type.
1063 ///
1064 /// By default, performs semantic analysis when building the function type.
1065 /// Subclasses may override this routine to provide different behavior.
1067 MutableArrayRef<QualType> ParamTypes,
1069
1070 /// Build a new unprototyped function type.
1072
1073 /// Rebuild an unresolved typename type, given the decl that
1074 /// the UnresolvedUsingTypenameDecl was transformed to.
1076 NestedNameSpecifier Qualifier,
1077 SourceLocation NameLoc, Decl *D);
1078
1079 /// Build a new type found via an alias.
1082 QualType UnderlyingType) {
1083 return SemaRef.Context.getUsingType(Keyword, Qualifier, D, UnderlyingType);
1084 }
1085
1086 /// Build a new typedef type.
1088 NestedNameSpecifier Qualifier,
1090 return SemaRef.Context.getTypedefType(Keyword, Qualifier, Typedef);
1091 }
1092
1093 /// Build a new MacroDefined type.
1095 const IdentifierInfo *MacroII) {
1096 return SemaRef.Context.getMacroQualifiedType(T, MacroII);
1097 }
1098
1099 /// Build a new class/struct/union/enum type.
1101 NestedNameSpecifier Qualifier, TagDecl *Tag) {
1102 return SemaRef.Context.getTagType(Keyword, Qualifier, Tag,
1103 /*OwnsTag=*/false);
1104 }
1106 return SemaRef.Context.getCanonicalTagType(Tag);
1107 }
1108
1109 /// Build a new typeof(expr) type.
1110 ///
1111 /// By default, performs semantic analysis when building the typeof type.
1112 /// Subclasses may override this routine to provide different behavior.
1114 TypeOfKind Kind);
1115
1116 /// Build a new typeof(type) type.
1117 ///
1118 /// By default, builds a new TypeOfType with the given underlying type.
1120
1121 /// Build a new unary transform type.
1123 UnaryTransformType::UTTKind UKind,
1124 SourceLocation Loc);
1125
1126 /// Build a new C++11 decltype type.
1127 ///
1128 /// By default, performs semantic analysis when building the decltype type.
1129 /// Subclasses may override this routine to provide different behavior.
1131
1133 SourceLocation Loc,
1134 SourceLocation EllipsisLoc,
1135 bool FullySubstituted,
1136 ArrayRef<QualType> Expansions = {});
1137
1138 /// Build a new C++11 auto type.
1139 ///
1140 /// By default, builds a new AutoType with the given deduced type.
1143 ConceptDecl *TypeConstraintConcept,
1144 ArrayRef<TemplateArgument> TypeConstraintArgs) {
1145 return SemaRef.Context.getAutoType(
1146 DK, DeducedAsType, Keyword, TypeConstraintConcept, TypeConstraintArgs);
1147 }
1148
1149 /// By default, builds a new DeducedTemplateSpecializationType with the given
1150 /// deduced type.
1154 return SemaRef.Context.getDeducedTemplateSpecializationType(
1155 DK, DeducedAsType, Keyword, Template);
1156 }
1157
1158 /// Build a new template specialization type.
1159 ///
1160 /// By default, performs semantic analysis when building the template
1161 /// specialization type. Subclasses may override this routine to provide
1162 /// different behavior.
1165 SourceLocation TemplateLoc,
1167
1168 /// Build a new parenthesized type.
1169 ///
1170 /// By default, builds a new ParenType type from the inner type.
1171 /// Subclasses may override this routine to provide different behavior.
1173 return SemaRef.BuildParenType(InnerType);
1174 }
1175
1176 /// Build a new typename type that refers to an identifier.
1177 ///
1178 /// By default, performs semantic analysis when building the typename type
1179 /// (or elaborated type). Subclasses may override this routine to provide
1180 /// different behavior.
1182 SourceLocation KeywordLoc,
1183 NestedNameSpecifierLoc QualifierLoc,
1184 const IdentifierInfo *Id,
1185 SourceLocation IdLoc,
1186 bool DeducedTSTContext) {
1187 CXXScopeSpec SS;
1188 SS.Adopt(QualifierLoc);
1189
1190 if (QualifierLoc.getNestedNameSpecifier().isDependent()) {
1191 // If the name is still dependent, just build a new dependent name type.
1192 if (!SemaRef.computeDeclContext(SS))
1193 return SemaRef.Context.getDependentNameType(Keyword,
1194 QualifierLoc.getNestedNameSpecifier(),
1195 Id);
1196 }
1197
1200 return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1201 *Id, IdLoc, DeducedTSTContext);
1202 }
1203
1205
1206 // We had a dependent elaborated-type-specifier that has been transformed
1207 // into a non-dependent elaborated-type-specifier. Find the tag we're
1208 // referring to.
1210 DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1211 if (!DC)
1212 return QualType();
1213
1214 if (SemaRef.RequireCompleteDeclContext(SS, DC))
1215 return QualType();
1216
1217 TagDecl *Tag = nullptr;
1218 SemaRef.LookupQualifiedName(Result, DC);
1219 switch (Result.getResultKind()) {
1222 break;
1223
1225 Tag = Result.getAsSingle<TagDecl>();
1226 break;
1227
1230 llvm_unreachable("Tag lookup cannot find non-tags");
1231
1233 // Let the LookupResult structure handle ambiguities.
1234 return QualType();
1235 }
1236
1237 if (!Tag) {
1238 // Check where the name exists but isn't a tag type and use that to emit
1239 // better diagnostics.
1241 SemaRef.LookupQualifiedName(Result, DC);
1242 switch (Result.getResultKind()) {
1246 NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1247 NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1248 SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag)
1249 << SomeDecl << NTK << Kind;
1250 SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1251 break;
1252 }
1253 default:
1254 SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1255 << Kind << Id << DC << QualifierLoc.getSourceRange();
1256 break;
1257 }
1258 return QualType();
1259 }
1260 if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1261 IdLoc, Id)) {
1262 SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1263 SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1264 return QualType();
1265 }
1266 return getDerived().RebuildTagType(
1267 Keyword, QualifierLoc.getNestedNameSpecifier(), Tag);
1268 }
1269
1270 /// Build a new pack expansion type.
1271 ///
1272 /// By default, builds a new PackExpansionType type from the given pattern.
1273 /// Subclasses may override this routine to provide different behavior.
1275 SourceLocation EllipsisLoc,
1276 UnsignedOrNone NumExpansions) {
1277 return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1278 NumExpansions);
1279 }
1280
1281 /// Build a new atomic type given its value type.
1282 ///
1283 /// By default, performs semantic analysis when building the atomic type.
1284 /// Subclasses may override this routine to provide different behavior.
1286
1287 /// Build a new pipe type given its value type.
1289 bool isReadPipe);
1290
1291 /// Build a bit-precise int given its value type.
1292 QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits,
1293 SourceLocation Loc);
1294
1295 /// Build a dependent bit-precise int given its value type.
1296 QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
1297 SourceLocation Loc);
1298
1299 /// Build a new template name given a nested name specifier, a flag
1300 /// indicating whether the "template" keyword was provided, and the template
1301 /// that the template name refers to.
1302 ///
1303 /// By default, builds the new template name directly. Subclasses may override
1304 /// this routine to provide different behavior.
1306 TemplateName Name);
1307
1308 /// Build a new template name given a nested name specifier and the
1309 /// name that is referred to as a template.
1310 ///
1311 /// By default, performs semantic analysis to determine whether the name can
1312 /// be resolved to a specific template, then builds the appropriate kind of
1313 /// template name. Subclasses may override this routine to provide different
1314 /// behavior.
1316 SourceLocation TemplateKWLoc,
1317 const IdentifierInfo &Name,
1318 SourceLocation NameLoc, QualType ObjectType,
1319 bool AllowInjectedClassName);
1320
1321 /// Build a new template name given a nested name specifier and the
1322 /// overloaded operator name that is referred to as a template.
1323 ///
1324 /// By default, performs semantic analysis to determine whether the name can
1325 /// be resolved to a specific template, then builds the appropriate kind of
1326 /// template name. Subclasses may override this routine to provide different
1327 /// behavior.
1329 SourceLocation TemplateKWLoc,
1330 OverloadedOperatorKind Operator,
1331 SourceLocation NameLoc, QualType ObjectType,
1332 bool AllowInjectedClassName);
1333
1335 SourceLocation TemplateKWLoc,
1337 SourceLocation NameLoc, QualType ObjectType,
1338 bool AllowInjectedClassName);
1339
1340 /// Build a new template name given a template template parameter pack
1341 /// and the
1342 ///
1343 /// By default, performs semantic analysis to determine whether the name can
1344 /// be resolved to a specific template, then builds the appropriate kind of
1345 /// template name. Subclasses may override this routine to provide different
1346 /// behavior.
1348 Decl *AssociatedDecl, unsigned Index,
1349 bool Final) {
1351 ArgPack, AssociatedDecl, Index, Final);
1352 }
1353
1354 /// Build a new compound statement.
1355 ///
1356 /// By default, performs semantic analysis to build the new statement.
1357 /// Subclasses may override this routine to provide different behavior.
1359 MultiStmtArg Statements,
1360 SourceLocation RBraceLoc,
1361 bool IsStmtExpr) {
1362 return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1363 IsStmtExpr);
1364 }
1365
1366 /// Build a new case statement.
1367 ///
1368 /// By default, performs semantic analysis to build the new statement.
1369 /// Subclasses may override this routine to provide different behavior.
1371 Expr *LHS,
1372 SourceLocation EllipsisLoc,
1373 Expr *RHS,
1374 SourceLocation ColonLoc) {
1375 return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1376 ColonLoc);
1377 }
1378
1379 /// Attach the body to a new case statement.
1380 ///
1381 /// By default, performs semantic analysis to build the new statement.
1382 /// Subclasses may override this routine to provide different behavior.
1384 getSema().ActOnCaseStmtBody(S, Body);
1385 return S;
1386 }
1387
1388 /// Build a new default statement.
1389 ///
1390 /// By default, performs semantic analysis to build the new statement.
1391 /// Subclasses may override this routine to provide different behavior.
1393 SourceLocation ColonLoc,
1394 Stmt *SubStmt) {
1395 return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1396 /*CurScope=*/nullptr);
1397 }
1398
1399 /// Build a new label statement.
1400 ///
1401 /// By default, performs semantic analysis to build the new statement.
1402 /// Subclasses may override this routine to provide different behavior.
1404 SourceLocation ColonLoc, Stmt *SubStmt) {
1405 return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1406 }
1407
1408 /// Build a new attributed statement.
1409 ///
1410 /// By default, performs semantic analysis to build the new statement.
1411 /// Subclasses may override this routine to provide different behavior.
1414 Stmt *SubStmt) {
1415 if (SemaRef.CheckRebuiltStmtAttributes(Attrs))
1416 return StmtError();
1417 return SemaRef.BuildAttributedStmt(AttrLoc, Attrs, SubStmt);
1418 }
1419
1420 /// Build a new "if" statement.
1421 ///
1422 /// By default, performs semantic analysis to build the new statement.
1423 /// Subclasses may override this routine to provide different behavior.
1426 SourceLocation RParenLoc, Stmt *Init, Stmt *Then,
1427 SourceLocation ElseLoc, Stmt *Else) {
1428 return getSema().ActOnIfStmt(IfLoc, Kind, LParenLoc, Init, Cond, RParenLoc,
1429 Then, ElseLoc, Else);
1430 }
1431
1432 /// Start building a new switch statement.
1433 ///
1434 /// By default, performs semantic analysis to build the new statement.
1435 /// Subclasses may override this routine to provide different behavior.
1437 SourceLocation LParenLoc, Stmt *Init,
1439 SourceLocation RParenLoc) {
1440 return getSema().ActOnStartOfSwitchStmt(SwitchLoc, LParenLoc, Init, Cond,
1441 RParenLoc);
1442 }
1443
1444 /// Attach the body to the switch statement.
1445 ///
1446 /// By default, performs semantic analysis to build the new statement.
1447 /// Subclasses may override this routine to provide different behavior.
1449 Stmt *Switch, Stmt *Body) {
1450 return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1451 }
1452
1453 /// Build a new while statement.
1454 ///
1455 /// By default, performs semantic analysis to build the new statement.
1456 /// Subclasses may override this routine to provide different behavior.
1459 SourceLocation RParenLoc, Stmt *Body) {
1460 return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body);
1461 }
1462
1463 /// Build a new do-while statement.
1464 ///
1465 /// By default, performs semantic analysis to build the new statement.
1466 /// Subclasses may override this routine to provide different behavior.
1468 SourceLocation WhileLoc, SourceLocation LParenLoc,
1469 Expr *Cond, SourceLocation RParenLoc) {
1470 return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1471 Cond, RParenLoc);
1472 }
1473
1474 /// Build a new for statement.
1475 ///
1476 /// By default, performs semantic analysis to build the new statement.
1477 /// Subclasses may override this routine to provide different behavior.
1480 Sema::FullExprArg Inc, SourceLocation RParenLoc,
1481 Stmt *Body) {
1482 return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1483 Inc, RParenLoc, Body);
1484 }
1485
1486 /// Build a new goto statement.
1487 ///
1488 /// By default, performs semantic analysis to build the new statement.
1489 /// Subclasses may override this routine to provide different behavior.
1491 LabelDecl *Label) {
1492 return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1493 }
1494
1495 /// Build a new indirect goto statement.
1496 ///
1497 /// By default, performs semantic analysis to build the new statement.
1498 /// Subclasses may override this routine to provide different behavior.
1500 SourceLocation StarLoc,
1501 Expr *Target) {
1502 return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1503 }
1504
1505 /// Build a new return statement.
1506 ///
1507 /// By default, performs semantic analysis to build the new statement.
1508 /// Subclasses may override this routine to provide different behavior.
1510 return getSema().BuildReturnStmt(ReturnLoc, Result);
1511 }
1512
1513 /// Build a new declaration statement.
1514 ///
1515 /// By default, performs semantic analysis to build the new statement.
1516 /// Subclasses may override this routine to provide different behavior.
1518 SourceLocation StartLoc, SourceLocation EndLoc) {
1520 return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1521 }
1522
1523 /// Build a new inline asm statement.
1524 ///
1525 /// By default, performs semantic analysis to build the new statement.
1526 /// Subclasses may override this routine to provide different behavior.
1528 bool IsVolatile, unsigned NumOutputs,
1529 unsigned NumInputs, IdentifierInfo **Names,
1530 MultiExprArg Constraints, MultiExprArg Exprs,
1531 Expr *AsmString, MultiExprArg Clobbers,
1532 unsigned NumLabels,
1533 SourceLocation RParenLoc) {
1534 return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1535 NumInputs, Names, Constraints, Exprs,
1536 AsmString, Clobbers, NumLabels, RParenLoc);
1537 }
1538
1539 /// Build a new MS style inline asm statement.
1540 ///
1541 /// By default, performs semantic analysis to build the new statement.
1542 /// Subclasses may override this routine to provide different behavior.
1544 ArrayRef<Token> AsmToks,
1545 StringRef AsmString,
1546 unsigned NumOutputs, unsigned NumInputs,
1547 ArrayRef<StringRef> Constraints,
1548 ArrayRef<StringRef> Clobbers,
1549 ArrayRef<Expr*> Exprs,
1550 SourceLocation EndLoc) {
1551 return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1552 NumOutputs, NumInputs,
1553 Constraints, Clobbers, Exprs, EndLoc);
1554 }
1555
1556 /// Build a new co_return statement.
1557 ///
1558 /// By default, performs semantic analysis to build the new statement.
1559 /// Subclasses may override this routine to provide different behavior.
1561 bool IsImplicit) {
1562 return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1563 }
1564
1565 /// Build a new co_await expression.
1566 ///
1567 /// By default, performs semantic analysis to build the new expression.
1568 /// Subclasses may override this routine to provide different behavior.
1570 UnresolvedLookupExpr *OpCoawaitLookup,
1571 bool IsImplicit) {
1572 // This function rebuilds a coawait-expr given its operator.
1573 // For an explicit coawait-expr, the rebuild involves the full set
1574 // of transformations performed by BuildUnresolvedCoawaitExpr(),
1575 // including calling await_transform().
1576 // For an implicit coawait-expr, we need to rebuild the "operator
1577 // coawait" but not await_transform(), so use BuildResolvedCoawaitExpr().
1578 // This mirrors how the implicit CoawaitExpr is originally created
1579 // in Sema::ActOnCoroutineBodyStart().
1580 if (IsImplicit) {
1582 CoawaitLoc, Operand, OpCoawaitLookup);
1583 if (Suspend.isInvalid())
1584 return ExprError();
1585 return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Operand,
1586 Suspend.get(), true);
1587 }
1588
1589 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Operand,
1590 OpCoawaitLookup);
1591 }
1592
1593 /// Build a new co_await expression.
1594 ///
1595 /// By default, performs semantic analysis to build the new expression.
1596 /// Subclasses may override this routine to provide different behavior.
1598 Expr *Result,
1599 UnresolvedLookupExpr *Lookup) {
1600 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1601 }
1602
1603 /// Build a new co_yield expression.
1604 ///
1605 /// By default, performs semantic analysis to build the new expression.
1606 /// Subclasses may override this routine to provide different behavior.
1608 return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1609 }
1610
1614
1615 /// Build a new Objective-C \@try statement.
1616 ///
1617 /// By default, performs semantic analysis to build the new statement.
1618 /// Subclasses may override this routine to provide different behavior.
1620 Stmt *TryBody,
1621 MultiStmtArg CatchStmts,
1622 Stmt *Finally) {
1623 return getSema().ObjC().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1624 Finally);
1625 }
1626
1627 /// Rebuild an Objective-C exception declaration.
1628 ///
1629 /// By default, performs semantic analysis to build the new declaration.
1630 /// Subclasses may override this routine to provide different behavior.
1632 TypeSourceInfo *TInfo, QualType T) {
1634 TInfo, T, ExceptionDecl->getInnerLocStart(),
1635 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
1636 }
1637
1638 /// Build a new Objective-C \@catch statement.
1639 ///
1640 /// By default, performs semantic analysis to build the new statement.
1641 /// Subclasses may override this routine to provide different behavior.
1643 SourceLocation RParenLoc,
1644 VarDecl *Var,
1645 Stmt *Body) {
1646 return getSema().ObjC().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, Var, Body);
1647 }
1648
1649 /// Build a new Objective-C \@finally statement.
1650 ///
1651 /// By default, performs semantic analysis to build the new statement.
1652 /// Subclasses may override this routine to provide different behavior.
1654 Stmt *Body) {
1655 return getSema().ObjC().ActOnObjCAtFinallyStmt(AtLoc, Body);
1656 }
1657
1658 /// Build a new Objective-C \@throw statement.
1659 ///
1660 /// By default, performs semantic analysis to build the new statement.
1661 /// Subclasses may override this routine to provide different behavior.
1663 Expr *Operand) {
1664 return getSema().ObjC().BuildObjCAtThrowStmt(AtLoc, Operand);
1665 }
1666
1667 /// Build a new OpenMP Canonical loop.
1668 ///
1669 /// Ensures that the outermost loop in @p LoopStmt is wrapped by a
1670 /// OMPCanonicalLoop.
1672 return getSema().OpenMP().ActOnOpenMPCanonicalLoop(LoopStmt);
1673 }
1674
1675 /// Build a new OpenMP executable directive.
1676 ///
1677 /// By default, performs semantic analysis to build the new statement.
1678 /// Subclasses may override this routine to provide different behavior.
1680 DeclarationNameInfo DirName,
1681 OpenMPDirectiveKind CancelRegion,
1682 ArrayRef<OMPClause *> Clauses,
1683 Stmt *AStmt, SourceLocation StartLoc,
1684 SourceLocation EndLoc) {
1685
1687 Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1688 }
1689
1690 /// Build a new OpenMP informational directive.
1692 DeclarationNameInfo DirName,
1693 ArrayRef<OMPClause *> Clauses,
1694 Stmt *AStmt,
1695 SourceLocation StartLoc,
1696 SourceLocation EndLoc) {
1697
1699 Kind, DirName, Clauses, AStmt, StartLoc, EndLoc);
1700 }
1701
1702 /// Build a new OpenMP 'if' clause.
1703 ///
1704 /// By default, performs semantic analysis to build the new OpenMP clause.
1705 /// Subclasses may override this routine to provide different behavior.
1707 Expr *Condition, SourceLocation StartLoc,
1708 SourceLocation LParenLoc,
1709 SourceLocation NameModifierLoc,
1710 SourceLocation ColonLoc,
1711 SourceLocation EndLoc) {
1713 NameModifier, Condition, StartLoc, LParenLoc, NameModifierLoc, ColonLoc,
1714 EndLoc);
1715 }
1716
1717 /// Build a new OpenMP 'final' clause.
1718 ///
1719 /// By default, performs semantic analysis to build the new OpenMP clause.
1720 /// Subclasses may override this routine to provide different behavior.
1722 SourceLocation LParenLoc,
1723 SourceLocation EndLoc) {
1724 return getSema().OpenMP().ActOnOpenMPFinalClause(Condition, StartLoc,
1725 LParenLoc, EndLoc);
1726 }
1727
1728 /// Build a new OpenMP 'num_threads' clause.
1729 ///
1730 /// By default, performs semantic analysis to build the new OpenMP clause.
1731 /// Subclasses may override this routine to provide different behavior.
1733 Expr *NumThreads,
1734 SourceLocation StartLoc,
1735 SourceLocation LParenLoc,
1736 SourceLocation ModifierLoc,
1737 SourceLocation EndLoc) {
1739 Modifier, NumThreads, StartLoc, LParenLoc, ModifierLoc, EndLoc);
1740 }
1741
1742 /// Build a new OpenMP 'safelen' clause.
1743 ///
1744 /// By default, performs semantic analysis to build the new OpenMP clause.
1745 /// Subclasses may override this routine to provide different behavior.
1747 SourceLocation LParenLoc,
1748 SourceLocation EndLoc) {
1749 return getSema().OpenMP().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc,
1750 EndLoc);
1751 }
1752
1753 /// Build a new OpenMP 'simdlen' clause.
1754 ///
1755 /// By default, performs semantic analysis to build the new OpenMP clause.
1756 /// Subclasses may override this routine to provide different behavior.
1758 SourceLocation LParenLoc,
1759 SourceLocation EndLoc) {
1760 return getSema().OpenMP().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc,
1761 EndLoc);
1762 }
1763
1765 SourceLocation StartLoc,
1766 SourceLocation LParenLoc,
1767 SourceLocation EndLoc) {
1768 return getSema().OpenMP().ActOnOpenMPSizesClause(Sizes, StartLoc, LParenLoc,
1769 EndLoc);
1770 }
1771
1773 SourceLocation StartLoc,
1774 SourceLocation LParenLoc,
1775 SourceLocation EndLoc,
1776 std::optional<unsigned> FillIdx,
1777 SourceLocation FillLoc) {
1778 unsigned FillCount = FillIdx ? 1 : 0;
1780 Counts, StartLoc, LParenLoc, EndLoc, FillIdx, FillLoc, FillCount);
1781 }
1782
1783 /// Build a new OpenMP 'permutation' clause.
1785 SourceLocation StartLoc,
1786 SourceLocation LParenLoc,
1787 SourceLocation EndLoc) {
1788 return getSema().OpenMP().ActOnOpenMPPermutationClause(PermExprs, StartLoc,
1789 LParenLoc, EndLoc);
1790 }
1791
1792 /// Build a new OpenMP 'full' clause.
1794 SourceLocation EndLoc) {
1795 return getSema().OpenMP().ActOnOpenMPFullClause(StartLoc, EndLoc);
1796 }
1797
1798 /// Build a new OpenMP 'partial' clause.
1800 SourceLocation LParenLoc,
1801 SourceLocation EndLoc) {
1802 return getSema().OpenMP().ActOnOpenMPPartialClause(Factor, StartLoc,
1803 LParenLoc, EndLoc);
1804 }
1805
1806 OMPClause *
1808 SourceLocation LParenLoc, SourceLocation FirstLoc,
1809 SourceLocation CountLoc, SourceLocation EndLoc) {
1811 First, Count, StartLoc, LParenLoc, FirstLoc, CountLoc, EndLoc);
1812 }
1813
1814 /// Build a new OpenMP 'allocator' clause.
1815 ///
1816 /// By default, performs semantic analysis to build the new OpenMP clause.
1817 /// Subclasses may override this routine to provide different behavior.
1819 SourceLocation LParenLoc,
1820 SourceLocation EndLoc) {
1821 return getSema().OpenMP().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc,
1822 EndLoc);
1823 }
1824
1825 /// Build a new OpenMP 'collapse' clause.
1826 ///
1827 /// By default, performs semantic analysis to build the new OpenMP clause.
1828 /// Subclasses may override this routine to provide different behavior.
1830 SourceLocation LParenLoc,
1831 SourceLocation EndLoc) {
1832 return getSema().OpenMP().ActOnOpenMPCollapseClause(Num, StartLoc,
1833 LParenLoc, EndLoc);
1834 }
1835
1836 /// Build a new OpenMP 'default' clause.
1837 ///
1838 /// By default, performs semantic analysis to build the new OpenMP clause.
1839 /// Subclasses may override this routine to provide different behavior.
1842 SourceLocation VCLoc,
1843 SourceLocation StartLoc,
1844 SourceLocation LParenLoc,
1845 SourceLocation EndLoc) {
1847 Kind, KindKwLoc, VCKind, VCLoc, StartLoc, LParenLoc, EndLoc);
1848 }
1849
1850 /// Build a new OpenMP 'proc_bind' clause.
1851 ///
1852 /// By default, performs semantic analysis to build the new OpenMP clause.
1853 /// Subclasses may override this routine to provide different behavior.
1855 SourceLocation KindKwLoc,
1856 SourceLocation StartLoc,
1857 SourceLocation LParenLoc,
1858 SourceLocation EndLoc) {
1860 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1861 }
1863 SourceLocation StartLoc,
1864 SourceLocation LParenLoc,
1865 SourceLocation EndLoc) {
1867 ImpexTypeArg, StartLoc, LParenLoc, EndLoc);
1868 }
1869
1870 /// Build a new OpenMP 'schedule' clause.
1871 ///
1872 /// By default, performs semantic analysis to build the new OpenMP clause.
1873 /// Subclasses may override this routine to provide different behavior.
1876 OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1877 SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1878 SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1880 M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1881 CommaLoc, EndLoc);
1882 }
1883
1884 /// Build a new OpenMP 'ordered' clause.
1885 ///
1886 /// By default, performs semantic analysis to build the new OpenMP clause.
1887 /// Subclasses may override this routine to provide different behavior.
1889 SourceLocation EndLoc,
1890 SourceLocation LParenLoc, Expr *Num) {
1891 return getSema().OpenMP().ActOnOpenMPOrderedClause(StartLoc, EndLoc,
1892 LParenLoc, Num);
1893 }
1894
1895 /// Build a new OpenMP 'nowait' clause.
1896 ///
1897 /// By default, performs semantic analysis to build the new OpenMP clause.
1898 /// Subclasses may override this routine to provide different behavior.
1900 SourceLocation LParenLoc,
1901 SourceLocation EndLoc) {
1902 return getSema().OpenMP().ActOnOpenMPNowaitClause(StartLoc, EndLoc,
1903 LParenLoc, Condition);
1904 }
1905
1906 /// Build a new OpenMP 'private' clause.
1907 ///
1908 /// By default, performs semantic analysis to build the new OpenMP clause.
1909 /// Subclasses may override this routine to provide different behavior.
1911 SourceLocation StartLoc,
1912 SourceLocation LParenLoc,
1913 SourceLocation EndLoc) {
1914 return getSema().OpenMP().ActOnOpenMPPrivateClause(VarList, StartLoc,
1915 LParenLoc, EndLoc);
1916 }
1917
1918 /// Build a new OpenMP 'firstprivate' clause.
1919 ///
1920 /// By default, performs semantic analysis to build the new OpenMP clause.
1921 /// Subclasses may override this routine to provide different behavior.
1923 SourceLocation StartLoc,
1924 SourceLocation LParenLoc,
1925 SourceLocation EndLoc) {
1926 return getSema().OpenMP().ActOnOpenMPFirstprivateClause(VarList, StartLoc,
1927 LParenLoc, EndLoc);
1928 }
1929
1930 /// Build a new OpenMP 'lastprivate' clause.
1931 ///
1932 /// By default, performs semantic analysis to build the new OpenMP clause.
1933 /// Subclasses may override this routine to provide different behavior.
1936 SourceLocation LPKindLoc,
1937 SourceLocation ColonLoc,
1938 SourceLocation StartLoc,
1939 SourceLocation LParenLoc,
1940 SourceLocation EndLoc) {
1942 VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1943 }
1944
1945 /// Build a new OpenMP 'shared' clause.
1946 ///
1947 /// By default, performs semantic analysis to build the new OpenMP clause.
1948 /// Subclasses may override this routine to provide different behavior.
1950 SourceLocation StartLoc,
1951 SourceLocation LParenLoc,
1952 SourceLocation EndLoc) {
1953 return getSema().OpenMP().ActOnOpenMPSharedClause(VarList, StartLoc,
1954 LParenLoc, EndLoc);
1955 }
1956
1957 /// Build a new OpenMP 'reduction' clause.
1958 ///
1959 /// By default, performs semantic analysis to build the new statement.
1960 /// Subclasses may override this routine to provide different behavior.
1963 OpenMPOriginalSharingModifier OriginalSharingModifier,
1964 SourceLocation StartLoc, SourceLocation LParenLoc,
1965 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1966 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
1967 const DeclarationNameInfo &ReductionId,
1968 ArrayRef<Expr *> UnresolvedReductions) {
1970 VarList, {Modifier, OriginalSharingModifier}, StartLoc, LParenLoc,
1971 ModifierLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, ReductionId,
1972 UnresolvedReductions);
1973 }
1974
1975 /// Build a new OpenMP 'task_reduction' clause.
1976 ///
1977 /// By default, performs semantic analysis to build the new statement.
1978 /// Subclasses may override this routine to provide different behavior.
1980 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1981 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
1982 CXXScopeSpec &ReductionIdScopeSpec,
1983 const DeclarationNameInfo &ReductionId,
1984 ArrayRef<Expr *> UnresolvedReductions) {
1986 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1987 ReductionId, UnresolvedReductions);
1988 }
1989
1990 /// Build a new OpenMP 'in_reduction' clause.
1991 ///
1992 /// By default, performs semantic analysis to build the new statement.
1993 /// Subclasses may override this routine to provide different behavior.
1994 OMPClause *
1996 SourceLocation LParenLoc, SourceLocation ColonLoc,
1997 SourceLocation EndLoc,
1998 CXXScopeSpec &ReductionIdScopeSpec,
1999 const DeclarationNameInfo &ReductionId,
2000 ArrayRef<Expr *> UnresolvedReductions) {
2002 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
2003 ReductionId, UnresolvedReductions);
2004 }
2005
2006 /// Build a new OpenMP 'linear' clause.
2007 ///
2008 /// By default, performs semantic analysis to build the new OpenMP clause.
2009 /// Subclasses may override this routine to provide different behavior.
2011 ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc,
2012 SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier,
2013 SourceLocation ModifierLoc, SourceLocation ColonLoc,
2014 SourceLocation StepModifierLoc, SourceLocation EndLoc) {
2016 VarList, Step, StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc,
2017 StepModifierLoc, EndLoc);
2018 }
2019
2020 /// Build a new OpenMP 'aligned' clause.
2021 ///
2022 /// By default, performs semantic analysis to build the new OpenMP clause.
2023 /// Subclasses may override this routine to provide different behavior.
2025 SourceLocation StartLoc,
2026 SourceLocation LParenLoc,
2027 SourceLocation ColonLoc,
2028 SourceLocation EndLoc) {
2030 VarList, Alignment, StartLoc, LParenLoc, ColonLoc, EndLoc);
2031 }
2032
2033 /// Build a new OpenMP 'copyin' clause.
2034 ///
2035 /// By default, performs semantic analysis to build the new OpenMP clause.
2036 /// Subclasses may override this routine to provide different behavior.
2038 SourceLocation StartLoc,
2039 SourceLocation LParenLoc,
2040 SourceLocation EndLoc) {
2041 return getSema().OpenMP().ActOnOpenMPCopyinClause(VarList, StartLoc,
2042 LParenLoc, EndLoc);
2043 }
2044
2045 /// Build a new OpenMP 'copyprivate' clause.
2046 ///
2047 /// By default, performs semantic analysis to build the new OpenMP clause.
2048 /// Subclasses may override this routine to provide different behavior.
2050 SourceLocation StartLoc,
2051 SourceLocation LParenLoc,
2052 SourceLocation EndLoc) {
2053 return getSema().OpenMP().ActOnOpenMPCopyprivateClause(VarList, StartLoc,
2054 LParenLoc, EndLoc);
2055 }
2056
2057 /// Build a new OpenMP 'flush' pseudo clause.
2058 ///
2059 /// By default, performs semantic analysis to build the new OpenMP clause.
2060 /// Subclasses may override this routine to provide different behavior.
2062 SourceLocation StartLoc,
2063 SourceLocation LParenLoc,
2064 SourceLocation EndLoc) {
2065 return getSema().OpenMP().ActOnOpenMPFlushClause(VarList, StartLoc,
2066 LParenLoc, EndLoc);
2067 }
2068
2069 /// Build a new OpenMP 'depobj' pseudo clause.
2070 ///
2071 /// By default, performs semantic analysis to build the new OpenMP clause.
2072 /// Subclasses may override this routine to provide different behavior.
2074 SourceLocation LParenLoc,
2075 SourceLocation EndLoc) {
2076 return getSema().OpenMP().ActOnOpenMPDepobjClause(Depobj, StartLoc,
2077 LParenLoc, EndLoc);
2078 }
2079
2080 /// Build a new OpenMP 'depend' pseudo clause.
2081 ///
2082 /// By default, performs semantic analysis to build the new OpenMP clause.
2083 /// Subclasses may override this routine to provide different behavior.
2085 Expr *DepModifier, ArrayRef<Expr *> VarList,
2086 SourceLocation StartLoc,
2087 SourceLocation LParenLoc,
2088 SourceLocation EndLoc) {
2090 Data, DepModifier, VarList, StartLoc, LParenLoc, EndLoc);
2091 }
2092
2093 /// Build a new OpenMP 'device' clause.
2094 ///
2095 /// By default, performs semantic analysis to build the new statement.
2096 /// Subclasses may override this routine to provide different behavior.
2098 Expr *Device, SourceLocation StartLoc,
2099 SourceLocation LParenLoc,
2100 SourceLocation ModifierLoc,
2101 SourceLocation EndLoc) {
2103 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2104 }
2105
2106 /// Build a new OpenMP 'map' clause.
2107 ///
2108 /// By default, performs semantic analysis to build the new OpenMP clause.
2109 /// Subclasses may override this routine to provide different behavior.
2111 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
2112 ArrayRef<SourceLocation> MapTypeModifiersLoc,
2113 CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId,
2114 OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
2115 SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
2116 const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) {
2118 IteratorModifier, MapTypeModifiers, MapTypeModifiersLoc,
2119 MapperIdScopeSpec, MapperId, MapType, IsMapTypeImplicit, MapLoc,
2120 ColonLoc, VarList, Locs,
2121 /*NoDiagnose=*/false, UnresolvedMappers);
2122 }
2123
2124 /// Build a new OpenMP 'allocate' clause.
2125 ///
2126 /// By default, performs semantic analysis to build the new OpenMP clause.
2127 /// Subclasses may override this routine to provide different behavior.
2128 OMPClause *
2129 RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment,
2130 OpenMPAllocateClauseModifier FirstModifier,
2131 SourceLocation FirstModifierLoc,
2132 OpenMPAllocateClauseModifier SecondModifier,
2133 SourceLocation SecondModifierLoc,
2134 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2135 SourceLocation LParenLoc, SourceLocation ColonLoc,
2136 SourceLocation EndLoc) {
2138 Allocate, Alignment, FirstModifier, FirstModifierLoc, SecondModifier,
2139 SecondModifierLoc, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc);
2140 }
2141
2142 /// Build a new OpenMP 'num_teams' clause.
2143 ///
2144 /// By default, performs semantic analysis to build the new statement.
2145 /// Subclasses may override this routine to provide different behavior.
2147 SourceLocation StartLoc,
2148 SourceLocation LParenLoc,
2149 SourceLocation EndLoc) {
2150 return getSema().OpenMP().ActOnOpenMPNumTeamsClause(VarList, StartLoc,
2151 LParenLoc, EndLoc);
2152 }
2153
2154 /// Build a new OpenMP 'thread_limit' clause.
2155 ///
2156 /// By default, performs semantic analysis to build the new statement.
2157 /// Subclasses may override this routine to provide different behavior.
2159 SourceLocation StartLoc,
2160 SourceLocation LParenLoc,
2161 SourceLocation EndLoc) {
2162 return getSema().OpenMP().ActOnOpenMPThreadLimitClause(VarList, StartLoc,
2163 LParenLoc, EndLoc);
2164 }
2165
2166 /// Build a new OpenMP 'priority' clause.
2167 ///
2168 /// By default, performs semantic analysis to build the new statement.
2169 /// Subclasses may override this routine to provide different behavior.
2171 SourceLocation LParenLoc,
2172 SourceLocation EndLoc) {
2173 return getSema().OpenMP().ActOnOpenMPPriorityClause(Priority, StartLoc,
2174 LParenLoc, EndLoc);
2175 }
2176
2177 /// Build a new OpenMP 'grainsize' clause.
2178 ///
2179 /// By default, performs semantic analysis to build the new statement.
2180 /// Subclasses may override this routine to provide different behavior.
2182 Expr *Device, SourceLocation StartLoc,
2183 SourceLocation LParenLoc,
2184 SourceLocation ModifierLoc,
2185 SourceLocation EndLoc) {
2187 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2188 }
2189
2190 /// Build a new OpenMP 'num_tasks' clause.
2191 ///
2192 /// By default, performs semantic analysis to build the new statement.
2193 /// Subclasses may override this routine to provide different behavior.
2195 Expr *NumTasks, SourceLocation StartLoc,
2196 SourceLocation LParenLoc,
2197 SourceLocation ModifierLoc,
2198 SourceLocation EndLoc) {
2200 Modifier, NumTasks, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2201 }
2202
2203 /// Build a new OpenMP 'hint' clause.
2204 ///
2205 /// By default, performs semantic analysis to build the new statement.
2206 /// Subclasses may override this routine to provide different behavior.
2208 SourceLocation LParenLoc,
2209 SourceLocation EndLoc) {
2210 return getSema().OpenMP().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc,
2211 EndLoc);
2212 }
2213
2214 /// Build a new OpenMP 'detach' clause.
2215 ///
2216 /// By default, performs semantic analysis to build the new statement.
2217 /// Subclasses may override this routine to provide different behavior.
2219 SourceLocation LParenLoc,
2220 SourceLocation EndLoc) {
2221 return getSema().OpenMP().ActOnOpenMPDetachClause(Evt, StartLoc, LParenLoc,
2222 EndLoc);
2223 }
2224
2225 /// Build a new OpenMP 'dist_schedule' clause.
2226 ///
2227 /// By default, performs semantic analysis to build the new OpenMP clause.
2228 /// Subclasses may override this routine to provide different behavior.
2229 OMPClause *
2231 Expr *ChunkSize, SourceLocation StartLoc,
2232 SourceLocation LParenLoc, SourceLocation KindLoc,
2233 SourceLocation CommaLoc, SourceLocation EndLoc) {
2235 Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
2236 }
2237
2238 /// Build a new OpenMP 'to' clause.
2239 ///
2240 /// By default, performs semantic analysis to build the new statement.
2241 /// Subclasses may override this routine to provide different behavior.
2242 OMPClause *
2244 ArrayRef<SourceLocation> MotionModifiersLoc,
2245 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2246 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2247 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2248 ArrayRef<Expr *> UnresolvedMappers) {
2250 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2251 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2252 UnresolvedMappers);
2253 }
2254
2255 /// Build a new OpenMP 'from' clause.
2256 ///
2257 /// By default, performs semantic analysis to build the new statement.
2258 /// Subclasses may override this routine to provide different behavior.
2259 OMPClause *
2261 ArrayRef<SourceLocation> MotionModifiersLoc,
2262 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2263 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2264 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2265 ArrayRef<Expr *> UnresolvedMappers) {
2267 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2268 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2269 UnresolvedMappers);
2270 }
2271
2272 /// Build a new OpenMP 'use_device_ptr' clause.
2273 ///
2274 /// By default, performs semantic analysis to build the new OpenMP clause.
2275 /// Subclasses may override this routine to provide different behavior.
2277 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2278 OpenMPUseDevicePtrFallbackModifier FallbackModifier,
2279 SourceLocation FallbackModifierLoc) {
2281 VarList, Locs, FallbackModifier, FallbackModifierLoc);
2282 }
2283
2284 /// Build a new OpenMP 'use_device_addr' clause.
2285 ///
2286 /// By default, performs semantic analysis to build the new OpenMP clause.
2287 /// Subclasses may override this routine to provide different behavior.
2292
2293 /// Build a new OpenMP 'is_device_ptr' clause.
2294 ///
2295 /// By default, performs semantic analysis to build the new OpenMP clause.
2296 /// Subclasses may override this routine to provide different behavior.
2298 const OMPVarListLocTy &Locs) {
2299 return getSema().OpenMP().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
2300 }
2301
2302 /// Build a new OpenMP 'has_device_addr' clause.
2303 ///
2304 /// By default, performs semantic analysis to build the new OpenMP clause.
2305 /// Subclasses may override this routine to provide different behavior.
2310
2311 /// Build a new OpenMP 'defaultmap' clause.
2312 ///
2313 /// By default, performs semantic analysis to build the new OpenMP clause.
2314 /// Subclasses may override this routine to provide different behavior.
2317 SourceLocation StartLoc,
2318 SourceLocation LParenLoc,
2319 SourceLocation MLoc,
2320 SourceLocation KindLoc,
2321 SourceLocation EndLoc) {
2323 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2324 }
2325
2326 /// Build a new OpenMP 'nontemporal' clause.
2327 ///
2328 /// By default, performs semantic analysis to build the new OpenMP clause.
2329 /// Subclasses may override this routine to provide different behavior.
2331 SourceLocation StartLoc,
2332 SourceLocation LParenLoc,
2333 SourceLocation EndLoc) {
2334 return getSema().OpenMP().ActOnOpenMPNontemporalClause(VarList, StartLoc,
2335 LParenLoc, EndLoc);
2336 }
2337
2338 /// Build a new OpenMP 'inclusive' clause.
2339 ///
2340 /// By default, performs semantic analysis to build the new OpenMP clause.
2341 /// Subclasses may override this routine to provide different behavior.
2343 SourceLocation StartLoc,
2344 SourceLocation LParenLoc,
2345 SourceLocation EndLoc) {
2346 return getSema().OpenMP().ActOnOpenMPInclusiveClause(VarList, StartLoc,
2347 LParenLoc, EndLoc);
2348 }
2349
2350 /// Build a new OpenMP 'exclusive' clause.
2351 ///
2352 /// By default, performs semantic analysis to build the new OpenMP clause.
2353 /// Subclasses may override this routine to provide different behavior.
2355 SourceLocation StartLoc,
2356 SourceLocation LParenLoc,
2357 SourceLocation EndLoc) {
2358 return getSema().OpenMP().ActOnOpenMPExclusiveClause(VarList, StartLoc,
2359 LParenLoc, EndLoc);
2360 }
2361
2362 /// Build a new OpenMP 'uses_allocators' clause.
2363 ///
2364 /// By default, performs semantic analysis to build the new OpenMP clause.
2365 /// Subclasses may override this routine to provide different behavior.
2372
2373 /// Build a new OpenMP 'affinity' clause.
2374 ///
2375 /// By default, performs semantic analysis to build the new OpenMP clause.
2376 /// Subclasses may override this routine to provide different behavior.
2378 SourceLocation LParenLoc,
2379 SourceLocation ColonLoc,
2380 SourceLocation EndLoc, Expr *Modifier,
2381 ArrayRef<Expr *> Locators) {
2383 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2384 }
2385
2386 /// Build a new OpenMP 'order' clause.
2387 ///
2388 /// By default, performs semantic analysis to build the new OpenMP clause.
2389 /// Subclasses may override this routine to provide different behavior.
2391 OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc,
2392 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
2393 OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc) {
2395 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2396 }
2397
2398 /// Build a new OpenMP 'init' clause.
2399 ///
2400 /// By default, performs semantic analysis to build the new OpenMP clause.
2401 /// Subclasses may override this routine to provide different behavior.
2403 SourceLocation StartLoc,
2404 SourceLocation LParenLoc,
2405 SourceLocation VarLoc,
2406 SourceLocation EndLoc) {
2408 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2409 }
2410
2411 /// Build a new OpenMP 'use' clause.
2412 ///
2413 /// By default, performs semantic analysis to build the new OpenMP clause.
2414 /// Subclasses may override this routine to provide different behavior.
2416 SourceLocation LParenLoc,
2417 SourceLocation VarLoc, SourceLocation EndLoc) {
2418 return getSema().OpenMP().ActOnOpenMPUseClause(InteropVar, StartLoc,
2419 LParenLoc, VarLoc, EndLoc);
2420 }
2421
2422 /// Build a new OpenMP 'destroy' clause.
2423 ///
2424 /// By default, performs semantic analysis to build the new OpenMP clause.
2425 /// Subclasses may override this routine to provide different behavior.
2427 SourceLocation LParenLoc,
2428 SourceLocation VarLoc,
2429 SourceLocation EndLoc) {
2431 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2432 }
2433
2434 /// Build a new OpenMP 'novariants' clause.
2435 ///
2436 /// By default, performs semantic analysis to build the new OpenMP clause.
2437 /// Subclasses may override this routine to provide different behavior.
2439 SourceLocation StartLoc,
2440 SourceLocation LParenLoc,
2441 SourceLocation EndLoc) {
2443 LParenLoc, EndLoc);
2444 }
2445
2446 /// Build a new OpenMP 'nocontext' clause.
2447 ///
2448 /// By default, performs semantic analysis to build the new OpenMP clause.
2449 /// Subclasses may override this routine to provide different behavior.
2451 SourceLocation LParenLoc,
2452 SourceLocation EndLoc) {
2454 LParenLoc, EndLoc);
2455 }
2456
2457 /// Build a new OpenMP 'filter' clause.
2458 ///
2459 /// By default, performs semantic analysis to build the new OpenMP clause.
2460 /// Subclasses may override this routine to provide different behavior.
2462 SourceLocation LParenLoc,
2463 SourceLocation EndLoc) {
2464 return getSema().OpenMP().ActOnOpenMPFilterClause(ThreadID, StartLoc,
2465 LParenLoc, EndLoc);
2466 }
2467
2468 /// Build a new OpenMP 'bind' clause.
2469 ///
2470 /// By default, performs semantic analysis to build the new OpenMP clause.
2471 /// Subclasses may override this routine to provide different behavior.
2473 SourceLocation KindLoc,
2474 SourceLocation StartLoc,
2475 SourceLocation LParenLoc,
2476 SourceLocation EndLoc) {
2477 return getSema().OpenMP().ActOnOpenMPBindClause(Kind, KindLoc, StartLoc,
2478 LParenLoc, EndLoc);
2479 }
2480
2481 /// Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
2482 ///
2483 /// By default, performs semantic analysis to build the new OpenMP clause.
2484 /// Subclasses may override this routine to provide different behavior.
2486 SourceLocation LParenLoc,
2487 SourceLocation EndLoc) {
2488 return getSema().OpenMP().ActOnOpenMPXDynCGroupMemClause(Size, StartLoc,
2489 LParenLoc, EndLoc);
2490 }
2491
2492 /// Build a new OpenMP 'dyn_groupprivate' clause.
2493 ///
2494 /// By default, performs semantic analysis to build the new OpenMP clause.
2495 /// Subclasses may override this routine to provide different behavior.
2499 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc,
2500 SourceLocation M2Loc, SourceLocation EndLoc) {
2502 M1, M2, Size, StartLoc, LParenLoc, M1Loc, M2Loc, EndLoc);
2503 }
2504
2505 /// Build a new OpenMP 'ompx_attribute' clause.
2506 ///
2507 /// By default, performs semantic analysis to build the new OpenMP clause.
2508 /// Subclasses may override this routine to provide different behavior.
2510 SourceLocation StartLoc,
2511 SourceLocation LParenLoc,
2512 SourceLocation EndLoc) {
2513 return getSema().OpenMP().ActOnOpenMPXAttributeClause(Attrs, StartLoc,
2514 LParenLoc, EndLoc);
2515 }
2516
2517 /// Build a new OpenMP 'ompx_bare' clause.
2518 ///
2519 /// By default, performs semantic analysis to build the new OpenMP clause.
2520 /// Subclasses may override this routine to provide different behavior.
2522 SourceLocation EndLoc) {
2523 return getSema().OpenMP().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2524 }
2525
2526 /// Build a new OpenMP 'align' clause.
2527 ///
2528 /// By default, performs semantic analysis to build the new OpenMP clause.
2529 /// Subclasses may override this routine to provide different behavior.
2531 SourceLocation LParenLoc,
2532 SourceLocation EndLoc) {
2533 return getSema().OpenMP().ActOnOpenMPAlignClause(A, StartLoc, LParenLoc,
2534 EndLoc);
2535 }
2536
2537 /// Build a new OpenMP 'at' clause.
2538 ///
2539 /// By default, performs semantic analysis to build the new OpenMP clause.
2540 /// Subclasses may override this routine to provide different behavior.
2542 SourceLocation StartLoc,
2543 SourceLocation LParenLoc,
2544 SourceLocation EndLoc) {
2545 return getSema().OpenMP().ActOnOpenMPAtClause(Kind, KwLoc, StartLoc,
2546 LParenLoc, EndLoc);
2547 }
2548
2549 /// Build a new OpenMP 'severity' clause.
2550 ///
2551 /// By default, performs semantic analysis to build the new OpenMP clause.
2552 /// Subclasses may override this routine to provide different behavior.
2554 SourceLocation KwLoc,
2555 SourceLocation StartLoc,
2556 SourceLocation LParenLoc,
2557 SourceLocation EndLoc) {
2558 return getSema().OpenMP().ActOnOpenMPSeverityClause(Kind, KwLoc, StartLoc,
2559 LParenLoc, EndLoc);
2560 }
2561
2562 /// Build a new OpenMP 'message' clause.
2563 ///
2564 /// By default, performs semantic analysis to build the new OpenMP clause.
2565 /// Subclasses may override this routine to provide different behavior.
2567 SourceLocation LParenLoc,
2568 SourceLocation EndLoc) {
2569 return getSema().OpenMP().ActOnOpenMPMessageClause(MS, StartLoc, LParenLoc,
2570 EndLoc);
2571 }
2572
2573 /// Build a new OpenMP 'doacross' clause.
2574 ///
2575 /// By default, performs semantic analysis to build the new OpenMP clause.
2576 /// Subclasses may override this routine to provide different behavior.
2577 OMPClause *
2579 SourceLocation DepLoc, SourceLocation ColonLoc,
2580 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2581 SourceLocation LParenLoc, SourceLocation EndLoc) {
2583 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2584 }
2585
2586 /// Build a new OpenMP 'holds' clause.
2588 SourceLocation LParenLoc,
2589 SourceLocation EndLoc) {
2590 return getSema().OpenMP().ActOnOpenMPHoldsClause(A, StartLoc, LParenLoc,
2591 EndLoc);
2592 }
2593
2594 /// Rebuild the operand to an Objective-C \@synchronized statement.
2595 ///
2596 /// By default, performs semantic analysis to build the new statement.
2597 /// Subclasses may override this routine to provide different behavior.
2602
2603 /// Build a new Objective-C \@synchronized statement.
2604 ///
2605 /// By default, performs semantic analysis to build the new statement.
2606 /// Subclasses may override this routine to provide different behavior.
2611
2612 /// Build a new Objective-C \@autoreleasepool statement.
2613 ///
2614 /// By default, performs semantic analysis to build the new statement.
2615 /// Subclasses may override this routine to provide different behavior.
2620
2621 /// Build a new Objective-C fast enumeration statement.
2622 ///
2623 /// By default, performs semantic analysis to build the new statement.
2624 /// Subclasses may override this routine to provide different behavior.
2626 Stmt *Element,
2627 Expr *Collection,
2628 SourceLocation RParenLoc,
2629 Stmt *Body) {
2631 ForLoc, Element, Collection, RParenLoc);
2632 if (ForEachStmt.isInvalid())
2633 return StmtError();
2634
2635 return getSema().ObjC().FinishObjCForCollectionStmt(ForEachStmt.get(),
2636 Body);
2637 }
2638
2639 /// Build a new C++ exception declaration.
2640 ///
2641 /// By default, performs semantic analysis to build the new decaration.
2642 /// Subclasses may override this routine to provide different behavior.
2645 SourceLocation StartLoc,
2646 SourceLocation IdLoc,
2647 IdentifierInfo *Id) {
2649 StartLoc, IdLoc, Id);
2650 if (Var)
2651 getSema().CurContext->addDecl(Var);
2652 return Var;
2653 }
2654
2655 /// Build a new C++ catch statement.
2656 ///
2657 /// By default, performs semantic analysis to build the new statement.
2658 /// Subclasses may override this routine to provide different behavior.
2660 VarDecl *ExceptionDecl,
2661 Stmt *Handler) {
2662 return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2663 Handler));
2664 }
2665
2666 /// Build a new C++ try statement.
2667 ///
2668 /// By default, performs semantic analysis to build the new statement.
2669 /// Subclasses may override this routine to provide different behavior.
2671 ArrayRef<Stmt *> Handlers) {
2672 return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2673 }
2674
2675 /// Build a new C++0x range-based for statement.
2676 ///
2677 /// By default, performs semantic analysis to build the new statement.
2678 /// Subclasses may override this routine to provide different behavior.
2680 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init,
2681 SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond,
2682 Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc,
2683 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
2684 // If we've just learned that the range is actually an Objective-C
2685 // collection, treat this as an Objective-C fast enumeration loop.
2686 if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2687 if (RangeStmt->isSingleDecl()) {
2688 if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2689 if (RangeVar->isInvalidDecl())
2690 return StmtError();
2691
2692 Expr *RangeExpr = RangeVar->getInit();
2693 if (!RangeExpr->isTypeDependent() &&
2694 RangeExpr->getType()->isObjCObjectPointerType()) {
2695 // FIXME: Support init-statements in Objective-C++20 ranged for
2696 // statement.
2697 if (Init) {
2698 return SemaRef.Diag(Init->getBeginLoc(),
2699 diag::err_objc_for_range_init_stmt)
2700 << Init->getSourceRange();
2701 }
2703 ForLoc, LoopVar, RangeExpr, RParenLoc);
2704 }
2705 }
2706 }
2707 }
2708
2710 ForLoc, CoawaitLoc, Init, ColonLoc, Range, Begin, End, Cond, Inc,
2711 LoopVar, RParenLoc, Sema::BFRK_Rebuild, LifetimeExtendTemps);
2712 }
2713
2714 /// Build a new C++0x range-based for statement.
2715 ///
2716 /// By default, performs semantic analysis to build the new statement.
2717 /// Subclasses may override this routine to provide different behavior.
2719 bool IsIfExists,
2720 NestedNameSpecifierLoc QualifierLoc,
2721 DeclarationNameInfo NameInfo,
2722 Stmt *Nested) {
2723 return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2724 QualifierLoc, NameInfo, Nested);
2725 }
2726
2727 /// Attach body to a C++0x range-based for statement.
2728 ///
2729 /// By default, performs semantic analysis to finish the new statement.
2730 /// Subclasses may override this routine to provide different behavior.
2732 return getSema().FinishCXXForRangeStmt(ForRange, Body);
2733 }
2734
2736 Stmt *TryBlock, Stmt *Handler) {
2737 return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2738 }
2739
2741 Stmt *Block) {
2742 return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2743 }
2744
2746 return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2747 }
2748
2750 SourceLocation LParen,
2751 SourceLocation RParen,
2752 TypeSourceInfo *TSI) {
2753 return getSema().SYCL().BuildUniqueStableNameExpr(OpLoc, LParen, RParen,
2754 TSI);
2755 }
2756
2757 /// Build a new predefined expression.
2758 ///
2759 /// By default, performs semantic analysis to build the new expression.
2760 /// Subclasses may override this routine to provide different behavior.
2764
2765 /// Build a new expression that references a declaration.
2766 ///
2767 /// By default, performs semantic analysis to build the new expression.
2768 /// Subclasses may override this routine to provide different behavior.
2770 LookupResult &R,
2771 bool RequiresADL) {
2772 return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2773 }
2774
2775
2776 /// Build a new expression that references a declaration.
2777 ///
2778 /// By default, performs semantic analysis to build the new expression.
2779 /// Subclasses may override this routine to provide different behavior.
2781 ValueDecl *VD,
2782 const DeclarationNameInfo &NameInfo,
2784 TemplateArgumentListInfo *TemplateArgs) {
2785 CXXScopeSpec SS;
2786 SS.Adopt(QualifierLoc);
2787 return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2788 TemplateArgs);
2789 }
2790
2791 /// Build a new expression in parentheses.
2792 ///
2793 /// By default, performs semantic analysis to build the new expression.
2794 /// Subclasses may override this routine to provide different behavior.
2796 SourceLocation RParen) {
2797 return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2798 }
2799
2800 /// Build a new pseudo-destructor expression.
2801 ///
2802 /// By default, performs semantic analysis to build the new expression.
2803 /// Subclasses may override this routine to provide different behavior.
2805 SourceLocation OperatorLoc,
2806 bool isArrow,
2807 CXXScopeSpec &SS,
2808 TypeSourceInfo *ScopeType,
2809 SourceLocation CCLoc,
2810 SourceLocation TildeLoc,
2811 PseudoDestructorTypeStorage Destroyed);
2812
2813 /// Build a new unary operator expression.
2814 ///
2815 /// By default, performs semantic analysis to build the new expression.
2816 /// Subclasses may override this routine to provide different behavior.
2819 Expr *SubExpr) {
2820 return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2821 }
2822
2823 /// Build a new builtin offsetof expression.
2824 ///
2825 /// By default, performs semantic analysis to build the new expression.
2826 /// Subclasses may override this routine to provide different behavior.
2830 SourceLocation RParenLoc) {
2831 return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2832 RParenLoc);
2833 }
2834
2835 /// Build a new sizeof, alignof or vec_step expression with a
2836 /// type argument.
2837 ///
2838 /// By default, performs semantic analysis to build the new expression.
2839 /// Subclasses may override this routine to provide different behavior.
2841 SourceLocation OpLoc,
2842 UnaryExprOrTypeTrait ExprKind,
2843 SourceRange R) {
2844 return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2845 }
2846
2847 /// Build a new sizeof, alignof or vec step expression with an
2848 /// expression argument.
2849 ///
2850 /// By default, performs semantic analysis to build the new expression.
2851 /// Subclasses may override this routine to provide different behavior.
2853 UnaryExprOrTypeTrait ExprKind,
2854 SourceRange R) {
2856 = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2857 if (Result.isInvalid())
2858 return ExprError();
2859
2860 return Result;
2861 }
2862
2863 /// Build a new array subscript expression.
2864 ///
2865 /// By default, performs semantic analysis to build the new expression.
2866 /// Subclasses may override this routine to provide different behavior.
2868 SourceLocation LBracketLoc,
2869 Expr *RHS,
2870 SourceLocation RBracketLoc) {
2871 return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2872 LBracketLoc, RHS,
2873 RBracketLoc);
2874 }
2875
2876 /// Build a new matrix single subscript expression.
2877 ///
2878 /// By default, performs semantic analysis to build the new expression.
2879 /// Subclasses may override this routine to provide different behavior.
2881 SourceLocation RBracketLoc) {
2883 RBracketLoc);
2884 }
2885
2886 /// Build a new matrix subscript expression.
2887 ///
2888 /// By default, performs semantic analysis to build the new expression.
2889 /// Subclasses may override this routine to provide different behavior.
2891 Expr *ColumnIdx,
2892 SourceLocation RBracketLoc) {
2893 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2894 RBracketLoc);
2895 }
2896
2897 /// Build a new array section expression.
2898 ///
2899 /// By default, performs semantic analysis to build the new expression.
2900 /// Subclasses may override this routine to provide different behavior.
2902 SourceLocation LBracketLoc,
2903 Expr *LowerBound,
2904 SourceLocation ColonLocFirst,
2905 SourceLocation ColonLocSecond,
2906 Expr *Length, Expr *Stride,
2907 SourceLocation RBracketLoc) {
2908 if (IsOMPArraySection)
2910 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2911 Stride, RBracketLoc);
2912
2913 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2914 "Stride/second colon not allowed for OpenACC");
2915
2917 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2918 }
2919
2920 /// Build a new array shaping expression.
2921 ///
2922 /// By default, performs semantic analysis to build the new expression.
2923 /// Subclasses may override this routine to provide different behavior.
2925 SourceLocation RParenLoc,
2926 ArrayRef<Expr *> Dims,
2927 ArrayRef<SourceRange> BracketsRanges) {
2929 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2930 }
2931
2932 /// Build a new iterator expression.
2933 ///
2934 /// By default, performs semantic analysis to build the new expression.
2935 /// Subclasses may override this routine to provide different behavior.
2938 SourceLocation RLoc,
2941 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2942 }
2943
2944 /// Build a new call expression.
2945 ///
2946 /// By default, performs semantic analysis to build the new expression.
2947 /// Subclasses may override this routine to provide different behavior.
2949 MultiExprArg Args,
2950 SourceLocation RParenLoc,
2951 Expr *ExecConfig = nullptr) {
2952 return getSema().ActOnCallExpr(
2953 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2954 }
2955
2957 MultiExprArg Args,
2958 SourceLocation RParenLoc) {
2960 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2961 }
2962
2963 /// Build a new member access expression.
2964 ///
2965 /// By default, performs semantic analysis to build the new expression.
2966 /// Subclasses may override this routine to provide different behavior.
2968 bool isArrow,
2969 NestedNameSpecifierLoc QualifierLoc,
2970 SourceLocation TemplateKWLoc,
2971 const DeclarationNameInfo &MemberNameInfo,
2973 NamedDecl *FoundDecl,
2974 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2975 NamedDecl *FirstQualifierInScope) {
2977 isArrow);
2978 if (!Member->getDeclName()) {
2979 // We have a reference to an unnamed field. This is always the
2980 // base of an anonymous struct/union member access, i.e. the
2981 // field is always of record type.
2982 assert(Member->getType()->isRecordType() &&
2983 "unnamed member not of record type?");
2984
2985 BaseResult =
2987 QualifierLoc.getNestedNameSpecifier(),
2988 FoundDecl, Member);
2989 if (BaseResult.isInvalid())
2990 return ExprError();
2991 Base = BaseResult.get();
2992
2993 // `TranformMaterializeTemporaryExpr()` removes materialized temporaries
2994 // from the AST, so we need to re-insert them if needed (since
2995 // `BuildFieldRefereneExpr()` doesn't do this).
2996 if (!isArrow && Base->isPRValue()) {
2998 if (BaseResult.isInvalid())
2999 return ExprError();
3000 Base = BaseResult.get();
3001 }
3002
3003 CXXScopeSpec EmptySS;
3005 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
3006 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
3007 MemberNameInfo);
3008 }
3009
3010 CXXScopeSpec SS;
3011 SS.Adopt(QualifierLoc);
3012
3013 Base = BaseResult.get();
3014 if (Base->containsErrors())
3015 return ExprError();
3016
3017 QualType BaseType = Base->getType();
3018
3019 if (isArrow && !BaseType->isPointerType())
3020 return ExprError();
3021
3022 // FIXME: this involves duplicating earlier analysis in a lot of
3023 // cases; we should avoid this when possible.
3024 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
3025 R.addDecl(FoundDecl);
3026 R.resolveKind();
3027
3028 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
3030 if (auto *ThisClass = cast<CXXThisExpr>(Base)
3031 ->getType()
3032 ->getPointeeType()
3033 ->getAsCXXRecordDecl()) {
3034 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
3035 // In unevaluated contexts, an expression supposed to be a member access
3036 // might reference a member in an unrelated class.
3037 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
3038 return getSema().BuildDeclRefExpr(Member, Member->getType(),
3039 VK_LValue, Member->getLocation());
3040 }
3041 }
3042
3043 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
3044 SS, TemplateKWLoc,
3045 FirstQualifierInScope,
3046 R, ExplicitTemplateArgs,
3047 /*S*/nullptr);
3048 }
3049
3050 /// Build a new binary operator expression.
3051 ///
3052 /// By default, performs semantic analysis to build the new expression.
3053 /// Subclasses may override this routine to provide different behavior.
3055 Expr *LHS, Expr *RHS,
3056 bool ForFoldExpression = false) {
3057 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS,
3058 ForFoldExpression);
3059 }
3060
3061 /// Build a new rewritten operator expression.
3062 ///
3063 /// By default, performs semantic analysis to build the new expression.
3064 /// Subclasses may override this routine to provide different behavior.
3066 SourceLocation OpLoc, BinaryOperatorKind Opcode,
3067 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
3068 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
3069 RHS, /*RequiresADL*/false);
3070 }
3071
3072 /// Build a new conditional operator expression.
3073 ///
3074 /// By default, performs semantic analysis to build the new expression.
3075 /// Subclasses may override this routine to provide different behavior.
3077 SourceLocation QuestionLoc,
3078 Expr *LHS,
3079 SourceLocation ColonLoc,
3080 Expr *RHS) {
3081 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
3082 LHS, RHS);
3083 }
3084
3085 /// Build a new C-style cast expression.
3086 ///
3087 /// By default, performs semantic analysis to build the new expression.
3088 /// Subclasses may override this routine to provide different behavior.
3090 TypeSourceInfo *TInfo,
3091 SourceLocation RParenLoc,
3092 Expr *SubExpr) {
3093 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
3094 SubExpr);
3095 }
3096
3097 /// Build a new compound literal expression.
3098 ///
3099 /// By default, performs semantic analysis to build the new expression.
3100 /// Subclasses may override this routine to provide different behavior.
3102 TypeSourceInfo *TInfo,
3103 SourceLocation RParenLoc,
3104 Expr *Init) {
3105 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
3106 Init);
3107 }
3108
3109 /// Build a new extended vector or matrix element access expression.
3110 ///
3111 /// By default, performs semantic analysis to build the new expression.
3112 /// Subclasses may override this routine to provide different behavior.
3114 SourceLocation OpLoc,
3115 bool IsArrow,
3116 SourceLocation AccessorLoc,
3117 IdentifierInfo &Accessor) {
3118
3119 CXXScopeSpec SS;
3120 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3122 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3123 /*FirstQualifierInScope*/ nullptr, NameInfo,
3124 /* TemplateArgs */ nullptr,
3125 /*S*/ nullptr);
3126 }
3127
3128 /// Build a new initializer list expression.
3129 ///
3130 /// By default, performs semantic analysis to build the new expression.
3131 /// Subclasses may override this routine to provide different behavior.
3134 SourceLocation RBraceLoc) {
3135 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
3136 }
3137
3138 /// Build a new designated initializer expression.
3139 ///
3140 /// By default, performs semantic analysis to build the new expression.
3141 /// Subclasses may override this routine to provide different behavior.
3143 MultiExprArg ArrayExprs,
3144 SourceLocation EqualOrColonLoc,
3145 bool GNUSyntax,
3146 Expr *Init) {
3148 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3149 Init);
3150 if (Result.isInvalid())
3151 return ExprError();
3152
3153 return Result;
3154 }
3155
3156 /// Build a new value-initialized expression.
3157 ///
3158 /// By default, builds the implicit value initialization without performing
3159 /// any semantic analysis. Subclasses may override this routine to provide
3160 /// different behavior.
3164
3165 /// Build a new \c va_arg expression.
3166 ///
3167 /// By default, performs semantic analysis to build the new expression.
3168 /// Subclasses may override this routine to provide different behavior.
3170 Expr *SubExpr, TypeSourceInfo *TInfo,
3171 SourceLocation RParenLoc) {
3172 return getSema().BuildVAArgExpr(BuiltinLoc,
3173 SubExpr, TInfo,
3174 RParenLoc);
3175 }
3176
3177 /// Build a new expression list in parentheses.
3178 ///
3179 /// By default, performs semantic analysis to build the new expression.
3180 /// Subclasses may override this routine to provide different behavior.
3182 MultiExprArg SubExprs,
3183 SourceLocation RParenLoc) {
3184 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3185 }
3186
3188 unsigned NumUserSpecifiedExprs,
3189 SourceLocation InitLoc,
3190 SourceLocation LParenLoc,
3191 SourceLocation RParenLoc) {
3192 return getSema().ActOnCXXParenListInitExpr(Args, T, NumUserSpecifiedExprs,
3193 InitLoc, LParenLoc, RParenLoc);
3194 }
3195
3196 /// Build a new address-of-label expression.
3197 ///
3198 /// By default, performs semantic analysis, using the name of the label
3199 /// rather than attempting to map the label statement itself.
3200 /// Subclasses may override this routine to provide different behavior.
3202 SourceLocation LabelLoc, LabelDecl *Label) {
3203 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3204 }
3205
3206 /// Build a new GNU statement expression.
3207 ///
3208 /// By default, performs semantic analysis to build the new expression.
3209 /// Subclasses may override this routine to provide different behavior.
3211 SourceLocation RParenLoc, unsigned TemplateDepth) {
3212 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3213 TemplateDepth);
3214 }
3215
3216 /// Build a new __builtin_choose_expr expression.
3217 ///
3218 /// By default, performs semantic analysis to build the new expression.
3219 /// Subclasses may override this routine to provide different behavior.
3221 Expr *Cond, Expr *LHS, Expr *RHS,
3222 SourceLocation RParenLoc) {
3223 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3224 Cond, LHS, RHS,
3225 RParenLoc);
3226 }
3227
3228 /// Build a new generic selection expression with an expression predicate.
3229 ///
3230 /// By default, performs semantic analysis to build the new expression.
3231 /// Subclasses may override this routine to provide different behavior.
3233 SourceLocation DefaultLoc,
3234 SourceLocation RParenLoc,
3235 Expr *ControllingExpr,
3237 ArrayRef<Expr *> Exprs) {
3238 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3239 /*PredicateIsExpr=*/true,
3240 ControllingExpr, Types, Exprs);
3241 }
3242
3243 /// Build a new generic selection expression with a type predicate.
3244 ///
3245 /// By default, performs semantic analysis to build the new expression.
3246 /// Subclasses may override this routine to provide different behavior.
3248 SourceLocation DefaultLoc,
3249 SourceLocation RParenLoc,
3250 TypeSourceInfo *ControllingType,
3252 ArrayRef<Expr *> Exprs) {
3253 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3254 /*PredicateIsExpr=*/false,
3255 ControllingType, Types, Exprs);
3256 }
3257
3258 /// Build a new overloaded operator call expression.
3259 ///
3260 /// By default, performs semantic analysis to build the new expression.
3261 /// The semantic analysis provides the behavior of template instantiation,
3262 /// copying with transformations that turn what looks like an overloaded
3263 /// operator call into a use of a builtin operator, performing
3264 /// argument-dependent lookup, etc. Subclasses may override this routine to
3265 /// provide different behavior.
3267 SourceLocation OpLoc,
3268 SourceLocation CalleeLoc,
3269 bool RequiresADL,
3270 const UnresolvedSetImpl &Functions,
3271 Expr *First, Expr *Second);
3272
3273 /// Build a new C++ "named" cast expression, such as static_cast or
3274 /// reinterpret_cast.
3275 ///
3276 /// By default, this routine dispatches to one of the more-specific routines
3277 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3278 /// Subclasses may override this routine to provide different behavior.
3281 SourceLocation LAngleLoc,
3282 TypeSourceInfo *TInfo,
3283 SourceLocation RAngleLoc,
3284 SourceLocation LParenLoc,
3285 Expr *SubExpr,
3286 SourceLocation RParenLoc) {
3287 switch (Class) {
3288 case Stmt::CXXStaticCastExprClass:
3289 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3290 RAngleLoc, LParenLoc,
3291 SubExpr, RParenLoc);
3292
3293 case Stmt::CXXDynamicCastExprClass:
3294 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3295 RAngleLoc, LParenLoc,
3296 SubExpr, RParenLoc);
3297
3298 case Stmt::CXXReinterpretCastExprClass:
3299 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3300 RAngleLoc, LParenLoc,
3301 SubExpr,
3302 RParenLoc);
3303
3304 case Stmt::CXXConstCastExprClass:
3305 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3306 RAngleLoc, LParenLoc,
3307 SubExpr, RParenLoc);
3308
3309 case Stmt::CXXAddrspaceCastExprClass:
3310 return getDerived().RebuildCXXAddrspaceCastExpr(
3311 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3312
3313 default:
3314 llvm_unreachable("Invalid C++ named cast");
3315 }
3316 }
3317
3318 /// Build a new C++ static_cast expression.
3319 ///
3320 /// By default, performs semantic analysis to build the new expression.
3321 /// Subclasses may override this routine to provide different behavior.
3323 SourceLocation LAngleLoc,
3324 TypeSourceInfo *TInfo,
3325 SourceLocation RAngleLoc,
3326 SourceLocation LParenLoc,
3327 Expr *SubExpr,
3328 SourceLocation RParenLoc) {
3329 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3330 TInfo, SubExpr,
3331 SourceRange(LAngleLoc, RAngleLoc),
3332 SourceRange(LParenLoc, RParenLoc));
3333 }
3334
3335 /// Build a new C++ dynamic_cast expression.
3336 ///
3337 /// By default, performs semantic analysis to build the new expression.
3338 /// Subclasses may override this routine to provide different behavior.
3340 SourceLocation LAngleLoc,
3341 TypeSourceInfo *TInfo,
3342 SourceLocation RAngleLoc,
3343 SourceLocation LParenLoc,
3344 Expr *SubExpr,
3345 SourceLocation RParenLoc) {
3346 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3347 TInfo, SubExpr,
3348 SourceRange(LAngleLoc, RAngleLoc),
3349 SourceRange(LParenLoc, RParenLoc));
3350 }
3351
3352 /// Build a new C++ reinterpret_cast expression.
3353 ///
3354 /// By default, performs semantic analysis to build the new expression.
3355 /// Subclasses may override this routine to provide different behavior.
3357 SourceLocation LAngleLoc,
3358 TypeSourceInfo *TInfo,
3359 SourceLocation RAngleLoc,
3360 SourceLocation LParenLoc,
3361 Expr *SubExpr,
3362 SourceLocation RParenLoc) {
3363 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3364 TInfo, SubExpr,
3365 SourceRange(LAngleLoc, RAngleLoc),
3366 SourceRange(LParenLoc, RParenLoc));
3367 }
3368
3369 /// Build a new C++ const_cast expression.
3370 ///
3371 /// By default, performs semantic analysis to build the new expression.
3372 /// Subclasses may override this routine to provide different behavior.
3374 SourceLocation LAngleLoc,
3375 TypeSourceInfo *TInfo,
3376 SourceLocation RAngleLoc,
3377 SourceLocation LParenLoc,
3378 Expr *SubExpr,
3379 SourceLocation RParenLoc) {
3380 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3381 TInfo, SubExpr,
3382 SourceRange(LAngleLoc, RAngleLoc),
3383 SourceRange(LParenLoc, RParenLoc));
3384 }
3385
3388 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3389 SourceLocation LParenLoc, Expr *SubExpr,
3390 SourceLocation RParenLoc) {
3391 return getSema().BuildCXXNamedCast(
3392 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3393 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3394 }
3395
3396 /// Build a new C++ functional-style cast expression.
3397 ///
3398 /// By default, performs semantic analysis to build the new expression.
3399 /// Subclasses may override this routine to provide different behavior.
3401 SourceLocation LParenLoc,
3402 Expr *Sub,
3403 SourceLocation RParenLoc,
3404 bool ListInitialization) {
3405 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3406 // CXXParenListInitExpr. Pass its expanded arguments so that the
3407 // CXXParenListInitExpr can be rebuilt.
3408 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3410 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3411 RParenLoc, ListInitialization);
3412
3413 if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub))
3415 TInfo, LParenLoc, PLE->getInitExprs(), RParenLoc, ListInitialization);
3416
3417 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3418 MultiExprArg(&Sub, 1), RParenLoc,
3419 ListInitialization);
3420 }
3421
3422 /// Build a new C++ __builtin_bit_cast expression.
3423 ///
3424 /// By default, performs semantic analysis to build the new expression.
3425 /// Subclasses may override this routine to provide different behavior.
3427 TypeSourceInfo *TSI, Expr *Sub,
3428 SourceLocation RParenLoc) {
3429 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3430 }
3431
3432 /// Build a new C++ typeid(type) expression.
3433 ///
3434 /// By default, performs semantic analysis to build the new expression.
3435 /// Subclasses may override this routine to provide different behavior.
3437 SourceLocation TypeidLoc,
3438 TypeSourceInfo *Operand,
3439 SourceLocation RParenLoc) {
3440 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3441 RParenLoc);
3442 }
3443
3444
3445 /// Build a new C++ typeid(expr) expression.
3446 ///
3447 /// By default, performs semantic analysis to build the new expression.
3448 /// Subclasses may override this routine to provide different behavior.
3450 SourceLocation TypeidLoc,
3451 Expr *Operand,
3452 SourceLocation RParenLoc) {
3453 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3454 RParenLoc);
3455 }
3456
3457 /// Build a new C++ __uuidof(type) expression.
3458 ///
3459 /// By default, performs semantic analysis to build the new expression.
3460 /// Subclasses may override this routine to provide different behavior.
3462 TypeSourceInfo *Operand,
3463 SourceLocation RParenLoc) {
3464 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3465 }
3466
3467 /// Build a new C++ __uuidof(expr) expression.
3468 ///
3469 /// By default, performs semantic analysis to build the new expression.
3470 /// Subclasses may override this routine to provide different behavior.
3472 Expr *Operand, SourceLocation RParenLoc) {
3473 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3474 }
3475
3476 /// Build a new C++ "this" expression.
3477 ///
3478 /// By default, performs semantic analysis to build a new "this" expression.
3479 /// Subclasses may override this routine to provide different behavior.
3481 QualType ThisType,
3482 bool isImplicit) {
3483 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3484 return ExprError();
3485 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3486 }
3487
3488 /// Build a new C++ throw expression.
3489 ///
3490 /// By default, performs semantic analysis to build the new expression.
3491 /// Subclasses may override this routine to provide different behavior.
3493 bool IsThrownVariableInScope) {
3494 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3495 }
3496
3497 /// Build a new C++ default-argument expression.
3498 ///
3499 /// By default, builds a new default-argument expression, which does not
3500 /// require any semantic analysis. Subclasses may override this routine to
3501 /// provide different behavior.
3503 Expr *RewrittenExpr) {
3504 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3505 RewrittenExpr, getSema().CurContext);
3506 }
3507
3508 /// Build a new C++11 default-initialization expression.
3509 ///
3510 /// By default, builds a new default field initialization expression, which
3511 /// does not require any semantic analysis. Subclasses may override this
3512 /// routine to provide different behavior.
3517
3518 /// Build a new C++ zero-initialization expression.
3519 ///
3520 /// By default, performs semantic analysis to build the new expression.
3521 /// Subclasses may override this routine to provide different behavior.
3523 SourceLocation LParenLoc,
3524 SourceLocation RParenLoc) {
3525 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3526 /*ListInitialization=*/false);
3527 }
3528
3529 /// Build a new C++ "new" expression.
3530 ///
3531 /// By default, performs semantic analysis to build the new expression.
3532 /// Subclasses may override this routine to provide different behavior.
3534 SourceLocation PlacementLParen,
3535 MultiExprArg PlacementArgs,
3536 SourceLocation PlacementRParen,
3537 SourceRange TypeIdParens, QualType AllocatedType,
3538 TypeSourceInfo *AllocatedTypeInfo,
3539 std::optional<Expr *> ArraySize,
3540 SourceRange DirectInitRange, Expr *Initializer) {
3541 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3542 PlacementLParen,
3543 PlacementArgs,
3544 PlacementRParen,
3545 TypeIdParens,
3546 AllocatedType,
3547 AllocatedTypeInfo,
3548 ArraySize,
3549 DirectInitRange,
3550 Initializer);
3551 }
3552
3553 /// Build a new C++ "delete" expression.
3554 ///
3555 /// By default, performs semantic analysis to build the new expression.
3556 /// Subclasses may override this routine to provide different behavior.
3558 bool IsGlobalDelete,
3559 bool IsArrayForm,
3560 Expr *Operand) {
3561 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3562 Operand);
3563 }
3564
3565 /// Build a new type trait expression.
3566 ///
3567 /// By default, performs semantic analysis to build the new expression.
3568 /// Subclasses may override this routine to provide different behavior.
3570 SourceLocation StartLoc,
3572 SourceLocation RParenLoc) {
3573 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3574 }
3575
3576 /// Build a new array type trait expression.
3577 ///
3578 /// By default, performs semantic analysis to build the new expression.
3579 /// Subclasses may override this routine to provide different behavior.
3581 SourceLocation StartLoc,
3582 TypeSourceInfo *TSInfo,
3583 Expr *DimExpr,
3584 SourceLocation RParenLoc) {
3585 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3586 }
3587
3588 /// Build a new expression trait expression.
3589 ///
3590 /// By default, performs semantic analysis to build the new expression.
3591 /// Subclasses may override this routine to provide different behavior.
3593 SourceLocation StartLoc,
3594 Expr *Queried,
3595 SourceLocation RParenLoc) {
3596 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3597 }
3598
3599 /// Build a new (previously unresolved) declaration reference
3600 /// expression.
3601 ///
3602 /// By default, performs semantic analysis to build the new expression.
3603 /// Subclasses may override this routine to provide different behavior.
3605 NestedNameSpecifierLoc QualifierLoc,
3606 SourceLocation TemplateKWLoc,
3607 const DeclarationNameInfo &NameInfo,
3608 const TemplateArgumentListInfo *TemplateArgs,
3609 bool IsAddressOfOperand,
3610 TypeSourceInfo **RecoveryTSI) {
3611 CXXScopeSpec SS;
3612 SS.Adopt(QualifierLoc);
3613
3614 if (TemplateArgs || TemplateKWLoc.isValid())
3616 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3617
3619 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3620 }
3621
3622 /// Build a new template-id expression.
3623 ///
3624 /// By default, performs semantic analysis to build the new expression.
3625 /// Subclasses may override this routine to provide different behavior.
3627 SourceLocation TemplateKWLoc,
3628 LookupResult &R,
3629 bool RequiresADL,
3630 const TemplateArgumentListInfo *TemplateArgs) {
3631 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3632 TemplateArgs);
3633 }
3634
3635 /// Build a new object-construction expression.
3636 ///
3637 /// By default, performs semantic analysis to build the new expression.
3638 /// Subclasses may override this routine to provide different behavior.
3641 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3642 bool ListInitialization, bool StdInitListInitialization,
3643 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3644 SourceRange ParenRange) {
3645 // Reconstruct the constructor we originally found, which might be
3646 // different if this is a call to an inherited constructor.
3647 CXXConstructorDecl *FoundCtor = Constructor;
3648 if (Constructor->isInheritingConstructor())
3649 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3650
3651 SmallVector<Expr *, 8> ConvertedArgs;
3652 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3653 ConvertedArgs))
3654 return ExprError();
3655
3656 return getSema().BuildCXXConstructExpr(Loc, T, Constructor,
3657 IsElidable,
3658 ConvertedArgs,
3659 HadMultipleCandidates,
3660 ListInitialization,
3661 StdInitListInitialization,
3662 RequiresZeroInit, ConstructKind,
3663 ParenRange);
3664 }
3665
3666 /// Build a new implicit construction via inherited constructor
3667 /// expression.
3670 bool ConstructsVBase,
3671 bool InheritedFromVBase) {
3673 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3674 }
3675
3676 /// Build a new object-construction expression.
3677 ///
3678 /// By default, performs semantic analysis to build the new expression.
3679 /// Subclasses may override this routine to provide different behavior.
3681 SourceLocation LParenOrBraceLoc,
3682 MultiExprArg Args,
3683 SourceLocation RParenOrBraceLoc,
3684 bool ListInitialization) {
3686 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3687 }
3688
3689 /// Build a new object-construction expression.
3690 ///
3691 /// By default, performs semantic analysis to build the new expression.
3692 /// Subclasses may override this routine to provide different behavior.
3694 SourceLocation LParenLoc,
3695 MultiExprArg Args,
3696 SourceLocation RParenLoc,
3697 bool ListInitialization) {
3698 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3699 RParenLoc, ListInitialization);
3700 }
3701
3702 /// Build a new member reference expression.
3703 ///
3704 /// By default, performs semantic analysis to build the new expression.
3705 /// Subclasses may override this routine to provide different behavior.
3707 QualType BaseType,
3708 bool IsArrow,
3709 SourceLocation OperatorLoc,
3710 NestedNameSpecifierLoc QualifierLoc,
3711 SourceLocation TemplateKWLoc,
3712 NamedDecl *FirstQualifierInScope,
3713 const DeclarationNameInfo &MemberNameInfo,
3714 const TemplateArgumentListInfo *TemplateArgs) {
3715 CXXScopeSpec SS;
3716 SS.Adopt(QualifierLoc);
3717
3718 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3719 OperatorLoc, IsArrow,
3720 SS, TemplateKWLoc,
3721 FirstQualifierInScope,
3722 MemberNameInfo,
3723 TemplateArgs, /*S*/nullptr);
3724 }
3725
3726 /// Build a new member reference expression.
3727 ///
3728 /// By default, performs semantic analysis to build the new expression.
3729 /// Subclasses may override this routine to provide different behavior.
3731 SourceLocation OperatorLoc,
3732 bool IsArrow,
3733 NestedNameSpecifierLoc QualifierLoc,
3734 SourceLocation TemplateKWLoc,
3735 NamedDecl *FirstQualifierInScope,
3736 LookupResult &R,
3737 const TemplateArgumentListInfo *TemplateArgs) {
3738 CXXScopeSpec SS;
3739 SS.Adopt(QualifierLoc);
3740
3741 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3742 OperatorLoc, IsArrow,
3743 SS, TemplateKWLoc,
3744 FirstQualifierInScope,
3745 R, TemplateArgs, /*S*/nullptr);
3746 }
3747
3748 /// Build a new noexcept expression.
3749 ///
3750 /// By default, performs semantic analysis to build the new expression.
3751 /// Subclasses may override this routine to provide different behavior.
3753 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3754 }
3755
3758
3759 /// Build a new expression to compute the length of a parameter pack.
3761 SourceLocation PackLoc,
3762 SourceLocation RParenLoc,
3763 UnsignedOrNone Length,
3764 ArrayRef<TemplateArgument> PartialArgs) {
3765 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3766 RParenLoc, Length, PartialArgs);
3767 }
3768
3770 SourceLocation RSquareLoc,
3771 Expr *PackIdExpression, Expr *IndexExpr,
3772 ArrayRef<Expr *> ExpandedExprs,
3773 bool FullySubstituted = false) {
3774 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3775 IndexExpr, RSquareLoc, ExpandedExprs,
3776 FullySubstituted);
3777 }
3778
3779 /// Build a new expression representing a call to a source location
3780 /// builtin.
3781 ///
3782 /// By default, performs semantic analysis to build the new expression.
3783 /// Subclasses may override this routine to provide different behavior.
3785 SourceLocation BuiltinLoc,
3786 SourceLocation RPLoc,
3787 DeclContext *ParentContext) {
3788 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3789 ParentContext);
3790 }
3791
3793 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3794 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3796 CXXScopeSpec SS;
3797 SS.Adopt(NNS);
3798 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3799 ConceptNameInfo,
3800 FoundDecl,
3801 NamedConcept, TALI);
3802 if (Result.isInvalid())
3803 return ExprError();
3804 return Result;
3805 }
3806
3807 /// \brief Build a new requires expression.
3808 ///
3809 /// By default, performs semantic analysis to build the new expression.
3810 /// Subclasses may override this routine to provide different behavior.
3813 SourceLocation LParenLoc,
3814 ArrayRef<ParmVarDecl *> LocalParameters,
3815 SourceLocation RParenLoc,
3817 SourceLocation ClosingBraceLoc) {
3818 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3819 LocalParameters, RParenLoc, Requirements,
3820 ClosingBraceLoc);
3821 }
3822
3826 return SemaRef.BuildTypeRequirement(SubstDiag);
3827 }
3828
3830 return SemaRef.BuildTypeRequirement(T);
3831 }
3832
3835 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3836 SourceLocation NoexceptLoc,
3838 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3839 std::move(Ret));
3840 }
3841
3843 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3845 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3846 std::move(Ret));
3847 }
3848
3850 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3851 const ASTConstraintSatisfaction &Satisfaction) {
3852 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3853 Satisfaction);
3854 }
3855
3857 return SemaRef.BuildNestedRequirement(Constraint);
3858 }
3859
3860 /// \brief Build a new Objective-C boxed expression.
3861 ///
3862 /// By default, performs semantic analysis to build the new expression.
3863 /// Subclasses may override this routine to provide different behavior.
3865 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3866 }
3867
3868 /// Build a new Objective-C array literal.
3869 ///
3870 /// By default, performs semantic analysis to build the new expression.
3871 /// Subclasses may override this routine to provide different behavior.
3873 Expr **Elements, unsigned NumElements) {
3875 Range, MultiExprArg(Elements, NumElements));
3876 }
3877
3879 Expr *Base, Expr *Key,
3880 ObjCMethodDecl *getterMethod,
3881 ObjCMethodDecl *setterMethod) {
3883 RB, Base, Key, getterMethod, setterMethod);
3884 }
3885
3886 /// Build a new Objective-C dictionary literal.
3887 ///
3888 /// By default, performs semantic analysis to build the new expression.
3889 /// Subclasses may override this routine to provide different behavior.
3894
3895 /// Build a new Objective-C \@encode expression.
3896 ///
3897 /// By default, performs semantic analysis to build the new expression.
3898 /// Subclasses may override this routine to provide different behavior.
3900 TypeSourceInfo *EncodeTypeInfo,
3901 SourceLocation RParenLoc) {
3902 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3903 RParenLoc);
3904 }
3905
3906 /// Build a new Objective-C class message.
3908 Selector Sel,
3909 ArrayRef<SourceLocation> SelectorLocs,
3911 SourceLocation LBracLoc,
3912 MultiExprArg Args,
3913 SourceLocation RBracLoc) {
3914 return SemaRef.ObjC().BuildClassMessage(
3915 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3916 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3917 RBracLoc, Args);
3918 }
3919
3920 /// Build a new Objective-C instance message.
3922 Selector Sel,
3923 ArrayRef<SourceLocation> SelectorLocs,
3925 SourceLocation LBracLoc,
3926 MultiExprArg Args,
3927 SourceLocation RBracLoc) {
3928 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3929 /*SuperLoc=*/SourceLocation(),
3930 Sel, Method, LBracLoc,
3931 SelectorLocs, RBracLoc, Args);
3932 }
3933
3934 /// Build a new Objective-C instance/class message to 'super'.
3936 Selector Sel,
3937 ArrayRef<SourceLocation> SelectorLocs,
3938 QualType SuperType,
3940 SourceLocation LBracLoc,
3941 MultiExprArg Args,
3942 SourceLocation RBracLoc) {
3943 return Method->isInstanceMethod()
3944 ? SemaRef.ObjC().BuildInstanceMessage(
3945 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3946 SelectorLocs, RBracLoc, Args)
3947 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3948 Sel, Method, LBracLoc,
3949 SelectorLocs, RBracLoc, Args);
3950 }
3951
3952 /// Build a new Objective-C ivar reference expression.
3953 ///
3954 /// By default, performs semantic analysis to build the new expression.
3955 /// Subclasses may override this routine to provide different behavior.
3957 SourceLocation IvarLoc,
3958 bool IsArrow, bool IsFreeIvar) {
3959 CXXScopeSpec SS;
3960 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3962 BaseArg, BaseArg->getType(),
3963 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3964 /*FirstQualifierInScope=*/nullptr, NameInfo,
3965 /*TemplateArgs=*/nullptr,
3966 /*S=*/nullptr);
3967 if (IsFreeIvar && Result.isUsable())
3968 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3969 return Result;
3970 }
3971
3972 /// Build a new Objective-C property reference expression.
3973 ///
3974 /// By default, performs semantic analysis to build the new expression.
3975 /// Subclasses may override this routine to provide different behavior.
3978 SourceLocation PropertyLoc) {
3979 CXXScopeSpec SS;
3980 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3981 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3982 /*FIXME:*/PropertyLoc,
3983 /*IsArrow=*/false,
3984 SS, SourceLocation(),
3985 /*FirstQualifierInScope=*/nullptr,
3986 NameInfo,
3987 /*TemplateArgs=*/nullptr,
3988 /*S=*/nullptr);
3989 }
3990
3991 /// Build a new Objective-C property reference expression.
3992 ///
3993 /// By default, performs semantic analysis to build the new expression.
3994 /// Subclasses may override this routine to provide different behavior.
3996 ObjCMethodDecl *Getter,
3997 ObjCMethodDecl *Setter,
3998 SourceLocation PropertyLoc) {
3999 // Since these expressions can only be value-dependent, we do not
4000 // need to perform semantic analysis again.
4001 return Owned(
4002 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
4004 PropertyLoc, Base));
4005 }
4006
4007 /// Build a new Objective-C "isa" expression.
4008 ///
4009 /// By default, performs semantic analysis to build the new expression.
4010 /// Subclasses may override this routine to provide different behavior.
4012 SourceLocation OpLoc, bool IsArrow) {
4013 CXXScopeSpec SS;
4014 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
4015 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
4016 OpLoc, IsArrow,
4017 SS, SourceLocation(),
4018 /*FirstQualifierInScope=*/nullptr,
4019 NameInfo,
4020 /*TemplateArgs=*/nullptr,
4021 /*S=*/nullptr);
4022 }
4023
4024 /// Build a new shuffle vector expression.
4025 ///
4026 /// By default, performs semantic analysis to build the new expression.
4027 /// Subclasses may override this routine to provide different behavior.
4029 MultiExprArg SubExprs,
4030 SourceLocation RParenLoc) {
4031 // Find the declaration for __builtin_shufflevector
4032 const IdentifierInfo &Name
4033 = SemaRef.Context.Idents.get("__builtin_shufflevector");
4034 TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
4035 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
4036 assert(!Lookup.empty() && "No __builtin_shufflevector?");
4037
4038 // Build a reference to the __builtin_shufflevector builtin
4040 Expr *Callee = new (SemaRef.Context)
4041 DeclRefExpr(SemaRef.Context, Builtin, false,
4042 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
4043 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
4044 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
4045 CK_BuiltinFnToFnPtr).get();
4046
4047 // Build the CallExpr
4048 ExprResult TheCall = CallExpr::Create(
4049 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
4050 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
4052
4053 // Type-check the __builtin_shufflevector expression.
4054 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
4055 }
4056
4057 /// Build a new convert vector expression.
4059 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
4060 SourceLocation RParenLoc) {
4061 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
4062 }
4063
4064 /// Build a new template argument pack expansion.
4065 ///
4066 /// By default, performs semantic analysis to build a new pack expansion
4067 /// for a template argument. Subclasses may override this routine to provide
4068 /// different behavior.
4070 SourceLocation EllipsisLoc,
4071 UnsignedOrNone NumExpansions) {
4072 switch (Pattern.getArgument().getKind()) {
4076 EllipsisLoc, NumExpansions);
4077 if (Result.isInvalid())
4078 return TemplateArgumentLoc();
4079
4081 /*IsCanonical=*/false),
4082 Result.get());
4083 }
4084
4086 return TemplateArgumentLoc(
4087 SemaRef.Context,
4089 NumExpansions),
4090 Pattern.getTemplateKWLoc(), Pattern.getTemplateQualifierLoc(),
4091 Pattern.getTemplateNameLoc(), EllipsisLoc);
4092
4100 llvm_unreachable("Pack expansion pattern has no parameter packs");
4101
4103 if (TypeSourceInfo *Expansion
4104 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4105 EllipsisLoc,
4106 NumExpansions))
4107 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4108 Expansion);
4109 break;
4110 }
4111
4112 return TemplateArgumentLoc();
4113 }
4114
4115 /// Build a new expression pack expansion.
4116 ///
4117 /// By default, performs semantic analysis to build a new pack expansion
4118 /// for an expression. Subclasses may override this routine to provide
4119 /// different behavior.
4121 UnsignedOrNone NumExpansions) {
4122 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4123 }
4124
4125 /// Build a new C++1z fold-expression.
4126 ///
4127 /// By default, performs semantic analysis in order to build a new fold
4128 /// expression.
4130 SourceLocation LParenLoc, Expr *LHS,
4131 BinaryOperatorKind Operator,
4132 SourceLocation EllipsisLoc, Expr *RHS,
4133 SourceLocation RParenLoc,
4134 UnsignedOrNone NumExpansions) {
4135 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4136 EllipsisLoc, RHS, RParenLoc,
4137 NumExpansions);
4138 }
4139
4141 LambdaScopeInfo *LSI) {
4142 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4143 if (Expr *Init = PVD->getInit())
4145 Init->containsUnexpandedParameterPack();
4146 else if (PVD->hasUninstantiatedDefaultArg())
4148 PVD->getUninstantiatedDefaultArg()
4149 ->containsUnexpandedParameterPack();
4150 }
4151 return getSema().BuildLambdaExpr(StartLoc, EndLoc);
4152 }
4153
4154 /// Build an empty C++1z fold-expression with the given operator.
4155 ///
4156 /// By default, produces the fallback value for the fold-expression, or
4157 /// produce an error if there is no fallback value.
4159 BinaryOperatorKind Operator) {
4160 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4161 }
4162
4163 /// Build a new atomic operation expression.
4164 ///
4165 /// By default, performs semantic analysis to build the new expression.
4166 /// Subclasses may override this routine to provide different behavior.
4169 SourceLocation RParenLoc) {
4170 // Use this for all of the locations, since we don't know the difference
4171 // between the call and the expr at this point.
4172 SourceRange Range{BuiltinLoc, RParenLoc};
4173 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4175 }
4176
4178 ArrayRef<Expr *> SubExprs, QualType Type) {
4179 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4180 }
4181
4183 SourceLocation BeginLoc,
4184 SourceLocation DirLoc,
4185 SourceLocation EndLoc,
4187 StmtResult StrBlock) {
4189 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4190 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, StrBlock);
4191 }
4192
4203
4205 SourceLocation BeginLoc,
4206 SourceLocation DirLoc,
4207 SourceLocation EndLoc,
4209 StmtResult Loop) {
4211 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4212 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, Loop);
4213 }
4214
4216 SourceLocation DirLoc,
4217 SourceLocation EndLoc,
4219 StmtResult StrBlock) {
4221 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4223 Clauses, StrBlock);
4224 }
4225
4235
4245
4247 SourceLocation DirLoc,
4248 SourceLocation EndLoc,
4250 StmtResult StrBlock) {
4254 Clauses, StrBlock);
4255 }
4256
4258 SourceLocation DirLoc,
4259 SourceLocation EndLoc,
4260 ArrayRef<OpenACCClause *> Clauses) {
4262 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4264 Clauses, {});
4265 }
4266
4276
4278 SourceLocation DirLoc,
4279 SourceLocation EndLoc,
4280 ArrayRef<OpenACCClause *> Clauses) {
4282 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4284 Clauses, {});
4285 }
4286
4288 SourceLocation DirLoc,
4289 SourceLocation EndLoc,
4290 ArrayRef<OpenACCClause *> Clauses) {
4292 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4294 Clauses, {});
4295 }
4296
4298 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4299 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4300 SourceLocation RParenLoc, SourceLocation EndLoc,
4301 ArrayRef<OpenACCClause *> Clauses) {
4303 Exprs.push_back(DevNumExpr);
4304 llvm::append_range(Exprs, QueueIdExprs);
4306 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4307 Exprs, OpenACCAtomicKind::None, RParenLoc, EndLoc, Clauses, {});
4308 }
4309
4311 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4312 SourceLocation ReadOnlyLoc, ArrayRef<Expr *> VarList,
4313 SourceLocation RParenLoc, SourceLocation EndLoc) {
4315 OpenACCDirectiveKind::Cache, BeginLoc, DirLoc, LParenLoc, ReadOnlyLoc,
4316 VarList, OpenACCAtomicKind::None, RParenLoc, EndLoc, {}, {});
4317 }
4318
4320 SourceLocation DirLoc,
4321 OpenACCAtomicKind AtKind,
4322 SourceLocation EndLoc,
4324 StmtResult AssociatedStmt) {
4326 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4327 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, Clauses,
4328 AssociatedStmt);
4329 }
4330
4334
4337 const NonTypeTemplateParmDecl *NTTP,
4339 UnsignedOrNone PackIndex, bool Final) {
4341 AssociatedDecl, NTTP, Loc, Arg, PackIndex, Final);
4342 }
4343
4345 SourceLocation StartLoc,
4346 SourceLocation LParenLoc,
4347 SourceLocation EndLoc) {
4348 return getSema().OpenMP().ActOnOpenMPTransparentClause(ImpexType, StartLoc,
4349 LParenLoc, EndLoc);
4350 }
4351
4352private:
4353 QualType TransformTypeInObjectScope(TypeLocBuilder &TLB, TypeLoc TL,
4354 QualType ObjectType,
4355 NamedDecl *FirstQualifierInScope);
4356
4357 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4358 QualType ObjectType,
4359 NamedDecl *FirstQualifierInScope) {
4360 if (getDerived().AlreadyTransformed(TSInfo->getType()))
4361 return TSInfo;
4362
4363 TypeLocBuilder TLB;
4364 QualType T = TransformTypeInObjectScope(TLB, TSInfo->getTypeLoc(),
4365 ObjectType, FirstQualifierInScope);
4366 if (T.isNull())
4367 return nullptr;
4368 return TLB.getTypeSourceInfo(SemaRef.Context, T);
4369 }
4370
4371 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4372 DependentNameTypeLoc TL,
4373 bool DeducibleTSTContext,
4374 QualType ObjectType = QualType(),
4375 NamedDecl *UnqualLookup = nullptr);
4376
4378 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4380
4381 OpenACCClause *
4382 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4383 OpenACCDirectiveKind DirKind,
4384 const OpenACCClause *OldClause);
4385};
4386
4387template <typename Derived>
4389 if (!S)
4390 return S;
4391
4392 switch (S->getStmtClass()) {
4393 case Stmt::NoStmtClass: break;
4394
4395 // Transform individual statement nodes
4396 // Pass SDK into statements that can produce a value
4397#define STMT(Node, Parent) \
4398 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4399#define VALUESTMT(Node, Parent) \
4400 case Stmt::Node##Class: \
4401 return getDerived().Transform##Node(cast<Node>(S), SDK);
4402#define ABSTRACT_STMT(Node)
4403#define EXPR(Node, Parent)
4404#include "clang/AST/StmtNodes.inc"
4405
4406 // Transform expressions by calling TransformExpr.
4407#define STMT(Node, Parent)
4408#define ABSTRACT_STMT(Stmt)
4409#define EXPR(Node, Parent) case Stmt::Node##Class:
4410#include "clang/AST/StmtNodes.inc"
4411 {
4412 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4413
4415 E = getSema().ActOnStmtExprResult(E);
4416 return getSema().ActOnExprStmt(E, SDK == StmtDiscardKind::Discarded);
4417 }
4418 }
4419
4420 return S;
4421}
4422
4423template<typename Derived>
4425 if (!S)
4426 return S;
4427
4428 switch (S->getClauseKind()) {
4429 default: break;
4430 // Transform individual clause nodes
4431#define GEN_CLANG_CLAUSE_CLASS
4432#define CLAUSE_CLASS(Enum, Str, Class) \
4433 case Enum: \
4434 return getDerived().Transform##Class(cast<Class>(S));
4435#include "llvm/Frontend/OpenMP/OMP.inc"
4436 }
4437
4438 return S;
4439}
4440
4441
4442template<typename Derived>
4444 if (!E)
4445 return E;
4446
4447 switch (E->getStmtClass()) {
4448 case Stmt::NoStmtClass: break;
4449#define STMT(Node, Parent) case Stmt::Node##Class: break;
4450#define ABSTRACT_STMT(Stmt)
4451#define EXPR(Node, Parent) \
4452 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4453#include "clang/AST/StmtNodes.inc"
4454 }
4455
4456 return E;
4457}
4458
4459template<typename Derived>
4461 bool NotCopyInit) {
4462 // Initializers are instantiated like expressions, except that various outer
4463 // layers are stripped.
4464 if (!Init)
4465 return Init;
4466
4467 if (auto *FE = dyn_cast<FullExpr>(Init))
4468 Init = FE->getSubExpr();
4469
4470 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4471 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4472 Init = OVE->getSourceExpr();
4473 }
4474
4475 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4476 Init = MTE->getSubExpr();
4477
4478 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4479 Init = Binder->getSubExpr();
4480
4481 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4482 Init = ICE->getSubExprAsWritten();
4483
4484 if (CXXStdInitializerListExpr *ILE =
4485 dyn_cast<CXXStdInitializerListExpr>(Init))
4486 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4487
4488 // If this is copy-initialization, we only need to reconstruct
4489 // InitListExprs. Other forms of copy-initialization will be a no-op if
4490 // the initializer is already the right type.
4491 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4492 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4493 return getDerived().TransformExpr(Init);
4494
4495 // Revert value-initialization back to empty parens.
4496 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4497 SourceRange Parens = VIE->getSourceRange();
4498 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4499 Parens.getEnd());
4500 }
4501
4502 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4504 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4505 SourceLocation());
4506
4507 // Revert initialization by constructor back to a parenthesized or braced list
4508 // of expressions. Any other form of initializer can just be reused directly.
4509 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4510 return getDerived().TransformExpr(Init);
4511
4512 // If the initialization implicitly converted an initializer list to a
4513 // std::initializer_list object, unwrap the std::initializer_list too.
4514 if (Construct && Construct->isStdInitListInitialization())
4515 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4516
4517 // Enter a list-init context if this was list initialization.
4520 Construct->isListInitialization());
4521
4522 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4523 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4524 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4525 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4526 SmallVector<Expr*, 8> NewArgs;
4527 bool ArgChanged = false;
4528 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4529 /*IsCall*/true, NewArgs, &ArgChanged))
4530 return ExprError();
4531
4532 // If this was list initialization, revert to syntactic list form.
4533 if (Construct->isListInitialization())
4534 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4535 Construct->getEndLoc());
4536
4537 // Build a ParenListExpr to represent anything else.
4539 if (Parens.isInvalid()) {
4540 // This was a variable declaration's initialization for which no initializer
4541 // was specified.
4542 assert(NewArgs.empty() &&
4543 "no parens or braces but have direct init with arguments?");
4544 return ExprEmpty();
4545 }
4546 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4547 Parens.getEnd());
4548}
4549
4550template<typename Derived>
4552 unsigned NumInputs,
4553 bool IsCall,
4554 SmallVectorImpl<Expr *> &Outputs,
4555 bool *ArgChanged) {
4556 for (unsigned I = 0; I != NumInputs; ++I) {
4557 // If requested, drop call arguments that need to be dropped.
4558 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4559 if (ArgChanged)
4560 *ArgChanged = true;
4561
4562 break;
4563 }
4564
4565 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4566 Expr *Pattern = Expansion->getPattern();
4567
4569 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4570 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4571
4572 // Determine whether the set of unexpanded parameter packs can and should
4573 // be expanded.
4574 bool Expand = true;
4575 bool RetainExpansion = false;
4576 UnsignedOrNone OrigNumExpansions = Expansion->getNumExpansions();
4577 UnsignedOrNone NumExpansions = OrigNumExpansions;
4579 Expansion->getEllipsisLoc(), Pattern->getSourceRange(),
4580 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
4581 RetainExpansion, NumExpansions))
4582 return true;
4583
4584 if (!Expand) {
4585 // The transform has determined that we should perform a simple
4586 // transformation on the pack expansion, producing another pack
4587 // expansion.
4588 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
4589 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4590 if (OutPattern.isInvalid())
4591 return true;
4592
4593 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4594 Expansion->getEllipsisLoc(),
4595 NumExpansions);
4596 if (Out.isInvalid())
4597 return true;
4598
4599 if (ArgChanged)
4600 *ArgChanged = true;
4601 Outputs.push_back(Out.get());
4602 continue;
4603 }
4604
4605 // Record right away that the argument was changed. This needs
4606 // to happen even if the array expands to nothing.
4607 if (ArgChanged) *ArgChanged = true;
4608
4609 // The transform has determined that we should perform an elementwise
4610 // expansion of the pattern. Do so.
4611 for (unsigned I = 0; I != *NumExpansions; ++I) {
4612 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
4613 ExprResult Out = getDerived().TransformExpr(Pattern);
4614 if (Out.isInvalid())
4615 return true;
4616
4617 if (Out.get()->containsUnexpandedParameterPack()) {
4618 Out = getDerived().RebuildPackExpansion(
4619 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4620 if (Out.isInvalid())
4621 return true;
4622 }
4623
4624 Outputs.push_back(Out.get());
4625 }
4626
4627 // If we're supposed to retain a pack expansion, do so by temporarily
4628 // forgetting the partially-substituted parameter pack.
4629 if (RetainExpansion) {
4630 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4631
4632 ExprResult Out = getDerived().TransformExpr(Pattern);
4633 if (Out.isInvalid())
4634 return true;
4635
4636 Out = getDerived().RebuildPackExpansion(
4637 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4638 if (Out.isInvalid())
4639 return true;
4640
4641 Outputs.push_back(Out.get());
4642 }
4643
4644 continue;
4645 }
4646
4648 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4649 : getDerived().TransformExpr(Inputs[I]);
4650 if (Result.isInvalid())
4651 return true;
4652
4653 if (Result.get() != Inputs[I] && ArgChanged)
4654 *ArgChanged = true;
4655
4656 Outputs.push_back(Result.get());
4657 }
4658
4659 return false;
4660}
4661
4662template <typename Derived>
4665
4668 /*LambdaContextDecl=*/nullptr,
4670 /*ShouldEnter=*/Kind == Sema::ConditionKind::ConstexprIf);
4671
4672 if (Var) {
4673 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4675
4676 if (!ConditionVar)
4677 return Sema::ConditionError();
4678
4679 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4680 }
4681
4682 if (Expr) {
4683 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4684
4685 if (CondExpr.isInvalid())
4686 return Sema::ConditionError();
4687
4688 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4689 /*MissingOK=*/true);
4690 }
4691
4692 return Sema::ConditionResult();
4693}
4694
4695template <typename Derived>
4697 NestedNameSpecifierLoc NNS, QualType ObjectType,
4698 NamedDecl *FirstQualifierInScope) {
4700
4701 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4702 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4703 Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix)
4704 Qualifiers.push_back(Qualifier);
4705 };
4706 insertNNS(NNS);
4707
4708 CXXScopeSpec SS;
4709 while (!Qualifiers.empty()) {
4710 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4712
4713 switch (QNNS.getKind()) {
4715 llvm_unreachable("unexpected null nested name specifier");
4716
4719 Q.getLocalBeginLoc(), const_cast<NamespaceBaseDecl *>(
4721 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4722 break;
4723 }
4724
4726 // There is no meaningful transformation that one could perform on the
4727 // global scope.
4728 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4729 break;
4730
4732 CXXRecordDecl *RD = cast_or_null<CXXRecordDecl>(
4734 SS.MakeMicrosoftSuper(SemaRef.Context, RD, Q.getBeginLoc(),
4735 Q.getEndLoc());
4736 break;
4737 }
4738
4740 assert(SS.isEmpty());
4741 TypeLoc TL = Q.castAsTypeLoc();
4742
4743 if (auto DNT = TL.getAs<DependentNameTypeLoc>()) {
4744 NestedNameSpecifierLoc QualifierLoc = DNT.getQualifierLoc();
4745 if (QualifierLoc) {
4746 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4747 QualifierLoc, ObjectType, FirstQualifierInScope);
4748 if (!QualifierLoc)
4749 return NestedNameSpecifierLoc();
4750 ObjectType = QualType();
4751 FirstQualifierInScope = nullptr;
4752 }
4753 SS.Adopt(QualifierLoc);
4755 const_cast<IdentifierInfo *>(DNT.getTypePtr()->getIdentifier()),
4756 DNT.getNameLoc(), Q.getLocalEndLoc(), ObjectType);
4757 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo,
4758 false, SS,
4759 FirstQualifierInScope, false))
4760 return NestedNameSpecifierLoc();
4761 return SS.getWithLocInContext(SemaRef.Context);
4762 }
4763
4764 QualType T = TL.getType();
4765 TypeLocBuilder TLB;
4766 if (!getDerived().AlreadyTransformed(T)) {
4767 T = TransformTypeInObjectScope(TLB, TL, ObjectType,
4768 FirstQualifierInScope);
4769 if (T.isNull())
4770 return NestedNameSpecifierLoc();
4771 TL = TLB.getTypeLocInContext(SemaRef.Context, T);
4772 }
4773
4774 if (T->isDependentType() || T->isRecordType() ||
4775 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4776 if (T->isEnumeralType())
4777 SemaRef.Diag(TL.getBeginLoc(),
4778 diag::warn_cxx98_compat_enum_nested_name_spec);
4779 SS.Make(SemaRef.Context, TL, Q.getLocalEndLoc());
4780 break;
4781 }
4782 // If the nested-name-specifier is an invalid type def, don't emit an
4783 // error because a previous error should have already been emitted.
4785 if (!TTL || !TTL.getDecl()->isInvalidDecl()) {
4786 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4787 << T << SS.getRange();
4788 }
4789 return NestedNameSpecifierLoc();
4790 }
4791 }
4792 }
4793
4794 // Don't rebuild the nested-name-specifier if we don't have to.
4795 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4797 return NNS;
4798
4799 // If we can re-use the source-location data from the original
4800 // nested-name-specifier, do so.
4801 if (SS.location_size() == NNS.getDataLength() &&
4802 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4804
4805 // Allocate new nested-name-specifier location information.
4806 return SS.getWithLocInContext(SemaRef.Context);
4807}
4808
4809template<typename Derived>
4813 DeclarationName Name = NameInfo.getName();
4814 if (!Name)
4815 return DeclarationNameInfo();
4816
4817 switch (Name.getNameKind()) {
4825 return NameInfo;
4826
4828 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4829 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4830 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4831 if (!NewTemplate)
4832 return DeclarationNameInfo();
4833
4834 DeclarationNameInfo NewNameInfo(NameInfo);
4835 NewNameInfo.setName(
4836 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
4837 return NewNameInfo;
4838 }
4839
4843 TypeSourceInfo *NewTInfo;
4844 CanQualType NewCanTy;
4845 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4846 NewTInfo = getDerived().TransformType(OldTInfo);
4847 if (!NewTInfo)
4848 return DeclarationNameInfo();
4849 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4850 }
4851 else {
4852 NewTInfo = nullptr;
4853 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4854 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4855 if (NewT.isNull())
4856 return DeclarationNameInfo();
4857 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4858 }
4859
4860 DeclarationName NewName
4861 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4862 NewCanTy);
4863 DeclarationNameInfo NewNameInfo(NameInfo);
4864 NewNameInfo.setName(NewName);
4865 NewNameInfo.setNamedTypeInfo(NewTInfo);
4866 return NewNameInfo;
4867 }
4868 }
4869
4870 llvm_unreachable("Unknown name kind.");
4871}
4872
4873template <typename Derived>
4875 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4877 QualType ObjectType, bool AllowInjectedClassName) {
4878 if (const IdentifierInfo *II = IO.getIdentifier())
4879 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, *II, NameLoc,
4880 ObjectType, AllowInjectedClassName);
4881 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, IO.getOperator(),
4882 NameLoc, ObjectType,
4883 AllowInjectedClassName);
4884}
4885
4886template <typename Derived>
4888 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
4889 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
4890 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
4892 TemplateName UnderlyingName = QTN->getUnderlyingTemplate();
4893
4894 if (QualifierLoc) {
4895 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4896 QualifierLoc, ObjectType, FirstQualifierInScope);
4897 if (!QualifierLoc)
4898 return TemplateName();
4899 }
4900
4901 NestedNameSpecifierLoc UnderlyingQualifier;
4902 TemplateName NewUnderlyingName = getDerived().TransformTemplateName(
4903 UnderlyingQualifier, TemplateKWLoc, UnderlyingName, NameLoc, ObjectType,
4904 FirstQualifierInScope, AllowInjectedClassName);
4905 if (NewUnderlyingName.isNull())
4906 return TemplateName();
4907 assert(!UnderlyingQualifier && "unexpected qualifier");
4908
4909 if (!getDerived().AlwaysRebuild() &&
4910 QualifierLoc.getNestedNameSpecifier() == QTN->getQualifier() &&
4911 NewUnderlyingName == UnderlyingName)
4912 return Name;
4913 CXXScopeSpec SS;
4914 SS.Adopt(QualifierLoc);
4915 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4916 NewUnderlyingName);
4917 }
4918
4920 if (QualifierLoc) {
4921 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4922 QualifierLoc, ObjectType, FirstQualifierInScope);
4923 if (!QualifierLoc)
4924 return TemplateName();
4925 // The qualifier-in-scope and object type only apply to the leftmost
4926 // entity.
4927 ObjectType = QualType();
4928 }
4929
4930 if (!getDerived().AlwaysRebuild() &&
4931 QualifierLoc.getNestedNameSpecifier() == DTN->getQualifier() &&
4932 ObjectType.isNull())
4933 return Name;
4934
4935 CXXScopeSpec SS;
4936 SS.Adopt(QualifierLoc);
4937 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, DTN->getName(),
4938 NameLoc, ObjectType,
4939 AllowInjectedClassName);
4940 }
4941
4944 assert(!QualifierLoc && "Unexpected qualified SubstTemplateTemplateParm");
4945
4946 NestedNameSpecifierLoc ReplacementQualifierLoc;
4947 TemplateName ReplacementName = S->getReplacement();
4948 if (NestedNameSpecifier Qualifier = ReplacementName.getQualifier()) {
4950 Builder.MakeTrivial(SemaRef.Context, Qualifier, NameLoc);
4951 ReplacementQualifierLoc = Builder.getWithLocInContext(SemaRef.Context);
4952 }
4953
4954 TemplateName NewName = getDerived().TransformTemplateName(
4955 ReplacementQualifierLoc, TemplateKWLoc, ReplacementName, NameLoc,
4956 ObjectType, FirstQualifierInScope, AllowInjectedClassName);
4957 if (NewName.isNull())
4958 return TemplateName();
4959 Decl *AssociatedDecl =
4960 getDerived().TransformDecl(NameLoc, S->getAssociatedDecl());
4961 if (!getDerived().AlwaysRebuild() && NewName == S->getReplacement() &&
4962 AssociatedDecl == S->getAssociatedDecl())
4963 return Name;
4964 return SemaRef.Context.getSubstTemplateTemplateParm(
4965 NewName, AssociatedDecl, S->getIndex(), S->getPackIndex(),
4966 S->getFinal());
4967 }
4968
4969 assert(!Name.getAsDeducedTemplateName() &&
4970 "DeducedTemplateName should not escape partial ordering");
4971
4972 // FIXME: Preserve UsingTemplateName.
4973 if (auto *Template = Name.getAsTemplateDecl()) {
4974 assert(!QualifierLoc && "Unexpected qualifier");
4975 return TemplateName(cast_or_null<TemplateDecl>(
4976 getDerived().TransformDecl(NameLoc, Template)));
4977 }
4978
4981 assert(!QualifierLoc &&
4982 "Unexpected qualified SubstTemplateTemplateParmPack");
4983 return getDerived().RebuildTemplateName(
4984 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4985 SubstPack->getIndex(), SubstPack->getFinal());
4986 }
4987
4988 // These should be getting filtered out before they reach the AST.
4989 llvm_unreachable("overloaded function decl survived to here");
4990}
4991
4992template <typename Derived>
4994 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
4995 TemplateName Name, SourceLocation NameLoc) {
4996 TemplateName TN = getDerived().TransformTemplateName(
4997 QualifierLoc, TemplateKeywordLoc, Name, NameLoc);
4998 if (TN.isNull())
4999 return TemplateArgument();
5000 return TemplateArgument(TN);
5001}
5002
5003template<typename Derived>
5005 const TemplateArgument &Arg,
5006 TemplateArgumentLoc &Output) {
5007 Output = getSema().getTrivialTemplateArgumentLoc(
5008 Arg, QualType(), getDerived().getBaseLocation());
5009}
5010
5011template <typename Derived>
5013 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
5014 bool Uneval) {
5015 const TemplateArgument &Arg = Input.getArgument();
5016 switch (Arg.getKind()) {
5019 llvm_unreachable("Unexpected TemplateArgument");
5020
5025 // Transform a resolved template argument straight to a resolved template
5026 // argument. We get here when substituting into an already-substituted
5027 // template type argument during concept satisfaction checking.
5029 QualType NewT = getDerived().TransformType(T);
5030 if (NewT.isNull())
5031 return true;
5032
5034 ? Arg.getAsDecl()
5035 : nullptr;
5036 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
5038 : nullptr;
5039 if (D && !NewD)
5040 return true;
5041
5042 if (NewT == T && D == NewD)
5043 Output = Input;
5044 else if (Arg.getKind() == TemplateArgument::Integral)
5045 Output = TemplateArgumentLoc(
5046 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
5048 else if (Arg.getKind() == TemplateArgument::NullPtr)
5049 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
5051 else if (Arg.getKind() == TemplateArgument::Declaration)
5052 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
5055 Output = TemplateArgumentLoc(
5056 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
5058 else
5059 llvm_unreachable("unexpected template argument kind");
5060
5061 return false;
5062 }
5063
5065 TypeSourceInfo *TSI = Input.getTypeSourceInfo();
5066 if (!TSI)
5068
5069 TSI = getDerived().TransformType(TSI);
5070 if (!TSI)
5071 return true;
5072
5073 Output = TemplateArgumentLoc(TemplateArgument(TSI->getType()), TSI);
5074 return false;
5075 }
5076
5078 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
5079
5080 TemplateArgument Out = getDerived().TransformNamedTemplateTemplateArgument(
5081 QualifierLoc, Input.getTemplateKWLoc(), Arg.getAsTemplate(),
5082 Input.getTemplateNameLoc());
5083 if (Out.isNull())
5084 return true;
5085 Output = TemplateArgumentLoc(SemaRef.Context, Out, Input.getTemplateKWLoc(),
5086 QualifierLoc, Input.getTemplateNameLoc());
5087 return false;
5088 }
5089
5091 llvm_unreachable("Caller should expand pack expansions");
5092
5094 // Template argument expressions are constant expressions.
5096 getSema(),
5099 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
5101
5102 Expr *InputExpr = Input.getSourceExpression();
5103 if (!InputExpr)
5104 InputExpr = Input.getArgument().getAsExpr();
5105
5106 ExprResult E = getDerived().TransformExpr(InputExpr);
5107 E = SemaRef.ActOnConstantExpression(E);
5108 if (E.isInvalid())
5109 return true;
5110 Output = TemplateArgumentLoc(
5111 TemplateArgument(E.get(), /*IsCanonical=*/false), E.get());
5112 return false;
5113 }
5114 }
5115
5116 // Work around bogus GCC warning
5117 return true;
5118}
5119
5120/// Iterator adaptor that invents template argument location information
5121/// for each of the template arguments in its underlying iterator.
5122template<typename Derived, typename InputIterator>
5125 InputIterator Iter;
5126
5127public:
5130 typedef typename std::iterator_traits<InputIterator>::difference_type
5132 typedef std::input_iterator_tag iterator_category;
5133
5134 class pointer {
5136
5137 public:
5138 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5139
5140 const TemplateArgumentLoc *operator->() const { return &Arg; }
5141 };
5142
5144 InputIterator Iter)
5145 : Self(Self), Iter(Iter) { }
5146
5148 ++Iter;
5149 return *this;
5150 }
5151
5154 ++(*this);
5155 return Old;
5156 }
5157
5160 Self.InventTemplateArgumentLoc(*Iter, Result);
5161 return Result;
5162 }
5163
5164 pointer operator->() const { return pointer(**this); }
5165
5168 return X.Iter == Y.Iter;
5169 }
5170
5173 return X.Iter != Y.Iter;
5174 }
5175};
5176
5177template<typename Derived>
5178template<typename InputIterator>
5180 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5181 bool Uneval) {
5182 for (TemplateArgumentLoc In : llvm::make_range(First, Last)) {
5184 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5185 // Unpack argument packs, which we translate them into separate
5186 // arguments.
5187 // FIXME: We could do much better if we could guarantee that the
5188 // TemplateArgumentLocInfo for the pack expansion would be usable for
5189 // all of the template arguments in the argument pack.
5190 typedef TemplateArgumentLocInventIterator<Derived,
5192 PackLocIterator;
5193
5194 TemplateArgumentListInfo *PackOutput = &Outputs;
5196
5198 PackLocIterator(*this, In.getArgument().pack_begin()),
5199 PackLocIterator(*this, In.getArgument().pack_end()), *PackOutput,
5200 Uneval))
5201 return true;
5202
5203 continue;
5204 }
5205
5206 if (In.getArgument().isPackExpansion()) {
5207 UnexpandedInfo Info;
5208 TemplateArgumentLoc Prepared;
5209 if (getDerived().PreparePackForExpansion(In, Uneval, Prepared, Info))
5210 return true;
5211 if (!Info.Expand) {
5212 Outputs.addArgument(Prepared);
5213 continue;
5214 }
5215
5216 // The transform has determined that we should perform an elementwise
5217 // expansion of the pattern. Do so.
5218 std::optional<ForgetSubstitutionRAII> ForgetSubst;
5220 ForgetSubst.emplace(getDerived());
5221 for (unsigned I = 0; I != *Info.NumExpansions; ++I) {
5222 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5223
5225 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5226 return true;
5227
5228 if (Out.getArgument().containsUnexpandedParameterPack()) {
5229 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5230 Info.OrigNumExpansions);
5231 if (Out.getArgument().isNull())
5232 return true;
5233 }
5234
5235 Outputs.addArgument(Out);
5236 }
5237
5238 // If we're supposed to retain a pack expansion, do so by temporarily
5239 // forgetting the partially-substituted parameter pack.
5240 if (Info.RetainExpansion) {
5241 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5242
5244 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5245 return true;
5246
5247 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5248 Info.OrigNumExpansions);
5249 if (Out.getArgument().isNull())
5250 return true;
5251
5252 Outputs.addArgument(Out);
5253 }
5254
5255 continue;
5256 }
5257
5258 // The simple case:
5259 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5260 return true;
5261
5262 Outputs.addArgument(Out);
5263 }
5264
5265 return false;
5266}
5267
5268template <typename Derived>
5269template <typename InputIterator>
5271 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5272 bool Uneval) {
5273
5274 // [C++26][temp.constr.normal]
5275 // any non-dependent concept template argument
5276 // is substituted into the constraint-expression of C.
5277 auto isNonDependentConceptArgument = [](const TemplateArgument &Arg) {
5278 return !Arg.isDependent() && Arg.isConceptOrConceptTemplateParameter();
5279 };
5280
5281 for (; First != Last; ++First) {
5284
5285 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5286 typedef TemplateArgumentLocInventIterator<Derived,
5288 PackLocIterator;
5290 PackLocIterator(*this, In.getArgument().pack_begin()),
5291 PackLocIterator(*this, In.getArgument().pack_end()), Outputs,
5292 Uneval))
5293 return true;
5294 continue;
5295 }
5296
5297 if (!isNonDependentConceptArgument(In.getArgument())) {
5298 Outputs.addArgument(In);
5299 continue;
5300 }
5301
5302 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5303 return true;
5304
5305 Outputs.addArgument(Out);
5306 }
5307
5308 return false;
5309}
5310
5311// FIXME: Find ways to reduce code duplication for pack expansions.
5312template <typename Derived>
5314 bool Uneval,
5316 UnexpandedInfo &Info) {
5317 auto ComputeInfo = [this](TemplateArgumentLoc Arg,
5318 bool IsLateExpansionAttempt, UnexpandedInfo &Info,
5319 TemplateArgumentLoc &Pattern) {
5320 assert(Arg.getArgument().isPackExpansion());
5321 // We have a pack expansion, for which we will be substituting into the
5322 // pattern.
5323 Pattern = getSema().getTemplateArgumentPackExpansionPattern(
5324 Arg, Info.Ellipsis, Info.OrigNumExpansions);
5326 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5327 if (IsLateExpansionAttempt) {
5328 // Request expansion only when there is an opportunity to expand a pack
5329 // that required a substituion first.
5330 bool SawPackTypes =
5331 llvm::any_of(Unexpanded, [](UnexpandedParameterPack P) {
5332 return P.first.dyn_cast<const SubstBuiltinTemplatePackType *>();
5333 });
5334 if (!SawPackTypes) {
5335 Info.Expand = false;
5336 return false;
5337 }
5338 }
5339 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5340
5341 // Determine whether the set of unexpanded parameter packs can and
5342 // should be expanded.
5343 Info.Expand = true;
5344 Info.RetainExpansion = false;
5345 Info.NumExpansions = Info.OrigNumExpansions;
5346 return getDerived().TryExpandParameterPacks(
5347 Info.Ellipsis, Pattern.getSourceRange(), Unexpanded,
5348 /*FailOnPackProducingTemplates=*/false, Info.Expand,
5349 Info.RetainExpansion, Info.NumExpansions);
5350 };
5351
5352 TemplateArgumentLoc Pattern;
5353 if (ComputeInfo(In, false, Info, Pattern))
5354 return true;
5355
5356 if (Info.Expand) {
5357 Out = Pattern;
5358 return false;
5359 }
5360
5361 // The transform has determined that we should perform a simple
5362 // transformation on the pack expansion, producing another pack
5363 // expansion.
5364 TemplateArgumentLoc OutPattern;
5365 std::optional<Sema::ArgPackSubstIndexRAII> SubstIndex(
5366 std::in_place, getSema(), std::nullopt);
5367 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5368 return true;
5369
5370 Out = getDerived().RebuildPackExpansion(OutPattern, Info.Ellipsis,
5371 Info.NumExpansions);
5372 if (Out.getArgument().isNull())
5373 return true;
5374 SubstIndex.reset();
5375
5376 if (!OutPattern.getArgument().containsUnexpandedParameterPack())
5377 return false;
5378
5379 // Some packs will learn their length after substitution, e.g.
5380 // __builtin_dedup_pack<T,int> has size 1 or 2, depending on the substitution
5381 // value of `T`.
5382 //
5383 // We only expand after we know sizes of all packs, check if this is the case
5384 // or not. However, we avoid a full template substitution and only do
5385 // expanstions after this point.
5386
5387 // E.g. when substituting template arguments of tuple with {T -> int} in the
5388 // following example:
5389 // template <class T>
5390 // struct TupleWithInt {
5391 // using type = std::tuple<__builtin_dedup_pack<T, int>...>;
5392 // };
5393 // TupleWithInt<int>::type y;
5394 // At this point we will see the `__builtin_dedup_pack<int, int>` with a known
5395 // length and run `ComputeInfo()` to provide the necessary information to our
5396 // caller.
5397 //
5398 // Note that we may still have situations where builtin is not going to be
5399 // expanded. For example:
5400 // template <class T>
5401 // struct Foo {
5402 // template <class U> using tuple_with_t =
5403 // std::tuple<__builtin_dedup_pack<T, U, int>...>; using type =
5404 // tuple_with_t<short>;
5405 // }
5406 // Because the substitution into `type` happens in dependent context, `type`
5407 // will be `tuple<builtin_dedup_pack<T, short, int>...>` after substitution
5408 // and the caller will not be able to expand it.
5409 ForgetSubstitutionRAII ForgetSubst(getDerived());
5410 if (ComputeInfo(Out, true, Info, OutPattern))
5411 return true;
5412 if (!Info.Expand)
5413 return false;
5414 Out = OutPattern;
5415 Info.ExpandUnderForgetSubstitions = true;
5416 return false;
5417}
5418
5419//===----------------------------------------------------------------------===//
5420// Type transformation
5421//===----------------------------------------------------------------------===//
5422
5423template<typename Derived>
5426 return T;
5427
5428 // Temporary workaround. All of these transformations should
5429 // eventually turn into transformations on TypeLocs.
5430 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5432
5433 TypeSourceInfo *NewTSI = getDerived().TransformType(TSI);
5434
5435 if (!NewTSI)
5436 return QualType();
5437
5438 return NewTSI->getType();
5439}
5440
5441template <typename Derived>
5443 // Refine the base location to the type's location.
5444 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5447 return TSI;
5448
5449 TypeLocBuilder TLB;
5450
5451 TypeLoc TL = TSI->getTypeLoc();
5452 TLB.reserve(TL.getFullDataSize());
5453
5454 QualType Result = getDerived().TransformType(TLB, TL);
5455 if (Result.isNull())
5456 return nullptr;
5457
5458 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5459}
5460
5461template<typename Derived>
5464 switch (T.getTypeLocClass()) {
5465#define ABSTRACT_TYPELOC(CLASS, PARENT)
5466#define TYPELOC(CLASS, PARENT) \
5467 case TypeLoc::CLASS: \
5468 return getDerived().Transform##CLASS##Type(TLB, \
5469 T.castAs<CLASS##TypeLoc>());
5470#include "clang/AST/TypeLocNodes.def"
5471 }
5472
5473 llvm_unreachable("unhandled type loc!");
5474}
5475
5476template<typename Derived>
5478 if (!isa<DependentNameType>(T))
5479 return TransformType(T);
5480
5482 return T;
5483 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5485 TypeSourceInfo *NewTSI = getDerived().TransformTypeWithDeducedTST(TSI);
5486 return NewTSI ? NewTSI->getType() : QualType();
5487}
5488
5489template <typename Derived>
5492 if (!isa<DependentNameType>(TSI->getType()))
5493 return TransformType(TSI);
5494
5495 // Refine the base location to the type's location.
5496 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5499 return TSI;
5500
5501 TypeLocBuilder TLB;
5502
5503 TypeLoc TL = TSI->getTypeLoc();
5504 TLB.reserve(TL.getFullDataSize());
5505
5506 auto QTL = TL.getAs<QualifiedTypeLoc>();
5507 if (QTL)
5508 TL = QTL.getUnqualifiedLoc();
5509
5510 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5511
5512 QualType Result = getDerived().TransformDependentNameType(
5513 TLB, DNTL, /*DeducedTSTContext*/true);
5514 if (Result.isNull())
5515 return nullptr;
5516
5517 if (QTL) {
5518 Result = getDerived().RebuildQualifiedType(Result, QTL);
5519 if (Result.isNull())
5520 return nullptr;
5522 }
5523
5524 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5525}
5526
5527template<typename Derived>
5530 QualifiedTypeLoc T) {
5532 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5533 auto SuppressObjCLifetime =
5535 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5536 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5537 SuppressObjCLifetime);
5538 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5539 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5540 TLB, STTP, SuppressObjCLifetime);
5541 } else {
5542 Result = getDerived().TransformType(TLB, UnqualTL);
5543 }
5544
5545 if (Result.isNull())
5546 return QualType();
5547
5548 Result = getDerived().RebuildQualifiedType(Result, T);
5549
5550 if (Result.isNull())
5551 return QualType();
5552
5553 // RebuildQualifiedType might have updated the type, but not in a way
5554 // that invalidates the TypeLoc. (There's no location information for
5555 // qualifiers.)
5557
5558 return Result;
5559}
5560
5561template <typename Derived>
5563 QualifiedTypeLoc TL) {
5564
5565 SourceLocation Loc = TL.getBeginLoc();
5566 Qualifiers Quals = TL.getType().getLocalQualifiers();
5567
5568 if ((T.getAddressSpace() != LangAS::Default &&
5569 Quals.getAddressSpace() != LangAS::Default) &&
5570 T.getAddressSpace() != Quals.getAddressSpace()) {
5571 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5572 << TL.getType() << T;
5573 return QualType();
5574 }
5575
5576 PointerAuthQualifier LocalPointerAuth = Quals.getPointerAuth();
5577 if (LocalPointerAuth.isPresent()) {
5578 if (T.getPointerAuth().isPresent()) {
5579 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_redundant) << TL.getType();
5580 return QualType();
5581 }
5582 if (!T->isDependentType()) {
5583 if (!T->isSignableType(SemaRef.getASTContext())) {
5584 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_invalid_target) << T;
5585 return QualType();
5586 }
5587 }
5588 }
5589 // C++ [dcl.fct]p7:
5590 // [When] adding cv-qualifications on top of the function type [...] the
5591 // cv-qualifiers are ignored.
5592 if (T->isFunctionType()) {
5593 T = SemaRef.getASTContext().getAddrSpaceQualType(T,
5594 Quals.getAddressSpace());
5595 return T;
5596 }
5597
5598 // C++ [dcl.ref]p1:
5599 // when the cv-qualifiers are introduced through the use of a typedef-name
5600 // or decltype-specifier [...] the cv-qualifiers are ignored.
5601 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5602 // applied to a reference type.
5603 if (T->isReferenceType()) {
5604 // The only qualifier that applies to a reference type is restrict.
5605 if (!Quals.hasRestrict())
5606 return T;
5608 }
5609
5610 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5611 // resulting type.
5612 if (Quals.hasObjCLifetime()) {
5613 if (!T->isObjCLifetimeType() && !T->isDependentType())
5614 Quals.removeObjCLifetime();
5615 else if (T.getObjCLifetime()) {
5616 // Objective-C ARC:
5617 // A lifetime qualifier applied to a substituted template parameter
5618 // overrides the lifetime qualifier from the template argument.
5619 const AutoType *AutoTy;
5620 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5621 // 'auto' types behave the same way as template parameters.
5622 QualType Deduced = AutoTy->getDeducedType();
5623 Qualifiers Qs = Deduced.getQualifiers();
5624 Qs.removeObjCLifetime();
5625 Deduced =
5626 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5627 T = SemaRef.Context.getAutoType(AutoTy->getDeducedKind(), Deduced,
5628 AutoTy->getKeyword(),
5629 AutoTy->getTypeConstraintConcept(),
5630 AutoTy->getTypeConstraintArguments());
5631 } else {
5632 // Otherwise, complain about the addition of a qualifier to an
5633 // already-qualified type.
5634 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5635 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5636 Quals.removeObjCLifetime();
5637 }
5638 }
5639 }
5640
5641 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5642}
5643
5644template <typename Derived>
5645QualType TreeTransform<Derived>::TransformTypeInObjectScope(
5646 TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType,
5647 NamedDecl *FirstQualifierInScope) {
5648 assert(!getDerived().AlreadyTransformed(TL.getType()));
5649
5650 switch (TL.getTypeLocClass()) {
5651 case TypeLoc::TemplateSpecialization:
5652 return getDerived().TransformTemplateSpecializationType(
5653 TLB, TL.castAs<TemplateSpecializationTypeLoc>(), ObjectType,
5654 FirstQualifierInScope, /*AllowInjectedClassName=*/true);
5655 case TypeLoc::DependentName:
5656 return getDerived().TransformDependentNameType(
5657 TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
5658 ObjectType, FirstQualifierInScope);
5659 default:
5660 // Any dependent canonical type can appear here, through type alias
5661 // templates.
5662 return getDerived().TransformType(TLB, TL);
5663 }
5664}
5665
5666template <class TyLoc> static inline
5668 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5669 NewT.setNameLoc(T.getNameLoc());
5670 return T.getType();
5671}
5672
5673template<typename Derived>
5674QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5675 BuiltinTypeLoc T) {
5676 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5677 NewT.setBuiltinLoc(T.getBuiltinLoc());
5678 if (T.needsExtraLocalData())
5679 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5680 return T.getType();
5681}
5682
5683template<typename Derived>
5685 ComplexTypeLoc T) {
5686 // FIXME: recurse?
5687 return TransformTypeSpecType(TLB, T);
5688}
5689
5690template <typename Derived>
5692 AdjustedTypeLoc TL) {
5693 // Adjustments applied during transformation are handled elsewhere.
5694 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5695}
5696
5697template<typename Derived>
5699 DecayedTypeLoc TL) {
5700 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5701 if (OriginalType.isNull())
5702 return QualType();
5703
5704 QualType Result = TL.getType();
5705 if (getDerived().AlwaysRebuild() ||
5706 OriginalType != TL.getOriginalLoc().getType())
5707 Result = SemaRef.Context.getDecayedType(OriginalType);
5708 TLB.push<DecayedTypeLoc>(Result);
5709 // Nothing to set for DecayedTypeLoc.
5710 return Result;
5711}
5712
5713template <typename Derived>
5717 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5718 if (OriginalType.isNull())
5719 return QualType();
5720
5721 QualType Result = TL.getType();
5722 if (getDerived().AlwaysRebuild() ||
5723 OriginalType != TL.getElementLoc().getType())
5724 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5725 TLB.push<ArrayParameterTypeLoc>(Result);
5726 // Nothing to set for ArrayParameterTypeLoc.
5727 return Result;
5728}
5729
5730template<typename Derived>
5732 PointerTypeLoc TL) {
5733 QualType PointeeType
5734 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5735 if (PointeeType.isNull())
5736 return QualType();
5737
5738 QualType Result = TL.getType();
5739 if (PointeeType->getAs<ObjCObjectType>()) {
5740 // A dependent pointer type 'T *' has is being transformed such
5741 // that an Objective-C class type is being replaced for 'T'. The
5742 // resulting pointer type is an ObjCObjectPointerType, not a
5743 // PointerType.
5744 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5745
5747 NewT.setStarLoc(TL.getStarLoc());
5748 return Result;
5749 }
5750
5751 if (getDerived().AlwaysRebuild() ||
5752 PointeeType != TL.getPointeeLoc().getType()) {
5753 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5754 if (Result.isNull())
5755 return QualType();
5756 }
5757
5758 // Objective-C ARC can add lifetime qualifiers to the type that we're
5759 // pointing to.
5760 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5761
5762 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5763 NewT.setSigilLoc(TL.getSigilLoc());
5764 return Result;
5765}
5766
5767template<typename Derived>
5771 QualType PointeeType
5772 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5773 if (PointeeType.isNull())
5774 return QualType();
5775
5776 QualType Result = TL.getType();
5777 if (getDerived().AlwaysRebuild() ||
5778 PointeeType != TL.getPointeeLoc().getType()) {
5779 Result = getDerived().RebuildBlockPointerType(PointeeType,
5780 TL.getSigilLoc());
5781 if (Result.isNull())
5782 return QualType();
5783 }
5784
5786 NewT.setSigilLoc(TL.getSigilLoc());
5787 return Result;
5788}
5789
5790/// Transforms a reference type. Note that somewhat paradoxically we
5791/// don't care whether the type itself is an l-value type or an r-value
5792/// type; we only care if the type was *written* as an l-value type
5793/// or an r-value type.
5794template<typename Derived>
5797 ReferenceTypeLoc TL) {
5798 const ReferenceType *T = TL.getTypePtr();
5799
5800 // Note that this works with the pointee-as-written.
5801 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5802 if (PointeeType.isNull())
5803 return QualType();
5804
5805 QualType Result = TL.getType();
5806 if (getDerived().AlwaysRebuild() ||
5807 PointeeType != T->getPointeeTypeAsWritten()) {
5808 Result = getDerived().RebuildReferenceType(PointeeType,
5809 T->isSpelledAsLValue(),
5810 TL.getSigilLoc());
5811 if (Result.isNull())
5812 return QualType();
5813 }
5814
5815 // Objective-C ARC can add lifetime qualifiers to the type that we're
5816 // referring to.
5819
5820 // r-value references can be rebuilt as l-value references.
5821 ReferenceTypeLoc NewTL;
5823 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5824 else
5825 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5826 NewTL.setSigilLoc(TL.getSigilLoc());
5827
5828 return Result;
5829}
5830
5831template<typename Derived>
5835 return TransformReferenceType(TLB, TL);
5836}
5837
5838template<typename Derived>
5839QualType
5840TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5841 RValueReferenceTypeLoc TL) {
5842 return TransformReferenceType(TLB, TL);
5843}
5844
5845template<typename Derived>
5849 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5850 if (PointeeType.isNull())
5851 return QualType();
5852
5853 const MemberPointerType *T = TL.getTypePtr();
5854
5855 NestedNameSpecifierLoc OldQualifierLoc = TL.getQualifierLoc();
5856 NestedNameSpecifierLoc NewQualifierLoc =
5857 getDerived().TransformNestedNameSpecifierLoc(OldQualifierLoc);
5858 if (!NewQualifierLoc)
5859 return QualType();
5860
5861 CXXRecordDecl *OldCls = T->getMostRecentCXXRecordDecl(), *NewCls = nullptr;
5862 if (OldCls) {
5863 NewCls = cast_or_null<CXXRecordDecl>(
5864 getDerived().TransformDecl(TL.getStarLoc(), OldCls));
5865 if (!NewCls)
5866 return QualType();
5867 }
5868
5869 QualType Result = TL.getType();
5870 if (getDerived().AlwaysRebuild() || PointeeType != T->getPointeeType() ||
5871 NewQualifierLoc.getNestedNameSpecifier() !=
5872 OldQualifierLoc.getNestedNameSpecifier() ||
5873 NewCls != OldCls) {
5874 CXXScopeSpec SS;
5875 SS.Adopt(NewQualifierLoc);
5876 Result = getDerived().RebuildMemberPointerType(PointeeType, SS, NewCls,
5877 TL.getStarLoc());
5878 if (Result.isNull())
5879 return QualType();
5880 }
5881
5882 // If we had to adjust the pointee type when building a member pointer, make
5883 // sure to push TypeLoc info for it.
5884 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5885 if (MPT && PointeeType != MPT->getPointeeType()) {
5886 assert(isa<AdjustedType>(MPT->getPointeeType()));
5887 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5888 }
5889
5891 NewTL.setSigilLoc(TL.getSigilLoc());
5892 NewTL.setQualifierLoc(NewQualifierLoc);
5893
5894 return Result;
5895}
5896
5897template<typename Derived>
5901 const ConstantArrayType *T = TL.getTypePtr();
5902 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5903 if (ElementType.isNull())
5904 return QualType();
5905
5906 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5907 Expr *OldSize = TL.getSizeExpr();
5908 if (!OldSize)
5909 OldSize = const_cast<Expr*>(T->getSizeExpr());
5910 Expr *NewSize = nullptr;
5911 if (OldSize) {
5914 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5915 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5916 }
5917
5918 QualType Result = TL.getType();
5919 if (getDerived().AlwaysRebuild() ||
5920 ElementType != T->getElementType() ||
5921 (T->getSizeExpr() && NewSize != OldSize)) {
5922 Result = getDerived().RebuildConstantArrayType(ElementType,
5923 T->getSizeModifier(),
5924 T->getSize(), NewSize,
5925 T->getIndexTypeCVRQualifiers(),
5926 TL.getBracketsRange());
5927 if (Result.isNull())
5928 return QualType();
5929 }
5930
5931 // We might have either a ConstantArrayType or a VariableArrayType now:
5932 // a ConstantArrayType is allowed to have an element type which is a
5933 // VariableArrayType if the type is dependent. Fortunately, all array
5934 // types have the same location layout.
5935 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5936 NewTL.setLBracketLoc(TL.getLBracketLoc());
5937 NewTL.setRBracketLoc(TL.getRBracketLoc());
5938 NewTL.setSizeExpr(NewSize);
5939
5940 return Result;
5941}
5942
5943template<typename Derived>
5945 TypeLocBuilder &TLB,
5947 const IncompleteArrayType *T = TL.getTypePtr();
5948 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5949 if (ElementType.isNull())
5950 return QualType();
5951
5952 QualType Result = TL.getType();
5953 if (getDerived().AlwaysRebuild() ||
5954 ElementType != T->getElementType()) {
5955 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5956 T->getSizeModifier(),
5957 T->getIndexTypeCVRQualifiers(),
5958 TL.getBracketsRange());
5959 if (Result.isNull())
5960 return QualType();
5961 }
5962
5964 NewTL.setLBracketLoc(TL.getLBracketLoc());
5965 NewTL.setRBracketLoc(TL.getRBracketLoc());
5966 NewTL.setSizeExpr(nullptr);
5967
5968 return Result;
5969}
5970
5971template<typename Derived>
5975 const VariableArrayType *T = TL.getTypePtr();
5976 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5977 if (ElementType.isNull())
5978 return QualType();
5979
5980 ExprResult SizeResult;
5981 {
5984 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5985 }
5986 if (SizeResult.isInvalid())
5987 return QualType();
5988 SizeResult =
5989 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5990 if (SizeResult.isInvalid())
5991 return QualType();
5992
5993 Expr *Size = SizeResult.get();
5994
5995 QualType Result = TL.getType();
5996 if (getDerived().AlwaysRebuild() ||
5997 ElementType != T->getElementType() ||
5998 Size != T->getSizeExpr()) {
5999 Result = getDerived().RebuildVariableArrayType(ElementType,
6000 T->getSizeModifier(),
6001 Size,
6002 T->getIndexTypeCVRQualifiers(),
6003 TL.getBracketsRange());
6004 if (Result.isNull())
6005 return QualType();
6006 }
6007
6008 // We might have constant size array now, but fortunately it has the same
6009 // location layout.
6010 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6011 NewTL.setLBracketLoc(TL.getLBracketLoc());
6012 NewTL.setRBracketLoc(TL.getRBracketLoc());
6013 NewTL.setSizeExpr(Size);
6014
6015 return Result;
6016}
6017
6018template<typename Derived>
6022 const DependentSizedArrayType *T = TL.getTypePtr();
6023 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6024 if (ElementType.isNull())
6025 return QualType();
6026
6027 // Array bounds are constant expressions.
6030
6031 // If we have a VLA then it won't be a constant.
6032 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
6033
6034 // Prefer the expression from the TypeLoc; the other may have been uniqued.
6035 Expr *origSize = TL.getSizeExpr();
6036 if (!origSize) origSize = T->getSizeExpr();
6037
6038 ExprResult sizeResult
6039 = getDerived().TransformExpr(origSize);
6040 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
6041 if (sizeResult.isInvalid())
6042 return QualType();
6043
6044 Expr *size = sizeResult.get();
6045
6046 QualType Result = TL.getType();
6047 if (getDerived().AlwaysRebuild() ||
6048 ElementType != T->getElementType() ||
6049 size != origSize) {
6050 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
6051 T->getSizeModifier(),
6052 size,
6053 T->getIndexTypeCVRQualifiers(),
6054 TL.getBracketsRange());
6055 if (Result.isNull())
6056 return QualType();
6057 }
6058
6059 // We might have any sort of array type now, but fortunately they
6060 // all have the same location layout.
6061 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6062 NewTL.setLBracketLoc(TL.getLBracketLoc());
6063 NewTL.setRBracketLoc(TL.getRBracketLoc());
6064 NewTL.setSizeExpr(size);
6065
6066 return Result;
6067}
6068
6069template <typename Derived>
6072 const DependentVectorType *T = TL.getTypePtr();
6073 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6074 if (ElementType.isNull())
6075 return QualType();
6076
6079
6080 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6081 Size = SemaRef.ActOnConstantExpression(Size);
6082 if (Size.isInvalid())
6083 return QualType();
6084
6085 QualType Result = TL.getType();
6086 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6087 Size.get() != T->getSizeExpr()) {
6088 Result = getDerived().RebuildDependentVectorType(
6089 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
6090 if (Result.isNull())
6091 return QualType();
6092 }
6093
6094 // Result might be dependent or not.
6097 TLB.push<DependentVectorTypeLoc>(Result);
6098 NewTL.setNameLoc(TL.getNameLoc());
6099 } else {
6100 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6101 NewTL.setNameLoc(TL.getNameLoc());
6102 }
6103
6104 return Result;
6105}
6106
6107template<typename Derived>
6109 TypeLocBuilder &TLB,
6111 const DependentSizedExtVectorType *T = TL.getTypePtr();
6112
6113 // FIXME: ext vector locs should be nested
6114 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6115 if (ElementType.isNull())
6116 return QualType();
6117
6118 // Vector sizes are constant expressions.
6121
6122 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6123 Size = SemaRef.ActOnConstantExpression(Size);
6124 if (Size.isInvalid())
6125 return QualType();
6126
6127 QualType Result = TL.getType();
6128 if (getDerived().AlwaysRebuild() ||
6129 ElementType != T->getElementType() ||
6130 Size.get() != T->getSizeExpr()) {
6131 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
6132 Size.get(),
6133 T->getAttributeLoc());
6134 if (Result.isNull())
6135 return QualType();
6136 }
6137
6138 // Result might be dependent or not.
6142 NewTL.setNameLoc(TL.getNameLoc());
6143 } else {
6144 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6145 NewTL.setNameLoc(TL.getNameLoc());
6146 }
6147
6148 return Result;
6149}
6150
6151template <typename Derived>
6155 const ConstantMatrixType *T = TL.getTypePtr();
6156 QualType ElementType = getDerived().TransformType(T->getElementType());
6157 if (ElementType.isNull())
6158 return QualType();
6159
6160 QualType Result = TL.getType();
6161 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
6162 Result = getDerived().RebuildConstantMatrixType(
6163 ElementType, T->getNumRows(), T->getNumColumns());
6164 if (Result.isNull())
6165 return QualType();
6166 }
6167
6169 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6170 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6171 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
6172 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
6173
6174 return Result;
6175}
6176
6177template <typename Derived>
6180 const DependentSizedMatrixType *T = TL.getTypePtr();
6181
6182 QualType ElementType = getDerived().TransformType(T->getElementType());
6183 if (ElementType.isNull()) {
6184 return QualType();
6185 }
6186
6187 // Matrix dimensions are constant expressions.
6190
6191 Expr *origRows = TL.getAttrRowOperand();
6192 if (!origRows)
6193 origRows = T->getRowExpr();
6194 Expr *origColumns = TL.getAttrColumnOperand();
6195 if (!origColumns)
6196 origColumns = T->getColumnExpr();
6197
6198 ExprResult rowResult = getDerived().TransformExpr(origRows);
6199 rowResult = SemaRef.ActOnConstantExpression(rowResult);
6200 if (rowResult.isInvalid())
6201 return QualType();
6202
6203 ExprResult columnResult = getDerived().TransformExpr(origColumns);
6204 columnResult = SemaRef.ActOnConstantExpression(columnResult);
6205 if (columnResult.isInvalid())
6206 return QualType();
6207
6208 Expr *rows = rowResult.get();
6209 Expr *columns = columnResult.get();
6210
6211 QualType Result = TL.getType();
6212 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6213 rows != origRows || columns != origColumns) {
6214 Result = getDerived().RebuildDependentSizedMatrixType(
6215 ElementType, rows, columns, T->getAttributeLoc());
6216
6217 if (Result.isNull())
6218 return QualType();
6219 }
6220
6221 // We might have any sort of matrix type now, but fortunately they
6222 // all have the same location layout.
6223 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
6224 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6225 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6226 NewTL.setAttrRowOperand(rows);
6227 NewTL.setAttrColumnOperand(columns);
6228 return Result;
6229}
6230
6231template <typename Derived>
6234 const DependentAddressSpaceType *T = TL.getTypePtr();
6235
6236 QualType pointeeType =
6237 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
6238
6239 if (pointeeType.isNull())
6240 return QualType();
6241
6242 // Address spaces are constant expressions.
6245
6246 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
6247 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
6248 if (AddrSpace.isInvalid())
6249 return QualType();
6250
6251 QualType Result = TL.getType();
6252 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
6253 AddrSpace.get() != T->getAddrSpaceExpr()) {
6254 Result = getDerived().RebuildDependentAddressSpaceType(
6255 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6256 if (Result.isNull())
6257 return QualType();
6258 }
6259
6260 // Result might be dependent or not.
6264
6265 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6266 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6267 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6268
6269 } else {
6270 TLB.TypeWasModifiedSafely(Result);
6271 }
6272
6273 return Result;
6274}
6275
6276template <typename Derived>
6278 VectorTypeLoc TL) {
6279 const VectorType *T = TL.getTypePtr();
6280 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6281 if (ElementType.isNull())
6282 return QualType();
6283
6284 QualType Result = TL.getType();
6285 if (getDerived().AlwaysRebuild() ||
6286 ElementType != T->getElementType()) {
6287 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6288 T->getVectorKind());
6289 if (Result.isNull())
6290 return QualType();
6291 }
6292
6293 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6294 NewTL.setNameLoc(TL.getNameLoc());
6295
6296 return Result;
6297}
6298
6299template<typename Derived>
6301 ExtVectorTypeLoc TL) {
6302 const VectorType *T = TL.getTypePtr();
6303 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6304 if (ElementType.isNull())
6305 return QualType();
6306
6307 QualType Result = TL.getType();
6308 if (getDerived().AlwaysRebuild() ||
6309 ElementType != T->getElementType()) {
6310 Result = getDerived().RebuildExtVectorType(ElementType,
6311 T->getNumElements(),
6312 /*FIXME*/ SourceLocation());
6313 if (Result.isNull())
6314 return QualType();
6315 }
6316
6317 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6318 NewTL.setNameLoc(TL.getNameLoc());
6319
6320 return Result;
6321}
6322
6323template <typename Derived>
6325 ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions,
6326 bool ExpectParameterPack) {
6327 TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
6328 TypeSourceInfo *NewTSI = nullptr;
6329
6330 if (NumExpansions && isa<PackExpansionType>(OldTSI->getType())) {
6331 // If we're substituting into a pack expansion type and we know the
6332 // length we want to expand to, just substitute for the pattern.
6333 TypeLoc OldTL = OldTSI->getTypeLoc();
6334 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6335
6336 TypeLocBuilder TLB;
6337 TypeLoc NewTL = OldTSI->getTypeLoc();
6338 TLB.reserve(NewTL.getFullDataSize());
6339
6340 QualType Result = getDerived().TransformType(TLB,
6341 OldExpansionTL.getPatternLoc());
6342 if (Result.isNull())
6343 return nullptr;
6344
6346 OldExpansionTL.getPatternLoc().getSourceRange(),
6347 OldExpansionTL.getEllipsisLoc(),
6348 NumExpansions);
6349 if (Result.isNull())
6350 return nullptr;
6351
6352 PackExpansionTypeLoc NewExpansionTL
6353 = TLB.push<PackExpansionTypeLoc>(Result);
6354 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6355 NewTSI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6356 } else
6357 NewTSI = getDerived().TransformType(OldTSI);
6358 if (!NewTSI)
6359 return nullptr;
6360
6361 if (NewTSI == OldTSI && indexAdjustment == 0)
6362 return OldParm;
6363
6365 SemaRef.Context, OldParm->getDeclContext(), OldParm->getInnerLocStart(),
6366 OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
6367 NewTSI, OldParm->getStorageClass(),
6368 /* DefArg */ nullptr);
6369 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6370 OldParm->getFunctionScopeIndex() + indexAdjustment);
6371 getDerived().transformedLocalDecl(OldParm, {newParm});
6372 return newParm;
6373}
6374
6375template <typename Derived>
6378 const QualType *ParamTypes,
6379 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6380 SmallVectorImpl<QualType> &OutParamTypes,
6383 unsigned *LastParamTransformed) {
6384 int indexAdjustment = 0;
6385
6386 unsigned NumParams = Params.size();
6387 for (unsigned i = 0; i != NumParams; ++i) {
6388 if (LastParamTransformed)
6389 *LastParamTransformed = i;
6390 if (ParmVarDecl *OldParm = Params[i]) {
6391 assert(OldParm->getFunctionScopeIndex() == i);
6392
6393 UnsignedOrNone NumExpansions = std::nullopt;
6394 ParmVarDecl *NewParm = nullptr;
6395 if (OldParm->isParameterPack()) {
6396 // We have a function parameter pack that may need to be expanded.
6398
6399 // Find the parameter packs that could be expanded.
6400 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6402 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6403 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6404
6405 // Determine whether we should expand the parameter packs.
6406 bool ShouldExpand = false;
6407 bool RetainExpansion = false;
6408 UnsignedOrNone OrigNumExpansions = std::nullopt;
6409 if (Unexpanded.size() > 0) {
6410 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6411 NumExpansions = OrigNumExpansions;
6413 ExpansionTL.getEllipsisLoc(), Pattern.getSourceRange(),
6414 Unexpanded, /*FailOnPackProducingTemplates=*/true,
6415 ShouldExpand, RetainExpansion, NumExpansions)) {
6416 return true;
6417 }
6418 } else {
6419#ifndef NDEBUG
6420 const AutoType *AT =
6421 Pattern.getType().getTypePtr()->getContainedAutoType();
6422 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6423 "Could not find parameter packs or undeduced auto type!");
6424#endif
6425 }
6426
6427 if (ShouldExpand) {
6428 // Expand the function parameter pack into multiple, separate
6429 // parameters.
6430 getDerived().ExpandingFunctionParameterPack(OldParm);
6431 for (unsigned I = 0; I != *NumExpansions; ++I) {
6432 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6433 ParmVarDecl *NewParm
6434 = getDerived().TransformFunctionTypeParam(OldParm,
6435 indexAdjustment++,
6436 OrigNumExpansions,
6437 /*ExpectParameterPack=*/false);
6438 if (!NewParm)
6439 return true;
6440
6441 if (ParamInfos)
6442 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6443 OutParamTypes.push_back(NewParm->getType());
6444 if (PVars)
6445 PVars->push_back(NewParm);
6446 }
6447
6448 // If we're supposed to retain a pack expansion, do so by temporarily
6449 // forgetting the partially-substituted parameter pack.
6450 if (RetainExpansion) {
6451 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6452 ParmVarDecl *NewParm
6453 = getDerived().TransformFunctionTypeParam(OldParm,
6454 indexAdjustment++,
6455 OrigNumExpansions,
6456 /*ExpectParameterPack=*/false);
6457 if (!NewParm)
6458 return true;
6459
6460 if (ParamInfos)
6461 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6462 OutParamTypes.push_back(NewParm->getType());
6463 if (PVars)
6464 PVars->push_back(NewParm);
6465 }
6466
6467 // The next parameter should have the same adjustment as the
6468 // last thing we pushed, but we post-incremented indexAdjustment
6469 // on every push. Also, if we push nothing, the adjustment should
6470 // go down by one.
6471 indexAdjustment--;
6472
6473 // We're done with the pack expansion.
6474 continue;
6475 }
6476
6477 // We'll substitute the parameter now without expanding the pack
6478 // expansion.
6479 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6480 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6481 indexAdjustment,
6482 NumExpansions,
6483 /*ExpectParameterPack=*/true);
6484 assert(NewParm->isParameterPack() &&
6485 "Parameter pack no longer a parameter pack after "
6486 "transformation.");
6487 } else {
6488 NewParm = getDerived().TransformFunctionTypeParam(
6489 OldParm, indexAdjustment, std::nullopt,
6490 /*ExpectParameterPack=*/false);
6491 }
6492
6493 if (!NewParm)
6494 return true;
6495
6496 if (ParamInfos)
6497 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6498 OutParamTypes.push_back(NewParm->getType());
6499 if (PVars)
6500 PVars->push_back(NewParm);
6501 continue;
6502 }
6503
6504 // Deal with the possibility that we don't have a parameter
6505 // declaration for this parameter.
6506 assert(ParamTypes);
6507 QualType OldType = ParamTypes[i];
6508 bool IsPackExpansion = false;
6509 UnsignedOrNone NumExpansions = std::nullopt;
6510 QualType NewType;
6511 if (const PackExpansionType *Expansion
6512 = dyn_cast<PackExpansionType>(OldType)) {
6513 // We have a function parameter pack that may need to be expanded.
6514 QualType Pattern = Expansion->getPattern();
6516 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6517
6518 // Determine whether we should expand the parameter packs.
6519 bool ShouldExpand = false;
6520 bool RetainExpansion = false;
6522 Loc, SourceRange(), Unexpanded,
6523 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
6524 RetainExpansion, NumExpansions)) {
6525 return true;
6526 }
6527
6528 if (ShouldExpand) {
6529 // Expand the function parameter pack into multiple, separate
6530 // parameters.
6531 for (unsigned I = 0; I != *NumExpansions; ++I) {
6532 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6533 QualType NewType = getDerived().TransformType(Pattern);
6534 if (NewType.isNull())
6535 return true;
6536
6537 if (NewType->containsUnexpandedParameterPack()) {
6538 NewType = getSema().getASTContext().getPackExpansionType(
6539 NewType, std::nullopt);
6540
6541 if (NewType.isNull())
6542 return true;
6543 }
6544
6545 if (ParamInfos)
6546 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6547 OutParamTypes.push_back(NewType);
6548 if (PVars)
6549 PVars->push_back(nullptr);
6550 }
6551
6552 // We're done with the pack expansion.
6553 continue;
6554 }
6555
6556 // If we're supposed to retain a pack expansion, do so by temporarily
6557 // forgetting the partially-substituted parameter pack.
6558 if (RetainExpansion) {
6559 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6560 QualType NewType = getDerived().TransformType(Pattern);
6561 if (NewType.isNull())
6562 return true;
6563
6564 if (ParamInfos)
6565 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6566 OutParamTypes.push_back(NewType);
6567 if (PVars)
6568 PVars->push_back(nullptr);
6569 }
6570
6571 // We'll substitute the parameter now without expanding the pack
6572 // expansion.
6573 OldType = Expansion->getPattern();
6574 IsPackExpansion = true;
6575 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6576 NewType = getDerived().TransformType(OldType);
6577 } else {
6578 NewType = getDerived().TransformType(OldType);
6579 }
6580
6581 if (NewType.isNull())
6582 return true;
6583
6584 if (IsPackExpansion)
6585 NewType = getSema().Context.getPackExpansionType(NewType,
6586 NumExpansions);
6587
6588 if (ParamInfos)
6589 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6590 OutParamTypes.push_back(NewType);
6591 if (PVars)
6592 PVars->push_back(nullptr);
6593 }
6594
6595#ifndef NDEBUG
6596 if (PVars) {
6597 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6598 if (ParmVarDecl *parm = (*PVars)[i])
6599 assert(parm->getFunctionScopeIndex() == i);
6600 }
6601#endif
6602
6603 return false;
6604}
6605
6606template<typename Derived>
6610 SmallVector<QualType, 4> ExceptionStorage;
6611 return getDerived().TransformFunctionProtoType(
6612 TLB, TL, nullptr, Qualifiers(),
6613 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6614 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6615 ExceptionStorage, Changed);
6616 });
6617}
6618
6619template<typename Derived> template<typename Fn>
6621 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6622 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6623
6624 // Transform the parameters and return type.
6625 //
6626 // We are required to instantiate the params and return type in source order.
6627 // When the function has a trailing return type, we instantiate the
6628 // parameters before the return type, since the return type can then refer
6629 // to the parameters themselves (via decltype, sizeof, etc.).
6630 //
6631 SmallVector<QualType, 4> ParamTypes;
6633 Sema::ExtParameterInfoBuilder ExtParamInfos;
6634 const FunctionProtoType *T = TL.getTypePtr();
6635
6636 QualType ResultType;
6637
6638 if (T->hasTrailingReturn()) {
6640 TL.getBeginLoc(), TL.getParams(),
6642 T->getExtParameterInfosOrNull(),
6643 ParamTypes, &ParamDecls, ExtParamInfos))
6644 return QualType();
6645
6646 {
6647 // C++11 [expr.prim.general]p3:
6648 // If a declaration declares a member function or member function
6649 // template of a class X, the expression this is a prvalue of type
6650 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6651 // and the end of the function-definition, member-declarator, or
6652 // declarator.
6653 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6654 Sema::CXXThisScopeRAII ThisScope(
6655 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6656
6657 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6658 if (ResultType.isNull())
6659 return QualType();
6660 }
6661 }
6662 else {
6663 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6664 if (ResultType.isNull())
6665 return QualType();
6666
6668 TL.getBeginLoc(), TL.getParams(),
6670 T->getExtParameterInfosOrNull(),
6671 ParamTypes, &ParamDecls, ExtParamInfos))
6672 return QualType();
6673 }
6674
6675 FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
6676
6677 bool EPIChanged = false;
6678 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6679 return QualType();
6680
6681 // Handle extended parameter information.
6682 if (auto NewExtParamInfos =
6683 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6684 if (!EPI.ExtParameterInfos ||
6686 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6687 EPIChanged = true;
6688 }
6689 EPI.ExtParameterInfos = NewExtParamInfos;
6690 } else if (EPI.ExtParameterInfos) {
6691 EPIChanged = true;
6692 EPI.ExtParameterInfos = nullptr;
6693 }
6694
6695 // Transform any function effects with unevaluated conditions.
6696 // Hold this set in a local for the rest of this function, since EPI
6697 // may need to hold a FunctionEffectsRef pointing into it.
6698 std::optional<FunctionEffectSet> NewFX;
6699 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6700 NewFX.emplace();
6703
6704 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6705 FunctionEffectWithCondition NewEC = PrevEC;
6706 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6707 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6708 if (NewExpr.isInvalid())
6709 return QualType();
6710 std::optional<FunctionEffectMode> Mode =
6711 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6712 if (!Mode)
6713 return QualType();
6714
6715 // The condition expression has been transformed, and re-evaluated.
6716 // It may or may not have become constant.
6717 switch (*Mode) {
6719 NewEC.Cond = {};
6720 break;
6722 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6723 NewEC.Cond = {};
6724 break;
6726 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6727 break;
6729 llvm_unreachable(
6730 "FunctionEffectMode::None shouldn't be possible here");
6731 }
6732 }
6733 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6734 TL.getBeginLoc())) {
6736 NewFX->insert(NewEC, Errs);
6737 assert(Errs.empty());
6738 }
6739 }
6740 EPI.FunctionEffects = *NewFX;
6741 EPIChanged = true;
6742 }
6743
6744 QualType Result = TL.getType();
6745 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6746 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6747 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6748 if (Result.isNull())
6749 return QualType();
6750 }
6751
6754 NewTL.setLParenLoc(TL.getLParenLoc());
6755 NewTL.setRParenLoc(TL.getRParenLoc());
6758 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6759 NewTL.setParam(i, ParamDecls[i]);
6760
6761 return Result;
6762}
6763
6764template<typename Derived>
6767 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6768 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6769
6770 // Instantiate a dynamic noexcept expression, if any.
6771 if (isComputedNoexcept(ESI.Type)) {
6772 // Update this scrope because ContextDecl in Sema will be used in
6773 // TransformExpr.
6774 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6775 Sema::CXXThisScopeRAII ThisScope(
6776 SemaRef, Method ? Method->getParent() : nullptr,
6777 Method ? Method->getMethodQualifiers() : Qualifiers{},
6778 Method != nullptr);
6781 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6782 if (NoexceptExpr.isInvalid())
6783 return true;
6784
6786 NoexceptExpr =
6787 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6788 if (NoexceptExpr.isInvalid())
6789 return true;
6790
6791 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6792 Changed = true;
6793 ESI.NoexceptExpr = NoexceptExpr.get();
6794 ESI.Type = EST;
6795 }
6796
6797 if (ESI.Type != EST_Dynamic)
6798 return false;
6799
6800 // Instantiate a dynamic exception specification's type.
6801 for (QualType T : ESI.Exceptions) {
6802 if (const PackExpansionType *PackExpansion =
6803 T->getAs<PackExpansionType>()) {
6804 Changed = true;
6805
6806 // We have a pack expansion. Instantiate it.
6808 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6809 Unexpanded);
6810 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6811
6812 // Determine whether the set of unexpanded parameter packs can and
6813 // should
6814 // be expanded.
6815 bool Expand = false;
6816 bool RetainExpansion = false;
6817 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
6818 // FIXME: Track the location of the ellipsis (and track source location
6819 // information for the types in the exception specification in general).
6821 Loc, SourceRange(), Unexpanded,
6822 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
6823 NumExpansions))
6824 return true;
6825
6826 if (!Expand) {
6827 // We can't expand this pack expansion into separate arguments yet;
6828 // just substitute into the pattern and create a new pack expansion
6829 // type.
6830 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6831 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6832 if (U.isNull())
6833 return true;
6834
6835 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6836 Exceptions.push_back(U);
6837 continue;
6838 }
6839
6840 // Substitute into the pack expansion pattern for each slice of the
6841 // pack.
6842 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6843 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
6844
6845 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6846 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6847 return true;
6848
6849 Exceptions.push_back(U);
6850 }
6851 } else {
6852 QualType U = getDerived().TransformType(T);
6853 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6854 return true;
6855 if (T != U)
6856 Changed = true;
6857
6858 Exceptions.push_back(U);
6859 }
6860 }
6861
6862 ESI.Exceptions = Exceptions;
6863 if (ESI.Exceptions.empty())
6864 ESI.Type = EST_DynamicNone;
6865 return false;
6866}
6867
6868template<typename Derived>
6870 TypeLocBuilder &TLB,
6872 const FunctionNoProtoType *T = TL.getTypePtr();
6873 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6874 if (ResultType.isNull())
6875 return QualType();
6876
6877 QualType Result = TL.getType();
6878 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6879 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6880
6883 NewTL.setLParenLoc(TL.getLParenLoc());
6884 NewTL.setRParenLoc(TL.getRParenLoc());
6886
6887 return Result;
6888}
6889
6890template <typename Derived>
6891QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6892 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6893
6894 const UnresolvedUsingType *T = TL.getTypePtr();
6895 bool Changed = false;
6896
6897 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6898 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6899 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6900 if (!QualifierLoc)
6901 return QualType();
6902 Changed |= QualifierLoc != OldQualifierLoc;
6903 }
6904
6905 auto *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6906 if (!D)
6907 return QualType();
6908 Changed |= D != T->getDecl();
6909
6910 QualType Result = TL.getType();
6911 if (getDerived().AlwaysRebuild() || Changed) {
6912 Result = getDerived().RebuildUnresolvedUsingType(
6913 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TL.getNameLoc(),
6914 D);
6915 if (Result.isNull())
6916 return QualType();
6917 }
6918
6920 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6921 QualifierLoc, TL.getNameLoc());
6922 else
6923 TLB.push<UnresolvedUsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6924 QualifierLoc, TL.getNameLoc());
6925 return Result;
6926}
6927
6928template <typename Derived>
6930 UsingTypeLoc TL) {
6931 const UsingType *T = TL.getTypePtr();
6932 bool Changed = false;
6933
6934 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6935 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6936 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6937 if (!QualifierLoc)
6938 return QualType();
6939 Changed |= QualifierLoc != OldQualifierLoc;
6940 }
6941
6942 auto *D = cast_or_null<UsingShadowDecl>(
6943 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6944 if (!D)
6945 return QualType();
6946 Changed |= D != T->getDecl();
6947
6948 QualType UnderlyingType = getDerived().TransformType(T->desugar());
6949 if (UnderlyingType.isNull())
6950 return QualType();
6951 Changed |= UnderlyingType != T->desugar();
6952
6953 QualType Result = TL.getType();
6954 if (getDerived().AlwaysRebuild() || Changed) {
6955 Result = getDerived().RebuildUsingType(
6956 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), D,
6957 UnderlyingType);
6958 if (Result.isNull())
6959 return QualType();
6960 }
6961 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(), QualifierLoc,
6962 TL.getNameLoc());
6963 return Result;
6964}
6965
6966template<typename Derived>
6968 TypedefTypeLoc TL) {
6969 const TypedefType *T = TL.getTypePtr();
6970 bool Changed = false;
6971
6972 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6973 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6974 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6975 if (!QualifierLoc)
6976 return QualType();
6977 Changed |= QualifierLoc != OldQualifierLoc;
6978 }
6979
6980 auto *Typedef = cast_or_null<TypedefNameDecl>(
6981 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6982 if (!Typedef)
6983 return QualType();
6984 Changed |= Typedef != T->getDecl();
6985
6986 // FIXME: Transform the UnderlyingType if different from decl.
6987
6988 QualType Result = TL.getType();
6989 if (getDerived().AlwaysRebuild() || Changed) {
6990 Result = getDerived().RebuildTypedefType(
6991 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), Typedef);
6992 if (Result.isNull())
6993 return QualType();
6994 }
6995
6996 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6997 QualifierLoc, TL.getNameLoc());
6998 return Result;
6999}
7000
7001template<typename Derived>
7003 TypeOfExprTypeLoc TL) {
7004 // typeof expressions are not potentially evaluated contexts
7008
7009 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
7010 if (E.isInvalid())
7011 return QualType();
7012
7013 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
7014 if (E.isInvalid())
7015 return QualType();
7016
7017 QualType Result = TL.getType();
7019 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
7020 Result =
7021 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
7022 if (Result.isNull())
7023 return QualType();
7024 }
7025
7026 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
7027 NewTL.setTypeofLoc(TL.getTypeofLoc());
7028 NewTL.setLParenLoc(TL.getLParenLoc());
7029 NewTL.setRParenLoc(TL.getRParenLoc());
7030
7031 return Result;
7032}
7033
7034template<typename Derived>
7036 TypeOfTypeLoc TL) {
7037 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
7038 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
7039 if (!New_Under_TI)
7040 return QualType();
7041
7042 QualType Result = TL.getType();
7043 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
7044 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
7045 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
7046 if (Result.isNull())
7047 return QualType();
7048 }
7049
7050 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
7051 NewTL.setTypeofLoc(TL.getTypeofLoc());
7052 NewTL.setLParenLoc(TL.getLParenLoc());
7053 NewTL.setRParenLoc(TL.getRParenLoc());
7054 NewTL.setUnmodifiedTInfo(New_Under_TI);
7055
7056 return Result;
7057}
7058
7059template<typename Derived>
7061 DecltypeTypeLoc TL) {
7062 const DecltypeType *T = TL.getTypePtr();
7063
7064 // decltype expressions are not potentially evaluated contexts
7068
7069 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
7070 if (E.isInvalid())
7071 return QualType();
7072
7073 E = getSema().ActOnDecltypeExpression(E.get());
7074 if (E.isInvalid())
7075 return QualType();
7076
7077 QualType Result = TL.getType();
7078 if (getDerived().AlwaysRebuild() ||
7079 E.get() != T->getUnderlyingExpr()) {
7080 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
7081 if (Result.isNull())
7082 return QualType();
7083 }
7084 else E.get();
7085
7086 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
7087 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
7088 NewTL.setRParenLoc(TL.getRParenLoc());
7089 return Result;
7090}
7091
7092template <typename Derived>
7096 // Transform the index
7097 ExprResult IndexExpr;
7098 {
7099 EnterExpressionEvaluationContext ConstantContext(
7101
7102 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
7103 if (IndexExpr.isInvalid())
7104 return QualType();
7105 }
7106 QualType Pattern = TL.getPattern();
7107
7108 const PackIndexingType *PIT = TL.getTypePtr();
7109 SmallVector<QualType, 5> SubtitutedTypes;
7110 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
7111
7112 bool NotYetExpanded = Types.empty();
7113 bool FullySubstituted = true;
7114
7115 if (Types.empty() && !PIT->expandsToEmptyPack())
7116 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
7117
7118 for (QualType T : Types) {
7119 if (!T->containsUnexpandedParameterPack()) {
7120 QualType Transformed = getDerived().TransformType(T);
7121 if (Transformed.isNull())
7122 return QualType();
7123 SubtitutedTypes.push_back(Transformed);
7124 continue;
7125 }
7126
7128 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
7129 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7130 // Determine whether the set of unexpanded parameter packs can and should
7131 // be expanded.
7132 bool ShouldExpand = true;
7133 bool RetainExpansion = false;
7134 UnsignedOrNone NumExpansions = std::nullopt;
7135 if (getDerived().TryExpandParameterPacks(
7136 TL.getEllipsisLoc(), SourceRange(), Unexpanded,
7137 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
7138 RetainExpansion, NumExpansions))
7139 return QualType();
7140 if (!ShouldExpand) {
7141 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7142 // FIXME: should we keep TypeLoc for individual expansions in
7143 // PackIndexingTypeLoc?
7144 TypeSourceInfo *TI =
7145 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
7146 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
7147 if (Pack.isNull())
7148 return QualType();
7149 if (NotYetExpanded) {
7150 FullySubstituted = false;
7151 QualType Out = getDerived().RebuildPackIndexingType(
7152 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7153 FullySubstituted);
7154 if (Out.isNull())
7155 return QualType();
7156
7158 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7159 return Out;
7160 }
7161 SubtitutedTypes.push_back(Pack);
7162 continue;
7163 }
7164 for (unsigned I = 0; I != *NumExpansions; ++I) {
7165 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
7166 QualType Out = getDerived().TransformType(T);
7167 if (Out.isNull())
7168 return QualType();
7169 SubtitutedTypes.push_back(Out);
7170 FullySubstituted &= !Out->containsUnexpandedParameterPack();
7171 }
7172 // If we're supposed to retain a pack expansion, do so by temporarily
7173 // forgetting the partially-substituted parameter pack.
7174 if (RetainExpansion) {
7175 FullySubstituted = false;
7176 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
7177 QualType Out = getDerived().TransformType(T);
7178 if (Out.isNull())
7179 return QualType();
7180 SubtitutedTypes.push_back(Out);
7181 }
7182 }
7183
7184 // A pack indexing type can appear in a larger pack expansion,
7185 // e.g. `Pack...[pack_of_indexes]...`
7186 // so we need to temporarily disable substitution of pack elements
7187 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7188 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
7189
7190 QualType Out = getDerived().RebuildPackIndexingType(
7191 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7192 FullySubstituted, SubtitutedTypes);
7193 if (Out.isNull())
7194 return Out;
7195
7197 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7198 return Out;
7199}
7200
7201template<typename Derived>
7203 TypeLocBuilder &TLB,
7205 QualType Result = TL.getType();
7206 TypeSourceInfo *NewBaseTSI = TL.getUnderlyingTInfo();
7207 if (Result->isDependentType()) {
7208 const UnaryTransformType *T = TL.getTypePtr();
7209
7210 NewBaseTSI = getDerived().TransformType(TL.getUnderlyingTInfo());
7211 if (!NewBaseTSI)
7212 return QualType();
7213 QualType NewBase = NewBaseTSI->getType();
7214
7215 Result = getDerived().RebuildUnaryTransformType(NewBase,
7216 T->getUTTKind(),
7217 TL.getKWLoc());
7218 if (Result.isNull())
7219 return QualType();
7220 }
7221
7223 NewTL.setKWLoc(TL.getKWLoc());
7224 NewTL.setParensRange(TL.getParensRange());
7225 NewTL.setUnderlyingTInfo(NewBaseTSI);
7226 return Result;
7227}
7228
7229template<typename Derived>
7232 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
7233
7234 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7235 TemplateName TemplateName = getDerived().TransformTemplateName(
7236 QualifierLoc, /*TemplateKELoc=*/SourceLocation(), T->getTemplateName(),
7237 TL.getTemplateNameLoc());
7238 if (TemplateName.isNull())
7239 return QualType();
7240
7241 QualType OldDeduced = T->getDeducedType();
7242 QualType NewDeduced;
7243 if (!OldDeduced.isNull()) {
7244 NewDeduced = getDerived().TransformType(OldDeduced);
7245 if (NewDeduced.isNull())
7246 return QualType();
7247 }
7248
7249 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
7250 NewDeduced.isNull() ? DeducedKind::Undeduced : DeducedKind::Deduced,
7251 NewDeduced, T->getKeyword(), TemplateName);
7252 if (Result.isNull())
7253 return QualType();
7254
7255 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7256 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7257 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7258 NewTL.setQualifierLoc(QualifierLoc);
7259 return Result;
7260}
7261
7262template <typename Derived>
7264 TagTypeLoc TL) {
7265 const TagType *T = TL.getTypePtr();
7266
7267 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7268 if (QualifierLoc) {
7269 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7270 if (!QualifierLoc)
7271 return QualType();
7272 }
7273
7274 auto *TD = cast_or_null<TagDecl>(
7275 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7276 if (!TD)
7277 return QualType();
7278
7279 QualType Result = TL.getType();
7280 if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() ||
7281 TD != T->getDecl()) {
7282 if (T->isCanonicalUnqualified())
7283 Result = getDerived().RebuildCanonicalTagType(TD);
7284 else
7285 Result = getDerived().RebuildTagType(
7286 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TD);
7287 if (Result.isNull())
7288 return QualType();
7289 }
7290
7291 TagTypeLoc NewTL = TLB.push<TagTypeLoc>(Result);
7293 NewTL.setQualifierLoc(QualifierLoc);
7294 NewTL.setNameLoc(TL.getNameLoc());
7295
7296 return Result;
7297}
7298
7299template <typename Derived>
7301 EnumTypeLoc TL) {
7302 return getDerived().TransformTagType(TLB, TL);
7303}
7304
7305template <typename Derived>
7306QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
7307 RecordTypeLoc TL) {
7308 return getDerived().TransformTagType(TLB, TL);
7309}
7310
7311template<typename Derived>
7313 TypeLocBuilder &TLB,
7315 return getDerived().TransformTagType(TLB, TL);
7316}
7317
7318template<typename Derived>
7320 TypeLocBuilder &TLB,
7322 return getDerived().TransformTemplateTypeParmType(
7323 TLB, TL,
7324 /*SuppressObjCLifetime=*/false);
7325}
7326
7327template <typename Derived>
7329 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7330 return TransformTypeSpecType(TLB, TL);
7331}
7332
7333template<typename Derived>
7334QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7335 TypeLocBuilder &TLB,
7336 SubstTemplateTypeParmTypeLoc TL) {
7337 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7338
7339 Decl *NewReplaced =
7340 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7341
7342 // Substitute into the replacement type, which itself might involve something
7343 // that needs to be transformed. This only tends to occur with default
7344 // template arguments of template template parameters.
7345 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7346 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7347 if (Replacement.isNull())
7348 return QualType();
7349
7350 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7351 Replacement, NewReplaced, T->getIndex(), T->getPackIndex(),
7352 T->getFinal());
7353
7354 // Propagate type-source information.
7355 SubstTemplateTypeParmTypeLoc NewTL
7356 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7357 NewTL.setNameLoc(TL.getNameLoc());
7358 return Result;
7359
7360}
7361template <typename Derived>
7364 return TransformTypeSpecType(TLB, TL);
7365}
7366
7367template<typename Derived>
7369 TypeLocBuilder &TLB,
7371 return getDerived().TransformSubstTemplateTypeParmPackType(
7372 TLB, TL, /*SuppressObjCLifetime=*/false);
7373}
7374
7375template <typename Derived>
7378 return TransformTypeSpecType(TLB, TL);
7379}
7380
7381template<typename Derived>
7382QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
7383 AtomicTypeLoc TL) {
7384 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7385 if (ValueType.isNull())
7386 return QualType();
7387
7388 QualType Result = TL.getType();
7389 if (getDerived().AlwaysRebuild() ||
7390 ValueType != TL.getValueLoc().getType()) {
7391 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7392 if (Result.isNull())
7393 return QualType();
7394 }
7395
7396 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7397 NewTL.setKWLoc(TL.getKWLoc());
7398 NewTL.setLParenLoc(TL.getLParenLoc());
7399 NewTL.setRParenLoc(TL.getRParenLoc());
7400
7401 return Result;
7402}
7403
7404template <typename Derived>
7406 PipeTypeLoc TL) {
7407 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7408 if (ValueType.isNull())
7409 return QualType();
7410
7411 QualType Result = TL.getType();
7412 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7413 const PipeType *PT = Result->castAs<PipeType>();
7414 bool isReadPipe = PT->isReadOnly();
7415 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7416 if (Result.isNull())
7417 return QualType();
7418 }
7419
7420 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7421 NewTL.setKWLoc(TL.getKWLoc());
7422
7423 return Result;
7424}
7425
7426template <typename Derived>
7428 BitIntTypeLoc TL) {
7429 const BitIntType *EIT = TL.getTypePtr();
7430 QualType Result = TL.getType();
7431
7432 if (getDerived().AlwaysRebuild()) {
7433 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7434 EIT->getNumBits(), TL.getNameLoc());
7435 if (Result.isNull())
7436 return QualType();
7437 }
7438
7439 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7440 NewTL.setNameLoc(TL.getNameLoc());
7441 return Result;
7442}
7443
7444template <typename Derived>
7447 const DependentBitIntType *EIT = TL.getTypePtr();
7448
7451 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7452 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7453
7454 if (BitsExpr.isInvalid())
7455 return QualType();
7456
7457 QualType Result = TL.getType();
7458
7459 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7460 Result = getDerived().RebuildDependentBitIntType(
7461 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7462
7463 if (Result.isNull())
7464 return QualType();
7465 }
7466
7469 NewTL.setNameLoc(TL.getNameLoc());
7470 } else {
7471 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7472 NewTL.setNameLoc(TL.getNameLoc());
7473 }
7474 return Result;
7475}
7476
7477template <typename Derived>
7480 llvm_unreachable("This type does not need to be transformed.");
7481}
7482
7483 /// Simple iterator that traverses the template arguments in a
7484 /// container that provides a \c getArgLoc() member function.
7485 ///
7486 /// This iterator is intended to be used with the iterator form of
7487 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7488 template<typename ArgLocContainer>
7490 ArgLocContainer *Container;
7491 unsigned Index;
7492
7493 public:
7496 typedef int difference_type;
7497 typedef std::input_iterator_tag iterator_category;
7498
7499 class pointer {
7501
7502 public:
7503 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7504
7506 return &Arg;
7507 }
7508 };
7509
7510
7512
7513 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7514 unsigned Index)
7515 : Container(&Container), Index(Index) { }
7516
7518 ++Index;
7519 return *this;
7520 }
7521
7524 ++(*this);
7525 return Old;
7526 }
7527
7529 return Container->getArgLoc(Index);
7530 }
7531
7533 return pointer(Container->getArgLoc(Index));
7534 }
7535
7538 return X.Container == Y.Container && X.Index == Y.Index;
7539 }
7540
7543 return !(X == Y);
7544 }
7545 };
7546
7547template<typename Derived>
7548QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7549 AutoTypeLoc TL) {
7550 const AutoType *T = TL.getTypePtr();
7551 QualType OldDeduced = T->getDeducedType();
7552 QualType NewDeduced;
7553 if (!OldDeduced.isNull()) {
7554 NewDeduced = getDerived().TransformType(OldDeduced);
7555 if (NewDeduced.isNull())
7556 return QualType();
7557 }
7558
7559 ConceptDecl *NewCD = nullptr;
7560 TemplateArgumentListInfo NewTemplateArgs;
7561 NestedNameSpecifierLoc NewNestedNameSpec;
7562 if (T->isConstrained()) {
7563 assert(TL.getConceptReference());
7564 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7565 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7566
7567 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7568 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7570 if (getDerived().TransformTemplateArguments(
7571 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7572 NewTemplateArgs))
7573 return QualType();
7574
7575 if (TL.getNestedNameSpecifierLoc()) {
7576 NewNestedNameSpec
7577 = getDerived().TransformNestedNameSpecifierLoc(
7578 TL.getNestedNameSpecifierLoc());
7579 if (!NewNestedNameSpec)
7580 return QualType();
7581 }
7582 }
7583
7584 QualType Result = TL.getType();
7585 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7586 T->isDependentType() || T->isConstrained()) {
7587 // FIXME: Maybe don't rebuild if all template arguments are the same.
7589 NewArgList.reserve(NewTemplateArgs.size());
7590 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7591 NewArgList.push_back(ArgLoc.getArgument());
7592 Result = getDerived().RebuildAutoType(
7593 NewDeduced.isNull() ? DeducedKind::Undeduced : DeducedKind::Deduced,
7594 NewDeduced, T->getKeyword(), NewCD, NewArgList);
7595 if (Result.isNull())
7596 return QualType();
7597 }
7598
7599 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7600 NewTL.setNameLoc(TL.getNameLoc());
7601 NewTL.setRParenLoc(TL.getRParenLoc());
7602 NewTL.setConceptReference(nullptr);
7603
7604 if (T->isConstrained()) {
7606 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7607 TL.getConceptNameLoc(),
7608 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7609 auto *CR = ConceptReference::Create(
7610 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7611 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7612 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7613 NewTL.setConceptReference(CR);
7614 }
7615
7616 return Result;
7617}
7618
7619template <typename Derived>
7622 return getDerived().TransformTemplateSpecializationType(
7623 TLB, TL, /*ObjectType=*/QualType(), /*FirstQualifierInScope=*/nullptr,
7624 /*AllowInjectedClassName=*/false);
7625}
7626
7627template <typename Derived>
7630 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
7631 const TemplateSpecializationType *T = TL.getTypePtr();
7632
7633 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7634 TemplateName Template = getDerived().TransformTemplateName(
7635 QualifierLoc, TL.getTemplateKeywordLoc(), T->getTemplateName(),
7636 TL.getTemplateNameLoc(), ObjectType, FirstQualifierInScope,
7637 AllowInjectedClassName);
7638 if (Template.isNull())
7639 return QualType();
7640
7641 TemplateArgumentListInfo NewTemplateArgs;
7642 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7643 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7645 ArgIterator;
7646 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7647 ArgIterator(TL, TL.getNumArgs()),
7648 NewTemplateArgs))
7649 return QualType();
7650
7651 // This needs to be rebuilt if either the arguments changed, or if the
7652 // original template changed. If the template changed, and even if the
7653 // arguments didn't change, these arguments might not correspond to their
7654 // respective parameters, therefore needing conversions.
7655 QualType Result = getDerived().RebuildTemplateSpecializationType(
7656 TL.getTypePtr()->getKeyword(), Template, TL.getTemplateNameLoc(),
7657 NewTemplateArgs);
7658
7659 if (!Result.isNull()) {
7661 TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getTemplateKeywordLoc(),
7662 TL.getTemplateNameLoc(), NewTemplateArgs);
7663 }
7664
7665 return Result;
7666}
7667
7668template <typename Derived>
7670 AttributedTypeLoc TL) {
7671 const AttributedType *oldType = TL.getTypePtr();
7672 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7673 if (modifiedType.isNull())
7674 return QualType();
7675
7676 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7677 const Attr *oldAttr = TL.getAttr();
7678 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7679 if (oldAttr && !newAttr)
7680 return QualType();
7681
7682 QualType result = TL.getType();
7683
7684 // FIXME: dependent operand expressions?
7685 if (getDerived().AlwaysRebuild() ||
7686 modifiedType != oldType->getModifiedType()) {
7687 // If the equivalent type is equal to the modified type, we don't want to
7688 // transform it as well because:
7689 //
7690 // 1. The transformation would yield the same result and is therefore
7691 // superfluous, and
7692 //
7693 // 2. Transforming the same type twice can cause problems, e.g. if it
7694 // is a FunctionProtoType, we may end up instantiating the function
7695 // parameters twice, which causes an assertion since the parameters
7696 // are already bound to their counterparts in the template for this
7697 // instantiation.
7698 //
7699 QualType equivalentType = modifiedType;
7700 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7701 TypeLocBuilder AuxiliaryTLB;
7702 AuxiliaryTLB.reserve(TL.getFullDataSize());
7703 equivalentType =
7704 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7705 if (equivalentType.isNull())
7706 return QualType();
7707 }
7708
7709 // Check whether we can add nullability; it is only represented as
7710 // type sugar, and therefore cannot be diagnosed in any other way.
7711 if (auto nullability = oldType->getImmediateNullability()) {
7712 if (!modifiedType->canHaveNullability()) {
7713 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7714 : TL.getModifiedLoc().getBeginLoc()),
7715 diag::err_nullability_nonpointer)
7716 << DiagNullabilityKind(*nullability, false) << modifiedType;
7717 return QualType();
7718 }
7719 }
7720
7721 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7722 modifiedType,
7723 equivalentType,
7724 TL.getAttr());
7725 }
7726
7727 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7728 newTL.setAttr(newAttr);
7729 return result;
7730}
7731
7732template <typename Derived>
7735 const CountAttributedType *OldTy = TL.getTypePtr();
7736 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7737 if (InnerTy.isNull())
7738 return QualType();
7739
7740 Expr *OldCount = TL.getCountExpr();
7741 Expr *NewCount = nullptr;
7742 if (OldCount) {
7743 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7744 if (CountResult.isInvalid())
7745 return QualType();
7746 NewCount = CountResult.get();
7747 }
7748
7749 QualType Result = TL.getType();
7750 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7751 OldCount != NewCount) {
7752 // Currently, CountAttributedType can only wrap incomplete array types.
7754 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7755 }
7756
7757 TLB.push<CountAttributedTypeLoc>(Result);
7758 return Result;
7759}
7760
7761template <typename Derived>
7764 // The BTFTagAttributedType is available for C only.
7765 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7766}
7767
7768template <typename Derived>
7771 const OverflowBehaviorType *OldTy = TL.getTypePtr();
7772 QualType InnerTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7773 if (InnerTy.isNull())
7774 return QualType();
7775
7776 QualType Result = TL.getType();
7777 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->getUnderlyingType()) {
7778 Result = SemaRef.Context.getOverflowBehaviorType(OldTy->getBehaviorKind(),
7779 InnerTy);
7780 if (Result.isNull())
7781 return QualType();
7782 }
7783
7785 NewTL.initializeLocal(SemaRef.Context, TL.getAttrLoc());
7786 return Result;
7787}
7788
7789template <typename Derived>
7792
7793 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7794
7795 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7796 if (WrappedTy.isNull())
7797 return QualType();
7798
7799 QualType ContainedTy = QualType();
7800 QualType OldContainedTy = oldType->getContainedType();
7801 TypeSourceInfo *ContainedTSI = nullptr;
7802 if (!OldContainedTy.isNull()) {
7803 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7804 if (!oldContainedTSI)
7805 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7806 OldContainedTy, SourceLocation());
7807 ContainedTSI = getDerived().TransformType(oldContainedTSI);
7808 if (!ContainedTSI)
7809 return QualType();
7810 ContainedTy = ContainedTSI->getType();
7811 }
7812
7813 QualType Result = TL.getType();
7814 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7815 ContainedTy != oldType->getContainedType()) {
7817 WrappedTy, ContainedTy, oldType->getAttrs());
7818 }
7819
7822 NewTL.setSourceRange(TL.getLocalSourceRange());
7823 NewTL.setContainedTypeSourceInfo(ContainedTSI);
7824 return Result;
7825}
7826
7827template <typename Derived>
7830 // No transformations needed.
7831 return TL.getType();
7832}
7833
7834template<typename Derived>
7837 ParenTypeLoc TL) {
7838 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7839 if (Inner.isNull())
7840 return QualType();
7841
7842 QualType Result = TL.getType();
7843 if (getDerived().AlwaysRebuild() ||
7844 Inner != TL.getInnerLoc().getType()) {
7845 Result = getDerived().RebuildParenType(Inner);
7846 if (Result.isNull())
7847 return QualType();
7848 }
7849
7850 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7851 NewTL.setLParenLoc(TL.getLParenLoc());
7852 NewTL.setRParenLoc(TL.getRParenLoc());
7853 return Result;
7854}
7855
7856template <typename Derived>
7860 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7861 if (Inner.isNull())
7862 return QualType();
7863
7864 QualType Result = TL.getType();
7865 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7866 Result =
7867 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7868 if (Result.isNull())
7869 return QualType();
7870 }
7871
7873 NewTL.setExpansionLoc(TL.getExpansionLoc());
7874 return Result;
7875}
7876
7877template<typename Derived>
7878QualType TreeTransform<Derived>::TransformDependentNameType(
7880 return TransformDependentNameType(TLB, TL, false);
7881}
7882
7883template <typename Derived>
7884QualType TreeTransform<Derived>::TransformDependentNameType(
7885 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext,
7886 QualType ObjectType, NamedDecl *UnqualLookup) {
7887 const DependentNameType *T = TL.getTypePtr();
7888
7889 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7890 if (QualifierLoc) {
7891 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
7892 QualifierLoc, ObjectType, UnqualLookup);
7893 if (!QualifierLoc)
7894 return QualType();
7895 } else {
7896 assert((ObjectType.isNull() && !UnqualLookup) &&
7897 "must be transformed by TransformNestedNameSpecifierLoc");
7898 }
7899
7901 = getDerived().RebuildDependentNameType(T->getKeyword(),
7902 TL.getElaboratedKeywordLoc(),
7903 QualifierLoc,
7904 T->getIdentifier(),
7905 TL.getNameLoc(),
7906 DeducedTSTContext);
7907 if (Result.isNull())
7908 return QualType();
7909
7910 if (isa<TagType>(Result)) {
7911 auto NewTL = TLB.push<TagTypeLoc>(Result);
7912 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7913 NewTL.setQualifierLoc(QualifierLoc);
7914 NewTL.setNameLoc(TL.getNameLoc());
7916 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7917 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7918 NewTL.setTemplateNameLoc(TL.getNameLoc());
7919 NewTL.setQualifierLoc(QualifierLoc);
7920 } else if (isa<TypedefType>(Result)) {
7921 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7922 QualifierLoc, TL.getNameLoc());
7923 } else if (isa<UnresolvedUsingType>(Result)) {
7924 auto NewTL = TLB.push<UnresolvedUsingTypeLoc>(Result);
7925 NewTL.set(TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getNameLoc());
7926 } else {
7927 auto NewTL = TLB.push<DependentNameTypeLoc>(Result);
7928 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7929 NewTL.setQualifierLoc(QualifierLoc);
7930 NewTL.setNameLoc(TL.getNameLoc());
7931 }
7932 return Result;
7933}
7934
7935template<typename Derived>
7938 QualType Pattern
7939 = getDerived().TransformType(TLB, TL.getPatternLoc());
7940 if (Pattern.isNull())
7941 return QualType();
7942
7943 QualType Result = TL.getType();
7944 if (getDerived().AlwaysRebuild() ||
7945 Pattern != TL.getPatternLoc().getType()) {
7946 Result = getDerived().RebuildPackExpansionType(Pattern,
7947 TL.getPatternLoc().getSourceRange(),
7948 TL.getEllipsisLoc(),
7949 TL.getTypePtr()->getNumExpansions());
7950 if (Result.isNull())
7951 return QualType();
7952 }
7953
7955 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7956 return Result;
7957}
7958
7959template<typename Derived>
7963 // ObjCInterfaceType is never dependent.
7964 TLB.pushFullCopy(TL);
7965 return TL.getType();
7966}
7967
7968template<typename Derived>
7972 const ObjCTypeParamType *T = TL.getTypePtr();
7973 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7974 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7975 if (!OTP)
7976 return QualType();
7977
7978 QualType Result = TL.getType();
7979 if (getDerived().AlwaysRebuild() ||
7980 OTP != T->getDecl()) {
7981 Result = getDerived().RebuildObjCTypeParamType(
7982 OTP, TL.getProtocolLAngleLoc(),
7983 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7984 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7985 if (Result.isNull())
7986 return QualType();
7987 }
7988
7990 if (TL.getNumProtocols()) {
7991 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7992 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7993 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7994 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7995 }
7996 return Result;
7997}
7998
7999template<typename Derived>
8002 ObjCObjectTypeLoc TL) {
8003 // Transform base type.
8004 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
8005 if (BaseType.isNull())
8006 return QualType();
8007
8008 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
8009
8010 // Transform type arguments.
8011 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
8012 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
8013 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
8014 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
8015 QualType TypeArg = TypeArgInfo->getType();
8016 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
8017 AnyChanged = true;
8018
8019 // We have a pack expansion. Instantiate it.
8020 const auto *PackExpansion = PackExpansionLoc.getType()
8021 ->castAs<PackExpansionType>();
8023 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
8024 Unexpanded);
8025 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
8026
8027 // Determine whether the set of unexpanded parameter packs can
8028 // and should be expanded.
8029 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
8030 bool Expand = false;
8031 bool RetainExpansion = false;
8032 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
8033 if (getDerived().TryExpandParameterPacks(
8034 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
8035 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
8036 RetainExpansion, NumExpansions))
8037 return QualType();
8038
8039 if (!Expand) {
8040 // We can't expand this pack expansion into separate arguments yet;
8041 // just substitute into the pattern and create a new pack expansion
8042 // type.
8043 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
8044
8045 TypeLocBuilder TypeArgBuilder;
8046 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8047 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
8048 PatternLoc);
8049 if (NewPatternType.isNull())
8050 return QualType();
8051
8052 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
8053 NewPatternType, NumExpansions);
8054 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
8055 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
8056 NewTypeArgInfos.push_back(
8057 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
8058 continue;
8059 }
8060
8061 // Substitute into the pack expansion pattern for each slice of the
8062 // pack.
8063 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
8064 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
8065
8066 TypeLocBuilder TypeArgBuilder;
8067 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8068
8069 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
8070 PatternLoc);
8071 if (NewTypeArg.isNull())
8072 return QualType();
8073
8074 NewTypeArgInfos.push_back(
8075 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8076 }
8077
8078 continue;
8079 }
8080
8081 TypeLocBuilder TypeArgBuilder;
8082 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
8083 QualType NewTypeArg =
8084 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
8085 if (NewTypeArg.isNull())
8086 return QualType();
8087
8088 // If nothing changed, just keep the old TypeSourceInfo.
8089 if (NewTypeArg == TypeArg) {
8090 NewTypeArgInfos.push_back(TypeArgInfo);
8091 continue;
8092 }
8093
8094 NewTypeArgInfos.push_back(
8095 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8096 AnyChanged = true;
8097 }
8098
8099 QualType Result = TL.getType();
8100 if (getDerived().AlwaysRebuild() || AnyChanged) {
8101 // Rebuild the type.
8102 Result = getDerived().RebuildObjCObjectType(
8103 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
8104 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
8105 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8106 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8107
8108 if (Result.isNull())
8109 return QualType();
8110 }
8111
8112 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
8113 NewT.setHasBaseTypeAsWritten(true);
8114 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
8115 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
8116 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
8117 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
8118 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8119 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8120 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
8121 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8122 return Result;
8123}
8124
8125template<typename Derived>
8129 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8130 if (PointeeType.isNull())
8131 return QualType();
8132
8133 QualType Result = TL.getType();
8134 if (getDerived().AlwaysRebuild() ||
8135 PointeeType != TL.getPointeeLoc().getType()) {
8136 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8137 TL.getStarLoc());
8138 if (Result.isNull())
8139 return QualType();
8140 }
8141
8143 NewT.setStarLoc(TL.getStarLoc());
8144 return Result;
8145}
8146
8147//===----------------------------------------------------------------------===//
8148// Statement transformation
8149//===----------------------------------------------------------------------===//
8150template<typename Derived>
8153 return S;
8154}
8155
8156template<typename Derived>
8159 return getDerived().TransformCompoundStmt(S, false);
8160}
8161
8162template<typename Derived>
8165 bool IsStmtExpr) {
8166 Sema::CompoundScopeRAII CompoundScope(getSema());
8167 Sema::FPFeaturesStateRAII FPSave(getSema());
8168 if (S->hasStoredFPFeatures())
8169 getSema().resetFPOptions(
8170 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8171
8172 bool SubStmtInvalid = false;
8173 bool SubStmtChanged = false;
8174 SmallVector<Stmt*, 8> Statements;
8175 for (auto *B : S->body()) {
8176 StmtResult Result = getDerived().TransformStmt(
8177 B, IsStmtExpr && B == S->body_back() ? StmtDiscardKind::StmtExprResult
8178 : StmtDiscardKind::Discarded);
8179
8180 if (Result.isInvalid()) {
8181 // Immediately fail if this was a DeclStmt, since it's very
8182 // likely that this will cause problems for future statements.
8183 if (isa<DeclStmt>(B))
8184 return StmtError();
8185
8186 // Otherwise, just keep processing substatements and fail later.
8187 SubStmtInvalid = true;
8188 continue;
8189 }
8190
8191 SubStmtChanged = SubStmtChanged || Result.get() != B;
8192 Statements.push_back(Result.getAs<Stmt>());
8193 }
8194
8195 if (SubStmtInvalid)
8196 return StmtError();
8197
8198 if (!getDerived().AlwaysRebuild() &&
8199 !SubStmtChanged)
8200 return S;
8201
8202 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8203 Statements,
8204 S->getRBracLoc(),
8205 IsStmtExpr);
8206}
8207
8208template<typename Derived>
8211 ExprResult LHS, RHS;
8212 {
8215
8216 // Transform the left-hand case value.
8217 LHS = getDerived().TransformExpr(S->getLHS());
8218 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8219 if (LHS.isInvalid())
8220 return StmtError();
8221
8222 // Transform the right-hand case value (for the GNU case-range extension).
8223 RHS = getDerived().TransformExpr(S->getRHS());
8224 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8225 if (RHS.isInvalid())
8226 return StmtError();
8227 }
8228
8229 // Build the case statement.
8230 // Case statements are always rebuilt so that they will attached to their
8231 // transformed switch statement.
8232 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8233 LHS.get(),
8234 S->getEllipsisLoc(),
8235 RHS.get(),
8236 S->getColonLoc());
8237 if (Case.isInvalid())
8238 return StmtError();
8239
8240 // Transform the statement following the case
8241 StmtResult SubStmt =
8242 getDerived().TransformStmt(S->getSubStmt());
8243 if (SubStmt.isInvalid())
8244 return StmtError();
8245
8246 // Attach the body to the case statement
8247 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8248}
8249
8250template <typename Derived>
8252 // Transform the statement following the default case
8253 StmtResult SubStmt =
8254 getDerived().TransformStmt(S->getSubStmt());
8255 if (SubStmt.isInvalid())
8256 return StmtError();
8257
8258 // Default statements are always rebuilt
8259 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8260 SubStmt.get());
8261}
8262
8263template<typename Derived>
8266 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8267 if (SubStmt.isInvalid())
8268 return StmtError();
8269
8270 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8271 S->getDecl());
8272 if (!LD)
8273 return StmtError();
8274
8275 // If we're transforming "in-place" (we're not creating new local
8276 // declarations), assume we're replacing the old label statement
8277 // and clear out the reference to it.
8278 if (LD == S->getDecl())
8279 S->getDecl()->setStmt(nullptr);
8280
8281 // FIXME: Pass the real colon location in.
8282 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8284 SubStmt.get());
8285}
8286
8287template <typename Derived>
8289 if (!R)
8290 return R;
8291
8292 switch (R->getKind()) {
8293// Transform attributes by calling TransformXXXAttr.
8294#define ATTR(X) \
8295 case attr::X: \
8296 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8297#include "clang/Basic/AttrList.inc"
8298 }
8299 return R;
8300}
8301
8302template <typename Derived>
8304 const Stmt *InstS,
8305 const Attr *R) {
8306 if (!R)
8307 return R;
8308
8309 switch (R->getKind()) {
8310// Transform attributes by calling TransformStmtXXXAttr.
8311#define ATTR(X) \
8312 case attr::X: \
8313 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8314#include "clang/Basic/AttrList.inc"
8315 }
8316 return TransformAttr(R);
8317}
8318
8319template <typename Derived>
8322 StmtDiscardKind SDK) {
8323 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8324 if (SubStmt.isInvalid())
8325 return StmtError();
8326
8327 bool AttrsChanged = false;
8329
8330 // Visit attributes and keep track if any are transformed.
8331 for (const auto *I : S->getAttrs()) {
8332 const Attr *R =
8333 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8334 AttrsChanged |= (I != R);
8335 if (R)
8336 Attrs.push_back(R);
8337 }
8338
8339 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8340 return S;
8341
8342 // If transforming the attributes failed for all of the attributes in the
8343 // statement, don't make an AttributedStmt without attributes.
8344 if (Attrs.empty())
8345 return SubStmt;
8346
8347 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8348 SubStmt.get());
8349}
8350
8351template<typename Derived>
8354 // Transform the initialization statement
8355 StmtResult Init = getDerived().TransformStmt(S->getInit());
8356 if (Init.isInvalid())
8357 return StmtError();
8358
8360 if (!S->isConsteval()) {
8361 // Transform the condition
8362 Cond = getDerived().TransformCondition(
8363 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8364 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8366 if (Cond.isInvalid())
8367 return StmtError();
8368 }
8369
8370 // If this is a constexpr if, determine which arm we should instantiate.
8371 std::optional<bool> ConstexprConditionValue;
8372 if (S->isConstexpr())
8373 ConstexprConditionValue = Cond.getKnownValue();
8374
8375 // Transform the "then" branch.
8376 StmtResult Then;
8377 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8381 S->isNonNegatedConsteval());
8382
8383 Then = getDerived().TransformStmt(S->getThen());
8384 if (Then.isInvalid())
8385 return StmtError();
8386 } else {
8387 // Discarded branch is replaced with empty CompoundStmt so we can keep
8388 // proper source location for start and end of original branch, so
8389 // subsequent transformations like CoverageMapping work properly
8390 Then = new (getSema().Context)
8391 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8392 }
8393
8394 // Transform the "else" branch.
8395 StmtResult Else;
8396 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8400 S->isNegatedConsteval());
8401
8402 Else = getDerived().TransformStmt(S->getElse());
8403 if (Else.isInvalid())
8404 return StmtError();
8405 } else if (S->getElse() && ConstexprConditionValue &&
8406 *ConstexprConditionValue) {
8407 // Same thing here as with <then> branch, we are discarding it, we can't
8408 // replace it with NULL nor NullStmt as we need to keep for source location
8409 // range, for CoverageMapping
8410 Else = new (getSema().Context)
8411 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8412 }
8413
8414 if (!getDerived().AlwaysRebuild() &&
8415 Init.get() == S->getInit() &&
8416 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8417 Then.get() == S->getThen() &&
8418 Else.get() == S->getElse())
8419 return S;
8420
8421 return getDerived().RebuildIfStmt(
8422 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8423 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8424}
8425
8426template<typename Derived>
8429 // Transform the initialization statement
8430 StmtResult Init = getDerived().TransformStmt(S->getInit());
8431 if (Init.isInvalid())
8432 return StmtError();
8433
8434 // Transform the condition.
8435 Sema::ConditionResult Cond = getDerived().TransformCondition(
8436 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8438 if (Cond.isInvalid())
8439 return StmtError();
8440
8441 // Rebuild the switch statement.
8443 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8444 Init.get(), Cond, S->getRParenLoc());
8445 if (Switch.isInvalid())
8446 return StmtError();
8447
8448 // Transform the body of the switch statement.
8449 StmtResult Body = getDerived().TransformStmt(S->getBody());
8450 if (Body.isInvalid())
8451 return StmtError();
8452
8453 // Complete the switch statement.
8454 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8455 Body.get());
8456}
8457
8458template<typename Derived>
8461 // Transform the condition
8462 Sema::ConditionResult Cond = getDerived().TransformCondition(
8463 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8465 if (Cond.isInvalid())
8466 return StmtError();
8467
8468 // OpenACC Restricts a while-loop inside of certain construct/clause
8469 // combinations, so diagnose that here in OpenACC mode.
8471 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8472
8473 // Transform the body
8474 StmtResult Body = getDerived().TransformStmt(S->getBody());
8475 if (Body.isInvalid())
8476 return StmtError();
8477
8478 if (!getDerived().AlwaysRebuild() &&
8479 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8480 Body.get() == S->getBody())
8481 return Owned(S);
8482
8483 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8484 Cond, S->getRParenLoc(), Body.get());
8485}
8486
8487template<typename Derived>
8490 // OpenACC Restricts a do-loop inside of certain construct/clause
8491 // combinations, so diagnose that here in OpenACC mode.
8493 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8494
8495 // Transform the body
8496 StmtResult Body = getDerived().TransformStmt(S->getBody());
8497 if (Body.isInvalid())
8498 return StmtError();
8499
8500 // Transform the condition
8501 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8502 if (Cond.isInvalid())
8503 return StmtError();
8504
8505 if (!getDerived().AlwaysRebuild() &&
8506 Cond.get() == S->getCond() &&
8507 Body.get() == S->getBody())
8508 return S;
8509
8510 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8511 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8512 S->getRParenLoc());
8513}
8514
8515template<typename Derived>
8518 if (getSema().getLangOpts().OpenMP)
8519 getSema().OpenMP().startOpenMPLoop();
8520
8521 // Transform the initialization statement
8522 StmtResult Init = getDerived().TransformStmt(S->getInit());
8523 if (Init.isInvalid())
8524 return StmtError();
8525
8526 // In OpenMP loop region loop control variable must be captured and be
8527 // private. Perform analysis of first part (if any).
8528 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8529 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8530 Init.get());
8531
8532 // Transform the condition
8533 Sema::ConditionResult Cond = getDerived().TransformCondition(
8534 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8536 if (Cond.isInvalid())
8537 return StmtError();
8538
8539 // Transform the increment
8540 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8541 if (Inc.isInvalid())
8542 return StmtError();
8543
8544 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8545 if (S->getInc() && !FullInc.get())
8546 return StmtError();
8547
8548 // OpenACC Restricts a for-loop inside of certain construct/clause
8549 // combinations, so diagnose that here in OpenACC mode.
8551 SemaRef.OpenACC().ActOnForStmtBegin(
8552 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8553 Cond.get().second, S->getInc(), Inc.get());
8554
8555 // Transform the body
8556 StmtResult Body = getDerived().TransformStmt(S->getBody());
8557 if (Body.isInvalid())
8558 return StmtError();
8559
8560 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8561
8562 if (!getDerived().AlwaysRebuild() &&
8563 Init.get() == S->getInit() &&
8564 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8565 Inc.get() == S->getInc() &&
8566 Body.get() == S->getBody())
8567 return S;
8568
8569 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8570 Init.get(), Cond, FullInc,
8571 S->getRParenLoc(), Body.get());
8572}
8573
8574template<typename Derived>
8577 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8578 S->getLabel());
8579 if (!LD)
8580 return StmtError();
8581
8582 // Goto statements must always be rebuilt, to resolve the label.
8583 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8584 cast<LabelDecl>(LD));
8585}
8586
8587template<typename Derived>
8590 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8591 if (Target.isInvalid())
8592 return StmtError();
8593 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8594
8595 if (!getDerived().AlwaysRebuild() &&
8596 Target.get() == S->getTarget())
8597 return S;
8598
8599 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8600 Target.get());
8601}
8602
8603template<typename Derived>
8606 if (!S->hasLabelTarget())
8607 return S;
8608
8609 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8610 S->getLabelDecl());
8611 if (!LD)
8612 return StmtError();
8613
8614 return new (SemaRef.Context)
8615 ContinueStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8616}
8617
8618template<typename Derived>
8621 if (!S->hasLabelTarget())
8622 return S;
8623
8624 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8625 S->getLabelDecl());
8626 if (!LD)
8627 return StmtError();
8628
8629 return new (SemaRef.Context)
8630 BreakStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8631}
8632
8633template <typename Derived>
8635 StmtResult Result = getDerived().TransformStmt(S->getBody());
8636 if (!Result.isUsable())
8637 return StmtError();
8638 return DeferStmt::Create(getSema().Context, S->getDeferLoc(), Result.get());
8639}
8640
8641template<typename Derived>
8644 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8645 /*NotCopyInit*/false);
8646 if (Result.isInvalid())
8647 return StmtError();
8648
8649 // FIXME: We always rebuild the return statement because there is no way
8650 // to tell whether the return type of the function has changed.
8651 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8652}
8653
8654template<typename Derived>
8657 bool DeclChanged = false;
8659 LambdaScopeInfo *LSI = getSema().getCurLambda();
8660 for (auto *D : S->decls()) {
8661 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8662 if (!Transformed)
8663 return StmtError();
8664
8665 if (Transformed != D)
8666 DeclChanged = true;
8667
8668 if (LSI) {
8669 if (auto *TD = dyn_cast<TypeDecl>(Transformed)) {
8670 if (auto *TN = dyn_cast<TypedefNameDecl>(TD)) {
8671 LSI->ContainsUnexpandedParameterPack |=
8672 TN->getUnderlyingType()->containsUnexpandedParameterPack();
8673 } else {
8674 LSI->ContainsUnexpandedParameterPack |=
8675 getSema()
8676 .getASTContext()
8677 .getTypeDeclType(TD)
8678 ->containsUnexpandedParameterPack();
8679 }
8680 }
8681 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8682 LSI->ContainsUnexpandedParameterPack |=
8683 VD->getType()->containsUnexpandedParameterPack();
8684 }
8685
8686 Decls.push_back(Transformed);
8687 }
8688
8689 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8690 return S;
8691
8692 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8693}
8694
8695template<typename Derived>
8698
8699 SmallVector<Expr*, 8> Constraints;
8702
8703 SmallVector<Expr*, 8> Clobbers;
8704
8705 bool ExprsChanged = false;
8706
8707 auto RebuildString = [&](Expr *E) {
8708 ExprResult Result = getDerived().TransformExpr(E);
8709 if (!Result.isUsable())
8710 return Result;
8711 if (Result.get() != E) {
8712 ExprsChanged = true;
8713 Result = SemaRef.ActOnGCCAsmStmtString(Result.get(), /*ForLabel=*/false);
8714 }
8715 return Result;
8716 };
8717
8718 // Go through the outputs.
8719 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8720 Names.push_back(S->getOutputIdentifier(I));
8721
8722 ExprResult Result = RebuildString(S->getOutputConstraintExpr(I));
8723 if (Result.isInvalid())
8724 return StmtError();
8725
8726 Constraints.push_back(Result.get());
8727
8728 // Transform the output expr.
8729 Expr *OutputExpr = S->getOutputExpr(I);
8730 Result = getDerived().TransformExpr(OutputExpr);
8731 if (Result.isInvalid())
8732 return StmtError();
8733
8734 ExprsChanged |= Result.get() != OutputExpr;
8735
8736 Exprs.push_back(Result.get());
8737 }
8738
8739 // Go through the inputs.
8740 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8741 Names.push_back(S->getInputIdentifier(I));
8742
8743 ExprResult Result = RebuildString(S->getInputConstraintExpr(I));
8744 if (Result.isInvalid())
8745 return StmtError();
8746
8747 Constraints.push_back(Result.get());
8748
8749 // Transform the input expr.
8750 Expr *InputExpr = S->getInputExpr(I);
8751 Result = getDerived().TransformExpr(InputExpr);
8752 if (Result.isInvalid())
8753 return StmtError();
8754
8755 ExprsChanged |= Result.get() != InputExpr;
8756
8757 Exprs.push_back(Result.get());
8758 }
8759
8760 // Go through the Labels.
8761 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8762 Names.push_back(S->getLabelIdentifier(I));
8763
8764 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8765 if (Result.isInvalid())
8766 return StmtError();
8767 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8768 Exprs.push_back(Result.get());
8769 }
8770
8771 // Go through the clobbers.
8772 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) {
8773 ExprResult Result = RebuildString(S->getClobberExpr(I));
8774 if (Result.isInvalid())
8775 return StmtError();
8776 Clobbers.push_back(Result.get());
8777 }
8778
8779 ExprResult AsmString = RebuildString(S->getAsmStringExpr());
8780 if (AsmString.isInvalid())
8781 return StmtError();
8782
8783 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8784 return S;
8785
8786 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8787 S->isVolatile(), S->getNumOutputs(),
8788 S->getNumInputs(), Names.data(),
8789 Constraints, Exprs, AsmString.get(),
8790 Clobbers, S->getNumLabels(),
8791 S->getRParenLoc());
8792}
8793
8794template<typename Derived>
8797 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8798
8799 bool HadError = false, HadChange = false;
8800
8801 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8802 SmallVector<Expr*, 8> TransformedExprs;
8803 TransformedExprs.reserve(SrcExprs.size());
8804 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8805 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8806 if (!Result.isUsable()) {
8807 HadError = true;
8808 } else {
8809 HadChange |= (Result.get() != SrcExprs[i]);
8810 TransformedExprs.push_back(Result.get());
8811 }
8812 }
8813
8814 if (HadError) return StmtError();
8815 if (!HadChange && !getDerived().AlwaysRebuild())
8816 return Owned(S);
8817
8818 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8819 AsmToks, S->getAsmString(),
8820 S->getNumOutputs(), S->getNumInputs(),
8821 S->getAllConstraints(), S->getClobbers(),
8822 TransformedExprs, S->getEndLoc());
8823}
8824
8825// C++ Coroutines
8826template<typename Derived>
8829 auto *ScopeInfo = SemaRef.getCurFunction();
8830 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8831 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8832 ScopeInfo->NeedsCoroutineSuspends &&
8833 ScopeInfo->CoroutineSuspends.first == nullptr &&
8834 ScopeInfo->CoroutineSuspends.second == nullptr &&
8835 "expected clean scope info");
8836
8837 // Set that we have (possibly-invalid) suspend points before we do anything
8838 // that may fail.
8839 ScopeInfo->setNeedsCoroutineSuspends(false);
8840
8841 // We re-build the coroutine promise object (and the coroutine parameters its
8842 // type and constructor depend on) based on the types used in our current
8843 // function. We must do so, and set it on the current FunctionScopeInfo,
8844 // before attempting to transform the other parts of the coroutine body
8845 // statement, such as the implicit suspend statements (because those
8846 // statements reference the FunctionScopeInfo::CoroutinePromise).
8847 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8848 return StmtError();
8849 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8850 if (!Promise)
8851 return StmtError();
8852 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8853 ScopeInfo->CoroutinePromise = Promise;
8854
8855 // Transform the implicit coroutine statements constructed using dependent
8856 // types during the previous parse: initial and final suspensions, the return
8857 // object, and others. We also transform the coroutine function's body.
8858 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8859 if (InitSuspend.isInvalid())
8860 return StmtError();
8861 StmtResult FinalSuspend =
8862 getDerived().TransformStmt(S->getFinalSuspendStmt());
8863 if (FinalSuspend.isInvalid() ||
8864 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8865 return StmtError();
8866 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8867 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8868
8869 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8870 if (BodyRes.isInvalid())
8871 return StmtError();
8872
8873 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8874 if (Builder.isInvalid())
8875 return StmtError();
8876
8877 Expr *ReturnObject = S->getReturnValueInit();
8878 assert(ReturnObject && "the return object is expected to be valid");
8879 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8880 /*NoCopyInit*/ false);
8881 if (Res.isInvalid())
8882 return StmtError();
8883 Builder.ReturnValue = Res.get();
8884
8885 // If during the previous parse the coroutine still had a dependent promise
8886 // statement, we may need to build some implicit coroutine statements
8887 // (such as exception and fallthrough handlers) for the first time.
8888 if (S->hasDependentPromiseType()) {
8889 // We can only build these statements, however, if the current promise type
8890 // is not dependent.
8891 if (!Promise->getType()->isDependentType()) {
8892 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8893 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8894 "these nodes should not have been built yet");
8895 if (!Builder.buildDependentStatements())
8896 return StmtError();
8897 }
8898 } else {
8899 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8900 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8901 if (Res.isInvalid())
8902 return StmtError();
8903 Builder.OnFallthrough = Res.get();
8904 }
8905
8906 if (auto *OnException = S->getExceptionHandler()) {
8907 StmtResult Res = getDerived().TransformStmt(OnException);
8908 if (Res.isInvalid())
8909 return StmtError();
8910 Builder.OnException = Res.get();
8911 }
8912
8913 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8914 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8915 if (Res.isInvalid())
8916 return StmtError();
8917 Builder.ReturnStmtOnAllocFailure = Res.get();
8918 }
8919
8920 // Transform any additional statements we may have already built
8921 assert(S->getAllocate() && S->getDeallocate() &&
8922 "allocation and deallocation calls must already be built");
8923 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8924 if (AllocRes.isInvalid())
8925 return StmtError();
8926 Builder.Allocate = AllocRes.get();
8927
8928 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8929 if (DeallocRes.isInvalid())
8930 return StmtError();
8931 Builder.Deallocate = DeallocRes.get();
8932
8933 if (auto *ResultDecl = S->getResultDecl()) {
8934 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8935 if (Res.isInvalid())
8936 return StmtError();
8937 Builder.ResultDecl = Res.get();
8938 }
8939
8940 if (auto *ReturnStmt = S->getReturnStmt()) {
8941 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8942 if (Res.isInvalid())
8943 return StmtError();
8944 Builder.ReturnStmt = Res.get();
8945 }
8946 }
8947
8948 return getDerived().RebuildCoroutineBodyStmt(Builder);
8949}
8950
8951template<typename Derived>
8954 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8955 /*NotCopyInit*/false);
8956 if (Result.isInvalid())
8957 return StmtError();
8958
8959 // Always rebuild; we don't know if this needs to be injected into a new
8960 // context or if the promise type has changed.
8961 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8962 S->isImplicit());
8963}
8964
8965template <typename Derived>
8967 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8968 /*NotCopyInit*/ false);
8969 if (Operand.isInvalid())
8970 return ExprError();
8971
8972 // Rebuild the common-expr from the operand rather than transforming it
8973 // separately.
8974
8975 // FIXME: getCurScope() should not be used during template instantiation.
8976 // We should pick up the set of unqualified lookup results for operator
8977 // co_await during the initial parse.
8978 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8979 getSema().getCurScope(), E->getKeywordLoc());
8980
8981 // Always rebuild; we don't know if this needs to be injected into a new
8982 // context or if the promise type has changed.
8983 return getDerived().RebuildCoawaitExpr(
8984 E->getKeywordLoc(), Operand.get(),
8985 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8986}
8987
8988template <typename Derived>
8991 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8992 /*NotCopyInit*/ false);
8993 if (OperandResult.isInvalid())
8994 return ExprError();
8995
8996 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8997 E->getOperatorCoawaitLookup());
8998
8999 if (LookupResult.isInvalid())
9000 return ExprError();
9001
9002 // Always rebuild; we don't know if this needs to be injected into a new
9003 // context or if the promise type has changed.
9004 return getDerived().RebuildDependentCoawaitExpr(
9005 E->getKeywordLoc(), OperandResult.get(),
9007}
9008
9009template<typename Derived>
9012 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
9013 /*NotCopyInit*/false);
9014 if (Result.isInvalid())
9015 return ExprError();
9016
9017 // Always rebuild; we don't know if this needs to be injected into a new
9018 // context or if the promise type has changed.
9019 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
9020}
9021
9022// Objective-C Statements.
9023
9024template<typename Derived>
9027 // Transform the body of the @try.
9028 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
9029 if (TryBody.isInvalid())
9030 return StmtError();
9031
9032 // Transform the @catch statements (if present).
9033 bool AnyCatchChanged = false;
9034 SmallVector<Stmt*, 8> CatchStmts;
9035 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
9036 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
9037 if (Catch.isInvalid())
9038 return StmtError();
9039 if (Catch.get() != S->getCatchStmt(I))
9040 AnyCatchChanged = true;
9041 CatchStmts.push_back(Catch.get());
9042 }
9043
9044 // Transform the @finally statement (if present).
9045 StmtResult Finally;
9046 if (S->getFinallyStmt()) {
9047 Finally = getDerived().TransformStmt(S->getFinallyStmt());
9048 if (Finally.isInvalid())
9049 return StmtError();
9050 }
9051
9052 // If nothing changed, just retain this statement.
9053 if (!getDerived().AlwaysRebuild() &&
9054 TryBody.get() == S->getTryBody() &&
9055 !AnyCatchChanged &&
9056 Finally.get() == S->getFinallyStmt())
9057 return S;
9058
9059 // Build a new statement.
9060 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
9061 CatchStmts, Finally.get());
9062}
9063
9064template<typename Derived>
9067 // Transform the @catch parameter, if there is one.
9068 VarDecl *Var = nullptr;
9069 if (VarDecl *FromVar = S->getCatchParamDecl()) {
9070 TypeSourceInfo *TSInfo = nullptr;
9071 if (FromVar->getTypeSourceInfo()) {
9072 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
9073 if (!TSInfo)
9074 return StmtError();
9075 }
9076
9077 QualType T;
9078 if (TSInfo)
9079 T = TSInfo->getType();
9080 else {
9081 T = getDerived().TransformType(FromVar->getType());
9082 if (T.isNull())
9083 return StmtError();
9084 }
9085
9086 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
9087 if (!Var)
9088 return StmtError();
9089 }
9090
9091 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
9092 if (Body.isInvalid())
9093 return StmtError();
9094
9095 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
9096 S->getRParenLoc(),
9097 Var, Body.get());
9098}
9099
9100template<typename Derived>
9103 // Transform the body.
9104 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
9105 if (Body.isInvalid())
9106 return StmtError();
9107
9108 // If nothing changed, just retain this statement.
9109 if (!getDerived().AlwaysRebuild() &&
9110 Body.get() == S->getFinallyBody())
9111 return S;
9112
9113 // Build a new statement.
9114 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
9115 Body.get());
9116}
9117
9118template<typename Derived>
9122 if (S->getThrowExpr()) {
9123 Operand = getDerived().TransformExpr(S->getThrowExpr());
9124 if (Operand.isInvalid())
9125 return StmtError();
9126 }
9127
9128 if (!getDerived().AlwaysRebuild() &&
9129 Operand.get() == S->getThrowExpr())
9130 return S;
9131
9132 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
9133}
9134
9135template<typename Derived>
9139 // Transform the object we are locking.
9140 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
9141 if (Object.isInvalid())
9142 return StmtError();
9143 Object =
9144 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
9145 Object.get());
9146 if (Object.isInvalid())
9147 return StmtError();
9148
9149 // Transform the body.
9150 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
9151 if (Body.isInvalid())
9152 return StmtError();
9153
9154 // If nothing change, just retain the current statement.
9155 if (!getDerived().AlwaysRebuild() &&
9156 Object.get() == S->getSynchExpr() &&
9157 Body.get() == S->getSynchBody())
9158 return S;
9159
9160 // Build a new statement.
9161 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
9162 Object.get(), Body.get());
9163}
9164
9165template<typename Derived>
9169 // Transform the body.
9170 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
9171 if (Body.isInvalid())
9172 return StmtError();
9173
9174 // If nothing changed, just retain this statement.
9175 if (!getDerived().AlwaysRebuild() &&
9176 Body.get() == S->getSubStmt())
9177 return S;
9178
9179 // Build a new statement.
9180 return getDerived().RebuildObjCAutoreleasePoolStmt(
9181 S->getAtLoc(), Body.get());
9182}
9183
9184template<typename Derived>
9188 // Transform the element statement.
9189 StmtResult Element = getDerived().TransformStmt(
9190 S->getElement(), StmtDiscardKind::NotDiscarded);
9191 if (Element.isInvalid())
9192 return StmtError();
9193
9194 // Transform the collection expression.
9195 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9196 if (Collection.isInvalid())
9197 return StmtError();
9198
9199 // Transform the body.
9200 StmtResult Body = getDerived().TransformStmt(S->getBody());
9201 if (Body.isInvalid())
9202 return StmtError();
9203
9204 // If nothing changed, just retain this statement.
9205 if (!getDerived().AlwaysRebuild() &&
9206 Element.get() == S->getElement() &&
9207 Collection.get() == S->getCollection() &&
9208 Body.get() == S->getBody())
9209 return S;
9210
9211 // Build a new statement.
9212 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9213 Element.get(),
9214 Collection.get(),
9215 S->getRParenLoc(),
9216 Body.get());
9217}
9218
9219template <typename Derived>
9221 // Transform the exception declaration, if any.
9222 VarDecl *Var = nullptr;
9223 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9224 TypeSourceInfo *T =
9225 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9226 if (!T)
9227 return StmtError();
9228
9229 Var = getDerived().RebuildExceptionDecl(
9230 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9231 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9232 if (!Var || Var->isInvalidDecl())
9233 return StmtError();
9234 }
9235
9236 // Transform the actual exception handler.
9237 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9238 if (Handler.isInvalid())
9239 return StmtError();
9240
9241 if (!getDerived().AlwaysRebuild() && !Var &&
9242 Handler.get() == S->getHandlerBlock())
9243 return S;
9244
9245 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9246}
9247
9248template <typename Derived>
9250 // Transform the try block itself.
9251 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9252 if (TryBlock.isInvalid())
9253 return StmtError();
9254
9255 // Transform the handlers.
9256 bool HandlerChanged = false;
9257 SmallVector<Stmt *, 8> Handlers;
9258 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9259 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9260 if (Handler.isInvalid())
9261 return StmtError();
9262
9263 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9264 Handlers.push_back(Handler.getAs<Stmt>());
9265 }
9266
9267 getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
9268
9269 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9270 !HandlerChanged)
9271 return S;
9272
9273 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9274 Handlers);
9275}
9276
9277template<typename Derived>
9280 EnterExpressionEvaluationContext ForRangeInitContext(
9282 /*LambdaContextDecl=*/nullptr,
9284 getSema().getLangOpts().CPlusPlus23);
9285
9286 // P2718R0 - Lifetime extension in range-based for loops.
9287 if (getSema().getLangOpts().CPlusPlus23) {
9288 auto &LastRecord = getSema().currentEvaluationContext();
9289 LastRecord.InLifetimeExtendingContext = true;
9290 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9291 }
9293 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9294 if (Init.isInvalid())
9295 return StmtError();
9296
9297 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9298 if (Range.isInvalid())
9299 return StmtError();
9300
9301 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9302 assert(getSema().getLangOpts().CPlusPlus23 ||
9303 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9304 auto ForRangeLifetimeExtendTemps =
9305 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9306
9307 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9308 if (Begin.isInvalid())
9309 return StmtError();
9310 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9311 if (End.isInvalid())
9312 return StmtError();
9313
9314 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9315 if (Cond.isInvalid())
9316 return StmtError();
9317 if (Cond.get())
9318 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9319 if (Cond.isInvalid())
9320 return StmtError();
9321 if (Cond.get())
9322 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9323
9324 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9325 if (Inc.isInvalid())
9326 return StmtError();
9327 if (Inc.get())
9328 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9329
9330 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9331 if (LoopVar.isInvalid())
9332 return StmtError();
9333
9334 StmtResult NewStmt = S;
9335 if (getDerived().AlwaysRebuild() ||
9336 Init.get() != S->getInit() ||
9337 Range.get() != S->getRangeStmt() ||
9338 Begin.get() != S->getBeginStmt() ||
9339 End.get() != S->getEndStmt() ||
9340 Cond.get() != S->getCond() ||
9341 Inc.get() != S->getInc() ||
9342 LoopVar.get() != S->getLoopVarStmt()) {
9343 NewStmt = getDerived().RebuildCXXForRangeStmt(
9344 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9345 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9346 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9347 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9348 // Might not have attached any initializer to the loop variable.
9349 getSema().ActOnInitializerError(
9350 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9351 return StmtError();
9352 }
9353 }
9354
9355 // OpenACC Restricts a while-loop inside of certain construct/clause
9356 // combinations, so diagnose that here in OpenACC mode.
9358 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9359
9360 StmtResult Body = getDerived().TransformStmt(S->getBody());
9361 if (Body.isInvalid())
9362 return StmtError();
9363
9364 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9365
9366 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9367 // it now so we have a new statement to attach the body to.
9368 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9369 NewStmt = getDerived().RebuildCXXForRangeStmt(
9370 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9371 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9372 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9373 if (NewStmt.isInvalid())
9374 return StmtError();
9375 }
9376
9377 if (NewStmt.get() == S)
9378 return S;
9379
9380 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9381}
9382
9383template<typename Derived>
9387 // Transform the nested-name-specifier, if any.
9388 NestedNameSpecifierLoc QualifierLoc;
9389 if (S->getQualifierLoc()) {
9390 QualifierLoc
9391 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9392 if (!QualifierLoc)
9393 return StmtError();
9394 }
9395
9396 // Transform the declaration name.
9397 DeclarationNameInfo NameInfo = S->getNameInfo();
9398 if (NameInfo.getName()) {
9399 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9400 if (!NameInfo.getName())
9401 return StmtError();
9402 }
9403
9404 // Check whether anything changed.
9405 if (!getDerived().AlwaysRebuild() &&
9406 QualifierLoc == S->getQualifierLoc() &&
9407 NameInfo.getName() == S->getNameInfo().getName())
9408 return S;
9409
9410 // Determine whether this name exists, if we can.
9411 CXXScopeSpec SS;
9412 SS.Adopt(QualifierLoc);
9413 bool Dependent = false;
9414 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9416 if (S->isIfExists())
9417 break;
9418
9419 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9420
9422 if (S->isIfNotExists())
9423 break;
9424
9425 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9426
9428 Dependent = true;
9429 break;
9430
9432 return StmtError();
9433 }
9434
9435 // We need to continue with the instantiation, so do so now.
9436 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9437 if (SubStmt.isInvalid())
9438 return StmtError();
9439
9440 // If we have resolved the name, just transform to the substatement.
9441 if (!Dependent)
9442 return SubStmt;
9443
9444 // The name is still dependent, so build a dependent expression again.
9445 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9446 S->isIfExists(),
9447 QualifierLoc,
9448 NameInfo,
9449 SubStmt.get());
9450}
9451
9452template<typename Derived>
9455 NestedNameSpecifierLoc QualifierLoc;
9456 if (E->getQualifierLoc()) {
9457 QualifierLoc
9458 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9459 if (!QualifierLoc)
9460 return ExprError();
9461 }
9462
9463 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9464 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9465 if (!PD)
9466 return ExprError();
9467
9468 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9469 if (Base.isInvalid())
9470 return ExprError();
9471
9472 return new (SemaRef.getASTContext())
9473 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9475 QualifierLoc, E->getMemberLoc());
9476}
9477
9478template <typename Derived>
9481 auto BaseRes = getDerived().TransformExpr(E->getBase());
9482 if (BaseRes.isInvalid())
9483 return ExprError();
9484 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9485 if (IdxRes.isInvalid())
9486 return ExprError();
9487
9488 if (!getDerived().AlwaysRebuild() &&
9489 BaseRes.get() == E->getBase() &&
9490 IdxRes.get() == E->getIdx())
9491 return E;
9492
9493 return getDerived().RebuildArraySubscriptExpr(
9494 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9495}
9496
9497template <typename Derived>
9499 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9500 if (TryBlock.isInvalid())
9501 return StmtError();
9502
9503 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9504 if (Handler.isInvalid())
9505 return StmtError();
9506
9507 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9508 Handler.get() == S->getHandler())
9509 return S;
9510
9511 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9512 TryBlock.get(), Handler.get());
9513}
9514
9515template <typename Derived>
9517 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9518 if (Block.isInvalid())
9519 return StmtError();
9520
9521 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9522}
9523
9524template <typename Derived>
9526 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9527 if (FilterExpr.isInvalid())
9528 return StmtError();
9529
9530 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9531 if (Block.isInvalid())
9532 return StmtError();
9533
9534 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9535 Block.get());
9536}
9537
9538template <typename Derived>
9540 if (isa<SEHFinallyStmt>(Handler))
9541 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9542 else
9543 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9544}
9545
9546template<typename Derived>
9549 return S;
9550}
9551
9552//===----------------------------------------------------------------------===//
9553// OpenMP directive transformation
9554//===----------------------------------------------------------------------===//
9555
9556template <typename Derived>
9557StmtResult
9558TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9559 // OMPCanonicalLoops are eliminated during transformation, since they will be
9560 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9561 // after transformation.
9562 return getDerived().TransformStmt(L->getLoopStmt());
9563}
9564
9565template <typename Derived>
9568
9569 // Transform the clauses
9571 ArrayRef<OMPClause *> Clauses = D->clauses();
9572 TClauses.reserve(Clauses.size());
9573 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9574 I != E; ++I) {
9575 if (*I) {
9576 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9577 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9578 getDerived().getSema().OpenMP().EndOpenMPClause();
9579 if (Clause)
9580 TClauses.push_back(Clause);
9581 } else {
9582 TClauses.push_back(nullptr);
9583 }
9584 }
9585 StmtResult AssociatedStmt;
9586 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9587 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9588 D->getDirectiveKind(),
9589 /*CurScope=*/nullptr);
9590 StmtResult Body;
9591 {
9592 Sema::CompoundScopeRAII CompoundScope(getSema());
9593 Stmt *CS;
9594 if (D->getDirectiveKind() == OMPD_atomic ||
9595 D->getDirectiveKind() == OMPD_critical ||
9596 D->getDirectiveKind() == OMPD_section ||
9597 D->getDirectiveKind() == OMPD_master)
9598 CS = D->getAssociatedStmt();
9599 else
9600 CS = D->getRawStmt();
9601 Body = getDerived().TransformStmt(CS);
9602 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9603 getSema().getLangOpts().OpenMPIRBuilder)
9604 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9605 }
9606 AssociatedStmt =
9607 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9608 if (AssociatedStmt.isInvalid()) {
9609 return StmtError();
9610 }
9611 }
9612 if (TClauses.size() != Clauses.size()) {
9613 return StmtError();
9614 }
9615
9616 // Transform directive name for 'omp critical' directive.
9617 DeclarationNameInfo DirName;
9618 if (D->getDirectiveKind() == OMPD_critical) {
9619 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9620 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9621 }
9622 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9623 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9624 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9625 } else if (D->getDirectiveKind() == OMPD_cancel) {
9626 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9627 }
9628
9629 return getDerived().RebuildOMPExecutableDirective(
9630 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9631 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
9632}
9633
9634/// This is mostly the same as above, but allows 'informational' class
9635/// directives when rebuilding the stmt. It still takes an
9636/// OMPExecutableDirective-type argument because we're reusing that as the
9637/// superclass for the 'assume' directive at present, instead of defining a
9638/// mostly-identical OMPInformationalDirective parent class.
9639template <typename Derived>
9642
9643 // Transform the clauses
9645 ArrayRef<OMPClause *> Clauses = D->clauses();
9646 TClauses.reserve(Clauses.size());
9647 for (OMPClause *C : Clauses) {
9648 if (C) {
9649 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
9650 OMPClause *Clause = getDerived().TransformOMPClause(C);
9651 getDerived().getSema().OpenMP().EndOpenMPClause();
9652 if (Clause)
9653 TClauses.push_back(Clause);
9654 } else {
9655 TClauses.push_back(nullptr);
9656 }
9657 }
9658 StmtResult AssociatedStmt;
9659 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9660 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9661 D->getDirectiveKind(),
9662 /*CurScope=*/nullptr);
9663 StmtResult Body;
9664 {
9665 Sema::CompoundScopeRAII CompoundScope(getSema());
9666 assert(D->getDirectiveKind() == OMPD_assume &&
9667 "Unexpected informational directive");
9668 Stmt *CS = D->getAssociatedStmt();
9669 Body = getDerived().TransformStmt(CS);
9670 }
9671 AssociatedStmt =
9672 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9673 if (AssociatedStmt.isInvalid())
9674 return StmtError();
9675 }
9676 if (TClauses.size() != Clauses.size())
9677 return StmtError();
9678
9679 DeclarationNameInfo DirName;
9680
9681 return getDerived().RebuildOMPInformationalDirective(
9682 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
9683 D->getBeginLoc(), D->getEndLoc());
9684}
9685
9686template <typename Derived>
9689 // TODO: Fix This
9690 unsigned OMPVersion = getDerived().getSema().getLangOpts().OpenMP;
9691 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9692 << getOpenMPDirectiveName(D->getDirectiveKind(), OMPVersion);
9693 return StmtError();
9694}
9695
9696template <typename Derived>
9697StmtResult
9698TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9699 DeclarationNameInfo DirName;
9700 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9701 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
9702 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9703 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9704 return Res;
9705}
9706
9707template <typename Derived>
9710 DeclarationNameInfo DirName;
9711 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9712 OMPD_simd, DirName, nullptr, D->getBeginLoc());
9713 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9714 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9715 return Res;
9716}
9717
9718template <typename Derived>
9721 DeclarationNameInfo DirName;
9722 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9723 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9724 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9725 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9726 return Res;
9727}
9728
9729template <typename Derived>
9732 DeclarationNameInfo DirName;
9733 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9734 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9735 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9736 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9737 return Res;
9738}
9739
9740template <typename Derived>
9743 DeclarationNameInfo DirName;
9744 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9745 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9746 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9747 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9748 return Res;
9749}
9750
9751template <typename Derived>
9754 DeclarationNameInfo DirName;
9755 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9756 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9757 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9758 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9759 return Res;
9760}
9761
9762template <typename Derived>
9764 OMPInterchangeDirective *D) {
9765 DeclarationNameInfo DirName;
9766 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9767 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9768 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9769 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9770 return Res;
9771}
9772
9773template <typename Derived>
9776 DeclarationNameInfo DirName;
9777 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9778 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9779 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9780 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9781 return Res;
9782}
9783
9784template <typename Derived>
9787 DeclarationNameInfo DirName;
9788 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9789 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9790 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9791 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9792 return Res;
9793}
9794
9795template <typename Derived>
9798 DeclarationNameInfo DirName;
9799 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9800 OMPD_for, DirName, nullptr, D->getBeginLoc());
9801 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9802 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9803 return Res;
9804}
9805
9806template <typename Derived>
9809 DeclarationNameInfo DirName;
9810 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9811 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
9812 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9813 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9814 return Res;
9815}
9816
9817template <typename Derived>
9820 DeclarationNameInfo DirName;
9821 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9822 OMPD_sections, DirName, nullptr, D->getBeginLoc());
9823 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9824 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9825 return Res;
9826}
9827
9828template <typename Derived>
9831 DeclarationNameInfo DirName;
9832 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9833 OMPD_section, DirName, nullptr, D->getBeginLoc());
9834 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9835 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9836 return Res;
9837}
9838
9839template <typename Derived>
9842 DeclarationNameInfo DirName;
9843 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9844 OMPD_scope, DirName, nullptr, D->getBeginLoc());
9845 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9846 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9847 return Res;
9848}
9849
9850template <typename Derived>
9853 DeclarationNameInfo DirName;
9854 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9855 OMPD_single, DirName, nullptr, D->getBeginLoc());
9856 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9857 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9858 return Res;
9859}
9860
9861template <typename Derived>
9864 DeclarationNameInfo DirName;
9865 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9866 OMPD_master, DirName, nullptr, D->getBeginLoc());
9867 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9868 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9869 return Res;
9870}
9871
9872template <typename Derived>
9875 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9876 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
9877 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9878 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9879 return Res;
9880}
9881
9882template <typename Derived>
9884 OMPParallelForDirective *D) {
9885 DeclarationNameInfo DirName;
9886 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9887 OMPD_parallel_for, DirName, nullptr, D->getBeginLoc());
9888 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9889 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9890 return Res;
9891}
9892
9893template <typename Derived>
9895 OMPParallelForSimdDirective *D) {
9896 DeclarationNameInfo DirName;
9897 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9898 OMPD_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9899 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9900 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9901 return Res;
9902}
9903
9904template <typename Derived>
9906 OMPParallelMasterDirective *D) {
9907 DeclarationNameInfo DirName;
9908 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9909 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
9910 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9911 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9912 return Res;
9913}
9914
9915template <typename Derived>
9917 OMPParallelMaskedDirective *D) {
9918 DeclarationNameInfo DirName;
9919 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9920 OMPD_parallel_masked, DirName, nullptr, D->getBeginLoc());
9921 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9922 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9923 return Res;
9924}
9925
9926template <typename Derived>
9928 OMPParallelSectionsDirective *D) {
9929 DeclarationNameInfo DirName;
9930 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9931 OMPD_parallel_sections, DirName, nullptr, D->getBeginLoc());
9932 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9933 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9934 return Res;
9935}
9936
9937template <typename Derived>
9940 DeclarationNameInfo DirName;
9941 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9942 OMPD_task, DirName, nullptr, D->getBeginLoc());
9943 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9944 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9945 return Res;
9946}
9947
9948template <typename Derived>
9950 OMPTaskyieldDirective *D) {
9951 DeclarationNameInfo DirName;
9952 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9953 OMPD_taskyield, DirName, nullptr, D->getBeginLoc());
9954 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9955 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9956 return Res;
9957}
9958
9959template <typename Derived>
9962 DeclarationNameInfo DirName;
9963 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9964 OMPD_barrier, DirName, nullptr, D->getBeginLoc());
9965 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9966 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9967 return Res;
9968}
9969
9970template <typename Derived>
9973 DeclarationNameInfo DirName;
9974 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9975 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
9976 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9977 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9978 return Res;
9979}
9980
9981template <typename Derived>
9984 DeclarationNameInfo DirName;
9985 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9986 OMPD_assume, DirName, nullptr, D->getBeginLoc());
9987 StmtResult Res = getDerived().TransformOMPInformationalDirective(D);
9988 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9989 return Res;
9990}
9991
9992template <typename Derived>
9995 DeclarationNameInfo DirName;
9996 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9997 OMPD_error, DirName, nullptr, D->getBeginLoc());
9998 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9999 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10000 return Res;
10001}
10002
10003template <typename Derived>
10005 OMPTaskgroupDirective *D) {
10006 DeclarationNameInfo DirName;
10007 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10008 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
10009 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10010 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10011 return Res;
10012}
10013
10014template <typename Derived>
10017 DeclarationNameInfo DirName;
10018 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10019 OMPD_flush, DirName, nullptr, D->getBeginLoc());
10020 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10021 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10022 return Res;
10023}
10024
10025template <typename Derived>
10028 DeclarationNameInfo DirName;
10029 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10030 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
10031 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10032 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10033 return Res;
10034}
10035
10036template <typename Derived>
10039 DeclarationNameInfo DirName;
10040 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10041 OMPD_scan, DirName, nullptr, D->getBeginLoc());
10042 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10043 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10044 return Res;
10045}
10046
10047template <typename Derived>
10050 DeclarationNameInfo DirName;
10051 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10052 OMPD_ordered, DirName, nullptr, D->getBeginLoc());
10053 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10054 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10055 return Res;
10056}
10057
10058template <typename Derived>
10061 DeclarationNameInfo DirName;
10062 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10063 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
10064 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10065 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10066 return Res;
10067}
10068
10069template <typename Derived>
10072 DeclarationNameInfo DirName;
10073 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10074 OMPD_target, DirName, nullptr, D->getBeginLoc());
10075 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10076 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10077 return Res;
10078}
10079
10080template <typename Derived>
10082 OMPTargetDataDirective *D) {
10083 DeclarationNameInfo DirName;
10084 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10085 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
10086 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10087 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10088 return Res;
10089}
10090
10091template <typename Derived>
10093 OMPTargetEnterDataDirective *D) {
10094 DeclarationNameInfo DirName;
10095 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10096 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
10097 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10098 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10099 return Res;
10100}
10101
10102template <typename Derived>
10104 OMPTargetExitDataDirective *D) {
10105 DeclarationNameInfo DirName;
10106 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10107 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
10108 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10109 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10110 return Res;
10111}
10112
10113template <typename Derived>
10115 OMPTargetParallelDirective *D) {
10116 DeclarationNameInfo DirName;
10117 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10118 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
10119 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10120 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10121 return Res;
10122}
10123
10124template <typename Derived>
10126 OMPTargetParallelForDirective *D) {
10127 DeclarationNameInfo DirName;
10128 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10129 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
10130 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10131 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10132 return Res;
10133}
10134
10135template <typename Derived>
10137 OMPTargetUpdateDirective *D) {
10138 DeclarationNameInfo DirName;
10139 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10140 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
10141 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10142 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10143 return Res;
10144}
10145
10146template <typename Derived>
10149 DeclarationNameInfo DirName;
10150 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10151 OMPD_teams, DirName, nullptr, D->getBeginLoc());
10152 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10153 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10154 return Res;
10155}
10156
10157template <typename Derived>
10159 OMPCancellationPointDirective *D) {
10160 DeclarationNameInfo DirName;
10161 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10162 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
10163 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10164 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10165 return Res;
10166}
10167
10168template <typename Derived>
10171 DeclarationNameInfo DirName;
10172 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10173 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
10174 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10175 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10176 return Res;
10177}
10178
10179template <typename Derived>
10182 DeclarationNameInfo DirName;
10183 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10184 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
10185 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10186 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10187 return Res;
10188}
10189
10190template <typename Derived>
10192 OMPTaskLoopSimdDirective *D) {
10193 DeclarationNameInfo DirName;
10194 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10195 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10196 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10197 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10198 return Res;
10199}
10200
10201template <typename Derived>
10203 OMPMasterTaskLoopDirective *D) {
10204 DeclarationNameInfo DirName;
10205 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10206 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
10207 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10208 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10209 return Res;
10210}
10211
10212template <typename Derived>
10214 OMPMaskedTaskLoopDirective *D) {
10215 DeclarationNameInfo DirName;
10216 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10217 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10218 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10219 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10220 return Res;
10221}
10222
10223template <typename Derived>
10225 OMPMasterTaskLoopSimdDirective *D) {
10226 DeclarationNameInfo DirName;
10227 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10228 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10229 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10230 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10231 return Res;
10232}
10233
10234template <typename Derived>
10236 OMPMaskedTaskLoopSimdDirective *D) {
10237 DeclarationNameInfo DirName;
10238 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10239 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10240 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10241 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10242 return Res;
10243}
10244
10245template <typename Derived>
10247 OMPParallelMasterTaskLoopDirective *D) {
10248 DeclarationNameInfo DirName;
10249 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10250 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10251 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10252 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10253 return Res;
10254}
10255
10256template <typename Derived>
10258 OMPParallelMaskedTaskLoopDirective *D) {
10259 DeclarationNameInfo DirName;
10260 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10261 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10262 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10263 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10264 return Res;
10265}
10266
10267template <typename Derived>
10270 OMPParallelMasterTaskLoopSimdDirective *D) {
10271 DeclarationNameInfo DirName;
10272 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10273 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10274 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10275 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10276 return Res;
10277}
10278
10279template <typename Derived>
10282 OMPParallelMaskedTaskLoopSimdDirective *D) {
10283 DeclarationNameInfo DirName;
10284 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10285 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10286 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10287 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10288 return Res;
10289}
10290
10291template <typename Derived>
10293 OMPDistributeDirective *D) {
10294 DeclarationNameInfo DirName;
10295 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10296 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10297 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10298 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10299 return Res;
10300}
10301
10302template <typename Derived>
10304 OMPDistributeParallelForDirective *D) {
10305 DeclarationNameInfo DirName;
10306 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10307 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10308 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10309 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10310 return Res;
10311}
10312
10313template <typename Derived>
10316 OMPDistributeParallelForSimdDirective *D) {
10317 DeclarationNameInfo DirName;
10318 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10319 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10320 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10321 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10322 return Res;
10323}
10324
10325template <typename Derived>
10327 OMPDistributeSimdDirective *D) {
10328 DeclarationNameInfo DirName;
10329 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10330 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
10331 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10332 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10333 return Res;
10334}
10335
10336template <typename Derived>
10338 OMPTargetParallelForSimdDirective *D) {
10339 DeclarationNameInfo DirName;
10340 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10341 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10342 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10343 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10344 return Res;
10345}
10346
10347template <typename Derived>
10349 OMPTargetSimdDirective *D) {
10350 DeclarationNameInfo DirName;
10351 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10352 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
10353 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10354 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10355 return Res;
10356}
10357
10358template <typename Derived>
10360 OMPTeamsDistributeDirective *D) {
10361 DeclarationNameInfo DirName;
10362 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10363 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10364 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10365 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10366 return Res;
10367}
10368
10369template <typename Derived>
10371 OMPTeamsDistributeSimdDirective *D) {
10372 DeclarationNameInfo DirName;
10373 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10374 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10375 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10376 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10377 return Res;
10378}
10379
10380template <typename Derived>
10382 OMPTeamsDistributeParallelForSimdDirective *D) {
10383 DeclarationNameInfo DirName;
10384 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10385 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10386 D->getBeginLoc());
10387 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10388 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10389 return Res;
10390}
10391
10392template <typename Derived>
10394 OMPTeamsDistributeParallelForDirective *D) {
10395 DeclarationNameInfo DirName;
10396 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10397 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10398 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10399 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10400 return Res;
10401}
10402
10403template <typename Derived>
10405 OMPTargetTeamsDirective *D) {
10406 DeclarationNameInfo DirName;
10407 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10408 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10409 auto Res = getDerived().TransformOMPExecutableDirective(D);
10410 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10411 return Res;
10412}
10413
10414template <typename Derived>
10416 OMPTargetTeamsDistributeDirective *D) {
10417 DeclarationNameInfo DirName;
10418 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10419 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10420 auto Res = getDerived().TransformOMPExecutableDirective(D);
10421 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10422 return Res;
10423}
10424
10425template <typename Derived>
10428 OMPTargetTeamsDistributeParallelForDirective *D) {
10429 DeclarationNameInfo DirName;
10430 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10431 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10432 D->getBeginLoc());
10433 auto Res = getDerived().TransformOMPExecutableDirective(D);
10434 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10435 return Res;
10436}
10437
10438template <typename Derived>
10441 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10442 DeclarationNameInfo DirName;
10443 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10444 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10445 D->getBeginLoc());
10446 auto Res = getDerived().TransformOMPExecutableDirective(D);
10447 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10448 return Res;
10449}
10450
10451template <typename Derived>
10454 OMPTargetTeamsDistributeSimdDirective *D) {
10455 DeclarationNameInfo DirName;
10456 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10457 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10458 auto Res = getDerived().TransformOMPExecutableDirective(D);
10459 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10460 return Res;
10461}
10462
10463template <typename Derived>
10466 DeclarationNameInfo DirName;
10467 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10468 OMPD_interop, DirName, nullptr, D->getBeginLoc());
10469 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10470 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10471 return Res;
10472}
10473
10474template <typename Derived>
10477 DeclarationNameInfo DirName;
10478 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10479 OMPD_dispatch, DirName, nullptr, D->getBeginLoc());
10480 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10481 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10482 return Res;
10483}
10484
10485template <typename Derived>
10488 DeclarationNameInfo DirName;
10489 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10490 OMPD_masked, DirName, nullptr, D->getBeginLoc());
10491 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10492 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10493 return Res;
10494}
10495
10496template <typename Derived>
10498 OMPGenericLoopDirective *D) {
10499 DeclarationNameInfo DirName;
10500 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10501 OMPD_loop, DirName, nullptr, D->getBeginLoc());
10502 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10503 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10504 return Res;
10505}
10506
10507template <typename Derived>
10509 OMPTeamsGenericLoopDirective *D) {
10510 DeclarationNameInfo DirName;
10511 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10512 OMPD_teams_loop, DirName, nullptr, D->getBeginLoc());
10513 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10514 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10515 return Res;
10516}
10517
10518template <typename Derived>
10520 OMPTargetTeamsGenericLoopDirective *D) {
10521 DeclarationNameInfo DirName;
10522 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10523 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
10524 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10525 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10526 return Res;
10527}
10528
10529template <typename Derived>
10531 OMPParallelGenericLoopDirective *D) {
10532 DeclarationNameInfo DirName;
10533 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10534 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
10535 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10536 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10537 return Res;
10538}
10539
10540template <typename Derived>
10543 OMPTargetParallelGenericLoopDirective *D) {
10544 DeclarationNameInfo DirName;
10545 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10546 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10547 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10548 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10549 return Res;
10550}
10551
10552//===----------------------------------------------------------------------===//
10553// OpenMP clause transformation
10554//===----------------------------------------------------------------------===//
10555template <typename Derived>
10557 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10558 if (Cond.isInvalid())
10559 return nullptr;
10560 return getDerived().RebuildOMPIfClause(
10561 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10562 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10563}
10564
10565template <typename Derived>
10567 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10568 if (Cond.isInvalid())
10569 return nullptr;
10570 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10571 C->getLParenLoc(), C->getEndLoc());
10572}
10573
10574template <typename Derived>
10575OMPClause *
10577 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
10578 if (NumThreads.isInvalid())
10579 return nullptr;
10580 return getDerived().RebuildOMPNumThreadsClause(
10581 C->getModifier(), NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(),
10582 C->getModifierLoc(), C->getEndLoc());
10583}
10584
10585template <typename Derived>
10586OMPClause *
10588 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10589 if (E.isInvalid())
10590 return nullptr;
10591 return getDerived().RebuildOMPSafelenClause(
10592 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10593}
10594
10595template <typename Derived>
10596OMPClause *
10598 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10599 if (E.isInvalid())
10600 return nullptr;
10601 return getDerived().RebuildOMPAllocatorClause(
10602 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10603}
10604
10605template <typename Derived>
10606OMPClause *
10608 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
10609 if (E.isInvalid())
10610 return nullptr;
10611 return getDerived().RebuildOMPSimdlenClause(
10612 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10613}
10614
10615template <typename Derived>
10617 SmallVector<Expr *, 4> TransformedSizes;
10618 TransformedSizes.reserve(C->getNumSizes());
10619 bool Changed = false;
10620 for (Expr *E : C->getSizesRefs()) {
10621 if (!E) {
10622 TransformedSizes.push_back(nullptr);
10623 continue;
10624 }
10625
10626 ExprResult T = getDerived().TransformExpr(E);
10627 if (T.isInvalid())
10628 return nullptr;
10629 if (E != T.get())
10630 Changed = true;
10631 TransformedSizes.push_back(T.get());
10632 }
10633
10634 if (!Changed && !getDerived().AlwaysRebuild())
10635 return C;
10636 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
10637 C->getLParenLoc(), C->getEndLoc());
10638}
10639
10640template <typename Derived>
10641OMPClause *
10643 SmallVector<Expr *, 4> TransformedCounts;
10644 TransformedCounts.reserve(C->getNumCounts());
10645 for (Expr *E : C->getCountsRefs()) {
10646 if (!E) {
10647 TransformedCounts.push_back(nullptr);
10648 continue;
10649 }
10650
10651 ExprResult T = getDerived().TransformExpr(E);
10652 if (T.isInvalid())
10653 return nullptr;
10654 TransformedCounts.push_back(T.get());
10655 }
10656
10657 return RebuildOMPCountsClause(TransformedCounts, C->getBeginLoc(),
10658 C->getLParenLoc(), C->getEndLoc(),
10659 C->getOmpFillIndex(), C->getOmpFillLoc());
10660}
10661
10662template <typename Derived>
10663OMPClause *
10665 SmallVector<Expr *> TransformedArgs;
10666 TransformedArgs.reserve(C->getNumLoops());
10667 bool Changed = false;
10668 for (Expr *E : C->getArgsRefs()) {
10669 if (!E) {
10670 TransformedArgs.push_back(nullptr);
10671 continue;
10672 }
10673
10674 ExprResult T = getDerived().TransformExpr(E);
10675 if (T.isInvalid())
10676 return nullptr;
10677 if (E != T.get())
10678 Changed = true;
10679 TransformedArgs.push_back(T.get());
10680 }
10681
10682 if (!Changed && !getDerived().AlwaysRebuild())
10683 return C;
10684 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
10685 C->getLParenLoc(), C->getEndLoc());
10686}
10687
10688template <typename Derived>
10690 if (!getDerived().AlwaysRebuild())
10691 return C;
10692 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10693}
10694
10695template <typename Derived>
10696OMPClause *
10698 ExprResult T = getDerived().TransformExpr(C->getFactor());
10699 if (T.isInvalid())
10700 return nullptr;
10701 Expr *Factor = T.get();
10702 bool Changed = Factor != C->getFactor();
10703
10704 if (!Changed && !getDerived().AlwaysRebuild())
10705 return C;
10706 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10707 C->getEndLoc());
10708}
10709
10710template <typename Derived>
10711OMPClause *
10713 ExprResult F = getDerived().TransformExpr(C->getFirst());
10714 if (F.isInvalid())
10715 return nullptr;
10716
10717 ExprResult Cn = getDerived().TransformExpr(C->getCount());
10718 if (Cn.isInvalid())
10719 return nullptr;
10720
10721 Expr *First = F.get();
10722 Expr *Count = Cn.get();
10723
10724 bool Changed = (First != C->getFirst()) || (Count != C->getCount());
10725
10726 // If no changes and AlwaysRebuild() is false, return the original clause
10727 if (!Changed && !getDerived().AlwaysRebuild())
10728 return C;
10729
10730 return RebuildOMPLoopRangeClause(First, Count, C->getBeginLoc(),
10731 C->getLParenLoc(), C->getFirstLoc(),
10732 C->getCountLoc(), C->getEndLoc());
10733}
10734
10735template <typename Derived>
10736OMPClause *
10738 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10739 if (E.isInvalid())
10740 return nullptr;
10741 return getDerived().RebuildOMPCollapseClause(
10742 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10743}
10744
10745template <typename Derived>
10746OMPClause *
10748 return getDerived().RebuildOMPDefaultClause(
10749 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getDefaultVC(),
10750 C->getDefaultVCLoc(), C->getBeginLoc(), C->getLParenLoc(),
10751 C->getEndLoc());
10752}
10753
10754template <typename Derived>
10755OMPClause *
10757 // No need to rebuild this clause, no template-dependent parameters.
10758 return C;
10759}
10760
10761template <typename Derived>
10762OMPClause *
10764 Expr *Impex = C->getImpexType();
10765 ExprResult TransformedImpex = getDerived().TransformExpr(Impex);
10766
10767 if (TransformedImpex.isInvalid())
10768 return nullptr;
10769
10770 return getDerived().RebuildOMPTransparentClause(
10771 TransformedImpex.get(), C->getBeginLoc(), C->getLParenLoc(),
10772 C->getEndLoc());
10773}
10774
10775template <typename Derived>
10776OMPClause *
10778 return getDerived().RebuildOMPProcBindClause(
10779 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10780 C->getLParenLoc(), C->getEndLoc());
10781}
10782
10783template <typename Derived>
10784OMPClause *
10786 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10787 if (E.isInvalid())
10788 return nullptr;
10789 return getDerived().RebuildOMPScheduleClause(
10790 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10791 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10792 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10793 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10794}
10795
10796template <typename Derived>
10797OMPClause *
10799 ExprResult E;
10800 if (auto *Num = C->getNumForLoops()) {
10801 E = getDerived().TransformExpr(Num);
10802 if (E.isInvalid())
10803 return nullptr;
10804 }
10805 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10806 C->getLParenLoc(), E.get());
10807}
10808
10809template <typename Derived>
10810OMPClause *
10812 ExprResult E;
10813 if (Expr *Evt = C->getEventHandler()) {
10814 E = getDerived().TransformExpr(Evt);
10815 if (E.isInvalid())
10816 return nullptr;
10817 }
10818 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10819 C->getLParenLoc(), C->getEndLoc());
10820}
10821
10822template <typename Derived>
10823OMPClause *
10826 if (auto *Condition = C->getCondition()) {
10827 Cond = getDerived().TransformExpr(Condition);
10828 if (Cond.isInvalid())
10829 return nullptr;
10830 }
10831 return getDerived().RebuildOMPNowaitClause(Cond.get(), C->getBeginLoc(),
10832 C->getLParenLoc(), C->getEndLoc());
10833}
10834
10835template <typename Derived>
10836OMPClause *
10838 // No need to rebuild this clause, no template-dependent parameters.
10839 return C;
10840}
10841
10842template <typename Derived>
10843OMPClause *
10845 // No need to rebuild this clause, no template-dependent parameters.
10846 return C;
10847}
10848
10849template <typename Derived>
10851 // No need to rebuild this clause, no template-dependent parameters.
10852 return C;
10853}
10854
10855template <typename Derived>
10857 // No need to rebuild this clause, no template-dependent parameters.
10858 return C;
10859}
10860
10861template <typename Derived>
10862OMPClause *
10864 // No need to rebuild this clause, no template-dependent parameters.
10865 return C;
10866}
10867
10868template <typename Derived>
10869OMPClause *
10871 // No need to rebuild this clause, no template-dependent parameters.
10872 return C;
10873}
10874
10875template <typename Derived>
10876OMPClause *
10878 // No need to rebuild this clause, no template-dependent parameters.
10879 return C;
10880}
10881
10882template <typename Derived>
10884 // No need to rebuild this clause, no template-dependent parameters.
10885 return C;
10886}
10887
10888template <typename Derived>
10889OMPClause *
10891 return C;
10892}
10893
10894template <typename Derived>
10896 ExprResult E = getDerived().TransformExpr(C->getExpr());
10897 if (E.isInvalid())
10898 return nullptr;
10899 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
10900 C->getLParenLoc(), C->getEndLoc());
10901}
10902
10903template <typename Derived>
10904OMPClause *
10906 return C;
10907}
10908
10909template <typename Derived>
10910OMPClause *
10912 return C;
10913}
10914template <typename Derived>
10916 OMPNoOpenMPRoutinesClause *C) {
10917 return C;
10918}
10919template <typename Derived>
10921 OMPNoOpenMPConstructsClause *C) {
10922 return C;
10923}
10924template <typename Derived>
10926 OMPNoParallelismClause *C) {
10927 return C;
10928}
10929
10930template <typename Derived>
10931OMPClause *
10933 // No need to rebuild this clause, no template-dependent parameters.
10934 return C;
10935}
10936
10937template <typename Derived>
10938OMPClause *
10940 // No need to rebuild this clause, no template-dependent parameters.
10941 return C;
10942}
10943
10944template <typename Derived>
10945OMPClause *
10947 // No need to rebuild this clause, no template-dependent parameters.
10948 return C;
10949}
10950
10951template <typename Derived>
10952OMPClause *
10954 // No need to rebuild this clause, no template-dependent parameters.
10955 return C;
10956}
10957
10958template <typename Derived>
10959OMPClause *
10961 // No need to rebuild this clause, no template-dependent parameters.
10962 return C;
10963}
10964
10965template <typename Derived>
10967 // No need to rebuild this clause, no template-dependent parameters.
10968 return C;
10969}
10970
10971template <typename Derived>
10972OMPClause *
10974 // No need to rebuild this clause, no template-dependent parameters.
10975 return C;
10976}
10977
10978template <typename Derived>
10980 // No need to rebuild this clause, no template-dependent parameters.
10981 return C;
10982}
10983
10984template <typename Derived>
10985OMPClause *
10987 // No need to rebuild this clause, no template-dependent parameters.
10988 return C;
10989}
10990
10991template <typename Derived>
10993 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
10994 if (IVR.isInvalid())
10995 return nullptr;
10996
10997 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
10998 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
10999 for (Expr *E : llvm::drop_begin(C->varlist())) {
11000 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
11001 if (ER.isInvalid())
11002 return nullptr;
11003 InteropInfo.PreferTypes.push_back(ER.get());
11004 }
11005 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
11006 C->getBeginLoc(), C->getLParenLoc(),
11007 C->getVarLoc(), C->getEndLoc());
11008}
11009
11010template <typename Derived>
11012 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
11013 if (ER.isInvalid())
11014 return nullptr;
11015 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
11016 C->getLParenLoc(), C->getVarLoc(),
11017 C->getEndLoc());
11018}
11019
11020template <typename Derived>
11021OMPClause *
11023 ExprResult ER;
11024 if (Expr *IV = C->getInteropVar()) {
11025 ER = getDerived().TransformExpr(IV);
11026 if (ER.isInvalid())
11027 return nullptr;
11028 }
11029 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
11030 C->getLParenLoc(), C->getVarLoc(),
11031 C->getEndLoc());
11032}
11033
11034template <typename Derived>
11035OMPClause *
11037 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11038 if (Cond.isInvalid())
11039 return nullptr;
11040 return getDerived().RebuildOMPNovariantsClause(
11041 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11042}
11043
11044template <typename Derived>
11045OMPClause *
11047 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11048 if (Cond.isInvalid())
11049 return nullptr;
11050 return getDerived().RebuildOMPNocontextClause(
11051 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11052}
11053
11054template <typename Derived>
11055OMPClause *
11057 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
11058 if (ThreadID.isInvalid())
11059 return nullptr;
11060 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
11061 C->getLParenLoc(), C->getEndLoc());
11062}
11063
11064template <typename Derived>
11066 ExprResult E = getDerived().TransformExpr(C->getAlignment());
11067 if (E.isInvalid())
11068 return nullptr;
11069 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
11070 C->getLParenLoc(), C->getEndLoc());
11071}
11072
11073template <typename Derived>
11075 OMPUnifiedAddressClause *C) {
11076 llvm_unreachable("unified_address clause cannot appear in dependent context");
11077}
11078
11079template <typename Derived>
11081 OMPUnifiedSharedMemoryClause *C) {
11082 llvm_unreachable(
11083 "unified_shared_memory clause cannot appear in dependent context");
11084}
11085
11086template <typename Derived>
11088 OMPReverseOffloadClause *C) {
11089 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
11090}
11091
11092template <typename Derived>
11094 OMPDynamicAllocatorsClause *C) {
11095 llvm_unreachable(
11096 "dynamic_allocators clause cannot appear in dependent context");
11097}
11098
11099template <typename Derived>
11101 OMPAtomicDefaultMemOrderClause *C) {
11102 llvm_unreachable(
11103 "atomic_default_mem_order clause cannot appear in dependent context");
11104}
11105
11106template <typename Derived>
11107OMPClause *
11109 llvm_unreachable("self_maps clause cannot appear in dependent context");
11110}
11111
11112template <typename Derived>
11114 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
11115 C->getBeginLoc(), C->getLParenLoc(),
11116 C->getEndLoc());
11117}
11118
11119template <typename Derived>
11120OMPClause *
11122 return getDerived().RebuildOMPSeverityClause(
11123 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
11124 C->getLParenLoc(), C->getEndLoc());
11125}
11126
11127template <typename Derived>
11128OMPClause *
11130 ExprResult E = getDerived().TransformExpr(C->getMessageString());
11131 if (E.isInvalid())
11132 return nullptr;
11133 return getDerived().RebuildOMPMessageClause(
11134 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11135}
11136
11137template <typename Derived>
11138OMPClause *
11141 Vars.reserve(C->varlist_size());
11142 for (auto *VE : C->varlist()) {
11143 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11144 if (EVar.isInvalid())
11145 return nullptr;
11146 Vars.push_back(EVar.get());
11147 }
11148 return getDerived().RebuildOMPPrivateClause(
11149 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11150}
11151
11152template <typename Derived>
11154 OMPFirstprivateClause *C) {
11156 Vars.reserve(C->varlist_size());
11157 for (auto *VE : C->varlist()) {
11158 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11159 if (EVar.isInvalid())
11160 return nullptr;
11161 Vars.push_back(EVar.get());
11162 }
11163 return getDerived().RebuildOMPFirstprivateClause(
11164 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11165}
11166
11167template <typename Derived>
11168OMPClause *
11171 Vars.reserve(C->varlist_size());
11172 for (auto *VE : C->varlist()) {
11173 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11174 if (EVar.isInvalid())
11175 return nullptr;
11176 Vars.push_back(EVar.get());
11177 }
11178 return getDerived().RebuildOMPLastprivateClause(
11179 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11180 C->getLParenLoc(), C->getEndLoc());
11181}
11182
11183template <typename Derived>
11184OMPClause *
11187 Vars.reserve(C->varlist_size());
11188 for (auto *VE : C->varlist()) {
11189 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11190 if (EVar.isInvalid())
11191 return nullptr;
11192 Vars.push_back(EVar.get());
11193 }
11194 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11195 C->getLParenLoc(), C->getEndLoc());
11196}
11197
11198template <typename Derived>
11199OMPClause *
11202 Vars.reserve(C->varlist_size());
11203 for (auto *VE : C->varlist()) {
11204 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11205 if (EVar.isInvalid())
11206 return nullptr;
11207 Vars.push_back(EVar.get());
11208 }
11209 CXXScopeSpec ReductionIdScopeSpec;
11210 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11211
11212 DeclarationNameInfo NameInfo = C->getNameInfo();
11213 if (NameInfo.getName()) {
11214 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11215 if (!NameInfo.getName())
11216 return nullptr;
11217 }
11218 // Build a list of all UDR decls with the same names ranged by the Scopes.
11219 // The Scope boundary is a duplication of the previous decl.
11220 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11221 for (auto *E : C->reduction_ops()) {
11222 // Transform all the decls.
11223 if (E) {
11224 auto *ULE = cast<UnresolvedLookupExpr>(E);
11225 UnresolvedSet<8> Decls;
11226 for (auto *D : ULE->decls()) {
11227 NamedDecl *InstD =
11228 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11229 Decls.addDecl(InstD, InstD->getAccess());
11230 }
11231 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11232 SemaRef.Context, /*NamingClass=*/nullptr,
11233 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11234 /*ADL=*/true, Decls.begin(), Decls.end(),
11235 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11236 } else
11237 UnresolvedReductions.push_back(nullptr);
11238 }
11239 return getDerived().RebuildOMPReductionClause(
11240 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11241 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11242 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11243}
11244
11245template <typename Derived>
11247 OMPTaskReductionClause *C) {
11249 Vars.reserve(C->varlist_size());
11250 for (auto *VE : C->varlist()) {
11251 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11252 if (EVar.isInvalid())
11253 return nullptr;
11254 Vars.push_back(EVar.get());
11255 }
11256 CXXScopeSpec ReductionIdScopeSpec;
11257 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11258
11259 DeclarationNameInfo NameInfo = C->getNameInfo();
11260 if (NameInfo.getName()) {
11261 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11262 if (!NameInfo.getName())
11263 return nullptr;
11264 }
11265 // Build a list of all UDR decls with the same names ranged by the Scopes.
11266 // The Scope boundary is a duplication of the previous decl.
11267 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11268 for (auto *E : C->reduction_ops()) {
11269 // Transform all the decls.
11270 if (E) {
11271 auto *ULE = cast<UnresolvedLookupExpr>(E);
11272 UnresolvedSet<8> Decls;
11273 for (auto *D : ULE->decls()) {
11274 NamedDecl *InstD =
11275 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11276 Decls.addDecl(InstD, InstD->getAccess());
11277 }
11278 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11279 SemaRef.Context, /*NamingClass=*/nullptr,
11280 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11281 /*ADL=*/true, Decls.begin(), Decls.end(),
11282 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11283 } else
11284 UnresolvedReductions.push_back(nullptr);
11285 }
11286 return getDerived().RebuildOMPTaskReductionClause(
11287 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11288 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11289}
11290
11291template <typename Derived>
11292OMPClause *
11295 Vars.reserve(C->varlist_size());
11296 for (auto *VE : C->varlist()) {
11297 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11298 if (EVar.isInvalid())
11299 return nullptr;
11300 Vars.push_back(EVar.get());
11301 }
11302 CXXScopeSpec ReductionIdScopeSpec;
11303 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11304
11305 DeclarationNameInfo NameInfo = C->getNameInfo();
11306 if (NameInfo.getName()) {
11307 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11308 if (!NameInfo.getName())
11309 return nullptr;
11310 }
11311 // Build a list of all UDR decls with the same names ranged by the Scopes.
11312 // The Scope boundary is a duplication of the previous decl.
11313 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11314 for (auto *E : C->reduction_ops()) {
11315 // Transform all the decls.
11316 if (E) {
11317 auto *ULE = cast<UnresolvedLookupExpr>(E);
11318 UnresolvedSet<8> Decls;
11319 for (auto *D : ULE->decls()) {
11320 NamedDecl *InstD =
11321 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11322 Decls.addDecl(InstD, InstD->getAccess());
11323 }
11324 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11325 SemaRef.Context, /*NamingClass=*/nullptr,
11326 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11327 /*ADL=*/true, Decls.begin(), Decls.end(),
11328 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11329 } else
11330 UnresolvedReductions.push_back(nullptr);
11331 }
11332 return getDerived().RebuildOMPInReductionClause(
11333 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11334 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11335}
11336
11337template <typename Derived>
11338OMPClause *
11341 Vars.reserve(C->varlist_size());
11342 for (auto *VE : C->varlist()) {
11343 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11344 if (EVar.isInvalid())
11345 return nullptr;
11346 Vars.push_back(EVar.get());
11347 }
11348 ExprResult Step = getDerived().TransformExpr(C->getStep());
11349 if (Step.isInvalid())
11350 return nullptr;
11351 return getDerived().RebuildOMPLinearClause(
11352 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11353 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11354 C->getEndLoc());
11355}
11356
11357template <typename Derived>
11358OMPClause *
11361 Vars.reserve(C->varlist_size());
11362 for (auto *VE : C->varlist()) {
11363 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11364 if (EVar.isInvalid())
11365 return nullptr;
11366 Vars.push_back(EVar.get());
11367 }
11368 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11369 if (Alignment.isInvalid())
11370 return nullptr;
11371 return getDerived().RebuildOMPAlignedClause(
11372 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11373 C->getColonLoc(), C->getEndLoc());
11374}
11375
11376template <typename Derived>
11377OMPClause *
11380 Vars.reserve(C->varlist_size());
11381 for (auto *VE : C->varlist()) {
11382 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11383 if (EVar.isInvalid())
11384 return nullptr;
11385 Vars.push_back(EVar.get());
11386 }
11387 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11388 C->getLParenLoc(), C->getEndLoc());
11389}
11390
11391template <typename Derived>
11392OMPClause *
11395 Vars.reserve(C->varlist_size());
11396 for (auto *VE : C->varlist()) {
11397 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11398 if (EVar.isInvalid())
11399 return nullptr;
11400 Vars.push_back(EVar.get());
11401 }
11402 return getDerived().RebuildOMPCopyprivateClause(
11403 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11404}
11405
11406template <typename Derived>
11409 Vars.reserve(C->varlist_size());
11410 for (auto *VE : C->varlist()) {
11411 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11412 if (EVar.isInvalid())
11413 return nullptr;
11414 Vars.push_back(EVar.get());
11415 }
11416 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11417 C->getLParenLoc(), C->getEndLoc());
11418}
11419
11420template <typename Derived>
11421OMPClause *
11423 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11424 if (E.isInvalid())
11425 return nullptr;
11426 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11427 C->getLParenLoc(), C->getEndLoc());
11428}
11429
11430template <typename Derived>
11431OMPClause *
11434 Expr *DepModifier = C->getModifier();
11435 if (DepModifier) {
11436 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11437 if (DepModRes.isInvalid())
11438 return nullptr;
11439 DepModifier = DepModRes.get();
11440 }
11441 Vars.reserve(C->varlist_size());
11442 for (auto *VE : C->varlist()) {
11443 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11444 if (EVar.isInvalid())
11445 return nullptr;
11446 Vars.push_back(EVar.get());
11447 }
11448 return getDerived().RebuildOMPDependClause(
11449 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11450 C->getOmpAllMemoryLoc()},
11451 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11452}
11453
11454template <typename Derived>
11455OMPClause *
11457 ExprResult E = getDerived().TransformExpr(C->getDevice());
11458 if (E.isInvalid())
11459 return nullptr;
11460 return getDerived().RebuildOMPDeviceClause(
11461 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11462 C->getModifierLoc(), C->getEndLoc());
11463}
11464
11465template <typename Derived, class T>
11468 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11469 DeclarationNameInfo &MapperIdInfo,
11470 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11471 // Transform expressions in the list.
11472 Vars.reserve(C->varlist_size());
11473 for (auto *VE : C->varlist()) {
11474 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11475 if (EVar.isInvalid())
11476 return true;
11477 Vars.push_back(EVar.get());
11478 }
11479 // Transform mapper scope specifier and identifier.
11480 NestedNameSpecifierLoc QualifierLoc;
11481 if (C->getMapperQualifierLoc()) {
11482 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11483 C->getMapperQualifierLoc());
11484 if (!QualifierLoc)
11485 return true;
11486 }
11487 MapperIdScopeSpec.Adopt(QualifierLoc);
11488 MapperIdInfo = C->getMapperIdInfo();
11489 if (MapperIdInfo.getName()) {
11490 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11491 if (!MapperIdInfo.getName())
11492 return true;
11493 }
11494 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11495 // the previous user-defined mapper lookup in dependent environment.
11496 for (auto *E : C->mapperlists()) {
11497 // Transform all the decls.
11498 if (E) {
11499 auto *ULE = cast<UnresolvedLookupExpr>(E);
11500 UnresolvedSet<8> Decls;
11501 for (auto *D : ULE->decls()) {
11502 NamedDecl *InstD =
11503 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11504 Decls.addDecl(InstD, InstD->getAccess());
11505 }
11506 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11507 TT.getSema().Context, /*NamingClass=*/nullptr,
11508 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11509 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11510 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11511 } else {
11512 UnresolvedMappers.push_back(nullptr);
11513 }
11514 }
11515 return false;
11516}
11517
11518template <typename Derived>
11519OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11520 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11522 Expr *IteratorModifier = C->getIteratorModifier();
11523 if (IteratorModifier) {
11524 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11525 if (MapModRes.isInvalid())
11526 return nullptr;
11527 IteratorModifier = MapModRes.get();
11528 }
11529 CXXScopeSpec MapperIdScopeSpec;
11530 DeclarationNameInfo MapperIdInfo;
11531 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11533 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11534 return nullptr;
11535 return getDerived().RebuildOMPMapClause(
11536 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11537 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11538 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11539}
11540
11541template <typename Derived>
11542OMPClause *
11544 Expr *Allocator = C->getAllocator();
11545 if (Allocator) {
11546 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11547 if (AllocatorRes.isInvalid())
11548 return nullptr;
11549 Allocator = AllocatorRes.get();
11550 }
11551 Expr *Alignment = C->getAlignment();
11552 if (Alignment) {
11553 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11554 if (AlignmentRes.isInvalid())
11555 return nullptr;
11556 Alignment = AlignmentRes.get();
11557 }
11559 Vars.reserve(C->varlist_size());
11560 for (auto *VE : C->varlist()) {
11561 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11562 if (EVar.isInvalid())
11563 return nullptr;
11564 Vars.push_back(EVar.get());
11565 }
11566 return getDerived().RebuildOMPAllocateClause(
11567 Allocator, Alignment, C->getFirstAllocateModifier(),
11568 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11569 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11570 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11571}
11572
11573template <typename Derived>
11574OMPClause *
11577 Vars.reserve(C->varlist_size());
11578 for (auto *VE : C->varlist()) {
11579 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11580 if (EVar.isInvalid())
11581 return nullptr;
11582 Vars.push_back(EVar.get());
11583 }
11584 return getDerived().RebuildOMPNumTeamsClause(
11585 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11586}
11587
11588template <typename Derived>
11589OMPClause *
11592 Vars.reserve(C->varlist_size());
11593 for (auto *VE : C->varlist()) {
11594 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11595 if (EVar.isInvalid())
11596 return nullptr;
11597 Vars.push_back(EVar.get());
11598 }
11599 return getDerived().RebuildOMPThreadLimitClause(
11600 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11601}
11602
11603template <typename Derived>
11604OMPClause *
11606 ExprResult E = getDerived().TransformExpr(C->getPriority());
11607 if (E.isInvalid())
11608 return nullptr;
11609 return getDerived().RebuildOMPPriorityClause(
11610 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11611}
11612
11613template <typename Derived>
11614OMPClause *
11616 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11617 if (E.isInvalid())
11618 return nullptr;
11619 return getDerived().RebuildOMPGrainsizeClause(
11620 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11621 C->getModifierLoc(), C->getEndLoc());
11622}
11623
11624template <typename Derived>
11625OMPClause *
11627 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11628 if (E.isInvalid())
11629 return nullptr;
11630 return getDerived().RebuildOMPNumTasksClause(
11631 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11632 C->getModifierLoc(), C->getEndLoc());
11633}
11634
11635template <typename Derived>
11637 ExprResult E = getDerived().TransformExpr(C->getHint());
11638 if (E.isInvalid())
11639 return nullptr;
11640 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11641 C->getLParenLoc(), C->getEndLoc());
11642}
11643
11644template <typename Derived>
11646 OMPDistScheduleClause *C) {
11647 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11648 if (E.isInvalid())
11649 return nullptr;
11650 return getDerived().RebuildOMPDistScheduleClause(
11651 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11652 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11653}
11654
11655template <typename Derived>
11656OMPClause *
11658 // Rebuild Defaultmap Clause since we need to invoke the checking of
11659 // defaultmap(none:variable-category) after template initialization.
11660 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11661 C->getDefaultmapKind(),
11662 C->getBeginLoc(),
11663 C->getLParenLoc(),
11664 C->getDefaultmapModifierLoc(),
11665 C->getDefaultmapKindLoc(),
11666 C->getEndLoc());
11667}
11668
11669template <typename Derived>
11671 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11673 Expr *IteratorModifier = C->getIteratorModifier();
11674 if (IteratorModifier) {
11675 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11676 if (MapModRes.isInvalid())
11677 return nullptr;
11678 IteratorModifier = MapModRes.get();
11679 }
11680 CXXScopeSpec MapperIdScopeSpec;
11681 DeclarationNameInfo MapperIdInfo;
11682 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11684 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11685 return nullptr;
11686 return getDerived().RebuildOMPToClause(
11687 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11688 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11689 UnresolvedMappers);
11690}
11691
11692template <typename Derived>
11694 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11696 Expr *IteratorModifier = C->getIteratorModifier();
11697 if (IteratorModifier) {
11698 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11699 if (MapModRes.isInvalid())
11700 return nullptr;
11701 IteratorModifier = MapModRes.get();
11702 }
11703 CXXScopeSpec MapperIdScopeSpec;
11704 DeclarationNameInfo MapperIdInfo;
11705 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11707 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11708 return nullptr;
11709 return getDerived().RebuildOMPFromClause(
11710 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11711 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11712 UnresolvedMappers);
11713}
11714
11715template <typename Derived>
11717 OMPUseDevicePtrClause *C) {
11719 Vars.reserve(C->varlist_size());
11720 for (auto *VE : C->varlist()) {
11721 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11722 if (EVar.isInvalid())
11723 return nullptr;
11724 Vars.push_back(EVar.get());
11725 }
11726 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11727 return getDerived().RebuildOMPUseDevicePtrClause(
11728 Vars, Locs, C->getFallbackModifier(), C->getFallbackModifierLoc());
11729}
11730
11731template <typename Derived>
11733 OMPUseDeviceAddrClause *C) {
11735 Vars.reserve(C->varlist_size());
11736 for (auto *VE : C->varlist()) {
11737 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11738 if (EVar.isInvalid())
11739 return nullptr;
11740 Vars.push_back(EVar.get());
11741 }
11742 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11743 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11744}
11745
11746template <typename Derived>
11747OMPClause *
11750 Vars.reserve(C->varlist_size());
11751 for (auto *VE : C->varlist()) {
11752 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11753 if (EVar.isInvalid())
11754 return nullptr;
11755 Vars.push_back(EVar.get());
11756 }
11757 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11758 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11759}
11760
11761template <typename Derived>
11763 OMPHasDeviceAddrClause *C) {
11765 Vars.reserve(C->varlist_size());
11766 for (auto *VE : C->varlist()) {
11767 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11768 if (EVar.isInvalid())
11769 return nullptr;
11770 Vars.push_back(EVar.get());
11771 }
11772 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11773 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11774}
11775
11776template <typename Derived>
11777OMPClause *
11780 Vars.reserve(C->varlist_size());
11781 for (auto *VE : C->varlist()) {
11782 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11783 if (EVar.isInvalid())
11784 return nullptr;
11785 Vars.push_back(EVar.get());
11786 }
11787 return getDerived().RebuildOMPNontemporalClause(
11788 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11789}
11790
11791template <typename Derived>
11792OMPClause *
11795 Vars.reserve(C->varlist_size());
11796 for (auto *VE : C->varlist()) {
11797 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11798 if (EVar.isInvalid())
11799 return nullptr;
11800 Vars.push_back(EVar.get());
11801 }
11802 return getDerived().RebuildOMPInclusiveClause(
11803 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11804}
11805
11806template <typename Derived>
11807OMPClause *
11810 Vars.reserve(C->varlist_size());
11811 for (auto *VE : C->varlist()) {
11812 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11813 if (EVar.isInvalid())
11814 return nullptr;
11815 Vars.push_back(EVar.get());
11816 }
11817 return getDerived().RebuildOMPExclusiveClause(
11818 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11819}
11820
11821template <typename Derived>
11823 OMPUsesAllocatorsClause *C) {
11825 Data.reserve(C->getNumberOfAllocators());
11826 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11827 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11828 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11829 if (Allocator.isInvalid())
11830 continue;
11831 ExprResult AllocatorTraits;
11832 if (Expr *AT = D.AllocatorTraits) {
11833 AllocatorTraits = getDerived().TransformExpr(AT);
11834 if (AllocatorTraits.isInvalid())
11835 continue;
11836 }
11837 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11838 NewD.Allocator = Allocator.get();
11839 NewD.AllocatorTraits = AllocatorTraits.get();
11840 NewD.LParenLoc = D.LParenLoc;
11841 NewD.RParenLoc = D.RParenLoc;
11842 }
11843 return getDerived().RebuildOMPUsesAllocatorsClause(
11844 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11845}
11846
11847template <typename Derived>
11848OMPClause *
11850 SmallVector<Expr *, 4> Locators;
11851 Locators.reserve(C->varlist_size());
11852 ExprResult ModifierRes;
11853 if (Expr *Modifier = C->getModifier()) {
11854 ModifierRes = getDerived().TransformExpr(Modifier);
11855 if (ModifierRes.isInvalid())
11856 return nullptr;
11857 }
11858 for (Expr *E : C->varlist()) {
11859 ExprResult Locator = getDerived().TransformExpr(E);
11860 if (Locator.isInvalid())
11861 continue;
11862 Locators.push_back(Locator.get());
11863 }
11864 return getDerived().RebuildOMPAffinityClause(
11865 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11866 ModifierRes.get(), Locators);
11867}
11868
11869template <typename Derived>
11871 return getDerived().RebuildOMPOrderClause(
11872 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11873 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11874}
11875
11876template <typename Derived>
11878 return getDerived().RebuildOMPBindClause(
11879 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11880 C->getLParenLoc(), C->getEndLoc());
11881}
11882
11883template <typename Derived>
11885 OMPXDynCGroupMemClause *C) {
11886 ExprResult Size = getDerived().TransformExpr(C->getSize());
11887 if (Size.isInvalid())
11888 return nullptr;
11889 return getDerived().RebuildOMPXDynCGroupMemClause(
11890 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11891}
11892
11893template <typename Derived>
11895 OMPDynGroupprivateClause *C) {
11896 ExprResult Size = getDerived().TransformExpr(C->getSize());
11897 if (Size.isInvalid())
11898 return nullptr;
11899 return getDerived().RebuildOMPDynGroupprivateClause(
11900 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
11901 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
11902 C->getDynGroupprivateModifierLoc(),
11903 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
11904}
11905
11906template <typename Derived>
11907OMPClause *
11910 Vars.reserve(C->varlist_size());
11911 for (auto *VE : C->varlist()) {
11912 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11913 if (EVar.isInvalid())
11914 return nullptr;
11915 Vars.push_back(EVar.get());
11916 }
11917 return getDerived().RebuildOMPDoacrossClause(
11918 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11919 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11920}
11921
11922template <typename Derived>
11923OMPClause *
11926 for (auto *A : C->getAttrs())
11927 NewAttrs.push_back(getDerived().TransformAttr(A));
11928 return getDerived().RebuildOMPXAttributeClause(
11929 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11930}
11931
11932template <typename Derived>
11934 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11935}
11936
11937//===----------------------------------------------------------------------===//
11938// OpenACC transformation
11939//===----------------------------------------------------------------------===//
11940namespace {
11941template <typename Derived>
11942class OpenACCClauseTransform final
11943 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11944 TreeTransform<Derived> &Self;
11945 ArrayRef<const OpenACCClause *> ExistingClauses;
11946 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11947 OpenACCClause *NewClause = nullptr;
11948
11949 ExprResult VisitVar(Expr *VarRef) {
11950 ExprResult Res = Self.TransformExpr(VarRef);
11951
11952 if (!Res.isUsable())
11953 return Res;
11954
11955 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11956 ParsedClause.getClauseKind(),
11957 Res.get());
11958
11959 return Res;
11960 }
11961
11962 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11963 llvm::SmallVector<Expr *> InstantiatedVarList;
11964 for (Expr *CurVar : VarList) {
11965 ExprResult VarRef = VisitVar(CurVar);
11966
11967 if (VarRef.isUsable())
11968 InstantiatedVarList.push_back(VarRef.get());
11969 }
11970
11971 return InstantiatedVarList;
11972 }
11973
11974public:
11975 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11976 ArrayRef<const OpenACCClause *> ExistingClauses,
11977 SemaOpenACC::OpenACCParsedClause &PC)
11978 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
11979
11980 OpenACCClause *CreatedClause() const { return NewClause; }
11981
11982#define VISIT_CLAUSE(CLAUSE_NAME) \
11983 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11984#include "clang/Basic/OpenACCClauses.def"
11985};
11986
11987template <typename Derived>
11988void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11989 const OpenACCDefaultClause &C) {
11990 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
11991
11992 NewClause = OpenACCDefaultClause::Create(
11993 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
11994 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11995 ParsedClause.getEndLoc());
11996}
11997
11998template <typename Derived>
11999void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
12000 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12001 assert(Cond && "If constructed with invalid Condition");
12002 Sema::ConditionResult Res = Self.TransformCondition(
12003 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
12004
12005 if (Res.isInvalid() || !Res.get().second)
12006 return;
12007
12008 ParsedClause.setConditionDetails(Res.get().second);
12009
12010 NewClause = OpenACCIfClause::Create(
12011 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12012 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12013 ParsedClause.getEndLoc());
12014}
12015
12016template <typename Derived>
12017void OpenACCClauseTransform<Derived>::VisitSelfClause(
12018 const OpenACCSelfClause &C) {
12019
12020 // If this is an 'update' 'self' clause, this is actually a var list instead.
12021 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
12022 llvm::SmallVector<Expr *> InstantiatedVarList;
12023 for (Expr *CurVar : C.getVarList()) {
12024 ExprResult Res = Self.TransformExpr(CurVar);
12025
12026 if (!Res.isUsable())
12027 continue;
12028
12029 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
12030 ParsedClause.getClauseKind(),
12031 Res.get());
12032
12033 if (Res.isUsable())
12034 InstantiatedVarList.push_back(Res.get());
12035 }
12036
12037 ParsedClause.setVarListDetails(InstantiatedVarList,
12039
12040 NewClause = OpenACCSelfClause::Create(
12041 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12042 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12043 ParsedClause.getEndLoc());
12044 } else {
12045
12046 if (C.hasConditionExpr()) {
12047 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12049 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
12051
12052 if (Res.isInvalid() || !Res.get().second)
12053 return;
12054
12055 ParsedClause.setConditionDetails(Res.get().second);
12056 }
12057
12058 NewClause = OpenACCSelfClause::Create(
12059 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12060 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12061 ParsedClause.getEndLoc());
12062 }
12063}
12064
12065template <typename Derived>
12066void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
12067 const OpenACCNumGangsClause &C) {
12068 llvm::SmallVector<Expr *> InstantiatedIntExprs;
12069
12070 for (Expr *CurIntExpr : C.getIntExprs()) {
12071 ExprResult Res = Self.TransformExpr(CurIntExpr);
12072
12073 if (!Res.isUsable())
12074 return;
12075
12076 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12077 C.getClauseKind(),
12078 C.getBeginLoc(), Res.get());
12079 if (!Res.isUsable())
12080 return;
12081
12082 InstantiatedIntExprs.push_back(Res.get());
12083 }
12084
12085 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
12087 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12088 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12089 ParsedClause.getEndLoc());
12090}
12091
12092template <typename Derived>
12093void OpenACCClauseTransform<Derived>::VisitPrivateClause(
12094 const OpenACCPrivateClause &C) {
12095 llvm::SmallVector<Expr *> InstantiatedVarList;
12097
12098 for (const auto [RefExpr, InitRecipe] :
12099 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12100 ExprResult VarRef = VisitVar(RefExpr);
12101
12102 if (VarRef.isUsable()) {
12103 InstantiatedVarList.push_back(VarRef.get());
12104
12105 // We only have to create a new one if it is dependent, and Sema won't
12106 // make one of these unless the type is non-dependent.
12107 if (InitRecipe.isSet())
12108 InitRecipes.push_back(InitRecipe);
12109 else
12110 InitRecipes.push_back(
12111 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
12112 }
12113 }
12114 ParsedClause.setVarListDetails(InstantiatedVarList,
12116
12117 NewClause = OpenACCPrivateClause::Create(
12118 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12119 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12120 ParsedClause.getEndLoc());
12121}
12122
12123template <typename Derived>
12124void OpenACCClauseTransform<Derived>::VisitHostClause(
12125 const OpenACCHostClause &C) {
12126 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12128
12129 NewClause = OpenACCHostClause::Create(
12130 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12131 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12132 ParsedClause.getEndLoc());
12133}
12134
12135template <typename Derived>
12136void OpenACCClauseTransform<Derived>::VisitDeviceClause(
12137 const OpenACCDeviceClause &C) {
12138 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12140
12141 NewClause = OpenACCDeviceClause::Create(
12142 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12143 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12144 ParsedClause.getEndLoc());
12145}
12146
12147template <typename Derived>
12148void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
12150 llvm::SmallVector<Expr *> InstantiatedVarList;
12152
12153 for (const auto [RefExpr, InitRecipe] :
12154 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12155 ExprResult VarRef = VisitVar(RefExpr);
12156
12157 if (VarRef.isUsable()) {
12158 InstantiatedVarList.push_back(VarRef.get());
12159
12160 // We only have to create a new one if it is dependent, and Sema won't
12161 // make one of these unless the type is non-dependent.
12162 if (InitRecipe.isSet())
12163 InitRecipes.push_back(InitRecipe);
12164 else
12165 InitRecipes.push_back(
12166 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12167 VarRef.get()));
12168 }
12169 }
12170 ParsedClause.setVarListDetails(InstantiatedVarList,
12172
12174 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12175 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12176 ParsedClause.getEndLoc());
12177}
12178
12179template <typename Derived>
12180void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12181 const OpenACCNoCreateClause &C) {
12182 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12184
12186 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12187 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12188 ParsedClause.getEndLoc());
12189}
12190
12191template <typename Derived>
12192void OpenACCClauseTransform<Derived>::VisitPresentClause(
12193 const OpenACCPresentClause &C) {
12194 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12196
12197 NewClause = OpenACCPresentClause::Create(
12198 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12199 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12200 ParsedClause.getEndLoc());
12201}
12202
12203template <typename Derived>
12204void OpenACCClauseTransform<Derived>::VisitCopyClause(
12205 const OpenACCCopyClause &C) {
12206 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12207 C.getModifierList());
12208
12209 NewClause = OpenACCCopyClause::Create(
12210 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12211 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12212 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12213 ParsedClause.getEndLoc());
12214}
12215
12216template <typename Derived>
12217void OpenACCClauseTransform<Derived>::VisitLinkClause(
12218 const OpenACCLinkClause &C) {
12219 llvm_unreachable("link clause not valid unless a decl transform");
12220}
12221
12222template <typename Derived>
12223void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12225 llvm_unreachable("device_resident clause not valid unless a decl transform");
12226}
12227template <typename Derived>
12228void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12229 const OpenACCNoHostClause &C) {
12230 llvm_unreachable("nohost clause not valid unless a decl transform");
12231}
12232template <typename Derived>
12233void OpenACCClauseTransform<Derived>::VisitBindClause(
12234 const OpenACCBindClause &C) {
12235 llvm_unreachable("bind clause not valid unless a decl transform");
12236}
12237
12238template <typename Derived>
12239void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12240 const OpenACCCopyInClause &C) {
12241 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12242 C.getModifierList());
12243
12244 NewClause = OpenACCCopyInClause::Create(
12245 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12246 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12247 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12248 ParsedClause.getEndLoc());
12249}
12250
12251template <typename Derived>
12252void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12253 const OpenACCCopyOutClause &C) {
12254 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12255 C.getModifierList());
12256
12257 NewClause = OpenACCCopyOutClause::Create(
12258 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12259 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12260 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12261 ParsedClause.getEndLoc());
12262}
12263
12264template <typename Derived>
12265void OpenACCClauseTransform<Derived>::VisitCreateClause(
12266 const OpenACCCreateClause &C) {
12267 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12268 C.getModifierList());
12269
12270 NewClause = OpenACCCreateClause::Create(
12271 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12272 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12273 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12274 ParsedClause.getEndLoc());
12275}
12276template <typename Derived>
12277void OpenACCClauseTransform<Derived>::VisitAttachClause(
12278 const OpenACCAttachClause &C) {
12279 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12280
12281 // Ensure each var is a pointer type.
12282 llvm::erase_if(VarList, [&](Expr *E) {
12283 return Self.getSema().OpenACC().CheckVarIsPointerType(
12285 });
12286
12287 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12288 NewClause = OpenACCAttachClause::Create(
12289 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12290 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12291 ParsedClause.getEndLoc());
12292}
12293
12294template <typename Derived>
12295void OpenACCClauseTransform<Derived>::VisitDetachClause(
12296 const OpenACCDetachClause &C) {
12297 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12298
12299 // Ensure each var is a pointer type.
12300 llvm::erase_if(VarList, [&](Expr *E) {
12301 return Self.getSema().OpenACC().CheckVarIsPointerType(
12303 });
12304
12305 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12306 NewClause = OpenACCDetachClause::Create(
12307 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12308 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12309 ParsedClause.getEndLoc());
12310}
12311
12312template <typename Derived>
12313void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12314 const OpenACCDeleteClause &C) {
12315 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12317 NewClause = OpenACCDeleteClause::Create(
12318 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12319 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12320 ParsedClause.getEndLoc());
12321}
12322
12323template <typename Derived>
12324void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12325 const OpenACCUseDeviceClause &C) {
12326 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12329 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12330 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12331 ParsedClause.getEndLoc());
12332}
12333
12334template <typename Derived>
12335void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12336 const OpenACCDevicePtrClause &C) {
12337 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12338
12339 // Ensure each var is a pointer type.
12340 llvm::erase_if(VarList, [&](Expr *E) {
12341 return Self.getSema().OpenACC().CheckVarIsPointerType(
12343 });
12344
12345 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12347 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12348 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12349 ParsedClause.getEndLoc());
12350}
12351
12352template <typename Derived>
12353void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12354 const OpenACCNumWorkersClause &C) {
12355 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12356 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12357
12358 ExprResult Res = Self.TransformExpr(IntExpr);
12359 if (!Res.isUsable())
12360 return;
12361
12362 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12363 C.getClauseKind(),
12364 C.getBeginLoc(), Res.get());
12365 if (!Res.isUsable())
12366 return;
12367
12368 ParsedClause.setIntExprDetails(Res.get());
12370 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12371 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12372 ParsedClause.getEndLoc());
12373}
12374
12375template <typename Derived>
12376void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12377 const OpenACCDeviceNumClause &C) {
12378 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12379 assert(IntExpr && "device_num clause constructed with invalid int expr");
12380
12381 ExprResult Res = Self.TransformExpr(IntExpr);
12382 if (!Res.isUsable())
12383 return;
12384
12385 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12386 C.getClauseKind(),
12387 C.getBeginLoc(), Res.get());
12388 if (!Res.isUsable())
12389 return;
12390
12391 ParsedClause.setIntExprDetails(Res.get());
12393 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12394 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12395 ParsedClause.getEndLoc());
12396}
12397
12398template <typename Derived>
12399void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12401 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12402 assert(IntExpr && "default_async clause constructed with invalid int expr");
12403
12404 ExprResult Res = Self.TransformExpr(IntExpr);
12405 if (!Res.isUsable())
12406 return;
12407
12408 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12409 C.getClauseKind(),
12410 C.getBeginLoc(), Res.get());
12411 if (!Res.isUsable())
12412 return;
12413
12414 ParsedClause.setIntExprDetails(Res.get());
12416 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12417 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12418 ParsedClause.getEndLoc());
12419}
12420
12421template <typename Derived>
12422void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12424 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12425 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12426
12427 ExprResult Res = Self.TransformExpr(IntExpr);
12428 if (!Res.isUsable())
12429 return;
12430
12431 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12432 C.getClauseKind(),
12433 C.getBeginLoc(), Res.get());
12434 if (!Res.isUsable())
12435 return;
12436
12437 ParsedClause.setIntExprDetails(Res.get());
12439 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12440 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12441 ParsedClause.getEndLoc());
12442}
12443
12444template <typename Derived>
12445void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12446 const OpenACCAsyncClause &C) {
12447 if (C.hasIntExpr()) {
12448 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12449 if (!Res.isUsable())
12450 return;
12451
12452 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12453 C.getClauseKind(),
12454 C.getBeginLoc(), Res.get());
12455 if (!Res.isUsable())
12456 return;
12457 ParsedClause.setIntExprDetails(Res.get());
12458 }
12459
12460 NewClause = OpenACCAsyncClause::Create(
12461 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12462 ParsedClause.getLParenLoc(),
12463 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12464 : nullptr,
12465 ParsedClause.getEndLoc());
12466}
12467
12468template <typename Derived>
12469void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12470 const OpenACCWorkerClause &C) {
12471 if (C.hasIntExpr()) {
12472 // restrictions on this expression are all "does it exist in certain
12473 // situations" that are not possible to be dependent, so the only check we
12474 // have is that it transforms, and is an int expression.
12475 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12476 if (!Res.isUsable())
12477 return;
12478
12479 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12480 C.getClauseKind(),
12481 C.getBeginLoc(), Res.get());
12482 if (!Res.isUsable())
12483 return;
12484 ParsedClause.setIntExprDetails(Res.get());
12485 }
12486
12487 NewClause = OpenACCWorkerClause::Create(
12488 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12489 ParsedClause.getLParenLoc(),
12490 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12491 : nullptr,
12492 ParsedClause.getEndLoc());
12493}
12494
12495template <typename Derived>
12496void OpenACCClauseTransform<Derived>::VisitVectorClause(
12497 const OpenACCVectorClause &C) {
12498 if (C.hasIntExpr()) {
12499 // restrictions on this expression are all "does it exist in certain
12500 // situations" that are not possible to be dependent, so the only check we
12501 // have is that it transforms, and is an int expression.
12502 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12503 if (!Res.isUsable())
12504 return;
12505
12506 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12507 C.getClauseKind(),
12508 C.getBeginLoc(), Res.get());
12509 if (!Res.isUsable())
12510 return;
12511 ParsedClause.setIntExprDetails(Res.get());
12512 }
12513
12514 NewClause = OpenACCVectorClause::Create(
12515 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12516 ParsedClause.getLParenLoc(),
12517 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12518 : nullptr,
12519 ParsedClause.getEndLoc());
12520}
12521
12522template <typename Derived>
12523void OpenACCClauseTransform<Derived>::VisitWaitClause(
12524 const OpenACCWaitClause &C) {
12525 if (C.hasExprs()) {
12526 Expr *DevNumExpr = nullptr;
12527 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12528
12529 // Instantiate devnum expr if it exists.
12530 if (C.getDevNumExpr()) {
12531 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12532 if (!Res.isUsable())
12533 return;
12534 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12535 C.getClauseKind(),
12536 C.getBeginLoc(), Res.get());
12537 if (!Res.isUsable())
12538 return;
12539
12540 DevNumExpr = Res.get();
12541 }
12542
12543 // Instantiate queue ids.
12544 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12545 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12546 if (!Res.isUsable())
12547 return;
12548 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12549 C.getClauseKind(),
12550 C.getBeginLoc(), Res.get());
12551 if (!Res.isUsable())
12552 return;
12553
12554 InstantiatedQueueIdExprs.push_back(Res.get());
12555 }
12556
12557 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12558 std::move(InstantiatedQueueIdExprs));
12559 }
12560
12561 NewClause = OpenACCWaitClause::Create(
12562 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12563 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12564 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12565 ParsedClause.getEndLoc());
12566}
12567
12568template <typename Derived>
12569void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12570 const OpenACCDeviceTypeClause &C) {
12571 // Nothing to transform here, just create a new version of 'C'.
12573 Self.getSema().getASTContext(), C.getClauseKind(),
12574 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12575 C.getArchitectures(), ParsedClause.getEndLoc());
12576}
12577
12578template <typename Derived>
12579void OpenACCClauseTransform<Derived>::VisitAutoClause(
12580 const OpenACCAutoClause &C) {
12581 // Nothing to do, so just create a new node.
12582 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12583 ParsedClause.getBeginLoc(),
12584 ParsedClause.getEndLoc());
12585}
12586
12587template <typename Derived>
12588void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12589 const OpenACCIndependentClause &C) {
12590 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12591 ParsedClause.getBeginLoc(),
12592 ParsedClause.getEndLoc());
12593}
12594
12595template <typename Derived>
12596void OpenACCClauseTransform<Derived>::VisitSeqClause(
12597 const OpenACCSeqClause &C) {
12598 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12599 ParsedClause.getBeginLoc(),
12600 ParsedClause.getEndLoc());
12601}
12602template <typename Derived>
12603void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12604 const OpenACCFinalizeClause &C) {
12605 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12606 ParsedClause.getBeginLoc(),
12607 ParsedClause.getEndLoc());
12608}
12609
12610template <typename Derived>
12611void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12612 const OpenACCIfPresentClause &C) {
12613 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12614 ParsedClause.getBeginLoc(),
12615 ParsedClause.getEndLoc());
12616}
12617
12618template <typename Derived>
12619void OpenACCClauseTransform<Derived>::VisitReductionClause(
12620 const OpenACCReductionClause &C) {
12621 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12622 SmallVector<Expr *> ValidVars;
12624
12625 for (const auto [Var, OrigRecipe] :
12626 llvm::zip(TransformedVars, C.getRecipes())) {
12627 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12628 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12629 if (Res.isUsable()) {
12630 ValidVars.push_back(Res.get());
12631
12632 if (OrigRecipe.isSet())
12633 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
12634 else
12635 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
12636 C.getReductionOp(), Res.get()));
12637 }
12638 }
12639
12640 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12641 ExistingClauses, ParsedClause.getDirectiveKind(),
12642 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12643 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
12644}
12645
12646template <typename Derived>
12647void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12648 const OpenACCCollapseClause &C) {
12649 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12650 assert(LoopCount && "collapse clause constructed with invalid loop count");
12651
12652 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12653
12654 if (!NewLoopCount.isUsable())
12655 return;
12656
12657 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12658 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12659 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12660
12661 // FIXME: It isn't clear whether this is properly tested here, we should
12662 // probably see if we can come up with a test for this.
12663 if (!NewLoopCount.isUsable())
12664 return;
12665
12666 NewLoopCount =
12667 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12668
12669 // FIXME: It isn't clear whether this is properly tested here, we should
12670 // probably see if we can come up with a test for this.
12671 if (!NewLoopCount.isUsable())
12672 return;
12673
12674 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12676 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12677 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12678 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12679}
12680
12681template <typename Derived>
12682void OpenACCClauseTransform<Derived>::VisitTileClause(
12683 const OpenACCTileClause &C) {
12684
12685 llvm::SmallVector<Expr *> TransformedExprs;
12686
12687 for (Expr *E : C.getSizeExprs()) {
12688 ExprResult NewSizeExpr = Self.TransformExpr(E);
12689
12690 if (!NewSizeExpr.isUsable())
12691 return;
12692
12693 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12694 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12695 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12696
12697 // FIXME: It isn't clear whether this is properly tested here, we should
12698 // probably see if we can come up with a test for this.
12699 if (!NewSizeExpr.isUsable())
12700 return;
12701
12702 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12703
12704 if (!NewSizeExpr.isUsable())
12705 return;
12706 TransformedExprs.push_back(NewSizeExpr.get());
12707 }
12708
12709 ParsedClause.setIntExprDetails(TransformedExprs);
12710 NewClause = OpenACCTileClause::Create(
12711 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12712 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12713 ParsedClause.getEndLoc());
12714}
12715template <typename Derived>
12716void OpenACCClauseTransform<Derived>::VisitGangClause(
12717 const OpenACCGangClause &C) {
12718 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12719 llvm::SmallVector<Expr *> TransformedIntExprs;
12720
12721 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12722 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12723 if (!ER.isUsable())
12724 continue;
12725
12726 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12727 ParsedClause.getDirectiveKind(),
12728 C.getExpr(I).first, ER.get());
12729 if (!ER.isUsable())
12730 continue;
12731 TransformedGangKinds.push_back(C.getExpr(I).first);
12732 TransformedIntExprs.push_back(ER.get());
12733 }
12734
12735 NewClause = Self.getSema().OpenACC().CheckGangClause(
12736 ParsedClause.getDirectiveKind(), ExistingClauses,
12737 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12738 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12739}
12740} // namespace
12741template <typename Derived>
12742OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12743 ArrayRef<const OpenACCClause *> ExistingClauses,
12744 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12745
12747 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12748 ParsedClause.setEndLoc(OldClause->getEndLoc());
12749
12750 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12751 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12752
12753 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12754 ParsedClause};
12755 Transform.Visit(OldClause);
12756
12757 return Transform.CreatedClause();
12758}
12759
12760template <typename Derived>
12762TreeTransform<Derived>::TransformOpenACCClauseList(
12764 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12765 for (const auto *Clause : OldClauses) {
12766 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12767 TransformedClauses, DirKind, Clause))
12768 TransformedClauses.push_back(TransformedClause);
12769 }
12770 return TransformedClauses;
12771}
12772
12773template <typename Derived>
12776 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12777
12778 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12779 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12780 C->clauses());
12781
12782 if (getSema().OpenACC().ActOnStartStmtDirective(
12783 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12784 return StmtError();
12785
12786 // Transform Structured Block.
12787 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12788 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12789 C->clauses(), TransformedClauses);
12790 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12791 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12792 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12793
12794 return getDerived().RebuildOpenACCComputeConstruct(
12795 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12796 C->getEndLoc(), TransformedClauses, StrBlock);
12797}
12798
12799template <typename Derived>
12802
12803 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12804
12805 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12806 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12807 C->clauses());
12808
12809 if (getSema().OpenACC().ActOnStartStmtDirective(
12810 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12811 return StmtError();
12812
12813 // Transform Loop.
12814 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12815 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12816 C->clauses(), TransformedClauses);
12817 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12818 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12819 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12820
12821 return getDerived().RebuildOpenACCLoopConstruct(
12822 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12823 TransformedClauses, Loop);
12824}
12825
12826template <typename Derived>
12828 OpenACCCombinedConstruct *C) {
12829 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12830
12831 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12832 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12833 C->clauses());
12834
12835 if (getSema().OpenACC().ActOnStartStmtDirective(
12836 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12837 return StmtError();
12838
12839 // Transform Loop.
12840 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12841 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12842 C->clauses(), TransformedClauses);
12843 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12844 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12845 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12846
12847 return getDerived().RebuildOpenACCCombinedConstruct(
12848 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12849 C->getEndLoc(), TransformedClauses, Loop);
12850}
12851
12852template <typename Derived>
12855 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12856
12857 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12858 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12859 C->clauses());
12860 if (getSema().OpenACC().ActOnStartStmtDirective(
12861 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12862 return StmtError();
12863
12864 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12865 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12866 C->clauses(), TransformedClauses);
12867 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12868 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12869 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12870
12871 return getDerived().RebuildOpenACCDataConstruct(
12872 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12873 TransformedClauses, StrBlock);
12874}
12875
12876template <typename Derived>
12878 OpenACCEnterDataConstruct *C) {
12879 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12880
12881 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12882 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12883 C->clauses());
12884 if (getSema().OpenACC().ActOnStartStmtDirective(
12885 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12886 return StmtError();
12887
12888 return getDerived().RebuildOpenACCEnterDataConstruct(
12889 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12890 TransformedClauses);
12891}
12892
12893template <typename Derived>
12895 OpenACCExitDataConstruct *C) {
12896 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12897
12898 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12899 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12900 C->clauses());
12901 if (getSema().OpenACC().ActOnStartStmtDirective(
12902 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12903 return StmtError();
12904
12905 return getDerived().RebuildOpenACCExitDataConstruct(
12906 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12907 TransformedClauses);
12908}
12909
12910template <typename Derived>
12912 OpenACCHostDataConstruct *C) {
12913 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12914
12915 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12916 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12917 C->clauses());
12918 if (getSema().OpenACC().ActOnStartStmtDirective(
12919 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12920 return StmtError();
12921
12922 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12923 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12924 C->clauses(), TransformedClauses);
12925 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12926 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12927 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12928
12929 return getDerived().RebuildOpenACCHostDataConstruct(
12930 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12931 TransformedClauses, StrBlock);
12932}
12933
12934template <typename Derived>
12937 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12938
12939 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12940 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12941 C->clauses());
12942 if (getSema().OpenACC().ActOnStartStmtDirective(
12943 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12944 return StmtError();
12945
12946 return getDerived().RebuildOpenACCInitConstruct(
12947 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12948 TransformedClauses);
12949}
12950
12951template <typename Derived>
12953 OpenACCShutdownConstruct *C) {
12954 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12955
12956 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12957 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12958 C->clauses());
12959 if (getSema().OpenACC().ActOnStartStmtDirective(
12960 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12961 return StmtError();
12962
12963 return getDerived().RebuildOpenACCShutdownConstruct(
12964 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12965 TransformedClauses);
12966}
12967template <typename Derived>
12970 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12971
12972 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12973 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12974 C->clauses());
12975 if (getSema().OpenACC().ActOnStartStmtDirective(
12976 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12977 return StmtError();
12978
12979 return getDerived().RebuildOpenACCSetConstruct(
12980 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12981 TransformedClauses);
12982}
12983
12984template <typename Derived>
12986 OpenACCUpdateConstruct *C) {
12987 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12988
12989 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12990 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12991 C->clauses());
12992 if (getSema().OpenACC().ActOnStartStmtDirective(
12993 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12994 return StmtError();
12995
12996 return getDerived().RebuildOpenACCUpdateConstruct(
12997 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12998 TransformedClauses);
12999}
13000
13001template <typename Derived>
13004 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13005
13006 ExprResult DevNumExpr;
13007 if (C->hasDevNumExpr()) {
13008 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
13009
13010 if (DevNumExpr.isUsable())
13011 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
13013 C->getBeginLoc(), DevNumExpr.get());
13014 }
13015
13016 llvm::SmallVector<Expr *> QueueIdExprs;
13017
13018 for (Expr *QE : C->getQueueIdExprs()) {
13019 assert(QE && "Null queue id expr?");
13020 ExprResult NewEQ = getDerived().TransformExpr(QE);
13021
13022 if (!NewEQ.isUsable())
13023 break;
13024 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
13026 C->getBeginLoc(), NewEQ.get());
13027 if (NewEQ.isUsable())
13028 QueueIdExprs.push_back(NewEQ.get());
13029 }
13030
13031 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13032 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13033 C->clauses());
13034
13035 if (getSema().OpenACC().ActOnStartStmtDirective(
13036 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
13037 return StmtError();
13038
13039 return getDerived().RebuildOpenACCWaitConstruct(
13040 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13041 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
13042 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
13043}
13044template <typename Derived>
13046 OpenACCCacheConstruct *C) {
13047 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13048
13049 llvm::SmallVector<Expr *> TransformedVarList;
13050 for (Expr *Var : C->getVarList()) {
13051 assert(Var && "Null var listexpr?");
13052
13053 ExprResult NewVar = getDerived().TransformExpr(Var);
13054
13055 if (!NewVar.isUsable())
13056 break;
13057
13058 NewVar = getSema().OpenACC().ActOnVar(
13059 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
13060 if (!NewVar.isUsable())
13061 break;
13062
13063 TransformedVarList.push_back(NewVar.get());
13064 }
13065
13066 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13067 C->getBeginLoc(), {}))
13068 return StmtError();
13069
13070 return getDerived().RebuildOpenACCCacheConstruct(
13071 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13072 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
13073 C->getEndLoc());
13074}
13075
13076template <typename Derived>
13078 OpenACCAtomicConstruct *C) {
13079 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13080
13081 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13082 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13083 C->clauses());
13084
13085 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13086 C->getBeginLoc(), {}))
13087 return StmtError();
13088
13089 // Transform Associated Stmt.
13090 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13091 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
13092
13093 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
13094 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
13095 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
13096 AssocStmt);
13097
13098 return getDerived().RebuildOpenACCAtomicConstruct(
13099 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
13100 C->getEndLoc(), TransformedClauses, AssocStmt);
13101}
13102
13103template <typename Derived>
13106 if (getDerived().AlwaysRebuild())
13107 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
13108 // Nothing can ever change, so there is never anything to transform.
13109 return E;
13110}
13111
13112//===----------------------------------------------------------------------===//
13113// Expression transformation
13114//===----------------------------------------------------------------------===//
13115template<typename Derived>
13118 return TransformExpr(E->getSubExpr());
13119}
13120
13121template <typename Derived>
13124 if (!E->isTypeDependent())
13125 return E;
13126
13127 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
13128
13129 if (!NewT)
13130 return ExprError();
13131
13132 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
13133 return E;
13134
13135 return getDerived().RebuildSYCLUniqueStableNameExpr(
13136 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
13137}
13138
13139template <typename Derived>
13142 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
13143 const auto *SKEPAttr = FD->template getAttr<SYCLKernelEntryPointAttr>();
13144 if (!SKEPAttr || SKEPAttr->isInvalidAttr())
13145 return StmtError();
13146
13147 ExprResult IdExpr = getDerived().TransformExpr(S->getKernelLaunchIdExpr());
13148 if (IdExpr.isInvalid())
13149 return StmtError();
13150
13151 StmtResult Body = getDerived().TransformStmt(S->getOriginalStmt());
13152 if (Body.isInvalid())
13153 return StmtError();
13154
13156 cast<FunctionDecl>(SemaRef.CurContext), cast<CompoundStmt>(Body.get()),
13157 IdExpr.get());
13158 if (SR.isInvalid())
13159 return StmtError();
13160
13161 return SR;
13162}
13163
13164template <typename Derived>
13166 // TODO(reflection): Implement its transform
13167 assert(false && "not implemented yet");
13168 return ExprError();
13169}
13170
13171template<typename Derived>
13174 if (!E->isTypeDependent())
13175 return E;
13176
13177 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13178 E->getIdentKind());
13179}
13180
13181template<typename Derived>
13184 NestedNameSpecifierLoc QualifierLoc;
13185 if (E->getQualifierLoc()) {
13186 QualifierLoc
13187 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13188 if (!QualifierLoc)
13189 return ExprError();
13190 }
13191
13192 ValueDecl *ND
13193 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13194 E->getDecl()));
13195 if (!ND || ND->isInvalidDecl())
13196 return ExprError();
13197
13198 NamedDecl *Found = ND;
13199 if (E->getFoundDecl() != E->getDecl()) {
13200 Found = cast_or_null<NamedDecl>(
13201 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13202 if (!Found)
13203 return ExprError();
13204 }
13205
13206 DeclarationNameInfo NameInfo = E->getNameInfo();
13207 if (NameInfo.getName()) {
13208 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13209 if (!NameInfo.getName())
13210 return ExprError();
13211 }
13212
13213 if (!getDerived().AlwaysRebuild() &&
13214 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13215 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13216 Found == E->getFoundDecl() &&
13217 NameInfo.getName() == E->getDecl()->getDeclName() &&
13218 !E->hasExplicitTemplateArgs()) {
13219
13220 // Mark it referenced in the new context regardless.
13221 // FIXME: this is a bit instantiation-specific.
13222 SemaRef.MarkDeclRefReferenced(E);
13223
13224 return E;
13225 }
13226
13227 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13228 if (E->hasExplicitTemplateArgs()) {
13229 TemplateArgs = &TransArgs;
13230 TransArgs.setLAngleLoc(E->getLAngleLoc());
13231 TransArgs.setRAngleLoc(E->getRAngleLoc());
13232 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13233 E->getNumTemplateArgs(),
13234 TransArgs))
13235 return ExprError();
13236 }
13237
13238 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13239 Found, TemplateArgs);
13240}
13241
13242template<typename Derived>
13245 return E;
13246}
13247
13248template <typename Derived>
13250 FixedPointLiteral *E) {
13251 return E;
13252}
13253
13254template<typename Derived>
13257 return E;
13258}
13259
13260template<typename Derived>
13263 return E;
13264}
13265
13266template<typename Derived>
13269 return E;
13270}
13271
13272template<typename Derived>
13275 return E;
13276}
13277
13278template<typename Derived>
13281 return getDerived().TransformCallExpr(E);
13282}
13283
13284template<typename Derived>
13287 ExprResult ControllingExpr;
13288 TypeSourceInfo *ControllingType = nullptr;
13289 if (E->isExprPredicate())
13290 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13291 else
13292 ControllingType = getDerived().TransformType(E->getControllingType());
13293
13294 if (ControllingExpr.isInvalid() && !ControllingType)
13295 return ExprError();
13296
13297 SmallVector<Expr *, 4> AssocExprs;
13299 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13300 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13301 if (TSI) {
13302 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13303 if (!AssocType)
13304 return ExprError();
13305 AssocTypes.push_back(AssocType);
13306 } else {
13307 AssocTypes.push_back(nullptr);
13308 }
13309
13310 ExprResult AssocExpr =
13311 getDerived().TransformExpr(Assoc.getAssociationExpr());
13312 if (AssocExpr.isInvalid())
13313 return ExprError();
13314 AssocExprs.push_back(AssocExpr.get());
13315 }
13316
13317 if (!ControllingType)
13318 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13319 E->getDefaultLoc(),
13320 E->getRParenLoc(),
13321 ControllingExpr.get(),
13322 AssocTypes,
13323 AssocExprs);
13324 return getDerived().RebuildGenericSelectionExpr(
13325 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13326 ControllingType, AssocTypes, AssocExprs);
13327}
13328
13329template<typename Derived>
13332 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13333 if (SubExpr.isInvalid())
13334 return ExprError();
13335
13336 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13337 return E;
13338
13339 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13340 E->getRParen());
13341}
13342
13343/// The operand of a unary address-of operator has special rules: it's
13344/// allowed to refer to a non-static member of a class even if there's no 'this'
13345/// object available.
13346template<typename Derived>
13349 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13350 return getDerived().TransformDependentScopeDeclRefExpr(
13351 DRE, /*IsAddressOfOperand=*/true, nullptr);
13352 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13353 return getDerived().TransformUnresolvedLookupExpr(
13354 ULE, /*IsAddressOfOperand=*/true);
13355 else
13356 return getDerived().TransformExpr(E);
13357}
13358
13359template<typename Derived>
13362 ExprResult SubExpr;
13363 if (E->getOpcode() == UO_AddrOf)
13364 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13365 else
13366 SubExpr = TransformExpr(E->getSubExpr());
13367 if (SubExpr.isInvalid())
13368 return ExprError();
13369
13370 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13371 return E;
13372
13373 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13374 E->getOpcode(),
13375 SubExpr.get());
13376}
13377
13378template<typename Derived>
13380TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13381 // Transform the type.
13382 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13383 if (!Type)
13384 return ExprError();
13385
13386 // Transform all of the components into components similar to what the
13387 // parser uses.
13388 // FIXME: It would be slightly more efficient in the non-dependent case to
13389 // just map FieldDecls, rather than requiring the rebuilder to look for
13390 // the fields again. However, __builtin_offsetof is rare enough in
13391 // template code that we don't care.
13392 bool ExprChanged = false;
13393 typedef Sema::OffsetOfComponent Component;
13394 SmallVector<Component, 4> Components;
13395 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13396 const OffsetOfNode &ON = E->getComponent(I);
13397 Component Comp;
13398 Comp.isBrackets = true;
13399 Comp.LocStart = ON.getSourceRange().getBegin();
13400 Comp.LocEnd = ON.getSourceRange().getEnd();
13401 switch (ON.getKind()) {
13402 case OffsetOfNode::Array: {
13403 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13404 ExprResult Index = getDerived().TransformExpr(FromIndex);
13405 if (Index.isInvalid())
13406 return ExprError();
13407
13408 ExprChanged = ExprChanged || Index.get() != FromIndex;
13409 Comp.isBrackets = true;
13410 Comp.U.E = Index.get();
13411 break;
13412 }
13413
13416 Comp.isBrackets = false;
13417 Comp.U.IdentInfo = ON.getFieldName();
13418 if (!Comp.U.IdentInfo)
13419 continue;
13420
13421 break;
13422
13423 case OffsetOfNode::Base:
13424 // Will be recomputed during the rebuild.
13425 continue;
13426 }
13427
13428 Components.push_back(Comp);
13429 }
13430
13431 // If nothing changed, retain the existing expression.
13432 if (!getDerived().AlwaysRebuild() &&
13433 Type == E->getTypeSourceInfo() &&
13434 !ExprChanged)
13435 return E;
13436
13437 // Build a new offsetof expression.
13438 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13439 Components, E->getRParenLoc());
13440}
13441
13442template<typename Derived>
13445 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13446 "opaque value expression requires transformation");
13447 return E;
13448}
13449
13450template <typename Derived>
13453 bool Changed = false;
13454 for (Expr *C : E->subExpressions()) {
13455 ExprResult NewC = getDerived().TransformExpr(C);
13456 if (NewC.isInvalid())
13457 return ExprError();
13458 Children.push_back(NewC.get());
13459
13460 Changed |= NewC.get() != C;
13461 }
13462 if (!getDerived().AlwaysRebuild() && !Changed)
13463 return E;
13464 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13465 Children, E->getType());
13466}
13467
13468template<typename Derived>
13471 // Rebuild the syntactic form. The original syntactic form has
13472 // opaque-value expressions in it, so strip those away and rebuild
13473 // the result. This is a really awful way of doing this, but the
13474 // better solution (rebuilding the semantic expressions and
13475 // rebinding OVEs as necessary) doesn't work; we'd need
13476 // TreeTransform to not strip away implicit conversions.
13477 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13478 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13479 if (result.isInvalid()) return ExprError();
13480
13481 // If that gives us a pseudo-object result back, the pseudo-object
13482 // expression must have been an lvalue-to-rvalue conversion which we
13483 // should reapply.
13484 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13485 result = SemaRef.PseudoObject().checkRValue(result.get());
13486
13487 return result;
13488}
13489
13490template<typename Derived>
13494 if (E->isArgumentType()) {
13495 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13496
13497 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13498 if (!NewT)
13499 return ExprError();
13500
13501 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13502 return E;
13503
13504 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13505 E->getKind(),
13506 E->getSourceRange());
13507 }
13508
13509 // C++0x [expr.sizeof]p1:
13510 // The operand is either an expression, which is an unevaluated operand
13511 // [...]
13515
13516 // Try to recover if we have something like sizeof(T::X) where X is a type.
13517 // Notably, there must be *exactly* one set of parens if X is a type.
13518 TypeSourceInfo *RecoveryTSI = nullptr;
13519 ExprResult SubExpr;
13520 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13521 if (auto *DRE =
13522 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13523 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13524 PE, DRE, false, &RecoveryTSI);
13525 else
13526 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13527
13528 if (RecoveryTSI) {
13529 return getDerived().RebuildUnaryExprOrTypeTrait(
13530 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13531 } else if (SubExpr.isInvalid())
13532 return ExprError();
13533
13534 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13535 return E;
13536
13537 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13538 E->getOperatorLoc(),
13539 E->getKind(),
13540 E->getSourceRange());
13541}
13542
13543template<typename Derived>
13546 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13547 if (LHS.isInvalid())
13548 return ExprError();
13549
13550 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13551 if (RHS.isInvalid())
13552 return ExprError();
13553
13554
13555 if (!getDerived().AlwaysRebuild() &&
13556 LHS.get() == E->getLHS() &&
13557 RHS.get() == E->getRHS())
13558 return E;
13559
13560 return getDerived().RebuildArraySubscriptExpr(
13561 LHS.get(),
13562 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13563}
13564
13565template <typename Derived>
13568 ExprResult Base = getDerived().TransformExpr(E->getBase());
13569 if (Base.isInvalid())
13570 return ExprError();
13571
13572 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13573 if (RowIdx.isInvalid())
13574 return ExprError();
13575
13576 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13577 RowIdx.get() == E->getRowIdx())
13578 return E;
13579
13580 return getDerived().RebuildMatrixSingleSubscriptExpr(Base.get(), RowIdx.get(),
13581 E->getRBracketLoc());
13582}
13583
13584template <typename Derived>
13587 ExprResult Base = getDerived().TransformExpr(E->getBase());
13588 if (Base.isInvalid())
13589 return ExprError();
13590
13591 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13592 if (RowIdx.isInvalid())
13593 return ExprError();
13594
13595 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13596 if (ColumnIdx.isInvalid())
13597 return ExprError();
13598
13599 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13600 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13601 return E;
13602
13603 return getDerived().RebuildMatrixSubscriptExpr(
13604 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13605}
13606
13607template <typename Derived>
13610 ExprResult Base = getDerived().TransformExpr(E->getBase());
13611 if (Base.isInvalid())
13612 return ExprError();
13613
13614 ExprResult LowerBound;
13615 if (E->getLowerBound()) {
13616 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13617 if (LowerBound.isInvalid())
13618 return ExprError();
13619 }
13620
13621 ExprResult Length;
13622 if (E->getLength()) {
13623 Length = getDerived().TransformExpr(E->getLength());
13624 if (Length.isInvalid())
13625 return ExprError();
13626 }
13627
13628 ExprResult Stride;
13629 if (E->isOMPArraySection()) {
13630 if (Expr *Str = E->getStride()) {
13631 Stride = getDerived().TransformExpr(Str);
13632 if (Stride.isInvalid())
13633 return ExprError();
13634 }
13635 }
13636
13637 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13638 LowerBound.get() == E->getLowerBound() &&
13639 Length.get() == E->getLength() &&
13640 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13641 return E;
13642
13643 return getDerived().RebuildArraySectionExpr(
13644 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13645 LowerBound.get(), E->getColonLocFirst(),
13646 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13647 Length.get(), Stride.get(), E->getRBracketLoc());
13648}
13649
13650template <typename Derived>
13653 ExprResult Base = getDerived().TransformExpr(E->getBase());
13654 if (Base.isInvalid())
13655 return ExprError();
13656
13658 bool ErrorFound = false;
13659 for (Expr *Dim : E->getDimensions()) {
13660 ExprResult DimRes = getDerived().TransformExpr(Dim);
13661 if (DimRes.isInvalid()) {
13662 ErrorFound = true;
13663 continue;
13664 }
13665 Dims.push_back(DimRes.get());
13666 }
13667
13668 if (ErrorFound)
13669 return ExprError();
13670 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13671 E->getRParenLoc(), Dims,
13672 E->getBracketsRanges());
13673}
13674
13675template <typename Derived>
13678 unsigned NumIterators = E->numOfIterators();
13680
13681 bool ErrorFound = false;
13682 bool NeedToRebuild = getDerived().AlwaysRebuild();
13683 for (unsigned I = 0; I < NumIterators; ++I) {
13684 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13685 Data[I].DeclIdent = D->getIdentifier();
13686 Data[I].DeclIdentLoc = D->getLocation();
13687 if (D->getLocation() == D->getBeginLoc()) {
13688 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13689 "Implicit type must be int.");
13690 } else {
13691 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13692 QualType DeclTy = getDerived().TransformType(D->getType());
13693 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13694 }
13695 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13696 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13697 ExprResult End = getDerived().TransformExpr(Range.End);
13698 ExprResult Step = getDerived().TransformExpr(Range.Step);
13699 ErrorFound = ErrorFound ||
13700 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13701 !Data[I].Type.get().isNull())) ||
13702 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13703 if (ErrorFound)
13704 continue;
13705 Data[I].Range.Begin = Begin.get();
13706 Data[I].Range.End = End.get();
13707 Data[I].Range.Step = Step.get();
13708 Data[I].AssignLoc = E->getAssignLoc(I);
13709 Data[I].ColonLoc = E->getColonLoc(I);
13710 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13711 NeedToRebuild =
13712 NeedToRebuild ||
13713 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13714 D->getType().getTypePtrOrNull()) ||
13715 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13716 Range.Step != Data[I].Range.Step;
13717 }
13718 if (ErrorFound)
13719 return ExprError();
13720 if (!NeedToRebuild)
13721 return E;
13722
13723 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13724 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13725 if (!Res.isUsable())
13726 return Res;
13727 auto *IE = cast<OMPIteratorExpr>(Res.get());
13728 for (unsigned I = 0; I < NumIterators; ++I)
13729 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13730 IE->getIteratorDecl(I));
13731 return Res;
13732}
13733
13734template<typename Derived>
13737 // Transform the callee.
13738 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13739 if (Callee.isInvalid())
13740 return ExprError();
13741
13742 // Transform arguments.
13743 bool ArgChanged = false;
13745 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13746 &ArgChanged))
13747 return ExprError();
13748
13749 if (!getDerived().AlwaysRebuild() &&
13750 Callee.get() == E->getCallee() &&
13751 !ArgChanged)
13752 return SemaRef.MaybeBindToTemporary(E);
13753
13754 // FIXME: Wrong source location information for the '('.
13755 SourceLocation FakeLParenLoc
13756 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13757
13758 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13759 if (E->hasStoredFPFeatures()) {
13760 FPOptionsOverride NewOverrides = E->getFPFeatures();
13761 getSema().CurFPFeatures =
13762 NewOverrides.applyOverrides(getSema().getLangOpts());
13763 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13764 }
13765
13766 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13767 Args,
13768 E->getRParenLoc());
13769}
13770
13771template<typename Derived>
13774 ExprResult Base = getDerived().TransformExpr(E->getBase());
13775 if (Base.isInvalid())
13776 return ExprError();
13777
13778 NestedNameSpecifierLoc QualifierLoc;
13779 if (E->hasQualifier()) {
13780 QualifierLoc
13781 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13782
13783 if (!QualifierLoc)
13784 return ExprError();
13785 }
13786 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13787
13789 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13790 E->getMemberDecl()));
13791 if (!Member)
13792 return ExprError();
13793
13794 NamedDecl *FoundDecl = E->getFoundDecl();
13795 if (FoundDecl == E->getMemberDecl()) {
13796 FoundDecl = Member;
13797 } else {
13798 FoundDecl = cast_or_null<NamedDecl>(
13799 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13800 if (!FoundDecl)
13801 return ExprError();
13802 }
13803
13804 if (!getDerived().AlwaysRebuild() &&
13805 Base.get() == E->getBase() &&
13806 QualifierLoc == E->getQualifierLoc() &&
13807 Member == E->getMemberDecl() &&
13808 FoundDecl == E->getFoundDecl() &&
13809 !E->hasExplicitTemplateArgs()) {
13810
13811 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13812 // for Openmp where the field need to be privatizized in the case.
13813 if (!(isa<CXXThisExpr>(E->getBase()) &&
13814 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13816 // Mark it referenced in the new context regardless.
13817 // FIXME: this is a bit instantiation-specific.
13818 SemaRef.MarkMemberReferenced(E);
13819 return E;
13820 }
13821 }
13822
13823 TemplateArgumentListInfo TransArgs;
13824 if (E->hasExplicitTemplateArgs()) {
13825 TransArgs.setLAngleLoc(E->getLAngleLoc());
13826 TransArgs.setRAngleLoc(E->getRAngleLoc());
13827 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13828 E->getNumTemplateArgs(),
13829 TransArgs))
13830 return ExprError();
13831 }
13832
13833 // FIXME: Bogus source location for the operator
13834 SourceLocation FakeOperatorLoc =
13835 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13836
13837 // FIXME: to do this check properly, we will need to preserve the
13838 // first-qualifier-in-scope here, just in case we had a dependent
13839 // base (and therefore couldn't do the check) and a
13840 // nested-name-qualifier (and therefore could do the lookup).
13841 NamedDecl *FirstQualifierInScope = nullptr;
13842 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13843 if (MemberNameInfo.getName()) {
13844 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13845 if (!MemberNameInfo.getName())
13846 return ExprError();
13847 }
13848
13849 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13850 E->isArrow(),
13851 QualifierLoc,
13852 TemplateKWLoc,
13853 MemberNameInfo,
13854 Member,
13855 FoundDecl,
13856 (E->hasExplicitTemplateArgs()
13857 ? &TransArgs : nullptr),
13858 FirstQualifierInScope);
13859}
13860
13861template<typename Derived>
13864 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13865 if (LHS.isInvalid())
13866 return ExprError();
13867
13868 ExprResult RHS =
13869 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13870 if (RHS.isInvalid())
13871 return ExprError();
13872
13873 if (!getDerived().AlwaysRebuild() &&
13874 LHS.get() == E->getLHS() &&
13875 RHS.get() == E->getRHS())
13876 return E;
13877
13878 if (E->isCompoundAssignmentOp())
13879 // FPFeatures has already been established from trailing storage
13880 return getDerived().RebuildBinaryOperator(
13881 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13882 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13883 FPOptionsOverride NewOverrides(E->getFPFeatures());
13884 getSema().CurFPFeatures =
13885 NewOverrides.applyOverrides(getSema().getLangOpts());
13886 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13887 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13888 LHS.get(), RHS.get());
13889}
13890
13891template <typename Derived>
13894 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13895
13896 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13897 if (LHS.isInvalid())
13898 return ExprError();
13899
13900 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13901 if (RHS.isInvalid())
13902 return ExprError();
13903
13904 // Extract the already-resolved callee declarations so that we can restrict
13905 // ourselves to using them as the unqualified lookup results when rebuilding.
13906 UnresolvedSet<2> UnqualLookups;
13907 bool ChangedAnyLookups = false;
13908 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13909 const_cast<Expr *>(Decomp.InnerBinOp)};
13910 for (Expr *PossibleBinOp : PossibleBinOps) {
13911 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13912 if (!Op)
13913 continue;
13914 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13915 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13916 continue;
13917
13918 // Transform the callee in case we built a call to a local extern
13919 // declaration.
13920 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13921 E->getOperatorLoc(), Callee->getFoundDecl()));
13922 if (!Found)
13923 return ExprError();
13924 if (Found != Callee->getFoundDecl())
13925 ChangedAnyLookups = true;
13926 UnqualLookups.addDecl(Found);
13927 }
13928
13929 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13930 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13931 // Mark all functions used in the rewrite as referenced. Note that when
13932 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13933 // function calls, and/or there might be a user-defined conversion sequence
13934 // applied to the operands of the <.
13935 // FIXME: this is a bit instantiation-specific.
13936 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13937 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13938 return E;
13939 }
13940
13941 return getDerived().RebuildCXXRewrittenBinaryOperator(
13942 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13943}
13944
13945template<typename Derived>
13949 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13950 FPOptionsOverride NewOverrides(E->getFPFeatures());
13951 getSema().CurFPFeatures =
13952 NewOverrides.applyOverrides(getSema().getLangOpts());
13953 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13954 return getDerived().TransformBinaryOperator(E);
13955}
13956
13957template<typename Derived>
13960 // Just rebuild the common and RHS expressions and see whether we
13961 // get any changes.
13962
13963 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13964 if (commonExpr.isInvalid())
13965 return ExprError();
13966
13967 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13968 if (rhs.isInvalid())
13969 return ExprError();
13970
13971 if (!getDerived().AlwaysRebuild() &&
13972 commonExpr.get() == e->getCommon() &&
13973 rhs.get() == e->getFalseExpr())
13974 return e;
13975
13976 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13977 e->getQuestionLoc(),
13978 nullptr,
13979 e->getColonLoc(),
13980 rhs.get());
13981}
13982
13983template<typename Derived>
13986 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13987 if (Cond.isInvalid())
13988 return ExprError();
13989
13990 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13991 if (LHS.isInvalid())
13992 return ExprError();
13993
13994 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13995 if (RHS.isInvalid())
13996 return ExprError();
13997
13998 if (!getDerived().AlwaysRebuild() &&
13999 Cond.get() == E->getCond() &&
14000 LHS.get() == E->getLHS() &&
14001 RHS.get() == E->getRHS())
14002 return E;
14003
14004 return getDerived().RebuildConditionalOperator(Cond.get(),
14005 E->getQuestionLoc(),
14006 LHS.get(),
14007 E->getColonLoc(),
14008 RHS.get());
14009}
14010
14011template<typename Derived>
14014 // Implicit casts are eliminated during transformation, since they
14015 // will be recomputed by semantic analysis after transformation.
14016 return getDerived().TransformExpr(E->getSubExprAsWritten());
14017}
14018
14019template<typename Derived>
14022 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14023 if (!Type)
14024 return ExprError();
14025
14026 ExprResult SubExpr
14027 = getDerived().TransformExpr(E->getSubExprAsWritten());
14028 if (SubExpr.isInvalid())
14029 return ExprError();
14030
14031 if (!getDerived().AlwaysRebuild() &&
14032 Type == E->getTypeInfoAsWritten() &&
14033 SubExpr.get() == E->getSubExpr())
14034 return E;
14035
14036 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
14037 Type,
14038 E->getRParenLoc(),
14039 SubExpr.get());
14040}
14041
14042template<typename Derived>
14045 TypeSourceInfo *OldT = E->getTypeSourceInfo();
14046 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
14047 if (!NewT)
14048 return ExprError();
14049
14050 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
14051 if (Init.isInvalid())
14052 return ExprError();
14053
14054 if (!getDerived().AlwaysRebuild() &&
14055 OldT == NewT &&
14056 Init.get() == E->getInitializer())
14057 return SemaRef.MaybeBindToTemporary(E);
14058
14059 // Note: the expression type doesn't necessarily match the
14060 // type-as-written, but that's okay, because it should always be
14061 // derivable from the initializer.
14062
14063 return getDerived().RebuildCompoundLiteralExpr(
14064 E->getLParenLoc(), NewT,
14065 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
14066}
14067
14068template<typename Derived>
14071 ExprResult Base = getDerived().TransformExpr(E->getBase());
14072 if (Base.isInvalid())
14073 return ExprError();
14074
14075 if (!getDerived().AlwaysRebuild() &&
14076 Base.get() == E->getBase())
14077 return E;
14078
14079 // FIXME: Bad source location
14080 SourceLocation FakeOperatorLoc =
14081 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14082 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14083 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
14084 E->getAccessor());
14085}
14086
14087template <typename Derived>
14090 ExprResult Base = getDerived().TransformExpr(E->getBase());
14091 if (Base.isInvalid())
14092 return ExprError();
14093
14094 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase())
14095 return E;
14096
14097 // FIXME: Bad source location
14098 SourceLocation FakeOperatorLoc =
14099 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14100 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14101 Base.get(), FakeOperatorLoc, /*isArrow*/ false, E->getAccessorLoc(),
14102 E->getAccessor());
14103}
14104
14105template<typename Derived>
14108 if (InitListExpr *Syntactic = E->getSyntacticForm())
14109 E = Syntactic;
14110
14111 bool InitChanged = false;
14112
14115
14117 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
14118 Inits, &InitChanged))
14119 return ExprError();
14120
14121 if (!getDerived().AlwaysRebuild() && !InitChanged) {
14122 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
14123 // in some cases. We can't reuse it in general, because the syntactic and
14124 // semantic forms are linked, and we can't know that semantic form will
14125 // match even if the syntactic form does.
14126 }
14127
14128 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
14129 E->getRBraceLoc());
14130}
14131
14132template<typename Derived>
14135 Designation Desig;
14136
14137 // transform the initializer value
14138 ExprResult Init = getDerived().TransformExpr(E->getInit());
14139 if (Init.isInvalid())
14140 return ExprError();
14141
14142 // transform the designators.
14143 SmallVector<Expr*, 4> ArrayExprs;
14144 bool ExprChanged = false;
14145 for (const DesignatedInitExpr::Designator &D : E->designators()) {
14146 if (D.isFieldDesignator()) {
14147 if (D.getFieldDecl()) {
14148 FieldDecl *Field = cast_or_null<FieldDecl>(
14149 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
14150 if (Field != D.getFieldDecl())
14151 // Rebuild the expression when the transformed FieldDecl is
14152 // different to the already assigned FieldDecl.
14153 ExprChanged = true;
14154 if (Field->isAnonymousStructOrUnion())
14155 continue;
14156 } else {
14157 // Ensure that the designator expression is rebuilt when there isn't
14158 // a resolved FieldDecl in the designator as we don't want to assign
14159 // a FieldDecl to a pattern designator that will be instantiated again.
14160 ExprChanged = true;
14161 }
14162 Desig.AddDesignator(Designator::CreateFieldDesignator(
14163 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
14164 continue;
14165 }
14166
14167 if (D.isArrayDesignator()) {
14168 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
14169 if (Index.isInvalid())
14170 return ExprError();
14171
14172 Desig.AddDesignator(
14173 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
14174
14175 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
14176 ArrayExprs.push_back(Index.get());
14177 continue;
14178 }
14179
14180 assert(D.isArrayRangeDesignator() && "New kind of designator?");
14181 ExprResult Start
14182 = getDerived().TransformExpr(E->getArrayRangeStart(D));
14183 if (Start.isInvalid())
14184 return ExprError();
14185
14186 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
14187 if (End.isInvalid())
14188 return ExprError();
14189
14190 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
14191 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
14192
14193 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
14194 End.get() != E->getArrayRangeEnd(D);
14195
14196 ArrayExprs.push_back(Start.get());
14197 ArrayExprs.push_back(End.get());
14198 }
14199
14200 if (!getDerived().AlwaysRebuild() &&
14201 Init.get() == E->getInit() &&
14202 !ExprChanged)
14203 return E;
14204
14205 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14206 E->getEqualOrColonLoc(),
14207 E->usesGNUSyntax(), Init.get());
14208}
14209
14210// Seems that if TransformInitListExpr() only works on the syntactic form of an
14211// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14212template<typename Derived>
14216 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14217 "initializer");
14218 return ExprError();
14219}
14220
14221template<typename Derived>
14224 NoInitExpr *E) {
14225 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14226 return ExprError();
14227}
14228
14229template<typename Derived>
14232 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14233 return ExprError();
14234}
14235
14236template<typename Derived>
14239 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14240 return ExprError();
14241}
14242
14243template<typename Derived>
14247 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14248
14249 // FIXME: Will we ever have proper type location here? Will we actually
14250 // need to transform the type?
14251 QualType T = getDerived().TransformType(E->getType());
14252 if (T.isNull())
14253 return ExprError();
14254
14255 if (!getDerived().AlwaysRebuild() &&
14256 T == E->getType())
14257 return E;
14258
14259 return getDerived().RebuildImplicitValueInitExpr(T);
14260}
14261
14262template<typename Derived>
14265 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14266 if (!TInfo)
14267 return ExprError();
14268
14269 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14270 if (SubExpr.isInvalid())
14271 return ExprError();
14272
14273 if (!getDerived().AlwaysRebuild() &&
14274 TInfo == E->getWrittenTypeInfo() &&
14275 SubExpr.get() == E->getSubExpr())
14276 return E;
14277
14278 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14279 TInfo, E->getRParenLoc());
14280}
14281
14282template<typename Derived>
14285 bool ArgumentChanged = false;
14287 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14288 &ArgumentChanged))
14289 return ExprError();
14290
14291 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14292 Inits,
14293 E->getRParenLoc());
14294}
14295
14296/// Transform an address-of-label expression.
14297///
14298/// By default, the transformation of an address-of-label expression always
14299/// rebuilds the expression, so that the label identifier can be resolved to
14300/// the corresponding label statement by semantic analysis.
14301template<typename Derived>
14304 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14305 E->getLabel());
14306 if (!LD)
14307 return ExprError();
14308
14309 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14310 cast<LabelDecl>(LD));
14311}
14312
14313template<typename Derived>
14316 SemaRef.ActOnStartStmtExpr();
14317 StmtResult SubStmt
14318 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14319 if (SubStmt.isInvalid()) {
14320 SemaRef.ActOnStmtExprError();
14321 return ExprError();
14322 }
14323
14324 unsigned OldDepth = E->getTemplateDepth();
14325 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14326
14327 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14328 SubStmt.get() == E->getSubStmt()) {
14329 // Calling this an 'error' is unintuitive, but it does the right thing.
14330 SemaRef.ActOnStmtExprError();
14331 return SemaRef.MaybeBindToTemporary(E);
14332 }
14333
14334 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14335 E->getRParenLoc(), NewDepth);
14336}
14337
14338template<typename Derived>
14341 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14342 if (Cond.isInvalid())
14343 return ExprError();
14344
14345 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14346 if (LHS.isInvalid())
14347 return ExprError();
14348
14349 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14350 if (RHS.isInvalid())
14351 return ExprError();
14352
14353 if (!getDerived().AlwaysRebuild() &&
14354 Cond.get() == E->getCond() &&
14355 LHS.get() == E->getLHS() &&
14356 RHS.get() == E->getRHS())
14357 return E;
14358
14359 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14360 Cond.get(), LHS.get(), RHS.get(),
14361 E->getRParenLoc());
14362}
14363
14364template<typename Derived>
14367 return E;
14368}
14369
14370template<typename Derived>
14373 switch (E->getOperator()) {
14374 case OO_New:
14375 case OO_Delete:
14376 case OO_Array_New:
14377 case OO_Array_Delete:
14378 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14379
14380 case OO_Subscript:
14381 case OO_Call: {
14382 // This is a call to an object's operator().
14383 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14384
14385 // Transform the object itself.
14386 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14387 if (Object.isInvalid())
14388 return ExprError();
14389
14390 // FIXME: Poor location information. Also, if the location for the end of
14391 // the token is within a macro expansion, getLocForEndOfToken() will return
14392 // an invalid source location. If that happens and we have an otherwise
14393 // valid end location, use the valid one instead of the invalid one.
14394 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14395 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14396 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14397 FakeLParenLoc = EndLoc;
14398
14399 // Transform the call arguments.
14401 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14402 Args))
14403 return ExprError();
14404
14405 if (E->getOperator() == OO_Subscript)
14406 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14407 Args, E->getEndLoc());
14408
14409 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14410 E->getEndLoc());
14411 }
14412
14413#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14414 case OO_##Name: \
14415 break;
14416
14417#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14418#include "clang/Basic/OperatorKinds.def"
14419
14420 case OO_Conditional:
14421 llvm_unreachable("conditional operator is not actually overloadable");
14422
14423 case OO_None:
14425 llvm_unreachable("not an overloaded operator?");
14426 }
14427
14429 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14430 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14431 else
14432 First = getDerived().TransformExpr(E->getArg(0));
14433 if (First.isInvalid())
14434 return ExprError();
14435
14436 ExprResult Second;
14437 if (E->getNumArgs() == 2) {
14438 Second =
14439 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14440 if (Second.isInvalid())
14441 return ExprError();
14442 }
14443
14444 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14445 FPOptionsOverride NewOverrides(E->getFPFeatures());
14446 getSema().CurFPFeatures =
14447 NewOverrides.applyOverrides(getSema().getLangOpts());
14448 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14449
14450 Expr *Callee = E->getCallee();
14451 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14452 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14454 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14455 return ExprError();
14456
14457 return getDerived().RebuildCXXOperatorCallExpr(
14458 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14459 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14460 }
14461
14462 UnresolvedSet<1> Functions;
14463 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14464 Callee = ICE->getSubExprAsWritten();
14465 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14466 ValueDecl *VD = cast_or_null<ValueDecl>(
14467 getDerived().TransformDecl(DR->getLocation(), DR));
14468 if (!VD)
14469 return ExprError();
14470
14471 if (!isa<CXXMethodDecl>(VD))
14472 Functions.addDecl(VD);
14473
14474 return getDerived().RebuildCXXOperatorCallExpr(
14475 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14476 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14477}
14478
14479template<typename Derived>
14482 return getDerived().TransformCallExpr(E);
14483}
14484
14485template <typename Derived>
14487 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14488 getSema().CurContext != E->getParentContext();
14489
14490 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14491 return E;
14492
14493 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14494 E->getBeginLoc(), E->getEndLoc(),
14495 getSema().CurContext);
14496}
14497
14498template <typename Derived>
14500 return E;
14501}
14502
14503template<typename Derived>
14506 // Transform the callee.
14507 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14508 if (Callee.isInvalid())
14509 return ExprError();
14510
14511 // Transform exec config.
14512 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14513 if (EC.isInvalid())
14514 return ExprError();
14515
14516 // Transform arguments.
14517 bool ArgChanged = false;
14519 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14520 &ArgChanged))
14521 return ExprError();
14522
14523 if (!getDerived().AlwaysRebuild() &&
14524 Callee.get() == E->getCallee() &&
14525 !ArgChanged)
14526 return SemaRef.MaybeBindToTemporary(E);
14527
14528 // FIXME: Wrong source location information for the '('.
14529 SourceLocation FakeLParenLoc
14530 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14531 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14532 Args,
14533 E->getRParenLoc(), EC.get());
14534}
14535
14536template<typename Derived>
14539 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14540 if (!Type)
14541 return ExprError();
14542
14543 ExprResult SubExpr
14544 = getDerived().TransformExpr(E->getSubExprAsWritten());
14545 if (SubExpr.isInvalid())
14546 return ExprError();
14547
14548 if (!getDerived().AlwaysRebuild() &&
14549 Type == E->getTypeInfoAsWritten() &&
14550 SubExpr.get() == E->getSubExpr())
14551 return E;
14552 return getDerived().RebuildCXXNamedCastExpr(
14555 // FIXME. this should be '(' location
14556 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14557}
14558
14559template<typename Derived>
14562 TypeSourceInfo *TSI =
14563 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14564 if (!TSI)
14565 return ExprError();
14566
14567 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14568 if (Sub.isInvalid())
14569 return ExprError();
14570
14571 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14572 Sub.get(), BCE->getEndLoc());
14573}
14574
14575template<typename Derived>
14577TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14578 return getDerived().TransformCXXNamedCastExpr(E);
14579}
14580
14581template<typename Derived>
14584 return getDerived().TransformCXXNamedCastExpr(E);
14585}
14586
14587template<typename Derived>
14591 return getDerived().TransformCXXNamedCastExpr(E);
14592}
14593
14594template<typename Derived>
14597 return getDerived().TransformCXXNamedCastExpr(E);
14598}
14599
14600template<typename Derived>
14603 return getDerived().TransformCXXNamedCastExpr(E);
14604}
14605
14606template<typename Derived>
14611 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14612 if (!Type)
14613 return ExprError();
14614
14615 ExprResult SubExpr
14616 = getDerived().TransformExpr(E->getSubExprAsWritten());
14617 if (SubExpr.isInvalid())
14618 return ExprError();
14619
14620 if (!getDerived().AlwaysRebuild() &&
14621 Type == E->getTypeInfoAsWritten() &&
14622 SubExpr.get() == E->getSubExpr())
14623 return E;
14624
14625 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14626 E->getLParenLoc(),
14627 SubExpr.get(),
14628 E->getRParenLoc(),
14629 E->isListInitialization());
14630}
14631
14632template<typename Derived>
14635 if (E->isTypeOperand()) {
14636 TypeSourceInfo *TInfo
14637 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14638 if (!TInfo)
14639 return ExprError();
14640
14641 if (!getDerived().AlwaysRebuild() &&
14642 TInfo == E->getTypeOperandSourceInfo())
14643 return E;
14644
14645 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14646 TInfo, E->getEndLoc());
14647 }
14648
14649 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14650 // type. We must not unilaterally enter unevaluated context here, as then
14651 // semantic processing can re-transform an already transformed operand.
14652 Expr *Op = E->getExprOperand();
14654 if (E->isGLValue()) {
14655 QualType OpType = Op->getType();
14656 if (auto *RD = OpType->getAsCXXRecordDecl()) {
14657 if (SemaRef.RequireCompleteType(E->getBeginLoc(), OpType,
14658 diag::err_incomplete_typeid))
14659 return ExprError();
14660
14661 if (RD->isPolymorphic())
14662 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14663 }
14664 }
14665
14668
14669 ExprResult SubExpr = getDerived().TransformExpr(Op);
14670 if (SubExpr.isInvalid())
14671 return ExprError();
14672
14673 if (!getDerived().AlwaysRebuild() &&
14674 SubExpr.get() == E->getExprOperand())
14675 return E;
14676
14677 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14678 SubExpr.get(), E->getEndLoc());
14679}
14680
14681template<typename Derived>
14684 if (E->isTypeOperand()) {
14685 TypeSourceInfo *TInfo
14686 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14687 if (!TInfo)
14688 return ExprError();
14689
14690 if (!getDerived().AlwaysRebuild() &&
14691 TInfo == E->getTypeOperandSourceInfo())
14692 return E;
14693
14694 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14695 TInfo, E->getEndLoc());
14696 }
14697
14700
14701 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14702 if (SubExpr.isInvalid())
14703 return ExprError();
14704
14705 if (!getDerived().AlwaysRebuild() &&
14706 SubExpr.get() == E->getExprOperand())
14707 return E;
14708
14709 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14710 SubExpr.get(), E->getEndLoc());
14711}
14712
14713template<typename Derived>
14716 return E;
14717}
14718
14719template<typename Derived>
14723 return E;
14724}
14725
14726template<typename Derived>
14729
14730 // In lambdas, the qualifiers of the type depends of where in
14731 // the call operator `this` appear, and we do not have a good way to
14732 // rebuild this information, so we transform the type.
14733 //
14734 // In other contexts, the type of `this` may be overrided
14735 // for type deduction, so we need to recompute it.
14736 //
14737 // Always recompute the type if we're in the body of a lambda, and
14738 // 'this' is dependent on a lambda's explicit object parameter; we
14739 // also need to always rebuild the expression in this case to clear
14740 // the flag.
14741 QualType T = [&]() {
14742 auto &S = getSema();
14743 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14744 return S.getCurrentThisType();
14745 if (S.getCurLambda())
14746 return getDerived().TransformType(E->getType());
14747 return S.getCurrentThisType();
14748 }();
14749
14750 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14751 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14752 // Mark it referenced in the new context regardless.
14753 // FIXME: this is a bit instantiation-specific.
14754 getSema().MarkThisReferenced(E);
14755 return E;
14756 }
14757
14758 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14759}
14760
14761template<typename Derived>
14764 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14765 if (SubExpr.isInvalid())
14766 return ExprError();
14767
14768 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14769
14770 if (!getDerived().AlwaysRebuild() &&
14771 SubExpr.get() == E->getSubExpr())
14772 return E;
14773
14774 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14775 E->isThrownVariableInScope());
14776}
14777
14778template<typename Derived>
14781 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14782 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14783 if (!Param)
14784 return ExprError();
14785
14786 ExprResult InitRes;
14787 if (E->hasRewrittenInit()) {
14788 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14789 if (InitRes.isInvalid())
14790 return ExprError();
14791 }
14792
14793 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14794 E->getUsedContext() == SemaRef.CurContext &&
14795 InitRes.get() == E->getRewrittenExpr())
14796 return E;
14797
14798 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14799 InitRes.get());
14800}
14801
14802template<typename Derived>
14805 FieldDecl *Field = cast_or_null<FieldDecl>(
14806 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14807 if (!Field)
14808 return ExprError();
14809
14810 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14811 E->getUsedContext() == SemaRef.CurContext)
14812 return E;
14813
14814 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14815}
14816
14817template<typename Derived>
14821 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14822 if (!T)
14823 return ExprError();
14824
14825 if (!getDerived().AlwaysRebuild() &&
14826 T == E->getTypeSourceInfo())
14827 return E;
14828
14829 return getDerived().RebuildCXXScalarValueInitExpr(T,
14830 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14831 E->getRParenLoc());
14832}
14833
14834template<typename Derived>
14837 // Transform the type that we're allocating
14838 TypeSourceInfo *AllocTypeInfo =
14839 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14840 if (!AllocTypeInfo)
14841 return ExprError();
14842
14843 // Transform the size of the array we're allocating (if any).
14844 std::optional<Expr *> ArraySize;
14845 if (E->isArray()) {
14846 ExprResult NewArraySize;
14847 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14848 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14849 if (NewArraySize.isInvalid())
14850 return ExprError();
14851 }
14852 ArraySize = NewArraySize.get();
14853 }
14854
14855 // Transform the placement arguments (if any).
14856 bool ArgumentChanged = false;
14857 SmallVector<Expr*, 8> PlacementArgs;
14858 if (getDerived().TransformExprs(E->getPlacementArgs(),
14859 E->getNumPlacementArgs(), true,
14860 PlacementArgs, &ArgumentChanged))
14861 return ExprError();
14862
14863 // Transform the initializer (if any).
14864 Expr *OldInit = E->getInitializer();
14865 ExprResult NewInit;
14866 if (OldInit)
14867 NewInit = getDerived().TransformInitializer(OldInit, true);
14868 if (NewInit.isInvalid())
14869 return ExprError();
14870
14871 // Transform new operator and delete operator.
14872 FunctionDecl *OperatorNew = nullptr;
14873 if (E->getOperatorNew()) {
14874 OperatorNew = cast_or_null<FunctionDecl>(
14875 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14876 if (!OperatorNew)
14877 return ExprError();
14878 }
14879
14880 FunctionDecl *OperatorDelete = nullptr;
14881 if (E->getOperatorDelete()) {
14882 OperatorDelete = cast_or_null<FunctionDecl>(
14883 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14884 if (!OperatorDelete)
14885 return ExprError();
14886 }
14887
14888 if (!getDerived().AlwaysRebuild() &&
14889 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14890 ArraySize == E->getArraySize() &&
14891 NewInit.get() == OldInit &&
14892 OperatorNew == E->getOperatorNew() &&
14893 OperatorDelete == E->getOperatorDelete() &&
14894 !ArgumentChanged) {
14895 // Mark any declarations we need as referenced.
14896 // FIXME: instantiation-specific.
14897 if (OperatorNew)
14898 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14899 if (OperatorDelete)
14900 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14901
14902 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14903 QualType ElementType
14904 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14905 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14907 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14908 }
14909 }
14910
14911 return E;
14912 }
14913
14914 QualType AllocType = AllocTypeInfo->getType();
14915 if (!ArraySize) {
14916 // If no array size was specified, but the new expression was
14917 // instantiated with an array type (e.g., "new T" where T is
14918 // instantiated with "int[4]"), extract the outer bound from the
14919 // array type as our array size. We do this with constant and
14920 // dependently-sized array types.
14921 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14922 if (!ArrayT) {
14923 // Do nothing
14924 } else if (const ConstantArrayType *ConsArrayT
14925 = dyn_cast<ConstantArrayType>(ArrayT)) {
14926 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14927 SemaRef.Context.getSizeType(),
14928 /*FIXME:*/ E->getBeginLoc());
14929 AllocType = ConsArrayT->getElementType();
14930 } else if (const DependentSizedArrayType *DepArrayT
14931 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14932 if (DepArrayT->getSizeExpr()) {
14933 ArraySize = DepArrayT->getSizeExpr();
14934 AllocType = DepArrayT->getElementType();
14935 }
14936 }
14937 }
14938
14939 return getDerived().RebuildCXXNewExpr(
14940 E->getBeginLoc(), E->isGlobalNew(),
14941 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14942 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14943 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14944}
14945
14946template<typename Derived>
14949 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14950 if (Operand.isInvalid())
14951 return ExprError();
14952
14953 // Transform the delete operator, if known.
14954 FunctionDecl *OperatorDelete = nullptr;
14955 if (E->getOperatorDelete()) {
14956 OperatorDelete = cast_or_null<FunctionDecl>(
14957 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14958 if (!OperatorDelete)
14959 return ExprError();
14960 }
14961
14962 if (!getDerived().AlwaysRebuild() &&
14963 Operand.get() == E->getArgument() &&
14964 OperatorDelete == E->getOperatorDelete()) {
14965 // Mark any declarations we need as referenced.
14966 // FIXME: instantiation-specific.
14967 if (OperatorDelete)
14968 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14969
14970 if (!E->getArgument()->isTypeDependent()) {
14972 E->getDestroyedType());
14973 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14974 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14975 SemaRef.LookupDestructor(Record));
14976 }
14977
14978 return E;
14979 }
14980
14981 return getDerived().RebuildCXXDeleteExpr(
14982 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14983}
14984
14985template<typename Derived>
14989 ExprResult Base = getDerived().TransformExpr(E->getBase());
14990 if (Base.isInvalid())
14991 return ExprError();
14992
14993 ParsedType ObjectTypePtr;
14994 bool MayBePseudoDestructor = false;
14995 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14996 E->getOperatorLoc(),
14997 E->isArrow()? tok::arrow : tok::period,
14998 ObjectTypePtr,
14999 MayBePseudoDestructor);
15000 if (Base.isInvalid())
15001 return ExprError();
15002
15003 QualType ObjectType = ObjectTypePtr.get();
15004 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
15005 if (QualifierLoc) {
15006 QualifierLoc
15007 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
15008 if (!QualifierLoc)
15009 return ExprError();
15010 }
15011 CXXScopeSpec SS;
15012 SS.Adopt(QualifierLoc);
15013
15015 if (E->getDestroyedTypeInfo()) {
15016 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
15017 E->getDestroyedTypeInfo(), ObjectType,
15018 /*FirstQualifierInScope=*/nullptr);
15019 if (!DestroyedTypeInfo)
15020 return ExprError();
15021 Destroyed = DestroyedTypeInfo;
15022 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
15023 // We aren't likely to be able to resolve the identifier down to a type
15024 // now anyway, so just retain the identifier.
15025 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
15026 E->getDestroyedTypeLoc());
15027 } else {
15028 // Look for a destructor known with the given name.
15029 ParsedType T = SemaRef.getDestructorName(
15030 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
15031 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
15032 if (!T)
15033 return ExprError();
15034
15035 Destroyed
15037 E->getDestroyedTypeLoc());
15038 }
15039
15040 TypeSourceInfo *ScopeTypeInfo = nullptr;
15041 if (E->getScopeTypeInfo()) {
15042 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
15043 E->getScopeTypeInfo(), ObjectType, nullptr);
15044 if (!ScopeTypeInfo)
15045 return ExprError();
15046 }
15047
15048 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
15049 E->getOperatorLoc(),
15050 E->isArrow(),
15051 SS,
15052 ScopeTypeInfo,
15053 E->getColonColonLoc(),
15054 E->getTildeLoc(),
15055 Destroyed);
15056}
15057
15058template <typename Derived>
15060 bool RequiresADL,
15061 LookupResult &R) {
15062 // Transform all the decls.
15063 bool AllEmptyPacks = true;
15064 for (auto *OldD : Old->decls()) {
15065 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
15066 if (!InstD) {
15067 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
15068 // This can happen because of dependent hiding.
15069 if (isa<UsingShadowDecl>(OldD))
15070 continue;
15071 else {
15072 R.clear();
15073 return true;
15074 }
15075 }
15076
15077 // Expand using pack declarations.
15078 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
15079 ArrayRef<NamedDecl*> Decls = SingleDecl;
15080 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
15081 Decls = UPD->expansions();
15082
15083 // Expand using declarations.
15084 for (auto *D : Decls) {
15085 if (auto *UD = dyn_cast<UsingDecl>(D)) {
15086 for (auto *SD : UD->shadows())
15087 R.addDecl(SD);
15088 } else {
15089 R.addDecl(D);
15090 }
15091 }
15092
15093 AllEmptyPacks &= Decls.empty();
15094 }
15095
15096 // C++ [temp.res]/8.4.2:
15097 // The program is ill-formed, no diagnostic required, if [...] lookup for
15098 // a name in the template definition found a using-declaration, but the
15099 // lookup in the corresponding scope in the instantiation odoes not find
15100 // any declarations because the using-declaration was a pack expansion and
15101 // the corresponding pack is empty
15102 if (AllEmptyPacks && !RequiresADL) {
15103 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
15104 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
15105 return true;
15106 }
15107
15108 // Resolve a kind, but don't do any further analysis. If it's
15109 // ambiguous, the callee needs to deal with it.
15110 R.resolveKind();
15111
15112 if (Old->hasTemplateKeyword() && !R.empty()) {
15113 NamedDecl *FoundDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
15114 getSema().FilterAcceptableTemplateNames(R,
15115 /*AllowFunctionTemplates=*/true,
15116 /*AllowDependent=*/true);
15117 if (R.empty()) {
15118 // If a 'template' keyword was used, a lookup that finds only non-template
15119 // names is an error.
15120 getSema().Diag(R.getNameLoc(),
15121 diag::err_template_kw_refers_to_non_template)
15122 << R.getLookupName() << Old->getQualifierLoc().getSourceRange()
15123 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
15124 getSema().Diag(FoundDecl->getLocation(),
15125 diag::note_template_kw_refers_to_non_template)
15126 << R.getLookupName();
15127 return true;
15128 }
15129 }
15130
15131 return false;
15132}
15133
15134template <typename Derived>
15139
15140template <typename Derived>
15143 bool IsAddressOfOperand) {
15144 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
15146
15147 // Transform the declaration set.
15148 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
15149 return ExprError();
15150
15151 // Rebuild the nested-name qualifier, if present.
15152 CXXScopeSpec SS;
15153 if (Old->getQualifierLoc()) {
15154 NestedNameSpecifierLoc QualifierLoc
15155 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
15156 if (!QualifierLoc)
15157 return ExprError();
15158
15159 SS.Adopt(QualifierLoc);
15160 }
15161
15162 if (Old->getNamingClass()) {
15163 CXXRecordDecl *NamingClass
15164 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
15165 Old->getNameLoc(),
15166 Old->getNamingClass()));
15167 if (!NamingClass) {
15168 R.clear();
15169 return ExprError();
15170 }
15171
15172 R.setNamingClass(NamingClass);
15173 }
15174
15175 // Rebuild the template arguments, if any.
15176 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
15177 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
15178 if (Old->hasExplicitTemplateArgs() &&
15179 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15180 Old->getNumTemplateArgs(),
15181 TransArgs)) {
15182 R.clear();
15183 return ExprError();
15184 }
15185
15186 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
15187 // a non-static data member is named in an unevaluated operand, or when
15188 // a member is named in a dependent class scope function template explicit
15189 // specialization that is neither declared static nor with an explicit object
15190 // parameter.
15191 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
15192 return SemaRef.BuildPossibleImplicitMemberExpr(
15193 SS, TemplateKWLoc, R,
15194 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
15195 /*S=*/nullptr);
15196
15197 // If we have neither explicit template arguments, nor the template keyword,
15198 // it's a normal declaration name or member reference.
15199 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
15200 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
15201
15202 // If we have template arguments, then rebuild the template-id expression.
15203 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
15204 Old->requiresADL(), &TransArgs);
15205}
15206
15207template<typename Derived>
15210 bool ArgChanged = false;
15212 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15213 TypeSourceInfo *From = E->getArg(I);
15214 TypeLoc FromTL = From->getTypeLoc();
15215 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15216 TypeLocBuilder TLB;
15217 TLB.reserve(FromTL.getFullDataSize());
15218 QualType To = getDerived().TransformType(TLB, FromTL);
15219 if (To.isNull())
15220 return ExprError();
15221
15222 if (To == From->getType())
15223 Args.push_back(From);
15224 else {
15225 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15226 ArgChanged = true;
15227 }
15228 continue;
15229 }
15230
15231 ArgChanged = true;
15232
15233 // We have a pack expansion. Instantiate it.
15234 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15235 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15237 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15238
15239 // Determine whether the set of unexpanded parameter packs can and should
15240 // be expanded.
15241 bool Expand = true;
15242 bool RetainExpansion = false;
15243 UnsignedOrNone OrigNumExpansions =
15244 ExpansionTL.getTypePtr()->getNumExpansions();
15245 UnsignedOrNone NumExpansions = OrigNumExpansions;
15246 if (getDerived().TryExpandParameterPacks(
15247 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15248 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15249 RetainExpansion, NumExpansions))
15250 return ExprError();
15251
15252 if (!Expand) {
15253 // The transform has determined that we should perform a simple
15254 // transformation on the pack expansion, producing another pack
15255 // expansion.
15256 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15257
15258 TypeLocBuilder TLB;
15259 TLB.reserve(From->getTypeLoc().getFullDataSize());
15260
15261 QualType To = getDerived().TransformType(TLB, PatternTL);
15262 if (To.isNull())
15263 return ExprError();
15264
15265 To = getDerived().RebuildPackExpansionType(To,
15266 PatternTL.getSourceRange(),
15267 ExpansionTL.getEllipsisLoc(),
15268 NumExpansions);
15269 if (To.isNull())
15270 return ExprError();
15271
15272 PackExpansionTypeLoc ToExpansionTL
15273 = TLB.push<PackExpansionTypeLoc>(To);
15274 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15275 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15276 continue;
15277 }
15278
15279 // Expand the pack expansion by substituting for each argument in the
15280 // pack(s).
15281 for (unsigned I = 0; I != *NumExpansions; ++I) {
15282 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15283 TypeLocBuilder TLB;
15284 TLB.reserve(PatternTL.getFullDataSize());
15285 QualType To = getDerived().TransformType(TLB, PatternTL);
15286 if (To.isNull())
15287 return ExprError();
15288
15289 if (To->containsUnexpandedParameterPack()) {
15290 To = getDerived().RebuildPackExpansionType(To,
15291 PatternTL.getSourceRange(),
15292 ExpansionTL.getEllipsisLoc(),
15293 NumExpansions);
15294 if (To.isNull())
15295 return ExprError();
15296
15297 PackExpansionTypeLoc ToExpansionTL
15298 = TLB.push<PackExpansionTypeLoc>(To);
15299 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15300 }
15301
15302 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15303 }
15304
15305 if (!RetainExpansion)
15306 continue;
15307
15308 // If we're supposed to retain a pack expansion, do so by temporarily
15309 // forgetting the partially-substituted parameter pack.
15310 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15311
15312 TypeLocBuilder TLB;
15313 TLB.reserve(From->getTypeLoc().getFullDataSize());
15314
15315 QualType To = getDerived().TransformType(TLB, PatternTL);
15316 if (To.isNull())
15317 return ExprError();
15318
15319 To = getDerived().RebuildPackExpansionType(To,
15320 PatternTL.getSourceRange(),
15321 ExpansionTL.getEllipsisLoc(),
15322 NumExpansions);
15323 if (To.isNull())
15324 return ExprError();
15325
15326 PackExpansionTypeLoc ToExpansionTL
15327 = TLB.push<PackExpansionTypeLoc>(To);
15328 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15329 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15330 }
15331
15332 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15333 return E;
15334
15335 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15336 E->getEndLoc());
15337}
15338
15339template<typename Derived>
15343 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15344 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15345 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15346 Old->NumTemplateArgs, TransArgs))
15347 return ExprError();
15348
15349 return getDerived().RebuildConceptSpecializationExpr(
15350 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15351 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15352 &TransArgs);
15353}
15354
15355template<typename Derived>
15358 SmallVector<ParmVarDecl*, 4> TransParams;
15359 SmallVector<QualType, 4> TransParamTypes;
15360 Sema::ExtParameterInfoBuilder ExtParamInfos;
15361
15362 // C++2a [expr.prim.req]p2
15363 // Expressions appearing within a requirement-body are unevaluated operands.
15367
15369 getSema().Context, getSema().CurContext,
15370 E->getBody()->getBeginLoc());
15371
15372 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15373
15374 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15375 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15376 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15377
15378 for (ParmVarDecl *Param : TransParams)
15379 if (Param)
15380 Param->setDeclContext(Body);
15381
15382 // On failure to transform, TransformRequiresTypeParams returns an expression
15383 // in the event that the transformation of the type params failed in some way.
15384 // It is expected that this will result in a 'not satisfied' Requires clause
15385 // when instantiating.
15386 if (!TypeParamResult.isUnset())
15387 return TypeParamResult;
15388
15390 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15391 TransReqs))
15392 return ExprError();
15393
15394 for (concepts::Requirement *Req : TransReqs) {
15395 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15396 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15397 ER->getReturnTypeRequirement()
15398 .getTypeConstraintTemplateParameterList()->getParam(0)
15399 ->setDeclContext(Body);
15400 }
15401 }
15402 }
15403
15404 return getDerived().RebuildRequiresExpr(
15405 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15406 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15407}
15408
15409template<typename Derived>
15413 for (concepts::Requirement *Req : Reqs) {
15414 concepts::Requirement *TransReq = nullptr;
15415 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15416 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15417 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15418 TransReq = getDerived().TransformExprRequirement(ExprReq);
15419 else
15420 TransReq = getDerived().TransformNestedRequirement(
15422 if (!TransReq)
15423 return true;
15424 Transformed.push_back(TransReq);
15425 }
15426 return false;
15427}
15428
15429template<typename Derived>
15433 if (Req->isSubstitutionFailure()) {
15434 if (getDerived().AlwaysRebuild())
15435 return getDerived().RebuildTypeRequirement(
15437 return Req;
15438 }
15439 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15440 if (!TransType)
15441 return nullptr;
15442 return getDerived().RebuildTypeRequirement(TransType);
15443}
15444
15445template<typename Derived>
15448 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15449 if (Req->isExprSubstitutionFailure())
15450 TransExpr = Req->getExprSubstitutionDiagnostic();
15451 else {
15452 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15453 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15454 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15455 if (TransExprRes.isInvalid())
15456 return nullptr;
15457 TransExpr = TransExprRes.get();
15458 }
15459
15460 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15461 const auto &RetReq = Req->getReturnTypeRequirement();
15462 if (RetReq.isEmpty())
15463 TransRetReq.emplace();
15464 else if (RetReq.isSubstitutionFailure())
15465 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15466 else if (RetReq.isTypeConstraint()) {
15467 TemplateParameterList *OrigTPL =
15468 RetReq.getTypeConstraintTemplateParameterList();
15470 getDerived().TransformTemplateParameterList(OrigTPL);
15471 if (!TPL)
15472 return nullptr;
15473 TransRetReq.emplace(TPL);
15474 }
15475 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15476 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15477 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15478 Req->getNoexceptLoc(),
15479 std::move(*TransRetReq));
15480 return getDerived().RebuildExprRequirement(
15482 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15483}
15484
15485template<typename Derived>
15489 if (Req->hasInvalidConstraint()) {
15490 if (getDerived().AlwaysRebuild())
15491 return getDerived().RebuildNestedRequirement(
15493 return Req;
15494 }
15495 ExprResult TransConstraint =
15496 getDerived().TransformExpr(Req->getConstraintExpr());
15497 if (TransConstraint.isInvalid())
15498 return nullptr;
15499 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15500}
15501
15502template<typename Derived>
15505 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15506 if (!T)
15507 return ExprError();
15508
15509 if (!getDerived().AlwaysRebuild() &&
15510 T == E->getQueriedTypeSourceInfo())
15511 return E;
15512
15513 ExprResult SubExpr;
15514 {
15517 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15518 if (SubExpr.isInvalid())
15519 return ExprError();
15520 }
15521
15522 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15523 SubExpr.get(), E->getEndLoc());
15524}
15525
15526template<typename Derived>
15529 ExprResult SubExpr;
15530 {
15533 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15534 if (SubExpr.isInvalid())
15535 return ExprError();
15536
15537 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15538 return E;
15539 }
15540
15541 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15542 SubExpr.get(), E->getEndLoc());
15543}
15544
15545template <typename Derived>
15547 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15548 TypeSourceInfo **RecoveryTSI) {
15549 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15550 DRE, AddrTaken, RecoveryTSI);
15551
15552 // Propagate both errors and recovered types, which return ExprEmpty.
15553 if (!NewDRE.isUsable())
15554 return NewDRE;
15555
15556 // We got an expr, wrap it up in parens.
15557 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15558 return PE;
15559 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15560 PE->getRParen());
15561}
15562
15563template <typename Derived>
15569
15570template <typename Derived>
15572 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15573 TypeSourceInfo **RecoveryTSI) {
15574 assert(E->getQualifierLoc());
15575 NestedNameSpecifierLoc QualifierLoc =
15576 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15577 if (!QualifierLoc)
15578 return ExprError();
15579 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15580
15581 // TODO: If this is a conversion-function-id, verify that the
15582 // destination type name (if present) resolves the same way after
15583 // instantiation as it did in the local scope.
15584
15585 DeclarationNameInfo NameInfo =
15586 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15587 if (!NameInfo.getName())
15588 return ExprError();
15589
15590 if (!E->hasExplicitTemplateArgs()) {
15591 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15592 // Note: it is sufficient to compare the Name component of NameInfo:
15593 // if name has not changed, DNLoc has not changed either.
15594 NameInfo.getName() == E->getDeclName())
15595 return E;
15596
15597 return getDerived().RebuildDependentScopeDeclRefExpr(
15598 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15599 IsAddressOfOperand, RecoveryTSI);
15600 }
15601
15602 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15603 if (getDerived().TransformTemplateArguments(
15604 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15605 return ExprError();
15606
15607 return getDerived().RebuildDependentScopeDeclRefExpr(
15608 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15609 RecoveryTSI);
15610}
15611
15612template<typename Derived>
15615 // CXXConstructExprs other than for list-initialization and
15616 // CXXTemporaryObjectExpr are always implicit, so when we have
15617 // a 1-argument construction we just transform that argument.
15618 if (getDerived().AllowSkippingCXXConstructExpr() &&
15619 ((E->getNumArgs() == 1 ||
15620 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15621 (!getDerived().DropCallArgument(E->getArg(0))) &&
15622 !E->isListInitialization()))
15623 return getDerived().TransformInitializer(E->getArg(0),
15624 /*DirectInit*/ false);
15625
15626 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15627
15628 QualType T = getDerived().TransformType(E->getType());
15629 if (T.isNull())
15630 return ExprError();
15631
15632 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15633 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15634 if (!Constructor)
15635 return ExprError();
15636
15637 bool ArgumentChanged = false;
15639 {
15642 E->isListInitialization());
15643 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15644 &ArgumentChanged))
15645 return ExprError();
15646 }
15647
15648 if (!getDerived().AlwaysRebuild() &&
15649 T == E->getType() &&
15650 Constructor == E->getConstructor() &&
15651 !ArgumentChanged) {
15652 // Mark the constructor as referenced.
15653 // FIXME: Instantiation-specific
15654 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15655 return E;
15656 }
15657
15658 return getDerived().RebuildCXXConstructExpr(
15659 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15660 E->hadMultipleCandidates(), E->isListInitialization(),
15661 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15662 E->getConstructionKind(), E->getParenOrBraceRange());
15663}
15664
15665template<typename Derived>
15668 QualType T = getDerived().TransformType(E->getType());
15669 if (T.isNull())
15670 return ExprError();
15671
15672 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15673 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15674 if (!Constructor)
15675 return ExprError();
15676
15677 if (!getDerived().AlwaysRebuild() &&
15678 T == E->getType() &&
15679 Constructor == E->getConstructor()) {
15680 // Mark the constructor as referenced.
15681 // FIXME: Instantiation-specific
15682 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15683 return E;
15684 }
15685
15686 return getDerived().RebuildCXXInheritedCtorInitExpr(
15687 T, E->getLocation(), Constructor,
15688 E->constructsVBase(), E->inheritedFromVBase());
15689}
15690
15691/// Transform a C++ temporary-binding expression.
15692///
15693/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15694/// transform the subexpression and return that.
15695template<typename Derived>
15698 if (auto *Dtor = E->getTemporary()->getDestructor())
15699 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15700 const_cast<CXXDestructorDecl *>(Dtor));
15701 return getDerived().TransformExpr(E->getSubExpr());
15702}
15703
15704/// Transform a C++ expression that contains cleanups that should
15705/// be run after the expression is evaluated.
15706///
15707/// Since ExprWithCleanups nodes are implicitly generated, we
15708/// just transform the subexpression and return that.
15709template<typename Derived>
15712 return getDerived().TransformExpr(E->getSubExpr());
15713}
15714
15715template<typename Derived>
15719 TypeSourceInfo *T =
15720 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15721 if (!T)
15722 return ExprError();
15723
15724 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15725 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15726 if (!Constructor)
15727 return ExprError();
15728
15729 bool ArgumentChanged = false;
15731 Args.reserve(E->getNumArgs());
15732 {
15735 E->isListInitialization());
15736 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15737 &ArgumentChanged))
15738 return ExprError();
15739
15740 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15741 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc());
15742 if (Res.isInvalid())
15743 return ExprError();
15744 Args = {Res.get()};
15745 }
15746 }
15747
15748 if (!getDerived().AlwaysRebuild() &&
15749 T == E->getTypeSourceInfo() &&
15750 Constructor == E->getConstructor() &&
15751 !ArgumentChanged) {
15752 // FIXME: Instantiation-specific
15753 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15754 return SemaRef.MaybeBindToTemporary(E);
15755 }
15756
15757 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15758 return getDerived().RebuildCXXTemporaryObjectExpr(
15759 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15760}
15761
15762template<typename Derived>
15765 // Transform any init-capture expressions before entering the scope of the
15766 // lambda body, because they are not semantically within that scope.
15767 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15768 struct TransformedInitCapture {
15769 // The location of the ... if the result is retaining a pack expansion.
15770 SourceLocation EllipsisLoc;
15771 // Zero or more expansions of the init-capture.
15772 SmallVector<InitCaptureInfoTy, 4> Expansions;
15773 };
15775 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15776 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15777 CEnd = E->capture_end();
15778 C != CEnd; ++C) {
15779 if (!E->isInitCapture(C))
15780 continue;
15781
15782 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15783 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15784
15785 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15786 UnsignedOrNone NumExpansions) {
15787 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15788 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15789
15790 if (NewExprInitResult.isInvalid()) {
15791 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15792 return;
15793 }
15794 Expr *NewExprInit = NewExprInitResult.get();
15795
15796 QualType NewInitCaptureType =
15797 getSema().buildLambdaInitCaptureInitialization(
15798 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15799 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15800 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15802 NewExprInit);
15803 Result.Expansions.push_back(
15804 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15805 };
15806
15807 // If this is an init-capture pack, consider expanding the pack now.
15808 if (OldVD->isParameterPack()) {
15809 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15810 ->getTypeLoc()
15813 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15814
15815 // Determine whether the set of unexpanded parameter packs can and should
15816 // be expanded.
15817 bool Expand = true;
15818 bool RetainExpansion = false;
15819 UnsignedOrNone OrigNumExpansions =
15820 ExpansionTL.getTypePtr()->getNumExpansions();
15821 UnsignedOrNone NumExpansions = OrigNumExpansions;
15822 if (getDerived().TryExpandParameterPacks(
15823 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15824 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15825 RetainExpansion, NumExpansions))
15826 return ExprError();
15827 assert(!RetainExpansion && "Should not need to retain expansion after a "
15828 "capture since it cannot be extended");
15829 if (Expand) {
15830 for (unsigned I = 0; I != *NumExpansions; ++I) {
15831 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15832 SubstInitCapture(SourceLocation(), std::nullopt);
15833 }
15834 } else {
15835 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15836 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15837 }
15838 } else {
15839 SubstInitCapture(SourceLocation(), std::nullopt);
15840 }
15841 }
15842
15843 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15844 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15845
15846 // Create the local class that will describe the lambda.
15847
15848 // FIXME: DependencyKind below is wrong when substituting inside a templated
15849 // context that isn't a DeclContext (such as a variable template), or when
15850 // substituting an unevaluated lambda inside of a function's parameter's type
15851 // - as parameter types are not instantiated from within a function's DC. We
15852 // use evaluation contexts to distinguish the function parameter case.
15855 DeclContext *DC = getSema().CurContext;
15856 // A RequiresExprBodyDecl is not interesting for dependencies.
15857 // For the following case,
15858 //
15859 // template <typename>
15860 // concept C = requires { [] {}; };
15861 //
15862 // template <class F>
15863 // struct Widget;
15864 //
15865 // template <C F>
15866 // struct Widget<F> {};
15867 //
15868 // While we are substituting Widget<F>, the parent of DC would be
15869 // the template specialization itself. Thus, the lambda expression
15870 // will be deemed as dependent even if there are no dependent template
15871 // arguments.
15872 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15873 while (DC->isRequiresExprBody())
15874 DC = DC->getParent();
15875 if ((getSema().isUnevaluatedContext() ||
15876 getSema().isConstantEvaluatedContext()) &&
15877 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15878 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
15879 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15880 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15881
15882 CXXRecordDecl *OldClass = E->getLambdaClass();
15883 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15884 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15885 E->getCaptureDefault());
15886 getDerived().transformedLocalDecl(OldClass, {Class});
15887
15888 CXXMethodDecl *NewCallOperator =
15889 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15890
15891 // Enter the scope of the lambda.
15892 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15893 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15894 E->hasExplicitParameters(), E->isMutable());
15895
15896 // Introduce the context of the call operator.
15897 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15898 /*NewThisContext*/false);
15899
15900 bool Invalid = false;
15901
15902 // Transform captures.
15903 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15904 CEnd = E->capture_end();
15905 C != CEnd; ++C) {
15906 // When we hit the first implicit capture, tell Sema that we've finished
15907 // the list of explicit captures.
15908 if (C->isImplicit())
15909 break;
15910
15911 // Capturing 'this' is trivial.
15912 if (C->capturesThis()) {
15913 // If this is a lambda that is part of a default member initialiser
15914 // and which we're instantiating outside the class that 'this' is
15915 // supposed to refer to, adjust the type of 'this' accordingly.
15916 //
15917 // Otherwise, leave the type of 'this' as-is.
15918 Sema::CXXThisScopeRAII ThisScope(
15919 getSema(),
15920 dyn_cast_if_present<CXXRecordDecl>(
15921 getSema().getFunctionLevelDeclContext()),
15922 Qualifiers());
15923 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15924 /*BuildAndDiagnose*/ true, nullptr,
15925 C->getCaptureKind() == LCK_StarThis);
15926 continue;
15927 }
15928 // Captured expression will be recaptured during captured variables
15929 // rebuilding.
15930 if (C->capturesVLAType())
15931 continue;
15932
15933 // Rebuild init-captures, including the implied field declaration.
15934 if (E->isInitCapture(C)) {
15935 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15936
15937 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15939
15940 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15941 ExprResult Init = Info.first;
15942 QualType InitQualType = Info.second;
15943 if (Init.isInvalid() || InitQualType.isNull()) {
15944 Invalid = true;
15945 break;
15946 }
15947 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15948 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15949 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15950 getSema().CurContext);
15951 if (!NewVD) {
15952 Invalid = true;
15953 break;
15954 }
15955 NewVDs.push_back(NewVD);
15956 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15957 // Cases we want to tackle:
15958 // ([C(Pack)] {}, ...)
15959 // But rule out cases e.g.
15960 // [...C = Pack()] {}
15961 if (NewC.EllipsisLoc.isInvalid())
15962 LSI->ContainsUnexpandedParameterPack |=
15963 Init.get()->containsUnexpandedParameterPack();
15964 }
15965
15966 if (Invalid)
15967 break;
15968
15969 getDerived().transformedLocalDecl(OldVD, NewVDs);
15970 continue;
15971 }
15972
15973 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15974
15975 // Determine the capture kind for Sema.
15977 : C->getCaptureKind() == LCK_ByCopy
15980 SourceLocation EllipsisLoc;
15981 if (C->isPackExpansion()) {
15982 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15983 bool ShouldExpand = false;
15984 bool RetainExpansion = false;
15985 UnsignedOrNone NumExpansions = std::nullopt;
15986 if (getDerived().TryExpandParameterPacks(
15987 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
15988 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
15989 RetainExpansion, NumExpansions)) {
15990 Invalid = true;
15991 continue;
15992 }
15993
15994 if (ShouldExpand) {
15995 // The transform has determined that we should perform an expansion;
15996 // transform and capture each of the arguments.
15997 // expansion of the pattern. Do so.
15998 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
15999 for (unsigned I = 0; I != *NumExpansions; ++I) {
16000 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16001 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
16002 getDerived().TransformDecl(C->getLocation(), Pack));
16003 if (!CapturedVar) {
16004 Invalid = true;
16005 continue;
16006 }
16007
16008 // Capture the transformed variable.
16009 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
16010 }
16011
16012 // FIXME: Retain a pack expansion if RetainExpansion is true.
16013
16014 continue;
16015 }
16016
16017 EllipsisLoc = C->getEllipsisLoc();
16018 }
16019
16020 // Transform the captured variable.
16021 auto *CapturedVar = cast_or_null<ValueDecl>(
16022 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16023 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
16024 Invalid = true;
16025 continue;
16026 }
16027
16028 // This is not an init-capture; however it contains an unexpanded pack e.g.
16029 // ([Pack] {}(), ...)
16030 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
16031 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
16032
16033 // Capture the transformed variable.
16034 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
16035 EllipsisLoc);
16036 }
16037 getSema().finishLambdaExplicitCaptures(LSI);
16038
16039 // Transform the template parameters, and add them to the current
16040 // instantiation scope. The null case is handled correctly.
16041 auto TPL = getDerived().TransformTemplateParameterList(
16042 E->getTemplateParameterList());
16043 LSI->GLTemplateParameterList = TPL;
16044 if (TPL) {
16045 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
16046 TPL);
16047 LSI->ContainsUnexpandedParameterPack |=
16048 TPL->containsUnexpandedParameterPack();
16049 }
16050
16051 TypeLocBuilder NewCallOpTLBuilder;
16052 TypeLoc OldCallOpTypeLoc =
16053 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
16054 QualType NewCallOpType =
16055 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
16056 if (NewCallOpType.isNull())
16057 return ExprError();
16058 LSI->ContainsUnexpandedParameterPack |=
16059 NewCallOpType->containsUnexpandedParameterPack();
16060 TypeSourceInfo *NewCallOpTSI =
16061 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
16062
16063 // The type may be an AttributedType or some other kind of sugar;
16064 // get the actual underlying FunctionProtoType.
16065 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
16066 assert(FPTL && "Not a FunctionProtoType?");
16067
16068 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
16069 // If the concept refers to any outer parameter packs, we track the SubstIndex
16070 // for evaluation.
16071 if (TRC && TRC.ConstraintExpr->containsUnexpandedParameterPack() &&
16072 !TRC.ArgPackSubstIndex)
16074
16075 getSema().CompleteLambdaCallOperator(
16076 NewCallOperator, E->getCallOperator()->getLocation(),
16077 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
16078 E->getCallOperator()->getConstexprKind(),
16079 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
16080 E->hasExplicitResultType());
16081
16082 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
16083 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
16084
16085 {
16086 // Number the lambda for linkage purposes if necessary.
16087 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
16088
16089 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
16090 if (getDerived().ReplacingOriginal()) {
16091 Numbering = OldClass->getLambdaNumbering();
16092 }
16093
16094 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
16095 }
16096
16097 // FIXME: Sema's lambda-building mechanism expects us to push an expression
16098 // evaluation context even if we're not transforming the function body.
16099 getSema().PushExpressionEvaluationContextForFunction(
16101 E->getCallOperator());
16102
16103 StmtResult Body;
16104 {
16105 Sema::NonSFINAEContext _(getSema());
16108 C.PointOfInstantiation = E->getBody()->getBeginLoc();
16109 getSema().pushCodeSynthesisContext(C);
16110
16111 // Instantiate the body of the lambda expression.
16112 Body = Invalid ? StmtError()
16113 : getDerived().TransformLambdaBody(E, E->getBody());
16114
16115 getSema().popCodeSynthesisContext();
16116 }
16117
16118 // ActOnLambda* will pop the function scope for us.
16119 FuncScopeCleanup.disable();
16120
16121 if (Body.isInvalid()) {
16122 SavedContext.pop();
16123 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
16124 /*IsInstantiation=*/true);
16125 return ExprError();
16126 }
16127
16128 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
16129 /*IsInstantiation=*/true,
16130 /*RetainFunctionScopeInfo=*/true);
16131 SavedContext.pop();
16132
16133 // Recompute the dependency of the lambda so that we can defer the lambda call
16134 // construction until after we have all the necessary template arguments. For
16135 // example, given
16136 //
16137 // template <class> struct S {
16138 // template <class U>
16139 // using Type = decltype([](U){}(42.0));
16140 // };
16141 // void foo() {
16142 // using T = S<int>::Type<float>;
16143 // ^~~~~~
16144 // }
16145 //
16146 // We would end up here from instantiating S<int> when ensuring its
16147 // completeness. That would transform the lambda call expression regardless of
16148 // the absence of the corresponding argument for U.
16149 //
16150 // Going ahead with unsubstituted type U makes things worse: we would soon
16151 // compare the argument type (which is float) against the parameter U
16152 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
16153 // error suggesting unmatched types 'U' and 'float'!
16154 //
16155 // That said, everything will be fine if we defer that semantic checking.
16156 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
16157 // dependent. Since the CallExpr's dependency boils down to the lambda's
16158 // dependency in this case, we can harness that by recomputing the dependency
16159 // from the instantiation arguments.
16160 //
16161 // FIXME: Creating the type of a lambda requires us to have a dependency
16162 // value, which happens before its substitution. We update its dependency
16163 // *after* the substitution in case we can't decide the dependency
16164 // so early, e.g. because we want to see if any of the *substituted*
16165 // parameters are dependent.
16166 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
16167 Class->setLambdaDependencyKind(DependencyKind);
16168
16169 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
16170 Body.get()->getEndLoc(), LSI);
16171}
16172
16173template<typename Derived>
16178
16179template<typename Derived>
16182 // Transform captures.
16184 CEnd = E->capture_end();
16185 C != CEnd; ++C) {
16186 // When we hit the first implicit capture, tell Sema that we've finished
16187 // the list of explicit captures.
16188 if (!C->isImplicit())
16189 continue;
16190
16191 // Capturing 'this' is trivial.
16192 if (C->capturesThis()) {
16193 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16194 /*BuildAndDiagnose*/ true, nullptr,
16195 C->getCaptureKind() == LCK_StarThis);
16196 continue;
16197 }
16198 // Captured expression will be recaptured during captured variables
16199 // rebuilding.
16200 if (C->capturesVLAType())
16201 continue;
16202
16203 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16204 assert(!E->isInitCapture(C) && "implicit init-capture?");
16205
16206 // Transform the captured variable.
16207 VarDecl *CapturedVar = cast_or_null<VarDecl>(
16208 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16209 if (!CapturedVar || CapturedVar->isInvalidDecl())
16210 return StmtError();
16211
16212 // Capture the transformed variable.
16213 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16214 }
16215
16216 return S;
16217}
16218
16219template<typename Derived>
16223 TypeSourceInfo *T =
16224 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16225 if (!T)
16226 return ExprError();
16227
16228 bool ArgumentChanged = false;
16230 Args.reserve(E->getNumArgs());
16231 {
16235 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16236 &ArgumentChanged))
16237 return ExprError();
16238 }
16239
16240 if (!getDerived().AlwaysRebuild() &&
16241 T == E->getTypeSourceInfo() &&
16242 !ArgumentChanged)
16243 return E;
16244
16245 // FIXME: we're faking the locations of the commas
16246 return getDerived().RebuildCXXUnresolvedConstructExpr(
16247 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16248}
16249
16250template<typename Derived>
16254 // Transform the base of the expression.
16255 ExprResult Base((Expr*) nullptr);
16256 Expr *OldBase;
16257 QualType BaseType;
16258 QualType ObjectType;
16259 if (!E->isImplicitAccess()) {
16260 OldBase = E->getBase();
16261 Base = getDerived().TransformExpr(OldBase);
16262 if (Base.isInvalid())
16263 return ExprError();
16264
16265 // Start the member reference and compute the object's type.
16266 ParsedType ObjectTy;
16267 bool MayBePseudoDestructor = false;
16268 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16269 E->getOperatorLoc(),
16270 E->isArrow()? tok::arrow : tok::period,
16271 ObjectTy,
16272 MayBePseudoDestructor);
16273 if (Base.isInvalid())
16274 return ExprError();
16275
16276 ObjectType = ObjectTy.get();
16277 BaseType = ((Expr*) Base.get())->getType();
16278 } else {
16279 OldBase = nullptr;
16280 BaseType = getDerived().TransformType(E->getBaseType());
16281 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16282 }
16283
16284 // Transform the first part of the nested-name-specifier that qualifies
16285 // the member name.
16286 NamedDecl *FirstQualifierInScope
16287 = getDerived().TransformFirstQualifierInScope(
16288 E->getFirstQualifierFoundInScope(),
16289 E->getQualifierLoc().getBeginLoc());
16290
16291 NestedNameSpecifierLoc QualifierLoc;
16292 if (E->getQualifier()) {
16293 QualifierLoc
16294 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16295 ObjectType,
16296 FirstQualifierInScope);
16297 if (!QualifierLoc)
16298 return ExprError();
16299 }
16300
16301 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16302
16303 // TODO: If this is a conversion-function-id, verify that the
16304 // destination type name (if present) resolves the same way after
16305 // instantiation as it did in the local scope.
16306
16307 DeclarationNameInfo NameInfo
16308 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16309 if (!NameInfo.getName())
16310 return ExprError();
16311
16312 if (!E->hasExplicitTemplateArgs()) {
16313 // This is a reference to a member without an explicitly-specified
16314 // template argument list. Optimize for this common case.
16315 if (!getDerived().AlwaysRebuild() &&
16316 Base.get() == OldBase &&
16317 BaseType == E->getBaseType() &&
16318 QualifierLoc == E->getQualifierLoc() &&
16319 NameInfo.getName() == E->getMember() &&
16320 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16321 return E;
16322
16323 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16324 BaseType,
16325 E->isArrow(),
16326 E->getOperatorLoc(),
16327 QualifierLoc,
16328 TemplateKWLoc,
16329 FirstQualifierInScope,
16330 NameInfo,
16331 /*TemplateArgs*/nullptr);
16332 }
16333
16334 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16335 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16336 E->getNumTemplateArgs(),
16337 TransArgs))
16338 return ExprError();
16339
16340 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16341 BaseType,
16342 E->isArrow(),
16343 E->getOperatorLoc(),
16344 QualifierLoc,
16345 TemplateKWLoc,
16346 FirstQualifierInScope,
16347 NameInfo,
16348 &TransArgs);
16349}
16350
16351template <typename Derived>
16353 UnresolvedMemberExpr *Old) {
16354 // Transform the base of the expression.
16355 ExprResult Base((Expr *)nullptr);
16356 QualType BaseType;
16357 if (!Old->isImplicitAccess()) {
16358 Base = getDerived().TransformExpr(Old->getBase());
16359 if (Base.isInvalid())
16360 return ExprError();
16361 Base =
16362 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16363 if (Base.isInvalid())
16364 return ExprError();
16365 BaseType = Base.get()->getType();
16366 } else {
16367 BaseType = getDerived().TransformType(Old->getBaseType());
16368 }
16369
16370 NestedNameSpecifierLoc QualifierLoc;
16371 if (Old->getQualifierLoc()) {
16372 QualifierLoc =
16373 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16374 if (!QualifierLoc)
16375 return ExprError();
16376 }
16377
16378 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16379
16380 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16381
16382 // Transform the declaration set.
16383 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16384 return ExprError();
16385
16386 // Determine the naming class.
16387 if (Old->getNamingClass()) {
16388 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16389 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16390 if (!NamingClass)
16391 return ExprError();
16392
16393 R.setNamingClass(NamingClass);
16394 }
16395
16396 TemplateArgumentListInfo TransArgs;
16397 if (Old->hasExplicitTemplateArgs()) {
16398 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16399 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16400 if (getDerived().TransformTemplateArguments(
16401 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16402 return ExprError();
16403 }
16404
16405 // FIXME: to do this check properly, we will need to preserve the
16406 // first-qualifier-in-scope here, just in case we had a dependent
16407 // base (and therefore couldn't do the check) and a
16408 // nested-name-qualifier (and therefore could do the lookup).
16409 NamedDecl *FirstQualifierInScope = nullptr;
16410
16411 return getDerived().RebuildUnresolvedMemberExpr(
16412 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16413 TemplateKWLoc, FirstQualifierInScope, R,
16414 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16415}
16416
16417template<typename Derived>
16422 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16423 if (SubExpr.isInvalid())
16424 return ExprError();
16425
16426 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16427 return E;
16428
16429 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16430}
16431
16432template<typename Derived>
16435 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16436 if (Pattern.isInvalid())
16437 return ExprError();
16438
16439 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16440 return E;
16441
16442 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16443 E->getNumExpansions());
16444}
16445
16446template <typename Derived>
16448 ArrayRef<TemplateArgument> PackArgs) {
16450 for (const TemplateArgument &Arg : PackArgs) {
16451 if (!Arg.isPackExpansion()) {
16452 Result = *Result + 1;
16453 continue;
16454 }
16455
16456 TemplateArgumentLoc ArgLoc;
16457 InventTemplateArgumentLoc(Arg, ArgLoc);
16458
16459 // Find the pattern of the pack expansion.
16460 SourceLocation Ellipsis;
16461 UnsignedOrNone OrigNumExpansions = std::nullopt;
16462 TemplateArgumentLoc Pattern =
16463 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16464 OrigNumExpansions);
16465
16466 // Substitute under the pack expansion. Do not expand the pack (yet).
16467 TemplateArgumentLoc OutPattern;
16468 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16469 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16470 /*Uneval*/ true))
16471 return 1u;
16472
16473 // See if we can determine the number of arguments from the result.
16474 UnsignedOrNone NumExpansions =
16475 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16476 if (!NumExpansions) {
16477 // No: we must be in an alias template expansion, and we're going to
16478 // need to actually expand the packs.
16479 Result = std::nullopt;
16480 break;
16481 }
16482
16483 Result = *Result + *NumExpansions;
16484 }
16485 return Result;
16486}
16487
16488template<typename Derived>
16491 // If E is not value-dependent, then nothing will change when we transform it.
16492 // Note: This is an instantiation-centric view.
16493 if (!E->isValueDependent())
16494 return E;
16495
16498
16500 TemplateArgument ArgStorage;
16501
16502 // Find the argument list to transform.
16503 if (E->isPartiallySubstituted()) {
16504 PackArgs = E->getPartialArguments();
16505 } else if (E->isValueDependent()) {
16506 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16507 bool ShouldExpand = false;
16508 bool RetainExpansion = false;
16509 UnsignedOrNone NumExpansions = std::nullopt;
16510 if (getDerived().TryExpandParameterPacks(
16511 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16512 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16513 RetainExpansion, NumExpansions))
16514 return ExprError();
16515
16516 // If we need to expand the pack, build a template argument from it and
16517 // expand that.
16518 if (ShouldExpand) {
16519 auto *Pack = E->getPack();
16520 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16521 ArgStorage = getSema().Context.getPackExpansionType(
16522 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16523 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16524 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16525 } else {
16526 auto *VD = cast<ValueDecl>(Pack);
16527 ExprResult DRE = getSema().BuildDeclRefExpr(
16528 VD, VD->getType().getNonLValueExprType(getSema().Context),
16529 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16530 E->getPackLoc());
16531 if (DRE.isInvalid())
16532 return ExprError();
16533 ArgStorage = TemplateArgument(
16534 new (getSema().Context)
16535 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16536 /*IsCanonical=*/false);
16537 }
16538 PackArgs = ArgStorage;
16539 }
16540 }
16541
16542 // If we're not expanding the pack, just transform the decl.
16543 if (!PackArgs.size()) {
16544 auto *Pack = cast_or_null<NamedDecl>(
16545 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16546 if (!Pack)
16547 return ExprError();
16548 return getDerived().RebuildSizeOfPackExpr(
16549 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16550 std::nullopt, {});
16551 }
16552
16553 // Try to compute the result without performing a partial substitution.
16555 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16556
16557 // Common case: we could determine the number of expansions without
16558 // substituting.
16559 if (Result)
16560 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16561 E->getPackLoc(),
16562 E->getRParenLoc(), *Result, {});
16563
16564 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16565 E->getPackLoc());
16566 {
16567 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16569 Derived, const TemplateArgument*> PackLocIterator;
16570 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16571 PackLocIterator(*this, PackArgs.end()),
16572 TransformedPackArgs, /*Uneval*/true))
16573 return ExprError();
16574 }
16575
16576 // Check whether we managed to fully-expand the pack.
16577 // FIXME: Is it possible for us to do so and not hit the early exit path?
16579 bool PartialSubstitution = false;
16580 for (auto &Loc : TransformedPackArgs.arguments()) {
16581 Args.push_back(Loc.getArgument());
16582 if (Loc.getArgument().isPackExpansion())
16583 PartialSubstitution = true;
16584 }
16585
16586 if (PartialSubstitution)
16587 return getDerived().RebuildSizeOfPackExpr(
16588 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16589 std::nullopt, Args);
16590
16591 return getDerived().RebuildSizeOfPackExpr(
16592 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16593 /*Length=*/static_cast<unsigned>(Args.size()),
16594 /*PartialArgs=*/{});
16595}
16596
16597template <typename Derived>
16600 if (!E->isValueDependent())
16601 return E;
16602
16603 // Transform the index
16604 ExprResult IndexExpr;
16605 {
16606 EnterExpressionEvaluationContext ConstantContext(
16608 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16609 if (IndexExpr.isInvalid())
16610 return ExprError();
16611 }
16612
16613 SmallVector<Expr *, 5> ExpandedExprs;
16614 bool FullySubstituted = true;
16615 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16616 Expr *Pattern = E->getPackIdExpression();
16618 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16619 Unexpanded);
16620 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16621
16622 // Determine whether the set of unexpanded parameter packs can and should
16623 // be expanded.
16624 bool ShouldExpand = true;
16625 bool RetainExpansion = false;
16626 UnsignedOrNone OrigNumExpansions = std::nullopt,
16627 NumExpansions = std::nullopt;
16628 if (getDerived().TryExpandParameterPacks(
16629 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16630 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16631 RetainExpansion, NumExpansions))
16632 return true;
16633 if (!ShouldExpand) {
16634 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16635 ExprResult Pack = getDerived().TransformExpr(Pattern);
16636 if (Pack.isInvalid())
16637 return ExprError();
16638 return getDerived().RebuildPackIndexingExpr(
16639 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16640 {}, /*FullySubstituted=*/false);
16641 }
16642 for (unsigned I = 0; I != *NumExpansions; ++I) {
16643 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16644 ExprResult Out = getDerived().TransformExpr(Pattern);
16645 if (Out.isInvalid())
16646 return true;
16647 if (Out.get()->containsUnexpandedParameterPack()) {
16648 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16649 OrigNumExpansions);
16650 if (Out.isInvalid())
16651 return true;
16652 FullySubstituted = false;
16653 }
16654 ExpandedExprs.push_back(Out.get());
16655 }
16656 // If we're supposed to retain a pack expansion, do so by temporarily
16657 // forgetting the partially-substituted parameter pack.
16658 if (RetainExpansion) {
16659 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16660
16661 ExprResult Out = getDerived().TransformExpr(Pattern);
16662 if (Out.isInvalid())
16663 return true;
16664
16665 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16666 OrigNumExpansions);
16667 if (Out.isInvalid())
16668 return true;
16669 FullySubstituted = false;
16670 ExpandedExprs.push_back(Out.get());
16671 }
16672 } else if (!E->expandsToEmptyPack()) {
16673 if (getDerived().TransformExprs(E->getExpressions().data(),
16674 E->getExpressions().size(), false,
16675 ExpandedExprs))
16676 return ExprError();
16677 }
16678
16679 return getDerived().RebuildPackIndexingExpr(
16680 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16681 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16682}
16683
16684template <typename Derived>
16687 if (!getSema().ArgPackSubstIndex)
16688 // We aren't expanding the parameter pack, so just return ourselves.
16689 return E;
16690
16691 TemplateArgument Pack = E->getArgumentPack();
16693 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16694 E->getAssociatedDecl(), E->getParameterPack(),
16695 E->getParameterPackLocation(), Arg, SemaRef.getPackIndex(Pack),
16696 E->getFinal());
16697}
16698
16699template <typename Derived>
16702 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16703 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16704 if (Replacement.isInvalid())
16705 return true;
16706
16707 Decl *AssociatedDecl =
16708 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16709 if (!AssociatedDecl)
16710 return true;
16711
16712 if (Replacement.get() == OrigReplacement &&
16713 AssociatedDecl == E->getAssociatedDecl())
16714 return E;
16715
16716 auto getParamAndType = [E](Decl *AssociatedDecl)
16717 -> std::tuple<NonTypeTemplateParmDecl *, QualType> {
16718 auto [PDecl, Arg] =
16719 getReplacedTemplateParameter(AssociatedDecl, E->getIndex());
16720 auto *Param = cast<NonTypeTemplateParmDecl>(PDecl);
16721 if (Arg.isNull())
16722 return {Param, Param->getType()};
16723 if (UnsignedOrNone PackIndex = E->getPackIndex())
16724 Arg = Arg.getPackAsArray()[*PackIndex];
16725 return {Param, Arg.getNonTypeTemplateArgumentType()};
16726 };
16727
16728 // If the replacement expression did not change, and the parameter type
16729 // did not change, we can skip the semantic action because it would
16730 // produce the same result anyway.
16731 if (auto [Param, ParamType] = getParamAndType(AssociatedDecl);
16732 !SemaRef.Context.hasSameType(
16733 ParamType, std::get<1>(getParamAndType(E->getAssociatedDecl()))) ||
16734 Replacement.get() != OrigReplacement) {
16735 // When transforming the replacement expression previously, all Sema
16736 // specific annotations, such as implicit casts, are discarded. Calling the
16737 // corresponding sema action is necessary to recover those. Otherwise,
16738 // equivalency of the result would be lost.
16739 TemplateArgument SugaredConverted, CanonicalConverted;
16740 Replacement = SemaRef.CheckTemplateArgument(
16741 Param, ParamType, Replacement.get(), SugaredConverted,
16742 CanonicalConverted,
16743 /*StrictCheck=*/false, Sema::CTAK_Specified);
16744 if (Replacement.isInvalid())
16745 return true;
16746 } else {
16747 // Otherwise, the same expression would have been produced.
16748 Replacement = E->getReplacement();
16749 }
16750
16751 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16752 AssociatedDecl, E->getParameter(), E->getNameLoc(),
16753 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
16754 E->getPackIndex(), E->getFinal());
16755}
16756
16757template<typename Derived>
16760 // Default behavior is to do nothing with this transformation.
16761 return E;
16762}
16763
16764template<typename Derived>
16768 return getDerived().TransformExpr(E->getSubExpr());
16769}
16770
16771template<typename Derived>
16774 UnresolvedLookupExpr *Callee = nullptr;
16775 if (Expr *OldCallee = E->getCallee()) {
16776 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16777 if (CalleeResult.isInvalid())
16778 return ExprError();
16779 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16780 }
16781
16782 Expr *Pattern = E->getPattern();
16783
16785 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16786 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16787
16788 // Determine whether the set of unexpanded parameter packs can and should
16789 // be expanded.
16790 bool Expand = true;
16791 bool RetainExpansion = false;
16792 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16793 NumExpansions = OrigNumExpansions;
16794 if (getDerived().TryExpandParameterPacks(
16795 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16796 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16797 NumExpansions))
16798 return true;
16799
16800 if (!Expand) {
16801 // Do not expand any packs here, just transform and rebuild a fold
16802 // expression.
16803 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16804
16805 ExprResult LHS =
16806 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16807 if (LHS.isInvalid())
16808 return true;
16809
16810 ExprResult RHS =
16811 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16812 if (RHS.isInvalid())
16813 return true;
16814
16815 if (!getDerived().AlwaysRebuild() &&
16816 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16817 return E;
16818
16819 return getDerived().RebuildCXXFoldExpr(
16820 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16821 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16822 }
16823
16824 // Formally a fold expression expands to nested parenthesized expressions.
16825 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16826 // them.
16827 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16828 SemaRef.Diag(E->getEllipsisLoc(),
16829 clang::diag::err_fold_expression_limit_exceeded)
16830 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16831 << E->getSourceRange();
16832 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16833 return ExprError();
16834 }
16835
16836 // The transform has determined that we should perform an elementwise
16837 // expansion of the pattern. Do so.
16838 ExprResult Result = getDerived().TransformExpr(E->getInit());
16839 if (Result.isInvalid())
16840 return true;
16841 bool LeftFold = E->isLeftFold();
16842
16843 // If we're retaining an expansion for a right fold, it is the innermost
16844 // component and takes the init (if any).
16845 if (!LeftFold && RetainExpansion) {
16846 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16847
16848 ExprResult Out = getDerived().TransformExpr(Pattern);
16849 if (Out.isInvalid())
16850 return true;
16851
16852 Result = getDerived().RebuildCXXFoldExpr(
16853 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16854 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16855 if (Result.isInvalid())
16856 return true;
16857 }
16858
16859 bool WarnedOnComparison = false;
16860 for (unsigned I = 0; I != *NumExpansions; ++I) {
16861 Sema::ArgPackSubstIndexRAII SubstIndex(
16862 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16863 ExprResult Out = getDerived().TransformExpr(Pattern);
16864 if (Out.isInvalid())
16865 return true;
16866
16867 if (Out.get()->containsUnexpandedParameterPack()) {
16868 // We still have a pack; retain a pack expansion for this slice.
16869 Result = getDerived().RebuildCXXFoldExpr(
16870 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16871 E->getOperator(), E->getEllipsisLoc(),
16872 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16873 OrigNumExpansions);
16874 } else if (Result.isUsable()) {
16875 // We've got down to a single element; build a binary operator.
16876 Expr *LHS = LeftFold ? Result.get() : Out.get();
16877 Expr *RHS = LeftFold ? Out.get() : Result.get();
16878 if (Callee) {
16879 UnresolvedSet<16> Functions;
16880 Functions.append(Callee->decls_begin(), Callee->decls_end());
16881 Result = getDerived().RebuildCXXOperatorCallExpr(
16882 BinaryOperator::getOverloadedOperator(E->getOperator()),
16883 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16884 Functions, LHS, RHS);
16885 } else {
16886 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16887 E->getOperator(), LHS, RHS,
16888 /*ForFoldExpresion=*/true);
16889 if (!WarnedOnComparison && Result.isUsable()) {
16890 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16891 BO && BO->isComparisonOp()) {
16892 WarnedOnComparison = true;
16893 SemaRef.Diag(BO->getBeginLoc(),
16894 diag::warn_comparison_in_fold_expression)
16895 << BO->getOpcodeStr();
16896 }
16897 }
16898 }
16899 } else
16900 Result = Out;
16901
16902 if (Result.isInvalid())
16903 return true;
16904 }
16905
16906 // If we're retaining an expansion for a left fold, it is the outermost
16907 // component and takes the complete expansion so far as its init (if any).
16908 if (LeftFold && RetainExpansion) {
16909 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16910
16911 ExprResult Out = getDerived().TransformExpr(Pattern);
16912 if (Out.isInvalid())
16913 return true;
16914
16915 Result = getDerived().RebuildCXXFoldExpr(
16916 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16917 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16918 if (Result.isInvalid())
16919 return true;
16920 }
16921
16922 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16923 PE->setIsProducedByFoldExpansion();
16924
16925 // If we had no init and an empty pack, and we're not retaining an expansion,
16926 // then produce a fallback value or error.
16927 if (Result.isUnset())
16928 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16929 E->getOperator());
16930 return Result;
16931}
16932
16933template <typename Derived>
16936 SmallVector<Expr *, 4> TransformedInits;
16937 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16938
16939 QualType T = getDerived().TransformType(E->getType());
16940
16941 bool ArgChanged = false;
16942
16943 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16944 TransformedInits, &ArgChanged))
16945 return ExprError();
16946
16947 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16948 return E;
16949
16950 return getDerived().RebuildCXXParenListInitExpr(
16951 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16952 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16953}
16954
16955template<typename Derived>
16959 return getDerived().TransformExpr(E->getSubExpr());
16960}
16961
16962template<typename Derived>
16965 return SemaRef.MaybeBindToTemporary(E);
16966}
16967
16968template<typename Derived>
16971 return E;
16972}
16973
16974template<typename Derived>
16977 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16978 if (SubExpr.isInvalid())
16979 return ExprError();
16980
16981 if (!getDerived().AlwaysRebuild() &&
16982 SubExpr.get() == E->getSubExpr())
16983 return E;
16984
16985 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16986}
16987
16988template<typename Derived>
16991 // Transform each of the elements.
16992 SmallVector<Expr *, 8> Elements;
16993 bool ArgChanged = false;
16994 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
16995 /*IsCall=*/false, Elements, &ArgChanged))
16996 return ExprError();
16997
16998 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16999 return SemaRef.MaybeBindToTemporary(E);
17000
17001 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
17002 Elements.data(),
17003 Elements.size());
17004}
17005
17006template<typename Derived>
17010 // Transform each of the elements.
17012 bool ArgChanged = false;
17013 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
17014 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
17015
17016 if (OrigElement.isPackExpansion()) {
17017 // This key/value element is a pack expansion.
17019 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
17020 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
17021 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
17022
17023 // Determine whether the set of unexpanded parameter packs can
17024 // and should be expanded.
17025 bool Expand = true;
17026 bool RetainExpansion = false;
17027 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
17028 UnsignedOrNone NumExpansions = OrigNumExpansions;
17029 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
17030 OrigElement.Value->getEndLoc());
17031 if (getDerived().TryExpandParameterPacks(
17032 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
17033 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
17034 NumExpansions))
17035 return ExprError();
17036
17037 if (!Expand) {
17038 // The transform has determined that we should perform a simple
17039 // transformation on the pack expansion, producing another pack
17040 // expansion.
17041 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
17042 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17043 if (Key.isInvalid())
17044 return ExprError();
17045
17046 if (Key.get() != OrigElement.Key)
17047 ArgChanged = true;
17048
17049 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17050 if (Value.isInvalid())
17051 return ExprError();
17052
17053 if (Value.get() != OrigElement.Value)
17054 ArgChanged = true;
17055
17056 ObjCDictionaryElement Expansion = {
17057 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
17058 };
17059 Elements.push_back(Expansion);
17060 continue;
17061 }
17062
17063 // Record right away that the argument was changed. This needs
17064 // to happen even if the array expands to nothing.
17065 ArgChanged = true;
17066
17067 // The transform has determined that we should perform an elementwise
17068 // expansion of the pattern. Do so.
17069 for (unsigned I = 0; I != *NumExpansions; ++I) {
17070 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
17071 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17072 if (Key.isInvalid())
17073 return ExprError();
17074
17075 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17076 if (Value.isInvalid())
17077 return ExprError();
17078
17079 ObjCDictionaryElement Element = {
17080 Key.get(), Value.get(), SourceLocation(), NumExpansions
17081 };
17082
17083 // If any unexpanded parameter packs remain, we still have a
17084 // pack expansion.
17085 // FIXME: Can this really happen?
17086 if (Key.get()->containsUnexpandedParameterPack() ||
17087 Value.get()->containsUnexpandedParameterPack())
17088 Element.EllipsisLoc = OrigElement.EllipsisLoc;
17089
17090 Elements.push_back(Element);
17091 }
17092
17093 // FIXME: Retain a pack expansion if RetainExpansion is true.
17094
17095 // We've finished with this pack expansion.
17096 continue;
17097 }
17098
17099 // Transform and check key.
17100 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17101 if (Key.isInvalid())
17102 return ExprError();
17103
17104 if (Key.get() != OrigElement.Key)
17105 ArgChanged = true;
17106
17107 // Transform and check value.
17109 = getDerived().TransformExpr(OrigElement.Value);
17110 if (Value.isInvalid())
17111 return ExprError();
17112
17113 if (Value.get() != OrigElement.Value)
17114 ArgChanged = true;
17115
17116 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
17117 std::nullopt};
17118 Elements.push_back(Element);
17119 }
17120
17121 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17122 return SemaRef.MaybeBindToTemporary(E);
17123
17124 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
17125 Elements);
17126}
17127
17128template<typename Derived>
17131 TypeSourceInfo *EncodedTypeInfo
17132 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
17133 if (!EncodedTypeInfo)
17134 return ExprError();
17135
17136 if (!getDerived().AlwaysRebuild() &&
17137 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
17138 return E;
17139
17140 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
17141 EncodedTypeInfo,
17142 E->getRParenLoc());
17143}
17144
17145template<typename Derived>
17148 // This is a kind of implicit conversion, and it needs to get dropped
17149 // and recomputed for the same general reasons that ImplicitCastExprs
17150 // do, as well a more specific one: this expression is only valid when
17151 // it appears *immediately* as an argument expression.
17152 return getDerived().TransformExpr(E->getSubExpr());
17153}
17154
17155template<typename Derived>
17158 TypeSourceInfo *TSInfo
17159 = getDerived().TransformType(E->getTypeInfoAsWritten());
17160 if (!TSInfo)
17161 return ExprError();
17162
17163 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
17164 if (Result.isInvalid())
17165 return ExprError();
17166
17167 if (!getDerived().AlwaysRebuild() &&
17168 TSInfo == E->getTypeInfoAsWritten() &&
17169 Result.get() == E->getSubExpr())
17170 return E;
17171
17172 return SemaRef.ObjC().BuildObjCBridgedCast(
17173 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
17174 Result.get());
17175}
17176
17177template <typename Derived>
17180 return E;
17181}
17182
17183template<typename Derived>
17186 // Transform arguments.
17187 bool ArgChanged = false;
17189 Args.reserve(E->getNumArgs());
17190 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
17191 &ArgChanged))
17192 return ExprError();
17193
17194 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
17195 // Class message: transform the receiver type.
17196 TypeSourceInfo *ReceiverTypeInfo
17197 = getDerived().TransformType(E->getClassReceiverTypeInfo());
17198 if (!ReceiverTypeInfo)
17199 return ExprError();
17200
17201 // If nothing changed, just retain the existing message send.
17202 if (!getDerived().AlwaysRebuild() &&
17203 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
17204 return SemaRef.MaybeBindToTemporary(E);
17205
17206 // Build a new class message send.
17208 E->getSelectorLocs(SelLocs);
17209 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
17210 E->getSelector(),
17211 SelLocs,
17212 E->getMethodDecl(),
17213 E->getLeftLoc(),
17214 Args,
17215 E->getRightLoc());
17216 }
17217 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17218 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17219 if (!E->getMethodDecl())
17220 return ExprError();
17221
17222 // Build a new class message send to 'super'.
17224 E->getSelectorLocs(SelLocs);
17225 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17226 E->getSelector(),
17227 SelLocs,
17228 E->getReceiverType(),
17229 E->getMethodDecl(),
17230 E->getLeftLoc(),
17231 Args,
17232 E->getRightLoc());
17233 }
17234
17235 // Instance message: transform the receiver
17236 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17237 "Only class and instance messages may be instantiated");
17238 ExprResult Receiver
17239 = getDerived().TransformExpr(E->getInstanceReceiver());
17240 if (Receiver.isInvalid())
17241 return ExprError();
17242
17243 // If nothing changed, just retain the existing message send.
17244 if (!getDerived().AlwaysRebuild() &&
17245 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17246 return SemaRef.MaybeBindToTemporary(E);
17247
17248 // Build a new instance message send.
17250 E->getSelectorLocs(SelLocs);
17251 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17252 E->getSelector(),
17253 SelLocs,
17254 E->getMethodDecl(),
17255 E->getLeftLoc(),
17256 Args,
17257 E->getRightLoc());
17258}
17259
17260template<typename Derived>
17263 return E;
17264}
17265
17266template<typename Derived>
17269 return E;
17270}
17271
17272template<typename Derived>
17275 // Transform the base expression.
17276 ExprResult Base = getDerived().TransformExpr(E->getBase());
17277 if (Base.isInvalid())
17278 return ExprError();
17279
17280 // We don't need to transform the ivar; it will never change.
17281
17282 // If nothing changed, just retain the existing expression.
17283 if (!getDerived().AlwaysRebuild() &&
17284 Base.get() == E->getBase())
17285 return E;
17286
17287 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17288 E->getLocation(),
17289 E->isArrow(), E->isFreeIvar());
17290}
17291
17292template<typename Derived>
17295 // 'super' and types never change. Property never changes. Just
17296 // retain the existing expression.
17297 if (!E->isObjectReceiver())
17298 return E;
17299
17300 // Transform the base expression.
17301 ExprResult Base = getDerived().TransformExpr(E->getBase());
17302 if (Base.isInvalid())
17303 return ExprError();
17304
17305 // We don't need to transform the property; it will never change.
17306
17307 // If nothing changed, just retain the existing expression.
17308 if (!getDerived().AlwaysRebuild() &&
17309 Base.get() == E->getBase())
17310 return E;
17311
17312 if (E->isExplicitProperty())
17313 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17314 E->getExplicitProperty(),
17315 E->getLocation());
17316
17317 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17318 SemaRef.Context.PseudoObjectTy,
17319 E->getImplicitPropertyGetter(),
17320 E->getImplicitPropertySetter(),
17321 E->getLocation());
17322}
17323
17324template<typename Derived>
17327 // Transform the base expression.
17328 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17329 if (Base.isInvalid())
17330 return ExprError();
17331
17332 // Transform the key expression.
17333 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17334 if (Key.isInvalid())
17335 return ExprError();
17336
17337 // If nothing changed, just retain the existing expression.
17338 if (!getDerived().AlwaysRebuild() &&
17339 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17340 return E;
17341
17342 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17343 Base.get(), Key.get(),
17344 E->getAtIndexMethodDecl(),
17345 E->setAtIndexMethodDecl());
17346}
17347
17348template<typename Derived>
17351 // Transform the base expression.
17352 ExprResult Base = getDerived().TransformExpr(E->getBase());
17353 if (Base.isInvalid())
17354 return ExprError();
17355
17356 // If nothing changed, just retain the existing expression.
17357 if (!getDerived().AlwaysRebuild() &&
17358 Base.get() == E->getBase())
17359 return E;
17360
17361 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17362 E->getOpLoc(),
17363 E->isArrow());
17364}
17365
17366template<typename Derived>
17369 bool ArgumentChanged = false;
17370 SmallVector<Expr*, 8> SubExprs;
17371 SubExprs.reserve(E->getNumSubExprs());
17372 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17373 SubExprs, &ArgumentChanged))
17374 return ExprError();
17375
17376 if (!getDerived().AlwaysRebuild() &&
17377 !ArgumentChanged)
17378 return E;
17379
17380 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17381 SubExprs,
17382 E->getRParenLoc());
17383}
17384
17385template<typename Derived>
17388 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17389 if (SrcExpr.isInvalid())
17390 return ExprError();
17391
17392 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17393 if (!Type)
17394 return ExprError();
17395
17396 if (!getDerived().AlwaysRebuild() &&
17397 Type == E->getTypeSourceInfo() &&
17398 SrcExpr.get() == E->getSrcExpr())
17399 return E;
17400
17401 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17402 SrcExpr.get(), Type,
17403 E->getRParenLoc());
17404}
17405
17406template<typename Derived>
17409 BlockDecl *oldBlock = E->getBlockDecl();
17410
17411 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17412 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17413
17414 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17415 blockScope->TheDecl->setBlockMissingReturnType(
17416 oldBlock->blockMissingReturnType());
17417
17419 SmallVector<QualType, 4> paramTypes;
17420
17421 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17422
17423 // Parameter substitution.
17424 Sema::ExtParameterInfoBuilder extParamInfos;
17425 if (getDerived().TransformFunctionTypeParams(
17426 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17427 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17428 extParamInfos)) {
17429 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17430 return ExprError();
17431 }
17432
17433 QualType exprResultType =
17434 getDerived().TransformType(exprFunctionType->getReturnType());
17435
17436 auto epi = exprFunctionType->getExtProtoInfo();
17437 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17438
17440 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17441 blockScope->FunctionType = functionType;
17442
17443 // Set the parameters on the block decl.
17444 if (!params.empty())
17445 blockScope->TheDecl->setParams(params);
17446
17447 if (!oldBlock->blockMissingReturnType()) {
17448 blockScope->HasImplicitReturnType = false;
17449 blockScope->ReturnType = exprResultType;
17450 }
17451
17452 // Transform the body
17453 StmtResult body = getDerived().TransformStmt(E->getBody());
17454 if (body.isInvalid()) {
17455 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17456 return ExprError();
17457 }
17458
17459#ifndef NDEBUG
17460 // In builds with assertions, make sure that we captured everything we
17461 // captured before.
17462 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17463 for (const auto &I : oldBlock->captures()) {
17464 VarDecl *oldCapture = I.getVariable();
17465
17466 // Ignore parameter packs.
17467 if (oldCapture->isParameterPack())
17468 continue;
17469
17470 VarDecl *newCapture =
17471 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17472 oldCapture));
17473 assert(blockScope->CaptureMap.count(newCapture));
17474 }
17475
17476 // The this pointer may not be captured by the instantiated block, even when
17477 // it's captured by the original block, if the expression causing the
17478 // capture is in the discarded branch of a constexpr if statement.
17479 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17480 "this pointer isn't captured in the old block");
17481 }
17482#endif
17483
17484 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17485 /*Scope=*/nullptr);
17486}
17487
17488template<typename Derived>
17491 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17492 if (SrcExpr.isInvalid())
17493 return ExprError();
17494
17495 QualType Type = getDerived().TransformType(E->getType());
17496
17497 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17498 E->getRParenLoc());
17499}
17500
17501template<typename Derived>
17504 bool ArgumentChanged = false;
17505 SmallVector<Expr*, 8> SubExprs;
17506 SubExprs.reserve(E->getNumSubExprs());
17507 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17508 SubExprs, &ArgumentChanged))
17509 return ExprError();
17510
17511 if (!getDerived().AlwaysRebuild() &&
17512 !ArgumentChanged)
17513 return E;
17514
17515 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17516 E->getOp(), E->getRParenLoc());
17517}
17518
17519//===----------------------------------------------------------------------===//
17520// Type reconstruction
17521//===----------------------------------------------------------------------===//
17522
17523template<typename Derived>
17526 return SemaRef.BuildPointerType(PointeeType, Star,
17528}
17529
17530template<typename Derived>
17533 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17535}
17536
17537template<typename Derived>
17540 bool WrittenAsLValue,
17541 SourceLocation Sigil) {
17542 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17543 Sigil, getDerived().getBaseEntity());
17544}
17545
17546template <typename Derived>
17548 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17549 SourceLocation Sigil) {
17550 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17552}
17553
17554template<typename Derived>
17556 const ObjCTypeParamDecl *Decl,
17557 SourceLocation ProtocolLAngleLoc,
17559 ArrayRef<SourceLocation> ProtocolLocs,
17560 SourceLocation ProtocolRAngleLoc) {
17561 return SemaRef.ObjC().BuildObjCTypeParamType(
17562 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17563 /*FailOnError=*/true);
17564}
17565
17566template<typename Derived>
17568 QualType BaseType,
17569 SourceLocation Loc,
17570 SourceLocation TypeArgsLAngleLoc,
17572 SourceLocation TypeArgsRAngleLoc,
17573 SourceLocation ProtocolLAngleLoc,
17575 ArrayRef<SourceLocation> ProtocolLocs,
17576 SourceLocation ProtocolRAngleLoc) {
17577 return SemaRef.ObjC().BuildObjCObjectType(
17578 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17579 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17580 /*FailOnError=*/true,
17581 /*Rebuilding=*/true);
17582}
17583
17584template<typename Derived>
17586 QualType PointeeType,
17588 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17589}
17590
17591template <typename Derived>
17593 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17594 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17595 if (SizeExpr || !Size)
17596 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17597 IndexTypeQuals, BracketsRange,
17599
17600 QualType Types[] = {
17601 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17602 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17603 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17604 };
17605 QualType SizeType;
17606 for (const auto &T : Types)
17607 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17608 SizeType = T;
17609 break;
17610 }
17611
17612 // Note that we can return a VariableArrayType here in the case where
17613 // the element type was a dependent VariableArrayType.
17614 IntegerLiteral *ArraySize
17615 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17616 /*FIXME*/BracketsRange.getBegin());
17617 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17618 IndexTypeQuals, BracketsRange,
17620}
17621
17622template <typename Derived>
17624 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17625 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17626 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17627 IndexTypeQuals, BracketsRange);
17628}
17629
17630template <typename Derived>
17632 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17633 SourceRange BracketsRange) {
17634 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17635 IndexTypeQuals, BracketsRange);
17636}
17637
17638template <typename Derived>
17640 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17641 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17642 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17643 SizeExpr,
17644 IndexTypeQuals, BracketsRange);
17645}
17646
17647template <typename Derived>
17649 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17650 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17651 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17652 SizeExpr,
17653 IndexTypeQuals, BracketsRange);
17654}
17655
17656template <typename Derived>
17658 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17659 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17660 AttributeLoc);
17661}
17662
17663template <typename Derived>
17665 unsigned NumElements,
17666 VectorKind VecKind) {
17667 // FIXME: semantic checking!
17668 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17669}
17670
17671template <typename Derived>
17673 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17674 VectorKind VecKind) {
17675 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17676}
17677
17678template<typename Derived>
17680 unsigned NumElements,
17681 SourceLocation AttributeLoc) {
17682 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17683 NumElements, true);
17684 IntegerLiteral *VectorSize
17685 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17686 AttributeLoc);
17687 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17688}
17689
17690template<typename Derived>
17693 Expr *SizeExpr,
17694 SourceLocation AttributeLoc) {
17695 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17696}
17697
17698template <typename Derived>
17700 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17701 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17702 NumColumns);
17703}
17704
17705template <typename Derived>
17707 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17708 SourceLocation AttributeLoc) {
17709 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17710 AttributeLoc);
17711}
17712
17713template <typename Derived>
17715 QualType T, MutableArrayRef<QualType> ParamTypes,
17717 return SemaRef.BuildFunctionType(T, ParamTypes,
17720 EPI);
17721}
17722
17723template<typename Derived>
17725 return SemaRef.Context.getFunctionNoProtoType(T);
17726}
17727
17728template <typename Derived>
17731 SourceLocation NameLoc, Decl *D) {
17732 assert(D && "no decl found");
17733 if (D->isInvalidDecl()) return QualType();
17734
17735 // FIXME: Doesn't account for ObjCInterfaceDecl!
17736 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17737 // A valid resolved using typename pack expansion decl can have multiple
17738 // UsingDecls, but they must each have exactly one type, and it must be
17739 // the same type in every case. But we must have at least one expansion!
17740 if (UPD->expansions().empty()) {
17741 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17742 << UPD->isCXXClassMember() << UPD;
17743 return QualType();
17744 }
17745
17746 // We might still have some unresolved types. Try to pick a resolved type
17747 // if we can. The final instantiation will check that the remaining
17748 // unresolved types instantiate to the type we pick.
17749 QualType FallbackT;
17750 QualType T;
17751 for (auto *E : UPD->expansions()) {
17752 QualType ThisT =
17753 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17754 if (ThisT.isNull())
17755 continue;
17756 if (ThisT->getAs<UnresolvedUsingType>())
17757 FallbackT = ThisT;
17758 else if (T.isNull())
17759 T = ThisT;
17760 else
17761 assert(getSema().Context.hasSameType(ThisT, T) &&
17762 "mismatched resolved types in using pack expansion");
17763 }
17764 return T.isNull() ? FallbackT : T;
17765 }
17766 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17767 assert(Using->hasTypename() &&
17768 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17769
17770 // A valid resolved using typename decl points to exactly one type decl.
17771 assert(++Using->shadow_begin() == Using->shadow_end());
17772
17773 UsingShadowDecl *Shadow = *Using->shadow_begin();
17774 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17775 return QualType();
17776 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17777 }
17779 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17780 return SemaRef.Context.getUnresolvedUsingType(
17782}
17783
17784template <typename Derived>
17786 TypeOfKind Kind) {
17787 return SemaRef.BuildTypeofExprType(E, Kind);
17788}
17789
17790template<typename Derived>
17792 TypeOfKind Kind) {
17793 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17794}
17795
17796template <typename Derived>
17798 return SemaRef.BuildDecltypeType(E);
17799}
17800
17801template <typename Derived>
17803 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17804 SourceLocation EllipsisLoc, bool FullySubstituted,
17805 ArrayRef<QualType> Expansions) {
17806 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17807 FullySubstituted, Expansions);
17808}
17809
17810template<typename Derived>
17812 UnaryTransformType::UTTKind UKind,
17813 SourceLocation Loc) {
17814 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17815}
17816
17817template <typename Derived>
17820 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17821 return SemaRef.CheckTemplateIdType(
17822 Keyword, Template, TemplateNameLoc, TemplateArgs,
17823 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17824}
17825
17826template<typename Derived>
17828 SourceLocation KWLoc) {
17829 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17830}
17831
17832template<typename Derived>
17834 SourceLocation KWLoc,
17835 bool isReadPipe) {
17836 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17837 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17838}
17839
17840template <typename Derived>
17842 unsigned NumBits,
17843 SourceLocation Loc) {
17844 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17845 NumBits, true);
17846 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17847 SemaRef.Context.IntTy, Loc);
17848 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17849}
17850
17851template <typename Derived>
17853 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17854 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17855}
17856
17857template <typename Derived>
17859 bool TemplateKW,
17860 TemplateName Name) {
17861 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17862 Name);
17863}
17864
17865template <typename Derived>
17867 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17868 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17870 TemplateName.setIdentifier(&Name, NameLoc);
17872 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17873 TemplateName, ParsedType::make(ObjectType),
17874 /*EnteringContext=*/false, Template,
17875 AllowInjectedClassName);
17876 return Template.get();
17877}
17878
17879template<typename Derived>
17882 SourceLocation TemplateKWLoc,
17883 OverloadedOperatorKind Operator,
17884 SourceLocation NameLoc,
17885 QualType ObjectType,
17886 bool AllowInjectedClassName) {
17887 UnqualifiedId Name;
17888 // FIXME: Bogus location information.
17889 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17890 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17892 getSema().ActOnTemplateName(
17893 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17894 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17895 return Template.get();
17896}
17897
17898template <typename Derived>
17901 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17902 Expr *Second) {
17903 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17904
17905 if (First->getObjectKind() == OK_ObjCProperty) {
17908 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17909 Opc, First, Second);
17910 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17911 if (Result.isInvalid())
17912 return ExprError();
17913 First = Result.get();
17914 }
17915
17916 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17917 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17918 if (Result.isInvalid())
17919 return ExprError();
17920 Second = Result.get();
17921 }
17922
17923 // Determine whether this should be a builtin operation.
17924 if (Op == OO_Subscript) {
17925 if (!First->getType()->isOverloadableType() &&
17926 !Second->getType()->isOverloadableType())
17927 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17928 OpLoc);
17929 } else if (Op == OO_Arrow) {
17930 // It is possible that the type refers to a RecoveryExpr created earlier
17931 // in the tree transformation.
17932 if (First->getType()->isDependentType())
17933 return ExprError();
17934 // -> is never a builtin operation.
17935 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17936 } else if (Second == nullptr || isPostIncDec) {
17937 if (!First->getType()->isOverloadableType() ||
17938 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17939 // The argument is not of overloadable type, or this is an expression
17940 // of the form &Class::member, so try to create a built-in unary
17941 // operation.
17943 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17944
17945 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17946 }
17947 } else {
17948 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17949 !First->getType()->isOverloadableType() &&
17950 !Second->getType()->isOverloadableType()) {
17951 // Neither of the arguments is type-dependent or has an overloadable
17952 // type, so try to create a built-in binary operation.
17955 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17956 if (Result.isInvalid())
17957 return ExprError();
17958
17959 return Result;
17960 }
17961 }
17962
17963 // Create the overloaded operator invocation for unary operators.
17964 if (!Second || isPostIncDec) {
17966 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17967 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17968 RequiresADL);
17969 }
17970
17971 // Create the overloaded operator invocation for binary operators.
17973 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17974 First, Second, RequiresADL);
17975 if (Result.isInvalid())
17976 return ExprError();
17977
17978 return Result;
17979}
17980
17981template<typename Derived>
17984 SourceLocation OperatorLoc,
17985 bool isArrow,
17986 CXXScopeSpec &SS,
17987 TypeSourceInfo *ScopeType,
17988 SourceLocation CCLoc,
17989 SourceLocation TildeLoc,
17990 PseudoDestructorTypeStorage Destroyed) {
17991 QualType CanonicalBaseType = Base->getType().getCanonicalType();
17992 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
17993 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
17994 (isArrow && isa<PointerType>(CanonicalBaseType) &&
17995 !cast<PointerType>(CanonicalBaseType)
17996 ->getPointeeType()
17997 ->getAsCanonical<RecordType>())) {
17998 // This pseudo-destructor expression is still a pseudo-destructor.
17999 return SemaRef.BuildPseudoDestructorExpr(
18000 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
18001 CCLoc, TildeLoc, Destroyed);
18002 }
18003
18004 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
18005 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
18006 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
18007 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
18008 NameInfo.setNamedTypeInfo(DestroyedType);
18009
18010 // The scope type is now known to be a valid nested name specifier
18011 // component. Tack it on to the nested name specifier.
18012 if (ScopeType) {
18013 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
18014 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
18015 diag::err_expected_class_or_namespace)
18016 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
18017 return ExprError();
18018 }
18019 SS.clear();
18020 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
18021 }
18022
18023 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
18024 return getSema().BuildMemberReferenceExpr(
18025 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
18026 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
18027 /*TemplateArgs*/ nullptr,
18028 /*S*/ nullptr);
18029}
18030
18031template<typename Derived>
18034 SourceLocation Loc = S->getBeginLoc();
18035 CapturedDecl *CD = S->getCapturedDecl();
18036 unsigned NumParams = CD->getNumParams();
18037 unsigned ContextParamPos = CD->getContextParamPosition();
18039 for (unsigned I = 0; I < NumParams; ++I) {
18040 if (I != ContextParamPos) {
18041 Params.push_back(
18042 std::make_pair(
18043 CD->getParam(I)->getName(),
18044 getDerived().TransformType(CD->getParam(I)->getType())));
18045 } else {
18046 Params.push_back(std::make_pair(StringRef(), QualType()));
18047 }
18048 }
18049 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
18050 S->getCapturedRegionKind(), Params);
18051 StmtResult Body;
18052 {
18053 Sema::CompoundScopeRAII CompoundScope(getSema());
18054 Body = getDerived().TransformStmt(S->getCapturedStmt());
18055 }
18056
18057 if (Body.isInvalid()) {
18058 getSema().ActOnCapturedRegionError();
18059 return StmtError();
18060 }
18061
18062 return getSema().ActOnCapturedRegionEnd(Body.get());
18063}
18064
18065template <typename Derived>
18068 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
18069 // function definition or instantiation of a function template specialization
18070 // and will therefore never appear in a dependent context.
18071 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
18072 "context");
18073}
18074
18075template <typename Derived>
18077 // We can transform the base expression and allow argument resolution to fill
18078 // in the rest.
18079 return getDerived().TransformExpr(E->getArgLValue());
18080}
18081
18082} // end namespace clang
18083
18084#endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
static Decl::Kind getKind(const Decl *D)
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
TokenType getType() const
Returns the token's type, e.g.
SmallVector< AnnotatedLine *, 1 > Children
If this token starts a block, this contains all the unwrapped lines in it.
#define X(type, name)
Definition Value.h:97
llvm::MachO::Record Record
Definition MachO.h:31
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
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:6024
Represents a loop initializing the elements of an array.
Definition Expr.h:5971
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1833
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7218
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:3777
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6732
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6927
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:2209
Stmt * getSubStmt()
Definition Stmt.h:2245
SourceLocation getAttrLoc() const
Definition Stmt.h:2240
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2241
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:2180
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:2142
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8288
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4689
void setIsVariadic(bool value)
Definition Decl.h:4765
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6671
Wrapper for source info for block pointers.
Definition TypeLoc.h:1526
BreakStmt - This represents a break.
Definition Stmt.h:3141
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5476
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:5495
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:5494
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition Expr.h: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:581
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:575
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition ExprCXX.h: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:2624
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:1041
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:2889
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:2136
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:5508
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:75
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:208
SourceRange getRange() const
Definition DeclSpec.h:81
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:96
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:212
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:180
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:1517
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4961
unsigned getNumParams() const
Definition Decl.h:4999
unsigned getContextParamPosition() const
Definition Decl.h:5028
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5001
This captures a statement into a function.
Definition Stmt.h:3943
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1493
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:4047
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:4138
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition Stmt.cpp:1508
CaseStmt - Represent a case statement.
Definition Stmt.h:1926
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition Expr.cpp:1980
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:5369
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:1746
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Stmt.h:1796
body_range body()
Definition Stmt.h:1809
SourceLocation getLBracLoc() const
Definition Stmt.h:1863
bool hasStoredFPFeatures() const
Definition Stmt.h:1793
Stmt * body_back()
Definition Stmt.h:1814
SourceLocation getRBracLoc() const
Definition Stmt.h:1864
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:3815
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:4442
ContinueStmt - This represents a continue.
Definition Stmt.h:3125
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:3491
Represents a 'co_yield' expression.
Definition ExprCXX.h:5450
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:1637
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:1942
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:3242
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:4116
Represents a 'co_await' expression while the type of the promise is dependent.
Definition ExprCXX.h:5401
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:4066
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2096
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4156
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition TypeBase.h:4528
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2068
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4282
Represents a single C99 designator.
Definition Expr.h:5597
Represents a C99 designated initializer expression.
Definition Expr.h:5554
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:208
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
Definition Designator.h:172
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
Definition Designator.h:142
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
Definition Designator.h:115
bool hasErrorOccurred() const
Definition Diagnostic.h:881
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2838
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Definition TypeBase.h:5082
Expr * getCondition() const
Definition TypeBase.h:5089
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:3082
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3214
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:6609
Represents difference between two FPOptions values.
FPOptions applyOverrides(FPOptions Base)
Represents a member of a struct/union/class.
Definition Decl.h:3175
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2894
Represents a function declaration or definition.
Definition Decl.h:2015
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2789
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5330
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4975
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5670
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5656
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5196
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4940
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:5362
param_type_iterator param_type_begin() const
Definition TypeBase.h:5806
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:4584
This represents a GCC inline-assembly statement extension.
Definition Stmt.h:3452
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:6181
AssociationTy< false > Association
Definition Expr.h:6414
GotoStmt - This represents a direct goto.
Definition Stmt.h:2975
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:7396
One of these records is kept for each identifier that is lexed.
IfStmt - This represents an if/then/else.
Definition Stmt.h:2265
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:6060
Represents a C array with an unspecified size.
Definition TypeBase.h:3964
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:3014
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:5475
Wrapper for source info for injected class names of class templates.
Definition TypeLoc.h:872
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition Expr.cpp:975
Represents the declaration of a label.
Definition Decl.h:524
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2152
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:1365
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1360
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1369
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:3671
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:4360
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:3708
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition Template.h:76
This represents a decl that may have a name.
Definition Decl.h:274
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition Decl.h:295
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:301
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:340
Represents C++ namespaces and their aliases.
Definition Decl.h:573
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents a place-holder for an object not to be initialized by anything.
Definition Expr.h:5880
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h:1709
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:1805
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1865
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1838
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:2923
unsigned getFunctionScopeDepth() const
Definition Decl.h:1855
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2725
PipeType - OpenCL20.
Definition TypeBase.h:8254
bool isReadOnly() const
Definition TypeBase.h:8284
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:3383
[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:6803
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:8436
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8468
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:7502
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3628
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3644
Represents the body of a requires-expression.
Definition DeclCXX.h:2105
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:3166
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition Stmt.cpp:1361
Represents a __leave statement.
Definition Stmt.h:3904
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:13758
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8532
A RAII object to enter scope of a compound statement.
Definition Sema.h:1315
A RAII object to temporarily push a declaration context.
Definition Sema.h:3526
A helper class for building up ExtParameterInfos.
Definition Sema.h:13119
const FunctionProtoType::ExtParameterInfo * getPointerOrNull(unsigned numParams)
Return a pointer (suitable for setting in an ExtProtoInfo) to the ExtParameterInfo array we've built ...
Definition Sema.h:13138
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13126
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14163
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:9415
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9423
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9418
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:7922
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7924
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7923
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:12064
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:7101
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:11867
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:11862
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:13752
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:6811
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6821
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6790
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6816
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:8401
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:11151
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:7908
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:8743
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:1711
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:1499
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:2515
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3732
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 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.
ExprResult RebuildInitList(SourceLocation LBraceLoc, MultiExprArg Inits, SourceLocation RBraceLoc)
Build a new initializer list expression.
QualType RebuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
StmtResult RebuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Operand)
Build a new Objective-C @throw statement.
OMPClause * RebuildOMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'task_reduction' clause.
StmtResult RebuildOpenACCWaitConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
OMPClause * RebuildOMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'copyin' clause.
QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc, bool isReadPipe)
Build a new pipe type given its value type.
StmtResult RebuildCaseStmt(SourceLocation CaseLoc, Expr *LHS, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation ColonLoc)
Build a new case statement.
ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
Build a new template-id expression.
StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc, VarDecl *ExceptionDecl, Stmt *Handler)
Build a new C++ catch statement.
OMPClause * RebuildOMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'destroy' clause.
ExprResult RebuildUnaryExprOrTypeTrait(Expr *SubExpr, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec step expression with an expression argument.
ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new address-of-label expression.
ExprResult RebuildCxxSubscriptExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
OMPClause * RebuildOMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_bare' clause.
const Attr * TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS, const Attr *A)
ExprResult RebuildConditionalOperator(Expr *Cond, SourceLocation QuestionLoc, Expr *LHS, SourceLocation ColonLoc, Expr *RHS)
Build a new conditional operator expression.
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
Attach body to a C++0x range-based for statement.
StmtResult RebuildOpenACCUpdateConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *Object, Stmt *Body)
Build a new Objective-C @synchronized statement.
ExprResult RebuildOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
OMPClause * RebuildOMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'device' clause.
OMPClause * RebuildOMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'has_device_addr' clause.
bool TryExpandParameterPacks(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions)
Determine whether we should expand a pack expansion with the given set of parameter packs into separa...
QualType RebuildDependentSizedExtVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
OMPClause * RebuildOMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_threads' clause.
void RememberPartiallySubstitutedPack(TemplateArgument Arg)
"Remember" the partially-substituted pack template argument after performing an instantiation that mu...
Decl * TransformDefinition(SourceLocation Loc, Decl *D)
Transform the definition of the given declaration.
ExprResult RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, UnresolvedLookupExpr *Lookup)
Build a new co_await expression.
StmtResult RebuildReturnStmt(SourceLocation ReturnLoc, Expr *Result)
Build a new return statement.
QualType TransformTemplateSpecializationType(TypeLocBuilder &TLB, TemplateSpecializationTypeLoc TL, QualType ObjectType, NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName)
TemplateArgument ForgetPartiallySubstitutedPack()
"Forget" about the partially-substituted pack template argument, when performing an instantiation tha...
OMPClause * RebuildOMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nocontext' clause.
ExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ reinterpret_cast expression.
QualType RebuildVectorType(QualType ElementType, unsigned NumElements, VectorKind VecKind)
Build a new vector type given the element type and number of elements.
ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc, TypeSourceInfo *Type, ArrayRef< Sema::OffsetOfComponent > Components, SourceLocation RParenLoc)
Build a new builtin offsetof expression.
QualType RebuildParenType(QualType InnerType)
Build a new parenthesized type.
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.
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:6273
A container of type source information.
Definition TypeBase.h:8407
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:8418
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:1871
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition TypeBase.h:2458
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition TypeBase.h:9189
bool isObjCObjectPointerType() const
Definition TypeBase.h:8852
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9266
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3577
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:1415
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2344
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:1034
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3390
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition ExprCXX.h:3464
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition ExprCXX.h:3459
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Definition ExprCXX.cpp:432
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4126
A set of unresolved declarations.
void append(iterator I, iterator E)
A set of unresolved declarations.
Wrapper for source info for unresolved typename using decls.
Definition TypeLoc.h:782
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition TypeBase.h:6078
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:3415
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3479
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:5559
Value()=default
Represents a variable declaration or definition.
Definition Decl.h:926
@ CInit
C-style initialization with assignment.
Definition Decl.h:931
@ CallInit
Call-style initialization (C++98)
Definition Decl.h:934
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1168
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:4021
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2045
Represents a GCC generic vector type.
Definition TypeBase.h:4230
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2703
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:1149
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:933
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:1830
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:3774
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:5986
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:1803
@ Deduced
The normal deduced case.
Definition TypeBase.h:1810
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
Definition TypeBase.h:1805
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:5961
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5982
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5972
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5979
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:5099
Holds information about the various types of exception specification.
Definition TypeBase.h:5419
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5435
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5421
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5424
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5427
Extra information about a function prototype.
Definition TypeBase.h:5447
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5452
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:3385
const NamespaceBaseDecl * Namespace
Iterator range representation begin:end[:step].
Definition ExprOpenMP.h:154
This structure contains most locations needed for by an OMPVarListClause.
An element in an Objective-C dictionary literal.
Definition ExprObjC.h:295
Data for list of allocators.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition Sema.h:13199
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13230
An RAII helper that pops function a function scope on exit.
Definition Sema.h:1330
Keeps information about an identifier in a nested-name-spec.
Definition Sema.h:3326
Location information for a TemplateArgument.
UnsignedOrNone OrigNumExpansions
SourceLocation Ellipsis
UnsignedOrNone NumExpansions