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.
1142 ConceptDecl *TypeConstraintConcept,
1143 ArrayRef<TemplateArgument> TypeConstraintArgs) {
1144 // Note, IsDependent is always false here: we implicitly convert an 'auto'
1145 // which has been deduced to a dependent type into an undeduced 'auto', so
1146 // that we'll retry deduction after the transformation.
1147 return SemaRef.Context.getAutoType(Deduced, Keyword,
1148 /*IsDependent*/ false, /*IsPack=*/false,
1149 TypeConstraintConcept,
1150 TypeConstraintArgs);
1151 }
1152
1153 /// By default, builds a new DeducedTemplateSpecializationType with the given
1154 /// deduced type.
1157 return SemaRef.Context.getDeducedTemplateSpecializationType(
1158 Keyword, Template, Deduced, /*IsDependent*/ false);
1159 }
1160
1161 /// Build a new template specialization type.
1162 ///
1163 /// By default, performs semantic analysis when building the template
1164 /// specialization type. Subclasses may override this routine to provide
1165 /// different behavior.
1168 SourceLocation TemplateLoc,
1170
1171 /// Build a new parenthesized type.
1172 ///
1173 /// By default, builds a new ParenType type from the inner type.
1174 /// Subclasses may override this routine to provide different behavior.
1176 return SemaRef.BuildParenType(InnerType);
1177 }
1178
1179 /// Build a new typename type that refers to an identifier.
1180 ///
1181 /// By default, performs semantic analysis when building the typename type
1182 /// (or elaborated type). Subclasses may override this routine to provide
1183 /// different behavior.
1185 SourceLocation KeywordLoc,
1186 NestedNameSpecifierLoc QualifierLoc,
1187 const IdentifierInfo *Id,
1188 SourceLocation IdLoc,
1189 bool DeducedTSTContext) {
1190 CXXScopeSpec SS;
1191 SS.Adopt(QualifierLoc);
1192
1193 if (QualifierLoc.getNestedNameSpecifier().isDependent()) {
1194 // If the name is still dependent, just build a new dependent name type.
1195 if (!SemaRef.computeDeclContext(SS))
1196 return SemaRef.Context.getDependentNameType(Keyword,
1197 QualifierLoc.getNestedNameSpecifier(),
1198 Id);
1199 }
1200
1203 return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1204 *Id, IdLoc, DeducedTSTContext);
1205 }
1206
1208
1209 // We had a dependent elaborated-type-specifier that has been transformed
1210 // into a non-dependent elaborated-type-specifier. Find the tag we're
1211 // referring to.
1213 DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1214 if (!DC)
1215 return QualType();
1216
1217 if (SemaRef.RequireCompleteDeclContext(SS, DC))
1218 return QualType();
1219
1220 TagDecl *Tag = nullptr;
1221 SemaRef.LookupQualifiedName(Result, DC);
1222 switch (Result.getResultKind()) {
1225 break;
1226
1228 Tag = Result.getAsSingle<TagDecl>();
1229 break;
1230
1233 llvm_unreachable("Tag lookup cannot find non-tags");
1234
1236 // Let the LookupResult structure handle ambiguities.
1237 return QualType();
1238 }
1239
1240 if (!Tag) {
1241 // Check where the name exists but isn't a tag type and use that to emit
1242 // better diagnostics.
1244 SemaRef.LookupQualifiedName(Result, DC);
1245 switch (Result.getResultKind()) {
1249 NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1250 NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1251 SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag)
1252 << SomeDecl << NTK << Kind;
1253 SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1254 break;
1255 }
1256 default:
1257 SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1258 << Kind << Id << DC << QualifierLoc.getSourceRange();
1259 break;
1260 }
1261 return QualType();
1262 }
1263 if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1264 IdLoc, Id)) {
1265 SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1266 SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1267 return QualType();
1268 }
1269 return getDerived().RebuildTagType(
1270 Keyword, QualifierLoc.getNestedNameSpecifier(), Tag);
1271 }
1272
1273 /// Build a new pack expansion type.
1274 ///
1275 /// By default, builds a new PackExpansionType type from the given pattern.
1276 /// Subclasses may override this routine to provide different behavior.
1278 SourceLocation EllipsisLoc,
1279 UnsignedOrNone NumExpansions) {
1280 return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1281 NumExpansions);
1282 }
1283
1284 /// Build a new atomic type given its value type.
1285 ///
1286 /// By default, performs semantic analysis when building the atomic type.
1287 /// Subclasses may override this routine to provide different behavior.
1289
1290 /// Build a new pipe type given its value type.
1292 bool isReadPipe);
1293
1294 /// Build a bit-precise int given its value type.
1295 QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits,
1296 SourceLocation Loc);
1297
1298 /// Build a dependent bit-precise int given its value type.
1299 QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
1300 SourceLocation Loc);
1301
1302 /// Build a new template name given a nested name specifier, a flag
1303 /// indicating whether the "template" keyword was provided, and the template
1304 /// that the template name refers to.
1305 ///
1306 /// By default, builds the new template name directly. Subclasses may override
1307 /// this routine to provide different behavior.
1309 TemplateName Name);
1310
1311 /// Build a new template name given a nested name specifier and the
1312 /// name that is referred to as a template.
1313 ///
1314 /// By default, performs semantic analysis to determine whether the name can
1315 /// be resolved to a specific template, then builds the appropriate kind of
1316 /// template name. Subclasses may override this routine to provide different
1317 /// behavior.
1319 SourceLocation TemplateKWLoc,
1320 const IdentifierInfo &Name,
1321 SourceLocation NameLoc, QualType ObjectType,
1322 bool AllowInjectedClassName);
1323
1324 /// Build a new template name given a nested name specifier and the
1325 /// overloaded operator name that is referred to as a template.
1326 ///
1327 /// By default, performs semantic analysis to determine whether the name can
1328 /// be resolved to a specific template, then builds the appropriate kind of
1329 /// template name. Subclasses may override this routine to provide different
1330 /// behavior.
1332 SourceLocation TemplateKWLoc,
1333 OverloadedOperatorKind Operator,
1334 SourceLocation NameLoc, QualType ObjectType,
1335 bool AllowInjectedClassName);
1336
1338 SourceLocation TemplateKWLoc,
1340 SourceLocation NameLoc, QualType ObjectType,
1341 bool AllowInjectedClassName);
1342
1343 /// Build a new template name given a template template parameter pack
1344 /// and the
1345 ///
1346 /// By default, performs semantic analysis to determine whether the name can
1347 /// be resolved to a specific template, then builds the appropriate kind of
1348 /// template name. Subclasses may override this routine to provide different
1349 /// behavior.
1351 Decl *AssociatedDecl, unsigned Index,
1352 bool Final) {
1354 ArgPack, AssociatedDecl, Index, Final);
1355 }
1356
1357 /// Build a new compound statement.
1358 ///
1359 /// By default, performs semantic analysis to build the new statement.
1360 /// Subclasses may override this routine to provide different behavior.
1362 MultiStmtArg Statements,
1363 SourceLocation RBraceLoc,
1364 bool IsStmtExpr) {
1365 return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1366 IsStmtExpr);
1367 }
1368
1369 /// Build a new case statement.
1370 ///
1371 /// By default, performs semantic analysis to build the new statement.
1372 /// Subclasses may override this routine to provide different behavior.
1374 Expr *LHS,
1375 SourceLocation EllipsisLoc,
1376 Expr *RHS,
1377 SourceLocation ColonLoc) {
1378 return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1379 ColonLoc);
1380 }
1381
1382 /// Attach the body to a new case statement.
1383 ///
1384 /// By default, performs semantic analysis to build the new statement.
1385 /// Subclasses may override this routine to provide different behavior.
1387 getSema().ActOnCaseStmtBody(S, Body);
1388 return S;
1389 }
1390
1391 /// Build a new default statement.
1392 ///
1393 /// By default, performs semantic analysis to build the new statement.
1394 /// Subclasses may override this routine to provide different behavior.
1396 SourceLocation ColonLoc,
1397 Stmt *SubStmt) {
1398 return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1399 /*CurScope=*/nullptr);
1400 }
1401
1402 /// Build a new label statement.
1403 ///
1404 /// By default, performs semantic analysis to build the new statement.
1405 /// Subclasses may override this routine to provide different behavior.
1407 SourceLocation ColonLoc, Stmt *SubStmt) {
1408 return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1409 }
1410
1411 /// Build a new attributed statement.
1412 ///
1413 /// By default, performs semantic analysis to build the new statement.
1414 /// Subclasses may override this routine to provide different behavior.
1417 Stmt *SubStmt) {
1418 if (SemaRef.CheckRebuiltStmtAttributes(Attrs))
1419 return StmtError();
1420 return SemaRef.BuildAttributedStmt(AttrLoc, Attrs, SubStmt);
1421 }
1422
1423 /// Build a new "if" statement.
1424 ///
1425 /// By default, performs semantic analysis to build the new statement.
1426 /// Subclasses may override this routine to provide different behavior.
1429 SourceLocation RParenLoc, Stmt *Init, Stmt *Then,
1430 SourceLocation ElseLoc, Stmt *Else) {
1431 return getSema().ActOnIfStmt(IfLoc, Kind, LParenLoc, Init, Cond, RParenLoc,
1432 Then, ElseLoc, Else);
1433 }
1434
1435 /// Start building a new switch statement.
1436 ///
1437 /// By default, performs semantic analysis to build the new statement.
1438 /// Subclasses may override this routine to provide different behavior.
1440 SourceLocation LParenLoc, Stmt *Init,
1442 SourceLocation RParenLoc) {
1443 return getSema().ActOnStartOfSwitchStmt(SwitchLoc, LParenLoc, Init, Cond,
1444 RParenLoc);
1445 }
1446
1447 /// Attach the body to the switch statement.
1448 ///
1449 /// By default, performs semantic analysis to build the new statement.
1450 /// Subclasses may override this routine to provide different behavior.
1452 Stmt *Switch, Stmt *Body) {
1453 return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1454 }
1455
1456 /// Build a new while statement.
1457 ///
1458 /// By default, performs semantic analysis to build the new statement.
1459 /// Subclasses may override this routine to provide different behavior.
1462 SourceLocation RParenLoc, Stmt *Body) {
1463 return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body);
1464 }
1465
1466 /// Build a new do-while statement.
1467 ///
1468 /// By default, performs semantic analysis to build the new statement.
1469 /// Subclasses may override this routine to provide different behavior.
1471 SourceLocation WhileLoc, SourceLocation LParenLoc,
1472 Expr *Cond, SourceLocation RParenLoc) {
1473 return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1474 Cond, RParenLoc);
1475 }
1476
1477 /// Build a new for statement.
1478 ///
1479 /// By default, performs semantic analysis to build the new statement.
1480 /// Subclasses may override this routine to provide different behavior.
1483 Sema::FullExprArg Inc, SourceLocation RParenLoc,
1484 Stmt *Body) {
1485 return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1486 Inc, RParenLoc, Body);
1487 }
1488
1489 /// Build a new goto statement.
1490 ///
1491 /// By default, performs semantic analysis to build the new statement.
1492 /// Subclasses may override this routine to provide different behavior.
1494 LabelDecl *Label) {
1495 return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1496 }
1497
1498 /// Build a new indirect goto statement.
1499 ///
1500 /// By default, performs semantic analysis to build the new statement.
1501 /// Subclasses may override this routine to provide different behavior.
1503 SourceLocation StarLoc,
1504 Expr *Target) {
1505 return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1506 }
1507
1508 /// Build a new return statement.
1509 ///
1510 /// By default, performs semantic analysis to build the new statement.
1511 /// Subclasses may override this routine to provide different behavior.
1513 return getSema().BuildReturnStmt(ReturnLoc, Result);
1514 }
1515
1516 /// Build a new declaration statement.
1517 ///
1518 /// By default, performs semantic analysis to build the new statement.
1519 /// Subclasses may override this routine to provide different behavior.
1521 SourceLocation StartLoc, SourceLocation EndLoc) {
1523 return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1524 }
1525
1526 /// Build a new inline asm statement.
1527 ///
1528 /// By default, performs semantic analysis to build the new statement.
1529 /// Subclasses may override this routine to provide different behavior.
1531 bool IsVolatile, unsigned NumOutputs,
1532 unsigned NumInputs, IdentifierInfo **Names,
1533 MultiExprArg Constraints, MultiExprArg Exprs,
1534 Expr *AsmString, MultiExprArg Clobbers,
1535 unsigned NumLabels,
1536 SourceLocation RParenLoc) {
1537 return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1538 NumInputs, Names, Constraints, Exprs,
1539 AsmString, Clobbers, NumLabels, RParenLoc);
1540 }
1541
1542 /// Build a new MS style inline asm statement.
1543 ///
1544 /// By default, performs semantic analysis to build the new statement.
1545 /// Subclasses may override this routine to provide different behavior.
1547 ArrayRef<Token> AsmToks,
1548 StringRef AsmString,
1549 unsigned NumOutputs, unsigned NumInputs,
1550 ArrayRef<StringRef> Constraints,
1551 ArrayRef<StringRef> Clobbers,
1552 ArrayRef<Expr*> Exprs,
1553 SourceLocation EndLoc) {
1554 return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1555 NumOutputs, NumInputs,
1556 Constraints, Clobbers, Exprs, EndLoc);
1557 }
1558
1559 /// Build a new co_return statement.
1560 ///
1561 /// By default, performs semantic analysis to build the new statement.
1562 /// Subclasses may override this routine to provide different behavior.
1564 bool IsImplicit) {
1565 return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1566 }
1567
1568 /// Build a new co_await expression.
1569 ///
1570 /// By default, performs semantic analysis to build the new expression.
1571 /// Subclasses may override this routine to provide different behavior.
1573 UnresolvedLookupExpr *OpCoawaitLookup,
1574 bool IsImplicit) {
1575 // This function rebuilds a coawait-expr given its operator.
1576 // For an explicit coawait-expr, the rebuild involves the full set
1577 // of transformations performed by BuildUnresolvedCoawaitExpr(),
1578 // including calling await_transform().
1579 // For an implicit coawait-expr, we need to rebuild the "operator
1580 // coawait" but not await_transform(), so use BuildResolvedCoawaitExpr().
1581 // This mirrors how the implicit CoawaitExpr is originally created
1582 // in Sema::ActOnCoroutineBodyStart().
1583 if (IsImplicit) {
1585 CoawaitLoc, Operand, OpCoawaitLookup);
1586 if (Suspend.isInvalid())
1587 return ExprError();
1588 return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Operand,
1589 Suspend.get(), true);
1590 }
1591
1592 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Operand,
1593 OpCoawaitLookup);
1594 }
1595
1596 /// Build a new co_await expression.
1597 ///
1598 /// By default, performs semantic analysis to build the new expression.
1599 /// Subclasses may override this routine to provide different behavior.
1601 Expr *Result,
1602 UnresolvedLookupExpr *Lookup) {
1603 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1604 }
1605
1606 /// Build a new co_yield expression.
1607 ///
1608 /// By default, performs semantic analysis to build the new expression.
1609 /// Subclasses may override this routine to provide different behavior.
1611 return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1612 }
1613
1617
1618 /// Build a new Objective-C \@try statement.
1619 ///
1620 /// By default, performs semantic analysis to build the new statement.
1621 /// Subclasses may override this routine to provide different behavior.
1623 Stmt *TryBody,
1624 MultiStmtArg CatchStmts,
1625 Stmt *Finally) {
1626 return getSema().ObjC().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1627 Finally);
1628 }
1629
1630 /// Rebuild an Objective-C exception declaration.
1631 ///
1632 /// By default, performs semantic analysis to build the new declaration.
1633 /// Subclasses may override this routine to provide different behavior.
1635 TypeSourceInfo *TInfo, QualType T) {
1637 TInfo, T, ExceptionDecl->getInnerLocStart(),
1638 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
1639 }
1640
1641 /// Build a new Objective-C \@catch statement.
1642 ///
1643 /// By default, performs semantic analysis to build the new statement.
1644 /// Subclasses may override this routine to provide different behavior.
1646 SourceLocation RParenLoc,
1647 VarDecl *Var,
1648 Stmt *Body) {
1649 return getSema().ObjC().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, Var, Body);
1650 }
1651
1652 /// Build a new Objective-C \@finally statement.
1653 ///
1654 /// By default, performs semantic analysis to build the new statement.
1655 /// Subclasses may override this routine to provide different behavior.
1657 Stmt *Body) {
1658 return getSema().ObjC().ActOnObjCAtFinallyStmt(AtLoc, Body);
1659 }
1660
1661 /// Build a new Objective-C \@throw statement.
1662 ///
1663 /// By default, performs semantic analysis to build the new statement.
1664 /// Subclasses may override this routine to provide different behavior.
1666 Expr *Operand) {
1667 return getSema().ObjC().BuildObjCAtThrowStmt(AtLoc, Operand);
1668 }
1669
1670 /// Build a new OpenMP Canonical loop.
1671 ///
1672 /// Ensures that the outermost loop in @p LoopStmt is wrapped by a
1673 /// OMPCanonicalLoop.
1675 return getSema().OpenMP().ActOnOpenMPCanonicalLoop(LoopStmt);
1676 }
1677
1678 /// Build a new OpenMP executable directive.
1679 ///
1680 /// By default, performs semantic analysis to build the new statement.
1681 /// Subclasses may override this routine to provide different behavior.
1683 DeclarationNameInfo DirName,
1684 OpenMPDirectiveKind CancelRegion,
1685 ArrayRef<OMPClause *> Clauses,
1686 Stmt *AStmt, SourceLocation StartLoc,
1687 SourceLocation EndLoc) {
1688
1690 Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1691 }
1692
1693 /// Build a new OpenMP informational directive.
1695 DeclarationNameInfo DirName,
1696 ArrayRef<OMPClause *> Clauses,
1697 Stmt *AStmt,
1698 SourceLocation StartLoc,
1699 SourceLocation EndLoc) {
1700
1702 Kind, DirName, Clauses, AStmt, StartLoc, EndLoc);
1703 }
1704
1705 /// Build a new OpenMP 'if' clause.
1706 ///
1707 /// By default, performs semantic analysis to build the new OpenMP clause.
1708 /// Subclasses may override this routine to provide different behavior.
1710 Expr *Condition, SourceLocation StartLoc,
1711 SourceLocation LParenLoc,
1712 SourceLocation NameModifierLoc,
1713 SourceLocation ColonLoc,
1714 SourceLocation EndLoc) {
1716 NameModifier, Condition, StartLoc, LParenLoc, NameModifierLoc, ColonLoc,
1717 EndLoc);
1718 }
1719
1720 /// Build a new OpenMP 'final' clause.
1721 ///
1722 /// By default, performs semantic analysis to build the new OpenMP clause.
1723 /// Subclasses may override this routine to provide different behavior.
1725 SourceLocation LParenLoc,
1726 SourceLocation EndLoc) {
1727 return getSema().OpenMP().ActOnOpenMPFinalClause(Condition, StartLoc,
1728 LParenLoc, EndLoc);
1729 }
1730
1731 /// Build a new OpenMP 'num_threads' clause.
1732 ///
1733 /// By default, performs semantic analysis to build the new OpenMP clause.
1734 /// Subclasses may override this routine to provide different behavior.
1736 Expr *NumThreads,
1737 SourceLocation StartLoc,
1738 SourceLocation LParenLoc,
1739 SourceLocation ModifierLoc,
1740 SourceLocation EndLoc) {
1742 Modifier, NumThreads, StartLoc, LParenLoc, ModifierLoc, EndLoc);
1743 }
1744
1745 /// Build a new OpenMP 'safelen' clause.
1746 ///
1747 /// By default, performs semantic analysis to build the new OpenMP clause.
1748 /// Subclasses may override this routine to provide different behavior.
1750 SourceLocation LParenLoc,
1751 SourceLocation EndLoc) {
1752 return getSema().OpenMP().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc,
1753 EndLoc);
1754 }
1755
1756 /// Build a new OpenMP 'simdlen' clause.
1757 ///
1758 /// By default, performs semantic analysis to build the new OpenMP clause.
1759 /// Subclasses may override this routine to provide different behavior.
1761 SourceLocation LParenLoc,
1762 SourceLocation EndLoc) {
1763 return getSema().OpenMP().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc,
1764 EndLoc);
1765 }
1766
1768 SourceLocation StartLoc,
1769 SourceLocation LParenLoc,
1770 SourceLocation EndLoc) {
1771 return getSema().OpenMP().ActOnOpenMPSizesClause(Sizes, StartLoc, LParenLoc,
1772 EndLoc);
1773 }
1774
1775 /// Build a new OpenMP 'permutation' clause.
1777 SourceLocation StartLoc,
1778 SourceLocation LParenLoc,
1779 SourceLocation EndLoc) {
1780 return getSema().OpenMP().ActOnOpenMPPermutationClause(PermExprs, StartLoc,
1781 LParenLoc, EndLoc);
1782 }
1783
1784 /// Build a new OpenMP 'full' clause.
1786 SourceLocation EndLoc) {
1787 return getSema().OpenMP().ActOnOpenMPFullClause(StartLoc, EndLoc);
1788 }
1789
1790 /// Build a new OpenMP 'partial' clause.
1792 SourceLocation LParenLoc,
1793 SourceLocation EndLoc) {
1794 return getSema().OpenMP().ActOnOpenMPPartialClause(Factor, StartLoc,
1795 LParenLoc, EndLoc);
1796 }
1797
1798 OMPClause *
1800 SourceLocation LParenLoc, SourceLocation FirstLoc,
1801 SourceLocation CountLoc, SourceLocation EndLoc) {
1803 First, Count, StartLoc, LParenLoc, FirstLoc, CountLoc, EndLoc);
1804 }
1805
1806 /// Build a new OpenMP 'allocator' clause.
1807 ///
1808 /// By default, performs semantic analysis to build the new OpenMP clause.
1809 /// Subclasses may override this routine to provide different behavior.
1811 SourceLocation LParenLoc,
1812 SourceLocation EndLoc) {
1813 return getSema().OpenMP().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc,
1814 EndLoc);
1815 }
1816
1817 /// Build a new OpenMP 'collapse' clause.
1818 ///
1819 /// By default, performs semantic analysis to build the new OpenMP clause.
1820 /// Subclasses may override this routine to provide different behavior.
1822 SourceLocation LParenLoc,
1823 SourceLocation EndLoc) {
1824 return getSema().OpenMP().ActOnOpenMPCollapseClause(Num, StartLoc,
1825 LParenLoc, EndLoc);
1826 }
1827
1828 /// Build a new OpenMP 'default' clause.
1829 ///
1830 /// By default, performs semantic analysis to build the new OpenMP clause.
1831 /// Subclasses may override this routine to provide different behavior.
1834 SourceLocation VCLoc,
1835 SourceLocation StartLoc,
1836 SourceLocation LParenLoc,
1837 SourceLocation EndLoc) {
1839 Kind, KindKwLoc, VCKind, VCLoc, StartLoc, LParenLoc, EndLoc);
1840 }
1841
1842 /// Build a new OpenMP 'proc_bind' clause.
1843 ///
1844 /// By default, performs semantic analysis to build the new OpenMP clause.
1845 /// Subclasses may override this routine to provide different behavior.
1847 SourceLocation KindKwLoc,
1848 SourceLocation StartLoc,
1849 SourceLocation LParenLoc,
1850 SourceLocation EndLoc) {
1852 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1853 }
1855 SourceLocation StartLoc,
1856 SourceLocation LParenLoc,
1857 SourceLocation EndLoc) {
1859 ImpexTypeArg, StartLoc, LParenLoc, EndLoc);
1860 }
1861
1862 /// Build a new OpenMP 'schedule' clause.
1863 ///
1864 /// By default, performs semantic analysis to build the new OpenMP clause.
1865 /// Subclasses may override this routine to provide different behavior.
1868 OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1869 SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1870 SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1872 M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1873 CommaLoc, EndLoc);
1874 }
1875
1876 /// Build a new OpenMP 'ordered' clause.
1877 ///
1878 /// By default, performs semantic analysis to build the new OpenMP clause.
1879 /// Subclasses may override this routine to provide different behavior.
1881 SourceLocation EndLoc,
1882 SourceLocation LParenLoc, Expr *Num) {
1883 return getSema().OpenMP().ActOnOpenMPOrderedClause(StartLoc, EndLoc,
1884 LParenLoc, Num);
1885 }
1886
1887 /// Build a new OpenMP 'nowait' clause.
1888 ///
1889 /// By default, performs semantic analysis to build the new OpenMP clause.
1890 /// Subclasses may override this routine to provide different behavior.
1892 SourceLocation LParenLoc,
1893 SourceLocation EndLoc) {
1894 return getSema().OpenMP().ActOnOpenMPNowaitClause(StartLoc, EndLoc,
1895 LParenLoc, Condition);
1896 }
1897
1898 /// Build a new OpenMP 'private' clause.
1899 ///
1900 /// By default, performs semantic analysis to build the new OpenMP clause.
1901 /// Subclasses may override this routine to provide different behavior.
1903 SourceLocation StartLoc,
1904 SourceLocation LParenLoc,
1905 SourceLocation EndLoc) {
1906 return getSema().OpenMP().ActOnOpenMPPrivateClause(VarList, StartLoc,
1907 LParenLoc, EndLoc);
1908 }
1909
1910 /// Build a new OpenMP 'firstprivate' clause.
1911 ///
1912 /// By default, performs semantic analysis to build the new OpenMP clause.
1913 /// Subclasses may override this routine to provide different behavior.
1915 SourceLocation StartLoc,
1916 SourceLocation LParenLoc,
1917 SourceLocation EndLoc) {
1918 return getSema().OpenMP().ActOnOpenMPFirstprivateClause(VarList, StartLoc,
1919 LParenLoc, EndLoc);
1920 }
1921
1922 /// Build a new OpenMP 'lastprivate' clause.
1923 ///
1924 /// By default, performs semantic analysis to build the new OpenMP clause.
1925 /// Subclasses may override this routine to provide different behavior.
1928 SourceLocation LPKindLoc,
1929 SourceLocation ColonLoc,
1930 SourceLocation StartLoc,
1931 SourceLocation LParenLoc,
1932 SourceLocation EndLoc) {
1934 VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1935 }
1936
1937 /// Build a new OpenMP 'shared' clause.
1938 ///
1939 /// By default, performs semantic analysis to build the new OpenMP clause.
1940 /// Subclasses may override this routine to provide different behavior.
1942 SourceLocation StartLoc,
1943 SourceLocation LParenLoc,
1944 SourceLocation EndLoc) {
1945 return getSema().OpenMP().ActOnOpenMPSharedClause(VarList, StartLoc,
1946 LParenLoc, EndLoc);
1947 }
1948
1949 /// Build a new OpenMP 'reduction' clause.
1950 ///
1951 /// By default, performs semantic analysis to build the new statement.
1952 /// Subclasses may override this routine to provide different behavior.
1955 OpenMPOriginalSharingModifier OriginalSharingModifier,
1956 SourceLocation StartLoc, SourceLocation LParenLoc,
1957 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1958 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
1959 const DeclarationNameInfo &ReductionId,
1960 ArrayRef<Expr *> UnresolvedReductions) {
1962 VarList, {Modifier, OriginalSharingModifier}, StartLoc, LParenLoc,
1963 ModifierLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, ReductionId,
1964 UnresolvedReductions);
1965 }
1966
1967 /// Build a new OpenMP 'task_reduction' clause.
1968 ///
1969 /// By default, performs semantic analysis to build the new statement.
1970 /// Subclasses may override this routine to provide different behavior.
1972 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1973 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
1974 CXXScopeSpec &ReductionIdScopeSpec,
1975 const DeclarationNameInfo &ReductionId,
1976 ArrayRef<Expr *> UnresolvedReductions) {
1978 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1979 ReductionId, UnresolvedReductions);
1980 }
1981
1982 /// Build a new OpenMP 'in_reduction' clause.
1983 ///
1984 /// By default, performs semantic analysis to build the new statement.
1985 /// Subclasses may override this routine to provide different behavior.
1986 OMPClause *
1988 SourceLocation LParenLoc, SourceLocation ColonLoc,
1989 SourceLocation EndLoc,
1990 CXXScopeSpec &ReductionIdScopeSpec,
1991 const DeclarationNameInfo &ReductionId,
1992 ArrayRef<Expr *> UnresolvedReductions) {
1994 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1995 ReductionId, UnresolvedReductions);
1996 }
1997
1998 /// Build a new OpenMP 'linear' clause.
1999 ///
2000 /// By default, performs semantic analysis to build the new OpenMP clause.
2001 /// Subclasses may override this routine to provide different behavior.
2003 ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc,
2004 SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier,
2005 SourceLocation ModifierLoc, SourceLocation ColonLoc,
2006 SourceLocation StepModifierLoc, SourceLocation EndLoc) {
2008 VarList, Step, StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc,
2009 StepModifierLoc, EndLoc);
2010 }
2011
2012 /// Build a new OpenMP 'aligned' clause.
2013 ///
2014 /// By default, performs semantic analysis to build the new OpenMP clause.
2015 /// Subclasses may override this routine to provide different behavior.
2017 SourceLocation StartLoc,
2018 SourceLocation LParenLoc,
2019 SourceLocation ColonLoc,
2020 SourceLocation EndLoc) {
2022 VarList, Alignment, StartLoc, LParenLoc, ColonLoc, EndLoc);
2023 }
2024
2025 /// Build a new OpenMP 'copyin' clause.
2026 ///
2027 /// By default, performs semantic analysis to build the new OpenMP clause.
2028 /// Subclasses may override this routine to provide different behavior.
2030 SourceLocation StartLoc,
2031 SourceLocation LParenLoc,
2032 SourceLocation EndLoc) {
2033 return getSema().OpenMP().ActOnOpenMPCopyinClause(VarList, StartLoc,
2034 LParenLoc, EndLoc);
2035 }
2036
2037 /// Build a new OpenMP 'copyprivate' clause.
2038 ///
2039 /// By default, performs semantic analysis to build the new OpenMP clause.
2040 /// Subclasses may override this routine to provide different behavior.
2042 SourceLocation StartLoc,
2043 SourceLocation LParenLoc,
2044 SourceLocation EndLoc) {
2045 return getSema().OpenMP().ActOnOpenMPCopyprivateClause(VarList, StartLoc,
2046 LParenLoc, EndLoc);
2047 }
2048
2049 /// Build a new OpenMP 'flush' pseudo clause.
2050 ///
2051 /// By default, performs semantic analysis to build the new OpenMP clause.
2052 /// Subclasses may override this routine to provide different behavior.
2054 SourceLocation StartLoc,
2055 SourceLocation LParenLoc,
2056 SourceLocation EndLoc) {
2057 return getSema().OpenMP().ActOnOpenMPFlushClause(VarList, StartLoc,
2058 LParenLoc, EndLoc);
2059 }
2060
2061 /// Build a new OpenMP 'depobj' pseudo clause.
2062 ///
2063 /// By default, performs semantic analysis to build the new OpenMP clause.
2064 /// Subclasses may override this routine to provide different behavior.
2066 SourceLocation LParenLoc,
2067 SourceLocation EndLoc) {
2068 return getSema().OpenMP().ActOnOpenMPDepobjClause(Depobj, StartLoc,
2069 LParenLoc, EndLoc);
2070 }
2071
2072 /// Build a new OpenMP 'depend' pseudo clause.
2073 ///
2074 /// By default, performs semantic analysis to build the new OpenMP clause.
2075 /// Subclasses may override this routine to provide different behavior.
2077 Expr *DepModifier, ArrayRef<Expr *> VarList,
2078 SourceLocation StartLoc,
2079 SourceLocation LParenLoc,
2080 SourceLocation EndLoc) {
2082 Data, DepModifier, VarList, StartLoc, LParenLoc, EndLoc);
2083 }
2084
2085 /// Build a new OpenMP 'device' clause.
2086 ///
2087 /// By default, performs semantic analysis to build the new statement.
2088 /// Subclasses may override this routine to provide different behavior.
2090 Expr *Device, SourceLocation StartLoc,
2091 SourceLocation LParenLoc,
2092 SourceLocation ModifierLoc,
2093 SourceLocation EndLoc) {
2095 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2096 }
2097
2098 /// Build a new OpenMP 'map' clause.
2099 ///
2100 /// By default, performs semantic analysis to build the new OpenMP clause.
2101 /// Subclasses may override this routine to provide different behavior.
2103 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
2104 ArrayRef<SourceLocation> MapTypeModifiersLoc,
2105 CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId,
2106 OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
2107 SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
2108 const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) {
2110 IteratorModifier, MapTypeModifiers, MapTypeModifiersLoc,
2111 MapperIdScopeSpec, MapperId, MapType, IsMapTypeImplicit, MapLoc,
2112 ColonLoc, VarList, Locs,
2113 /*NoDiagnose=*/false, UnresolvedMappers);
2114 }
2115
2116 /// Build a new OpenMP 'allocate' clause.
2117 ///
2118 /// By default, performs semantic analysis to build the new OpenMP clause.
2119 /// Subclasses may override this routine to provide different behavior.
2120 OMPClause *
2121 RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment,
2122 OpenMPAllocateClauseModifier FirstModifier,
2123 SourceLocation FirstModifierLoc,
2124 OpenMPAllocateClauseModifier SecondModifier,
2125 SourceLocation SecondModifierLoc,
2126 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2127 SourceLocation LParenLoc, SourceLocation ColonLoc,
2128 SourceLocation EndLoc) {
2130 Allocate, Alignment, FirstModifier, FirstModifierLoc, SecondModifier,
2131 SecondModifierLoc, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc);
2132 }
2133
2134 /// Build a new OpenMP 'num_teams' clause.
2135 ///
2136 /// By default, performs semantic analysis to build the new statement.
2137 /// Subclasses may override this routine to provide different behavior.
2139 SourceLocation StartLoc,
2140 SourceLocation LParenLoc,
2141 SourceLocation EndLoc) {
2142 return getSema().OpenMP().ActOnOpenMPNumTeamsClause(VarList, StartLoc,
2143 LParenLoc, EndLoc);
2144 }
2145
2146 /// Build a new OpenMP 'thread_limit' clause.
2147 ///
2148 /// By default, performs semantic analysis to build the new statement.
2149 /// Subclasses may override this routine to provide different behavior.
2151 SourceLocation StartLoc,
2152 SourceLocation LParenLoc,
2153 SourceLocation EndLoc) {
2154 return getSema().OpenMP().ActOnOpenMPThreadLimitClause(VarList, StartLoc,
2155 LParenLoc, EndLoc);
2156 }
2157
2158 /// Build a new OpenMP 'priority' clause.
2159 ///
2160 /// By default, performs semantic analysis to build the new statement.
2161 /// Subclasses may override this routine to provide different behavior.
2163 SourceLocation LParenLoc,
2164 SourceLocation EndLoc) {
2165 return getSema().OpenMP().ActOnOpenMPPriorityClause(Priority, StartLoc,
2166 LParenLoc, EndLoc);
2167 }
2168
2169 /// Build a new OpenMP 'grainsize' clause.
2170 ///
2171 /// By default, performs semantic analysis to build the new statement.
2172 /// Subclasses may override this routine to provide different behavior.
2174 Expr *Device, SourceLocation StartLoc,
2175 SourceLocation LParenLoc,
2176 SourceLocation ModifierLoc,
2177 SourceLocation EndLoc) {
2179 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2180 }
2181
2182 /// Build a new OpenMP 'num_tasks' clause.
2183 ///
2184 /// By default, performs semantic analysis to build the new statement.
2185 /// Subclasses may override this routine to provide different behavior.
2187 Expr *NumTasks, SourceLocation StartLoc,
2188 SourceLocation LParenLoc,
2189 SourceLocation ModifierLoc,
2190 SourceLocation EndLoc) {
2192 Modifier, NumTasks, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2193 }
2194
2195 /// Build a new OpenMP 'hint' clause.
2196 ///
2197 /// By default, performs semantic analysis to build the new statement.
2198 /// Subclasses may override this routine to provide different behavior.
2200 SourceLocation LParenLoc,
2201 SourceLocation EndLoc) {
2202 return getSema().OpenMP().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc,
2203 EndLoc);
2204 }
2205
2206 /// Build a new OpenMP 'detach' clause.
2207 ///
2208 /// By default, performs semantic analysis to build the new statement.
2209 /// Subclasses may override this routine to provide different behavior.
2211 SourceLocation LParenLoc,
2212 SourceLocation EndLoc) {
2213 return getSema().OpenMP().ActOnOpenMPDetachClause(Evt, StartLoc, LParenLoc,
2214 EndLoc);
2215 }
2216
2217 /// Build a new OpenMP 'dist_schedule' clause.
2218 ///
2219 /// By default, performs semantic analysis to build the new OpenMP clause.
2220 /// Subclasses may override this routine to provide different behavior.
2221 OMPClause *
2223 Expr *ChunkSize, SourceLocation StartLoc,
2224 SourceLocation LParenLoc, SourceLocation KindLoc,
2225 SourceLocation CommaLoc, SourceLocation EndLoc) {
2227 Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
2228 }
2229
2230 /// Build a new OpenMP 'to' clause.
2231 ///
2232 /// By default, performs semantic analysis to build the new statement.
2233 /// Subclasses may override this routine to provide different behavior.
2234 OMPClause *
2236 ArrayRef<SourceLocation> MotionModifiersLoc,
2237 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2238 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2239 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2240 ArrayRef<Expr *> UnresolvedMappers) {
2242 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2243 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2244 UnresolvedMappers);
2245 }
2246
2247 /// Build a new OpenMP 'from' clause.
2248 ///
2249 /// By default, performs semantic analysis to build the new statement.
2250 /// Subclasses may override this routine to provide different behavior.
2251 OMPClause *
2253 ArrayRef<SourceLocation> MotionModifiersLoc,
2254 Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec,
2255 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2256 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2257 ArrayRef<Expr *> UnresolvedMappers) {
2259 MotionModifiers, MotionModifiersLoc, IteratorModifier,
2260 MapperIdScopeSpec, MapperId, ColonLoc, VarList, Locs,
2261 UnresolvedMappers);
2262 }
2263
2264 /// Build a new OpenMP 'use_device_ptr' clause.
2265 ///
2266 /// By default, performs semantic analysis to build the new OpenMP clause.
2267 /// Subclasses may override this routine to provide different behavior.
2269 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2270 OpenMPUseDevicePtrFallbackModifier FallbackModifier,
2271 SourceLocation FallbackModifierLoc) {
2273 VarList, Locs, FallbackModifier, FallbackModifierLoc);
2274 }
2275
2276 /// Build a new OpenMP 'use_device_addr' clause.
2277 ///
2278 /// By default, performs semantic analysis to build the new OpenMP clause.
2279 /// Subclasses may override this routine to provide different behavior.
2284
2285 /// Build a new OpenMP 'is_device_ptr' clause.
2286 ///
2287 /// By default, performs semantic analysis to build the new OpenMP clause.
2288 /// Subclasses may override this routine to provide different behavior.
2290 const OMPVarListLocTy &Locs) {
2291 return getSema().OpenMP().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
2292 }
2293
2294 /// Build a new OpenMP 'has_device_addr' clause.
2295 ///
2296 /// By default, performs semantic analysis to build the new OpenMP clause.
2297 /// Subclasses may override this routine to provide different behavior.
2302
2303 /// Build a new OpenMP 'defaultmap' clause.
2304 ///
2305 /// By default, performs semantic analysis to build the new OpenMP clause.
2306 /// Subclasses may override this routine to provide different behavior.
2309 SourceLocation StartLoc,
2310 SourceLocation LParenLoc,
2311 SourceLocation MLoc,
2312 SourceLocation KindLoc,
2313 SourceLocation EndLoc) {
2315 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2316 }
2317
2318 /// Build a new OpenMP 'nontemporal' clause.
2319 ///
2320 /// By default, performs semantic analysis to build the new OpenMP clause.
2321 /// Subclasses may override this routine to provide different behavior.
2323 SourceLocation StartLoc,
2324 SourceLocation LParenLoc,
2325 SourceLocation EndLoc) {
2326 return getSema().OpenMP().ActOnOpenMPNontemporalClause(VarList, StartLoc,
2327 LParenLoc, EndLoc);
2328 }
2329
2330 /// Build a new OpenMP 'inclusive' clause.
2331 ///
2332 /// By default, performs semantic analysis to build the new OpenMP clause.
2333 /// Subclasses may override this routine to provide different behavior.
2335 SourceLocation StartLoc,
2336 SourceLocation LParenLoc,
2337 SourceLocation EndLoc) {
2338 return getSema().OpenMP().ActOnOpenMPInclusiveClause(VarList, StartLoc,
2339 LParenLoc, EndLoc);
2340 }
2341
2342 /// Build a new OpenMP 'exclusive' clause.
2343 ///
2344 /// By default, performs semantic analysis to build the new OpenMP clause.
2345 /// Subclasses may override this routine to provide different behavior.
2347 SourceLocation StartLoc,
2348 SourceLocation LParenLoc,
2349 SourceLocation EndLoc) {
2350 return getSema().OpenMP().ActOnOpenMPExclusiveClause(VarList, StartLoc,
2351 LParenLoc, EndLoc);
2352 }
2353
2354 /// Build a new OpenMP 'uses_allocators' clause.
2355 ///
2356 /// By default, performs semantic analysis to build the new OpenMP clause.
2357 /// Subclasses may override this routine to provide different behavior.
2364
2365 /// Build a new OpenMP 'affinity' clause.
2366 ///
2367 /// By default, performs semantic analysis to build the new OpenMP clause.
2368 /// Subclasses may override this routine to provide different behavior.
2370 SourceLocation LParenLoc,
2371 SourceLocation ColonLoc,
2372 SourceLocation EndLoc, Expr *Modifier,
2373 ArrayRef<Expr *> Locators) {
2375 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2376 }
2377
2378 /// Build a new OpenMP 'order' clause.
2379 ///
2380 /// By default, performs semantic analysis to build the new OpenMP clause.
2381 /// Subclasses may override this routine to provide different behavior.
2383 OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc,
2384 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
2385 OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc) {
2387 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2388 }
2389
2390 /// Build a new OpenMP 'init' clause.
2391 ///
2392 /// By default, performs semantic analysis to build the new OpenMP clause.
2393 /// Subclasses may override this routine to provide different behavior.
2395 SourceLocation StartLoc,
2396 SourceLocation LParenLoc,
2397 SourceLocation VarLoc,
2398 SourceLocation EndLoc) {
2400 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2401 }
2402
2403 /// Build a new OpenMP 'use' clause.
2404 ///
2405 /// By default, performs semantic analysis to build the new OpenMP clause.
2406 /// Subclasses may override this routine to provide different behavior.
2408 SourceLocation LParenLoc,
2409 SourceLocation VarLoc, SourceLocation EndLoc) {
2410 return getSema().OpenMP().ActOnOpenMPUseClause(InteropVar, StartLoc,
2411 LParenLoc, VarLoc, EndLoc);
2412 }
2413
2414 /// Build a new OpenMP 'destroy' clause.
2415 ///
2416 /// By default, performs semantic analysis to build the new OpenMP clause.
2417 /// Subclasses may override this routine to provide different behavior.
2419 SourceLocation LParenLoc,
2420 SourceLocation VarLoc,
2421 SourceLocation EndLoc) {
2423 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2424 }
2425
2426 /// Build a new OpenMP 'novariants' clause.
2427 ///
2428 /// By default, performs semantic analysis to build the new OpenMP clause.
2429 /// Subclasses may override this routine to provide different behavior.
2431 SourceLocation StartLoc,
2432 SourceLocation LParenLoc,
2433 SourceLocation EndLoc) {
2435 LParenLoc, EndLoc);
2436 }
2437
2438 /// Build a new OpenMP 'nocontext' clause.
2439 ///
2440 /// By default, performs semantic analysis to build the new OpenMP clause.
2441 /// Subclasses may override this routine to provide different behavior.
2443 SourceLocation LParenLoc,
2444 SourceLocation EndLoc) {
2446 LParenLoc, EndLoc);
2447 }
2448
2449 /// Build a new OpenMP 'filter' clause.
2450 ///
2451 /// By default, performs semantic analysis to build the new OpenMP clause.
2452 /// Subclasses may override this routine to provide different behavior.
2454 SourceLocation LParenLoc,
2455 SourceLocation EndLoc) {
2456 return getSema().OpenMP().ActOnOpenMPFilterClause(ThreadID, StartLoc,
2457 LParenLoc, EndLoc);
2458 }
2459
2460 /// Build a new OpenMP 'bind' clause.
2461 ///
2462 /// By default, performs semantic analysis to build the new OpenMP clause.
2463 /// Subclasses may override this routine to provide different behavior.
2465 SourceLocation KindLoc,
2466 SourceLocation StartLoc,
2467 SourceLocation LParenLoc,
2468 SourceLocation EndLoc) {
2469 return getSema().OpenMP().ActOnOpenMPBindClause(Kind, KindLoc, StartLoc,
2470 LParenLoc, EndLoc);
2471 }
2472
2473 /// Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
2474 ///
2475 /// By default, performs semantic analysis to build the new OpenMP clause.
2476 /// Subclasses may override this routine to provide different behavior.
2478 SourceLocation LParenLoc,
2479 SourceLocation EndLoc) {
2480 return getSema().OpenMP().ActOnOpenMPXDynCGroupMemClause(Size, StartLoc,
2481 LParenLoc, EndLoc);
2482 }
2483
2484 /// Build a new OpenMP 'dyn_groupprivate' clause.
2485 ///
2486 /// By default, performs semantic analysis to build the new OpenMP clause.
2487 /// Subclasses may override this routine to provide different behavior.
2491 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc,
2492 SourceLocation M2Loc, SourceLocation EndLoc) {
2494 M1, M2, Size, StartLoc, LParenLoc, M1Loc, M2Loc, EndLoc);
2495 }
2496
2497 /// Build a new OpenMP 'ompx_attribute' clause.
2498 ///
2499 /// By default, performs semantic analysis to build the new OpenMP clause.
2500 /// Subclasses may override this routine to provide different behavior.
2502 SourceLocation StartLoc,
2503 SourceLocation LParenLoc,
2504 SourceLocation EndLoc) {
2505 return getSema().OpenMP().ActOnOpenMPXAttributeClause(Attrs, StartLoc,
2506 LParenLoc, EndLoc);
2507 }
2508
2509 /// Build a new OpenMP 'ompx_bare' clause.
2510 ///
2511 /// By default, performs semantic analysis to build the new OpenMP clause.
2512 /// Subclasses may override this routine to provide different behavior.
2514 SourceLocation EndLoc) {
2515 return getSema().OpenMP().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2516 }
2517
2518 /// Build a new OpenMP 'align' clause.
2519 ///
2520 /// By default, performs semantic analysis to build the new OpenMP clause.
2521 /// Subclasses may override this routine to provide different behavior.
2523 SourceLocation LParenLoc,
2524 SourceLocation EndLoc) {
2525 return getSema().OpenMP().ActOnOpenMPAlignClause(A, StartLoc, LParenLoc,
2526 EndLoc);
2527 }
2528
2529 /// Build a new OpenMP 'at' clause.
2530 ///
2531 /// By default, performs semantic analysis to build the new OpenMP clause.
2532 /// Subclasses may override this routine to provide different behavior.
2534 SourceLocation StartLoc,
2535 SourceLocation LParenLoc,
2536 SourceLocation EndLoc) {
2537 return getSema().OpenMP().ActOnOpenMPAtClause(Kind, KwLoc, StartLoc,
2538 LParenLoc, EndLoc);
2539 }
2540
2541 /// Build a new OpenMP 'severity' clause.
2542 ///
2543 /// By default, performs semantic analysis to build the new OpenMP clause.
2544 /// Subclasses may override this routine to provide different behavior.
2546 SourceLocation KwLoc,
2547 SourceLocation StartLoc,
2548 SourceLocation LParenLoc,
2549 SourceLocation EndLoc) {
2550 return getSema().OpenMP().ActOnOpenMPSeverityClause(Kind, KwLoc, StartLoc,
2551 LParenLoc, EndLoc);
2552 }
2553
2554 /// Build a new OpenMP 'message' clause.
2555 ///
2556 /// By default, performs semantic analysis to build the new OpenMP clause.
2557 /// Subclasses may override this routine to provide different behavior.
2559 SourceLocation LParenLoc,
2560 SourceLocation EndLoc) {
2561 return getSema().OpenMP().ActOnOpenMPMessageClause(MS, StartLoc, LParenLoc,
2562 EndLoc);
2563 }
2564
2565 /// Build a new OpenMP 'doacross' clause.
2566 ///
2567 /// By default, performs semantic analysis to build the new OpenMP clause.
2568 /// Subclasses may override this routine to provide different behavior.
2569 OMPClause *
2571 SourceLocation DepLoc, SourceLocation ColonLoc,
2572 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2573 SourceLocation LParenLoc, SourceLocation EndLoc) {
2575 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2576 }
2577
2578 /// Build a new OpenMP 'holds' clause.
2580 SourceLocation LParenLoc,
2581 SourceLocation EndLoc) {
2582 return getSema().OpenMP().ActOnOpenMPHoldsClause(A, StartLoc, LParenLoc,
2583 EndLoc);
2584 }
2585
2586 /// Rebuild the operand to an Objective-C \@synchronized statement.
2587 ///
2588 /// By default, performs semantic analysis to build the new statement.
2589 /// Subclasses may override this routine to provide different behavior.
2594
2595 /// Build a new Objective-C \@synchronized statement.
2596 ///
2597 /// By default, performs semantic analysis to build the new statement.
2598 /// Subclasses may override this routine to provide different behavior.
2600 Expr *Object, Stmt *Body) {
2601 return getSema().ObjC().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
2602 }
2603
2604 /// Build a new Objective-C \@autoreleasepool statement.
2605 ///
2606 /// By default, performs semantic analysis to build the new statement.
2607 /// Subclasses may override this routine to provide different behavior.
2612
2613 /// Build a new Objective-C fast enumeration statement.
2614 ///
2615 /// By default, performs semantic analysis to build the new statement.
2616 /// Subclasses may override this routine to provide different behavior.
2618 Stmt *Element,
2619 Expr *Collection,
2620 SourceLocation RParenLoc,
2621 Stmt *Body) {
2623 ForLoc, Element, Collection, RParenLoc);
2624 if (ForEachStmt.isInvalid())
2625 return StmtError();
2626
2627 return getSema().ObjC().FinishObjCForCollectionStmt(ForEachStmt.get(),
2628 Body);
2629 }
2630
2631 /// Build a new C++ exception declaration.
2632 ///
2633 /// By default, performs semantic analysis to build the new decaration.
2634 /// Subclasses may override this routine to provide different behavior.
2637 SourceLocation StartLoc,
2638 SourceLocation IdLoc,
2639 IdentifierInfo *Id) {
2641 StartLoc, IdLoc, Id);
2642 if (Var)
2643 getSema().CurContext->addDecl(Var);
2644 return Var;
2645 }
2646
2647 /// Build a new C++ catch statement.
2648 ///
2649 /// By default, performs semantic analysis to build the new statement.
2650 /// Subclasses may override this routine to provide different behavior.
2652 VarDecl *ExceptionDecl,
2653 Stmt *Handler) {
2654 return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2655 Handler));
2656 }
2657
2658 /// Build a new C++ try statement.
2659 ///
2660 /// By default, performs semantic analysis to build the new statement.
2661 /// Subclasses may override this routine to provide different behavior.
2663 ArrayRef<Stmt *> Handlers) {
2664 return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2665 }
2666
2667 /// Build a new C++0x range-based for statement.
2668 ///
2669 /// By default, performs semantic analysis to build the new statement.
2670 /// Subclasses may override this routine to provide different behavior.
2672 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init,
2673 SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond,
2674 Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc,
2675 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
2676 // If we've just learned that the range is actually an Objective-C
2677 // collection, treat this as an Objective-C fast enumeration loop.
2678 if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2679 if (RangeStmt->isSingleDecl()) {
2680 if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2681 if (RangeVar->isInvalidDecl())
2682 return StmtError();
2683
2684 Expr *RangeExpr = RangeVar->getInit();
2685 if (!RangeExpr->isTypeDependent() &&
2686 RangeExpr->getType()->isObjCObjectPointerType()) {
2687 // FIXME: Support init-statements in Objective-C++20 ranged for
2688 // statement.
2689 if (Init) {
2690 return SemaRef.Diag(Init->getBeginLoc(),
2691 diag::err_objc_for_range_init_stmt)
2692 << Init->getSourceRange();
2693 }
2695 ForLoc, LoopVar, RangeExpr, RParenLoc);
2696 }
2697 }
2698 }
2699 }
2700
2702 ForLoc, CoawaitLoc, Init, ColonLoc, Range, Begin, End, Cond, Inc,
2703 LoopVar, RParenLoc, Sema::BFRK_Rebuild, LifetimeExtendTemps);
2704 }
2705
2706 /// Build a new C++0x range-based for statement.
2707 ///
2708 /// By default, performs semantic analysis to build the new statement.
2709 /// Subclasses may override this routine to provide different behavior.
2711 bool IsIfExists,
2712 NestedNameSpecifierLoc QualifierLoc,
2713 DeclarationNameInfo NameInfo,
2714 Stmt *Nested) {
2715 return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2716 QualifierLoc, NameInfo, Nested);
2717 }
2718
2719 /// Attach body to a C++0x range-based for statement.
2720 ///
2721 /// By default, performs semantic analysis to finish the new statement.
2722 /// Subclasses may override this routine to provide different behavior.
2724 return getSema().FinishCXXForRangeStmt(ForRange, Body);
2725 }
2726
2728 Stmt *TryBlock, Stmt *Handler) {
2729 return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2730 }
2731
2733 Stmt *Block) {
2734 return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2735 }
2736
2738 return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2739 }
2740
2742 SourceLocation LParen,
2743 SourceLocation RParen,
2744 TypeSourceInfo *TSI) {
2745 return getSema().SYCL().BuildUniqueStableNameExpr(OpLoc, LParen, RParen,
2746 TSI);
2747 }
2748
2749 /// Build a new predefined expression.
2750 ///
2751 /// By default, performs semantic analysis to build the new expression.
2752 /// Subclasses may override this routine to provide different behavior.
2756
2757 /// Build a new expression that references a declaration.
2758 ///
2759 /// By default, performs semantic analysis to build the new expression.
2760 /// Subclasses may override this routine to provide different behavior.
2762 LookupResult &R,
2763 bool RequiresADL) {
2764 return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2765 }
2766
2767
2768 /// Build a new expression that references a declaration.
2769 ///
2770 /// By default, performs semantic analysis to build the new expression.
2771 /// Subclasses may override this routine to provide different behavior.
2773 ValueDecl *VD,
2774 const DeclarationNameInfo &NameInfo,
2776 TemplateArgumentListInfo *TemplateArgs) {
2777 CXXScopeSpec SS;
2778 SS.Adopt(QualifierLoc);
2779 return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2780 TemplateArgs);
2781 }
2782
2783 /// Build a new expression in parentheses.
2784 ///
2785 /// By default, performs semantic analysis to build the new expression.
2786 /// Subclasses may override this routine to provide different behavior.
2788 SourceLocation RParen) {
2789 return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2790 }
2791
2792 /// Build a new pseudo-destructor expression.
2793 ///
2794 /// By default, performs semantic analysis to build the new expression.
2795 /// Subclasses may override this routine to provide different behavior.
2797 SourceLocation OperatorLoc,
2798 bool isArrow,
2799 CXXScopeSpec &SS,
2800 TypeSourceInfo *ScopeType,
2801 SourceLocation CCLoc,
2802 SourceLocation TildeLoc,
2803 PseudoDestructorTypeStorage Destroyed);
2804
2805 /// Build a new unary operator expression.
2806 ///
2807 /// By default, performs semantic analysis to build the new expression.
2808 /// Subclasses may override this routine to provide different behavior.
2811 Expr *SubExpr) {
2812 return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2813 }
2814
2815 /// Build a new builtin offsetof expression.
2816 ///
2817 /// By default, performs semantic analysis to build the new expression.
2818 /// Subclasses may override this routine to provide different behavior.
2822 SourceLocation RParenLoc) {
2823 return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2824 RParenLoc);
2825 }
2826
2827 /// Build a new sizeof, alignof or vec_step expression with a
2828 /// type argument.
2829 ///
2830 /// By default, performs semantic analysis to build the new expression.
2831 /// Subclasses may override this routine to provide different behavior.
2833 SourceLocation OpLoc,
2834 UnaryExprOrTypeTrait ExprKind,
2835 SourceRange R) {
2836 return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2837 }
2838
2839 /// Build a new sizeof, alignof or vec step expression with an
2840 /// expression argument.
2841 ///
2842 /// By default, performs semantic analysis to build the new expression.
2843 /// Subclasses may override this routine to provide different behavior.
2845 UnaryExprOrTypeTrait ExprKind,
2846 SourceRange R) {
2848 = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2849 if (Result.isInvalid())
2850 return ExprError();
2851
2852 return Result;
2853 }
2854
2855 /// Build a new array subscript expression.
2856 ///
2857 /// By default, performs semantic analysis to build the new expression.
2858 /// Subclasses may override this routine to provide different behavior.
2860 SourceLocation LBracketLoc,
2861 Expr *RHS,
2862 SourceLocation RBracketLoc) {
2863 return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2864 LBracketLoc, RHS,
2865 RBracketLoc);
2866 }
2867
2868 /// Build a new matrix single subscript expression.
2869 ///
2870 /// By default, performs semantic analysis to build the new expression.
2871 /// Subclasses may override this routine to provide different behavior.
2873 SourceLocation RBracketLoc) {
2875 RBracketLoc);
2876 }
2877
2878 /// Build a new matrix subscript expression.
2879 ///
2880 /// By default, performs semantic analysis to build the new expression.
2881 /// Subclasses may override this routine to provide different behavior.
2883 Expr *ColumnIdx,
2884 SourceLocation RBracketLoc) {
2885 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2886 RBracketLoc);
2887 }
2888
2889 /// Build a new array section expression.
2890 ///
2891 /// By default, performs semantic analysis to build the new expression.
2892 /// Subclasses may override this routine to provide different behavior.
2894 SourceLocation LBracketLoc,
2895 Expr *LowerBound,
2896 SourceLocation ColonLocFirst,
2897 SourceLocation ColonLocSecond,
2898 Expr *Length, Expr *Stride,
2899 SourceLocation RBracketLoc) {
2900 if (IsOMPArraySection)
2902 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2903 Stride, RBracketLoc);
2904
2905 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2906 "Stride/second colon not allowed for OpenACC");
2907
2909 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2910 }
2911
2912 /// Build a new array shaping expression.
2913 ///
2914 /// By default, performs semantic analysis to build the new expression.
2915 /// Subclasses may override this routine to provide different behavior.
2917 SourceLocation RParenLoc,
2918 ArrayRef<Expr *> Dims,
2919 ArrayRef<SourceRange> BracketsRanges) {
2921 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2922 }
2923
2924 /// Build a new iterator expression.
2925 ///
2926 /// By default, performs semantic analysis to build the new expression.
2927 /// Subclasses may override this routine to provide different behavior.
2930 SourceLocation RLoc,
2933 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2934 }
2935
2936 /// Build a new call expression.
2937 ///
2938 /// By default, performs semantic analysis to build the new expression.
2939 /// Subclasses may override this routine to provide different behavior.
2941 MultiExprArg Args,
2942 SourceLocation RParenLoc,
2943 Expr *ExecConfig = nullptr) {
2944 return getSema().ActOnCallExpr(
2945 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2946 }
2947
2949 MultiExprArg Args,
2950 SourceLocation RParenLoc) {
2952 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2953 }
2954
2955 /// Build a new member access expression.
2956 ///
2957 /// By default, performs semantic analysis to build the new expression.
2958 /// Subclasses may override this routine to provide different behavior.
2960 bool isArrow,
2961 NestedNameSpecifierLoc QualifierLoc,
2962 SourceLocation TemplateKWLoc,
2963 const DeclarationNameInfo &MemberNameInfo,
2965 NamedDecl *FoundDecl,
2966 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2967 NamedDecl *FirstQualifierInScope) {
2969 isArrow);
2970 if (!Member->getDeclName()) {
2971 // We have a reference to an unnamed field. This is always the
2972 // base of an anonymous struct/union member access, i.e. the
2973 // field is always of record type.
2974 assert(Member->getType()->isRecordType() &&
2975 "unnamed member not of record type?");
2976
2977 BaseResult =
2979 QualifierLoc.getNestedNameSpecifier(),
2980 FoundDecl, Member);
2981 if (BaseResult.isInvalid())
2982 return ExprError();
2983 Base = BaseResult.get();
2984
2985 // `TranformMaterializeTemporaryExpr()` removes materialized temporaries
2986 // from the AST, so we need to re-insert them if needed (since
2987 // `BuildFieldRefereneExpr()` doesn't do this).
2988 if (!isArrow && Base->isPRValue()) {
2990 if (BaseResult.isInvalid())
2991 return ExprError();
2992 Base = BaseResult.get();
2993 }
2994
2995 CXXScopeSpec EmptySS;
2997 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
2998 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
2999 MemberNameInfo);
3000 }
3001
3002 CXXScopeSpec SS;
3003 SS.Adopt(QualifierLoc);
3004
3005 Base = BaseResult.get();
3006 if (Base->containsErrors())
3007 return ExprError();
3008
3009 QualType BaseType = Base->getType();
3010
3011 if (isArrow && !BaseType->isPointerType())
3012 return ExprError();
3013
3014 // FIXME: this involves duplicating earlier analysis in a lot of
3015 // cases; we should avoid this when possible.
3016 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
3017 R.addDecl(FoundDecl);
3018 R.resolveKind();
3019
3020 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
3022 if (auto *ThisClass = cast<CXXThisExpr>(Base)
3023 ->getType()
3024 ->getPointeeType()
3025 ->getAsCXXRecordDecl()) {
3026 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
3027 // In unevaluated contexts, an expression supposed to be a member access
3028 // might reference a member in an unrelated class.
3029 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
3030 return getSema().BuildDeclRefExpr(Member, Member->getType(),
3031 VK_LValue, Member->getLocation());
3032 }
3033 }
3034
3035 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
3036 SS, TemplateKWLoc,
3037 FirstQualifierInScope,
3038 R, ExplicitTemplateArgs,
3039 /*S*/nullptr);
3040 }
3041
3042 /// Build a new binary operator expression.
3043 ///
3044 /// By default, performs semantic analysis to build the new expression.
3045 /// Subclasses may override this routine to provide different behavior.
3047 Expr *LHS, Expr *RHS,
3048 bool ForFoldExpression = false) {
3049 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS,
3050 ForFoldExpression);
3051 }
3052
3053 /// Build a new rewritten operator expression.
3054 ///
3055 /// By default, performs semantic analysis to build the new expression.
3056 /// Subclasses may override this routine to provide different behavior.
3058 SourceLocation OpLoc, BinaryOperatorKind Opcode,
3059 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
3060 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
3061 RHS, /*RequiresADL*/false);
3062 }
3063
3064 /// Build a new conditional operator expression.
3065 ///
3066 /// By default, performs semantic analysis to build the new expression.
3067 /// Subclasses may override this routine to provide different behavior.
3069 SourceLocation QuestionLoc,
3070 Expr *LHS,
3071 SourceLocation ColonLoc,
3072 Expr *RHS) {
3073 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
3074 LHS, RHS);
3075 }
3076
3077 /// Build a new C-style cast expression.
3078 ///
3079 /// By default, performs semantic analysis to build the new expression.
3080 /// Subclasses may override this routine to provide different behavior.
3082 TypeSourceInfo *TInfo,
3083 SourceLocation RParenLoc,
3084 Expr *SubExpr) {
3085 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
3086 SubExpr);
3087 }
3088
3089 /// Build a new compound literal expression.
3090 ///
3091 /// By default, performs semantic analysis to build the new expression.
3092 /// Subclasses may override this routine to provide different behavior.
3094 TypeSourceInfo *TInfo,
3095 SourceLocation RParenLoc,
3096 Expr *Init) {
3097 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
3098 Init);
3099 }
3100
3101 /// Build a new extended vector element access expression.
3102 ///
3103 /// By default, performs semantic analysis to build the new expression.
3104 /// Subclasses may override this routine to provide different behavior.
3106 bool IsArrow,
3107 SourceLocation AccessorLoc,
3108 IdentifierInfo &Accessor) {
3109
3110 CXXScopeSpec SS;
3111 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3113 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3114 /*FirstQualifierInScope*/ nullptr, NameInfo,
3115 /* TemplateArgs */ nullptr,
3116 /*S*/ nullptr);
3117 }
3118
3119 /// Build a new initializer list expression.
3120 ///
3121 /// By default, performs semantic analysis to build the new expression.
3122 /// Subclasses may override this routine to provide different behavior.
3125 SourceLocation RBraceLoc) {
3126 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
3127 }
3128
3129 /// Build a new designated initializer expression.
3130 ///
3131 /// By default, performs semantic analysis to build the new expression.
3132 /// Subclasses may override this routine to provide different behavior.
3134 MultiExprArg ArrayExprs,
3135 SourceLocation EqualOrColonLoc,
3136 bool GNUSyntax,
3137 Expr *Init) {
3139 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3140 Init);
3141 if (Result.isInvalid())
3142 return ExprError();
3143
3144 return Result;
3145 }
3146
3147 /// Build a new value-initialized expression.
3148 ///
3149 /// By default, builds the implicit value initialization without performing
3150 /// any semantic analysis. Subclasses may override this routine to provide
3151 /// different behavior.
3155
3156 /// Build a new \c va_arg expression.
3157 ///
3158 /// By default, performs semantic analysis to build the new expression.
3159 /// Subclasses may override this routine to provide different behavior.
3161 Expr *SubExpr, TypeSourceInfo *TInfo,
3162 SourceLocation RParenLoc) {
3163 return getSema().BuildVAArgExpr(BuiltinLoc,
3164 SubExpr, TInfo,
3165 RParenLoc);
3166 }
3167
3168 /// Build a new expression list in parentheses.
3169 ///
3170 /// By default, performs semantic analysis to build the new expression.
3171 /// Subclasses may override this routine to provide different behavior.
3173 MultiExprArg SubExprs,
3174 SourceLocation RParenLoc) {
3175 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3176 }
3177
3179 unsigned NumUserSpecifiedExprs,
3180 SourceLocation InitLoc,
3181 SourceLocation LParenLoc,
3182 SourceLocation RParenLoc) {
3183 return getSema().ActOnCXXParenListInitExpr(Args, T, NumUserSpecifiedExprs,
3184 InitLoc, LParenLoc, RParenLoc);
3185 }
3186
3187 /// Build a new address-of-label expression.
3188 ///
3189 /// By default, performs semantic analysis, using the name of the label
3190 /// rather than attempting to map the label statement itself.
3191 /// Subclasses may override this routine to provide different behavior.
3193 SourceLocation LabelLoc, LabelDecl *Label) {
3194 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3195 }
3196
3197 /// Build a new GNU statement expression.
3198 ///
3199 /// By default, performs semantic analysis to build the new expression.
3200 /// Subclasses may override this routine to provide different behavior.
3202 SourceLocation RParenLoc, unsigned TemplateDepth) {
3203 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3204 TemplateDepth);
3205 }
3206
3207 /// Build a new __builtin_choose_expr expression.
3208 ///
3209 /// By default, performs semantic analysis to build the new expression.
3210 /// Subclasses may override this routine to provide different behavior.
3212 Expr *Cond, Expr *LHS, Expr *RHS,
3213 SourceLocation RParenLoc) {
3214 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3215 Cond, LHS, RHS,
3216 RParenLoc);
3217 }
3218
3219 /// Build a new generic selection expression with an expression predicate.
3220 ///
3221 /// By default, performs semantic analysis to build the new expression.
3222 /// Subclasses may override this routine to provide different behavior.
3224 SourceLocation DefaultLoc,
3225 SourceLocation RParenLoc,
3226 Expr *ControllingExpr,
3228 ArrayRef<Expr *> Exprs) {
3229 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3230 /*PredicateIsExpr=*/true,
3231 ControllingExpr, Types, Exprs);
3232 }
3233
3234 /// Build a new generic selection expression with a type predicate.
3235 ///
3236 /// By default, performs semantic analysis to build the new expression.
3237 /// Subclasses may override this routine to provide different behavior.
3239 SourceLocation DefaultLoc,
3240 SourceLocation RParenLoc,
3241 TypeSourceInfo *ControllingType,
3243 ArrayRef<Expr *> Exprs) {
3244 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3245 /*PredicateIsExpr=*/false,
3246 ControllingType, Types, Exprs);
3247 }
3248
3249 /// Build a new overloaded operator call expression.
3250 ///
3251 /// By default, performs semantic analysis to build the new expression.
3252 /// The semantic analysis provides the behavior of template instantiation,
3253 /// copying with transformations that turn what looks like an overloaded
3254 /// operator call into a use of a builtin operator, performing
3255 /// argument-dependent lookup, etc. Subclasses may override this routine to
3256 /// provide different behavior.
3258 SourceLocation OpLoc,
3259 SourceLocation CalleeLoc,
3260 bool RequiresADL,
3261 const UnresolvedSetImpl &Functions,
3262 Expr *First, Expr *Second);
3263
3264 /// Build a new C++ "named" cast expression, such as static_cast or
3265 /// reinterpret_cast.
3266 ///
3267 /// By default, this routine dispatches to one of the more-specific routines
3268 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3269 /// Subclasses may override this routine to provide different behavior.
3272 SourceLocation LAngleLoc,
3273 TypeSourceInfo *TInfo,
3274 SourceLocation RAngleLoc,
3275 SourceLocation LParenLoc,
3276 Expr *SubExpr,
3277 SourceLocation RParenLoc) {
3278 switch (Class) {
3279 case Stmt::CXXStaticCastExprClass:
3280 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3281 RAngleLoc, LParenLoc,
3282 SubExpr, RParenLoc);
3283
3284 case Stmt::CXXDynamicCastExprClass:
3285 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3286 RAngleLoc, LParenLoc,
3287 SubExpr, RParenLoc);
3288
3289 case Stmt::CXXReinterpretCastExprClass:
3290 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3291 RAngleLoc, LParenLoc,
3292 SubExpr,
3293 RParenLoc);
3294
3295 case Stmt::CXXConstCastExprClass:
3296 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3297 RAngleLoc, LParenLoc,
3298 SubExpr, RParenLoc);
3299
3300 case Stmt::CXXAddrspaceCastExprClass:
3301 return getDerived().RebuildCXXAddrspaceCastExpr(
3302 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3303
3304 default:
3305 llvm_unreachable("Invalid C++ named cast");
3306 }
3307 }
3308
3309 /// Build a new C++ static_cast expression.
3310 ///
3311 /// By default, performs semantic analysis to build the new expression.
3312 /// Subclasses may override this routine to provide different behavior.
3314 SourceLocation LAngleLoc,
3315 TypeSourceInfo *TInfo,
3316 SourceLocation RAngleLoc,
3317 SourceLocation LParenLoc,
3318 Expr *SubExpr,
3319 SourceLocation RParenLoc) {
3320 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3321 TInfo, SubExpr,
3322 SourceRange(LAngleLoc, RAngleLoc),
3323 SourceRange(LParenLoc, RParenLoc));
3324 }
3325
3326 /// Build a new C++ dynamic_cast expression.
3327 ///
3328 /// By default, performs semantic analysis to build the new expression.
3329 /// Subclasses may override this routine to provide different behavior.
3331 SourceLocation LAngleLoc,
3332 TypeSourceInfo *TInfo,
3333 SourceLocation RAngleLoc,
3334 SourceLocation LParenLoc,
3335 Expr *SubExpr,
3336 SourceLocation RParenLoc) {
3337 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3338 TInfo, SubExpr,
3339 SourceRange(LAngleLoc, RAngleLoc),
3340 SourceRange(LParenLoc, RParenLoc));
3341 }
3342
3343 /// Build a new C++ reinterpret_cast expression.
3344 ///
3345 /// By default, performs semantic analysis to build the new expression.
3346 /// Subclasses may override this routine to provide different behavior.
3348 SourceLocation LAngleLoc,
3349 TypeSourceInfo *TInfo,
3350 SourceLocation RAngleLoc,
3351 SourceLocation LParenLoc,
3352 Expr *SubExpr,
3353 SourceLocation RParenLoc) {
3354 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3355 TInfo, SubExpr,
3356 SourceRange(LAngleLoc, RAngleLoc),
3357 SourceRange(LParenLoc, RParenLoc));
3358 }
3359
3360 /// Build a new C++ const_cast expression.
3361 ///
3362 /// By default, performs semantic analysis to build the new expression.
3363 /// Subclasses may override this routine to provide different behavior.
3365 SourceLocation LAngleLoc,
3366 TypeSourceInfo *TInfo,
3367 SourceLocation RAngleLoc,
3368 SourceLocation LParenLoc,
3369 Expr *SubExpr,
3370 SourceLocation RParenLoc) {
3371 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3372 TInfo, SubExpr,
3373 SourceRange(LAngleLoc, RAngleLoc),
3374 SourceRange(LParenLoc, RParenLoc));
3375 }
3376
3379 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3380 SourceLocation LParenLoc, Expr *SubExpr,
3381 SourceLocation RParenLoc) {
3382 return getSema().BuildCXXNamedCast(
3383 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3384 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3385 }
3386
3387 /// Build a new C++ functional-style cast expression.
3388 ///
3389 /// By default, performs semantic analysis to build the new expression.
3390 /// Subclasses may override this routine to provide different behavior.
3392 SourceLocation LParenLoc,
3393 Expr *Sub,
3394 SourceLocation RParenLoc,
3395 bool ListInitialization) {
3396 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3397 // CXXParenListInitExpr. Pass its expanded arguments so that the
3398 // CXXParenListInitExpr can be rebuilt.
3399 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3401 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3402 RParenLoc, ListInitialization);
3403
3404 if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub))
3406 TInfo, LParenLoc, PLE->getInitExprs(), RParenLoc, ListInitialization);
3407
3408 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3409 MultiExprArg(&Sub, 1), RParenLoc,
3410 ListInitialization);
3411 }
3412
3413 /// Build a new C++ __builtin_bit_cast expression.
3414 ///
3415 /// By default, performs semantic analysis to build the new expression.
3416 /// Subclasses may override this routine to provide different behavior.
3418 TypeSourceInfo *TSI, Expr *Sub,
3419 SourceLocation RParenLoc) {
3420 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3421 }
3422
3423 /// Build a new C++ typeid(type) expression.
3424 ///
3425 /// By default, performs semantic analysis to build the new expression.
3426 /// Subclasses may override this routine to provide different behavior.
3428 SourceLocation TypeidLoc,
3429 TypeSourceInfo *Operand,
3430 SourceLocation RParenLoc) {
3431 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3432 RParenLoc);
3433 }
3434
3435
3436 /// Build a new C++ typeid(expr) expression.
3437 ///
3438 /// By default, performs semantic analysis to build the new expression.
3439 /// Subclasses may override this routine to provide different behavior.
3441 SourceLocation TypeidLoc,
3442 Expr *Operand,
3443 SourceLocation RParenLoc) {
3444 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3445 RParenLoc);
3446 }
3447
3448 /// Build a new C++ __uuidof(type) expression.
3449 ///
3450 /// By default, performs semantic analysis to build the new expression.
3451 /// Subclasses may override this routine to provide different behavior.
3453 TypeSourceInfo *Operand,
3454 SourceLocation RParenLoc) {
3455 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3456 }
3457
3458 /// Build a new C++ __uuidof(expr) expression.
3459 ///
3460 /// By default, performs semantic analysis to build the new expression.
3461 /// Subclasses may override this routine to provide different behavior.
3463 Expr *Operand, SourceLocation RParenLoc) {
3464 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3465 }
3466
3467 /// Build a new C++ "this" expression.
3468 ///
3469 /// By default, performs semantic analysis to build a new "this" expression.
3470 /// Subclasses may override this routine to provide different behavior.
3472 QualType ThisType,
3473 bool isImplicit) {
3474 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3475 return ExprError();
3476 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3477 }
3478
3479 /// Build a new C++ throw expression.
3480 ///
3481 /// By default, performs semantic analysis to build the new expression.
3482 /// Subclasses may override this routine to provide different behavior.
3484 bool IsThrownVariableInScope) {
3485 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3486 }
3487
3488 /// Build a new C++ default-argument expression.
3489 ///
3490 /// By default, builds a new default-argument expression, which does not
3491 /// require any semantic analysis. Subclasses may override this routine to
3492 /// provide different behavior.
3494 Expr *RewrittenExpr) {
3495 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3496 RewrittenExpr, getSema().CurContext);
3497 }
3498
3499 /// Build a new C++11 default-initialization expression.
3500 ///
3501 /// By default, builds a new default field initialization expression, which
3502 /// does not require any semantic analysis. Subclasses may override this
3503 /// routine to provide different behavior.
3508
3509 /// Build a new C++ zero-initialization expression.
3510 ///
3511 /// By default, performs semantic analysis to build the new expression.
3512 /// Subclasses may override this routine to provide different behavior.
3514 SourceLocation LParenLoc,
3515 SourceLocation RParenLoc) {
3516 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3517 /*ListInitialization=*/false);
3518 }
3519
3520 /// Build a new C++ "new" expression.
3521 ///
3522 /// By default, performs semantic analysis to build the new expression.
3523 /// Subclasses may override this routine to provide different behavior.
3525 SourceLocation PlacementLParen,
3526 MultiExprArg PlacementArgs,
3527 SourceLocation PlacementRParen,
3528 SourceRange TypeIdParens, QualType AllocatedType,
3529 TypeSourceInfo *AllocatedTypeInfo,
3530 std::optional<Expr *> ArraySize,
3531 SourceRange DirectInitRange, Expr *Initializer) {
3532 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3533 PlacementLParen,
3534 PlacementArgs,
3535 PlacementRParen,
3536 TypeIdParens,
3537 AllocatedType,
3538 AllocatedTypeInfo,
3539 ArraySize,
3540 DirectInitRange,
3541 Initializer);
3542 }
3543
3544 /// Build a new C++ "delete" expression.
3545 ///
3546 /// By default, performs semantic analysis to build the new expression.
3547 /// Subclasses may override this routine to provide different behavior.
3549 bool IsGlobalDelete,
3550 bool IsArrayForm,
3551 Expr *Operand) {
3552 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3553 Operand);
3554 }
3555
3556 /// Build a new type trait expression.
3557 ///
3558 /// By default, performs semantic analysis to build the new expression.
3559 /// Subclasses may override this routine to provide different behavior.
3561 SourceLocation StartLoc,
3563 SourceLocation RParenLoc) {
3564 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3565 }
3566
3567 /// Build a new array type trait expression.
3568 ///
3569 /// By default, performs semantic analysis to build the new expression.
3570 /// Subclasses may override this routine to provide different behavior.
3572 SourceLocation StartLoc,
3573 TypeSourceInfo *TSInfo,
3574 Expr *DimExpr,
3575 SourceLocation RParenLoc) {
3576 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3577 }
3578
3579 /// Build a new expression trait expression.
3580 ///
3581 /// By default, performs semantic analysis to build the new expression.
3582 /// Subclasses may override this routine to provide different behavior.
3584 SourceLocation StartLoc,
3585 Expr *Queried,
3586 SourceLocation RParenLoc) {
3587 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3588 }
3589
3590 /// Build a new (previously unresolved) declaration reference
3591 /// expression.
3592 ///
3593 /// By default, performs semantic analysis to build the new expression.
3594 /// Subclasses may override this routine to provide different behavior.
3596 NestedNameSpecifierLoc QualifierLoc,
3597 SourceLocation TemplateKWLoc,
3598 const DeclarationNameInfo &NameInfo,
3599 const TemplateArgumentListInfo *TemplateArgs,
3600 bool IsAddressOfOperand,
3601 TypeSourceInfo **RecoveryTSI) {
3602 CXXScopeSpec SS;
3603 SS.Adopt(QualifierLoc);
3604
3605 if (TemplateArgs || TemplateKWLoc.isValid())
3607 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3608
3610 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3611 }
3612
3613 /// Build a new template-id expression.
3614 ///
3615 /// By default, performs semantic analysis to build the new expression.
3616 /// Subclasses may override this routine to provide different behavior.
3618 SourceLocation TemplateKWLoc,
3619 LookupResult &R,
3620 bool RequiresADL,
3621 const TemplateArgumentListInfo *TemplateArgs) {
3622 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3623 TemplateArgs);
3624 }
3625
3626 /// Build a new object-construction expression.
3627 ///
3628 /// By default, performs semantic analysis to build the new expression.
3629 /// Subclasses may override this routine to provide different behavior.
3632 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3633 bool ListInitialization, bool StdInitListInitialization,
3634 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3635 SourceRange ParenRange) {
3636 // Reconstruct the constructor we originally found, which might be
3637 // different if this is a call to an inherited constructor.
3638 CXXConstructorDecl *FoundCtor = Constructor;
3639 if (Constructor->isInheritingConstructor())
3640 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3641
3642 SmallVector<Expr *, 8> ConvertedArgs;
3643 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3644 ConvertedArgs))
3645 return ExprError();
3646
3648 IsElidable,
3649 ConvertedArgs,
3650 HadMultipleCandidates,
3651 ListInitialization,
3652 StdInitListInitialization,
3653 RequiresZeroInit, ConstructKind,
3654 ParenRange);
3655 }
3656
3657 /// Build a new implicit construction via inherited constructor
3658 /// expression.
3661 bool ConstructsVBase,
3662 bool InheritedFromVBase) {
3664 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3665 }
3666
3667 /// Build a new object-construction expression.
3668 ///
3669 /// By default, performs semantic analysis to build the new expression.
3670 /// Subclasses may override this routine to provide different behavior.
3672 SourceLocation LParenOrBraceLoc,
3673 MultiExprArg Args,
3674 SourceLocation RParenOrBraceLoc,
3675 bool ListInitialization) {
3677 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3678 }
3679
3680 /// Build a new object-construction expression.
3681 ///
3682 /// By default, performs semantic analysis to build the new expression.
3683 /// Subclasses may override this routine to provide different behavior.
3685 SourceLocation LParenLoc,
3686 MultiExprArg Args,
3687 SourceLocation RParenLoc,
3688 bool ListInitialization) {
3689 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3690 RParenLoc, ListInitialization);
3691 }
3692
3693 /// Build a new member reference expression.
3694 ///
3695 /// By default, performs semantic analysis to build the new expression.
3696 /// Subclasses may override this routine to provide different behavior.
3698 QualType BaseType,
3699 bool IsArrow,
3700 SourceLocation OperatorLoc,
3701 NestedNameSpecifierLoc QualifierLoc,
3702 SourceLocation TemplateKWLoc,
3703 NamedDecl *FirstQualifierInScope,
3704 const DeclarationNameInfo &MemberNameInfo,
3705 const TemplateArgumentListInfo *TemplateArgs) {
3706 CXXScopeSpec SS;
3707 SS.Adopt(QualifierLoc);
3708
3709 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3710 OperatorLoc, IsArrow,
3711 SS, TemplateKWLoc,
3712 FirstQualifierInScope,
3713 MemberNameInfo,
3714 TemplateArgs, /*S*/nullptr);
3715 }
3716
3717 /// Build a new member reference expression.
3718 ///
3719 /// By default, performs semantic analysis to build the new expression.
3720 /// Subclasses may override this routine to provide different behavior.
3722 SourceLocation OperatorLoc,
3723 bool IsArrow,
3724 NestedNameSpecifierLoc QualifierLoc,
3725 SourceLocation TemplateKWLoc,
3726 NamedDecl *FirstQualifierInScope,
3727 LookupResult &R,
3728 const TemplateArgumentListInfo *TemplateArgs) {
3729 CXXScopeSpec SS;
3730 SS.Adopt(QualifierLoc);
3731
3732 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3733 OperatorLoc, IsArrow,
3734 SS, TemplateKWLoc,
3735 FirstQualifierInScope,
3736 R, TemplateArgs, /*S*/nullptr);
3737 }
3738
3739 /// Build a new noexcept expression.
3740 ///
3741 /// By default, performs semantic analysis to build the new expression.
3742 /// Subclasses may override this routine to provide different behavior.
3744 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3745 }
3746
3749
3750 /// Build a new expression to compute the length of a parameter pack.
3752 SourceLocation PackLoc,
3753 SourceLocation RParenLoc,
3754 UnsignedOrNone Length,
3755 ArrayRef<TemplateArgument> PartialArgs) {
3756 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3757 RParenLoc, Length, PartialArgs);
3758 }
3759
3761 SourceLocation RSquareLoc,
3762 Expr *PackIdExpression, Expr *IndexExpr,
3763 ArrayRef<Expr *> ExpandedExprs,
3764 bool FullySubstituted = false) {
3765 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3766 IndexExpr, RSquareLoc, ExpandedExprs,
3767 FullySubstituted);
3768 }
3769
3770 /// Build a new expression representing a call to a source location
3771 /// builtin.
3772 ///
3773 /// By default, performs semantic analysis to build the new expression.
3774 /// Subclasses may override this routine to provide different behavior.
3776 SourceLocation BuiltinLoc,
3777 SourceLocation RPLoc,
3778 DeclContext *ParentContext) {
3779 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3780 ParentContext);
3781 }
3782
3784 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3785 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3787 CXXScopeSpec SS;
3788 SS.Adopt(NNS);
3789 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3790 ConceptNameInfo,
3791 FoundDecl,
3792 NamedConcept, TALI);
3793 if (Result.isInvalid())
3794 return ExprError();
3795 return Result;
3796 }
3797
3798 /// \brief Build a new requires expression.
3799 ///
3800 /// By default, performs semantic analysis to build the new expression.
3801 /// Subclasses may override this routine to provide different behavior.
3804 SourceLocation LParenLoc,
3805 ArrayRef<ParmVarDecl *> LocalParameters,
3806 SourceLocation RParenLoc,
3808 SourceLocation ClosingBraceLoc) {
3809 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3810 LocalParameters, RParenLoc, Requirements,
3811 ClosingBraceLoc);
3812 }
3813
3817 return SemaRef.BuildTypeRequirement(SubstDiag);
3818 }
3819
3821 return SemaRef.BuildTypeRequirement(T);
3822 }
3823
3826 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3827 SourceLocation NoexceptLoc,
3829 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3830 std::move(Ret));
3831 }
3832
3834 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3836 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3837 std::move(Ret));
3838 }
3839
3841 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3842 const ASTConstraintSatisfaction &Satisfaction) {
3843 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3844 Satisfaction);
3845 }
3846
3848 return SemaRef.BuildNestedRequirement(Constraint);
3849 }
3850
3851 /// \brief Build a new Objective-C boxed expression.
3852 ///
3853 /// By default, performs semantic analysis to build the new expression.
3854 /// Subclasses may override this routine to provide different behavior.
3856 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3857 }
3858
3859 /// Build a new Objective-C array literal.
3860 ///
3861 /// By default, performs semantic analysis to build the new expression.
3862 /// Subclasses may override this routine to provide different behavior.
3864 Expr **Elements, unsigned NumElements) {
3866 Range, MultiExprArg(Elements, NumElements));
3867 }
3868
3870 Expr *Base, Expr *Key,
3871 ObjCMethodDecl *getterMethod,
3872 ObjCMethodDecl *setterMethod) {
3874 RB, Base, Key, getterMethod, setterMethod);
3875 }
3876
3877 /// Build a new Objective-C dictionary literal.
3878 ///
3879 /// By default, performs semantic analysis to build the new expression.
3880 /// Subclasses may override this routine to provide different behavior.
3885
3886 /// Build a new Objective-C \@encode expression.
3887 ///
3888 /// By default, performs semantic analysis to build the new expression.
3889 /// Subclasses may override this routine to provide different behavior.
3891 TypeSourceInfo *EncodeTypeInfo,
3892 SourceLocation RParenLoc) {
3893 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3894 RParenLoc);
3895 }
3896
3897 /// Build a new Objective-C class message.
3899 Selector Sel,
3900 ArrayRef<SourceLocation> SelectorLocs,
3902 SourceLocation LBracLoc,
3903 MultiExprArg Args,
3904 SourceLocation RBracLoc) {
3905 return SemaRef.ObjC().BuildClassMessage(
3906 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3907 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3908 RBracLoc, Args);
3909 }
3910
3911 /// Build a new Objective-C instance message.
3913 Selector Sel,
3914 ArrayRef<SourceLocation> SelectorLocs,
3916 SourceLocation LBracLoc,
3917 MultiExprArg Args,
3918 SourceLocation RBracLoc) {
3919 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3920 /*SuperLoc=*/SourceLocation(),
3921 Sel, Method, LBracLoc,
3922 SelectorLocs, RBracLoc, Args);
3923 }
3924
3925 /// Build a new Objective-C instance/class message to 'super'.
3927 Selector Sel,
3928 ArrayRef<SourceLocation> SelectorLocs,
3929 QualType SuperType,
3931 SourceLocation LBracLoc,
3932 MultiExprArg Args,
3933 SourceLocation RBracLoc) {
3934 return Method->isInstanceMethod()
3935 ? SemaRef.ObjC().BuildInstanceMessage(
3936 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3937 SelectorLocs, RBracLoc, Args)
3938 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3939 Sel, Method, LBracLoc,
3940 SelectorLocs, RBracLoc, Args);
3941 }
3942
3943 /// Build a new Objective-C ivar reference expression.
3944 ///
3945 /// By default, performs semantic analysis to build the new expression.
3946 /// Subclasses may override this routine to provide different behavior.
3948 SourceLocation IvarLoc,
3949 bool IsArrow, bool IsFreeIvar) {
3950 CXXScopeSpec SS;
3951 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3953 BaseArg, BaseArg->getType(),
3954 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3955 /*FirstQualifierInScope=*/nullptr, NameInfo,
3956 /*TemplateArgs=*/nullptr,
3957 /*S=*/nullptr);
3958 if (IsFreeIvar && Result.isUsable())
3959 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3960 return Result;
3961 }
3962
3963 /// Build a new Objective-C property reference expression.
3964 ///
3965 /// By default, performs semantic analysis to build the new expression.
3966 /// Subclasses may override this routine to provide different behavior.
3969 SourceLocation PropertyLoc) {
3970 CXXScopeSpec SS;
3971 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3972 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3973 /*FIXME:*/PropertyLoc,
3974 /*IsArrow=*/false,
3975 SS, SourceLocation(),
3976 /*FirstQualifierInScope=*/nullptr,
3977 NameInfo,
3978 /*TemplateArgs=*/nullptr,
3979 /*S=*/nullptr);
3980 }
3981
3982 /// Build a new Objective-C property reference expression.
3983 ///
3984 /// By default, performs semantic analysis to build the new expression.
3985 /// Subclasses may override this routine to provide different behavior.
3987 ObjCMethodDecl *Getter,
3988 ObjCMethodDecl *Setter,
3989 SourceLocation PropertyLoc) {
3990 // Since these expressions can only be value-dependent, we do not
3991 // need to perform semantic analysis again.
3992 return Owned(
3993 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3995 PropertyLoc, Base));
3996 }
3997
3998 /// Build a new Objective-C "isa" expression.
3999 ///
4000 /// By default, performs semantic analysis to build the new expression.
4001 /// Subclasses may override this routine to provide different behavior.
4003 SourceLocation OpLoc, bool IsArrow) {
4004 CXXScopeSpec SS;
4005 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
4006 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
4007 OpLoc, IsArrow,
4008 SS, SourceLocation(),
4009 /*FirstQualifierInScope=*/nullptr,
4010 NameInfo,
4011 /*TemplateArgs=*/nullptr,
4012 /*S=*/nullptr);
4013 }
4014
4015 /// Build a new shuffle vector expression.
4016 ///
4017 /// By default, performs semantic analysis to build the new expression.
4018 /// Subclasses may override this routine to provide different behavior.
4020 MultiExprArg SubExprs,
4021 SourceLocation RParenLoc) {
4022 // Find the declaration for __builtin_shufflevector
4023 const IdentifierInfo &Name
4024 = SemaRef.Context.Idents.get("__builtin_shufflevector");
4025 TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
4026 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
4027 assert(!Lookup.empty() && "No __builtin_shufflevector?");
4028
4029 // Build a reference to the __builtin_shufflevector builtin
4031 Expr *Callee = new (SemaRef.Context)
4032 DeclRefExpr(SemaRef.Context, Builtin, false,
4033 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
4034 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
4035 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
4036 CK_BuiltinFnToFnPtr).get();
4037
4038 // Build the CallExpr
4039 ExprResult TheCall = CallExpr::Create(
4040 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
4041 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
4043
4044 // Type-check the __builtin_shufflevector expression.
4045 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
4046 }
4047
4048 /// Build a new convert vector expression.
4050 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
4051 SourceLocation RParenLoc) {
4052 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
4053 }
4054
4055 /// Build a new template argument pack expansion.
4056 ///
4057 /// By default, performs semantic analysis to build a new pack expansion
4058 /// for a template argument. Subclasses may override this routine to provide
4059 /// different behavior.
4061 SourceLocation EllipsisLoc,
4062 UnsignedOrNone NumExpansions) {
4063 switch (Pattern.getArgument().getKind()) {
4067 EllipsisLoc, NumExpansions);
4068 if (Result.isInvalid())
4069 return TemplateArgumentLoc();
4070
4072 /*IsCanonical=*/false),
4073 Result.get());
4074 }
4075
4077 return TemplateArgumentLoc(
4078 SemaRef.Context,
4080 NumExpansions),
4081 Pattern.getTemplateKWLoc(), Pattern.getTemplateQualifierLoc(),
4082 Pattern.getTemplateNameLoc(), EllipsisLoc);
4083
4091 llvm_unreachable("Pack expansion pattern has no parameter packs");
4092
4094 if (TypeSourceInfo *Expansion
4095 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4096 EllipsisLoc,
4097 NumExpansions))
4098 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4099 Expansion);
4100 break;
4101 }
4102
4103 return TemplateArgumentLoc();
4104 }
4105
4106 /// Build a new expression pack expansion.
4107 ///
4108 /// By default, performs semantic analysis to build a new pack expansion
4109 /// for an expression. Subclasses may override this routine to provide
4110 /// different behavior.
4112 UnsignedOrNone NumExpansions) {
4113 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4114 }
4115
4116 /// Build a new C++1z fold-expression.
4117 ///
4118 /// By default, performs semantic analysis in order to build a new fold
4119 /// expression.
4121 SourceLocation LParenLoc, Expr *LHS,
4122 BinaryOperatorKind Operator,
4123 SourceLocation EllipsisLoc, Expr *RHS,
4124 SourceLocation RParenLoc,
4125 UnsignedOrNone NumExpansions) {
4126 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4127 EllipsisLoc, RHS, RParenLoc,
4128 NumExpansions);
4129 }
4130
4132 LambdaScopeInfo *LSI) {
4133 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4134 if (Expr *Init = PVD->getInit())
4136 Init->containsUnexpandedParameterPack();
4137 else if (PVD->hasUninstantiatedDefaultArg())
4139 PVD->getUninstantiatedDefaultArg()
4140 ->containsUnexpandedParameterPack();
4141 }
4142 return getSema().BuildLambdaExpr(StartLoc, EndLoc);
4143 }
4144
4145 /// Build an empty C++1z fold-expression with the given operator.
4146 ///
4147 /// By default, produces the fallback value for the fold-expression, or
4148 /// produce an error if there is no fallback value.
4150 BinaryOperatorKind Operator) {
4151 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4152 }
4153
4154 /// Build a new atomic operation expression.
4155 ///
4156 /// By default, performs semantic analysis to build the new expression.
4157 /// Subclasses may override this routine to provide different behavior.
4160 SourceLocation RParenLoc) {
4161 // Use this for all of the locations, since we don't know the difference
4162 // between the call and the expr at this point.
4163 SourceRange Range{BuiltinLoc, RParenLoc};
4164 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4166 }
4167
4169 ArrayRef<Expr *> SubExprs, QualType Type) {
4170 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4171 }
4172
4174 SourceLocation BeginLoc,
4175 SourceLocation DirLoc,
4176 SourceLocation EndLoc,
4178 StmtResult StrBlock) {
4180 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4181 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, StrBlock);
4182 }
4183
4194
4196 SourceLocation BeginLoc,
4197 SourceLocation DirLoc,
4198 SourceLocation EndLoc,
4200 StmtResult Loop) {
4202 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4203 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, Loop);
4204 }
4205
4207 SourceLocation DirLoc,
4208 SourceLocation EndLoc,
4210 StmtResult StrBlock) {
4212 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4214 Clauses, StrBlock);
4215 }
4216
4226
4236
4238 SourceLocation DirLoc,
4239 SourceLocation EndLoc,
4241 StmtResult StrBlock) {
4245 Clauses, StrBlock);
4246 }
4247
4249 SourceLocation DirLoc,
4250 SourceLocation EndLoc,
4251 ArrayRef<OpenACCClause *> Clauses) {
4253 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4255 Clauses, {});
4256 }
4257
4267
4269 SourceLocation DirLoc,
4270 SourceLocation EndLoc,
4271 ArrayRef<OpenACCClause *> Clauses) {
4273 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4275 Clauses, {});
4276 }
4277
4279 SourceLocation DirLoc,
4280 SourceLocation EndLoc,
4281 ArrayRef<OpenACCClause *> Clauses) {
4283 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4285 Clauses, {});
4286 }
4287
4289 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4290 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4291 SourceLocation RParenLoc, SourceLocation EndLoc,
4292 ArrayRef<OpenACCClause *> Clauses) {
4294 Exprs.push_back(DevNumExpr);
4295 llvm::append_range(Exprs, QueueIdExprs);
4297 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4298 Exprs, OpenACCAtomicKind::None, RParenLoc, EndLoc, Clauses, {});
4299 }
4300
4302 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4303 SourceLocation ReadOnlyLoc, ArrayRef<Expr *> VarList,
4304 SourceLocation RParenLoc, SourceLocation EndLoc) {
4306 OpenACCDirectiveKind::Cache, BeginLoc, DirLoc, LParenLoc, ReadOnlyLoc,
4307 VarList, OpenACCAtomicKind::None, RParenLoc, EndLoc, {}, {});
4308 }
4309
4311 SourceLocation DirLoc,
4312 OpenACCAtomicKind AtKind,
4313 SourceLocation EndLoc,
4315 StmtResult AssociatedStmt) {
4317 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4318 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, Clauses,
4319 AssociatedStmt);
4320 }
4321
4325
4328 const NonTypeTemplateParmDecl *NTTP,
4330 UnsignedOrNone PackIndex, bool Final) {
4332 AssociatedDecl, NTTP, Loc, Arg, PackIndex, Final);
4333 }
4334
4336 SourceLocation StartLoc,
4337 SourceLocation LParenLoc,
4338 SourceLocation EndLoc) {
4339 return getSema().OpenMP().ActOnOpenMPTransparentClause(ImpexType, StartLoc,
4340 LParenLoc, EndLoc);
4341 }
4342
4343private:
4344 QualType TransformTypeInObjectScope(TypeLocBuilder &TLB, TypeLoc TL,
4345 QualType ObjectType,
4346 NamedDecl *FirstQualifierInScope);
4347
4348 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4349 QualType ObjectType,
4350 NamedDecl *FirstQualifierInScope) {
4351 if (getDerived().AlreadyTransformed(TSInfo->getType()))
4352 return TSInfo;
4353
4354 TypeLocBuilder TLB;
4355 QualType T = TransformTypeInObjectScope(TLB, TSInfo->getTypeLoc(),
4356 ObjectType, FirstQualifierInScope);
4357 if (T.isNull())
4358 return nullptr;
4359 return TLB.getTypeSourceInfo(SemaRef.Context, T);
4360 }
4361
4362 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4363 DependentNameTypeLoc TL,
4364 bool DeducibleTSTContext,
4365 QualType ObjectType = QualType(),
4366 NamedDecl *UnqualLookup = nullptr);
4367
4369 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4371
4372 OpenACCClause *
4373 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4374 OpenACCDirectiveKind DirKind,
4375 const OpenACCClause *OldClause);
4376};
4377
4378template <typename Derived>
4380 if (!S)
4381 return S;
4382
4383 switch (S->getStmtClass()) {
4384 case Stmt::NoStmtClass: break;
4385
4386 // Transform individual statement nodes
4387 // Pass SDK into statements that can produce a value
4388#define STMT(Node, Parent) \
4389 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4390#define VALUESTMT(Node, Parent) \
4391 case Stmt::Node##Class: \
4392 return getDerived().Transform##Node(cast<Node>(S), SDK);
4393#define ABSTRACT_STMT(Node)
4394#define EXPR(Node, Parent)
4395#include "clang/AST/StmtNodes.inc"
4396
4397 // Transform expressions by calling TransformExpr.
4398#define STMT(Node, Parent)
4399#define ABSTRACT_STMT(Stmt)
4400#define EXPR(Node, Parent) case Stmt::Node##Class:
4401#include "clang/AST/StmtNodes.inc"
4402 {
4403 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4404
4406 E = getSema().ActOnStmtExprResult(E);
4407 return getSema().ActOnExprStmt(E, SDK == StmtDiscardKind::Discarded);
4408 }
4409 }
4410
4411 return S;
4412}
4413
4414template<typename Derived>
4416 if (!S)
4417 return S;
4418
4419 switch (S->getClauseKind()) {
4420 default: break;
4421 // Transform individual clause nodes
4422#define GEN_CLANG_CLAUSE_CLASS
4423#define CLAUSE_CLASS(Enum, Str, Class) \
4424 case Enum: \
4425 return getDerived().Transform##Class(cast<Class>(S));
4426#include "llvm/Frontend/OpenMP/OMP.inc"
4427 }
4428
4429 return S;
4430}
4431
4432
4433template<typename Derived>
4435 if (!E)
4436 return E;
4437
4438 switch (E->getStmtClass()) {
4439 case Stmt::NoStmtClass: break;
4440#define STMT(Node, Parent) case Stmt::Node##Class: break;
4441#define ABSTRACT_STMT(Stmt)
4442#define EXPR(Node, Parent) \
4443 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4444#include "clang/AST/StmtNodes.inc"
4445 }
4446
4447 return E;
4448}
4449
4450template<typename Derived>
4452 bool NotCopyInit) {
4453 // Initializers are instantiated like expressions, except that various outer
4454 // layers are stripped.
4455 if (!Init)
4456 return Init;
4457
4458 if (auto *FE = dyn_cast<FullExpr>(Init))
4459 Init = FE->getSubExpr();
4460
4461 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4462 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4463 Init = OVE->getSourceExpr();
4464 }
4465
4466 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4467 Init = MTE->getSubExpr();
4468
4469 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4470 Init = Binder->getSubExpr();
4471
4472 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4473 Init = ICE->getSubExprAsWritten();
4474
4475 if (CXXStdInitializerListExpr *ILE =
4476 dyn_cast<CXXStdInitializerListExpr>(Init))
4477 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4478
4479 // If this is copy-initialization, we only need to reconstruct
4480 // InitListExprs. Other forms of copy-initialization will be a no-op if
4481 // the initializer is already the right type.
4482 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4483 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4484 return getDerived().TransformExpr(Init);
4485
4486 // Revert value-initialization back to empty parens.
4487 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4488 SourceRange Parens = VIE->getSourceRange();
4489 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4490 Parens.getEnd());
4491 }
4492
4493 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4495 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4496 SourceLocation());
4497
4498 // Revert initialization by constructor back to a parenthesized or braced list
4499 // of expressions. Any other form of initializer can just be reused directly.
4500 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4501 return getDerived().TransformExpr(Init);
4502
4503 // If the initialization implicitly converted an initializer list to a
4504 // std::initializer_list object, unwrap the std::initializer_list too.
4505 if (Construct && Construct->isStdInitListInitialization())
4506 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4507
4508 // Enter a list-init context if this was list initialization.
4511 Construct->isListInitialization());
4512
4513 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4514 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4515 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4516 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4517 SmallVector<Expr*, 8> NewArgs;
4518 bool ArgChanged = false;
4519 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4520 /*IsCall*/true, NewArgs, &ArgChanged))
4521 return ExprError();
4522
4523 // If this was list initialization, revert to syntactic list form.
4524 if (Construct->isListInitialization())
4525 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4526 Construct->getEndLoc());
4527
4528 // Build a ParenListExpr to represent anything else.
4530 if (Parens.isInvalid()) {
4531 // This was a variable declaration's initialization for which no initializer
4532 // was specified.
4533 assert(NewArgs.empty() &&
4534 "no parens or braces but have direct init with arguments?");
4535 return ExprEmpty();
4536 }
4537 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4538 Parens.getEnd());
4539}
4540
4541template<typename Derived>
4543 unsigned NumInputs,
4544 bool IsCall,
4545 SmallVectorImpl<Expr *> &Outputs,
4546 bool *ArgChanged) {
4547 for (unsigned I = 0; I != NumInputs; ++I) {
4548 // If requested, drop call arguments that need to be dropped.
4549 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4550 if (ArgChanged)
4551 *ArgChanged = true;
4552
4553 break;
4554 }
4555
4556 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4557 Expr *Pattern = Expansion->getPattern();
4558
4560 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4561 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4562
4563 // Determine whether the set of unexpanded parameter packs can and should
4564 // be expanded.
4565 bool Expand = true;
4566 bool RetainExpansion = false;
4567 UnsignedOrNone OrigNumExpansions = Expansion->getNumExpansions();
4568 UnsignedOrNone NumExpansions = OrigNumExpansions;
4570 Expansion->getEllipsisLoc(), Pattern->getSourceRange(),
4571 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
4572 RetainExpansion, NumExpansions))
4573 return true;
4574
4575 if (!Expand) {
4576 // The transform has determined that we should perform a simple
4577 // transformation on the pack expansion, producing another pack
4578 // expansion.
4579 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
4580 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4581 if (OutPattern.isInvalid())
4582 return true;
4583
4584 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4585 Expansion->getEllipsisLoc(),
4586 NumExpansions);
4587 if (Out.isInvalid())
4588 return true;
4589
4590 if (ArgChanged)
4591 *ArgChanged = true;
4592 Outputs.push_back(Out.get());
4593 continue;
4594 }
4595
4596 // Record right away that the argument was changed. This needs
4597 // to happen even if the array expands to nothing.
4598 if (ArgChanged) *ArgChanged = true;
4599
4600 // The transform has determined that we should perform an elementwise
4601 // expansion of the pattern. Do so.
4602 for (unsigned I = 0; I != *NumExpansions; ++I) {
4603 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
4604 ExprResult Out = getDerived().TransformExpr(Pattern);
4605 if (Out.isInvalid())
4606 return true;
4607
4608 if (Out.get()->containsUnexpandedParameterPack()) {
4609 Out = getDerived().RebuildPackExpansion(
4610 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4611 if (Out.isInvalid())
4612 return true;
4613 }
4614
4615 Outputs.push_back(Out.get());
4616 }
4617
4618 // If we're supposed to retain a pack expansion, do so by temporarily
4619 // forgetting the partially-substituted parameter pack.
4620 if (RetainExpansion) {
4621 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4622
4623 ExprResult Out = getDerived().TransformExpr(Pattern);
4624 if (Out.isInvalid())
4625 return true;
4626
4627 Out = getDerived().RebuildPackExpansion(
4628 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4629 if (Out.isInvalid())
4630 return true;
4631
4632 Outputs.push_back(Out.get());
4633 }
4634
4635 continue;
4636 }
4637
4639 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4640 : getDerived().TransformExpr(Inputs[I]);
4641 if (Result.isInvalid())
4642 return true;
4643
4644 if (Result.get() != Inputs[I] && ArgChanged)
4645 *ArgChanged = true;
4646
4647 Outputs.push_back(Result.get());
4648 }
4649
4650 return false;
4651}
4652
4653template <typename Derived>
4656
4659 /*LambdaContextDecl=*/nullptr,
4661 /*ShouldEnter=*/Kind == Sema::ConditionKind::ConstexprIf);
4662
4663 if (Var) {
4664 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4666
4667 if (!ConditionVar)
4668 return Sema::ConditionError();
4669
4670 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4671 }
4672
4673 if (Expr) {
4674 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4675
4676 if (CondExpr.isInvalid())
4677 return Sema::ConditionError();
4678
4679 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4680 /*MissingOK=*/true);
4681 }
4682
4683 return Sema::ConditionResult();
4684}
4685
4686template <typename Derived>
4688 NestedNameSpecifierLoc NNS, QualType ObjectType,
4689 NamedDecl *FirstQualifierInScope) {
4691
4692 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4693 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4694 Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix)
4695 Qualifiers.push_back(Qualifier);
4696 };
4697 insertNNS(NNS);
4698
4699 CXXScopeSpec SS;
4700 while (!Qualifiers.empty()) {
4701 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4703
4704 switch (QNNS.getKind()) {
4706 llvm_unreachable("unexpected null nested name specifier");
4707
4710 Q.getLocalBeginLoc(), const_cast<NamespaceBaseDecl *>(
4712 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4713 break;
4714 }
4715
4717 // There is no meaningful transformation that one could perform on the
4718 // global scope.
4719 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4720 break;
4721
4723 CXXRecordDecl *RD = cast_or_null<CXXRecordDecl>(
4725 SS.MakeMicrosoftSuper(SemaRef.Context, RD, Q.getBeginLoc(),
4726 Q.getEndLoc());
4727 break;
4728 }
4729
4731 assert(SS.isEmpty());
4732 TypeLoc TL = Q.castAsTypeLoc();
4733
4734 if (auto DNT = TL.getAs<DependentNameTypeLoc>()) {
4735 NestedNameSpecifierLoc QualifierLoc = DNT.getQualifierLoc();
4736 if (QualifierLoc) {
4737 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4738 QualifierLoc, ObjectType, FirstQualifierInScope);
4739 if (!QualifierLoc)
4740 return NestedNameSpecifierLoc();
4741 ObjectType = QualType();
4742 FirstQualifierInScope = nullptr;
4743 }
4744 SS.Adopt(QualifierLoc);
4746 const_cast<IdentifierInfo *>(DNT.getTypePtr()->getIdentifier()),
4747 DNT.getNameLoc(), Q.getLocalEndLoc(), ObjectType);
4748 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo,
4749 false, SS,
4750 FirstQualifierInScope, false))
4751 return NestedNameSpecifierLoc();
4752 return SS.getWithLocInContext(SemaRef.Context);
4753 }
4754
4755 QualType T = TL.getType();
4756 TypeLocBuilder TLB;
4758 T = TransformTypeInObjectScope(TLB, TL, ObjectType,
4759 FirstQualifierInScope);
4760 if (T.isNull())
4761 return NestedNameSpecifierLoc();
4762 TL = TLB.getTypeLocInContext(SemaRef.Context, T);
4763 }
4764
4765 if (T->isDependentType() || T->isRecordType() ||
4766 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4767 if (T->isEnumeralType())
4768 SemaRef.Diag(TL.getBeginLoc(),
4769 diag::warn_cxx98_compat_enum_nested_name_spec);
4770 SS.Make(SemaRef.Context, TL, Q.getLocalEndLoc());
4771 break;
4772 }
4773 // If the nested-name-specifier is an invalid type def, don't emit an
4774 // error because a previous error should have already been emitted.
4776 if (!TTL || !TTL.getDecl()->isInvalidDecl()) {
4777 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4778 << T << SS.getRange();
4779 }
4780 return NestedNameSpecifierLoc();
4781 }
4782 }
4783 }
4784
4785 // Don't rebuild the nested-name-specifier if we don't have to.
4786 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4788 return NNS;
4789
4790 // If we can re-use the source-location data from the original
4791 // nested-name-specifier, do so.
4792 if (SS.location_size() == NNS.getDataLength() &&
4793 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4795
4796 // Allocate new nested-name-specifier location information.
4797 return SS.getWithLocInContext(SemaRef.Context);
4798}
4799
4800template<typename Derived>
4804 DeclarationName Name = NameInfo.getName();
4805 if (!Name)
4806 return DeclarationNameInfo();
4807
4808 switch (Name.getNameKind()) {
4816 return NameInfo;
4817
4819 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4820 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4821 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4822 if (!NewTemplate)
4823 return DeclarationNameInfo();
4824
4825 DeclarationNameInfo NewNameInfo(NameInfo);
4826 NewNameInfo.setName(
4827 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
4828 return NewNameInfo;
4829 }
4830
4834 TypeSourceInfo *NewTInfo;
4835 CanQualType NewCanTy;
4836 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4837 NewTInfo = getDerived().TransformType(OldTInfo);
4838 if (!NewTInfo)
4839 return DeclarationNameInfo();
4840 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4841 }
4842 else {
4843 NewTInfo = nullptr;
4844 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4845 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4846 if (NewT.isNull())
4847 return DeclarationNameInfo();
4848 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4849 }
4850
4851 DeclarationName NewName
4852 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4853 NewCanTy);
4854 DeclarationNameInfo NewNameInfo(NameInfo);
4855 NewNameInfo.setName(NewName);
4856 NewNameInfo.setNamedTypeInfo(NewTInfo);
4857 return NewNameInfo;
4858 }
4859 }
4860
4861 llvm_unreachable("Unknown name kind.");
4862}
4863
4864template <typename Derived>
4866 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4868 QualType ObjectType, bool AllowInjectedClassName) {
4869 if (const IdentifierInfo *II = IO.getIdentifier())
4870 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, *II, NameLoc,
4871 ObjectType, AllowInjectedClassName);
4872 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, IO.getOperator(),
4873 NameLoc, ObjectType,
4874 AllowInjectedClassName);
4875}
4876
4877template <typename Derived>
4879 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
4880 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
4881 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
4883 TemplateName UnderlyingName = QTN->getUnderlyingTemplate();
4884
4885 if (QualifierLoc) {
4886 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4887 QualifierLoc, ObjectType, FirstQualifierInScope);
4888 if (!QualifierLoc)
4889 return TemplateName();
4890 }
4891
4892 NestedNameSpecifierLoc UnderlyingQualifier;
4893 TemplateName NewUnderlyingName = getDerived().TransformTemplateName(
4894 UnderlyingQualifier, TemplateKWLoc, UnderlyingName, NameLoc, ObjectType,
4895 FirstQualifierInScope, AllowInjectedClassName);
4896 if (NewUnderlyingName.isNull())
4897 return TemplateName();
4898 assert(!UnderlyingQualifier && "unexpected qualifier");
4899
4900 if (!getDerived().AlwaysRebuild() &&
4901 QualifierLoc.getNestedNameSpecifier() == QTN->getQualifier() &&
4902 NewUnderlyingName == UnderlyingName)
4903 return Name;
4904 CXXScopeSpec SS;
4905 SS.Adopt(QualifierLoc);
4906 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4907 NewUnderlyingName);
4908 }
4909
4911 if (QualifierLoc) {
4912 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4913 QualifierLoc, ObjectType, FirstQualifierInScope);
4914 if (!QualifierLoc)
4915 return TemplateName();
4916 // The qualifier-in-scope and object type only apply to the leftmost
4917 // entity.
4918 ObjectType = QualType();
4919 }
4920
4921 if (!getDerived().AlwaysRebuild() &&
4922 QualifierLoc.getNestedNameSpecifier() == DTN->getQualifier() &&
4923 ObjectType.isNull())
4924 return Name;
4925
4926 CXXScopeSpec SS;
4927 SS.Adopt(QualifierLoc);
4928 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, DTN->getName(),
4929 NameLoc, ObjectType,
4930 AllowInjectedClassName);
4931 }
4932
4935 assert(!QualifierLoc && "Unexpected qualified SubstTemplateTemplateParm");
4936
4937 NestedNameSpecifierLoc ReplacementQualifierLoc;
4938 TemplateName ReplacementName = S->getReplacement();
4939 if (NestedNameSpecifier Qualifier = ReplacementName.getQualifier()) {
4941 Builder.MakeTrivial(SemaRef.Context, Qualifier, NameLoc);
4942 ReplacementQualifierLoc = Builder.getWithLocInContext(SemaRef.Context);
4943 }
4944
4945 TemplateName NewName = getDerived().TransformTemplateName(
4946 ReplacementQualifierLoc, TemplateKWLoc, ReplacementName, NameLoc,
4947 ObjectType, FirstQualifierInScope, AllowInjectedClassName);
4948 if (NewName.isNull())
4949 return TemplateName();
4950 Decl *AssociatedDecl =
4951 getDerived().TransformDecl(NameLoc, S->getAssociatedDecl());
4952 if (!getDerived().AlwaysRebuild() && NewName == S->getReplacement() &&
4953 AssociatedDecl == S->getAssociatedDecl())
4954 return Name;
4955 return SemaRef.Context.getSubstTemplateTemplateParm(
4956 NewName, AssociatedDecl, S->getIndex(), S->getPackIndex(),
4957 S->getFinal());
4958 }
4959
4960 assert(!Name.getAsDeducedTemplateName() &&
4961 "DeducedTemplateName should not escape partial ordering");
4962
4963 // FIXME: Preserve UsingTemplateName.
4964 if (auto *Template = Name.getAsTemplateDecl()) {
4965 assert(!QualifierLoc && "Unexpected qualifier");
4966 return TemplateName(cast_or_null<TemplateDecl>(
4967 getDerived().TransformDecl(NameLoc, Template)));
4968 }
4969
4972 assert(!QualifierLoc &&
4973 "Unexpected qualified SubstTemplateTemplateParmPack");
4974 return getDerived().RebuildTemplateName(
4975 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4976 SubstPack->getIndex(), SubstPack->getFinal());
4977 }
4978
4979 // These should be getting filtered out before they reach the AST.
4980 llvm_unreachable("overloaded function decl survived to here");
4981}
4982
4983template <typename Derived>
4985 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
4986 TemplateName Name, SourceLocation NameLoc) {
4987 TemplateName TN = getDerived().TransformTemplateName(
4988 QualifierLoc, TemplateKeywordLoc, Name, NameLoc);
4989 if (TN.isNull())
4990 return TemplateArgument();
4991 return TemplateArgument(TN);
4992}
4993
4994template<typename Derived>
4996 const TemplateArgument &Arg,
4997 TemplateArgumentLoc &Output) {
4998 Output = getSema().getTrivialTemplateArgumentLoc(
4999 Arg, QualType(), getDerived().getBaseLocation());
5000}
5001
5002template <typename Derived>
5004 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
5005 bool Uneval) {
5006 const TemplateArgument &Arg = Input.getArgument();
5007 switch (Arg.getKind()) {
5010 llvm_unreachable("Unexpected TemplateArgument");
5011
5016 // Transform a resolved template argument straight to a resolved template
5017 // argument. We get here when substituting into an already-substituted
5018 // template type argument during concept satisfaction checking.
5020 QualType NewT = getDerived().TransformType(T);
5021 if (NewT.isNull())
5022 return true;
5023
5025 ? Arg.getAsDecl()
5026 : nullptr;
5027 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
5029 : nullptr;
5030 if (D && !NewD)
5031 return true;
5032
5033 if (NewT == T && D == NewD)
5034 Output = Input;
5035 else if (Arg.getKind() == TemplateArgument::Integral)
5036 Output = TemplateArgumentLoc(
5037 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
5039 else if (Arg.getKind() == TemplateArgument::NullPtr)
5040 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
5042 else if (Arg.getKind() == TemplateArgument::Declaration)
5043 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
5046 Output = TemplateArgumentLoc(
5047 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
5049 else
5050 llvm_unreachable("unexpected template argument kind");
5051
5052 return false;
5053 }
5054
5056 TypeSourceInfo *TSI = Input.getTypeSourceInfo();
5057 if (!TSI)
5059
5060 TSI = getDerived().TransformType(TSI);
5061 if (!TSI)
5062 return true;
5063
5064 Output = TemplateArgumentLoc(TemplateArgument(TSI->getType()), TSI);
5065 return false;
5066 }
5067
5069 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
5070
5071 TemplateArgument Out = getDerived().TransformNamedTemplateTemplateArgument(
5072 QualifierLoc, Input.getTemplateKWLoc(), Arg.getAsTemplate(),
5073 Input.getTemplateNameLoc());
5074 if (Out.isNull())
5075 return true;
5076 Output = TemplateArgumentLoc(SemaRef.Context, Out, Input.getTemplateKWLoc(),
5077 QualifierLoc, Input.getTemplateNameLoc());
5078 return false;
5079 }
5080
5082 llvm_unreachable("Caller should expand pack expansions");
5083
5085 // Template argument expressions are constant expressions.
5087 getSema(),
5090 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
5092
5093 Expr *InputExpr = Input.getSourceExpression();
5094 if (!InputExpr)
5095 InputExpr = Input.getArgument().getAsExpr();
5096
5097 ExprResult E = getDerived().TransformExpr(InputExpr);
5098 E = SemaRef.ActOnConstantExpression(E);
5099 if (E.isInvalid())
5100 return true;
5101 Output = TemplateArgumentLoc(
5102 TemplateArgument(E.get(), /*IsCanonical=*/false), E.get());
5103 return false;
5104 }
5105 }
5106
5107 // Work around bogus GCC warning
5108 return true;
5109}
5110
5111/// Iterator adaptor that invents template argument location information
5112/// for each of the template arguments in its underlying iterator.
5113template<typename Derived, typename InputIterator>
5116 InputIterator Iter;
5117
5118public:
5121 typedef typename std::iterator_traits<InputIterator>::difference_type
5123 typedef std::input_iterator_tag iterator_category;
5124
5125 class pointer {
5127
5128 public:
5129 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5130
5131 const TemplateArgumentLoc *operator->() const { return &Arg; }
5132 };
5133
5135 InputIterator Iter)
5136 : Self(Self), Iter(Iter) { }
5137
5139 ++Iter;
5140 return *this;
5141 }
5142
5145 ++(*this);
5146 return Old;
5147 }
5148
5151 Self.InventTemplateArgumentLoc(*Iter, Result);
5152 return Result;
5153 }
5154
5155 pointer operator->() const { return pointer(**this); }
5156
5159 return X.Iter == Y.Iter;
5160 }
5161
5164 return X.Iter != Y.Iter;
5165 }
5166};
5167
5168template<typename Derived>
5169template<typename InputIterator>
5171 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5172 bool Uneval) {
5173 for (TemplateArgumentLoc In : llvm::make_range(First, Last)) {
5175 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5176 // Unpack argument packs, which we translate them into separate
5177 // arguments.
5178 // FIXME: We could do much better if we could guarantee that the
5179 // TemplateArgumentLocInfo for the pack expansion would be usable for
5180 // all of the template arguments in the argument pack.
5181 typedef TemplateArgumentLocInventIterator<Derived,
5183 PackLocIterator;
5184
5185 TemplateArgumentListInfo *PackOutput = &Outputs;
5187
5189 PackLocIterator(*this, In.getArgument().pack_begin()),
5190 PackLocIterator(*this, In.getArgument().pack_end()), *PackOutput,
5191 Uneval))
5192 return true;
5193
5194 continue;
5195 }
5196
5197 if (In.getArgument().isPackExpansion()) {
5198 UnexpandedInfo Info;
5199 TemplateArgumentLoc Prepared;
5200 if (getDerived().PreparePackForExpansion(In, Uneval, Prepared, Info))
5201 return true;
5202 if (!Info.Expand) {
5203 Outputs.addArgument(Prepared);
5204 continue;
5205 }
5206
5207 // The transform has determined that we should perform an elementwise
5208 // expansion of the pattern. Do so.
5209 std::optional<ForgetSubstitutionRAII> ForgetSubst;
5211 ForgetSubst.emplace(getDerived());
5212 for (unsigned I = 0; I != *Info.NumExpansions; ++I) {
5213 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5214
5216 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5217 return true;
5218
5219 if (Out.getArgument().containsUnexpandedParameterPack()) {
5220 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5221 Info.OrigNumExpansions);
5222 if (Out.getArgument().isNull())
5223 return true;
5224 }
5225
5226 Outputs.addArgument(Out);
5227 }
5228
5229 // If we're supposed to retain a pack expansion, do so by temporarily
5230 // forgetting the partially-substituted parameter pack.
5231 if (Info.RetainExpansion) {
5232 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5233
5235 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5236 return true;
5237
5238 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5239 Info.OrigNumExpansions);
5240 if (Out.getArgument().isNull())
5241 return true;
5242
5243 Outputs.addArgument(Out);
5244 }
5245
5246 continue;
5247 }
5248
5249 // The simple case:
5250 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5251 return true;
5252
5253 Outputs.addArgument(Out);
5254 }
5255
5256 return false;
5257}
5258
5259template <typename Derived>
5260template <typename InputIterator>
5262 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5263 bool Uneval) {
5264
5265 // [C++26][temp.constr.normal]
5266 // any non-dependent concept template argument
5267 // is substituted into the constraint-expression of C.
5268 auto isNonDependentConceptArgument = [](const TemplateArgument &Arg) {
5269 return !Arg.isDependent() && Arg.isConceptOrConceptTemplateParameter();
5270 };
5271
5272 for (; First != Last; ++First) {
5275
5276 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5277 typedef TemplateArgumentLocInventIterator<Derived,
5279 PackLocIterator;
5281 PackLocIterator(*this, In.getArgument().pack_begin()),
5282 PackLocIterator(*this, In.getArgument().pack_end()), Outputs,
5283 Uneval))
5284 return true;
5285 continue;
5286 }
5287
5288 if (!isNonDependentConceptArgument(In.getArgument())) {
5289 Outputs.addArgument(In);
5290 continue;
5291 }
5292
5293 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5294 return true;
5295
5296 Outputs.addArgument(Out);
5297 }
5298
5299 return false;
5300}
5301
5302// FIXME: Find ways to reduce code duplication for pack expansions.
5303template <typename Derived>
5305 bool Uneval,
5307 UnexpandedInfo &Info) {
5308 auto ComputeInfo = [this](TemplateArgumentLoc Arg,
5309 bool IsLateExpansionAttempt, UnexpandedInfo &Info,
5310 TemplateArgumentLoc &Pattern) {
5311 assert(Arg.getArgument().isPackExpansion());
5312 // We have a pack expansion, for which we will be substituting into the
5313 // pattern.
5314 Pattern = getSema().getTemplateArgumentPackExpansionPattern(
5315 Arg, Info.Ellipsis, Info.OrigNumExpansions);
5317 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5318 if (IsLateExpansionAttempt) {
5319 // Request expansion only when there is an opportunity to expand a pack
5320 // that required a substituion first.
5321 bool SawPackTypes =
5322 llvm::any_of(Unexpanded, [](UnexpandedParameterPack P) {
5323 return P.first.dyn_cast<const SubstBuiltinTemplatePackType *>();
5324 });
5325 if (!SawPackTypes) {
5326 Info.Expand = false;
5327 return false;
5328 }
5329 }
5330 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5331
5332 // Determine whether the set of unexpanded parameter packs can and
5333 // should be expanded.
5334 Info.Expand = true;
5335 Info.RetainExpansion = false;
5336 Info.NumExpansions = Info.OrigNumExpansions;
5337 return getDerived().TryExpandParameterPacks(
5338 Info.Ellipsis, Pattern.getSourceRange(), Unexpanded,
5339 /*FailOnPackProducingTemplates=*/false, Info.Expand,
5340 Info.RetainExpansion, Info.NumExpansions);
5341 };
5342
5343 TemplateArgumentLoc Pattern;
5344 if (ComputeInfo(In, false, Info, Pattern))
5345 return true;
5346
5347 if (Info.Expand) {
5348 Out = Pattern;
5349 return false;
5350 }
5351
5352 // The transform has determined that we should perform a simple
5353 // transformation on the pack expansion, producing another pack
5354 // expansion.
5355 TemplateArgumentLoc OutPattern;
5356 std::optional<Sema::ArgPackSubstIndexRAII> SubstIndex(
5357 std::in_place, getSema(), std::nullopt);
5358 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5359 return true;
5360
5361 Out = getDerived().RebuildPackExpansion(OutPattern, Info.Ellipsis,
5362 Info.NumExpansions);
5363 if (Out.getArgument().isNull())
5364 return true;
5365 SubstIndex.reset();
5366
5367 if (!OutPattern.getArgument().containsUnexpandedParameterPack())
5368 return false;
5369
5370 // Some packs will learn their length after substitution, e.g.
5371 // __builtin_dedup_pack<T,int> has size 1 or 2, depending on the substitution
5372 // value of `T`.
5373 //
5374 // We only expand after we know sizes of all packs, check if this is the case
5375 // or not. However, we avoid a full template substitution and only do
5376 // expanstions after this point.
5377
5378 // E.g. when substituting template arguments of tuple with {T -> int} in the
5379 // following example:
5380 // template <class T>
5381 // struct TupleWithInt {
5382 // using type = std::tuple<__builtin_dedup_pack<T, int>...>;
5383 // };
5384 // TupleWithInt<int>::type y;
5385 // At this point we will see the `__builtin_dedup_pack<int, int>` with a known
5386 // length and run `ComputeInfo()` to provide the necessary information to our
5387 // caller.
5388 //
5389 // Note that we may still have situations where builtin is not going to be
5390 // expanded. For example:
5391 // template <class T>
5392 // struct Foo {
5393 // template <class U> using tuple_with_t =
5394 // std::tuple<__builtin_dedup_pack<T, U, int>...>; using type =
5395 // tuple_with_t<short>;
5396 // }
5397 // Because the substitution into `type` happens in dependent context, `type`
5398 // will be `tuple<builtin_dedup_pack<T, short, int>...>` after substitution
5399 // and the caller will not be able to expand it.
5400 ForgetSubstitutionRAII ForgetSubst(getDerived());
5401 if (ComputeInfo(Out, true, Info, OutPattern))
5402 return true;
5403 if (!Info.Expand)
5404 return false;
5405 Out = OutPattern;
5406 Info.ExpandUnderForgetSubstitions = true;
5407 return false;
5408}
5409
5410//===----------------------------------------------------------------------===//
5411// Type transformation
5412//===----------------------------------------------------------------------===//
5413
5414template<typename Derived>
5417 return T;
5418
5419 // Temporary workaround. All of these transformations should
5420 // eventually turn into transformations on TypeLocs.
5421 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5423
5424 TypeSourceInfo *NewTSI = getDerived().TransformType(TSI);
5425
5426 if (!NewTSI)
5427 return QualType();
5428
5429 return NewTSI->getType();
5430}
5431
5432template <typename Derived>
5434 // Refine the base location to the type's location.
5435 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5438 return TSI;
5439
5440 TypeLocBuilder TLB;
5441
5442 TypeLoc TL = TSI->getTypeLoc();
5443 TLB.reserve(TL.getFullDataSize());
5444
5445 QualType Result = getDerived().TransformType(TLB, TL);
5446 if (Result.isNull())
5447 return nullptr;
5448
5449 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5450}
5451
5452template<typename Derived>
5455 switch (T.getTypeLocClass()) {
5456#define ABSTRACT_TYPELOC(CLASS, PARENT)
5457#define TYPELOC(CLASS, PARENT) \
5458 case TypeLoc::CLASS: \
5459 return getDerived().Transform##CLASS##Type(TLB, \
5460 T.castAs<CLASS##TypeLoc>());
5461#include "clang/AST/TypeLocNodes.def"
5462 }
5463
5464 llvm_unreachable("unhandled type loc!");
5465}
5466
5467template<typename Derived>
5470 return TransformType(T);
5471
5473 return T;
5474 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5476 TypeSourceInfo *NewTSI = getDerived().TransformTypeWithDeducedTST(TSI);
5477 return NewTSI ? NewTSI->getType() : QualType();
5478}
5479
5480template <typename Derived>
5483 if (!isa<DependentNameType>(TSI->getType()))
5484 return TransformType(TSI);
5485
5486 // Refine the base location to the type's location.
5487 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5490 return TSI;
5491
5492 TypeLocBuilder TLB;
5493
5494 TypeLoc TL = TSI->getTypeLoc();
5495 TLB.reserve(TL.getFullDataSize());
5496
5497 auto QTL = TL.getAs<QualifiedTypeLoc>();
5498 if (QTL)
5499 TL = QTL.getUnqualifiedLoc();
5500
5501 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5502
5503 QualType Result = getDerived().TransformDependentNameType(
5504 TLB, DNTL, /*DeducedTSTContext*/true);
5505 if (Result.isNull())
5506 return nullptr;
5507
5508 if (QTL) {
5509 Result = getDerived().RebuildQualifiedType(Result, QTL);
5510 if (Result.isNull())
5511 return nullptr;
5513 }
5514
5515 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5516}
5517
5518template<typename Derived>
5523 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5524 auto SuppressObjCLifetime =
5525 T.getType().getLocalQualifiers().hasObjCLifetime();
5526 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5527 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5528 SuppressObjCLifetime);
5529 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5530 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5531 TLB, STTP, SuppressObjCLifetime);
5532 } else {
5533 Result = getDerived().TransformType(TLB, UnqualTL);
5534 }
5535
5536 if (Result.isNull())
5537 return QualType();
5538
5539 Result = getDerived().RebuildQualifiedType(Result, T);
5540
5541 if (Result.isNull())
5542 return QualType();
5543
5544 // RebuildQualifiedType might have updated the type, but not in a way
5545 // that invalidates the TypeLoc. (There's no location information for
5546 // qualifiers.)
5548
5549 return Result;
5550}
5551
5552template <typename Derived>
5554 QualifiedTypeLoc TL) {
5555
5556 SourceLocation Loc = TL.getBeginLoc();
5557 Qualifiers Quals = TL.getType().getLocalQualifiers();
5558
5559 if ((T.getAddressSpace() != LangAS::Default &&
5560 Quals.getAddressSpace() != LangAS::Default) &&
5561 T.getAddressSpace() != Quals.getAddressSpace()) {
5562 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5563 << TL.getType() << T;
5564 return QualType();
5565 }
5566
5567 PointerAuthQualifier LocalPointerAuth = Quals.getPointerAuth();
5568 if (LocalPointerAuth.isPresent()) {
5569 if (T.getPointerAuth().isPresent()) {
5570 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_redundant) << TL.getType();
5571 return QualType();
5572 }
5573 if (!T->isDependentType()) {
5574 if (!T->isSignableType(SemaRef.getASTContext())) {
5575 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_invalid_target) << T;
5576 return QualType();
5577 }
5578 }
5579 }
5580 // C++ [dcl.fct]p7:
5581 // [When] adding cv-qualifications on top of the function type [...] the
5582 // cv-qualifiers are ignored.
5583 if (T->isFunctionType()) {
5584 T = SemaRef.getASTContext().getAddrSpaceQualType(T,
5585 Quals.getAddressSpace());
5586 return T;
5587 }
5588
5589 // C++ [dcl.ref]p1:
5590 // when the cv-qualifiers are introduced through the use of a typedef-name
5591 // or decltype-specifier [...] the cv-qualifiers are ignored.
5592 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5593 // applied to a reference type.
5594 if (T->isReferenceType()) {
5595 // The only qualifier that applies to a reference type is restrict.
5596 if (!Quals.hasRestrict())
5597 return T;
5599 }
5600
5601 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5602 // resulting type.
5603 if (Quals.hasObjCLifetime()) {
5604 if (!T->isObjCLifetimeType() && !T->isDependentType())
5605 Quals.removeObjCLifetime();
5606 else if (T.getObjCLifetime()) {
5607 // Objective-C ARC:
5608 // A lifetime qualifier applied to a substituted template parameter
5609 // overrides the lifetime qualifier from the template argument.
5610 const AutoType *AutoTy;
5611 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5612 // 'auto' types behave the same way as template parameters.
5613 QualType Deduced = AutoTy->getDeducedType();
5614 Qualifiers Qs = Deduced.getQualifiers();
5615 Qs.removeObjCLifetime();
5616 Deduced =
5617 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5618 T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
5619 AutoTy->isDependentType(),
5620 /*isPack=*/false,
5621 AutoTy->getTypeConstraintConcept(),
5622 AutoTy->getTypeConstraintArguments());
5623 } else {
5624 // Otherwise, complain about the addition of a qualifier to an
5625 // already-qualified type.
5626 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5627 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5628 Quals.removeObjCLifetime();
5629 }
5630 }
5631 }
5632
5633 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5634}
5635
5636template <typename Derived>
5637QualType TreeTransform<Derived>::TransformTypeInObjectScope(
5638 TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType,
5639 NamedDecl *FirstQualifierInScope) {
5640 assert(!getDerived().AlreadyTransformed(TL.getType()));
5641
5642 switch (TL.getTypeLocClass()) {
5643 case TypeLoc::TemplateSpecialization:
5644 return getDerived().TransformTemplateSpecializationType(
5645 TLB, TL.castAs<TemplateSpecializationTypeLoc>(), ObjectType,
5646 FirstQualifierInScope, /*AllowInjectedClassName=*/true);
5647 case TypeLoc::DependentName:
5648 return getDerived().TransformDependentNameType(
5649 TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
5650 ObjectType, FirstQualifierInScope);
5651 default:
5652 // Any dependent canonical type can appear here, through type alias
5653 // templates.
5654 return getDerived().TransformType(TLB, TL);
5655 }
5656}
5657
5658template <class TyLoc> static inline
5660 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5661 NewT.setNameLoc(T.getNameLoc());
5662 return T.getType();
5663}
5664
5665template<typename Derived>
5666QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5667 BuiltinTypeLoc T) {
5668 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5669 NewT.setBuiltinLoc(T.getBuiltinLoc());
5670 if (T.needsExtraLocalData())
5671 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5672 return T.getType();
5673}
5674
5675template<typename Derived>
5677 ComplexTypeLoc T) {
5678 // FIXME: recurse?
5679 return TransformTypeSpecType(TLB, T);
5680}
5681
5682template <typename Derived>
5684 AdjustedTypeLoc TL) {
5685 // Adjustments applied during transformation are handled elsewhere.
5686 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5687}
5688
5689template<typename Derived>
5691 DecayedTypeLoc TL) {
5692 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5693 if (OriginalType.isNull())
5694 return QualType();
5695
5696 QualType Result = TL.getType();
5697 if (getDerived().AlwaysRebuild() ||
5698 OriginalType != TL.getOriginalLoc().getType())
5699 Result = SemaRef.Context.getDecayedType(OriginalType);
5700 TLB.push<DecayedTypeLoc>(Result);
5701 // Nothing to set for DecayedTypeLoc.
5702 return Result;
5703}
5704
5705template <typename Derived>
5709 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5710 if (OriginalType.isNull())
5711 return QualType();
5712
5713 QualType Result = TL.getType();
5714 if (getDerived().AlwaysRebuild() ||
5715 OriginalType != TL.getElementLoc().getType())
5716 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5717 TLB.push<ArrayParameterTypeLoc>(Result);
5718 // Nothing to set for ArrayParameterTypeLoc.
5719 return Result;
5720}
5721
5722template<typename Derived>
5724 PointerTypeLoc TL) {
5725 QualType PointeeType
5726 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5727 if (PointeeType.isNull())
5728 return QualType();
5729
5730 QualType Result = TL.getType();
5731 if (PointeeType->getAs<ObjCObjectType>()) {
5732 // A dependent pointer type 'T *' has is being transformed such
5733 // that an Objective-C class type is being replaced for 'T'. The
5734 // resulting pointer type is an ObjCObjectPointerType, not a
5735 // PointerType.
5736 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5737
5739 NewT.setStarLoc(TL.getStarLoc());
5740 return Result;
5741 }
5742
5743 if (getDerived().AlwaysRebuild() ||
5744 PointeeType != TL.getPointeeLoc().getType()) {
5745 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5746 if (Result.isNull())
5747 return QualType();
5748 }
5749
5750 // Objective-C ARC can add lifetime qualifiers to the type that we're
5751 // pointing to.
5752 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5753
5754 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5755 NewT.setSigilLoc(TL.getSigilLoc());
5756 return Result;
5757}
5758
5759template<typename Derived>
5763 QualType PointeeType
5764 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5765 if (PointeeType.isNull())
5766 return QualType();
5767
5768 QualType Result = TL.getType();
5769 if (getDerived().AlwaysRebuild() ||
5770 PointeeType != TL.getPointeeLoc().getType()) {
5771 Result = getDerived().RebuildBlockPointerType(PointeeType,
5772 TL.getSigilLoc());
5773 if (Result.isNull())
5774 return QualType();
5775 }
5776
5778 NewT.setSigilLoc(TL.getSigilLoc());
5779 return Result;
5780}
5781
5782/// Transforms a reference type. Note that somewhat paradoxically we
5783/// don't care whether the type itself is an l-value type or an r-value
5784/// type; we only care if the type was *written* as an l-value type
5785/// or an r-value type.
5786template<typename Derived>
5789 ReferenceTypeLoc TL) {
5790 const ReferenceType *T = TL.getTypePtr();
5791
5792 // Note that this works with the pointee-as-written.
5793 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5794 if (PointeeType.isNull())
5795 return QualType();
5796
5797 QualType Result = TL.getType();
5798 if (getDerived().AlwaysRebuild() ||
5799 PointeeType != T->getPointeeTypeAsWritten()) {
5800 Result = getDerived().RebuildReferenceType(PointeeType,
5801 T->isSpelledAsLValue(),
5802 TL.getSigilLoc());
5803 if (Result.isNull())
5804 return QualType();
5805 }
5806
5807 // Objective-C ARC can add lifetime qualifiers to the type that we're
5808 // referring to.
5811
5812 // r-value references can be rebuilt as l-value references.
5813 ReferenceTypeLoc NewTL;
5815 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5816 else
5817 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5818 NewTL.setSigilLoc(TL.getSigilLoc());
5819
5820 return Result;
5821}
5822
5823template<typename Derived>
5827 return TransformReferenceType(TLB, TL);
5828}
5829
5830template<typename Derived>
5831QualType
5832TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5833 RValueReferenceTypeLoc TL) {
5834 return TransformReferenceType(TLB, TL);
5835}
5836
5837template<typename Derived>
5841 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5842 if (PointeeType.isNull())
5843 return QualType();
5844
5845 const MemberPointerType *T = TL.getTypePtr();
5846
5847 NestedNameSpecifierLoc OldQualifierLoc = TL.getQualifierLoc();
5848 NestedNameSpecifierLoc NewQualifierLoc =
5849 getDerived().TransformNestedNameSpecifierLoc(OldQualifierLoc);
5850 if (!NewQualifierLoc)
5851 return QualType();
5852
5853 CXXRecordDecl *OldCls = T->getMostRecentCXXRecordDecl(), *NewCls = nullptr;
5854 if (OldCls) {
5855 NewCls = cast_or_null<CXXRecordDecl>(
5856 getDerived().TransformDecl(TL.getStarLoc(), OldCls));
5857 if (!NewCls)
5858 return QualType();
5859 }
5860
5861 QualType Result = TL.getType();
5862 if (getDerived().AlwaysRebuild() || PointeeType != T->getPointeeType() ||
5863 NewQualifierLoc.getNestedNameSpecifier() !=
5864 OldQualifierLoc.getNestedNameSpecifier() ||
5865 NewCls != OldCls) {
5866 CXXScopeSpec SS;
5867 SS.Adopt(NewQualifierLoc);
5868 Result = getDerived().RebuildMemberPointerType(PointeeType, SS, NewCls,
5869 TL.getStarLoc());
5870 if (Result.isNull())
5871 return QualType();
5872 }
5873
5874 // If we had to adjust the pointee type when building a member pointer, make
5875 // sure to push TypeLoc info for it.
5876 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5877 if (MPT && PointeeType != MPT->getPointeeType()) {
5878 assert(isa<AdjustedType>(MPT->getPointeeType()));
5879 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5880 }
5881
5883 NewTL.setSigilLoc(TL.getSigilLoc());
5884 NewTL.setQualifierLoc(NewQualifierLoc);
5885
5886 return Result;
5887}
5888
5889template<typename Derived>
5893 const ConstantArrayType *T = TL.getTypePtr();
5894 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5895 if (ElementType.isNull())
5896 return QualType();
5897
5898 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5899 Expr *OldSize = TL.getSizeExpr();
5900 if (!OldSize)
5901 OldSize = const_cast<Expr*>(T->getSizeExpr());
5902 Expr *NewSize = nullptr;
5903 if (OldSize) {
5906 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5907 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5908 }
5909
5910 QualType Result = TL.getType();
5911 if (getDerived().AlwaysRebuild() ||
5912 ElementType != T->getElementType() ||
5913 (T->getSizeExpr() && NewSize != OldSize)) {
5914 Result = getDerived().RebuildConstantArrayType(ElementType,
5915 T->getSizeModifier(),
5916 T->getSize(), NewSize,
5917 T->getIndexTypeCVRQualifiers(),
5918 TL.getBracketsRange());
5919 if (Result.isNull())
5920 return QualType();
5921 }
5922
5923 // We might have either a ConstantArrayType or a VariableArrayType now:
5924 // a ConstantArrayType is allowed to have an element type which is a
5925 // VariableArrayType if the type is dependent. Fortunately, all array
5926 // types have the same location layout.
5927 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5928 NewTL.setLBracketLoc(TL.getLBracketLoc());
5929 NewTL.setRBracketLoc(TL.getRBracketLoc());
5930 NewTL.setSizeExpr(NewSize);
5931
5932 return Result;
5933}
5934
5935template<typename Derived>
5937 TypeLocBuilder &TLB,
5939 const IncompleteArrayType *T = TL.getTypePtr();
5940 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5941 if (ElementType.isNull())
5942 return QualType();
5943
5944 QualType Result = TL.getType();
5945 if (getDerived().AlwaysRebuild() ||
5946 ElementType != T->getElementType()) {
5947 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5948 T->getSizeModifier(),
5949 T->getIndexTypeCVRQualifiers(),
5950 TL.getBracketsRange());
5951 if (Result.isNull())
5952 return QualType();
5953 }
5954
5956 NewTL.setLBracketLoc(TL.getLBracketLoc());
5957 NewTL.setRBracketLoc(TL.getRBracketLoc());
5958 NewTL.setSizeExpr(nullptr);
5959
5960 return Result;
5961}
5962
5963template<typename Derived>
5967 const VariableArrayType *T = TL.getTypePtr();
5968 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5969 if (ElementType.isNull())
5970 return QualType();
5971
5972 ExprResult SizeResult;
5973 {
5976 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5977 }
5978 if (SizeResult.isInvalid())
5979 return QualType();
5980 SizeResult =
5981 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5982 if (SizeResult.isInvalid())
5983 return QualType();
5984
5985 Expr *Size = SizeResult.get();
5986
5987 QualType Result = TL.getType();
5988 if (getDerived().AlwaysRebuild() ||
5989 ElementType != T->getElementType() ||
5990 Size != T->getSizeExpr()) {
5991 Result = getDerived().RebuildVariableArrayType(ElementType,
5992 T->getSizeModifier(),
5993 Size,
5994 T->getIndexTypeCVRQualifiers(),
5995 TL.getBracketsRange());
5996 if (Result.isNull())
5997 return QualType();
5998 }
5999
6000 // We might have constant size array now, but fortunately it has the same
6001 // location layout.
6002 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6003 NewTL.setLBracketLoc(TL.getLBracketLoc());
6004 NewTL.setRBracketLoc(TL.getRBracketLoc());
6005 NewTL.setSizeExpr(Size);
6006
6007 return Result;
6008}
6009
6010template<typename Derived>
6014 const DependentSizedArrayType *T = TL.getTypePtr();
6015 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6016 if (ElementType.isNull())
6017 return QualType();
6018
6019 // Array bounds are constant expressions.
6022
6023 // If we have a VLA then it won't be a constant.
6024 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
6025
6026 // Prefer the expression from the TypeLoc; the other may have been uniqued.
6027 Expr *origSize = TL.getSizeExpr();
6028 if (!origSize) origSize = T->getSizeExpr();
6029
6030 ExprResult sizeResult
6031 = getDerived().TransformExpr(origSize);
6032 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
6033 if (sizeResult.isInvalid())
6034 return QualType();
6035
6036 Expr *size = sizeResult.get();
6037
6038 QualType Result = TL.getType();
6039 if (getDerived().AlwaysRebuild() ||
6040 ElementType != T->getElementType() ||
6041 size != origSize) {
6042 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
6043 T->getSizeModifier(),
6044 size,
6045 T->getIndexTypeCVRQualifiers(),
6046 TL.getBracketsRange());
6047 if (Result.isNull())
6048 return QualType();
6049 }
6050
6051 // We might have any sort of array type now, but fortunately they
6052 // all have the same location layout.
6053 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6054 NewTL.setLBracketLoc(TL.getLBracketLoc());
6055 NewTL.setRBracketLoc(TL.getRBracketLoc());
6056 NewTL.setSizeExpr(size);
6057
6058 return Result;
6059}
6060
6061template <typename Derived>
6064 const DependentVectorType *T = TL.getTypePtr();
6065 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6066 if (ElementType.isNull())
6067 return QualType();
6068
6071
6072 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6073 Size = SemaRef.ActOnConstantExpression(Size);
6074 if (Size.isInvalid())
6075 return QualType();
6076
6077 QualType Result = TL.getType();
6078 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6079 Size.get() != T->getSizeExpr()) {
6080 Result = getDerived().RebuildDependentVectorType(
6081 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
6082 if (Result.isNull())
6083 return QualType();
6084 }
6085
6086 // Result might be dependent or not.
6089 TLB.push<DependentVectorTypeLoc>(Result);
6090 NewTL.setNameLoc(TL.getNameLoc());
6091 } else {
6092 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6093 NewTL.setNameLoc(TL.getNameLoc());
6094 }
6095
6096 return Result;
6097}
6098
6099template<typename Derived>
6101 TypeLocBuilder &TLB,
6103 const DependentSizedExtVectorType *T = TL.getTypePtr();
6104
6105 // FIXME: ext vector locs should be nested
6106 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6107 if (ElementType.isNull())
6108 return QualType();
6109
6110 // Vector sizes are constant expressions.
6113
6114 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6115 Size = SemaRef.ActOnConstantExpression(Size);
6116 if (Size.isInvalid())
6117 return QualType();
6118
6119 QualType Result = TL.getType();
6120 if (getDerived().AlwaysRebuild() ||
6121 ElementType != T->getElementType() ||
6122 Size.get() != T->getSizeExpr()) {
6123 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
6124 Size.get(),
6125 T->getAttributeLoc());
6126 if (Result.isNull())
6127 return QualType();
6128 }
6129
6130 // Result might be dependent or not.
6134 NewTL.setNameLoc(TL.getNameLoc());
6135 } else {
6136 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6137 NewTL.setNameLoc(TL.getNameLoc());
6138 }
6139
6140 return Result;
6141}
6142
6143template <typename Derived>
6147 const ConstantMatrixType *T = TL.getTypePtr();
6148 QualType ElementType = getDerived().TransformType(T->getElementType());
6149 if (ElementType.isNull())
6150 return QualType();
6151
6152 QualType Result = TL.getType();
6153 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
6154 Result = getDerived().RebuildConstantMatrixType(
6155 ElementType, T->getNumRows(), T->getNumColumns());
6156 if (Result.isNull())
6157 return QualType();
6158 }
6159
6161 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6162 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6163 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
6164 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
6165
6166 return Result;
6167}
6168
6169template <typename Derived>
6172 const DependentSizedMatrixType *T = TL.getTypePtr();
6173
6174 QualType ElementType = getDerived().TransformType(T->getElementType());
6175 if (ElementType.isNull()) {
6176 return QualType();
6177 }
6178
6179 // Matrix dimensions are constant expressions.
6182
6183 Expr *origRows = TL.getAttrRowOperand();
6184 if (!origRows)
6185 origRows = T->getRowExpr();
6186 Expr *origColumns = TL.getAttrColumnOperand();
6187 if (!origColumns)
6188 origColumns = T->getColumnExpr();
6189
6190 ExprResult rowResult = getDerived().TransformExpr(origRows);
6191 rowResult = SemaRef.ActOnConstantExpression(rowResult);
6192 if (rowResult.isInvalid())
6193 return QualType();
6194
6195 ExprResult columnResult = getDerived().TransformExpr(origColumns);
6196 columnResult = SemaRef.ActOnConstantExpression(columnResult);
6197 if (columnResult.isInvalid())
6198 return QualType();
6199
6200 Expr *rows = rowResult.get();
6201 Expr *columns = columnResult.get();
6202
6203 QualType Result = TL.getType();
6204 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6205 rows != origRows || columns != origColumns) {
6206 Result = getDerived().RebuildDependentSizedMatrixType(
6207 ElementType, rows, columns, T->getAttributeLoc());
6208
6209 if (Result.isNull())
6210 return QualType();
6211 }
6212
6213 // We might have any sort of matrix type now, but fortunately they
6214 // all have the same location layout.
6215 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
6216 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6217 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6218 NewTL.setAttrRowOperand(rows);
6219 NewTL.setAttrColumnOperand(columns);
6220 return Result;
6221}
6222
6223template <typename Derived>
6226 const DependentAddressSpaceType *T = TL.getTypePtr();
6227
6228 QualType pointeeType =
6229 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
6230
6231 if (pointeeType.isNull())
6232 return QualType();
6233
6234 // Address spaces are constant expressions.
6237
6238 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
6239 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
6240 if (AddrSpace.isInvalid())
6241 return QualType();
6242
6243 QualType Result = TL.getType();
6244 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
6245 AddrSpace.get() != T->getAddrSpaceExpr()) {
6246 Result = getDerived().RebuildDependentAddressSpaceType(
6247 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6248 if (Result.isNull())
6249 return QualType();
6250 }
6251
6252 // Result might be dependent or not.
6256
6257 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6258 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6259 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6260
6261 } else {
6262 TLB.TypeWasModifiedSafely(Result);
6263 }
6264
6265 return Result;
6266}
6267
6268template <typename Derived>
6270 VectorTypeLoc TL) {
6271 const VectorType *T = TL.getTypePtr();
6272 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6273 if (ElementType.isNull())
6274 return QualType();
6275
6276 QualType Result = TL.getType();
6277 if (getDerived().AlwaysRebuild() ||
6278 ElementType != T->getElementType()) {
6279 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6280 T->getVectorKind());
6281 if (Result.isNull())
6282 return QualType();
6283 }
6284
6285 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6286 NewTL.setNameLoc(TL.getNameLoc());
6287
6288 return Result;
6289}
6290
6291template<typename Derived>
6293 ExtVectorTypeLoc TL) {
6294 const VectorType *T = TL.getTypePtr();
6295 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6296 if (ElementType.isNull())
6297 return QualType();
6298
6299 QualType Result = TL.getType();
6300 if (getDerived().AlwaysRebuild() ||
6301 ElementType != T->getElementType()) {
6302 Result = getDerived().RebuildExtVectorType(ElementType,
6303 T->getNumElements(),
6304 /*FIXME*/ SourceLocation());
6305 if (Result.isNull())
6306 return QualType();
6307 }
6308
6309 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6310 NewTL.setNameLoc(TL.getNameLoc());
6311
6312 return Result;
6313}
6314
6315template <typename Derived>
6317 ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions,
6318 bool ExpectParameterPack) {
6319 TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
6320 TypeSourceInfo *NewTSI = nullptr;
6321
6322 if (NumExpansions && isa<PackExpansionType>(OldTSI->getType())) {
6323 // If we're substituting into a pack expansion type and we know the
6324 // length we want to expand to, just substitute for the pattern.
6325 TypeLoc OldTL = OldTSI->getTypeLoc();
6326 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6327
6328 TypeLocBuilder TLB;
6329 TypeLoc NewTL = OldTSI->getTypeLoc();
6330 TLB.reserve(NewTL.getFullDataSize());
6331
6332 QualType Result = getDerived().TransformType(TLB,
6333 OldExpansionTL.getPatternLoc());
6334 if (Result.isNull())
6335 return nullptr;
6336
6338 OldExpansionTL.getPatternLoc().getSourceRange(),
6339 OldExpansionTL.getEllipsisLoc(),
6340 NumExpansions);
6341 if (Result.isNull())
6342 return nullptr;
6343
6344 PackExpansionTypeLoc NewExpansionTL
6345 = TLB.push<PackExpansionTypeLoc>(Result);
6346 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6347 NewTSI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6348 } else
6349 NewTSI = getDerived().TransformType(OldTSI);
6350 if (!NewTSI)
6351 return nullptr;
6352
6353 if (NewTSI == OldTSI && indexAdjustment == 0)
6354 return OldParm;
6355
6357 SemaRef.Context, OldParm->getDeclContext(), OldParm->getInnerLocStart(),
6358 OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
6359 NewTSI, OldParm->getStorageClass(),
6360 /* DefArg */ nullptr);
6361 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6362 OldParm->getFunctionScopeIndex() + indexAdjustment);
6363 getDerived().transformedLocalDecl(OldParm, {newParm});
6364 return newParm;
6365}
6366
6367template <typename Derived>
6370 const QualType *ParamTypes,
6371 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6372 SmallVectorImpl<QualType> &OutParamTypes,
6375 unsigned *LastParamTransformed) {
6376 int indexAdjustment = 0;
6377
6378 unsigned NumParams = Params.size();
6379 for (unsigned i = 0; i != NumParams; ++i) {
6380 if (LastParamTransformed)
6381 *LastParamTransformed = i;
6382 if (ParmVarDecl *OldParm = Params[i]) {
6383 assert(OldParm->getFunctionScopeIndex() == i);
6384
6385 UnsignedOrNone NumExpansions = std::nullopt;
6386 ParmVarDecl *NewParm = nullptr;
6387 if (OldParm->isParameterPack()) {
6388 // We have a function parameter pack that may need to be expanded.
6390
6391 // Find the parameter packs that could be expanded.
6392 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6394 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6395 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6396
6397 // Determine whether we should expand the parameter packs.
6398 bool ShouldExpand = false;
6399 bool RetainExpansion = false;
6400 UnsignedOrNone OrigNumExpansions = std::nullopt;
6401 if (Unexpanded.size() > 0) {
6402 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6403 NumExpansions = OrigNumExpansions;
6405 ExpansionTL.getEllipsisLoc(), Pattern.getSourceRange(),
6406 Unexpanded, /*FailOnPackProducingTemplates=*/true,
6407 ShouldExpand, RetainExpansion, NumExpansions)) {
6408 return true;
6409 }
6410 } else {
6411#ifndef NDEBUG
6412 const AutoType *AT =
6413 Pattern.getType().getTypePtr()->getContainedAutoType();
6414 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6415 "Could not find parameter packs or undeduced auto type!");
6416#endif
6417 }
6418
6419 if (ShouldExpand) {
6420 // Expand the function parameter pack into multiple, separate
6421 // parameters.
6422 getDerived().ExpandingFunctionParameterPack(OldParm);
6423 for (unsigned I = 0; I != *NumExpansions; ++I) {
6424 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6425 ParmVarDecl *NewParm
6426 = getDerived().TransformFunctionTypeParam(OldParm,
6427 indexAdjustment++,
6428 OrigNumExpansions,
6429 /*ExpectParameterPack=*/false);
6430 if (!NewParm)
6431 return true;
6432
6433 if (ParamInfos)
6434 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6435 OutParamTypes.push_back(NewParm->getType());
6436 if (PVars)
6437 PVars->push_back(NewParm);
6438 }
6439
6440 // If we're supposed to retain a pack expansion, do so by temporarily
6441 // forgetting the partially-substituted parameter pack.
6442 if (RetainExpansion) {
6443 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6444 ParmVarDecl *NewParm
6445 = getDerived().TransformFunctionTypeParam(OldParm,
6446 indexAdjustment++,
6447 OrigNumExpansions,
6448 /*ExpectParameterPack=*/false);
6449 if (!NewParm)
6450 return true;
6451
6452 if (ParamInfos)
6453 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6454 OutParamTypes.push_back(NewParm->getType());
6455 if (PVars)
6456 PVars->push_back(NewParm);
6457 }
6458
6459 // The next parameter should have the same adjustment as the
6460 // last thing we pushed, but we post-incremented indexAdjustment
6461 // on every push. Also, if we push nothing, the adjustment should
6462 // go down by one.
6463 indexAdjustment--;
6464
6465 // We're done with the pack expansion.
6466 continue;
6467 }
6468
6469 // We'll substitute the parameter now without expanding the pack
6470 // expansion.
6471 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6472 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6473 indexAdjustment,
6474 NumExpansions,
6475 /*ExpectParameterPack=*/true);
6476 assert(NewParm->isParameterPack() &&
6477 "Parameter pack no longer a parameter pack after "
6478 "transformation.");
6479 } else {
6480 NewParm = getDerived().TransformFunctionTypeParam(
6481 OldParm, indexAdjustment, std::nullopt,
6482 /*ExpectParameterPack=*/false);
6483 }
6484
6485 if (!NewParm)
6486 return true;
6487
6488 if (ParamInfos)
6489 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6490 OutParamTypes.push_back(NewParm->getType());
6491 if (PVars)
6492 PVars->push_back(NewParm);
6493 continue;
6494 }
6495
6496 // Deal with the possibility that we don't have a parameter
6497 // declaration for this parameter.
6498 assert(ParamTypes);
6499 QualType OldType = ParamTypes[i];
6500 bool IsPackExpansion = false;
6501 UnsignedOrNone NumExpansions = std::nullopt;
6502 QualType NewType;
6503 if (const PackExpansionType *Expansion
6504 = dyn_cast<PackExpansionType>(OldType)) {
6505 // We have a function parameter pack that may need to be expanded.
6506 QualType Pattern = Expansion->getPattern();
6508 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6509
6510 // Determine whether we should expand the parameter packs.
6511 bool ShouldExpand = false;
6512 bool RetainExpansion = false;
6514 Loc, SourceRange(), Unexpanded,
6515 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
6516 RetainExpansion, NumExpansions)) {
6517 return true;
6518 }
6519
6520 if (ShouldExpand) {
6521 // Expand the function parameter pack into multiple, separate
6522 // parameters.
6523 for (unsigned I = 0; I != *NumExpansions; ++I) {
6524 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6525 QualType NewType = getDerived().TransformType(Pattern);
6526 if (NewType.isNull())
6527 return true;
6528
6529 if (NewType->containsUnexpandedParameterPack()) {
6530 NewType = getSema().getASTContext().getPackExpansionType(
6531 NewType, std::nullopt);
6532
6533 if (NewType.isNull())
6534 return true;
6535 }
6536
6537 if (ParamInfos)
6538 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6539 OutParamTypes.push_back(NewType);
6540 if (PVars)
6541 PVars->push_back(nullptr);
6542 }
6543
6544 // We're done with the pack expansion.
6545 continue;
6546 }
6547
6548 // If we're supposed to retain a pack expansion, do so by temporarily
6549 // forgetting the partially-substituted parameter pack.
6550 if (RetainExpansion) {
6551 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6552 QualType NewType = getDerived().TransformType(Pattern);
6553 if (NewType.isNull())
6554 return true;
6555
6556 if (ParamInfos)
6557 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6558 OutParamTypes.push_back(NewType);
6559 if (PVars)
6560 PVars->push_back(nullptr);
6561 }
6562
6563 // We'll substitute the parameter now without expanding the pack
6564 // expansion.
6565 OldType = Expansion->getPattern();
6566 IsPackExpansion = true;
6567 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6568 NewType = getDerived().TransformType(OldType);
6569 } else {
6570 NewType = getDerived().TransformType(OldType);
6571 }
6572
6573 if (NewType.isNull())
6574 return true;
6575
6576 if (IsPackExpansion)
6577 NewType = getSema().Context.getPackExpansionType(NewType,
6578 NumExpansions);
6579
6580 if (ParamInfos)
6581 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6582 OutParamTypes.push_back(NewType);
6583 if (PVars)
6584 PVars->push_back(nullptr);
6585 }
6586
6587#ifndef NDEBUG
6588 if (PVars) {
6589 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6590 if (ParmVarDecl *parm = (*PVars)[i])
6591 assert(parm->getFunctionScopeIndex() == i);
6592 }
6593#endif
6594
6595 return false;
6596}
6597
6598template<typename Derived>
6602 SmallVector<QualType, 4> ExceptionStorage;
6603 return getDerived().TransformFunctionProtoType(
6604 TLB, TL, nullptr, Qualifiers(),
6605 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6606 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6607 ExceptionStorage, Changed);
6608 });
6609}
6610
6611template<typename Derived> template<typename Fn>
6613 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6614 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6615
6616 // Transform the parameters and return type.
6617 //
6618 // We are required to instantiate the params and return type in source order.
6619 // When the function has a trailing return type, we instantiate the
6620 // parameters before the return type, since the return type can then refer
6621 // to the parameters themselves (via decltype, sizeof, etc.).
6622 //
6623 SmallVector<QualType, 4> ParamTypes;
6625 Sema::ExtParameterInfoBuilder ExtParamInfos;
6626 const FunctionProtoType *T = TL.getTypePtr();
6627
6628 QualType ResultType;
6629
6630 if (T->hasTrailingReturn()) {
6632 TL.getBeginLoc(), TL.getParams(),
6634 T->getExtParameterInfosOrNull(),
6635 ParamTypes, &ParamDecls, ExtParamInfos))
6636 return QualType();
6637
6638 {
6639 // C++11 [expr.prim.general]p3:
6640 // If a declaration declares a member function or member function
6641 // template of a class X, the expression this is a prvalue of type
6642 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6643 // and the end of the function-definition, member-declarator, or
6644 // declarator.
6645 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6646 Sema::CXXThisScopeRAII ThisScope(
6647 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6648
6649 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6650 if (ResultType.isNull())
6651 return QualType();
6652 }
6653 }
6654 else {
6655 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6656 if (ResultType.isNull())
6657 return QualType();
6658
6660 TL.getBeginLoc(), TL.getParams(),
6662 T->getExtParameterInfosOrNull(),
6663 ParamTypes, &ParamDecls, ExtParamInfos))
6664 return QualType();
6665 }
6666
6667 FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
6668
6669 bool EPIChanged = false;
6670 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6671 return QualType();
6672
6673 // Handle extended parameter information.
6674 if (auto NewExtParamInfos =
6675 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6676 if (!EPI.ExtParameterInfos ||
6678 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6679 EPIChanged = true;
6680 }
6681 EPI.ExtParameterInfos = NewExtParamInfos;
6682 } else if (EPI.ExtParameterInfos) {
6683 EPIChanged = true;
6684 EPI.ExtParameterInfos = nullptr;
6685 }
6686
6687 // Transform any function effects with unevaluated conditions.
6688 // Hold this set in a local for the rest of this function, since EPI
6689 // may need to hold a FunctionEffectsRef pointing into it.
6690 std::optional<FunctionEffectSet> NewFX;
6691 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6692 NewFX.emplace();
6695
6696 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6697 FunctionEffectWithCondition NewEC = PrevEC;
6698 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6699 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6700 if (NewExpr.isInvalid())
6701 return QualType();
6702 std::optional<FunctionEffectMode> Mode =
6703 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6704 if (!Mode)
6705 return QualType();
6706
6707 // The condition expression has been transformed, and re-evaluated.
6708 // It may or may not have become constant.
6709 switch (*Mode) {
6711 NewEC.Cond = {};
6712 break;
6714 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6715 NewEC.Cond = {};
6716 break;
6718 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6719 break;
6721 llvm_unreachable(
6722 "FunctionEffectMode::None shouldn't be possible here");
6723 }
6724 }
6725 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6726 TL.getBeginLoc())) {
6728 NewFX->insert(NewEC, Errs);
6729 assert(Errs.empty());
6730 }
6731 }
6732 EPI.FunctionEffects = *NewFX;
6733 EPIChanged = true;
6734 }
6735
6736 QualType Result = TL.getType();
6737 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6738 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6739 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6740 if (Result.isNull())
6741 return QualType();
6742 }
6743
6746 NewTL.setLParenLoc(TL.getLParenLoc());
6747 NewTL.setRParenLoc(TL.getRParenLoc());
6750 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6751 NewTL.setParam(i, ParamDecls[i]);
6752
6753 return Result;
6754}
6755
6756template<typename Derived>
6759 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6760 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6761
6762 // Instantiate a dynamic noexcept expression, if any.
6763 if (isComputedNoexcept(ESI.Type)) {
6764 // Update this scrope because ContextDecl in Sema will be used in
6765 // TransformExpr.
6766 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6767 Sema::CXXThisScopeRAII ThisScope(
6768 SemaRef, Method ? Method->getParent() : nullptr,
6769 Method ? Method->getMethodQualifiers() : Qualifiers{},
6770 Method != nullptr);
6773 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6774 if (NoexceptExpr.isInvalid())
6775 return true;
6776
6778 NoexceptExpr =
6779 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6780 if (NoexceptExpr.isInvalid())
6781 return true;
6782
6783 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6784 Changed = true;
6785 ESI.NoexceptExpr = NoexceptExpr.get();
6786 ESI.Type = EST;
6787 }
6788
6789 if (ESI.Type != EST_Dynamic)
6790 return false;
6791
6792 // Instantiate a dynamic exception specification's type.
6793 for (QualType T : ESI.Exceptions) {
6794 if (const PackExpansionType *PackExpansion =
6795 T->getAs<PackExpansionType>()) {
6796 Changed = true;
6797
6798 // We have a pack expansion. Instantiate it.
6800 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6801 Unexpanded);
6802 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6803
6804 // Determine whether the set of unexpanded parameter packs can and
6805 // should
6806 // be expanded.
6807 bool Expand = false;
6808 bool RetainExpansion = false;
6809 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
6810 // FIXME: Track the location of the ellipsis (and track source location
6811 // information for the types in the exception specification in general).
6813 Loc, SourceRange(), Unexpanded,
6814 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
6815 NumExpansions))
6816 return true;
6817
6818 if (!Expand) {
6819 // We can't expand this pack expansion into separate arguments yet;
6820 // just substitute into the pattern and create a new pack expansion
6821 // type.
6822 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6823 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6824 if (U.isNull())
6825 return true;
6826
6827 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6828 Exceptions.push_back(U);
6829 continue;
6830 }
6831
6832 // Substitute into the pack expansion pattern for each slice of the
6833 // pack.
6834 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6835 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
6836
6837 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6838 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6839 return true;
6840
6841 Exceptions.push_back(U);
6842 }
6843 } else {
6844 QualType U = getDerived().TransformType(T);
6845 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6846 return true;
6847 if (T != U)
6848 Changed = true;
6849
6850 Exceptions.push_back(U);
6851 }
6852 }
6853
6854 ESI.Exceptions = Exceptions;
6855 if (ESI.Exceptions.empty())
6856 ESI.Type = EST_DynamicNone;
6857 return false;
6858}
6859
6860template<typename Derived>
6862 TypeLocBuilder &TLB,
6864 const FunctionNoProtoType *T = TL.getTypePtr();
6865 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6866 if (ResultType.isNull())
6867 return QualType();
6868
6869 QualType Result = TL.getType();
6870 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6871 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6872
6875 NewTL.setLParenLoc(TL.getLParenLoc());
6876 NewTL.setRParenLoc(TL.getRParenLoc());
6878
6879 return Result;
6880}
6881
6882template <typename Derived>
6883QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6884 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6885
6886 const UnresolvedUsingType *T = TL.getTypePtr();
6887 bool Changed = false;
6888
6889 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6890 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6891 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6892 if (!QualifierLoc)
6893 return QualType();
6894 Changed |= QualifierLoc != OldQualifierLoc;
6895 }
6896
6897 auto *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6898 if (!D)
6899 return QualType();
6900 Changed |= D != T->getDecl();
6901
6902 QualType Result = TL.getType();
6903 if (getDerived().AlwaysRebuild() || Changed) {
6904 Result = getDerived().RebuildUnresolvedUsingType(
6905 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TL.getNameLoc(),
6906 D);
6907 if (Result.isNull())
6908 return QualType();
6909 }
6910
6912 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6913 QualifierLoc, TL.getNameLoc());
6914 else
6915 TLB.push<UnresolvedUsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6916 QualifierLoc, TL.getNameLoc());
6917 return Result;
6918}
6919
6920template <typename Derived>
6922 UsingTypeLoc TL) {
6923 const UsingType *T = TL.getTypePtr();
6924 bool Changed = false;
6925
6926 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6927 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6928 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6929 if (!QualifierLoc)
6930 return QualType();
6931 Changed |= QualifierLoc != OldQualifierLoc;
6932 }
6933
6934 auto *D = cast_or_null<UsingShadowDecl>(
6935 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6936 if (!D)
6937 return QualType();
6938 Changed |= D != T->getDecl();
6939
6940 QualType UnderlyingType = getDerived().TransformType(T->desugar());
6941 if (UnderlyingType.isNull())
6942 return QualType();
6943 Changed |= UnderlyingType != T->desugar();
6944
6945 QualType Result = TL.getType();
6946 if (getDerived().AlwaysRebuild() || Changed) {
6947 Result = getDerived().RebuildUsingType(
6948 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), D,
6949 UnderlyingType);
6950 if (Result.isNull())
6951 return QualType();
6952 }
6953 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(), QualifierLoc,
6954 TL.getNameLoc());
6955 return Result;
6956}
6957
6958template<typename Derived>
6960 TypedefTypeLoc TL) {
6961 const TypedefType *T = TL.getTypePtr();
6962 bool Changed = false;
6963
6964 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6965 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6966 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6967 if (!QualifierLoc)
6968 return QualType();
6969 Changed |= QualifierLoc != OldQualifierLoc;
6970 }
6971
6972 auto *Typedef = cast_or_null<TypedefNameDecl>(
6973 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6974 if (!Typedef)
6975 return QualType();
6976 Changed |= Typedef != T->getDecl();
6977
6978 // FIXME: Transform the UnderlyingType if different from decl.
6979
6980 QualType Result = TL.getType();
6981 if (getDerived().AlwaysRebuild() || Changed) {
6982 Result = getDerived().RebuildTypedefType(
6983 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), Typedef);
6984 if (Result.isNull())
6985 return QualType();
6986 }
6987
6988 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6989 QualifierLoc, TL.getNameLoc());
6990 return Result;
6991}
6992
6993template<typename Derived>
6995 TypeOfExprTypeLoc TL) {
6996 // typeof expressions are not potentially evaluated contexts
7000
7001 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
7002 if (E.isInvalid())
7003 return QualType();
7004
7005 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
7006 if (E.isInvalid())
7007 return QualType();
7008
7009 QualType Result = TL.getType();
7011 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
7012 Result =
7013 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
7014 if (Result.isNull())
7015 return QualType();
7016 }
7017
7018 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
7019 NewTL.setTypeofLoc(TL.getTypeofLoc());
7020 NewTL.setLParenLoc(TL.getLParenLoc());
7021 NewTL.setRParenLoc(TL.getRParenLoc());
7022
7023 return Result;
7024}
7025
7026template<typename Derived>
7028 TypeOfTypeLoc TL) {
7029 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
7030 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
7031 if (!New_Under_TI)
7032 return QualType();
7033
7034 QualType Result = TL.getType();
7035 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
7036 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
7037 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
7038 if (Result.isNull())
7039 return QualType();
7040 }
7041
7042 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
7043 NewTL.setTypeofLoc(TL.getTypeofLoc());
7044 NewTL.setLParenLoc(TL.getLParenLoc());
7045 NewTL.setRParenLoc(TL.getRParenLoc());
7046 NewTL.setUnmodifiedTInfo(New_Under_TI);
7047
7048 return Result;
7049}
7050
7051template<typename Derived>
7053 DecltypeTypeLoc TL) {
7054 const DecltypeType *T = TL.getTypePtr();
7055
7056 // decltype expressions are not potentially evaluated contexts
7060
7061 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
7062 if (E.isInvalid())
7063 return QualType();
7064
7065 E = getSema().ActOnDecltypeExpression(E.get());
7066 if (E.isInvalid())
7067 return QualType();
7068
7069 QualType Result = TL.getType();
7070 if (getDerived().AlwaysRebuild() ||
7071 E.get() != T->getUnderlyingExpr()) {
7072 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
7073 if (Result.isNull())
7074 return QualType();
7075 }
7076 else E.get();
7077
7078 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
7079 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
7080 NewTL.setRParenLoc(TL.getRParenLoc());
7081 return Result;
7082}
7083
7084template <typename Derived>
7088 // Transform the index
7089 ExprResult IndexExpr;
7090 {
7091 EnterExpressionEvaluationContext ConstantContext(
7093
7094 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
7095 if (IndexExpr.isInvalid())
7096 return QualType();
7097 }
7098 QualType Pattern = TL.getPattern();
7099
7100 const PackIndexingType *PIT = TL.getTypePtr();
7101 SmallVector<QualType, 5> SubtitutedTypes;
7102 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
7103
7104 bool NotYetExpanded = Types.empty();
7105 bool FullySubstituted = true;
7106
7107 if (Types.empty() && !PIT->expandsToEmptyPack())
7108 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
7109
7110 for (QualType T : Types) {
7111 if (!T->containsUnexpandedParameterPack()) {
7112 QualType Transformed = getDerived().TransformType(T);
7113 if (Transformed.isNull())
7114 return QualType();
7115 SubtitutedTypes.push_back(Transformed);
7116 continue;
7117 }
7118
7120 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
7121 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7122 // Determine whether the set of unexpanded parameter packs can and should
7123 // be expanded.
7124 bool ShouldExpand = true;
7125 bool RetainExpansion = false;
7126 UnsignedOrNone NumExpansions = std::nullopt;
7127 if (getDerived().TryExpandParameterPacks(
7128 TL.getEllipsisLoc(), SourceRange(), Unexpanded,
7129 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
7130 RetainExpansion, NumExpansions))
7131 return QualType();
7132 if (!ShouldExpand) {
7133 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7134 // FIXME: should we keep TypeLoc for individual expansions in
7135 // PackIndexingTypeLoc?
7136 TypeSourceInfo *TI =
7137 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
7138 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
7139 if (Pack.isNull())
7140 return QualType();
7141 if (NotYetExpanded) {
7142 FullySubstituted = false;
7143 QualType Out = getDerived().RebuildPackIndexingType(
7144 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7145 FullySubstituted);
7146 if (Out.isNull())
7147 return QualType();
7148
7150 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7151 return Out;
7152 }
7153 SubtitutedTypes.push_back(Pack);
7154 continue;
7155 }
7156 for (unsigned I = 0; I != *NumExpansions; ++I) {
7157 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
7158 QualType Out = getDerived().TransformType(T);
7159 if (Out.isNull())
7160 return QualType();
7161 SubtitutedTypes.push_back(Out);
7162 FullySubstituted &= !Out->containsUnexpandedParameterPack();
7163 }
7164 // If we're supposed to retain a pack expansion, do so by temporarily
7165 // forgetting the partially-substituted parameter pack.
7166 if (RetainExpansion) {
7167 FullySubstituted = false;
7168 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
7169 QualType Out = getDerived().TransformType(T);
7170 if (Out.isNull())
7171 return QualType();
7172 SubtitutedTypes.push_back(Out);
7173 }
7174 }
7175
7176 // A pack indexing type can appear in a larger pack expansion,
7177 // e.g. `Pack...[pack_of_indexes]...`
7178 // so we need to temporarily disable substitution of pack elements
7179 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7180 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
7181
7182 QualType Out = getDerived().RebuildPackIndexingType(
7183 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7184 FullySubstituted, SubtitutedTypes);
7185 if (Out.isNull())
7186 return Out;
7187
7189 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7190 return Out;
7191}
7192
7193template<typename Derived>
7195 TypeLocBuilder &TLB,
7197 QualType Result = TL.getType();
7198 TypeSourceInfo *NewBaseTSI = TL.getUnderlyingTInfo();
7199 if (Result->isDependentType()) {
7200 const UnaryTransformType *T = TL.getTypePtr();
7201
7202 NewBaseTSI = getDerived().TransformType(TL.getUnderlyingTInfo());
7203 if (!NewBaseTSI)
7204 return QualType();
7205 QualType NewBase = NewBaseTSI->getType();
7206
7207 Result = getDerived().RebuildUnaryTransformType(NewBase,
7208 T->getUTTKind(),
7209 TL.getKWLoc());
7210 if (Result.isNull())
7211 return QualType();
7212 }
7213
7215 NewTL.setKWLoc(TL.getKWLoc());
7216 NewTL.setParensRange(TL.getParensRange());
7217 NewTL.setUnderlyingTInfo(NewBaseTSI);
7218 return Result;
7219}
7220
7221template<typename Derived>
7224 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
7225
7226 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7227 TemplateName TemplateName = getDerived().TransformTemplateName(
7228 QualifierLoc, /*TemplateKELoc=*/SourceLocation(), T->getTemplateName(),
7229 TL.getTemplateNameLoc());
7230 if (TemplateName.isNull())
7231 return QualType();
7232
7233 QualType OldDeduced = T->getDeducedType();
7234 QualType NewDeduced;
7235 if (!OldDeduced.isNull()) {
7236 NewDeduced = getDerived().TransformType(OldDeduced);
7237 if (NewDeduced.isNull())
7238 return QualType();
7239 }
7240
7241 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
7242 T->getKeyword(), TemplateName, NewDeduced);
7243 if (Result.isNull())
7244 return QualType();
7245
7246 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7247 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7248 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7249 NewTL.setQualifierLoc(QualifierLoc);
7250 return Result;
7251}
7252
7253template <typename Derived>
7255 TagTypeLoc TL) {
7256 const TagType *T = TL.getTypePtr();
7257
7258 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7259 if (QualifierLoc) {
7260 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7261 if (!QualifierLoc)
7262 return QualType();
7263 }
7264
7265 auto *TD = cast_or_null<TagDecl>(
7266 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7267 if (!TD)
7268 return QualType();
7269
7270 QualType Result = TL.getType();
7271 if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() ||
7272 TD != T->getDecl()) {
7273 if (T->isCanonicalUnqualified())
7274 Result = getDerived().RebuildCanonicalTagType(TD);
7275 else
7276 Result = getDerived().RebuildTagType(
7277 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TD);
7278 if (Result.isNull())
7279 return QualType();
7280 }
7281
7282 TagTypeLoc NewTL = TLB.push<TagTypeLoc>(Result);
7284 NewTL.setQualifierLoc(QualifierLoc);
7285 NewTL.setNameLoc(TL.getNameLoc());
7286
7287 return Result;
7288}
7289
7290template <typename Derived>
7292 EnumTypeLoc TL) {
7293 return getDerived().TransformTagType(TLB, TL);
7294}
7295
7296template <typename Derived>
7297QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
7298 RecordTypeLoc TL) {
7299 return getDerived().TransformTagType(TLB, TL);
7300}
7301
7302template<typename Derived>
7304 TypeLocBuilder &TLB,
7306 return getDerived().TransformTagType(TLB, TL);
7307}
7308
7309template<typename Derived>
7311 TypeLocBuilder &TLB,
7313 return getDerived().TransformTemplateTypeParmType(
7314 TLB, TL,
7315 /*SuppressObjCLifetime=*/false);
7316}
7317
7318template <typename Derived>
7320 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7321 return TransformTypeSpecType(TLB, TL);
7322}
7323
7324template<typename Derived>
7325QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7326 TypeLocBuilder &TLB,
7327 SubstTemplateTypeParmTypeLoc TL) {
7328 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7329
7330 Decl *NewReplaced =
7331 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7332
7333 // Substitute into the replacement type, which itself might involve something
7334 // that needs to be transformed. This only tends to occur with default
7335 // template arguments of template template parameters.
7336 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7337 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7338 if (Replacement.isNull())
7339 return QualType();
7340
7341 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7342 Replacement, NewReplaced, T->getIndex(), T->getPackIndex(),
7343 T->getFinal());
7344
7345 // Propagate type-source information.
7346 SubstTemplateTypeParmTypeLoc NewTL
7347 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7348 NewTL.setNameLoc(TL.getNameLoc());
7349 return Result;
7350
7351}
7352template <typename Derived>
7355 return TransformTypeSpecType(TLB, TL);
7356}
7357
7358template<typename Derived>
7360 TypeLocBuilder &TLB,
7362 return getDerived().TransformSubstTemplateTypeParmPackType(
7363 TLB, TL, /*SuppressObjCLifetime=*/false);
7364}
7365
7366template <typename Derived>
7369 return TransformTypeSpecType(TLB, TL);
7370}
7371
7372template<typename Derived>
7373QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
7374 AtomicTypeLoc TL) {
7375 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7376 if (ValueType.isNull())
7377 return QualType();
7378
7379 QualType Result = TL.getType();
7380 if (getDerived().AlwaysRebuild() ||
7381 ValueType != TL.getValueLoc().getType()) {
7382 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7383 if (Result.isNull())
7384 return QualType();
7385 }
7386
7387 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7388 NewTL.setKWLoc(TL.getKWLoc());
7389 NewTL.setLParenLoc(TL.getLParenLoc());
7390 NewTL.setRParenLoc(TL.getRParenLoc());
7391
7392 return Result;
7393}
7394
7395template <typename Derived>
7397 PipeTypeLoc TL) {
7398 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7399 if (ValueType.isNull())
7400 return QualType();
7401
7402 QualType Result = TL.getType();
7403 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7404 const PipeType *PT = Result->castAs<PipeType>();
7405 bool isReadPipe = PT->isReadOnly();
7406 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7407 if (Result.isNull())
7408 return QualType();
7409 }
7410
7411 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7412 NewTL.setKWLoc(TL.getKWLoc());
7413
7414 return Result;
7415}
7416
7417template <typename Derived>
7419 BitIntTypeLoc TL) {
7420 const BitIntType *EIT = TL.getTypePtr();
7421 QualType Result = TL.getType();
7422
7423 if (getDerived().AlwaysRebuild()) {
7424 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7425 EIT->getNumBits(), TL.getNameLoc());
7426 if (Result.isNull())
7427 return QualType();
7428 }
7429
7430 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7431 NewTL.setNameLoc(TL.getNameLoc());
7432 return Result;
7433}
7434
7435template <typename Derived>
7438 const DependentBitIntType *EIT = TL.getTypePtr();
7439
7442 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7443 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7444
7445 if (BitsExpr.isInvalid())
7446 return QualType();
7447
7448 QualType Result = TL.getType();
7449
7450 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7451 Result = getDerived().RebuildDependentBitIntType(
7452 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7453
7454 if (Result.isNull())
7455 return QualType();
7456 }
7457
7460 NewTL.setNameLoc(TL.getNameLoc());
7461 } else {
7462 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7463 NewTL.setNameLoc(TL.getNameLoc());
7464 }
7465 return Result;
7466}
7467
7468template <typename Derived>
7471 llvm_unreachable("This type does not need to be transformed.");
7472}
7473
7474 /// Simple iterator that traverses the template arguments in a
7475 /// container that provides a \c getArgLoc() member function.
7476 ///
7477 /// This iterator is intended to be used with the iterator form of
7478 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7479 template<typename ArgLocContainer>
7481 ArgLocContainer *Container;
7482 unsigned Index;
7483
7484 public:
7487 typedef int difference_type;
7488 typedef std::input_iterator_tag iterator_category;
7489
7490 class pointer {
7492
7493 public:
7494 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7495
7497 return &Arg;
7498 }
7499 };
7500
7501
7503
7504 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7505 unsigned Index)
7506 : Container(&Container), Index(Index) { }
7507
7509 ++Index;
7510 return *this;
7511 }
7512
7515 ++(*this);
7516 return Old;
7517 }
7518
7520 return Container->getArgLoc(Index);
7521 }
7522
7524 return pointer(Container->getArgLoc(Index));
7525 }
7526
7529 return X.Container == Y.Container && X.Index == Y.Index;
7530 }
7531
7534 return !(X == Y);
7535 }
7536 };
7537
7538template<typename Derived>
7539QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7540 AutoTypeLoc TL) {
7541 const AutoType *T = TL.getTypePtr();
7542 QualType OldDeduced = T->getDeducedType();
7543 QualType NewDeduced;
7544 if (!OldDeduced.isNull()) {
7545 NewDeduced = getDerived().TransformType(OldDeduced);
7546 if (NewDeduced.isNull())
7547 return QualType();
7548 }
7549
7550 ConceptDecl *NewCD = nullptr;
7551 TemplateArgumentListInfo NewTemplateArgs;
7552 NestedNameSpecifierLoc NewNestedNameSpec;
7553 if (T->isConstrained()) {
7554 assert(TL.getConceptReference());
7555 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7556 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7557
7558 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7559 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7561 if (getDerived().TransformTemplateArguments(
7562 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7563 NewTemplateArgs))
7564 return QualType();
7565
7566 if (TL.getNestedNameSpecifierLoc()) {
7567 NewNestedNameSpec
7568 = getDerived().TransformNestedNameSpecifierLoc(
7569 TL.getNestedNameSpecifierLoc());
7570 if (!NewNestedNameSpec)
7571 return QualType();
7572 }
7573 }
7574
7575 QualType Result = TL.getType();
7576 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7577 T->isDependentType() || T->isConstrained()) {
7578 // FIXME: Maybe don't rebuild if all template arguments are the same.
7580 NewArgList.reserve(NewTemplateArgs.size());
7581 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7582 NewArgList.push_back(ArgLoc.getArgument());
7583 Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword(), NewCD,
7584 NewArgList);
7585 if (Result.isNull())
7586 return QualType();
7587 }
7588
7589 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7590 NewTL.setNameLoc(TL.getNameLoc());
7591 NewTL.setRParenLoc(TL.getRParenLoc());
7592 NewTL.setConceptReference(nullptr);
7593
7594 if (T->isConstrained()) {
7596 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7597 TL.getConceptNameLoc(),
7598 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7599 auto *CR = ConceptReference::Create(
7600 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7601 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7602 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7603 NewTL.setConceptReference(CR);
7604 }
7605
7606 return Result;
7607}
7608
7609template <typename Derived>
7612 return getDerived().TransformTemplateSpecializationType(
7613 TLB, TL, /*ObjectType=*/QualType(), /*FirstQualifierInScope=*/nullptr,
7614 /*AllowInjectedClassName=*/false);
7615}
7616
7617template <typename Derived>
7620 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
7621 const TemplateSpecializationType *T = TL.getTypePtr();
7622
7623 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7624 TemplateName Template = getDerived().TransformTemplateName(
7625 QualifierLoc, TL.getTemplateKeywordLoc(), T->getTemplateName(),
7626 TL.getTemplateNameLoc(), ObjectType, FirstQualifierInScope,
7627 AllowInjectedClassName);
7628 if (Template.isNull())
7629 return QualType();
7630
7631 TemplateArgumentListInfo NewTemplateArgs;
7632 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7633 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7635 ArgIterator;
7636 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7637 ArgIterator(TL, TL.getNumArgs()),
7638 NewTemplateArgs))
7639 return QualType();
7640
7641 // This needs to be rebuilt if either the arguments changed, or if the
7642 // original template changed. If the template changed, and even if the
7643 // arguments didn't change, these arguments might not correspond to their
7644 // respective parameters, therefore needing conversions.
7645 QualType Result = getDerived().RebuildTemplateSpecializationType(
7646 TL.getTypePtr()->getKeyword(), Template, TL.getTemplateNameLoc(),
7647 NewTemplateArgs);
7648
7649 if (!Result.isNull()) {
7651 TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getTemplateKeywordLoc(),
7652 TL.getTemplateNameLoc(), NewTemplateArgs);
7653 }
7654
7655 return Result;
7656}
7657
7658template <typename Derived>
7660 AttributedTypeLoc TL) {
7661 const AttributedType *oldType = TL.getTypePtr();
7662 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7663 if (modifiedType.isNull())
7664 return QualType();
7665
7666 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7667 const Attr *oldAttr = TL.getAttr();
7668 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7669 if (oldAttr && !newAttr)
7670 return QualType();
7671
7672 QualType result = TL.getType();
7673
7674 // FIXME: dependent operand expressions?
7675 if (getDerived().AlwaysRebuild() ||
7676 modifiedType != oldType->getModifiedType()) {
7677 // If the equivalent type is equal to the modified type, we don't want to
7678 // transform it as well because:
7679 //
7680 // 1. The transformation would yield the same result and is therefore
7681 // superfluous, and
7682 //
7683 // 2. Transforming the same type twice can cause problems, e.g. if it
7684 // is a FunctionProtoType, we may end up instantiating the function
7685 // parameters twice, which causes an assertion since the parameters
7686 // are already bound to their counterparts in the template for this
7687 // instantiation.
7688 //
7689 QualType equivalentType = modifiedType;
7690 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7691 TypeLocBuilder AuxiliaryTLB;
7692 AuxiliaryTLB.reserve(TL.getFullDataSize());
7693 equivalentType =
7694 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7695 if (equivalentType.isNull())
7696 return QualType();
7697 }
7698
7699 // Check whether we can add nullability; it is only represented as
7700 // type sugar, and therefore cannot be diagnosed in any other way.
7701 if (auto nullability = oldType->getImmediateNullability()) {
7702 if (!modifiedType->canHaveNullability()) {
7703 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7704 : TL.getModifiedLoc().getBeginLoc()),
7705 diag::err_nullability_nonpointer)
7706 << DiagNullabilityKind(*nullability, false) << modifiedType;
7707 return QualType();
7708 }
7709 }
7710
7711 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7712 modifiedType,
7713 equivalentType,
7714 TL.getAttr());
7715 }
7716
7717 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7718 newTL.setAttr(newAttr);
7719 return result;
7720}
7721
7722template <typename Derived>
7725 const CountAttributedType *OldTy = TL.getTypePtr();
7726 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7727 if (InnerTy.isNull())
7728 return QualType();
7729
7730 Expr *OldCount = TL.getCountExpr();
7731 Expr *NewCount = nullptr;
7732 if (OldCount) {
7733 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7734 if (CountResult.isInvalid())
7735 return QualType();
7736 NewCount = CountResult.get();
7737 }
7738
7739 QualType Result = TL.getType();
7740 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7741 OldCount != NewCount) {
7742 // Currently, CountAttributedType can only wrap incomplete array types.
7744 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7745 }
7746
7747 TLB.push<CountAttributedTypeLoc>(Result);
7748 return Result;
7749}
7750
7751template <typename Derived>
7754 // The BTFTagAttributedType is available for C only.
7755 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7756}
7757
7758template <typename Derived>
7761
7762 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7763
7764 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7765 if (WrappedTy.isNull())
7766 return QualType();
7767
7768 QualType ContainedTy = QualType();
7769 QualType OldContainedTy = oldType->getContainedType();
7770 TypeSourceInfo *ContainedTSI = nullptr;
7771 if (!OldContainedTy.isNull()) {
7772 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7773 if (!oldContainedTSI)
7774 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7775 OldContainedTy, SourceLocation());
7776 ContainedTSI = getDerived().TransformType(oldContainedTSI);
7777 if (!ContainedTSI)
7778 return QualType();
7779 ContainedTy = ContainedTSI->getType();
7780 }
7781
7782 QualType Result = TL.getType();
7783 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7784 ContainedTy != oldType->getContainedType()) {
7786 WrappedTy, ContainedTy, oldType->getAttrs());
7787 }
7788
7791 NewTL.setSourceRange(TL.getLocalSourceRange());
7792 NewTL.setContainedTypeSourceInfo(ContainedTSI);
7793 return Result;
7794}
7795
7796template <typename Derived>
7799 // No transformations needed.
7800 return TL.getType();
7801}
7802
7803template<typename Derived>
7806 ParenTypeLoc TL) {
7807 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7808 if (Inner.isNull())
7809 return QualType();
7810
7811 QualType Result = TL.getType();
7812 if (getDerived().AlwaysRebuild() ||
7813 Inner != TL.getInnerLoc().getType()) {
7814 Result = getDerived().RebuildParenType(Inner);
7815 if (Result.isNull())
7816 return QualType();
7817 }
7818
7819 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7820 NewTL.setLParenLoc(TL.getLParenLoc());
7821 NewTL.setRParenLoc(TL.getRParenLoc());
7822 return Result;
7823}
7824
7825template <typename Derived>
7829 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7830 if (Inner.isNull())
7831 return QualType();
7832
7833 QualType Result = TL.getType();
7834 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7835 Result =
7836 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7837 if (Result.isNull())
7838 return QualType();
7839 }
7840
7842 NewTL.setExpansionLoc(TL.getExpansionLoc());
7843 return Result;
7844}
7845
7846template<typename Derived>
7847QualType TreeTransform<Derived>::TransformDependentNameType(
7849 return TransformDependentNameType(TLB, TL, false);
7850}
7851
7852template <typename Derived>
7853QualType TreeTransform<Derived>::TransformDependentNameType(
7854 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext,
7855 QualType ObjectType, NamedDecl *UnqualLookup) {
7856 const DependentNameType *T = TL.getTypePtr();
7857
7858 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7859 if (QualifierLoc) {
7860 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
7861 QualifierLoc, ObjectType, UnqualLookup);
7862 if (!QualifierLoc)
7863 return QualType();
7864 } else {
7865 assert((ObjectType.isNull() && !UnqualLookup) &&
7866 "must be transformed by TransformNestedNameSpecifierLoc");
7867 }
7868
7870 = getDerived().RebuildDependentNameType(T->getKeyword(),
7871 TL.getElaboratedKeywordLoc(),
7872 QualifierLoc,
7873 T->getIdentifier(),
7874 TL.getNameLoc(),
7875 DeducedTSTContext);
7876 if (Result.isNull())
7877 return QualType();
7878
7879 if (isa<TagType>(Result)) {
7880 auto NewTL = TLB.push<TagTypeLoc>(Result);
7881 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7882 NewTL.setQualifierLoc(QualifierLoc);
7883 NewTL.setNameLoc(TL.getNameLoc());
7885 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7886 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7887 NewTL.setTemplateNameLoc(TL.getNameLoc());
7888 NewTL.setQualifierLoc(QualifierLoc);
7889 } else if (isa<TypedefType>(Result)) {
7890 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7891 QualifierLoc, TL.getNameLoc());
7892 } else if (isa<UnresolvedUsingType>(Result)) {
7893 auto NewTL = TLB.push<UnresolvedUsingTypeLoc>(Result);
7894 NewTL.set(TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getNameLoc());
7895 } else {
7896 auto NewTL = TLB.push<DependentNameTypeLoc>(Result);
7897 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7898 NewTL.setQualifierLoc(QualifierLoc);
7899 NewTL.setNameLoc(TL.getNameLoc());
7900 }
7901 return Result;
7902}
7903
7904template<typename Derived>
7907 QualType Pattern
7908 = getDerived().TransformType(TLB, TL.getPatternLoc());
7909 if (Pattern.isNull())
7910 return QualType();
7911
7912 QualType Result = TL.getType();
7913 if (getDerived().AlwaysRebuild() ||
7914 Pattern != TL.getPatternLoc().getType()) {
7915 Result = getDerived().RebuildPackExpansionType(Pattern,
7916 TL.getPatternLoc().getSourceRange(),
7917 TL.getEllipsisLoc(),
7918 TL.getTypePtr()->getNumExpansions());
7919 if (Result.isNull())
7920 return QualType();
7921 }
7922
7924 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7925 return Result;
7926}
7927
7928template<typename Derived>
7932 // ObjCInterfaceType is never dependent.
7933 TLB.pushFullCopy(TL);
7934 return TL.getType();
7935}
7936
7937template<typename Derived>
7941 const ObjCTypeParamType *T = TL.getTypePtr();
7942 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7943 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7944 if (!OTP)
7945 return QualType();
7946
7947 QualType Result = TL.getType();
7948 if (getDerived().AlwaysRebuild() ||
7949 OTP != T->getDecl()) {
7950 Result = getDerived().RebuildObjCTypeParamType(
7951 OTP, TL.getProtocolLAngleLoc(),
7952 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7953 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7954 if (Result.isNull())
7955 return QualType();
7956 }
7957
7959 if (TL.getNumProtocols()) {
7960 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7961 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7962 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7963 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7964 }
7965 return Result;
7966}
7967
7968template<typename Derived>
7971 ObjCObjectTypeLoc TL) {
7972 // Transform base type.
7973 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
7974 if (BaseType.isNull())
7975 return QualType();
7976
7977 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
7978
7979 // Transform type arguments.
7980 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
7981 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
7982 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
7983 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
7984 QualType TypeArg = TypeArgInfo->getType();
7985 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
7986 AnyChanged = true;
7987
7988 // We have a pack expansion. Instantiate it.
7989 const auto *PackExpansion = PackExpansionLoc.getType()
7990 ->castAs<PackExpansionType>();
7992 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
7993 Unexpanded);
7994 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7995
7996 // Determine whether the set of unexpanded parameter packs can
7997 // and should be expanded.
7998 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
7999 bool Expand = false;
8000 bool RetainExpansion = false;
8001 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
8002 if (getDerived().TryExpandParameterPacks(
8003 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
8004 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
8005 RetainExpansion, NumExpansions))
8006 return QualType();
8007
8008 if (!Expand) {
8009 // We can't expand this pack expansion into separate arguments yet;
8010 // just substitute into the pattern and create a new pack expansion
8011 // type.
8012 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
8013
8014 TypeLocBuilder TypeArgBuilder;
8015 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8016 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
8017 PatternLoc);
8018 if (NewPatternType.isNull())
8019 return QualType();
8020
8021 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
8022 NewPatternType, NumExpansions);
8023 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
8024 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
8025 NewTypeArgInfos.push_back(
8026 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
8027 continue;
8028 }
8029
8030 // Substitute into the pack expansion pattern for each slice of the
8031 // pack.
8032 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
8033 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
8034
8035 TypeLocBuilder TypeArgBuilder;
8036 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8037
8038 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
8039 PatternLoc);
8040 if (NewTypeArg.isNull())
8041 return QualType();
8042
8043 NewTypeArgInfos.push_back(
8044 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8045 }
8046
8047 continue;
8048 }
8049
8050 TypeLocBuilder TypeArgBuilder;
8051 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
8052 QualType NewTypeArg =
8053 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
8054 if (NewTypeArg.isNull())
8055 return QualType();
8056
8057 // If nothing changed, just keep the old TypeSourceInfo.
8058 if (NewTypeArg == TypeArg) {
8059 NewTypeArgInfos.push_back(TypeArgInfo);
8060 continue;
8061 }
8062
8063 NewTypeArgInfos.push_back(
8064 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8065 AnyChanged = true;
8066 }
8067
8068 QualType Result = TL.getType();
8069 if (getDerived().AlwaysRebuild() || AnyChanged) {
8070 // Rebuild the type.
8071 Result = getDerived().RebuildObjCObjectType(
8072 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
8073 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
8074 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8075 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8076
8077 if (Result.isNull())
8078 return QualType();
8079 }
8080
8081 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
8082 NewT.setHasBaseTypeAsWritten(true);
8083 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
8084 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
8085 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
8086 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
8087 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8088 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8089 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
8090 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8091 return Result;
8092}
8093
8094template<typename Derived>
8098 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8099 if (PointeeType.isNull())
8100 return QualType();
8101
8102 QualType Result = TL.getType();
8103 if (getDerived().AlwaysRebuild() ||
8104 PointeeType != TL.getPointeeLoc().getType()) {
8105 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8106 TL.getStarLoc());
8107 if (Result.isNull())
8108 return QualType();
8109 }
8110
8112 NewT.setStarLoc(TL.getStarLoc());
8113 return Result;
8114}
8115
8116//===----------------------------------------------------------------------===//
8117// Statement transformation
8118//===----------------------------------------------------------------------===//
8119template<typename Derived>
8122 return S;
8123}
8124
8125template<typename Derived>
8128 return getDerived().TransformCompoundStmt(S, false);
8129}
8130
8131template<typename Derived>
8134 bool IsStmtExpr) {
8135 Sema::CompoundScopeRAII CompoundScope(getSema());
8136 Sema::FPFeaturesStateRAII FPSave(getSema());
8137 if (S->hasStoredFPFeatures())
8138 getSema().resetFPOptions(
8139 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8140
8141 bool SubStmtInvalid = false;
8142 bool SubStmtChanged = false;
8143 SmallVector<Stmt*, 8> Statements;
8144 for (auto *B : S->body()) {
8145 StmtResult Result = getDerived().TransformStmt(
8146 B, IsStmtExpr && B == S->body_back() ? StmtDiscardKind::StmtExprResult
8147 : StmtDiscardKind::Discarded);
8148
8149 if (Result.isInvalid()) {
8150 // Immediately fail if this was a DeclStmt, since it's very
8151 // likely that this will cause problems for future statements.
8152 if (isa<DeclStmt>(B))
8153 return StmtError();
8154
8155 // Otherwise, just keep processing substatements and fail later.
8156 SubStmtInvalid = true;
8157 continue;
8158 }
8159
8160 SubStmtChanged = SubStmtChanged || Result.get() != B;
8161 Statements.push_back(Result.getAs<Stmt>());
8162 }
8163
8164 if (SubStmtInvalid)
8165 return StmtError();
8166
8167 if (!getDerived().AlwaysRebuild() &&
8168 !SubStmtChanged)
8169 return S;
8170
8171 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8172 Statements,
8173 S->getRBracLoc(),
8174 IsStmtExpr);
8175}
8176
8177template<typename Derived>
8180 ExprResult LHS, RHS;
8181 {
8184
8185 // Transform the left-hand case value.
8186 LHS = getDerived().TransformExpr(S->getLHS());
8187 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8188 if (LHS.isInvalid())
8189 return StmtError();
8190
8191 // Transform the right-hand case value (for the GNU case-range extension).
8192 RHS = getDerived().TransformExpr(S->getRHS());
8193 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8194 if (RHS.isInvalid())
8195 return StmtError();
8196 }
8197
8198 // Build the case statement.
8199 // Case statements are always rebuilt so that they will attached to their
8200 // transformed switch statement.
8201 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8202 LHS.get(),
8203 S->getEllipsisLoc(),
8204 RHS.get(),
8205 S->getColonLoc());
8206 if (Case.isInvalid())
8207 return StmtError();
8208
8209 // Transform the statement following the case
8210 StmtResult SubStmt =
8211 getDerived().TransformStmt(S->getSubStmt());
8212 if (SubStmt.isInvalid())
8213 return StmtError();
8214
8215 // Attach the body to the case statement
8216 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8217}
8218
8219template <typename Derived>
8221 // Transform the statement following the default case
8222 StmtResult SubStmt =
8223 getDerived().TransformStmt(S->getSubStmt());
8224 if (SubStmt.isInvalid())
8225 return StmtError();
8226
8227 // Default statements are always rebuilt
8228 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8229 SubStmt.get());
8230}
8231
8232template<typename Derived>
8235 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8236 if (SubStmt.isInvalid())
8237 return StmtError();
8238
8239 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8240 S->getDecl());
8241 if (!LD)
8242 return StmtError();
8243
8244 // If we're transforming "in-place" (we're not creating new local
8245 // declarations), assume we're replacing the old label statement
8246 // and clear out the reference to it.
8247 if (LD == S->getDecl())
8248 S->getDecl()->setStmt(nullptr);
8249
8250 // FIXME: Pass the real colon location in.
8251 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8253 SubStmt.get());
8254}
8255
8256template <typename Derived>
8258 if (!R)
8259 return R;
8260
8261 switch (R->getKind()) {
8262// Transform attributes by calling TransformXXXAttr.
8263#define ATTR(X) \
8264 case attr::X: \
8265 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8266#include "clang/Basic/AttrList.inc"
8267 }
8268 return R;
8269}
8270
8271template <typename Derived>
8273 const Stmt *InstS,
8274 const Attr *R) {
8275 if (!R)
8276 return R;
8277
8278 switch (R->getKind()) {
8279// Transform attributes by calling TransformStmtXXXAttr.
8280#define ATTR(X) \
8281 case attr::X: \
8282 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8283#include "clang/Basic/AttrList.inc"
8284 }
8285 return TransformAttr(R);
8286}
8287
8288template <typename Derived>
8291 StmtDiscardKind SDK) {
8292 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8293 if (SubStmt.isInvalid())
8294 return StmtError();
8295
8296 bool AttrsChanged = false;
8298
8299 // Visit attributes and keep track if any are transformed.
8300 for (const auto *I : S->getAttrs()) {
8301 const Attr *R =
8302 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8303 AttrsChanged |= (I != R);
8304 if (R)
8305 Attrs.push_back(R);
8306 }
8307
8308 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8309 return S;
8310
8311 // If transforming the attributes failed for all of the attributes in the
8312 // statement, don't make an AttributedStmt without attributes.
8313 if (Attrs.empty())
8314 return SubStmt;
8315
8316 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8317 SubStmt.get());
8318}
8319
8320template<typename Derived>
8323 // Transform the initialization statement
8324 StmtResult Init = getDerived().TransformStmt(S->getInit());
8325 if (Init.isInvalid())
8326 return StmtError();
8327
8329 if (!S->isConsteval()) {
8330 // Transform the condition
8331 Cond = getDerived().TransformCondition(
8332 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8333 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8335 if (Cond.isInvalid())
8336 return StmtError();
8337 }
8338
8339 // If this is a constexpr if, determine which arm we should instantiate.
8340 std::optional<bool> ConstexprConditionValue;
8341 if (S->isConstexpr())
8342 ConstexprConditionValue = Cond.getKnownValue();
8343
8344 // Transform the "then" branch.
8345 StmtResult Then;
8346 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8350 S->isNonNegatedConsteval());
8351
8352 Then = getDerived().TransformStmt(S->getThen());
8353 if (Then.isInvalid())
8354 return StmtError();
8355 } else {
8356 // Discarded branch is replaced with empty CompoundStmt so we can keep
8357 // proper source location for start and end of original branch, so
8358 // subsequent transformations like CoverageMapping work properly
8359 Then = new (getSema().Context)
8360 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8361 }
8362
8363 // Transform the "else" branch.
8364 StmtResult Else;
8365 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8369 S->isNegatedConsteval());
8370
8371 Else = getDerived().TransformStmt(S->getElse());
8372 if (Else.isInvalid())
8373 return StmtError();
8374 } else if (S->getElse() && ConstexprConditionValue &&
8375 *ConstexprConditionValue) {
8376 // Same thing here as with <then> branch, we are discarding it, we can't
8377 // replace it with NULL nor NullStmt as we need to keep for source location
8378 // range, for CoverageMapping
8379 Else = new (getSema().Context)
8380 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8381 }
8382
8383 if (!getDerived().AlwaysRebuild() &&
8384 Init.get() == S->getInit() &&
8385 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8386 Then.get() == S->getThen() &&
8387 Else.get() == S->getElse())
8388 return S;
8389
8390 return getDerived().RebuildIfStmt(
8391 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8392 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8393}
8394
8395template<typename Derived>
8398 // Transform the initialization statement
8399 StmtResult Init = getDerived().TransformStmt(S->getInit());
8400 if (Init.isInvalid())
8401 return StmtError();
8402
8403 // Transform the condition.
8404 Sema::ConditionResult Cond = getDerived().TransformCondition(
8405 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8407 if (Cond.isInvalid())
8408 return StmtError();
8409
8410 // Rebuild the switch statement.
8412 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8413 Init.get(), Cond, S->getRParenLoc());
8414 if (Switch.isInvalid())
8415 return StmtError();
8416
8417 // Transform the body of the switch statement.
8418 StmtResult Body = getDerived().TransformStmt(S->getBody());
8419 if (Body.isInvalid())
8420 return StmtError();
8421
8422 // Complete the switch statement.
8423 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8424 Body.get());
8425}
8426
8427template<typename Derived>
8430 // Transform the condition
8431 Sema::ConditionResult Cond = getDerived().TransformCondition(
8432 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8434 if (Cond.isInvalid())
8435 return StmtError();
8436
8437 // OpenACC Restricts a while-loop inside of certain construct/clause
8438 // combinations, so diagnose that here in OpenACC mode.
8440 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8441
8442 // Transform the body
8443 StmtResult Body = getDerived().TransformStmt(S->getBody());
8444 if (Body.isInvalid())
8445 return StmtError();
8446
8447 if (!getDerived().AlwaysRebuild() &&
8448 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8449 Body.get() == S->getBody())
8450 return Owned(S);
8451
8452 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8453 Cond, S->getRParenLoc(), Body.get());
8454}
8455
8456template<typename Derived>
8459 // OpenACC Restricts a do-loop inside of certain construct/clause
8460 // combinations, so diagnose that here in OpenACC mode.
8462 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8463
8464 // Transform the body
8465 StmtResult Body = getDerived().TransformStmt(S->getBody());
8466 if (Body.isInvalid())
8467 return StmtError();
8468
8469 // Transform the condition
8470 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8471 if (Cond.isInvalid())
8472 return StmtError();
8473
8474 if (!getDerived().AlwaysRebuild() &&
8475 Cond.get() == S->getCond() &&
8476 Body.get() == S->getBody())
8477 return S;
8478
8479 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8480 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8481 S->getRParenLoc());
8482}
8483
8484template<typename Derived>
8487 if (getSema().getLangOpts().OpenMP)
8488 getSema().OpenMP().startOpenMPLoop();
8489
8490 // Transform the initialization statement
8491 StmtResult Init = getDerived().TransformStmt(S->getInit());
8492 if (Init.isInvalid())
8493 return StmtError();
8494
8495 // In OpenMP loop region loop control variable must be captured and be
8496 // private. Perform analysis of first part (if any).
8497 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8498 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8499 Init.get());
8500
8501 // Transform the condition
8502 Sema::ConditionResult Cond = getDerived().TransformCondition(
8503 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8505 if (Cond.isInvalid())
8506 return StmtError();
8507
8508 // Transform the increment
8509 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8510 if (Inc.isInvalid())
8511 return StmtError();
8512
8513 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8514 if (S->getInc() && !FullInc.get())
8515 return StmtError();
8516
8517 // OpenACC Restricts a for-loop inside of certain construct/clause
8518 // combinations, so diagnose that here in OpenACC mode.
8520 SemaRef.OpenACC().ActOnForStmtBegin(
8521 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8522 Cond.get().second, S->getInc(), Inc.get());
8523
8524 // Transform the body
8525 StmtResult Body = getDerived().TransformStmt(S->getBody());
8526 if (Body.isInvalid())
8527 return StmtError();
8528
8529 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8530
8531 if (!getDerived().AlwaysRebuild() &&
8532 Init.get() == S->getInit() &&
8533 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8534 Inc.get() == S->getInc() &&
8535 Body.get() == S->getBody())
8536 return S;
8537
8538 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8539 Init.get(), Cond, FullInc,
8540 S->getRParenLoc(), Body.get());
8541}
8542
8543template<typename Derived>
8546 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8547 S->getLabel());
8548 if (!LD)
8549 return StmtError();
8550
8551 // Goto statements must always be rebuilt, to resolve the label.
8552 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8553 cast<LabelDecl>(LD));
8554}
8555
8556template<typename Derived>
8559 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8560 if (Target.isInvalid())
8561 return StmtError();
8562 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8563
8564 if (!getDerived().AlwaysRebuild() &&
8565 Target.get() == S->getTarget())
8566 return S;
8567
8568 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8569 Target.get());
8570}
8571
8572template<typename Derived>
8575 if (!S->hasLabelTarget())
8576 return S;
8577
8578 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8579 S->getLabelDecl());
8580 if (!LD)
8581 return StmtError();
8582
8583 return new (SemaRef.Context)
8584 ContinueStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8585}
8586
8587template<typename Derived>
8590 if (!S->hasLabelTarget())
8591 return S;
8592
8593 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8594 S->getLabelDecl());
8595 if (!LD)
8596 return StmtError();
8597
8598 return new (SemaRef.Context)
8599 BreakStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8600}
8601
8602template <typename Derived>
8604 StmtResult Result = getDerived().TransformStmt(S->getBody());
8605 if (!Result.isUsable())
8606 return StmtError();
8607 return DeferStmt::Create(getSema().Context, S->getDeferLoc(), Result.get());
8608}
8609
8610template<typename Derived>
8613 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8614 /*NotCopyInit*/false);
8615 if (Result.isInvalid())
8616 return StmtError();
8617
8618 // FIXME: We always rebuild the return statement because there is no way
8619 // to tell whether the return type of the function has changed.
8620 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8621}
8622
8623template<typename Derived>
8626 bool DeclChanged = false;
8628 LambdaScopeInfo *LSI = getSema().getCurLambda();
8629 for (auto *D : S->decls()) {
8630 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8631 if (!Transformed)
8632 return StmtError();
8633
8634 if (Transformed != D)
8635 DeclChanged = true;
8636
8637 if (LSI) {
8638 if (auto *TD = dyn_cast<TypeDecl>(Transformed)) {
8639 if (auto *TN = dyn_cast<TypedefNameDecl>(TD)) {
8640 LSI->ContainsUnexpandedParameterPack |=
8641 TN->getUnderlyingType()->containsUnexpandedParameterPack();
8642 } else {
8643 LSI->ContainsUnexpandedParameterPack |=
8644 getSema()
8645 .getASTContext()
8646 .getTypeDeclType(TD)
8647 ->containsUnexpandedParameterPack();
8648 }
8649 }
8650 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8651 LSI->ContainsUnexpandedParameterPack |=
8652 VD->getType()->containsUnexpandedParameterPack();
8653 }
8654
8655 Decls.push_back(Transformed);
8656 }
8657
8658 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8659 return S;
8660
8661 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8662}
8663
8664template<typename Derived>
8667
8668 SmallVector<Expr*, 8> Constraints;
8671
8672 SmallVector<Expr*, 8> Clobbers;
8673
8674 bool ExprsChanged = false;
8675
8676 auto RebuildString = [&](Expr *E) {
8677 ExprResult Result = getDerived().TransformExpr(E);
8678 if (!Result.isUsable())
8679 return Result;
8680 if (Result.get() != E) {
8681 ExprsChanged = true;
8682 Result = SemaRef.ActOnGCCAsmStmtString(Result.get(), /*ForLabel=*/false);
8683 }
8684 return Result;
8685 };
8686
8687 // Go through the outputs.
8688 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8689 Names.push_back(S->getOutputIdentifier(I));
8690
8691 ExprResult Result = RebuildString(S->getOutputConstraintExpr(I));
8692 if (Result.isInvalid())
8693 return StmtError();
8694
8695 Constraints.push_back(Result.get());
8696
8697 // Transform the output expr.
8698 Expr *OutputExpr = S->getOutputExpr(I);
8699 Result = getDerived().TransformExpr(OutputExpr);
8700 if (Result.isInvalid())
8701 return StmtError();
8702
8703 ExprsChanged |= Result.get() != OutputExpr;
8704
8705 Exprs.push_back(Result.get());
8706 }
8707
8708 // Go through the inputs.
8709 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8710 Names.push_back(S->getInputIdentifier(I));
8711
8712 ExprResult Result = RebuildString(S->getInputConstraintExpr(I));
8713 if (Result.isInvalid())
8714 return StmtError();
8715
8716 Constraints.push_back(Result.get());
8717
8718 // Transform the input expr.
8719 Expr *InputExpr = S->getInputExpr(I);
8720 Result = getDerived().TransformExpr(InputExpr);
8721 if (Result.isInvalid())
8722 return StmtError();
8723
8724 ExprsChanged |= Result.get() != InputExpr;
8725
8726 Exprs.push_back(Result.get());
8727 }
8728
8729 // Go through the Labels.
8730 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8731 Names.push_back(S->getLabelIdentifier(I));
8732
8733 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8734 if (Result.isInvalid())
8735 return StmtError();
8736 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8737 Exprs.push_back(Result.get());
8738 }
8739
8740 // Go through the clobbers.
8741 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) {
8742 ExprResult Result = RebuildString(S->getClobberExpr(I));
8743 if (Result.isInvalid())
8744 return StmtError();
8745 Clobbers.push_back(Result.get());
8746 }
8747
8748 ExprResult AsmString = RebuildString(S->getAsmStringExpr());
8749 if (AsmString.isInvalid())
8750 return StmtError();
8751
8752 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8753 return S;
8754
8755 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8756 S->isVolatile(), S->getNumOutputs(),
8757 S->getNumInputs(), Names.data(),
8758 Constraints, Exprs, AsmString.get(),
8759 Clobbers, S->getNumLabels(),
8760 S->getRParenLoc());
8761}
8762
8763template<typename Derived>
8766 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8767
8768 bool HadError = false, HadChange = false;
8769
8770 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8771 SmallVector<Expr*, 8> TransformedExprs;
8772 TransformedExprs.reserve(SrcExprs.size());
8773 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8774 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8775 if (!Result.isUsable()) {
8776 HadError = true;
8777 } else {
8778 HadChange |= (Result.get() != SrcExprs[i]);
8779 TransformedExprs.push_back(Result.get());
8780 }
8781 }
8782
8783 if (HadError) return StmtError();
8784 if (!HadChange && !getDerived().AlwaysRebuild())
8785 return Owned(S);
8786
8787 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8788 AsmToks, S->getAsmString(),
8789 S->getNumOutputs(), S->getNumInputs(),
8790 S->getAllConstraints(), S->getClobbers(),
8791 TransformedExprs, S->getEndLoc());
8792}
8793
8794// C++ Coroutines
8795template<typename Derived>
8798 auto *ScopeInfo = SemaRef.getCurFunction();
8799 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8800 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8801 ScopeInfo->NeedsCoroutineSuspends &&
8802 ScopeInfo->CoroutineSuspends.first == nullptr &&
8803 ScopeInfo->CoroutineSuspends.second == nullptr &&
8804 "expected clean scope info");
8805
8806 // Set that we have (possibly-invalid) suspend points before we do anything
8807 // that may fail.
8808 ScopeInfo->setNeedsCoroutineSuspends(false);
8809
8810 // We re-build the coroutine promise object (and the coroutine parameters its
8811 // type and constructor depend on) based on the types used in our current
8812 // function. We must do so, and set it on the current FunctionScopeInfo,
8813 // before attempting to transform the other parts of the coroutine body
8814 // statement, such as the implicit suspend statements (because those
8815 // statements reference the FunctionScopeInfo::CoroutinePromise).
8816 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8817 return StmtError();
8818 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8819 if (!Promise)
8820 return StmtError();
8821 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8822 ScopeInfo->CoroutinePromise = Promise;
8823
8824 // Transform the implicit coroutine statements constructed using dependent
8825 // types during the previous parse: initial and final suspensions, the return
8826 // object, and others. We also transform the coroutine function's body.
8827 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8828 if (InitSuspend.isInvalid())
8829 return StmtError();
8830 StmtResult FinalSuspend =
8831 getDerived().TransformStmt(S->getFinalSuspendStmt());
8832 if (FinalSuspend.isInvalid() ||
8833 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8834 return StmtError();
8835 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8836 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8837
8838 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8839 if (BodyRes.isInvalid())
8840 return StmtError();
8841
8842 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8843 if (Builder.isInvalid())
8844 return StmtError();
8845
8846 Expr *ReturnObject = S->getReturnValueInit();
8847 assert(ReturnObject && "the return object is expected to be valid");
8848 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8849 /*NoCopyInit*/ false);
8850 if (Res.isInvalid())
8851 return StmtError();
8852 Builder.ReturnValue = Res.get();
8853
8854 // If during the previous parse the coroutine still had a dependent promise
8855 // statement, we may need to build some implicit coroutine statements
8856 // (such as exception and fallthrough handlers) for the first time.
8857 if (S->hasDependentPromiseType()) {
8858 // We can only build these statements, however, if the current promise type
8859 // is not dependent.
8860 if (!Promise->getType()->isDependentType()) {
8861 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8862 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8863 "these nodes should not have been built yet");
8864 if (!Builder.buildDependentStatements())
8865 return StmtError();
8866 }
8867 } else {
8868 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8869 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8870 if (Res.isInvalid())
8871 return StmtError();
8872 Builder.OnFallthrough = Res.get();
8873 }
8874
8875 if (auto *OnException = S->getExceptionHandler()) {
8876 StmtResult Res = getDerived().TransformStmt(OnException);
8877 if (Res.isInvalid())
8878 return StmtError();
8879 Builder.OnException = Res.get();
8880 }
8881
8882 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8883 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8884 if (Res.isInvalid())
8885 return StmtError();
8886 Builder.ReturnStmtOnAllocFailure = Res.get();
8887 }
8888
8889 // Transform any additional statements we may have already built
8890 assert(S->getAllocate() && S->getDeallocate() &&
8891 "allocation and deallocation calls must already be built");
8892 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8893 if (AllocRes.isInvalid())
8894 return StmtError();
8895 Builder.Allocate = AllocRes.get();
8896
8897 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8898 if (DeallocRes.isInvalid())
8899 return StmtError();
8900 Builder.Deallocate = DeallocRes.get();
8901
8902 if (auto *ResultDecl = S->getResultDecl()) {
8903 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8904 if (Res.isInvalid())
8905 return StmtError();
8906 Builder.ResultDecl = Res.get();
8907 }
8908
8909 if (auto *ReturnStmt = S->getReturnStmt()) {
8910 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8911 if (Res.isInvalid())
8912 return StmtError();
8913 Builder.ReturnStmt = Res.get();
8914 }
8915 }
8916
8917 return getDerived().RebuildCoroutineBodyStmt(Builder);
8918}
8919
8920template<typename Derived>
8923 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8924 /*NotCopyInit*/false);
8925 if (Result.isInvalid())
8926 return StmtError();
8927
8928 // Always rebuild; we don't know if this needs to be injected into a new
8929 // context or if the promise type has changed.
8930 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8931 S->isImplicit());
8932}
8933
8934template <typename Derived>
8936 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8937 /*NotCopyInit*/ false);
8938 if (Operand.isInvalid())
8939 return ExprError();
8940
8941 // Rebuild the common-expr from the operand rather than transforming it
8942 // separately.
8943
8944 // FIXME: getCurScope() should not be used during template instantiation.
8945 // We should pick up the set of unqualified lookup results for operator
8946 // co_await during the initial parse.
8947 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8948 getSema().getCurScope(), E->getKeywordLoc());
8949
8950 // Always rebuild; we don't know if this needs to be injected into a new
8951 // context or if the promise type has changed.
8952 return getDerived().RebuildCoawaitExpr(
8953 E->getKeywordLoc(), Operand.get(),
8954 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8955}
8956
8957template <typename Derived>
8960 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8961 /*NotCopyInit*/ false);
8962 if (OperandResult.isInvalid())
8963 return ExprError();
8964
8965 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8966 E->getOperatorCoawaitLookup());
8967
8968 if (LookupResult.isInvalid())
8969 return ExprError();
8970
8971 // Always rebuild; we don't know if this needs to be injected into a new
8972 // context or if the promise type has changed.
8973 return getDerived().RebuildDependentCoawaitExpr(
8974 E->getKeywordLoc(), OperandResult.get(),
8976}
8977
8978template<typename Derived>
8981 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
8982 /*NotCopyInit*/false);
8983 if (Result.isInvalid())
8984 return ExprError();
8985
8986 // Always rebuild; we don't know if this needs to be injected into a new
8987 // context or if the promise type has changed.
8988 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
8989}
8990
8991// Objective-C Statements.
8992
8993template<typename Derived>
8996 // Transform the body of the @try.
8997 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
8998 if (TryBody.isInvalid())
8999 return StmtError();
9000
9001 // Transform the @catch statements (if present).
9002 bool AnyCatchChanged = false;
9003 SmallVector<Stmt*, 8> CatchStmts;
9004 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
9005 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
9006 if (Catch.isInvalid())
9007 return StmtError();
9008 if (Catch.get() != S->getCatchStmt(I))
9009 AnyCatchChanged = true;
9010 CatchStmts.push_back(Catch.get());
9011 }
9012
9013 // Transform the @finally statement (if present).
9014 StmtResult Finally;
9015 if (S->getFinallyStmt()) {
9016 Finally = getDerived().TransformStmt(S->getFinallyStmt());
9017 if (Finally.isInvalid())
9018 return StmtError();
9019 }
9020
9021 // If nothing changed, just retain this statement.
9022 if (!getDerived().AlwaysRebuild() &&
9023 TryBody.get() == S->getTryBody() &&
9024 !AnyCatchChanged &&
9025 Finally.get() == S->getFinallyStmt())
9026 return S;
9027
9028 // Build a new statement.
9029 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
9030 CatchStmts, Finally.get());
9031}
9032
9033template<typename Derived>
9036 // Transform the @catch parameter, if there is one.
9037 VarDecl *Var = nullptr;
9038 if (VarDecl *FromVar = S->getCatchParamDecl()) {
9039 TypeSourceInfo *TSInfo = nullptr;
9040 if (FromVar->getTypeSourceInfo()) {
9041 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
9042 if (!TSInfo)
9043 return StmtError();
9044 }
9045
9046 QualType T;
9047 if (TSInfo)
9048 T = TSInfo->getType();
9049 else {
9050 T = getDerived().TransformType(FromVar->getType());
9051 if (T.isNull())
9052 return StmtError();
9053 }
9054
9055 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
9056 if (!Var)
9057 return StmtError();
9058 }
9059
9060 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
9061 if (Body.isInvalid())
9062 return StmtError();
9063
9064 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
9065 S->getRParenLoc(),
9066 Var, Body.get());
9067}
9068
9069template<typename Derived>
9072 // Transform the body.
9073 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
9074 if (Body.isInvalid())
9075 return StmtError();
9076
9077 // If nothing changed, just retain this statement.
9078 if (!getDerived().AlwaysRebuild() &&
9079 Body.get() == S->getFinallyBody())
9080 return S;
9081
9082 // Build a new statement.
9083 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
9084 Body.get());
9085}
9086
9087template<typename Derived>
9091 if (S->getThrowExpr()) {
9092 Operand = getDerived().TransformExpr(S->getThrowExpr());
9093 if (Operand.isInvalid())
9094 return StmtError();
9095 }
9096
9097 if (!getDerived().AlwaysRebuild() &&
9098 Operand.get() == S->getThrowExpr())
9099 return S;
9100
9101 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
9102}
9103
9104template<typename Derived>
9108 // Transform the object we are locking.
9109 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
9110 if (Object.isInvalid())
9111 return StmtError();
9112 Object =
9113 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
9114 Object.get());
9115 if (Object.isInvalid())
9116 return StmtError();
9117
9118 // Transform the body.
9119 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
9120 if (Body.isInvalid())
9121 return StmtError();
9122
9123 // If nothing change, just retain the current statement.
9124 if (!getDerived().AlwaysRebuild() &&
9125 Object.get() == S->getSynchExpr() &&
9126 Body.get() == S->getSynchBody())
9127 return S;
9128
9129 // Build a new statement.
9130 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
9131 Object.get(), Body.get());
9132}
9133
9134template<typename Derived>
9138 // Transform the body.
9139 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
9140 if (Body.isInvalid())
9141 return StmtError();
9142
9143 // If nothing changed, just retain this statement.
9144 if (!getDerived().AlwaysRebuild() &&
9145 Body.get() == S->getSubStmt())
9146 return S;
9147
9148 // Build a new statement.
9149 return getDerived().RebuildObjCAutoreleasePoolStmt(
9150 S->getAtLoc(), Body.get());
9151}
9152
9153template<typename Derived>
9157 // Transform the element statement.
9158 StmtResult Element = getDerived().TransformStmt(
9159 S->getElement(), StmtDiscardKind::NotDiscarded);
9160 if (Element.isInvalid())
9161 return StmtError();
9162
9163 // Transform the collection expression.
9164 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9165 if (Collection.isInvalid())
9166 return StmtError();
9167
9168 // Transform the body.
9169 StmtResult Body = getDerived().TransformStmt(S->getBody());
9170 if (Body.isInvalid())
9171 return StmtError();
9172
9173 // If nothing changed, just retain this statement.
9174 if (!getDerived().AlwaysRebuild() &&
9175 Element.get() == S->getElement() &&
9176 Collection.get() == S->getCollection() &&
9177 Body.get() == S->getBody())
9178 return S;
9179
9180 // Build a new statement.
9181 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9182 Element.get(),
9183 Collection.get(),
9184 S->getRParenLoc(),
9185 Body.get());
9186}
9187
9188template <typename Derived>
9190 // Transform the exception declaration, if any.
9191 VarDecl *Var = nullptr;
9192 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9193 TypeSourceInfo *T =
9194 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9195 if (!T)
9196 return StmtError();
9197
9198 Var = getDerived().RebuildExceptionDecl(
9199 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9200 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9201 if (!Var || Var->isInvalidDecl())
9202 return StmtError();
9203 }
9204
9205 // Transform the actual exception handler.
9206 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9207 if (Handler.isInvalid())
9208 return StmtError();
9209
9210 if (!getDerived().AlwaysRebuild() && !Var &&
9211 Handler.get() == S->getHandlerBlock())
9212 return S;
9213
9214 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9215}
9216
9217template <typename Derived>
9219 // Transform the try block itself.
9220 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9221 if (TryBlock.isInvalid())
9222 return StmtError();
9223
9224 // Transform the handlers.
9225 bool HandlerChanged = false;
9226 SmallVector<Stmt *, 8> Handlers;
9227 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9228 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9229 if (Handler.isInvalid())
9230 return StmtError();
9231
9232 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9233 Handlers.push_back(Handler.getAs<Stmt>());
9234 }
9235
9236 getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
9237
9238 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9239 !HandlerChanged)
9240 return S;
9241
9242 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9243 Handlers);
9244}
9245
9246template<typename Derived>
9249 EnterExpressionEvaluationContext ForRangeInitContext(
9251 /*LambdaContextDecl=*/nullptr,
9253 getSema().getLangOpts().CPlusPlus23);
9254
9255 // P2718R0 - Lifetime extension in range-based for loops.
9256 if (getSema().getLangOpts().CPlusPlus23) {
9257 auto &LastRecord = getSema().currentEvaluationContext();
9258 LastRecord.InLifetimeExtendingContext = true;
9259 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9260 }
9262 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9263 if (Init.isInvalid())
9264 return StmtError();
9265
9266 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9267 if (Range.isInvalid())
9268 return StmtError();
9269
9270 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9271 assert(getSema().getLangOpts().CPlusPlus23 ||
9272 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9273 auto ForRangeLifetimeExtendTemps =
9274 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9275
9276 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9277 if (Begin.isInvalid())
9278 return StmtError();
9279 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9280 if (End.isInvalid())
9281 return StmtError();
9282
9283 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9284 if (Cond.isInvalid())
9285 return StmtError();
9286 if (Cond.get())
9287 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9288 if (Cond.isInvalid())
9289 return StmtError();
9290 if (Cond.get())
9291 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9292
9293 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9294 if (Inc.isInvalid())
9295 return StmtError();
9296 if (Inc.get())
9297 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9298
9299 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9300 if (LoopVar.isInvalid())
9301 return StmtError();
9302
9303 StmtResult NewStmt = S;
9304 if (getDerived().AlwaysRebuild() ||
9305 Init.get() != S->getInit() ||
9306 Range.get() != S->getRangeStmt() ||
9307 Begin.get() != S->getBeginStmt() ||
9308 End.get() != S->getEndStmt() ||
9309 Cond.get() != S->getCond() ||
9310 Inc.get() != S->getInc() ||
9311 LoopVar.get() != S->getLoopVarStmt()) {
9312 NewStmt = getDerived().RebuildCXXForRangeStmt(
9313 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9314 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9315 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9316 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9317 // Might not have attached any initializer to the loop variable.
9318 getSema().ActOnInitializerError(
9319 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9320 return StmtError();
9321 }
9322 }
9323
9324 // OpenACC Restricts a while-loop inside of certain construct/clause
9325 // combinations, so diagnose that here in OpenACC mode.
9327 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9328
9329 StmtResult Body = getDerived().TransformStmt(S->getBody());
9330 if (Body.isInvalid())
9331 return StmtError();
9332
9333 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9334
9335 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9336 // it now so we have a new statement to attach the body to.
9337 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9338 NewStmt = getDerived().RebuildCXXForRangeStmt(
9339 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9340 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9341 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9342 if (NewStmt.isInvalid())
9343 return StmtError();
9344 }
9345
9346 if (NewStmt.get() == S)
9347 return S;
9348
9349 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9350}
9351
9352template<typename Derived>
9356 // Transform the nested-name-specifier, if any.
9357 NestedNameSpecifierLoc QualifierLoc;
9358 if (S->getQualifierLoc()) {
9359 QualifierLoc
9360 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9361 if (!QualifierLoc)
9362 return StmtError();
9363 }
9364
9365 // Transform the declaration name.
9366 DeclarationNameInfo NameInfo = S->getNameInfo();
9367 if (NameInfo.getName()) {
9368 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9369 if (!NameInfo.getName())
9370 return StmtError();
9371 }
9372
9373 // Check whether anything changed.
9374 if (!getDerived().AlwaysRebuild() &&
9375 QualifierLoc == S->getQualifierLoc() &&
9376 NameInfo.getName() == S->getNameInfo().getName())
9377 return S;
9378
9379 // Determine whether this name exists, if we can.
9380 CXXScopeSpec SS;
9381 SS.Adopt(QualifierLoc);
9382 bool Dependent = false;
9383 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9385 if (S->isIfExists())
9386 break;
9387
9388 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9389
9391 if (S->isIfNotExists())
9392 break;
9393
9394 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9395
9397 Dependent = true;
9398 break;
9399
9401 return StmtError();
9402 }
9403
9404 // We need to continue with the instantiation, so do so now.
9405 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9406 if (SubStmt.isInvalid())
9407 return StmtError();
9408
9409 // If we have resolved the name, just transform to the substatement.
9410 if (!Dependent)
9411 return SubStmt;
9412
9413 // The name is still dependent, so build a dependent expression again.
9414 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9415 S->isIfExists(),
9416 QualifierLoc,
9417 NameInfo,
9418 SubStmt.get());
9419}
9420
9421template<typename Derived>
9424 NestedNameSpecifierLoc QualifierLoc;
9425 if (E->getQualifierLoc()) {
9426 QualifierLoc
9427 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9428 if (!QualifierLoc)
9429 return ExprError();
9430 }
9431
9432 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9433 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9434 if (!PD)
9435 return ExprError();
9436
9437 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9438 if (Base.isInvalid())
9439 return ExprError();
9440
9441 return new (SemaRef.getASTContext())
9442 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9444 QualifierLoc, E->getMemberLoc());
9445}
9446
9447template <typename Derived>
9450 auto BaseRes = getDerived().TransformExpr(E->getBase());
9451 if (BaseRes.isInvalid())
9452 return ExprError();
9453 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9454 if (IdxRes.isInvalid())
9455 return ExprError();
9456
9457 if (!getDerived().AlwaysRebuild() &&
9458 BaseRes.get() == E->getBase() &&
9459 IdxRes.get() == E->getIdx())
9460 return E;
9461
9462 return getDerived().RebuildArraySubscriptExpr(
9463 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9464}
9465
9466template <typename Derived>
9468 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9469 if (TryBlock.isInvalid())
9470 return StmtError();
9471
9472 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9473 if (Handler.isInvalid())
9474 return StmtError();
9475
9476 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9477 Handler.get() == S->getHandler())
9478 return S;
9479
9480 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9481 TryBlock.get(), Handler.get());
9482}
9483
9484template <typename Derived>
9486 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9487 if (Block.isInvalid())
9488 return StmtError();
9489
9490 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9491}
9492
9493template <typename Derived>
9495 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9496 if (FilterExpr.isInvalid())
9497 return StmtError();
9498
9499 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9500 if (Block.isInvalid())
9501 return StmtError();
9502
9503 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9504 Block.get());
9505}
9506
9507template <typename Derived>
9509 if (isa<SEHFinallyStmt>(Handler))
9510 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9511 else
9512 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9513}
9514
9515template<typename Derived>
9518 return S;
9519}
9520
9521//===----------------------------------------------------------------------===//
9522// OpenMP directive transformation
9523//===----------------------------------------------------------------------===//
9524
9525template <typename Derived>
9526StmtResult
9527TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9528 // OMPCanonicalLoops are eliminated during transformation, since they will be
9529 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9530 // after transformation.
9531 return getDerived().TransformStmt(L->getLoopStmt());
9532}
9533
9534template <typename Derived>
9537
9538 // Transform the clauses
9540 ArrayRef<OMPClause *> Clauses = D->clauses();
9541 TClauses.reserve(Clauses.size());
9542 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9543 I != E; ++I) {
9544 if (*I) {
9545 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9546 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9547 getDerived().getSema().OpenMP().EndOpenMPClause();
9548 if (Clause)
9549 TClauses.push_back(Clause);
9550 } else {
9551 TClauses.push_back(nullptr);
9552 }
9553 }
9554 StmtResult AssociatedStmt;
9555 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9556 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9557 D->getDirectiveKind(),
9558 /*CurScope=*/nullptr);
9559 StmtResult Body;
9560 {
9561 Sema::CompoundScopeRAII CompoundScope(getSema());
9562 Stmt *CS;
9563 if (D->getDirectiveKind() == OMPD_atomic ||
9564 D->getDirectiveKind() == OMPD_critical ||
9565 D->getDirectiveKind() == OMPD_section ||
9566 D->getDirectiveKind() == OMPD_master)
9567 CS = D->getAssociatedStmt();
9568 else
9569 CS = D->getRawStmt();
9570 Body = getDerived().TransformStmt(CS);
9571 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9572 getSema().getLangOpts().OpenMPIRBuilder)
9573 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9574 }
9575 AssociatedStmt =
9576 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9577 if (AssociatedStmt.isInvalid()) {
9578 return StmtError();
9579 }
9580 }
9581 if (TClauses.size() != Clauses.size()) {
9582 return StmtError();
9583 }
9584
9585 // Transform directive name for 'omp critical' directive.
9586 DeclarationNameInfo DirName;
9587 if (D->getDirectiveKind() == OMPD_critical) {
9588 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9589 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9590 }
9591 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9592 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9593 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9594 } else if (D->getDirectiveKind() == OMPD_cancel) {
9595 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9596 }
9597
9598 return getDerived().RebuildOMPExecutableDirective(
9599 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9600 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
9601}
9602
9603/// This is mostly the same as above, but allows 'informational' class
9604/// directives when rebuilding the stmt. It still takes an
9605/// OMPExecutableDirective-type argument because we're reusing that as the
9606/// superclass for the 'assume' directive at present, instead of defining a
9607/// mostly-identical OMPInformationalDirective parent class.
9608template <typename Derived>
9611
9612 // Transform the clauses
9614 ArrayRef<OMPClause *> Clauses = D->clauses();
9615 TClauses.reserve(Clauses.size());
9616 for (OMPClause *C : Clauses) {
9617 if (C) {
9618 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
9619 OMPClause *Clause = getDerived().TransformOMPClause(C);
9620 getDerived().getSema().OpenMP().EndOpenMPClause();
9621 if (Clause)
9622 TClauses.push_back(Clause);
9623 } else {
9624 TClauses.push_back(nullptr);
9625 }
9626 }
9627 StmtResult AssociatedStmt;
9628 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9629 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9630 D->getDirectiveKind(),
9631 /*CurScope=*/nullptr);
9632 StmtResult Body;
9633 {
9634 Sema::CompoundScopeRAII CompoundScope(getSema());
9635 assert(D->getDirectiveKind() == OMPD_assume &&
9636 "Unexpected informational directive");
9637 Stmt *CS = D->getAssociatedStmt();
9638 Body = getDerived().TransformStmt(CS);
9639 }
9640 AssociatedStmt =
9641 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9642 if (AssociatedStmt.isInvalid())
9643 return StmtError();
9644 }
9645 if (TClauses.size() != Clauses.size())
9646 return StmtError();
9647
9648 DeclarationNameInfo DirName;
9649
9650 return getDerived().RebuildOMPInformationalDirective(
9651 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
9652 D->getBeginLoc(), D->getEndLoc());
9653}
9654
9655template <typename Derived>
9658 // TODO: Fix This
9659 unsigned OMPVersion = getDerived().getSema().getLangOpts().OpenMP;
9660 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9661 << getOpenMPDirectiveName(D->getDirectiveKind(), OMPVersion);
9662 return StmtError();
9663}
9664
9665template <typename Derived>
9666StmtResult
9667TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9668 DeclarationNameInfo DirName;
9669 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9670 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
9671 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9672 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9673 return Res;
9674}
9675
9676template <typename Derived>
9679 DeclarationNameInfo DirName;
9680 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9681 OMPD_simd, DirName, nullptr, D->getBeginLoc());
9682 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9683 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9684 return Res;
9685}
9686
9687template <typename Derived>
9690 DeclarationNameInfo DirName;
9691 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9692 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9693 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9694 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9695 return Res;
9696}
9697
9698template <typename Derived>
9701 DeclarationNameInfo DirName;
9702 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9703 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9704 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9705 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9706 return Res;
9707}
9708
9709template <typename Derived>
9712 DeclarationNameInfo DirName;
9713 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9714 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9715 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9716 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9717 return Res;
9718}
9719
9720template <typename Derived>
9723 DeclarationNameInfo DirName;
9724 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9725 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9726 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9727 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9728 return Res;
9729}
9730
9731template <typename Derived>
9733 OMPInterchangeDirective *D) {
9734 DeclarationNameInfo DirName;
9735 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9736 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9737 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9738 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9739 return Res;
9740}
9741
9742template <typename Derived>
9745 DeclarationNameInfo DirName;
9746 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9747 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9748 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9749 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9750 return Res;
9751}
9752
9753template <typename Derived>
9756 DeclarationNameInfo DirName;
9757 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9758 OMPD_for, DirName, nullptr, D->getBeginLoc());
9759 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9760 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9761 return Res;
9762}
9763
9764template <typename Derived>
9767 DeclarationNameInfo DirName;
9768 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9769 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
9770 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9771 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9772 return Res;
9773}
9774
9775template <typename Derived>
9778 DeclarationNameInfo DirName;
9779 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9780 OMPD_sections, DirName, nullptr, D->getBeginLoc());
9781 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9782 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9783 return Res;
9784}
9785
9786template <typename Derived>
9789 DeclarationNameInfo DirName;
9790 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9791 OMPD_section, DirName, nullptr, D->getBeginLoc());
9792 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9793 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9794 return Res;
9795}
9796
9797template <typename Derived>
9800 DeclarationNameInfo DirName;
9801 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9802 OMPD_scope, DirName, nullptr, D->getBeginLoc());
9803 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9804 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9805 return Res;
9806}
9807
9808template <typename Derived>
9811 DeclarationNameInfo DirName;
9812 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9813 OMPD_single, DirName, nullptr, D->getBeginLoc());
9814 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9815 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9816 return Res;
9817}
9818
9819template <typename Derived>
9822 DeclarationNameInfo DirName;
9823 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9824 OMPD_master, DirName, nullptr, D->getBeginLoc());
9825 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9826 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9827 return Res;
9828}
9829
9830template <typename Derived>
9833 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9834 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
9835 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9836 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9837 return Res;
9838}
9839
9840template <typename Derived>
9842 OMPParallelForDirective *D) {
9843 DeclarationNameInfo DirName;
9844 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9845 OMPD_parallel_for, DirName, nullptr, D->getBeginLoc());
9846 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9847 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9848 return Res;
9849}
9850
9851template <typename Derived>
9853 OMPParallelForSimdDirective *D) {
9854 DeclarationNameInfo DirName;
9855 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9856 OMPD_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9857 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9858 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9859 return Res;
9860}
9861
9862template <typename Derived>
9864 OMPParallelMasterDirective *D) {
9865 DeclarationNameInfo DirName;
9866 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9867 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
9868 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9869 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9870 return Res;
9871}
9872
9873template <typename Derived>
9875 OMPParallelMaskedDirective *D) {
9876 DeclarationNameInfo DirName;
9877 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9878 OMPD_parallel_masked, DirName, nullptr, D->getBeginLoc());
9879 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9880 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9881 return Res;
9882}
9883
9884template <typename Derived>
9886 OMPParallelSectionsDirective *D) {
9887 DeclarationNameInfo DirName;
9888 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9889 OMPD_parallel_sections, DirName, nullptr, D->getBeginLoc());
9890 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9891 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9892 return Res;
9893}
9894
9895template <typename Derived>
9898 DeclarationNameInfo DirName;
9899 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9900 OMPD_task, DirName, nullptr, D->getBeginLoc());
9901 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9902 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9903 return Res;
9904}
9905
9906template <typename Derived>
9908 OMPTaskyieldDirective *D) {
9909 DeclarationNameInfo DirName;
9910 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9911 OMPD_taskyield, DirName, nullptr, D->getBeginLoc());
9912 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9913 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9914 return Res;
9915}
9916
9917template <typename Derived>
9920 DeclarationNameInfo DirName;
9921 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9922 OMPD_barrier, DirName, nullptr, D->getBeginLoc());
9923 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9924 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9925 return Res;
9926}
9927
9928template <typename Derived>
9931 DeclarationNameInfo DirName;
9932 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9933 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
9934 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9935 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9936 return Res;
9937}
9938
9939template <typename Derived>
9942 DeclarationNameInfo DirName;
9943 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9944 OMPD_assume, DirName, nullptr, D->getBeginLoc());
9945 StmtResult Res = getDerived().TransformOMPInformationalDirective(D);
9946 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9947 return Res;
9948}
9949
9950template <typename Derived>
9953 DeclarationNameInfo DirName;
9954 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9955 OMPD_error, DirName, nullptr, D->getBeginLoc());
9956 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9957 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9958 return Res;
9959}
9960
9961template <typename Derived>
9963 OMPTaskgroupDirective *D) {
9964 DeclarationNameInfo DirName;
9965 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9966 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
9967 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9968 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9969 return Res;
9970}
9971
9972template <typename Derived>
9975 DeclarationNameInfo DirName;
9976 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9977 OMPD_flush, DirName, nullptr, D->getBeginLoc());
9978 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9979 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9980 return Res;
9981}
9982
9983template <typename Derived>
9986 DeclarationNameInfo DirName;
9987 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9988 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
9989 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9990 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9991 return Res;
9992}
9993
9994template <typename Derived>
9997 DeclarationNameInfo DirName;
9998 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9999 OMPD_scan, DirName, nullptr, D->getBeginLoc());
10000 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10001 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10002 return Res;
10003}
10004
10005template <typename Derived>
10008 DeclarationNameInfo DirName;
10009 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10010 OMPD_ordered, DirName, nullptr, D->getBeginLoc());
10011 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10012 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10013 return Res;
10014}
10015
10016template <typename Derived>
10019 DeclarationNameInfo DirName;
10020 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10021 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
10022 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10023 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10024 return Res;
10025}
10026
10027template <typename Derived>
10030 DeclarationNameInfo DirName;
10031 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10032 OMPD_target, DirName, nullptr, D->getBeginLoc());
10033 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10034 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10035 return Res;
10036}
10037
10038template <typename Derived>
10040 OMPTargetDataDirective *D) {
10041 DeclarationNameInfo DirName;
10042 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10043 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
10044 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10045 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10046 return Res;
10047}
10048
10049template <typename Derived>
10051 OMPTargetEnterDataDirective *D) {
10052 DeclarationNameInfo DirName;
10053 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10054 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
10055 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10056 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10057 return Res;
10058}
10059
10060template <typename Derived>
10062 OMPTargetExitDataDirective *D) {
10063 DeclarationNameInfo DirName;
10064 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10065 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
10066 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10067 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10068 return Res;
10069}
10070
10071template <typename Derived>
10073 OMPTargetParallelDirective *D) {
10074 DeclarationNameInfo DirName;
10075 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10076 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
10077 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10078 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10079 return Res;
10080}
10081
10082template <typename Derived>
10084 OMPTargetParallelForDirective *D) {
10085 DeclarationNameInfo DirName;
10086 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10087 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
10088 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10089 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10090 return Res;
10091}
10092
10093template <typename Derived>
10095 OMPTargetUpdateDirective *D) {
10096 DeclarationNameInfo DirName;
10097 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10098 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
10099 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10100 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10101 return Res;
10102}
10103
10104template <typename Derived>
10107 DeclarationNameInfo DirName;
10108 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10109 OMPD_teams, DirName, nullptr, D->getBeginLoc());
10110 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10111 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10112 return Res;
10113}
10114
10115template <typename Derived>
10117 OMPCancellationPointDirective *D) {
10118 DeclarationNameInfo DirName;
10119 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10120 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
10121 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10122 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10123 return Res;
10124}
10125
10126template <typename Derived>
10129 DeclarationNameInfo DirName;
10130 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10131 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
10132 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10133 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10134 return Res;
10135}
10136
10137template <typename Derived>
10140 DeclarationNameInfo DirName;
10141 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10142 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
10143 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10144 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10145 return Res;
10146}
10147
10148template <typename Derived>
10150 OMPTaskLoopSimdDirective *D) {
10151 DeclarationNameInfo DirName;
10152 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10153 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10154 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10155 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10156 return Res;
10157}
10158
10159template <typename Derived>
10161 OMPMasterTaskLoopDirective *D) {
10162 DeclarationNameInfo DirName;
10163 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10164 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
10165 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10166 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10167 return Res;
10168}
10169
10170template <typename Derived>
10172 OMPMaskedTaskLoopDirective *D) {
10173 DeclarationNameInfo DirName;
10174 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10175 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10176 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10177 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10178 return Res;
10179}
10180
10181template <typename Derived>
10183 OMPMasterTaskLoopSimdDirective *D) {
10184 DeclarationNameInfo DirName;
10185 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10186 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10187 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10188 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10189 return Res;
10190}
10191
10192template <typename Derived>
10194 OMPMaskedTaskLoopSimdDirective *D) {
10195 DeclarationNameInfo DirName;
10196 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10197 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10198 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10199 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10200 return Res;
10201}
10202
10203template <typename Derived>
10205 OMPParallelMasterTaskLoopDirective *D) {
10206 DeclarationNameInfo DirName;
10207 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10208 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10209 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10210 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10211 return Res;
10212}
10213
10214template <typename Derived>
10216 OMPParallelMaskedTaskLoopDirective *D) {
10217 DeclarationNameInfo DirName;
10218 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10219 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10220 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10221 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10222 return Res;
10223}
10224
10225template <typename Derived>
10228 OMPParallelMasterTaskLoopSimdDirective *D) {
10229 DeclarationNameInfo DirName;
10230 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10231 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10232 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10233 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10234 return Res;
10235}
10236
10237template <typename Derived>
10240 OMPParallelMaskedTaskLoopSimdDirective *D) {
10241 DeclarationNameInfo DirName;
10242 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10243 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10244 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10245 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10246 return Res;
10247}
10248
10249template <typename Derived>
10251 OMPDistributeDirective *D) {
10252 DeclarationNameInfo DirName;
10253 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10254 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10255 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10256 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10257 return Res;
10258}
10259
10260template <typename Derived>
10262 OMPDistributeParallelForDirective *D) {
10263 DeclarationNameInfo DirName;
10264 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10265 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10266 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10267 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10268 return Res;
10269}
10270
10271template <typename Derived>
10274 OMPDistributeParallelForSimdDirective *D) {
10275 DeclarationNameInfo DirName;
10276 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10277 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10278 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10279 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10280 return Res;
10281}
10282
10283template <typename Derived>
10285 OMPDistributeSimdDirective *D) {
10286 DeclarationNameInfo DirName;
10287 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10288 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
10289 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10290 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10291 return Res;
10292}
10293
10294template <typename Derived>
10296 OMPTargetParallelForSimdDirective *D) {
10297 DeclarationNameInfo DirName;
10298 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10299 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10300 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10301 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10302 return Res;
10303}
10304
10305template <typename Derived>
10307 OMPTargetSimdDirective *D) {
10308 DeclarationNameInfo DirName;
10309 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10310 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
10311 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10312 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10313 return Res;
10314}
10315
10316template <typename Derived>
10318 OMPTeamsDistributeDirective *D) {
10319 DeclarationNameInfo DirName;
10320 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10321 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10322 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10323 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10324 return Res;
10325}
10326
10327template <typename Derived>
10329 OMPTeamsDistributeSimdDirective *D) {
10330 DeclarationNameInfo DirName;
10331 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10332 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10333 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10334 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10335 return Res;
10336}
10337
10338template <typename Derived>
10340 OMPTeamsDistributeParallelForSimdDirective *D) {
10341 DeclarationNameInfo DirName;
10342 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10343 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10344 D->getBeginLoc());
10345 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10346 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10347 return Res;
10348}
10349
10350template <typename Derived>
10352 OMPTeamsDistributeParallelForDirective *D) {
10353 DeclarationNameInfo DirName;
10354 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10355 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10356 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10357 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10358 return Res;
10359}
10360
10361template <typename Derived>
10363 OMPTargetTeamsDirective *D) {
10364 DeclarationNameInfo DirName;
10365 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10366 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10367 auto Res = getDerived().TransformOMPExecutableDirective(D);
10368 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10369 return Res;
10370}
10371
10372template <typename Derived>
10374 OMPTargetTeamsDistributeDirective *D) {
10375 DeclarationNameInfo DirName;
10376 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10377 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10378 auto Res = getDerived().TransformOMPExecutableDirective(D);
10379 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10380 return Res;
10381}
10382
10383template <typename Derived>
10386 OMPTargetTeamsDistributeParallelForDirective *D) {
10387 DeclarationNameInfo DirName;
10388 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10389 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10390 D->getBeginLoc());
10391 auto Res = getDerived().TransformOMPExecutableDirective(D);
10392 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10393 return Res;
10394}
10395
10396template <typename Derived>
10399 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10400 DeclarationNameInfo DirName;
10401 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10402 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10403 D->getBeginLoc());
10404 auto Res = getDerived().TransformOMPExecutableDirective(D);
10405 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10406 return Res;
10407}
10408
10409template <typename Derived>
10412 OMPTargetTeamsDistributeSimdDirective *D) {
10413 DeclarationNameInfo DirName;
10414 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10415 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10416 auto Res = getDerived().TransformOMPExecutableDirective(D);
10417 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10418 return Res;
10419}
10420
10421template <typename Derived>
10424 DeclarationNameInfo DirName;
10425 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10426 OMPD_interop, DirName, nullptr, D->getBeginLoc());
10427 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10428 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10429 return Res;
10430}
10431
10432template <typename Derived>
10435 DeclarationNameInfo DirName;
10436 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10437 OMPD_dispatch, DirName, nullptr, D->getBeginLoc());
10438 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10439 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10440 return Res;
10441}
10442
10443template <typename Derived>
10446 DeclarationNameInfo DirName;
10447 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10448 OMPD_masked, DirName, nullptr, D->getBeginLoc());
10449 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10450 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10451 return Res;
10452}
10453
10454template <typename Derived>
10456 OMPGenericLoopDirective *D) {
10457 DeclarationNameInfo DirName;
10458 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10459 OMPD_loop, DirName, nullptr, D->getBeginLoc());
10460 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10461 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10462 return Res;
10463}
10464
10465template <typename Derived>
10467 OMPTeamsGenericLoopDirective *D) {
10468 DeclarationNameInfo DirName;
10469 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10470 OMPD_teams_loop, DirName, nullptr, D->getBeginLoc());
10471 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10472 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10473 return Res;
10474}
10475
10476template <typename Derived>
10478 OMPTargetTeamsGenericLoopDirective *D) {
10479 DeclarationNameInfo DirName;
10480 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10481 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
10482 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10483 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10484 return Res;
10485}
10486
10487template <typename Derived>
10489 OMPParallelGenericLoopDirective *D) {
10490 DeclarationNameInfo DirName;
10491 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10492 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
10493 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10494 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10495 return Res;
10496}
10497
10498template <typename Derived>
10501 OMPTargetParallelGenericLoopDirective *D) {
10502 DeclarationNameInfo DirName;
10503 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10504 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10505 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10506 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10507 return Res;
10508}
10509
10510//===----------------------------------------------------------------------===//
10511// OpenMP clause transformation
10512//===----------------------------------------------------------------------===//
10513template <typename Derived>
10515 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10516 if (Cond.isInvalid())
10517 return nullptr;
10518 return getDerived().RebuildOMPIfClause(
10519 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10520 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10521}
10522
10523template <typename Derived>
10525 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10526 if (Cond.isInvalid())
10527 return nullptr;
10528 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10529 C->getLParenLoc(), C->getEndLoc());
10530}
10531
10532template <typename Derived>
10533OMPClause *
10535 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
10536 if (NumThreads.isInvalid())
10537 return nullptr;
10538 return getDerived().RebuildOMPNumThreadsClause(
10539 C->getModifier(), NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(),
10540 C->getModifierLoc(), C->getEndLoc());
10541}
10542
10543template <typename Derived>
10544OMPClause *
10546 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10547 if (E.isInvalid())
10548 return nullptr;
10549 return getDerived().RebuildOMPSafelenClause(
10550 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10551}
10552
10553template <typename Derived>
10554OMPClause *
10556 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10557 if (E.isInvalid())
10558 return nullptr;
10559 return getDerived().RebuildOMPAllocatorClause(
10560 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10561}
10562
10563template <typename Derived>
10564OMPClause *
10566 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
10567 if (E.isInvalid())
10568 return nullptr;
10569 return getDerived().RebuildOMPSimdlenClause(
10570 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10571}
10572
10573template <typename Derived>
10575 SmallVector<Expr *, 4> TransformedSizes;
10576 TransformedSizes.reserve(C->getNumSizes());
10577 bool Changed = false;
10578 for (Expr *E : C->getSizesRefs()) {
10579 if (!E) {
10580 TransformedSizes.push_back(nullptr);
10581 continue;
10582 }
10583
10584 ExprResult T = getDerived().TransformExpr(E);
10585 if (T.isInvalid())
10586 return nullptr;
10587 if (E != T.get())
10588 Changed = true;
10589 TransformedSizes.push_back(T.get());
10590 }
10591
10592 if (!Changed && !getDerived().AlwaysRebuild())
10593 return C;
10594 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
10595 C->getLParenLoc(), C->getEndLoc());
10596}
10597
10598template <typename Derived>
10599OMPClause *
10601 SmallVector<Expr *> TransformedArgs;
10602 TransformedArgs.reserve(C->getNumLoops());
10603 bool Changed = false;
10604 for (Expr *E : C->getArgsRefs()) {
10605 if (!E) {
10606 TransformedArgs.push_back(nullptr);
10607 continue;
10608 }
10609
10610 ExprResult T = getDerived().TransformExpr(E);
10611 if (T.isInvalid())
10612 return nullptr;
10613 if (E != T.get())
10614 Changed = true;
10615 TransformedArgs.push_back(T.get());
10616 }
10617
10618 if (!Changed && !getDerived().AlwaysRebuild())
10619 return C;
10620 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
10621 C->getLParenLoc(), C->getEndLoc());
10622}
10623
10624template <typename Derived>
10626 if (!getDerived().AlwaysRebuild())
10627 return C;
10628 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10629}
10630
10631template <typename Derived>
10632OMPClause *
10634 ExprResult T = getDerived().TransformExpr(C->getFactor());
10635 if (T.isInvalid())
10636 return nullptr;
10637 Expr *Factor = T.get();
10638 bool Changed = Factor != C->getFactor();
10639
10640 if (!Changed && !getDerived().AlwaysRebuild())
10641 return C;
10642 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10643 C->getEndLoc());
10644}
10645
10646template <typename Derived>
10647OMPClause *
10649 ExprResult F = getDerived().TransformExpr(C->getFirst());
10650 if (F.isInvalid())
10651 return nullptr;
10652
10653 ExprResult Cn = getDerived().TransformExpr(C->getCount());
10654 if (Cn.isInvalid())
10655 return nullptr;
10656
10657 Expr *First = F.get();
10658 Expr *Count = Cn.get();
10659
10660 bool Changed = (First != C->getFirst()) || (Count != C->getCount());
10661
10662 // If no changes and AlwaysRebuild() is false, return the original clause
10663 if (!Changed && !getDerived().AlwaysRebuild())
10664 return C;
10665
10666 return RebuildOMPLoopRangeClause(First, Count, C->getBeginLoc(),
10667 C->getLParenLoc(), C->getFirstLoc(),
10668 C->getCountLoc(), C->getEndLoc());
10669}
10670
10671template <typename Derived>
10672OMPClause *
10674 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10675 if (E.isInvalid())
10676 return nullptr;
10677 return getDerived().RebuildOMPCollapseClause(
10678 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10679}
10680
10681template <typename Derived>
10682OMPClause *
10684 return getDerived().RebuildOMPDefaultClause(
10685 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getDefaultVC(),
10686 C->getDefaultVCLoc(), C->getBeginLoc(), C->getLParenLoc(),
10687 C->getEndLoc());
10688}
10689
10690template <typename Derived>
10691OMPClause *
10693 // No need to rebuild this clause, no template-dependent parameters.
10694 return C;
10695}
10696
10697template <typename Derived>
10698OMPClause *
10700 Expr *Impex = C->getImpexType();
10701 ExprResult TransformedImpex = getDerived().TransformExpr(Impex);
10702
10703 if (TransformedImpex.isInvalid())
10704 return nullptr;
10705
10706 return getDerived().RebuildOMPTransparentClause(
10707 TransformedImpex.get(), C->getBeginLoc(), C->getLParenLoc(),
10708 C->getEndLoc());
10709}
10710
10711template <typename Derived>
10712OMPClause *
10714 return getDerived().RebuildOMPProcBindClause(
10715 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10716 C->getLParenLoc(), C->getEndLoc());
10717}
10718
10719template <typename Derived>
10720OMPClause *
10722 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10723 if (E.isInvalid())
10724 return nullptr;
10725 return getDerived().RebuildOMPScheduleClause(
10726 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10727 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10728 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10729 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10730}
10731
10732template <typename Derived>
10733OMPClause *
10735 ExprResult E;
10736 if (auto *Num = C->getNumForLoops()) {
10737 E = getDerived().TransformExpr(Num);
10738 if (E.isInvalid())
10739 return nullptr;
10740 }
10741 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10742 C->getLParenLoc(), E.get());
10743}
10744
10745template <typename Derived>
10746OMPClause *
10748 ExprResult E;
10749 if (Expr *Evt = C->getEventHandler()) {
10750 E = getDerived().TransformExpr(Evt);
10751 if (E.isInvalid())
10752 return nullptr;
10753 }
10754 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10755 C->getLParenLoc(), C->getEndLoc());
10756}
10757
10758template <typename Derived>
10759OMPClause *
10762 if (auto *Condition = C->getCondition()) {
10763 Cond = getDerived().TransformExpr(Condition);
10764 if (Cond.isInvalid())
10765 return nullptr;
10766 }
10767 return getDerived().RebuildOMPNowaitClause(Cond.get(), C->getBeginLoc(),
10768 C->getLParenLoc(), C->getEndLoc());
10769}
10770
10771template <typename Derived>
10772OMPClause *
10774 // No need to rebuild this clause, no template-dependent parameters.
10775 return C;
10776}
10777
10778template <typename Derived>
10779OMPClause *
10781 // No need to rebuild this clause, no template-dependent parameters.
10782 return C;
10783}
10784
10785template <typename Derived>
10787 // No need to rebuild this clause, no template-dependent parameters.
10788 return C;
10789}
10790
10791template <typename Derived>
10793 // No need to rebuild this clause, no template-dependent parameters.
10794 return C;
10795}
10796
10797template <typename Derived>
10798OMPClause *
10800 // No need to rebuild this clause, no template-dependent parameters.
10801 return C;
10802}
10803
10804template <typename Derived>
10805OMPClause *
10807 // No need to rebuild this clause, no template-dependent parameters.
10808 return C;
10809}
10810
10811template <typename Derived>
10812OMPClause *
10814 // No need to rebuild this clause, no template-dependent parameters.
10815 return C;
10816}
10817
10818template <typename Derived>
10820 // No need to rebuild this clause, no template-dependent parameters.
10821 return C;
10822}
10823
10824template <typename Derived>
10825OMPClause *
10827 return C;
10828}
10829
10830template <typename Derived>
10832 ExprResult E = getDerived().TransformExpr(C->getExpr());
10833 if (E.isInvalid())
10834 return nullptr;
10835 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
10836 C->getLParenLoc(), C->getEndLoc());
10837}
10838
10839template <typename Derived>
10840OMPClause *
10842 return C;
10843}
10844
10845template <typename Derived>
10846OMPClause *
10848 return C;
10849}
10850template <typename Derived>
10852 OMPNoOpenMPRoutinesClause *C) {
10853 return C;
10854}
10855template <typename Derived>
10857 OMPNoOpenMPConstructsClause *C) {
10858 return C;
10859}
10860template <typename Derived>
10862 OMPNoParallelismClause *C) {
10863 return C;
10864}
10865
10866template <typename Derived>
10867OMPClause *
10869 // No need to rebuild this clause, no template-dependent parameters.
10870 return C;
10871}
10872
10873template <typename Derived>
10874OMPClause *
10876 // No need to rebuild this clause, no template-dependent parameters.
10877 return C;
10878}
10879
10880template <typename Derived>
10881OMPClause *
10883 // No need to rebuild this clause, no template-dependent parameters.
10884 return C;
10885}
10886
10887template <typename Derived>
10888OMPClause *
10890 // No need to rebuild this clause, no template-dependent parameters.
10891 return C;
10892}
10893
10894template <typename Derived>
10895OMPClause *
10897 // No need to rebuild this clause, no template-dependent parameters.
10898 return C;
10899}
10900
10901template <typename Derived>
10903 // No need to rebuild this clause, no template-dependent parameters.
10904 return C;
10905}
10906
10907template <typename Derived>
10908OMPClause *
10910 // No need to rebuild this clause, no template-dependent parameters.
10911 return C;
10912}
10913
10914template <typename Derived>
10916 // No need to rebuild this clause, no template-dependent parameters.
10917 return C;
10918}
10919
10920template <typename Derived>
10921OMPClause *
10923 // No need to rebuild this clause, no template-dependent parameters.
10924 return C;
10925}
10926
10927template <typename Derived>
10929 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
10930 if (IVR.isInvalid())
10931 return nullptr;
10932
10933 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
10934 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
10935 for (Expr *E : llvm::drop_begin(C->varlist())) {
10936 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
10937 if (ER.isInvalid())
10938 return nullptr;
10939 InteropInfo.PreferTypes.push_back(ER.get());
10940 }
10941 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
10942 C->getBeginLoc(), C->getLParenLoc(),
10943 C->getVarLoc(), C->getEndLoc());
10944}
10945
10946template <typename Derived>
10948 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
10949 if (ER.isInvalid())
10950 return nullptr;
10951 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
10952 C->getLParenLoc(), C->getVarLoc(),
10953 C->getEndLoc());
10954}
10955
10956template <typename Derived>
10957OMPClause *
10959 ExprResult ER;
10960 if (Expr *IV = C->getInteropVar()) {
10961 ER = getDerived().TransformExpr(IV);
10962 if (ER.isInvalid())
10963 return nullptr;
10964 }
10965 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
10966 C->getLParenLoc(), C->getVarLoc(),
10967 C->getEndLoc());
10968}
10969
10970template <typename Derived>
10971OMPClause *
10973 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10974 if (Cond.isInvalid())
10975 return nullptr;
10976 return getDerived().RebuildOMPNovariantsClause(
10977 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10978}
10979
10980template <typename Derived>
10981OMPClause *
10983 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10984 if (Cond.isInvalid())
10985 return nullptr;
10986 return getDerived().RebuildOMPNocontextClause(
10987 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10988}
10989
10990template <typename Derived>
10991OMPClause *
10993 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
10994 if (ThreadID.isInvalid())
10995 return nullptr;
10996 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
10997 C->getLParenLoc(), C->getEndLoc());
10998}
10999
11000template <typename Derived>
11002 ExprResult E = getDerived().TransformExpr(C->getAlignment());
11003 if (E.isInvalid())
11004 return nullptr;
11005 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
11006 C->getLParenLoc(), C->getEndLoc());
11007}
11008
11009template <typename Derived>
11011 OMPUnifiedAddressClause *C) {
11012 llvm_unreachable("unified_address clause cannot appear in dependent context");
11013}
11014
11015template <typename Derived>
11017 OMPUnifiedSharedMemoryClause *C) {
11018 llvm_unreachable(
11019 "unified_shared_memory clause cannot appear in dependent context");
11020}
11021
11022template <typename Derived>
11024 OMPReverseOffloadClause *C) {
11025 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
11026}
11027
11028template <typename Derived>
11030 OMPDynamicAllocatorsClause *C) {
11031 llvm_unreachable(
11032 "dynamic_allocators clause cannot appear in dependent context");
11033}
11034
11035template <typename Derived>
11037 OMPAtomicDefaultMemOrderClause *C) {
11038 llvm_unreachable(
11039 "atomic_default_mem_order clause cannot appear in dependent context");
11040}
11041
11042template <typename Derived>
11043OMPClause *
11045 llvm_unreachable("self_maps clause cannot appear in dependent context");
11046}
11047
11048template <typename Derived>
11050 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
11051 C->getBeginLoc(), C->getLParenLoc(),
11052 C->getEndLoc());
11053}
11054
11055template <typename Derived>
11056OMPClause *
11058 return getDerived().RebuildOMPSeverityClause(
11059 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
11060 C->getLParenLoc(), C->getEndLoc());
11061}
11062
11063template <typename Derived>
11064OMPClause *
11066 ExprResult E = getDerived().TransformExpr(C->getMessageString());
11067 if (E.isInvalid())
11068 return nullptr;
11069 return getDerived().RebuildOMPMessageClause(
11070 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11071}
11072
11073template <typename Derived>
11074OMPClause *
11077 Vars.reserve(C->varlist_size());
11078 for (auto *VE : C->varlist()) {
11079 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11080 if (EVar.isInvalid())
11081 return nullptr;
11082 Vars.push_back(EVar.get());
11083 }
11084 return getDerived().RebuildOMPPrivateClause(
11085 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11086}
11087
11088template <typename Derived>
11090 OMPFirstprivateClause *C) {
11092 Vars.reserve(C->varlist_size());
11093 for (auto *VE : C->varlist()) {
11094 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11095 if (EVar.isInvalid())
11096 return nullptr;
11097 Vars.push_back(EVar.get());
11098 }
11099 return getDerived().RebuildOMPFirstprivateClause(
11100 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11101}
11102
11103template <typename Derived>
11104OMPClause *
11107 Vars.reserve(C->varlist_size());
11108 for (auto *VE : C->varlist()) {
11109 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11110 if (EVar.isInvalid())
11111 return nullptr;
11112 Vars.push_back(EVar.get());
11113 }
11114 return getDerived().RebuildOMPLastprivateClause(
11115 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11116 C->getLParenLoc(), C->getEndLoc());
11117}
11118
11119template <typename Derived>
11120OMPClause *
11123 Vars.reserve(C->varlist_size());
11124 for (auto *VE : C->varlist()) {
11125 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11126 if (EVar.isInvalid())
11127 return nullptr;
11128 Vars.push_back(EVar.get());
11129 }
11130 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11131 C->getLParenLoc(), C->getEndLoc());
11132}
11133
11134template <typename Derived>
11135OMPClause *
11138 Vars.reserve(C->varlist_size());
11139 for (auto *VE : C->varlist()) {
11140 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11141 if (EVar.isInvalid())
11142 return nullptr;
11143 Vars.push_back(EVar.get());
11144 }
11145 CXXScopeSpec ReductionIdScopeSpec;
11146 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11147
11148 DeclarationNameInfo NameInfo = C->getNameInfo();
11149 if (NameInfo.getName()) {
11150 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11151 if (!NameInfo.getName())
11152 return nullptr;
11153 }
11154 // Build a list of all UDR decls with the same names ranged by the Scopes.
11155 // The Scope boundary is a duplication of the previous decl.
11156 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11157 for (auto *E : C->reduction_ops()) {
11158 // Transform all the decls.
11159 if (E) {
11160 auto *ULE = cast<UnresolvedLookupExpr>(E);
11161 UnresolvedSet<8> Decls;
11162 for (auto *D : ULE->decls()) {
11163 NamedDecl *InstD =
11164 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11165 Decls.addDecl(InstD, InstD->getAccess());
11166 }
11167 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11168 SemaRef.Context, /*NamingClass=*/nullptr,
11169 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11170 /*ADL=*/true, Decls.begin(), Decls.end(),
11171 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11172 } else
11173 UnresolvedReductions.push_back(nullptr);
11174 }
11175 return getDerived().RebuildOMPReductionClause(
11176 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11177 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11178 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11179}
11180
11181template <typename Derived>
11183 OMPTaskReductionClause *C) {
11185 Vars.reserve(C->varlist_size());
11186 for (auto *VE : C->varlist()) {
11187 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11188 if (EVar.isInvalid())
11189 return nullptr;
11190 Vars.push_back(EVar.get());
11191 }
11192 CXXScopeSpec ReductionIdScopeSpec;
11193 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11194
11195 DeclarationNameInfo NameInfo = C->getNameInfo();
11196 if (NameInfo.getName()) {
11197 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11198 if (!NameInfo.getName())
11199 return nullptr;
11200 }
11201 // Build a list of all UDR decls with the same names ranged by the Scopes.
11202 // The Scope boundary is a duplication of the previous decl.
11203 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11204 for (auto *E : C->reduction_ops()) {
11205 // Transform all the decls.
11206 if (E) {
11207 auto *ULE = cast<UnresolvedLookupExpr>(E);
11208 UnresolvedSet<8> Decls;
11209 for (auto *D : ULE->decls()) {
11210 NamedDecl *InstD =
11211 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11212 Decls.addDecl(InstD, InstD->getAccess());
11213 }
11214 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11215 SemaRef.Context, /*NamingClass=*/nullptr,
11216 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11217 /*ADL=*/true, Decls.begin(), Decls.end(),
11218 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11219 } else
11220 UnresolvedReductions.push_back(nullptr);
11221 }
11222 return getDerived().RebuildOMPTaskReductionClause(
11223 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11224 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11225}
11226
11227template <typename Derived>
11228OMPClause *
11231 Vars.reserve(C->varlist_size());
11232 for (auto *VE : C->varlist()) {
11233 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11234 if (EVar.isInvalid())
11235 return nullptr;
11236 Vars.push_back(EVar.get());
11237 }
11238 CXXScopeSpec ReductionIdScopeSpec;
11239 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11240
11241 DeclarationNameInfo NameInfo = C->getNameInfo();
11242 if (NameInfo.getName()) {
11243 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11244 if (!NameInfo.getName())
11245 return nullptr;
11246 }
11247 // Build a list of all UDR decls with the same names ranged by the Scopes.
11248 // The Scope boundary is a duplication of the previous decl.
11249 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11250 for (auto *E : C->reduction_ops()) {
11251 // Transform all the decls.
11252 if (E) {
11253 auto *ULE = cast<UnresolvedLookupExpr>(E);
11254 UnresolvedSet<8> Decls;
11255 for (auto *D : ULE->decls()) {
11256 NamedDecl *InstD =
11257 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11258 Decls.addDecl(InstD, InstD->getAccess());
11259 }
11260 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11261 SemaRef.Context, /*NamingClass=*/nullptr,
11262 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11263 /*ADL=*/true, Decls.begin(), Decls.end(),
11264 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11265 } else
11266 UnresolvedReductions.push_back(nullptr);
11267 }
11268 return getDerived().RebuildOMPInReductionClause(
11269 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11270 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11271}
11272
11273template <typename Derived>
11274OMPClause *
11277 Vars.reserve(C->varlist_size());
11278 for (auto *VE : C->varlist()) {
11279 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11280 if (EVar.isInvalid())
11281 return nullptr;
11282 Vars.push_back(EVar.get());
11283 }
11284 ExprResult Step = getDerived().TransformExpr(C->getStep());
11285 if (Step.isInvalid())
11286 return nullptr;
11287 return getDerived().RebuildOMPLinearClause(
11288 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11289 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11290 C->getEndLoc());
11291}
11292
11293template <typename Derived>
11294OMPClause *
11297 Vars.reserve(C->varlist_size());
11298 for (auto *VE : C->varlist()) {
11299 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11300 if (EVar.isInvalid())
11301 return nullptr;
11302 Vars.push_back(EVar.get());
11303 }
11304 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11305 if (Alignment.isInvalid())
11306 return nullptr;
11307 return getDerived().RebuildOMPAlignedClause(
11308 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11309 C->getColonLoc(), C->getEndLoc());
11310}
11311
11312template <typename Derived>
11313OMPClause *
11316 Vars.reserve(C->varlist_size());
11317 for (auto *VE : C->varlist()) {
11318 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11319 if (EVar.isInvalid())
11320 return nullptr;
11321 Vars.push_back(EVar.get());
11322 }
11323 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11324 C->getLParenLoc(), C->getEndLoc());
11325}
11326
11327template <typename Derived>
11328OMPClause *
11331 Vars.reserve(C->varlist_size());
11332 for (auto *VE : C->varlist()) {
11333 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11334 if (EVar.isInvalid())
11335 return nullptr;
11336 Vars.push_back(EVar.get());
11337 }
11338 return getDerived().RebuildOMPCopyprivateClause(
11339 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11340}
11341
11342template <typename Derived>
11345 Vars.reserve(C->varlist_size());
11346 for (auto *VE : C->varlist()) {
11347 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11348 if (EVar.isInvalid())
11349 return nullptr;
11350 Vars.push_back(EVar.get());
11351 }
11352 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11353 C->getLParenLoc(), C->getEndLoc());
11354}
11355
11356template <typename Derived>
11357OMPClause *
11359 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11360 if (E.isInvalid())
11361 return nullptr;
11362 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11363 C->getLParenLoc(), C->getEndLoc());
11364}
11365
11366template <typename Derived>
11367OMPClause *
11370 Expr *DepModifier = C->getModifier();
11371 if (DepModifier) {
11372 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11373 if (DepModRes.isInvalid())
11374 return nullptr;
11375 DepModifier = DepModRes.get();
11376 }
11377 Vars.reserve(C->varlist_size());
11378 for (auto *VE : C->varlist()) {
11379 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11380 if (EVar.isInvalid())
11381 return nullptr;
11382 Vars.push_back(EVar.get());
11383 }
11384 return getDerived().RebuildOMPDependClause(
11385 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11386 C->getOmpAllMemoryLoc()},
11387 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11388}
11389
11390template <typename Derived>
11391OMPClause *
11393 ExprResult E = getDerived().TransformExpr(C->getDevice());
11394 if (E.isInvalid())
11395 return nullptr;
11396 return getDerived().RebuildOMPDeviceClause(
11397 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11398 C->getModifierLoc(), C->getEndLoc());
11399}
11400
11401template <typename Derived, class T>
11404 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11405 DeclarationNameInfo &MapperIdInfo,
11406 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11407 // Transform expressions in the list.
11408 Vars.reserve(C->varlist_size());
11409 for (auto *VE : C->varlist()) {
11410 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11411 if (EVar.isInvalid())
11412 return true;
11413 Vars.push_back(EVar.get());
11414 }
11415 // Transform mapper scope specifier and identifier.
11416 NestedNameSpecifierLoc QualifierLoc;
11417 if (C->getMapperQualifierLoc()) {
11418 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11419 C->getMapperQualifierLoc());
11420 if (!QualifierLoc)
11421 return true;
11422 }
11423 MapperIdScopeSpec.Adopt(QualifierLoc);
11424 MapperIdInfo = C->getMapperIdInfo();
11425 if (MapperIdInfo.getName()) {
11426 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11427 if (!MapperIdInfo.getName())
11428 return true;
11429 }
11430 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11431 // the previous user-defined mapper lookup in dependent environment.
11432 for (auto *E : C->mapperlists()) {
11433 // Transform all the decls.
11434 if (E) {
11435 auto *ULE = cast<UnresolvedLookupExpr>(E);
11436 UnresolvedSet<8> Decls;
11437 for (auto *D : ULE->decls()) {
11438 NamedDecl *InstD =
11439 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11440 Decls.addDecl(InstD, InstD->getAccess());
11441 }
11442 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11443 TT.getSema().Context, /*NamingClass=*/nullptr,
11444 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11445 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11446 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11447 } else {
11448 UnresolvedMappers.push_back(nullptr);
11449 }
11450 }
11451 return false;
11452}
11453
11454template <typename Derived>
11455OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11456 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11458 Expr *IteratorModifier = C->getIteratorModifier();
11459 if (IteratorModifier) {
11460 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11461 if (MapModRes.isInvalid())
11462 return nullptr;
11463 IteratorModifier = MapModRes.get();
11464 }
11465 CXXScopeSpec MapperIdScopeSpec;
11466 DeclarationNameInfo MapperIdInfo;
11467 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11469 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11470 return nullptr;
11471 return getDerived().RebuildOMPMapClause(
11472 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11473 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11474 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11475}
11476
11477template <typename Derived>
11478OMPClause *
11480 Expr *Allocator = C->getAllocator();
11481 if (Allocator) {
11482 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11483 if (AllocatorRes.isInvalid())
11484 return nullptr;
11485 Allocator = AllocatorRes.get();
11486 }
11487 Expr *Alignment = C->getAlignment();
11488 if (Alignment) {
11489 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11490 if (AlignmentRes.isInvalid())
11491 return nullptr;
11492 Alignment = AlignmentRes.get();
11493 }
11495 Vars.reserve(C->varlist_size());
11496 for (auto *VE : C->varlist()) {
11497 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11498 if (EVar.isInvalid())
11499 return nullptr;
11500 Vars.push_back(EVar.get());
11501 }
11502 return getDerived().RebuildOMPAllocateClause(
11503 Allocator, Alignment, C->getFirstAllocateModifier(),
11504 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11505 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11506 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11507}
11508
11509template <typename Derived>
11510OMPClause *
11513 Vars.reserve(C->varlist_size());
11514 for (auto *VE : C->varlist()) {
11515 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11516 if (EVar.isInvalid())
11517 return nullptr;
11518 Vars.push_back(EVar.get());
11519 }
11520 return getDerived().RebuildOMPNumTeamsClause(
11521 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11522}
11523
11524template <typename Derived>
11525OMPClause *
11528 Vars.reserve(C->varlist_size());
11529 for (auto *VE : C->varlist()) {
11530 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11531 if (EVar.isInvalid())
11532 return nullptr;
11533 Vars.push_back(EVar.get());
11534 }
11535 return getDerived().RebuildOMPThreadLimitClause(
11536 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11537}
11538
11539template <typename Derived>
11540OMPClause *
11542 ExprResult E = getDerived().TransformExpr(C->getPriority());
11543 if (E.isInvalid())
11544 return nullptr;
11545 return getDerived().RebuildOMPPriorityClause(
11546 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11547}
11548
11549template <typename Derived>
11550OMPClause *
11552 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11553 if (E.isInvalid())
11554 return nullptr;
11555 return getDerived().RebuildOMPGrainsizeClause(
11556 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11557 C->getModifierLoc(), C->getEndLoc());
11558}
11559
11560template <typename Derived>
11561OMPClause *
11563 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11564 if (E.isInvalid())
11565 return nullptr;
11566 return getDerived().RebuildOMPNumTasksClause(
11567 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11568 C->getModifierLoc(), C->getEndLoc());
11569}
11570
11571template <typename Derived>
11573 ExprResult E = getDerived().TransformExpr(C->getHint());
11574 if (E.isInvalid())
11575 return nullptr;
11576 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11577 C->getLParenLoc(), C->getEndLoc());
11578}
11579
11580template <typename Derived>
11582 OMPDistScheduleClause *C) {
11583 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11584 if (E.isInvalid())
11585 return nullptr;
11586 return getDerived().RebuildOMPDistScheduleClause(
11587 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11588 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11589}
11590
11591template <typename Derived>
11592OMPClause *
11594 // Rebuild Defaultmap Clause since we need to invoke the checking of
11595 // defaultmap(none:variable-category) after template initialization.
11596 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11597 C->getDefaultmapKind(),
11598 C->getBeginLoc(),
11599 C->getLParenLoc(),
11600 C->getDefaultmapModifierLoc(),
11601 C->getDefaultmapKindLoc(),
11602 C->getEndLoc());
11603}
11604
11605template <typename Derived>
11607 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11609 Expr *IteratorModifier = C->getIteratorModifier();
11610 if (IteratorModifier) {
11611 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11612 if (MapModRes.isInvalid())
11613 return nullptr;
11614 IteratorModifier = MapModRes.get();
11615 }
11616 CXXScopeSpec MapperIdScopeSpec;
11617 DeclarationNameInfo MapperIdInfo;
11618 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11620 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11621 return nullptr;
11622 return getDerived().RebuildOMPToClause(
11623 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11624 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11625 UnresolvedMappers);
11626}
11627
11628template <typename Derived>
11630 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11632 Expr *IteratorModifier = C->getIteratorModifier();
11633 if (IteratorModifier) {
11634 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11635 if (MapModRes.isInvalid())
11636 return nullptr;
11637 IteratorModifier = MapModRes.get();
11638 }
11639 CXXScopeSpec MapperIdScopeSpec;
11640 DeclarationNameInfo MapperIdInfo;
11641 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11643 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11644 return nullptr;
11645 return getDerived().RebuildOMPFromClause(
11646 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11647 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11648 UnresolvedMappers);
11649}
11650
11651template <typename Derived>
11653 OMPUseDevicePtrClause *C) {
11655 Vars.reserve(C->varlist_size());
11656 for (auto *VE : C->varlist()) {
11657 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11658 if (EVar.isInvalid())
11659 return nullptr;
11660 Vars.push_back(EVar.get());
11661 }
11662 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11663 return getDerived().RebuildOMPUseDevicePtrClause(
11664 Vars, Locs, C->getFallbackModifier(), C->getFallbackModifierLoc());
11665}
11666
11667template <typename Derived>
11669 OMPUseDeviceAddrClause *C) {
11671 Vars.reserve(C->varlist_size());
11672 for (auto *VE : C->varlist()) {
11673 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11674 if (EVar.isInvalid())
11675 return nullptr;
11676 Vars.push_back(EVar.get());
11677 }
11678 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11679 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11680}
11681
11682template <typename Derived>
11683OMPClause *
11686 Vars.reserve(C->varlist_size());
11687 for (auto *VE : C->varlist()) {
11688 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11689 if (EVar.isInvalid())
11690 return nullptr;
11691 Vars.push_back(EVar.get());
11692 }
11693 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11694 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11695}
11696
11697template <typename Derived>
11699 OMPHasDeviceAddrClause *C) {
11701 Vars.reserve(C->varlist_size());
11702 for (auto *VE : C->varlist()) {
11703 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11704 if (EVar.isInvalid())
11705 return nullptr;
11706 Vars.push_back(EVar.get());
11707 }
11708 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11709 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11710}
11711
11712template <typename Derived>
11713OMPClause *
11716 Vars.reserve(C->varlist_size());
11717 for (auto *VE : C->varlist()) {
11718 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11719 if (EVar.isInvalid())
11720 return nullptr;
11721 Vars.push_back(EVar.get());
11722 }
11723 return getDerived().RebuildOMPNontemporalClause(
11724 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11725}
11726
11727template <typename Derived>
11728OMPClause *
11731 Vars.reserve(C->varlist_size());
11732 for (auto *VE : C->varlist()) {
11733 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11734 if (EVar.isInvalid())
11735 return nullptr;
11736 Vars.push_back(EVar.get());
11737 }
11738 return getDerived().RebuildOMPInclusiveClause(
11739 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11740}
11741
11742template <typename Derived>
11743OMPClause *
11746 Vars.reserve(C->varlist_size());
11747 for (auto *VE : C->varlist()) {
11748 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11749 if (EVar.isInvalid())
11750 return nullptr;
11751 Vars.push_back(EVar.get());
11752 }
11753 return getDerived().RebuildOMPExclusiveClause(
11754 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11755}
11756
11757template <typename Derived>
11759 OMPUsesAllocatorsClause *C) {
11761 Data.reserve(C->getNumberOfAllocators());
11762 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11763 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11764 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11765 if (Allocator.isInvalid())
11766 continue;
11767 ExprResult AllocatorTraits;
11768 if (Expr *AT = D.AllocatorTraits) {
11769 AllocatorTraits = getDerived().TransformExpr(AT);
11770 if (AllocatorTraits.isInvalid())
11771 continue;
11772 }
11773 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11774 NewD.Allocator = Allocator.get();
11775 NewD.AllocatorTraits = AllocatorTraits.get();
11776 NewD.LParenLoc = D.LParenLoc;
11777 NewD.RParenLoc = D.RParenLoc;
11778 }
11779 return getDerived().RebuildOMPUsesAllocatorsClause(
11780 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11781}
11782
11783template <typename Derived>
11784OMPClause *
11786 SmallVector<Expr *, 4> Locators;
11787 Locators.reserve(C->varlist_size());
11788 ExprResult ModifierRes;
11789 if (Expr *Modifier = C->getModifier()) {
11790 ModifierRes = getDerived().TransformExpr(Modifier);
11791 if (ModifierRes.isInvalid())
11792 return nullptr;
11793 }
11794 for (Expr *E : C->varlist()) {
11795 ExprResult Locator = getDerived().TransformExpr(E);
11796 if (Locator.isInvalid())
11797 continue;
11798 Locators.push_back(Locator.get());
11799 }
11800 return getDerived().RebuildOMPAffinityClause(
11801 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11802 ModifierRes.get(), Locators);
11803}
11804
11805template <typename Derived>
11807 return getDerived().RebuildOMPOrderClause(
11808 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11809 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11810}
11811
11812template <typename Derived>
11814 return getDerived().RebuildOMPBindClause(
11815 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11816 C->getLParenLoc(), C->getEndLoc());
11817}
11818
11819template <typename Derived>
11821 OMPXDynCGroupMemClause *C) {
11822 ExprResult Size = getDerived().TransformExpr(C->getSize());
11823 if (Size.isInvalid())
11824 return nullptr;
11825 return getDerived().RebuildOMPXDynCGroupMemClause(
11826 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11827}
11828
11829template <typename Derived>
11831 OMPDynGroupprivateClause *C) {
11832 ExprResult Size = getDerived().TransformExpr(C->getSize());
11833 if (Size.isInvalid())
11834 return nullptr;
11835 return getDerived().RebuildOMPDynGroupprivateClause(
11836 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
11837 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
11838 C->getDynGroupprivateModifierLoc(),
11839 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
11840}
11841
11842template <typename Derived>
11843OMPClause *
11846 Vars.reserve(C->varlist_size());
11847 for (auto *VE : C->varlist()) {
11848 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11849 if (EVar.isInvalid())
11850 return nullptr;
11851 Vars.push_back(EVar.get());
11852 }
11853 return getDerived().RebuildOMPDoacrossClause(
11854 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11855 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11856}
11857
11858template <typename Derived>
11859OMPClause *
11862 for (auto *A : C->getAttrs())
11863 NewAttrs.push_back(getDerived().TransformAttr(A));
11864 return getDerived().RebuildOMPXAttributeClause(
11865 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11866}
11867
11868template <typename Derived>
11870 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11871}
11872
11873//===----------------------------------------------------------------------===//
11874// OpenACC transformation
11875//===----------------------------------------------------------------------===//
11876namespace {
11877template <typename Derived>
11878class OpenACCClauseTransform final
11879 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11880 TreeTransform<Derived> &Self;
11881 ArrayRef<const OpenACCClause *> ExistingClauses;
11882 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11883 OpenACCClause *NewClause = nullptr;
11884
11885 ExprResult VisitVar(Expr *VarRef) {
11886 ExprResult Res = Self.TransformExpr(VarRef);
11887
11888 if (!Res.isUsable())
11889 return Res;
11890
11891 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11892 ParsedClause.getClauseKind(),
11893 Res.get());
11894
11895 return Res;
11896 }
11897
11898 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11899 llvm::SmallVector<Expr *> InstantiatedVarList;
11900 for (Expr *CurVar : VarList) {
11901 ExprResult VarRef = VisitVar(CurVar);
11902
11903 if (VarRef.isUsable())
11904 InstantiatedVarList.push_back(VarRef.get());
11905 }
11906
11907 return InstantiatedVarList;
11908 }
11909
11910public:
11911 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11912 ArrayRef<const OpenACCClause *> ExistingClauses,
11913 SemaOpenACC::OpenACCParsedClause &PC)
11914 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
11915
11916 OpenACCClause *CreatedClause() const { return NewClause; }
11917
11918#define VISIT_CLAUSE(CLAUSE_NAME) \
11919 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11920#include "clang/Basic/OpenACCClauses.def"
11921};
11922
11923template <typename Derived>
11924void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11925 const OpenACCDefaultClause &C) {
11926 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
11927
11928 NewClause = OpenACCDefaultClause::Create(
11929 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
11930 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11931 ParsedClause.getEndLoc());
11932}
11933
11934template <typename Derived>
11935void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
11936 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11937 assert(Cond && "If constructed with invalid Condition");
11938 Sema::ConditionResult Res = Self.TransformCondition(
11939 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
11940
11941 if (Res.isInvalid() || !Res.get().second)
11942 return;
11943
11944 ParsedClause.setConditionDetails(Res.get().second);
11945
11946 NewClause = OpenACCIfClause::Create(
11947 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11948 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11949 ParsedClause.getEndLoc());
11950}
11951
11952template <typename Derived>
11953void OpenACCClauseTransform<Derived>::VisitSelfClause(
11954 const OpenACCSelfClause &C) {
11955
11956 // If this is an 'update' 'self' clause, this is actually a var list instead.
11957 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
11958 llvm::SmallVector<Expr *> InstantiatedVarList;
11959 for (Expr *CurVar : C.getVarList()) {
11960 ExprResult Res = Self.TransformExpr(CurVar);
11961
11962 if (!Res.isUsable())
11963 continue;
11964
11965 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11966 ParsedClause.getClauseKind(),
11967 Res.get());
11968
11969 if (Res.isUsable())
11970 InstantiatedVarList.push_back(Res.get());
11971 }
11972
11973 ParsedClause.setVarListDetails(InstantiatedVarList,
11975
11976 NewClause = OpenACCSelfClause::Create(
11977 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11978 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11979 ParsedClause.getEndLoc());
11980 } else {
11981
11982 if (C.hasConditionExpr()) {
11983 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11985 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
11987
11988 if (Res.isInvalid() || !Res.get().second)
11989 return;
11990
11991 ParsedClause.setConditionDetails(Res.get().second);
11992 }
11993
11994 NewClause = OpenACCSelfClause::Create(
11995 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11996 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11997 ParsedClause.getEndLoc());
11998 }
11999}
12000
12001template <typename Derived>
12002void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
12003 const OpenACCNumGangsClause &C) {
12004 llvm::SmallVector<Expr *> InstantiatedIntExprs;
12005
12006 for (Expr *CurIntExpr : C.getIntExprs()) {
12007 ExprResult Res = Self.TransformExpr(CurIntExpr);
12008
12009 if (!Res.isUsable())
12010 return;
12011
12012 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12013 C.getClauseKind(),
12014 C.getBeginLoc(), Res.get());
12015 if (!Res.isUsable())
12016 return;
12017
12018 InstantiatedIntExprs.push_back(Res.get());
12019 }
12020
12021 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
12023 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12024 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12025 ParsedClause.getEndLoc());
12026}
12027
12028template <typename Derived>
12029void OpenACCClauseTransform<Derived>::VisitPrivateClause(
12030 const OpenACCPrivateClause &C) {
12031 llvm::SmallVector<Expr *> InstantiatedVarList;
12033
12034 for (const auto [RefExpr, InitRecipe] :
12035 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12036 ExprResult VarRef = VisitVar(RefExpr);
12037
12038 if (VarRef.isUsable()) {
12039 InstantiatedVarList.push_back(VarRef.get());
12040
12041 // We only have to create a new one if it is dependent, and Sema won't
12042 // make one of these unless the type is non-dependent.
12043 if (InitRecipe.isSet())
12044 InitRecipes.push_back(InitRecipe);
12045 else
12046 InitRecipes.push_back(
12047 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
12048 }
12049 }
12050 ParsedClause.setVarListDetails(InstantiatedVarList,
12052
12053 NewClause = OpenACCPrivateClause::Create(
12054 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12055 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12056 ParsedClause.getEndLoc());
12057}
12058
12059template <typename Derived>
12060void OpenACCClauseTransform<Derived>::VisitHostClause(
12061 const OpenACCHostClause &C) {
12062 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12064
12065 NewClause = OpenACCHostClause::Create(
12066 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12067 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12068 ParsedClause.getEndLoc());
12069}
12070
12071template <typename Derived>
12072void OpenACCClauseTransform<Derived>::VisitDeviceClause(
12073 const OpenACCDeviceClause &C) {
12074 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12076
12077 NewClause = OpenACCDeviceClause::Create(
12078 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12079 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12080 ParsedClause.getEndLoc());
12081}
12082
12083template <typename Derived>
12084void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
12086 llvm::SmallVector<Expr *> InstantiatedVarList;
12088
12089 for (const auto [RefExpr, InitRecipe] :
12090 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12091 ExprResult VarRef = VisitVar(RefExpr);
12092
12093 if (VarRef.isUsable()) {
12094 InstantiatedVarList.push_back(VarRef.get());
12095
12096 // We only have to create a new one if it is dependent, and Sema won't
12097 // make one of these unless the type is non-dependent.
12098 if (InitRecipe.isSet())
12099 InitRecipes.push_back(InitRecipe);
12100 else
12101 InitRecipes.push_back(
12102 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12103 VarRef.get()));
12104 }
12105 }
12106 ParsedClause.setVarListDetails(InstantiatedVarList,
12108
12110 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12111 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12112 ParsedClause.getEndLoc());
12113}
12114
12115template <typename Derived>
12116void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12117 const OpenACCNoCreateClause &C) {
12118 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12120
12122 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12123 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12124 ParsedClause.getEndLoc());
12125}
12126
12127template <typename Derived>
12128void OpenACCClauseTransform<Derived>::VisitPresentClause(
12129 const OpenACCPresentClause &C) {
12130 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12132
12133 NewClause = OpenACCPresentClause::Create(
12134 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12135 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12136 ParsedClause.getEndLoc());
12137}
12138
12139template <typename Derived>
12140void OpenACCClauseTransform<Derived>::VisitCopyClause(
12141 const OpenACCCopyClause &C) {
12142 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12143 C.getModifierList());
12144
12145 NewClause = OpenACCCopyClause::Create(
12146 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12147 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12148 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12149 ParsedClause.getEndLoc());
12150}
12151
12152template <typename Derived>
12153void OpenACCClauseTransform<Derived>::VisitLinkClause(
12154 const OpenACCLinkClause &C) {
12155 llvm_unreachable("link clause not valid unless a decl transform");
12156}
12157
12158template <typename Derived>
12159void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12161 llvm_unreachable("device_resident clause not valid unless a decl transform");
12162}
12163template <typename Derived>
12164void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12165 const OpenACCNoHostClause &C) {
12166 llvm_unreachable("nohost clause not valid unless a decl transform");
12167}
12168template <typename Derived>
12169void OpenACCClauseTransform<Derived>::VisitBindClause(
12170 const OpenACCBindClause &C) {
12171 llvm_unreachable("bind clause not valid unless a decl transform");
12172}
12173
12174template <typename Derived>
12175void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12176 const OpenACCCopyInClause &C) {
12177 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12178 C.getModifierList());
12179
12180 NewClause = OpenACCCopyInClause::Create(
12181 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12182 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12183 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12184 ParsedClause.getEndLoc());
12185}
12186
12187template <typename Derived>
12188void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12189 const OpenACCCopyOutClause &C) {
12190 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12191 C.getModifierList());
12192
12193 NewClause = OpenACCCopyOutClause::Create(
12194 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12195 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12196 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12197 ParsedClause.getEndLoc());
12198}
12199
12200template <typename Derived>
12201void OpenACCClauseTransform<Derived>::VisitCreateClause(
12202 const OpenACCCreateClause &C) {
12203 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12204 C.getModifierList());
12205
12206 NewClause = OpenACCCreateClause::Create(
12207 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12208 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12209 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12210 ParsedClause.getEndLoc());
12211}
12212template <typename Derived>
12213void OpenACCClauseTransform<Derived>::VisitAttachClause(
12214 const OpenACCAttachClause &C) {
12215 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12216
12217 // Ensure each var is a pointer type.
12218 llvm::erase_if(VarList, [&](Expr *E) {
12219 return Self.getSema().OpenACC().CheckVarIsPointerType(
12221 });
12222
12223 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12224 NewClause = OpenACCAttachClause::Create(
12225 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12226 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12227 ParsedClause.getEndLoc());
12228}
12229
12230template <typename Derived>
12231void OpenACCClauseTransform<Derived>::VisitDetachClause(
12232 const OpenACCDetachClause &C) {
12233 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12234
12235 // Ensure each var is a pointer type.
12236 llvm::erase_if(VarList, [&](Expr *E) {
12237 return Self.getSema().OpenACC().CheckVarIsPointerType(
12239 });
12240
12241 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12242 NewClause = OpenACCDetachClause::Create(
12243 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12244 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12245 ParsedClause.getEndLoc());
12246}
12247
12248template <typename Derived>
12249void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12250 const OpenACCDeleteClause &C) {
12251 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12253 NewClause = OpenACCDeleteClause::Create(
12254 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12255 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12256 ParsedClause.getEndLoc());
12257}
12258
12259template <typename Derived>
12260void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12261 const OpenACCUseDeviceClause &C) {
12262 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12265 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12266 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12267 ParsedClause.getEndLoc());
12268}
12269
12270template <typename Derived>
12271void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12272 const OpenACCDevicePtrClause &C) {
12273 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12274
12275 // Ensure each var is a pointer type.
12276 llvm::erase_if(VarList, [&](Expr *E) {
12277 return Self.getSema().OpenACC().CheckVarIsPointerType(
12279 });
12280
12281 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12283 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12284 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12285 ParsedClause.getEndLoc());
12286}
12287
12288template <typename Derived>
12289void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12290 const OpenACCNumWorkersClause &C) {
12291 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12292 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12293
12294 ExprResult Res = Self.TransformExpr(IntExpr);
12295 if (!Res.isUsable())
12296 return;
12297
12298 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12299 C.getClauseKind(),
12300 C.getBeginLoc(), Res.get());
12301 if (!Res.isUsable())
12302 return;
12303
12304 ParsedClause.setIntExprDetails(Res.get());
12306 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12307 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12308 ParsedClause.getEndLoc());
12309}
12310
12311template <typename Derived>
12312void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12313 const OpenACCDeviceNumClause &C) {
12314 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12315 assert(IntExpr && "device_num clause constructed with invalid int expr");
12316
12317 ExprResult Res = Self.TransformExpr(IntExpr);
12318 if (!Res.isUsable())
12319 return;
12320
12321 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12322 C.getClauseKind(),
12323 C.getBeginLoc(), Res.get());
12324 if (!Res.isUsable())
12325 return;
12326
12327 ParsedClause.setIntExprDetails(Res.get());
12329 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12330 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12331 ParsedClause.getEndLoc());
12332}
12333
12334template <typename Derived>
12335void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12337 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12338 assert(IntExpr && "default_async clause constructed with invalid int expr");
12339
12340 ExprResult Res = Self.TransformExpr(IntExpr);
12341 if (!Res.isUsable())
12342 return;
12343
12344 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12345 C.getClauseKind(),
12346 C.getBeginLoc(), Res.get());
12347 if (!Res.isUsable())
12348 return;
12349
12350 ParsedClause.setIntExprDetails(Res.get());
12352 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12353 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12354 ParsedClause.getEndLoc());
12355}
12356
12357template <typename Derived>
12358void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12360 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12361 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12362
12363 ExprResult Res = Self.TransformExpr(IntExpr);
12364 if (!Res.isUsable())
12365 return;
12366
12367 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12368 C.getClauseKind(),
12369 C.getBeginLoc(), Res.get());
12370 if (!Res.isUsable())
12371 return;
12372
12373 ParsedClause.setIntExprDetails(Res.get());
12375 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12376 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12377 ParsedClause.getEndLoc());
12378}
12379
12380template <typename Derived>
12381void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12382 const OpenACCAsyncClause &C) {
12383 if (C.hasIntExpr()) {
12384 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12385 if (!Res.isUsable())
12386 return;
12387
12388 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12389 C.getClauseKind(),
12390 C.getBeginLoc(), Res.get());
12391 if (!Res.isUsable())
12392 return;
12393 ParsedClause.setIntExprDetails(Res.get());
12394 }
12395
12396 NewClause = OpenACCAsyncClause::Create(
12397 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12398 ParsedClause.getLParenLoc(),
12399 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12400 : nullptr,
12401 ParsedClause.getEndLoc());
12402}
12403
12404template <typename Derived>
12405void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12406 const OpenACCWorkerClause &C) {
12407 if (C.hasIntExpr()) {
12408 // restrictions on this expression are all "does it exist in certain
12409 // situations" that are not possible to be dependent, so the only check we
12410 // have is that it transforms, and is an int expression.
12411 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12412 if (!Res.isUsable())
12413 return;
12414
12415 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12416 C.getClauseKind(),
12417 C.getBeginLoc(), Res.get());
12418 if (!Res.isUsable())
12419 return;
12420 ParsedClause.setIntExprDetails(Res.get());
12421 }
12422
12423 NewClause = OpenACCWorkerClause::Create(
12424 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12425 ParsedClause.getLParenLoc(),
12426 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12427 : nullptr,
12428 ParsedClause.getEndLoc());
12429}
12430
12431template <typename Derived>
12432void OpenACCClauseTransform<Derived>::VisitVectorClause(
12433 const OpenACCVectorClause &C) {
12434 if (C.hasIntExpr()) {
12435 // restrictions on this expression are all "does it exist in certain
12436 // situations" that are not possible to be dependent, so the only check we
12437 // have is that it transforms, and is an int expression.
12438 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12439 if (!Res.isUsable())
12440 return;
12441
12442 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12443 C.getClauseKind(),
12444 C.getBeginLoc(), Res.get());
12445 if (!Res.isUsable())
12446 return;
12447 ParsedClause.setIntExprDetails(Res.get());
12448 }
12449
12450 NewClause = OpenACCVectorClause::Create(
12451 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12452 ParsedClause.getLParenLoc(),
12453 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12454 : nullptr,
12455 ParsedClause.getEndLoc());
12456}
12457
12458template <typename Derived>
12459void OpenACCClauseTransform<Derived>::VisitWaitClause(
12460 const OpenACCWaitClause &C) {
12461 if (C.hasExprs()) {
12462 Expr *DevNumExpr = nullptr;
12463 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12464
12465 // Instantiate devnum expr if it exists.
12466 if (C.getDevNumExpr()) {
12467 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12468 if (!Res.isUsable())
12469 return;
12470 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12471 C.getClauseKind(),
12472 C.getBeginLoc(), Res.get());
12473 if (!Res.isUsable())
12474 return;
12475
12476 DevNumExpr = Res.get();
12477 }
12478
12479 // Instantiate queue ids.
12480 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12481 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12482 if (!Res.isUsable())
12483 return;
12484 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12485 C.getClauseKind(),
12486 C.getBeginLoc(), Res.get());
12487 if (!Res.isUsable())
12488 return;
12489
12490 InstantiatedQueueIdExprs.push_back(Res.get());
12491 }
12492
12493 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12494 std::move(InstantiatedQueueIdExprs));
12495 }
12496
12497 NewClause = OpenACCWaitClause::Create(
12498 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12499 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12500 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12501 ParsedClause.getEndLoc());
12502}
12503
12504template <typename Derived>
12505void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12506 const OpenACCDeviceTypeClause &C) {
12507 // Nothing to transform here, just create a new version of 'C'.
12509 Self.getSema().getASTContext(), C.getClauseKind(),
12510 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12511 C.getArchitectures(), ParsedClause.getEndLoc());
12512}
12513
12514template <typename Derived>
12515void OpenACCClauseTransform<Derived>::VisitAutoClause(
12516 const OpenACCAutoClause &C) {
12517 // Nothing to do, so just create a new node.
12518 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12519 ParsedClause.getBeginLoc(),
12520 ParsedClause.getEndLoc());
12521}
12522
12523template <typename Derived>
12524void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12525 const OpenACCIndependentClause &C) {
12526 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12527 ParsedClause.getBeginLoc(),
12528 ParsedClause.getEndLoc());
12529}
12530
12531template <typename Derived>
12532void OpenACCClauseTransform<Derived>::VisitSeqClause(
12533 const OpenACCSeqClause &C) {
12534 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12535 ParsedClause.getBeginLoc(),
12536 ParsedClause.getEndLoc());
12537}
12538template <typename Derived>
12539void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12540 const OpenACCFinalizeClause &C) {
12541 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12542 ParsedClause.getBeginLoc(),
12543 ParsedClause.getEndLoc());
12544}
12545
12546template <typename Derived>
12547void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12548 const OpenACCIfPresentClause &C) {
12549 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12550 ParsedClause.getBeginLoc(),
12551 ParsedClause.getEndLoc());
12552}
12553
12554template <typename Derived>
12555void OpenACCClauseTransform<Derived>::VisitReductionClause(
12556 const OpenACCReductionClause &C) {
12557 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12558 SmallVector<Expr *> ValidVars;
12560
12561 for (const auto [Var, OrigRecipe] :
12562 llvm::zip(TransformedVars, C.getRecipes())) {
12563 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12564 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12565 if (Res.isUsable()) {
12566 ValidVars.push_back(Res.get());
12567
12568 if (OrigRecipe.isSet())
12569 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
12570 else
12571 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
12572 C.getReductionOp(), Res.get()));
12573 }
12574 }
12575
12576 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12577 ExistingClauses, ParsedClause.getDirectiveKind(),
12578 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12579 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
12580}
12581
12582template <typename Derived>
12583void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12584 const OpenACCCollapseClause &C) {
12585 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12586 assert(LoopCount && "collapse clause constructed with invalid loop count");
12587
12588 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12589
12590 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12591 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12592 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12593
12594 NewLoopCount =
12595 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12596
12597 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12599 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12600 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12601 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12602}
12603
12604template <typename Derived>
12605void OpenACCClauseTransform<Derived>::VisitTileClause(
12606 const OpenACCTileClause &C) {
12607
12608 llvm::SmallVector<Expr *> TransformedExprs;
12609
12610 for (Expr *E : C.getSizeExprs()) {
12611 ExprResult NewSizeExpr = Self.TransformExpr(E);
12612
12613 if (!NewSizeExpr.isUsable())
12614 return;
12615
12616 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12617 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12618 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12619
12620 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12621
12622 if (!NewSizeExpr.isUsable())
12623 return;
12624 TransformedExprs.push_back(NewSizeExpr.get());
12625 }
12626
12627 ParsedClause.setIntExprDetails(TransformedExprs);
12628 NewClause = OpenACCTileClause::Create(
12629 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12630 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12631 ParsedClause.getEndLoc());
12632}
12633template <typename Derived>
12634void OpenACCClauseTransform<Derived>::VisitGangClause(
12635 const OpenACCGangClause &C) {
12636 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12637 llvm::SmallVector<Expr *> TransformedIntExprs;
12638
12639 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12640 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12641 if (!ER.isUsable())
12642 continue;
12643
12644 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12645 ParsedClause.getDirectiveKind(),
12646 C.getExpr(I).first, ER.get());
12647 if (!ER.isUsable())
12648 continue;
12649 TransformedGangKinds.push_back(C.getExpr(I).first);
12650 TransformedIntExprs.push_back(ER.get());
12651 }
12652
12653 NewClause = Self.getSema().OpenACC().CheckGangClause(
12654 ParsedClause.getDirectiveKind(), ExistingClauses,
12655 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12656 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12657}
12658} // namespace
12659template <typename Derived>
12660OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12661 ArrayRef<const OpenACCClause *> ExistingClauses,
12662 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12663
12665 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12666 ParsedClause.setEndLoc(OldClause->getEndLoc());
12667
12668 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12669 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12670
12671 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12672 ParsedClause};
12673 Transform.Visit(OldClause);
12674
12675 return Transform.CreatedClause();
12676}
12677
12678template <typename Derived>
12680TreeTransform<Derived>::TransformOpenACCClauseList(
12682 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12683 for (const auto *Clause : OldClauses) {
12684 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12685 TransformedClauses, DirKind, Clause))
12686 TransformedClauses.push_back(TransformedClause);
12687 }
12688 return TransformedClauses;
12689}
12690
12691template <typename Derived>
12694 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12695
12696 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12697 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12698 C->clauses());
12699
12700 if (getSema().OpenACC().ActOnStartStmtDirective(
12701 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12702 return StmtError();
12703
12704 // Transform Structured Block.
12705 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12706 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12707 C->clauses(), TransformedClauses);
12708 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12709 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12710 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12711
12712 return getDerived().RebuildOpenACCComputeConstruct(
12713 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12714 C->getEndLoc(), TransformedClauses, StrBlock);
12715}
12716
12717template <typename Derived>
12720
12721 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12722
12723 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12724 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12725 C->clauses());
12726
12727 if (getSema().OpenACC().ActOnStartStmtDirective(
12728 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12729 return StmtError();
12730
12731 // Transform Loop.
12732 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12733 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12734 C->clauses(), TransformedClauses);
12735 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12736 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12737 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12738
12739 return getDerived().RebuildOpenACCLoopConstruct(
12740 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12741 TransformedClauses, Loop);
12742}
12743
12744template <typename Derived>
12746 OpenACCCombinedConstruct *C) {
12747 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12748
12749 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12750 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12751 C->clauses());
12752
12753 if (getSema().OpenACC().ActOnStartStmtDirective(
12754 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12755 return StmtError();
12756
12757 // Transform Loop.
12758 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12759 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12760 C->clauses(), TransformedClauses);
12761 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12762 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12763 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12764
12765 return getDerived().RebuildOpenACCCombinedConstruct(
12766 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12767 C->getEndLoc(), TransformedClauses, Loop);
12768}
12769
12770template <typename Derived>
12773 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12774
12775 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12776 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12777 C->clauses());
12778 if (getSema().OpenACC().ActOnStartStmtDirective(
12779 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12780 return StmtError();
12781
12782 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12783 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12784 C->clauses(), TransformedClauses);
12785 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12786 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12787 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12788
12789 return getDerived().RebuildOpenACCDataConstruct(
12790 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12791 TransformedClauses, StrBlock);
12792}
12793
12794template <typename Derived>
12796 OpenACCEnterDataConstruct *C) {
12797 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12798
12799 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12800 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12801 C->clauses());
12802 if (getSema().OpenACC().ActOnStartStmtDirective(
12803 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12804 return StmtError();
12805
12806 return getDerived().RebuildOpenACCEnterDataConstruct(
12807 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12808 TransformedClauses);
12809}
12810
12811template <typename Derived>
12813 OpenACCExitDataConstruct *C) {
12814 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12815
12816 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12817 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12818 C->clauses());
12819 if (getSema().OpenACC().ActOnStartStmtDirective(
12820 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12821 return StmtError();
12822
12823 return getDerived().RebuildOpenACCExitDataConstruct(
12824 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12825 TransformedClauses);
12826}
12827
12828template <typename Derived>
12830 OpenACCHostDataConstruct *C) {
12831 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12832
12833 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12834 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12835 C->clauses());
12836 if (getSema().OpenACC().ActOnStartStmtDirective(
12837 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12838 return StmtError();
12839
12840 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12841 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12842 C->clauses(), TransformedClauses);
12843 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12844 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12845 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12846
12847 return getDerived().RebuildOpenACCHostDataConstruct(
12848 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12849 TransformedClauses, StrBlock);
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 return getDerived().RebuildOpenACCInitConstruct(
12865 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12866 TransformedClauses);
12867}
12868
12869template <typename Derived>
12871 OpenACCShutdownConstruct *C) {
12872 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12873
12874 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12875 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12876 C->clauses());
12877 if (getSema().OpenACC().ActOnStartStmtDirective(
12878 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12879 return StmtError();
12880
12881 return getDerived().RebuildOpenACCShutdownConstruct(
12882 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12883 TransformedClauses);
12884}
12885template <typename Derived>
12888 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12889
12890 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12891 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12892 C->clauses());
12893 if (getSema().OpenACC().ActOnStartStmtDirective(
12894 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12895 return StmtError();
12896
12897 return getDerived().RebuildOpenACCSetConstruct(
12898 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12899 TransformedClauses);
12900}
12901
12902template <typename Derived>
12904 OpenACCUpdateConstruct *C) {
12905 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12906
12907 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12908 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12909 C->clauses());
12910 if (getSema().OpenACC().ActOnStartStmtDirective(
12911 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12912 return StmtError();
12913
12914 return getDerived().RebuildOpenACCUpdateConstruct(
12915 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12916 TransformedClauses);
12917}
12918
12919template <typename Derived>
12922 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12923
12924 ExprResult DevNumExpr;
12925 if (C->hasDevNumExpr()) {
12926 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
12927
12928 if (DevNumExpr.isUsable())
12929 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
12931 C->getBeginLoc(), DevNumExpr.get());
12932 }
12933
12934 llvm::SmallVector<Expr *> QueueIdExprs;
12935
12936 for (Expr *QE : C->getQueueIdExprs()) {
12937 assert(QE && "Null queue id expr?");
12938 ExprResult NewEQ = getDerived().TransformExpr(QE);
12939
12940 if (!NewEQ.isUsable())
12941 break;
12942 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
12944 C->getBeginLoc(), NewEQ.get());
12945 if (NewEQ.isUsable())
12946 QueueIdExprs.push_back(NewEQ.get());
12947 }
12948
12949 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12950 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12951 C->clauses());
12952
12953 if (getSema().OpenACC().ActOnStartStmtDirective(
12954 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12955 return StmtError();
12956
12957 return getDerived().RebuildOpenACCWaitConstruct(
12958 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12959 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
12960 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
12961}
12962template <typename Derived>
12964 OpenACCCacheConstruct *C) {
12965 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12966
12967 llvm::SmallVector<Expr *> TransformedVarList;
12968 for (Expr *Var : C->getVarList()) {
12969 assert(Var && "Null var listexpr?");
12970
12971 ExprResult NewVar = getDerived().TransformExpr(Var);
12972
12973 if (!NewVar.isUsable())
12974 break;
12975
12976 NewVar = getSema().OpenACC().ActOnVar(
12977 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
12978 if (!NewVar.isUsable())
12979 break;
12980
12981 TransformedVarList.push_back(NewVar.get());
12982 }
12983
12984 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
12985 C->getBeginLoc(), {}))
12986 return StmtError();
12987
12988 return getDerived().RebuildOpenACCCacheConstruct(
12989 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12990 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
12991 C->getEndLoc());
12992}
12993
12994template <typename Derived>
12996 OpenACCAtomicConstruct *C) {
12997 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12998
12999 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13000 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13001 C->clauses());
13002
13003 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13004 C->getBeginLoc(), {}))
13005 return StmtError();
13006
13007 // Transform Associated Stmt.
13008 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13009 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
13010
13011 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
13012 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
13013 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
13014 AssocStmt);
13015
13016 return getDerived().RebuildOpenACCAtomicConstruct(
13017 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
13018 C->getEndLoc(), TransformedClauses, AssocStmt);
13019}
13020
13021template <typename Derived>
13024 if (getDerived().AlwaysRebuild())
13025 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
13026 // Nothing can ever change, so there is never anything to transform.
13027 return E;
13028}
13029
13030//===----------------------------------------------------------------------===//
13031// Expression transformation
13032//===----------------------------------------------------------------------===//
13033template<typename Derived>
13036 return TransformExpr(E->getSubExpr());
13037}
13038
13039template <typename Derived>
13042 if (!E->isTypeDependent())
13043 return E;
13044
13045 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
13046
13047 if (!NewT)
13048 return ExprError();
13049
13050 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
13051 return E;
13052
13053 return getDerived().RebuildSYCLUniqueStableNameExpr(
13054 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
13055}
13056
13057template<typename Derived>
13060 if (!E->isTypeDependent())
13061 return E;
13062
13063 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13064 E->getIdentKind());
13065}
13066
13067template<typename Derived>
13070 NestedNameSpecifierLoc QualifierLoc;
13071 if (E->getQualifierLoc()) {
13072 QualifierLoc
13073 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13074 if (!QualifierLoc)
13075 return ExprError();
13076 }
13077
13078 ValueDecl *ND
13079 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13080 E->getDecl()));
13081 if (!ND || ND->isInvalidDecl())
13082 return ExprError();
13083
13084 NamedDecl *Found = ND;
13085 if (E->getFoundDecl() != E->getDecl()) {
13086 Found = cast_or_null<NamedDecl>(
13087 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13088 if (!Found)
13089 return ExprError();
13090 }
13091
13092 DeclarationNameInfo NameInfo = E->getNameInfo();
13093 if (NameInfo.getName()) {
13094 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13095 if (!NameInfo.getName())
13096 return ExprError();
13097 }
13098
13099 if (!getDerived().AlwaysRebuild() &&
13100 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13101 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13102 Found == E->getFoundDecl() &&
13103 NameInfo.getName() == E->getDecl()->getDeclName() &&
13104 !E->hasExplicitTemplateArgs()) {
13105
13106 // Mark it referenced in the new context regardless.
13107 // FIXME: this is a bit instantiation-specific.
13108 SemaRef.MarkDeclRefReferenced(E);
13109
13110 return E;
13111 }
13112
13113 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13114 if (E->hasExplicitTemplateArgs()) {
13115 TemplateArgs = &TransArgs;
13116 TransArgs.setLAngleLoc(E->getLAngleLoc());
13117 TransArgs.setRAngleLoc(E->getRAngleLoc());
13118 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13119 E->getNumTemplateArgs(),
13120 TransArgs))
13121 return ExprError();
13122 }
13123
13124 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13125 Found, TemplateArgs);
13126}
13127
13128template<typename Derived>
13131 return E;
13132}
13133
13134template <typename Derived>
13136 FixedPointLiteral *E) {
13137 return E;
13138}
13139
13140template<typename Derived>
13143 return E;
13144}
13145
13146template<typename Derived>
13149 return E;
13150}
13151
13152template<typename Derived>
13155 return E;
13156}
13157
13158template<typename Derived>
13161 return E;
13162}
13163
13164template<typename Derived>
13167 return getDerived().TransformCallExpr(E);
13168}
13169
13170template<typename Derived>
13173 ExprResult ControllingExpr;
13174 TypeSourceInfo *ControllingType = nullptr;
13175 if (E->isExprPredicate())
13176 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13177 else
13178 ControllingType = getDerived().TransformType(E->getControllingType());
13179
13180 if (ControllingExpr.isInvalid() && !ControllingType)
13181 return ExprError();
13182
13183 SmallVector<Expr *, 4> AssocExprs;
13185 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13186 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13187 if (TSI) {
13188 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13189 if (!AssocType)
13190 return ExprError();
13191 AssocTypes.push_back(AssocType);
13192 } else {
13193 AssocTypes.push_back(nullptr);
13194 }
13195
13196 ExprResult AssocExpr =
13197 getDerived().TransformExpr(Assoc.getAssociationExpr());
13198 if (AssocExpr.isInvalid())
13199 return ExprError();
13200 AssocExprs.push_back(AssocExpr.get());
13201 }
13202
13203 if (!ControllingType)
13204 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13205 E->getDefaultLoc(),
13206 E->getRParenLoc(),
13207 ControllingExpr.get(),
13208 AssocTypes,
13209 AssocExprs);
13210 return getDerived().RebuildGenericSelectionExpr(
13211 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13212 ControllingType, AssocTypes, AssocExprs);
13213}
13214
13215template<typename Derived>
13218 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13219 if (SubExpr.isInvalid())
13220 return ExprError();
13221
13222 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13223 return E;
13224
13225 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13226 E->getRParen());
13227}
13228
13229/// The operand of a unary address-of operator has special rules: it's
13230/// allowed to refer to a non-static member of a class even if there's no 'this'
13231/// object available.
13232template<typename Derived>
13235 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13236 return getDerived().TransformDependentScopeDeclRefExpr(
13237 DRE, /*IsAddressOfOperand=*/true, nullptr);
13238 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13239 return getDerived().TransformUnresolvedLookupExpr(
13240 ULE, /*IsAddressOfOperand=*/true);
13241 else
13242 return getDerived().TransformExpr(E);
13243}
13244
13245template<typename Derived>
13248 ExprResult SubExpr;
13249 if (E->getOpcode() == UO_AddrOf)
13250 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13251 else
13252 SubExpr = TransformExpr(E->getSubExpr());
13253 if (SubExpr.isInvalid())
13254 return ExprError();
13255
13256 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13257 return E;
13258
13259 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13260 E->getOpcode(),
13261 SubExpr.get());
13262}
13263
13264template<typename Derived>
13266TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13267 // Transform the type.
13268 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13269 if (!Type)
13270 return ExprError();
13271
13272 // Transform all of the components into components similar to what the
13273 // parser uses.
13274 // FIXME: It would be slightly more efficient in the non-dependent case to
13275 // just map FieldDecls, rather than requiring the rebuilder to look for
13276 // the fields again. However, __builtin_offsetof is rare enough in
13277 // template code that we don't care.
13278 bool ExprChanged = false;
13279 typedef Sema::OffsetOfComponent Component;
13280 SmallVector<Component, 4> Components;
13281 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13282 const OffsetOfNode &ON = E->getComponent(I);
13283 Component Comp;
13284 Comp.isBrackets = true;
13285 Comp.LocStart = ON.getSourceRange().getBegin();
13286 Comp.LocEnd = ON.getSourceRange().getEnd();
13287 switch (ON.getKind()) {
13288 case OffsetOfNode::Array: {
13289 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13290 ExprResult Index = getDerived().TransformExpr(FromIndex);
13291 if (Index.isInvalid())
13292 return ExprError();
13293
13294 ExprChanged = ExprChanged || Index.get() != FromIndex;
13295 Comp.isBrackets = true;
13296 Comp.U.E = Index.get();
13297 break;
13298 }
13299
13302 Comp.isBrackets = false;
13303 Comp.U.IdentInfo = ON.getFieldName();
13304 if (!Comp.U.IdentInfo)
13305 continue;
13306
13307 break;
13308
13309 case OffsetOfNode::Base:
13310 // Will be recomputed during the rebuild.
13311 continue;
13312 }
13313
13314 Components.push_back(Comp);
13315 }
13316
13317 // If nothing changed, retain the existing expression.
13318 if (!getDerived().AlwaysRebuild() &&
13319 Type == E->getTypeSourceInfo() &&
13320 !ExprChanged)
13321 return E;
13322
13323 // Build a new offsetof expression.
13324 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13325 Components, E->getRParenLoc());
13326}
13327
13328template<typename Derived>
13331 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13332 "opaque value expression requires transformation");
13333 return E;
13334}
13335
13336template <typename Derived>
13339 bool Changed = false;
13340 for (Expr *C : E->subExpressions()) {
13341 ExprResult NewC = getDerived().TransformExpr(C);
13342 if (NewC.isInvalid())
13343 return ExprError();
13344 Children.push_back(NewC.get());
13345
13346 Changed |= NewC.get() != C;
13347 }
13348 if (!getDerived().AlwaysRebuild() && !Changed)
13349 return E;
13350 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13351 Children, E->getType());
13352}
13353
13354template<typename Derived>
13357 // Rebuild the syntactic form. The original syntactic form has
13358 // opaque-value expressions in it, so strip those away and rebuild
13359 // the result. This is a really awful way of doing this, but the
13360 // better solution (rebuilding the semantic expressions and
13361 // rebinding OVEs as necessary) doesn't work; we'd need
13362 // TreeTransform to not strip away implicit conversions.
13363 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13364 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13365 if (result.isInvalid()) return ExprError();
13366
13367 // If that gives us a pseudo-object result back, the pseudo-object
13368 // expression must have been an lvalue-to-rvalue conversion which we
13369 // should reapply.
13370 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13371 result = SemaRef.PseudoObject().checkRValue(result.get());
13372
13373 return result;
13374}
13375
13376template<typename Derived>
13380 if (E->isArgumentType()) {
13381 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13382
13383 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13384 if (!NewT)
13385 return ExprError();
13386
13387 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13388 return E;
13389
13390 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13391 E->getKind(),
13392 E->getSourceRange());
13393 }
13394
13395 // C++0x [expr.sizeof]p1:
13396 // The operand is either an expression, which is an unevaluated operand
13397 // [...]
13401
13402 // Try to recover if we have something like sizeof(T::X) where X is a type.
13403 // Notably, there must be *exactly* one set of parens if X is a type.
13404 TypeSourceInfo *RecoveryTSI = nullptr;
13405 ExprResult SubExpr;
13406 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13407 if (auto *DRE =
13408 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13409 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13410 PE, DRE, false, &RecoveryTSI);
13411 else
13412 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13413
13414 if (RecoveryTSI) {
13415 return getDerived().RebuildUnaryExprOrTypeTrait(
13416 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13417 } else if (SubExpr.isInvalid())
13418 return ExprError();
13419
13420 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13421 return E;
13422
13423 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13424 E->getOperatorLoc(),
13425 E->getKind(),
13426 E->getSourceRange());
13427}
13428
13429template<typename Derived>
13432 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13433 if (LHS.isInvalid())
13434 return ExprError();
13435
13436 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13437 if (RHS.isInvalid())
13438 return ExprError();
13439
13440
13441 if (!getDerived().AlwaysRebuild() &&
13442 LHS.get() == E->getLHS() &&
13443 RHS.get() == E->getRHS())
13444 return E;
13445
13446 return getDerived().RebuildArraySubscriptExpr(
13447 LHS.get(),
13448 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13449}
13450
13451template <typename Derived>
13454 ExprResult Base = getDerived().TransformExpr(E->getBase());
13455 if (Base.isInvalid())
13456 return ExprError();
13457
13458 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13459 if (RowIdx.isInvalid())
13460 return ExprError();
13461
13462 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13463 RowIdx.get() == E->getRowIdx())
13464 return E;
13465
13466 return getDerived().RebuildMatrixSingleSubscriptExpr(Base.get(), RowIdx.get(),
13467 E->getRBracketLoc());
13468}
13469
13470template <typename Derived>
13473 ExprResult Base = getDerived().TransformExpr(E->getBase());
13474 if (Base.isInvalid())
13475 return ExprError();
13476
13477 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13478 if (RowIdx.isInvalid())
13479 return ExprError();
13480
13481 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13482 if (ColumnIdx.isInvalid())
13483 return ExprError();
13484
13485 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13486 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13487 return E;
13488
13489 return getDerived().RebuildMatrixSubscriptExpr(
13490 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13491}
13492
13493template <typename Derived>
13496 ExprResult Base = getDerived().TransformExpr(E->getBase());
13497 if (Base.isInvalid())
13498 return ExprError();
13499
13500 ExprResult LowerBound;
13501 if (E->getLowerBound()) {
13502 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13503 if (LowerBound.isInvalid())
13504 return ExprError();
13505 }
13506
13507 ExprResult Length;
13508 if (E->getLength()) {
13509 Length = getDerived().TransformExpr(E->getLength());
13510 if (Length.isInvalid())
13511 return ExprError();
13512 }
13513
13514 ExprResult Stride;
13515 if (E->isOMPArraySection()) {
13516 if (Expr *Str = E->getStride()) {
13517 Stride = getDerived().TransformExpr(Str);
13518 if (Stride.isInvalid())
13519 return ExprError();
13520 }
13521 }
13522
13523 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13524 LowerBound.get() == E->getLowerBound() &&
13525 Length.get() == E->getLength() &&
13526 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13527 return E;
13528
13529 return getDerived().RebuildArraySectionExpr(
13530 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13531 LowerBound.get(), E->getColonLocFirst(),
13532 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13533 Length.get(), Stride.get(), E->getRBracketLoc());
13534}
13535
13536template <typename Derived>
13539 ExprResult Base = getDerived().TransformExpr(E->getBase());
13540 if (Base.isInvalid())
13541 return ExprError();
13542
13544 bool ErrorFound = false;
13545 for (Expr *Dim : E->getDimensions()) {
13546 ExprResult DimRes = getDerived().TransformExpr(Dim);
13547 if (DimRes.isInvalid()) {
13548 ErrorFound = true;
13549 continue;
13550 }
13551 Dims.push_back(DimRes.get());
13552 }
13553
13554 if (ErrorFound)
13555 return ExprError();
13556 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13557 E->getRParenLoc(), Dims,
13558 E->getBracketsRanges());
13559}
13560
13561template <typename Derived>
13564 unsigned NumIterators = E->numOfIterators();
13566
13567 bool ErrorFound = false;
13568 bool NeedToRebuild = getDerived().AlwaysRebuild();
13569 for (unsigned I = 0; I < NumIterators; ++I) {
13570 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13571 Data[I].DeclIdent = D->getIdentifier();
13572 Data[I].DeclIdentLoc = D->getLocation();
13573 if (D->getLocation() == D->getBeginLoc()) {
13574 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13575 "Implicit type must be int.");
13576 } else {
13577 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13578 QualType DeclTy = getDerived().TransformType(D->getType());
13579 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13580 }
13581 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13582 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13583 ExprResult End = getDerived().TransformExpr(Range.End);
13584 ExprResult Step = getDerived().TransformExpr(Range.Step);
13585 ErrorFound = ErrorFound ||
13586 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13587 !Data[I].Type.get().isNull())) ||
13588 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13589 if (ErrorFound)
13590 continue;
13591 Data[I].Range.Begin = Begin.get();
13592 Data[I].Range.End = End.get();
13593 Data[I].Range.Step = Step.get();
13594 Data[I].AssignLoc = E->getAssignLoc(I);
13595 Data[I].ColonLoc = E->getColonLoc(I);
13596 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13597 NeedToRebuild =
13598 NeedToRebuild ||
13599 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13600 D->getType().getTypePtrOrNull()) ||
13601 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13602 Range.Step != Data[I].Range.Step;
13603 }
13604 if (ErrorFound)
13605 return ExprError();
13606 if (!NeedToRebuild)
13607 return E;
13608
13609 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13610 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13611 if (!Res.isUsable())
13612 return Res;
13613 auto *IE = cast<OMPIteratorExpr>(Res.get());
13614 for (unsigned I = 0; I < NumIterators; ++I)
13615 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13616 IE->getIteratorDecl(I));
13617 return Res;
13618}
13619
13620template<typename Derived>
13623 // Transform the callee.
13624 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13625 if (Callee.isInvalid())
13626 return ExprError();
13627
13628 // Transform arguments.
13629 bool ArgChanged = false;
13631 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13632 &ArgChanged))
13633 return ExprError();
13634
13635 if (!getDerived().AlwaysRebuild() &&
13636 Callee.get() == E->getCallee() &&
13637 !ArgChanged)
13638 return SemaRef.MaybeBindToTemporary(E);
13639
13640 // FIXME: Wrong source location information for the '('.
13641 SourceLocation FakeLParenLoc
13642 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13643
13644 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13645 if (E->hasStoredFPFeatures()) {
13646 FPOptionsOverride NewOverrides = E->getFPFeatures();
13647 getSema().CurFPFeatures =
13648 NewOverrides.applyOverrides(getSema().getLangOpts());
13649 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13650 }
13651
13652 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13653 Args,
13654 E->getRParenLoc());
13655}
13656
13657template<typename Derived>
13660 ExprResult Base = getDerived().TransformExpr(E->getBase());
13661 if (Base.isInvalid())
13662 return ExprError();
13663
13664 NestedNameSpecifierLoc QualifierLoc;
13665 if (E->hasQualifier()) {
13666 QualifierLoc
13667 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13668
13669 if (!QualifierLoc)
13670 return ExprError();
13671 }
13672 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13673
13675 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13676 E->getMemberDecl()));
13677 if (!Member)
13678 return ExprError();
13679
13680 NamedDecl *FoundDecl = E->getFoundDecl();
13681 if (FoundDecl == E->getMemberDecl()) {
13682 FoundDecl = Member;
13683 } else {
13684 FoundDecl = cast_or_null<NamedDecl>(
13685 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13686 if (!FoundDecl)
13687 return ExprError();
13688 }
13689
13690 if (!getDerived().AlwaysRebuild() &&
13691 Base.get() == E->getBase() &&
13692 QualifierLoc == E->getQualifierLoc() &&
13693 Member == E->getMemberDecl() &&
13694 FoundDecl == E->getFoundDecl() &&
13695 !E->hasExplicitTemplateArgs()) {
13696
13697 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13698 // for Openmp where the field need to be privatizized in the case.
13699 if (!(isa<CXXThisExpr>(E->getBase()) &&
13700 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13702 // Mark it referenced in the new context regardless.
13703 // FIXME: this is a bit instantiation-specific.
13704 SemaRef.MarkMemberReferenced(E);
13705 return E;
13706 }
13707 }
13708
13709 TemplateArgumentListInfo TransArgs;
13710 if (E->hasExplicitTemplateArgs()) {
13711 TransArgs.setLAngleLoc(E->getLAngleLoc());
13712 TransArgs.setRAngleLoc(E->getRAngleLoc());
13713 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13714 E->getNumTemplateArgs(),
13715 TransArgs))
13716 return ExprError();
13717 }
13718
13719 // FIXME: Bogus source location for the operator
13720 SourceLocation FakeOperatorLoc =
13721 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13722
13723 // FIXME: to do this check properly, we will need to preserve the
13724 // first-qualifier-in-scope here, just in case we had a dependent
13725 // base (and therefore couldn't do the check) and a
13726 // nested-name-qualifier (and therefore could do the lookup).
13727 NamedDecl *FirstQualifierInScope = nullptr;
13728 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13729 if (MemberNameInfo.getName()) {
13730 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13731 if (!MemberNameInfo.getName())
13732 return ExprError();
13733 }
13734
13735 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13736 E->isArrow(),
13737 QualifierLoc,
13738 TemplateKWLoc,
13739 MemberNameInfo,
13740 Member,
13741 FoundDecl,
13742 (E->hasExplicitTemplateArgs()
13743 ? &TransArgs : nullptr),
13744 FirstQualifierInScope);
13745}
13746
13747template<typename Derived>
13750 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13751 if (LHS.isInvalid())
13752 return ExprError();
13753
13754 ExprResult RHS =
13755 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13756 if (RHS.isInvalid())
13757 return ExprError();
13758
13759 if (!getDerived().AlwaysRebuild() &&
13760 LHS.get() == E->getLHS() &&
13761 RHS.get() == E->getRHS())
13762 return E;
13763
13764 if (E->isCompoundAssignmentOp())
13765 // FPFeatures has already been established from trailing storage
13766 return getDerived().RebuildBinaryOperator(
13767 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13768 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13769 FPOptionsOverride NewOverrides(E->getFPFeatures());
13770 getSema().CurFPFeatures =
13771 NewOverrides.applyOverrides(getSema().getLangOpts());
13772 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13773 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13774 LHS.get(), RHS.get());
13775}
13776
13777template <typename Derived>
13780 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13781
13782 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13783 if (LHS.isInvalid())
13784 return ExprError();
13785
13786 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13787 if (RHS.isInvalid())
13788 return ExprError();
13789
13790 // Extract the already-resolved callee declarations so that we can restrict
13791 // ourselves to using them as the unqualified lookup results when rebuilding.
13792 UnresolvedSet<2> UnqualLookups;
13793 bool ChangedAnyLookups = false;
13794 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13795 const_cast<Expr *>(Decomp.InnerBinOp)};
13796 for (Expr *PossibleBinOp : PossibleBinOps) {
13797 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13798 if (!Op)
13799 continue;
13800 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13801 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13802 continue;
13803
13804 // Transform the callee in case we built a call to a local extern
13805 // declaration.
13806 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13807 E->getOperatorLoc(), Callee->getFoundDecl()));
13808 if (!Found)
13809 return ExprError();
13810 if (Found != Callee->getFoundDecl())
13811 ChangedAnyLookups = true;
13812 UnqualLookups.addDecl(Found);
13813 }
13814
13815 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13816 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13817 // Mark all functions used in the rewrite as referenced. Note that when
13818 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13819 // function calls, and/or there might be a user-defined conversion sequence
13820 // applied to the operands of the <.
13821 // FIXME: this is a bit instantiation-specific.
13822 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13823 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13824 return E;
13825 }
13826
13827 return getDerived().RebuildCXXRewrittenBinaryOperator(
13828 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13829}
13830
13831template<typename Derived>
13835 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13836 FPOptionsOverride NewOverrides(E->getFPFeatures());
13837 getSema().CurFPFeatures =
13838 NewOverrides.applyOverrides(getSema().getLangOpts());
13839 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13840 return getDerived().TransformBinaryOperator(E);
13841}
13842
13843template<typename Derived>
13846 // Just rebuild the common and RHS expressions and see whether we
13847 // get any changes.
13848
13849 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13850 if (commonExpr.isInvalid())
13851 return ExprError();
13852
13853 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13854 if (rhs.isInvalid())
13855 return ExprError();
13856
13857 if (!getDerived().AlwaysRebuild() &&
13858 commonExpr.get() == e->getCommon() &&
13859 rhs.get() == e->getFalseExpr())
13860 return e;
13861
13862 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13863 e->getQuestionLoc(),
13864 nullptr,
13865 e->getColonLoc(),
13866 rhs.get());
13867}
13868
13869template<typename Derived>
13872 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13873 if (Cond.isInvalid())
13874 return ExprError();
13875
13876 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13877 if (LHS.isInvalid())
13878 return ExprError();
13879
13880 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13881 if (RHS.isInvalid())
13882 return ExprError();
13883
13884 if (!getDerived().AlwaysRebuild() &&
13885 Cond.get() == E->getCond() &&
13886 LHS.get() == E->getLHS() &&
13887 RHS.get() == E->getRHS())
13888 return E;
13889
13890 return getDerived().RebuildConditionalOperator(Cond.get(),
13891 E->getQuestionLoc(),
13892 LHS.get(),
13893 E->getColonLoc(),
13894 RHS.get());
13895}
13896
13897template<typename Derived>
13900 // Implicit casts are eliminated during transformation, since they
13901 // will be recomputed by semantic analysis after transformation.
13902 return getDerived().TransformExpr(E->getSubExprAsWritten());
13903}
13904
13905template<typename Derived>
13908 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
13909 if (!Type)
13910 return ExprError();
13911
13912 ExprResult SubExpr
13913 = getDerived().TransformExpr(E->getSubExprAsWritten());
13914 if (SubExpr.isInvalid())
13915 return ExprError();
13916
13917 if (!getDerived().AlwaysRebuild() &&
13918 Type == E->getTypeInfoAsWritten() &&
13919 SubExpr.get() == E->getSubExpr())
13920 return E;
13921
13922 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
13923 Type,
13924 E->getRParenLoc(),
13925 SubExpr.get());
13926}
13927
13928template<typename Derived>
13931 TypeSourceInfo *OldT = E->getTypeSourceInfo();
13932 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13933 if (!NewT)
13934 return ExprError();
13935
13936 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
13937 if (Init.isInvalid())
13938 return ExprError();
13939
13940 if (!getDerived().AlwaysRebuild() &&
13941 OldT == NewT &&
13942 Init.get() == E->getInitializer())
13943 return SemaRef.MaybeBindToTemporary(E);
13944
13945 // Note: the expression type doesn't necessarily match the
13946 // type-as-written, but that's okay, because it should always be
13947 // derivable from the initializer.
13948
13949 return getDerived().RebuildCompoundLiteralExpr(
13950 E->getLParenLoc(), NewT,
13951 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
13952}
13953
13954template<typename Derived>
13957 ExprResult Base = getDerived().TransformExpr(E->getBase());
13958 if (Base.isInvalid())
13959 return ExprError();
13960
13961 if (!getDerived().AlwaysRebuild() &&
13962 Base.get() == E->getBase())
13963 return E;
13964
13965 // FIXME: Bad source location
13966 SourceLocation FakeOperatorLoc =
13967 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
13968 return getDerived().RebuildExtVectorElementExpr(
13969 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
13970 E->getAccessor());
13971}
13972
13973template<typename Derived>
13976 if (InitListExpr *Syntactic = E->getSyntacticForm())
13977 E = Syntactic;
13978
13979 bool InitChanged = false;
13980
13983
13985 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
13986 Inits, &InitChanged))
13987 return ExprError();
13988
13989 if (!getDerived().AlwaysRebuild() && !InitChanged) {
13990 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
13991 // in some cases. We can't reuse it in general, because the syntactic and
13992 // semantic forms are linked, and we can't know that semantic form will
13993 // match even if the syntactic form does.
13994 }
13995
13996 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
13997 E->getRBraceLoc());
13998}
13999
14000template<typename Derived>
14003 Designation Desig;
14004
14005 // transform the initializer value
14006 ExprResult Init = getDerived().TransformExpr(E->getInit());
14007 if (Init.isInvalid())
14008 return ExprError();
14009
14010 // transform the designators.
14011 SmallVector<Expr*, 4> ArrayExprs;
14012 bool ExprChanged = false;
14013 for (const DesignatedInitExpr::Designator &D : E->designators()) {
14014 if (D.isFieldDesignator()) {
14015 if (D.getFieldDecl()) {
14016 FieldDecl *Field = cast_or_null<FieldDecl>(
14017 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
14018 if (Field != D.getFieldDecl())
14019 // Rebuild the expression when the transformed FieldDecl is
14020 // different to the already assigned FieldDecl.
14021 ExprChanged = true;
14022 if (Field->isAnonymousStructOrUnion())
14023 continue;
14024 } else {
14025 // Ensure that the designator expression is rebuilt when there isn't
14026 // a resolved FieldDecl in the designator as we don't want to assign
14027 // a FieldDecl to a pattern designator that will be instantiated again.
14028 ExprChanged = true;
14029 }
14030 Desig.AddDesignator(Designator::CreateFieldDesignator(
14031 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
14032 continue;
14033 }
14034
14035 if (D.isArrayDesignator()) {
14036 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
14037 if (Index.isInvalid())
14038 return ExprError();
14039
14040 Desig.AddDesignator(
14041 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
14042
14043 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
14044 ArrayExprs.push_back(Index.get());
14045 continue;
14046 }
14047
14048 assert(D.isArrayRangeDesignator() && "New kind of designator?");
14049 ExprResult Start
14050 = getDerived().TransformExpr(E->getArrayRangeStart(D));
14051 if (Start.isInvalid())
14052 return ExprError();
14053
14054 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
14055 if (End.isInvalid())
14056 return ExprError();
14057
14058 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
14059 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
14060
14061 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
14062 End.get() != E->getArrayRangeEnd(D);
14063
14064 ArrayExprs.push_back(Start.get());
14065 ArrayExprs.push_back(End.get());
14066 }
14067
14068 if (!getDerived().AlwaysRebuild() &&
14069 Init.get() == E->getInit() &&
14070 !ExprChanged)
14071 return E;
14072
14073 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14074 E->getEqualOrColonLoc(),
14075 E->usesGNUSyntax(), Init.get());
14076}
14077
14078// Seems that if TransformInitListExpr() only works on the syntactic form of an
14079// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14080template<typename Derived>
14084 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14085 "initializer");
14086 return ExprError();
14087}
14088
14089template<typename Derived>
14092 NoInitExpr *E) {
14093 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14094 return ExprError();
14095}
14096
14097template<typename Derived>
14100 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14101 return ExprError();
14102}
14103
14104template<typename Derived>
14107 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14108 return ExprError();
14109}
14110
14111template<typename Derived>
14115 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14116
14117 // FIXME: Will we ever have proper type location here? Will we actually
14118 // need to transform the type?
14119 QualType T = getDerived().TransformType(E->getType());
14120 if (T.isNull())
14121 return ExprError();
14122
14123 if (!getDerived().AlwaysRebuild() &&
14124 T == E->getType())
14125 return E;
14126
14127 return getDerived().RebuildImplicitValueInitExpr(T);
14128}
14129
14130template<typename Derived>
14133 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14134 if (!TInfo)
14135 return ExprError();
14136
14137 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14138 if (SubExpr.isInvalid())
14139 return ExprError();
14140
14141 if (!getDerived().AlwaysRebuild() &&
14142 TInfo == E->getWrittenTypeInfo() &&
14143 SubExpr.get() == E->getSubExpr())
14144 return E;
14145
14146 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14147 TInfo, E->getRParenLoc());
14148}
14149
14150template<typename Derived>
14153 bool ArgumentChanged = false;
14155 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14156 &ArgumentChanged))
14157 return ExprError();
14158
14159 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14160 Inits,
14161 E->getRParenLoc());
14162}
14163
14164/// Transform an address-of-label expression.
14165///
14166/// By default, the transformation of an address-of-label expression always
14167/// rebuilds the expression, so that the label identifier can be resolved to
14168/// the corresponding label statement by semantic analysis.
14169template<typename Derived>
14172 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14173 E->getLabel());
14174 if (!LD)
14175 return ExprError();
14176
14177 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14178 cast<LabelDecl>(LD));
14179}
14180
14181template<typename Derived>
14184 SemaRef.ActOnStartStmtExpr();
14185 StmtResult SubStmt
14186 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14187 if (SubStmt.isInvalid()) {
14188 SemaRef.ActOnStmtExprError();
14189 return ExprError();
14190 }
14191
14192 unsigned OldDepth = E->getTemplateDepth();
14193 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14194
14195 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14196 SubStmt.get() == E->getSubStmt()) {
14197 // Calling this an 'error' is unintuitive, but it does the right thing.
14198 SemaRef.ActOnStmtExprError();
14199 return SemaRef.MaybeBindToTemporary(E);
14200 }
14201
14202 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14203 E->getRParenLoc(), NewDepth);
14204}
14205
14206template<typename Derived>
14209 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14210 if (Cond.isInvalid())
14211 return ExprError();
14212
14213 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14214 if (LHS.isInvalid())
14215 return ExprError();
14216
14217 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14218 if (RHS.isInvalid())
14219 return ExprError();
14220
14221 if (!getDerived().AlwaysRebuild() &&
14222 Cond.get() == E->getCond() &&
14223 LHS.get() == E->getLHS() &&
14224 RHS.get() == E->getRHS())
14225 return E;
14226
14227 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14228 Cond.get(), LHS.get(), RHS.get(),
14229 E->getRParenLoc());
14230}
14231
14232template<typename Derived>
14235 return E;
14236}
14237
14238template<typename Derived>
14241 switch (E->getOperator()) {
14242 case OO_New:
14243 case OO_Delete:
14244 case OO_Array_New:
14245 case OO_Array_Delete:
14246 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14247
14248 case OO_Subscript:
14249 case OO_Call: {
14250 // This is a call to an object's operator().
14251 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14252
14253 // Transform the object itself.
14254 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14255 if (Object.isInvalid())
14256 return ExprError();
14257
14258 // FIXME: Poor location information. Also, if the location for the end of
14259 // the token is within a macro expansion, getLocForEndOfToken() will return
14260 // an invalid source location. If that happens and we have an otherwise
14261 // valid end location, use the valid one instead of the invalid one.
14262 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14263 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14264 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14265 FakeLParenLoc = EndLoc;
14266
14267 // Transform the call arguments.
14269 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14270 Args))
14271 return ExprError();
14272
14273 if (E->getOperator() == OO_Subscript)
14274 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14275 Args, E->getEndLoc());
14276
14277 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14278 E->getEndLoc());
14279 }
14280
14281#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14282 case OO_##Name: \
14283 break;
14284
14285#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14286#include "clang/Basic/OperatorKinds.def"
14287
14288 case OO_Conditional:
14289 llvm_unreachable("conditional operator is not actually overloadable");
14290
14291 case OO_None:
14293 llvm_unreachable("not an overloaded operator?");
14294 }
14295
14297 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14298 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14299 else
14300 First = getDerived().TransformExpr(E->getArg(0));
14301 if (First.isInvalid())
14302 return ExprError();
14303
14304 ExprResult Second;
14305 if (E->getNumArgs() == 2) {
14306 Second =
14307 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14308 if (Second.isInvalid())
14309 return ExprError();
14310 }
14311
14312 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14313 FPOptionsOverride NewOverrides(E->getFPFeatures());
14314 getSema().CurFPFeatures =
14315 NewOverrides.applyOverrides(getSema().getLangOpts());
14316 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14317
14318 Expr *Callee = E->getCallee();
14319 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14320 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14322 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14323 return ExprError();
14324
14325 return getDerived().RebuildCXXOperatorCallExpr(
14326 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14327 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14328 }
14329
14330 UnresolvedSet<1> Functions;
14331 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14332 Callee = ICE->getSubExprAsWritten();
14333 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14334 ValueDecl *VD = cast_or_null<ValueDecl>(
14335 getDerived().TransformDecl(DR->getLocation(), DR));
14336 if (!VD)
14337 return ExprError();
14338
14339 if (!isa<CXXMethodDecl>(VD))
14340 Functions.addDecl(VD);
14341
14342 return getDerived().RebuildCXXOperatorCallExpr(
14343 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14344 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14345}
14346
14347template<typename Derived>
14350 return getDerived().TransformCallExpr(E);
14351}
14352
14353template <typename Derived>
14355 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14356 getSema().CurContext != E->getParentContext();
14357
14358 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14359 return E;
14360
14361 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14362 E->getBeginLoc(), E->getEndLoc(),
14363 getSema().CurContext);
14364}
14365
14366template <typename Derived>
14368 return E;
14369}
14370
14371template<typename Derived>
14374 // Transform the callee.
14375 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14376 if (Callee.isInvalid())
14377 return ExprError();
14378
14379 // Transform exec config.
14380 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14381 if (EC.isInvalid())
14382 return ExprError();
14383
14384 // Transform arguments.
14385 bool ArgChanged = false;
14387 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14388 &ArgChanged))
14389 return ExprError();
14390
14391 if (!getDerived().AlwaysRebuild() &&
14392 Callee.get() == E->getCallee() &&
14393 !ArgChanged)
14394 return SemaRef.MaybeBindToTemporary(E);
14395
14396 // FIXME: Wrong source location information for the '('.
14397 SourceLocation FakeLParenLoc
14398 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14399 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14400 Args,
14401 E->getRParenLoc(), EC.get());
14402}
14403
14404template<typename Derived>
14407 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14408 if (!Type)
14409 return ExprError();
14410
14411 ExprResult SubExpr
14412 = getDerived().TransformExpr(E->getSubExprAsWritten());
14413 if (SubExpr.isInvalid())
14414 return ExprError();
14415
14416 if (!getDerived().AlwaysRebuild() &&
14417 Type == E->getTypeInfoAsWritten() &&
14418 SubExpr.get() == E->getSubExpr())
14419 return E;
14420 return getDerived().RebuildCXXNamedCastExpr(
14423 // FIXME. this should be '(' location
14424 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14425}
14426
14427template<typename Derived>
14430 TypeSourceInfo *TSI =
14431 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14432 if (!TSI)
14433 return ExprError();
14434
14435 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14436 if (Sub.isInvalid())
14437 return ExprError();
14438
14439 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14440 Sub.get(), BCE->getEndLoc());
14441}
14442
14443template<typename Derived>
14445TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14446 return getDerived().TransformCXXNamedCastExpr(E);
14447}
14448
14449template<typename Derived>
14452 return getDerived().TransformCXXNamedCastExpr(E);
14453}
14454
14455template<typename Derived>
14459 return getDerived().TransformCXXNamedCastExpr(E);
14460}
14461
14462template<typename Derived>
14465 return getDerived().TransformCXXNamedCastExpr(E);
14466}
14467
14468template<typename Derived>
14471 return getDerived().TransformCXXNamedCastExpr(E);
14472}
14473
14474template<typename Derived>
14479 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14480 if (!Type)
14481 return ExprError();
14482
14483 ExprResult SubExpr
14484 = getDerived().TransformExpr(E->getSubExprAsWritten());
14485 if (SubExpr.isInvalid())
14486 return ExprError();
14487
14488 if (!getDerived().AlwaysRebuild() &&
14489 Type == E->getTypeInfoAsWritten() &&
14490 SubExpr.get() == E->getSubExpr())
14491 return E;
14492
14493 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14494 E->getLParenLoc(),
14495 SubExpr.get(),
14496 E->getRParenLoc(),
14497 E->isListInitialization());
14498}
14499
14500template<typename Derived>
14503 if (E->isTypeOperand()) {
14504 TypeSourceInfo *TInfo
14505 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14506 if (!TInfo)
14507 return ExprError();
14508
14509 if (!getDerived().AlwaysRebuild() &&
14510 TInfo == E->getTypeOperandSourceInfo())
14511 return E;
14512
14513 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14514 TInfo, E->getEndLoc());
14515 }
14516
14517 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14518 // type. We must not unilaterally enter unevaluated context here, as then
14519 // semantic processing can re-transform an already transformed operand.
14520 Expr *Op = E->getExprOperand();
14522 if (E->isGLValue())
14523 if (auto *RD = Op->getType()->getAsCXXRecordDecl();
14524 RD && RD->isPolymorphic())
14525 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14526
14529
14530 ExprResult SubExpr = getDerived().TransformExpr(Op);
14531 if (SubExpr.isInvalid())
14532 return ExprError();
14533
14534 if (!getDerived().AlwaysRebuild() &&
14535 SubExpr.get() == E->getExprOperand())
14536 return E;
14537
14538 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14539 SubExpr.get(), E->getEndLoc());
14540}
14541
14542template<typename Derived>
14545 if (E->isTypeOperand()) {
14546 TypeSourceInfo *TInfo
14547 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14548 if (!TInfo)
14549 return ExprError();
14550
14551 if (!getDerived().AlwaysRebuild() &&
14552 TInfo == E->getTypeOperandSourceInfo())
14553 return E;
14554
14555 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14556 TInfo, E->getEndLoc());
14557 }
14558
14561
14562 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14563 if (SubExpr.isInvalid())
14564 return ExprError();
14565
14566 if (!getDerived().AlwaysRebuild() &&
14567 SubExpr.get() == E->getExprOperand())
14568 return E;
14569
14570 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14571 SubExpr.get(), E->getEndLoc());
14572}
14573
14574template<typename Derived>
14577 return E;
14578}
14579
14580template<typename Derived>
14584 return E;
14585}
14586
14587template<typename Derived>
14590
14591 // In lambdas, the qualifiers of the type depends of where in
14592 // the call operator `this` appear, and we do not have a good way to
14593 // rebuild this information, so we transform the type.
14594 //
14595 // In other contexts, the type of `this` may be overrided
14596 // for type deduction, so we need to recompute it.
14597 //
14598 // Always recompute the type if we're in the body of a lambda, and
14599 // 'this' is dependent on a lambda's explicit object parameter; we
14600 // also need to always rebuild the expression in this case to clear
14601 // the flag.
14602 QualType T = [&]() {
14603 auto &S = getSema();
14604 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14605 return S.getCurrentThisType();
14606 if (S.getCurLambda())
14607 return getDerived().TransformType(E->getType());
14608 return S.getCurrentThisType();
14609 }();
14610
14611 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14612 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14613 // Mark it referenced in the new context regardless.
14614 // FIXME: this is a bit instantiation-specific.
14615 getSema().MarkThisReferenced(E);
14616 return E;
14617 }
14618
14619 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14620}
14621
14622template<typename Derived>
14625 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14626 if (SubExpr.isInvalid())
14627 return ExprError();
14628
14629 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14630
14631 if (!getDerived().AlwaysRebuild() &&
14632 SubExpr.get() == E->getSubExpr())
14633 return E;
14634
14635 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14636 E->isThrownVariableInScope());
14637}
14638
14639template<typename Derived>
14642 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14643 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14644 if (!Param)
14645 return ExprError();
14646
14647 ExprResult InitRes;
14648 if (E->hasRewrittenInit()) {
14649 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14650 if (InitRes.isInvalid())
14651 return ExprError();
14652 }
14653
14654 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14655 E->getUsedContext() == SemaRef.CurContext &&
14656 InitRes.get() == E->getRewrittenExpr())
14657 return E;
14658
14659 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14660 InitRes.get());
14661}
14662
14663template<typename Derived>
14666 FieldDecl *Field = cast_or_null<FieldDecl>(
14667 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14668 if (!Field)
14669 return ExprError();
14670
14671 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14672 E->getUsedContext() == SemaRef.CurContext)
14673 return E;
14674
14675 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14676}
14677
14678template<typename Derived>
14682 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14683 if (!T)
14684 return ExprError();
14685
14686 if (!getDerived().AlwaysRebuild() &&
14687 T == E->getTypeSourceInfo())
14688 return E;
14689
14690 return getDerived().RebuildCXXScalarValueInitExpr(T,
14691 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14692 E->getRParenLoc());
14693}
14694
14695template<typename Derived>
14698 // Transform the type that we're allocating
14699 TypeSourceInfo *AllocTypeInfo =
14700 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14701 if (!AllocTypeInfo)
14702 return ExprError();
14703
14704 // Transform the size of the array we're allocating (if any).
14705 std::optional<Expr *> ArraySize;
14706 if (E->isArray()) {
14707 ExprResult NewArraySize;
14708 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14709 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14710 if (NewArraySize.isInvalid())
14711 return ExprError();
14712 }
14713 ArraySize = NewArraySize.get();
14714 }
14715
14716 // Transform the placement arguments (if any).
14717 bool ArgumentChanged = false;
14718 SmallVector<Expr*, 8> PlacementArgs;
14719 if (getDerived().TransformExprs(E->getPlacementArgs(),
14720 E->getNumPlacementArgs(), true,
14721 PlacementArgs, &ArgumentChanged))
14722 return ExprError();
14723
14724 // Transform the initializer (if any).
14725 Expr *OldInit = E->getInitializer();
14726 ExprResult NewInit;
14727 if (OldInit)
14728 NewInit = getDerived().TransformInitializer(OldInit, true);
14729 if (NewInit.isInvalid())
14730 return ExprError();
14731
14732 // Transform new operator and delete operator.
14733 FunctionDecl *OperatorNew = nullptr;
14734 if (E->getOperatorNew()) {
14735 OperatorNew = cast_or_null<FunctionDecl>(
14736 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14737 if (!OperatorNew)
14738 return ExprError();
14739 }
14740
14741 FunctionDecl *OperatorDelete = nullptr;
14742 if (E->getOperatorDelete()) {
14743 OperatorDelete = cast_or_null<FunctionDecl>(
14744 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14745 if (!OperatorDelete)
14746 return ExprError();
14747 }
14748
14749 if (!getDerived().AlwaysRebuild() &&
14750 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14751 ArraySize == E->getArraySize() &&
14752 NewInit.get() == OldInit &&
14753 OperatorNew == E->getOperatorNew() &&
14754 OperatorDelete == E->getOperatorDelete() &&
14755 !ArgumentChanged) {
14756 // Mark any declarations we need as referenced.
14757 // FIXME: instantiation-specific.
14758 if (OperatorNew)
14759 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14760 if (OperatorDelete)
14761 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14762
14763 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14764 QualType ElementType
14765 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14766 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14768 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14769 }
14770 }
14771
14772 return E;
14773 }
14774
14775 QualType AllocType = AllocTypeInfo->getType();
14776 if (!ArraySize) {
14777 // If no array size was specified, but the new expression was
14778 // instantiated with an array type (e.g., "new T" where T is
14779 // instantiated with "int[4]"), extract the outer bound from the
14780 // array type as our array size. We do this with constant and
14781 // dependently-sized array types.
14782 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14783 if (!ArrayT) {
14784 // Do nothing
14785 } else if (const ConstantArrayType *ConsArrayT
14786 = dyn_cast<ConstantArrayType>(ArrayT)) {
14787 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14788 SemaRef.Context.getSizeType(),
14789 /*FIXME:*/ E->getBeginLoc());
14790 AllocType = ConsArrayT->getElementType();
14791 } else if (const DependentSizedArrayType *DepArrayT
14792 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14793 if (DepArrayT->getSizeExpr()) {
14794 ArraySize = DepArrayT->getSizeExpr();
14795 AllocType = DepArrayT->getElementType();
14796 }
14797 }
14798 }
14799
14800 return getDerived().RebuildCXXNewExpr(
14801 E->getBeginLoc(), E->isGlobalNew(),
14802 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14803 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14804 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14805}
14806
14807template<typename Derived>
14810 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14811 if (Operand.isInvalid())
14812 return ExprError();
14813
14814 // Transform the delete operator, if known.
14815 FunctionDecl *OperatorDelete = nullptr;
14816 if (E->getOperatorDelete()) {
14817 OperatorDelete = cast_or_null<FunctionDecl>(
14818 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14819 if (!OperatorDelete)
14820 return ExprError();
14821 }
14822
14823 if (!getDerived().AlwaysRebuild() &&
14824 Operand.get() == E->getArgument() &&
14825 OperatorDelete == E->getOperatorDelete()) {
14826 // Mark any declarations we need as referenced.
14827 // FIXME: instantiation-specific.
14828 if (OperatorDelete)
14829 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14830
14831 if (!E->getArgument()->isTypeDependent()) {
14832 QualType Destroyed = SemaRef.Context.getBaseElementType(
14833 E->getDestroyedType());
14834 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14835 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14836 SemaRef.LookupDestructor(Record));
14837 }
14838
14839 return E;
14840 }
14841
14842 return getDerived().RebuildCXXDeleteExpr(
14843 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14844}
14845
14846template<typename Derived>
14850 ExprResult Base = getDerived().TransformExpr(E->getBase());
14851 if (Base.isInvalid())
14852 return ExprError();
14853
14854 ParsedType ObjectTypePtr;
14855 bool MayBePseudoDestructor = false;
14856 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14857 E->getOperatorLoc(),
14858 E->isArrow()? tok::arrow : tok::period,
14859 ObjectTypePtr,
14860 MayBePseudoDestructor);
14861 if (Base.isInvalid())
14862 return ExprError();
14863
14864 QualType ObjectType = ObjectTypePtr.get();
14865 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
14866 if (QualifierLoc) {
14867 QualifierLoc
14868 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
14869 if (!QualifierLoc)
14870 return ExprError();
14871 }
14872 CXXScopeSpec SS;
14873 SS.Adopt(QualifierLoc);
14874
14876 if (E->getDestroyedTypeInfo()) {
14877 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
14878 E->getDestroyedTypeInfo(), ObjectType,
14879 /*FirstQualifierInScope=*/nullptr);
14880 if (!DestroyedTypeInfo)
14881 return ExprError();
14882 Destroyed = DestroyedTypeInfo;
14883 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
14884 // We aren't likely to be able to resolve the identifier down to a type
14885 // now anyway, so just retain the identifier.
14886 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
14887 E->getDestroyedTypeLoc());
14888 } else {
14889 // Look for a destructor known with the given name.
14890 ParsedType T = SemaRef.getDestructorName(
14891 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
14892 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
14893 if (!T)
14894 return ExprError();
14895
14896 Destroyed
14898 E->getDestroyedTypeLoc());
14899 }
14900
14901 TypeSourceInfo *ScopeTypeInfo = nullptr;
14902 if (E->getScopeTypeInfo()) {
14903 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
14904 E->getScopeTypeInfo(), ObjectType, nullptr);
14905 if (!ScopeTypeInfo)
14906 return ExprError();
14907 }
14908
14909 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
14910 E->getOperatorLoc(),
14911 E->isArrow(),
14912 SS,
14913 ScopeTypeInfo,
14914 E->getColonColonLoc(),
14915 E->getTildeLoc(),
14916 Destroyed);
14917}
14918
14919template <typename Derived>
14921 bool RequiresADL,
14922 LookupResult &R) {
14923 // Transform all the decls.
14924 bool AllEmptyPacks = true;
14925 for (auto *OldD : Old->decls()) {
14926 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
14927 if (!InstD) {
14928 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
14929 // This can happen because of dependent hiding.
14930 if (isa<UsingShadowDecl>(OldD))
14931 continue;
14932 else {
14933 R.clear();
14934 return true;
14935 }
14936 }
14937
14938 // Expand using pack declarations.
14939 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
14940 ArrayRef<NamedDecl*> Decls = SingleDecl;
14941 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
14942 Decls = UPD->expansions();
14943
14944 // Expand using declarations.
14945 for (auto *D : Decls) {
14946 if (auto *UD = dyn_cast<UsingDecl>(D)) {
14947 for (auto *SD : UD->shadows())
14948 R.addDecl(SD);
14949 } else {
14950 R.addDecl(D);
14951 }
14952 }
14953
14954 AllEmptyPacks &= Decls.empty();
14955 }
14956
14957 // C++ [temp.res]/8.4.2:
14958 // The program is ill-formed, no diagnostic required, if [...] lookup for
14959 // a name in the template definition found a using-declaration, but the
14960 // lookup in the corresponding scope in the instantiation odoes not find
14961 // any declarations because the using-declaration was a pack expansion and
14962 // the corresponding pack is empty
14963 if (AllEmptyPacks && !RequiresADL) {
14964 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
14965 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
14966 return true;
14967 }
14968
14969 // Resolve a kind, but don't do any further analysis. If it's
14970 // ambiguous, the callee needs to deal with it.
14971 R.resolveKind();
14972
14973 if (Old->hasTemplateKeyword() && !R.empty()) {
14975 getSema().FilterAcceptableTemplateNames(R,
14976 /*AllowFunctionTemplates=*/true,
14977 /*AllowDependent=*/true);
14978 if (R.empty()) {
14979 // If a 'template' keyword was used, a lookup that finds only non-template
14980 // names is an error.
14981 getSema().Diag(R.getNameLoc(),
14982 diag::err_template_kw_refers_to_non_template)
14984 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
14985 getSema().Diag(FoundDecl->getLocation(),
14986 diag::note_template_kw_refers_to_non_template)
14987 << R.getLookupName();
14988 return true;
14989 }
14990 }
14991
14992 return false;
14993}
14994
14995template <typename Derived>
15000
15001template <typename Derived>
15004 bool IsAddressOfOperand) {
15005 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
15007
15008 // Transform the declaration set.
15009 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
15010 return ExprError();
15011
15012 // Rebuild the nested-name qualifier, if present.
15013 CXXScopeSpec SS;
15014 if (Old->getQualifierLoc()) {
15015 NestedNameSpecifierLoc QualifierLoc
15016 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
15017 if (!QualifierLoc)
15018 return ExprError();
15019
15020 SS.Adopt(QualifierLoc);
15021 }
15022
15023 if (Old->getNamingClass()) {
15024 CXXRecordDecl *NamingClass
15025 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
15026 Old->getNameLoc(),
15027 Old->getNamingClass()));
15028 if (!NamingClass) {
15029 R.clear();
15030 return ExprError();
15031 }
15032
15033 R.setNamingClass(NamingClass);
15034 }
15035
15036 // Rebuild the template arguments, if any.
15037 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
15038 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
15039 if (Old->hasExplicitTemplateArgs() &&
15040 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15041 Old->getNumTemplateArgs(),
15042 TransArgs)) {
15043 R.clear();
15044 return ExprError();
15045 }
15046
15047 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
15048 // a non-static data member is named in an unevaluated operand, or when
15049 // a member is named in a dependent class scope function template explicit
15050 // specialization that is neither declared static nor with an explicit object
15051 // parameter.
15052 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
15053 return SemaRef.BuildPossibleImplicitMemberExpr(
15054 SS, TemplateKWLoc, R,
15055 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
15056 /*S=*/nullptr);
15057
15058 // If we have neither explicit template arguments, nor the template keyword,
15059 // it's a normal declaration name or member reference.
15060 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
15061 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
15062
15063 // If we have template arguments, then rebuild the template-id expression.
15064 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
15065 Old->requiresADL(), &TransArgs);
15066}
15067
15068template<typename Derived>
15071 bool ArgChanged = false;
15073 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15074 TypeSourceInfo *From = E->getArg(I);
15075 TypeLoc FromTL = From->getTypeLoc();
15076 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15077 TypeLocBuilder TLB;
15078 TLB.reserve(FromTL.getFullDataSize());
15079 QualType To = getDerived().TransformType(TLB, FromTL);
15080 if (To.isNull())
15081 return ExprError();
15082
15083 if (To == From->getType())
15084 Args.push_back(From);
15085 else {
15086 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15087 ArgChanged = true;
15088 }
15089 continue;
15090 }
15091
15092 ArgChanged = true;
15093
15094 // We have a pack expansion. Instantiate it.
15095 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15096 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15098 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15099
15100 // Determine whether the set of unexpanded parameter packs can and should
15101 // be expanded.
15102 bool Expand = true;
15103 bool RetainExpansion = false;
15104 UnsignedOrNone OrigNumExpansions =
15105 ExpansionTL.getTypePtr()->getNumExpansions();
15106 UnsignedOrNone NumExpansions = OrigNumExpansions;
15107 if (getDerived().TryExpandParameterPacks(
15108 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15109 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15110 RetainExpansion, NumExpansions))
15111 return ExprError();
15112
15113 if (!Expand) {
15114 // The transform has determined that we should perform a simple
15115 // transformation on the pack expansion, producing another pack
15116 // expansion.
15117 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15118
15119 TypeLocBuilder TLB;
15120 TLB.reserve(From->getTypeLoc().getFullDataSize());
15121
15122 QualType To = getDerived().TransformType(TLB, PatternTL);
15123 if (To.isNull())
15124 return ExprError();
15125
15126 To = getDerived().RebuildPackExpansionType(To,
15127 PatternTL.getSourceRange(),
15128 ExpansionTL.getEllipsisLoc(),
15129 NumExpansions);
15130 if (To.isNull())
15131 return ExprError();
15132
15133 PackExpansionTypeLoc ToExpansionTL
15134 = TLB.push<PackExpansionTypeLoc>(To);
15135 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15136 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15137 continue;
15138 }
15139
15140 // Expand the pack expansion by substituting for each argument in the
15141 // pack(s).
15142 for (unsigned I = 0; I != *NumExpansions; ++I) {
15143 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15144 TypeLocBuilder TLB;
15145 TLB.reserve(PatternTL.getFullDataSize());
15146 QualType To = getDerived().TransformType(TLB, PatternTL);
15147 if (To.isNull())
15148 return ExprError();
15149
15150 if (To->containsUnexpandedParameterPack()) {
15151 To = getDerived().RebuildPackExpansionType(To,
15152 PatternTL.getSourceRange(),
15153 ExpansionTL.getEllipsisLoc(),
15154 NumExpansions);
15155 if (To.isNull())
15156 return ExprError();
15157
15158 PackExpansionTypeLoc ToExpansionTL
15159 = TLB.push<PackExpansionTypeLoc>(To);
15160 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15161 }
15162
15163 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15164 }
15165
15166 if (!RetainExpansion)
15167 continue;
15168
15169 // If we're supposed to retain a pack expansion, do so by temporarily
15170 // forgetting the partially-substituted parameter pack.
15171 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15172
15173 TypeLocBuilder TLB;
15174 TLB.reserve(From->getTypeLoc().getFullDataSize());
15175
15176 QualType To = getDerived().TransformType(TLB, PatternTL);
15177 if (To.isNull())
15178 return ExprError();
15179
15180 To = getDerived().RebuildPackExpansionType(To,
15181 PatternTL.getSourceRange(),
15182 ExpansionTL.getEllipsisLoc(),
15183 NumExpansions);
15184 if (To.isNull())
15185 return ExprError();
15186
15187 PackExpansionTypeLoc ToExpansionTL
15188 = TLB.push<PackExpansionTypeLoc>(To);
15189 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15190 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15191 }
15192
15193 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15194 return E;
15195
15196 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15197 E->getEndLoc());
15198}
15199
15200template<typename Derived>
15204 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15205 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15206 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15207 Old->NumTemplateArgs, TransArgs))
15208 return ExprError();
15209
15210 return getDerived().RebuildConceptSpecializationExpr(
15211 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15212 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15213 &TransArgs);
15214}
15215
15216template<typename Derived>
15219 SmallVector<ParmVarDecl*, 4> TransParams;
15220 SmallVector<QualType, 4> TransParamTypes;
15221 Sema::ExtParameterInfoBuilder ExtParamInfos;
15222
15223 // C++2a [expr.prim.req]p2
15224 // Expressions appearing within a requirement-body are unevaluated operands.
15228
15230 getSema().Context, getSema().CurContext,
15231 E->getBody()->getBeginLoc());
15232
15233 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15234
15235 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15236 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15237 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15238
15239 for (ParmVarDecl *Param : TransParams)
15240 if (Param)
15241 Param->setDeclContext(Body);
15242
15243 // On failure to transform, TransformRequiresTypeParams returns an expression
15244 // in the event that the transformation of the type params failed in some way.
15245 // It is expected that this will result in a 'not satisfied' Requires clause
15246 // when instantiating.
15247 if (!TypeParamResult.isUnset())
15248 return TypeParamResult;
15249
15251 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15252 TransReqs))
15253 return ExprError();
15254
15255 for (concepts::Requirement *Req : TransReqs) {
15256 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15257 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15258 ER->getReturnTypeRequirement()
15259 .getTypeConstraintTemplateParameterList()->getParam(0)
15260 ->setDeclContext(Body);
15261 }
15262 }
15263 }
15264
15265 return getDerived().RebuildRequiresExpr(
15266 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15267 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15268}
15269
15270template<typename Derived>
15274 for (concepts::Requirement *Req : Reqs) {
15275 concepts::Requirement *TransReq = nullptr;
15276 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15277 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15278 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15279 TransReq = getDerived().TransformExprRequirement(ExprReq);
15280 else
15281 TransReq = getDerived().TransformNestedRequirement(
15283 if (!TransReq)
15284 return true;
15285 Transformed.push_back(TransReq);
15286 }
15287 return false;
15288}
15289
15290template<typename Derived>
15294 if (Req->isSubstitutionFailure()) {
15295 if (getDerived().AlwaysRebuild())
15296 return getDerived().RebuildTypeRequirement(
15298 return Req;
15299 }
15300 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15301 if (!TransType)
15302 return nullptr;
15303 return getDerived().RebuildTypeRequirement(TransType);
15304}
15305
15306template<typename Derived>
15309 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15310 if (Req->isExprSubstitutionFailure())
15311 TransExpr = Req->getExprSubstitutionDiagnostic();
15312 else {
15313 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15314 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15315 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15316 if (TransExprRes.isInvalid())
15317 return nullptr;
15318 TransExpr = TransExprRes.get();
15319 }
15320
15321 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15322 const auto &RetReq = Req->getReturnTypeRequirement();
15323 if (RetReq.isEmpty())
15324 TransRetReq.emplace();
15325 else if (RetReq.isSubstitutionFailure())
15326 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15327 else if (RetReq.isTypeConstraint()) {
15328 TemplateParameterList *OrigTPL =
15329 RetReq.getTypeConstraintTemplateParameterList();
15331 getDerived().TransformTemplateParameterList(OrigTPL);
15332 if (!TPL)
15333 return nullptr;
15334 TransRetReq.emplace(TPL);
15335 }
15336 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15337 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15338 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15339 Req->getNoexceptLoc(),
15340 std::move(*TransRetReq));
15341 return getDerived().RebuildExprRequirement(
15343 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15344}
15345
15346template<typename Derived>
15350 if (Req->hasInvalidConstraint()) {
15351 if (getDerived().AlwaysRebuild())
15352 return getDerived().RebuildNestedRequirement(
15354 return Req;
15355 }
15356 ExprResult TransConstraint =
15357 getDerived().TransformExpr(Req->getConstraintExpr());
15358 if (TransConstraint.isInvalid())
15359 return nullptr;
15360 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15361}
15362
15363template<typename Derived>
15366 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15367 if (!T)
15368 return ExprError();
15369
15370 if (!getDerived().AlwaysRebuild() &&
15372 return E;
15373
15374 ExprResult SubExpr;
15375 {
15378 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15379 if (SubExpr.isInvalid())
15380 return ExprError();
15381 }
15382
15383 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15384 SubExpr.get(), E->getEndLoc());
15385}
15386
15387template<typename Derived>
15390 ExprResult SubExpr;
15391 {
15394 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15395 if (SubExpr.isInvalid())
15396 return ExprError();
15397
15398 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15399 return E;
15400 }
15401
15402 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15403 SubExpr.get(), E->getEndLoc());
15404}
15405
15406template <typename Derived>
15408 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15409 TypeSourceInfo **RecoveryTSI) {
15410 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15411 DRE, AddrTaken, RecoveryTSI);
15412
15413 // Propagate both errors and recovered types, which return ExprEmpty.
15414 if (!NewDRE.isUsable())
15415 return NewDRE;
15416
15417 // We got an expr, wrap it up in parens.
15418 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15419 return PE;
15420 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15421 PE->getRParen());
15422}
15423
15424template <typename Derived>
15430
15431template <typename Derived>
15433 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15434 TypeSourceInfo **RecoveryTSI) {
15435 assert(E->getQualifierLoc());
15436 NestedNameSpecifierLoc QualifierLoc =
15437 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15438 if (!QualifierLoc)
15439 return ExprError();
15440 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15441
15442 // TODO: If this is a conversion-function-id, verify that the
15443 // destination type name (if present) resolves the same way after
15444 // instantiation as it did in the local scope.
15445
15446 DeclarationNameInfo NameInfo =
15447 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15448 if (!NameInfo.getName())
15449 return ExprError();
15450
15451 if (!E->hasExplicitTemplateArgs()) {
15452 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15453 // Note: it is sufficient to compare the Name component of NameInfo:
15454 // if name has not changed, DNLoc has not changed either.
15455 NameInfo.getName() == E->getDeclName())
15456 return E;
15457
15458 return getDerived().RebuildDependentScopeDeclRefExpr(
15459 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15460 IsAddressOfOperand, RecoveryTSI);
15461 }
15462
15463 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15464 if (getDerived().TransformTemplateArguments(
15465 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15466 return ExprError();
15467
15468 return getDerived().RebuildDependentScopeDeclRefExpr(
15469 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15470 RecoveryTSI);
15471}
15472
15473template<typename Derived>
15476 // CXXConstructExprs other than for list-initialization and
15477 // CXXTemporaryObjectExpr are always implicit, so when we have
15478 // a 1-argument construction we just transform that argument.
15479 if (getDerived().AllowSkippingCXXConstructExpr() &&
15480 ((E->getNumArgs() == 1 ||
15481 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15482 (!getDerived().DropCallArgument(E->getArg(0))) &&
15483 !E->isListInitialization()))
15484 return getDerived().TransformInitializer(E->getArg(0),
15485 /*DirectInit*/ false);
15486
15487 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15488
15489 QualType T = getDerived().TransformType(E->getType());
15490 if (T.isNull())
15491 return ExprError();
15492
15493 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15494 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15495 if (!Constructor)
15496 return ExprError();
15497
15498 bool ArgumentChanged = false;
15500 {
15503 E->isListInitialization());
15504 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15505 &ArgumentChanged))
15506 return ExprError();
15507 }
15508
15509 if (!getDerived().AlwaysRebuild() &&
15510 T == E->getType() &&
15511 Constructor == E->getConstructor() &&
15512 !ArgumentChanged) {
15513 // Mark the constructor as referenced.
15514 // FIXME: Instantiation-specific
15515 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15516 return E;
15517 }
15518
15519 return getDerived().RebuildCXXConstructExpr(
15520 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15521 E->hadMultipleCandidates(), E->isListInitialization(),
15522 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15523 E->getConstructionKind(), E->getParenOrBraceRange());
15524}
15525
15526template<typename Derived>
15529 QualType T = getDerived().TransformType(E->getType());
15530 if (T.isNull())
15531 return ExprError();
15532
15533 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15534 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15535 if (!Constructor)
15536 return ExprError();
15537
15538 if (!getDerived().AlwaysRebuild() &&
15539 T == E->getType() &&
15540 Constructor == E->getConstructor()) {
15541 // Mark the constructor as referenced.
15542 // FIXME: Instantiation-specific
15543 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15544 return E;
15545 }
15546
15547 return getDerived().RebuildCXXInheritedCtorInitExpr(
15548 T, E->getLocation(), Constructor,
15549 E->constructsVBase(), E->inheritedFromVBase());
15550}
15551
15552/// Transform a C++ temporary-binding expression.
15553///
15554/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15555/// transform the subexpression and return that.
15556template<typename Derived>
15559 if (auto *Dtor = E->getTemporary()->getDestructor())
15560 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15561 const_cast<CXXDestructorDecl *>(Dtor));
15562 return getDerived().TransformExpr(E->getSubExpr());
15563}
15564
15565/// Transform a C++ expression that contains cleanups that should
15566/// be run after the expression is evaluated.
15567///
15568/// Since ExprWithCleanups nodes are implicitly generated, we
15569/// just transform the subexpression and return that.
15570template<typename Derived>
15573 return getDerived().TransformExpr(E->getSubExpr());
15574}
15575
15576template<typename Derived>
15580 TypeSourceInfo *T =
15581 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15582 if (!T)
15583 return ExprError();
15584
15585 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15586 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15587 if (!Constructor)
15588 return ExprError();
15589
15590 bool ArgumentChanged = false;
15592 Args.reserve(E->getNumArgs());
15593 {
15596 E->isListInitialization());
15597 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15598 &ArgumentChanged))
15599 return ExprError();
15600
15601 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15602 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc());
15603 if (Res.isInvalid())
15604 return ExprError();
15605 Args = {Res.get()};
15606 }
15607 }
15608
15609 if (!getDerived().AlwaysRebuild() &&
15610 T == E->getTypeSourceInfo() &&
15611 Constructor == E->getConstructor() &&
15612 !ArgumentChanged) {
15613 // FIXME: Instantiation-specific
15614 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15615 return SemaRef.MaybeBindToTemporary(E);
15616 }
15617
15618 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15619 return getDerived().RebuildCXXTemporaryObjectExpr(
15620 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15621}
15622
15623template<typename Derived>
15626 // Transform any init-capture expressions before entering the scope of the
15627 // lambda body, because they are not semantically within that scope.
15628 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15629 struct TransformedInitCapture {
15630 // The location of the ... if the result is retaining a pack expansion.
15631 SourceLocation EllipsisLoc;
15632 // Zero or more expansions of the init-capture.
15633 SmallVector<InitCaptureInfoTy, 4> Expansions;
15634 };
15636 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15637 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15638 CEnd = E->capture_end();
15639 C != CEnd; ++C) {
15640 if (!E->isInitCapture(C))
15641 continue;
15642
15643 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15644 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15645
15646 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15647 UnsignedOrNone NumExpansions) {
15648 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15649 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15650
15651 if (NewExprInitResult.isInvalid()) {
15652 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15653 return;
15654 }
15655 Expr *NewExprInit = NewExprInitResult.get();
15656
15657 QualType NewInitCaptureType =
15658 getSema().buildLambdaInitCaptureInitialization(
15659 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15660 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15661 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15663 NewExprInit);
15664 Result.Expansions.push_back(
15665 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15666 };
15667
15668 // If this is an init-capture pack, consider expanding the pack now.
15669 if (OldVD->isParameterPack()) {
15670 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15671 ->getTypeLoc()
15674 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15675
15676 // Determine whether the set of unexpanded parameter packs can and should
15677 // be expanded.
15678 bool Expand = true;
15679 bool RetainExpansion = false;
15680 UnsignedOrNone OrigNumExpansions =
15681 ExpansionTL.getTypePtr()->getNumExpansions();
15682 UnsignedOrNone NumExpansions = OrigNumExpansions;
15683 if (getDerived().TryExpandParameterPacks(
15684 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15685 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15686 RetainExpansion, NumExpansions))
15687 return ExprError();
15688 assert(!RetainExpansion && "Should not need to retain expansion after a "
15689 "capture since it cannot be extended");
15690 if (Expand) {
15691 for (unsigned I = 0; I != *NumExpansions; ++I) {
15692 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15693 SubstInitCapture(SourceLocation(), std::nullopt);
15694 }
15695 } else {
15696 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15697 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15698 }
15699 } else {
15700 SubstInitCapture(SourceLocation(), std::nullopt);
15701 }
15702 }
15703
15704 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15705 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15706
15707 // Create the local class that will describe the lambda.
15708
15709 // FIXME: DependencyKind below is wrong when substituting inside a templated
15710 // context that isn't a DeclContext (such as a variable template), or when
15711 // substituting an unevaluated lambda inside of a function's parameter's type
15712 // - as parameter types are not instantiated from within a function's DC. We
15713 // use evaluation contexts to distinguish the function parameter case.
15716 DeclContext *DC = getSema().CurContext;
15717 // A RequiresExprBodyDecl is not interesting for dependencies.
15718 // For the following case,
15719 //
15720 // template <typename>
15721 // concept C = requires { [] {}; };
15722 //
15723 // template <class F>
15724 // struct Widget;
15725 //
15726 // template <C F>
15727 // struct Widget<F> {};
15728 //
15729 // While we are substituting Widget<F>, the parent of DC would be
15730 // the template specialization itself. Thus, the lambda expression
15731 // will be deemed as dependent even if there are no dependent template
15732 // arguments.
15733 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15734 while (DC->isRequiresExprBody())
15735 DC = DC->getParent();
15736 if ((getSema().isUnevaluatedContext() ||
15737 getSema().isConstantEvaluatedContext()) &&
15738 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15739 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
15740 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15741 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15742
15743 CXXRecordDecl *OldClass = E->getLambdaClass();
15744 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15745 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15746 E->getCaptureDefault());
15747 getDerived().transformedLocalDecl(OldClass, {Class});
15748
15749 CXXMethodDecl *NewCallOperator =
15750 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15751
15752 // Enter the scope of the lambda.
15753 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15754 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15755 E->hasExplicitParameters(), E->isMutable());
15756
15757 // Introduce the context of the call operator.
15758 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15759 /*NewThisContext*/false);
15760
15761 bool Invalid = false;
15762
15763 // Transform captures.
15764 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15765 CEnd = E->capture_end();
15766 C != CEnd; ++C) {
15767 // When we hit the first implicit capture, tell Sema that we've finished
15768 // the list of explicit captures.
15769 if (C->isImplicit())
15770 break;
15771
15772 // Capturing 'this' is trivial.
15773 if (C->capturesThis()) {
15774 // If this is a lambda that is part of a default member initialiser
15775 // and which we're instantiating outside the class that 'this' is
15776 // supposed to refer to, adjust the type of 'this' accordingly.
15777 //
15778 // Otherwise, leave the type of 'this' as-is.
15779 Sema::CXXThisScopeRAII ThisScope(
15780 getSema(),
15781 dyn_cast_if_present<CXXRecordDecl>(
15782 getSema().getFunctionLevelDeclContext()),
15783 Qualifiers());
15784 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15785 /*BuildAndDiagnose*/ true, nullptr,
15786 C->getCaptureKind() == LCK_StarThis);
15787 continue;
15788 }
15789 // Captured expression will be recaptured during captured variables
15790 // rebuilding.
15791 if (C->capturesVLAType())
15792 continue;
15793
15794 // Rebuild init-captures, including the implied field declaration.
15795 if (E->isInitCapture(C)) {
15796 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15797
15798 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15800
15801 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15802 ExprResult Init = Info.first;
15803 QualType InitQualType = Info.second;
15804 if (Init.isInvalid() || InitQualType.isNull()) {
15805 Invalid = true;
15806 break;
15807 }
15808 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15809 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15810 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15811 getSema().CurContext);
15812 if (!NewVD) {
15813 Invalid = true;
15814 break;
15815 }
15816 NewVDs.push_back(NewVD);
15817 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15818 // Cases we want to tackle:
15819 // ([C(Pack)] {}, ...)
15820 // But rule out cases e.g.
15821 // [...C = Pack()] {}
15822 if (NewC.EllipsisLoc.isInvalid())
15823 LSI->ContainsUnexpandedParameterPack |=
15824 Init.get()->containsUnexpandedParameterPack();
15825 }
15826
15827 if (Invalid)
15828 break;
15829
15830 getDerived().transformedLocalDecl(OldVD, NewVDs);
15831 continue;
15832 }
15833
15834 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15835
15836 // Determine the capture kind for Sema.
15838 : C->getCaptureKind() == LCK_ByCopy
15841 SourceLocation EllipsisLoc;
15842 if (C->isPackExpansion()) {
15843 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15844 bool ShouldExpand = false;
15845 bool RetainExpansion = false;
15846 UnsignedOrNone NumExpansions = std::nullopt;
15847 if (getDerived().TryExpandParameterPacks(
15848 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
15849 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
15850 RetainExpansion, NumExpansions)) {
15851 Invalid = true;
15852 continue;
15853 }
15854
15855 if (ShouldExpand) {
15856 // The transform has determined that we should perform an expansion;
15857 // transform and capture each of the arguments.
15858 // expansion of the pattern. Do so.
15859 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
15860 for (unsigned I = 0; I != *NumExpansions; ++I) {
15861 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15862 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
15863 getDerived().TransformDecl(C->getLocation(), Pack));
15864 if (!CapturedVar) {
15865 Invalid = true;
15866 continue;
15867 }
15868
15869 // Capture the transformed variable.
15870 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
15871 }
15872
15873 // FIXME: Retain a pack expansion if RetainExpansion is true.
15874
15875 continue;
15876 }
15877
15878 EllipsisLoc = C->getEllipsisLoc();
15879 }
15880
15881 // Transform the captured variable.
15882 auto *CapturedVar = cast_or_null<ValueDecl>(
15883 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15884 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
15885 Invalid = true;
15886 continue;
15887 }
15888
15889 // This is not an init-capture; however it contains an unexpanded pack e.g.
15890 // ([Pack] {}(), ...)
15891 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
15892 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
15893
15894 // Capture the transformed variable.
15895 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
15896 EllipsisLoc);
15897 }
15898 getSema().finishLambdaExplicitCaptures(LSI);
15899
15900 // Transform the template parameters, and add them to the current
15901 // instantiation scope. The null case is handled correctly.
15902 auto TPL = getDerived().TransformTemplateParameterList(
15903 E->getTemplateParameterList());
15904 LSI->GLTemplateParameterList = TPL;
15905 if (TPL) {
15906 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
15907 TPL);
15908 LSI->ContainsUnexpandedParameterPack |=
15909 TPL->containsUnexpandedParameterPack();
15910 }
15911
15912 TypeLocBuilder NewCallOpTLBuilder;
15913 TypeLoc OldCallOpTypeLoc =
15914 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
15915 QualType NewCallOpType =
15916 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
15917 if (NewCallOpType.isNull())
15918 return ExprError();
15919 LSI->ContainsUnexpandedParameterPack |=
15920 NewCallOpType->containsUnexpandedParameterPack();
15921 TypeSourceInfo *NewCallOpTSI =
15922 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
15923
15924 // The type may be an AttributedType or some other kind of sugar;
15925 // get the actual underlying FunctionProtoType.
15926 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
15927 assert(FPTL && "Not a FunctionProtoType?");
15928
15929 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
15930 if (!TRC.ArgPackSubstIndex)
15932
15933 getSema().CompleteLambdaCallOperator(
15934 NewCallOperator, E->getCallOperator()->getLocation(),
15935 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
15936 E->getCallOperator()->getConstexprKind(),
15937 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
15938 E->hasExplicitResultType());
15939
15940 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
15941 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
15942
15943 {
15944 // Number the lambda for linkage purposes if necessary.
15945 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
15946
15947 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
15948 if (getDerived().ReplacingOriginal()) {
15949 Numbering = OldClass->getLambdaNumbering();
15950 }
15951
15952 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
15953 }
15954
15955 // FIXME: Sema's lambda-building mechanism expects us to push an expression
15956 // evaluation context even if we're not transforming the function body.
15957 getSema().PushExpressionEvaluationContextForFunction(
15959 E->getCallOperator());
15960
15961 StmtResult Body;
15962 {
15963 Sema::NonSFINAEContext _(getSema());
15966 C.PointOfInstantiation = E->getBody()->getBeginLoc();
15967 getSema().pushCodeSynthesisContext(C);
15968
15969 // Instantiate the body of the lambda expression.
15970 Body = Invalid ? StmtError()
15971 : getDerived().TransformLambdaBody(E, E->getBody());
15972
15973 getSema().popCodeSynthesisContext();
15974 }
15975
15976 // ActOnLambda* will pop the function scope for us.
15977 FuncScopeCleanup.disable();
15978
15979 if (Body.isInvalid()) {
15980 SavedContext.pop();
15981 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
15982 /*IsInstantiation=*/true);
15983 return ExprError();
15984 }
15985
15986 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
15987 /*IsInstantiation=*/true,
15988 /*RetainFunctionScopeInfo=*/true);
15989 SavedContext.pop();
15990
15991 // Recompute the dependency of the lambda so that we can defer the lambda call
15992 // construction until after we have all the necessary template arguments. For
15993 // example, given
15994 //
15995 // template <class> struct S {
15996 // template <class U>
15997 // using Type = decltype([](U){}(42.0));
15998 // };
15999 // void foo() {
16000 // using T = S<int>::Type<float>;
16001 // ^~~~~~
16002 // }
16003 //
16004 // We would end up here from instantiating S<int> when ensuring its
16005 // completeness. That would transform the lambda call expression regardless of
16006 // the absence of the corresponding argument for U.
16007 //
16008 // Going ahead with unsubstituted type U makes things worse: we would soon
16009 // compare the argument type (which is float) against the parameter U
16010 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
16011 // error suggesting unmatched types 'U' and 'float'!
16012 //
16013 // That said, everything will be fine if we defer that semantic checking.
16014 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
16015 // dependent. Since the CallExpr's dependency boils down to the lambda's
16016 // dependency in this case, we can harness that by recomputing the dependency
16017 // from the instantiation arguments.
16018 //
16019 // FIXME: Creating the type of a lambda requires us to have a dependency
16020 // value, which happens before its substitution. We update its dependency
16021 // *after* the substitution in case we can't decide the dependency
16022 // so early, e.g. because we want to see if any of the *substituted*
16023 // parameters are dependent.
16024 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
16025 Class->setLambdaDependencyKind(DependencyKind);
16026
16027 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
16028 Body.get()->getEndLoc(), LSI);
16029}
16030
16031template<typename Derived>
16036
16037template<typename Derived>
16040 // Transform captures.
16042 CEnd = E->capture_end();
16043 C != CEnd; ++C) {
16044 // When we hit the first implicit capture, tell Sema that we've finished
16045 // the list of explicit captures.
16046 if (!C->isImplicit())
16047 continue;
16048
16049 // Capturing 'this' is trivial.
16050 if (C->capturesThis()) {
16051 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16052 /*BuildAndDiagnose*/ true, nullptr,
16053 C->getCaptureKind() == LCK_StarThis);
16054 continue;
16055 }
16056 // Captured expression will be recaptured during captured variables
16057 // rebuilding.
16058 if (C->capturesVLAType())
16059 continue;
16060
16061 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16062 assert(!E->isInitCapture(C) && "implicit init-capture?");
16063
16064 // Transform the captured variable.
16065 VarDecl *CapturedVar = cast_or_null<VarDecl>(
16066 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16067 if (!CapturedVar || CapturedVar->isInvalidDecl())
16068 return StmtError();
16069
16070 // Capture the transformed variable.
16071 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16072 }
16073
16074 return S;
16075}
16076
16077template<typename Derived>
16081 TypeSourceInfo *T =
16082 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16083 if (!T)
16084 return ExprError();
16085
16086 bool ArgumentChanged = false;
16088 Args.reserve(E->getNumArgs());
16089 {
16093 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16094 &ArgumentChanged))
16095 return ExprError();
16096 }
16097
16098 if (!getDerived().AlwaysRebuild() &&
16099 T == E->getTypeSourceInfo() &&
16100 !ArgumentChanged)
16101 return E;
16102
16103 // FIXME: we're faking the locations of the commas
16104 return getDerived().RebuildCXXUnresolvedConstructExpr(
16105 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16106}
16107
16108template<typename Derived>
16112 // Transform the base of the expression.
16113 ExprResult Base((Expr*) nullptr);
16114 Expr *OldBase;
16115 QualType BaseType;
16116 QualType ObjectType;
16117 if (!E->isImplicitAccess()) {
16118 OldBase = E->getBase();
16119 Base = getDerived().TransformExpr(OldBase);
16120 if (Base.isInvalid())
16121 return ExprError();
16122
16123 // Start the member reference and compute the object's type.
16124 ParsedType ObjectTy;
16125 bool MayBePseudoDestructor = false;
16126 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16127 E->getOperatorLoc(),
16128 E->isArrow()? tok::arrow : tok::period,
16129 ObjectTy,
16130 MayBePseudoDestructor);
16131 if (Base.isInvalid())
16132 return ExprError();
16133
16134 ObjectType = ObjectTy.get();
16135 BaseType = ((Expr*) Base.get())->getType();
16136 } else {
16137 OldBase = nullptr;
16138 BaseType = getDerived().TransformType(E->getBaseType());
16139 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16140 }
16141
16142 // Transform the first part of the nested-name-specifier that qualifies
16143 // the member name.
16144 NamedDecl *FirstQualifierInScope
16145 = getDerived().TransformFirstQualifierInScope(
16146 E->getFirstQualifierFoundInScope(),
16147 E->getQualifierLoc().getBeginLoc());
16148
16149 NestedNameSpecifierLoc QualifierLoc;
16150 if (E->getQualifier()) {
16151 QualifierLoc
16152 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16153 ObjectType,
16154 FirstQualifierInScope);
16155 if (!QualifierLoc)
16156 return ExprError();
16157 }
16158
16159 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16160
16161 // TODO: If this is a conversion-function-id, verify that the
16162 // destination type name (if present) resolves the same way after
16163 // instantiation as it did in the local scope.
16164
16165 DeclarationNameInfo NameInfo
16166 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16167 if (!NameInfo.getName())
16168 return ExprError();
16169
16170 if (!E->hasExplicitTemplateArgs()) {
16171 // This is a reference to a member without an explicitly-specified
16172 // template argument list. Optimize for this common case.
16173 if (!getDerived().AlwaysRebuild() &&
16174 Base.get() == OldBase &&
16175 BaseType == E->getBaseType() &&
16176 QualifierLoc == E->getQualifierLoc() &&
16177 NameInfo.getName() == E->getMember() &&
16178 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16179 return E;
16180
16181 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16182 BaseType,
16183 E->isArrow(),
16184 E->getOperatorLoc(),
16185 QualifierLoc,
16186 TemplateKWLoc,
16187 FirstQualifierInScope,
16188 NameInfo,
16189 /*TemplateArgs*/nullptr);
16190 }
16191
16192 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16193 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16194 E->getNumTemplateArgs(),
16195 TransArgs))
16196 return ExprError();
16197
16198 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16199 BaseType,
16200 E->isArrow(),
16201 E->getOperatorLoc(),
16202 QualifierLoc,
16203 TemplateKWLoc,
16204 FirstQualifierInScope,
16205 NameInfo,
16206 &TransArgs);
16207}
16208
16209template <typename Derived>
16211 UnresolvedMemberExpr *Old) {
16212 // Transform the base of the expression.
16213 ExprResult Base((Expr *)nullptr);
16214 QualType BaseType;
16215 if (!Old->isImplicitAccess()) {
16216 Base = getDerived().TransformExpr(Old->getBase());
16217 if (Base.isInvalid())
16218 return ExprError();
16219 Base =
16220 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16221 if (Base.isInvalid())
16222 return ExprError();
16223 BaseType = Base.get()->getType();
16224 } else {
16225 BaseType = getDerived().TransformType(Old->getBaseType());
16226 }
16227
16228 NestedNameSpecifierLoc QualifierLoc;
16229 if (Old->getQualifierLoc()) {
16230 QualifierLoc =
16231 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16232 if (!QualifierLoc)
16233 return ExprError();
16234 }
16235
16236 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16237
16238 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16239
16240 // Transform the declaration set.
16241 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16242 return ExprError();
16243
16244 // Determine the naming class.
16245 if (Old->getNamingClass()) {
16246 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16247 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16248 if (!NamingClass)
16249 return ExprError();
16250
16251 R.setNamingClass(NamingClass);
16252 }
16253
16254 TemplateArgumentListInfo TransArgs;
16255 if (Old->hasExplicitTemplateArgs()) {
16256 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16257 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16258 if (getDerived().TransformTemplateArguments(
16259 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16260 return ExprError();
16261 }
16262
16263 // FIXME: to do this check properly, we will need to preserve the
16264 // first-qualifier-in-scope here, just in case we had a dependent
16265 // base (and therefore couldn't do the check) and a
16266 // nested-name-qualifier (and therefore could do the lookup).
16267 NamedDecl *FirstQualifierInScope = nullptr;
16268
16269 return getDerived().RebuildUnresolvedMemberExpr(
16270 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16271 TemplateKWLoc, FirstQualifierInScope, R,
16272 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16273}
16274
16275template<typename Derived>
16280 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16281 if (SubExpr.isInvalid())
16282 return ExprError();
16283
16284 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16285 return E;
16286
16287 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16288}
16289
16290template<typename Derived>
16293 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16294 if (Pattern.isInvalid())
16295 return ExprError();
16296
16297 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16298 return E;
16299
16300 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16301 E->getNumExpansions());
16302}
16303
16304template <typename Derived>
16306 ArrayRef<TemplateArgument> PackArgs) {
16308 for (const TemplateArgument &Arg : PackArgs) {
16309 if (!Arg.isPackExpansion()) {
16310 Result = *Result + 1;
16311 continue;
16312 }
16313
16314 TemplateArgumentLoc ArgLoc;
16315 InventTemplateArgumentLoc(Arg, ArgLoc);
16316
16317 // Find the pattern of the pack expansion.
16318 SourceLocation Ellipsis;
16319 UnsignedOrNone OrigNumExpansions = std::nullopt;
16320 TemplateArgumentLoc Pattern =
16321 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16322 OrigNumExpansions);
16323
16324 // Substitute under the pack expansion. Do not expand the pack (yet).
16325 TemplateArgumentLoc OutPattern;
16326 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16327 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16328 /*Uneval*/ true))
16329 return 1u;
16330
16331 // See if we can determine the number of arguments from the result.
16332 UnsignedOrNone NumExpansions =
16333 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16334 if (!NumExpansions) {
16335 // No: we must be in an alias template expansion, and we're going to
16336 // need to actually expand the packs.
16337 Result = std::nullopt;
16338 break;
16339 }
16340
16341 Result = *Result + *NumExpansions;
16342 }
16343 return Result;
16344}
16345
16346template<typename Derived>
16349 // If E is not value-dependent, then nothing will change when we transform it.
16350 // Note: This is an instantiation-centric view.
16351 if (!E->isValueDependent())
16352 return E;
16353
16356
16358 TemplateArgument ArgStorage;
16359
16360 // Find the argument list to transform.
16361 if (E->isPartiallySubstituted()) {
16362 PackArgs = E->getPartialArguments();
16363 } else if (E->isValueDependent()) {
16364 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16365 bool ShouldExpand = false;
16366 bool RetainExpansion = false;
16367 UnsignedOrNone NumExpansions = std::nullopt;
16368 if (getDerived().TryExpandParameterPacks(
16369 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16370 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16371 RetainExpansion, NumExpansions))
16372 return ExprError();
16373
16374 // If we need to expand the pack, build a template argument from it and
16375 // expand that.
16376 if (ShouldExpand) {
16377 auto *Pack = E->getPack();
16378 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16379 ArgStorage = getSema().Context.getPackExpansionType(
16380 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16381 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16382 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16383 } else {
16384 auto *VD = cast<ValueDecl>(Pack);
16385 ExprResult DRE = getSema().BuildDeclRefExpr(
16386 VD, VD->getType().getNonLValueExprType(getSema().Context),
16387 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16388 E->getPackLoc());
16389 if (DRE.isInvalid())
16390 return ExprError();
16391 ArgStorage = TemplateArgument(
16392 new (getSema().Context)
16393 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16394 /*IsCanonical=*/false);
16395 }
16396 PackArgs = ArgStorage;
16397 }
16398 }
16399
16400 // If we're not expanding the pack, just transform the decl.
16401 if (!PackArgs.size()) {
16402 auto *Pack = cast_or_null<NamedDecl>(
16403 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16404 if (!Pack)
16405 return ExprError();
16406 return getDerived().RebuildSizeOfPackExpr(
16407 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16408 std::nullopt, {});
16409 }
16410
16411 // Try to compute the result without performing a partial substitution.
16413 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16414
16415 // Common case: we could determine the number of expansions without
16416 // substituting.
16417 if (Result)
16418 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16419 E->getPackLoc(),
16420 E->getRParenLoc(), *Result, {});
16421
16422 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16423 E->getPackLoc());
16424 {
16425 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16427 Derived, const TemplateArgument*> PackLocIterator;
16428 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16429 PackLocIterator(*this, PackArgs.end()),
16430 TransformedPackArgs, /*Uneval*/true))
16431 return ExprError();
16432 }
16433
16434 // Check whether we managed to fully-expand the pack.
16435 // FIXME: Is it possible for us to do so and not hit the early exit path?
16437 bool PartialSubstitution = false;
16438 for (auto &Loc : TransformedPackArgs.arguments()) {
16439 Args.push_back(Loc.getArgument());
16440 if (Loc.getArgument().isPackExpansion())
16441 PartialSubstitution = true;
16442 }
16443
16444 if (PartialSubstitution)
16445 return getDerived().RebuildSizeOfPackExpr(
16446 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16447 std::nullopt, Args);
16448
16449 return getDerived().RebuildSizeOfPackExpr(
16450 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16451 /*Length=*/static_cast<unsigned>(Args.size()),
16452 /*PartialArgs=*/{});
16453}
16454
16455template <typename Derived>
16458 if (!E->isValueDependent())
16459 return E;
16460
16461 // Transform the index
16462 ExprResult IndexExpr;
16463 {
16464 EnterExpressionEvaluationContext ConstantContext(
16466 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16467 if (IndexExpr.isInvalid())
16468 return ExprError();
16469 }
16470
16471 SmallVector<Expr *, 5> ExpandedExprs;
16472 bool FullySubstituted = true;
16473 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16474 Expr *Pattern = E->getPackIdExpression();
16476 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16477 Unexpanded);
16478 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16479
16480 // Determine whether the set of unexpanded parameter packs can and should
16481 // be expanded.
16482 bool ShouldExpand = true;
16483 bool RetainExpansion = false;
16484 UnsignedOrNone OrigNumExpansions = std::nullopt,
16485 NumExpansions = std::nullopt;
16486 if (getDerived().TryExpandParameterPacks(
16487 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16488 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16489 RetainExpansion, NumExpansions))
16490 return true;
16491 if (!ShouldExpand) {
16492 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16493 ExprResult Pack = getDerived().TransformExpr(Pattern);
16494 if (Pack.isInvalid())
16495 return ExprError();
16496 return getDerived().RebuildPackIndexingExpr(
16497 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16498 {}, /*FullySubstituted=*/false);
16499 }
16500 for (unsigned I = 0; I != *NumExpansions; ++I) {
16501 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16502 ExprResult Out = getDerived().TransformExpr(Pattern);
16503 if (Out.isInvalid())
16504 return true;
16505 if (Out.get()->containsUnexpandedParameterPack()) {
16506 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16507 OrigNumExpansions);
16508 if (Out.isInvalid())
16509 return true;
16510 FullySubstituted = false;
16511 }
16512 ExpandedExprs.push_back(Out.get());
16513 }
16514 // If we're supposed to retain a pack expansion, do so by temporarily
16515 // forgetting the partially-substituted parameter pack.
16516 if (RetainExpansion) {
16517 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16518
16519 ExprResult Out = getDerived().TransformExpr(Pattern);
16520 if (Out.isInvalid())
16521 return true;
16522
16523 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16524 OrigNumExpansions);
16525 if (Out.isInvalid())
16526 return true;
16527 FullySubstituted = false;
16528 ExpandedExprs.push_back(Out.get());
16529 }
16530 } else if (!E->expandsToEmptyPack()) {
16531 if (getDerived().TransformExprs(E->getExpressions().data(),
16532 E->getExpressions().size(), false,
16533 ExpandedExprs))
16534 return ExprError();
16535 }
16536
16537 return getDerived().RebuildPackIndexingExpr(
16538 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16539 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16540}
16541
16542template <typename Derived>
16545 if (!getSema().ArgPackSubstIndex)
16546 // We aren't expanding the parameter pack, so just return ourselves.
16547 return E;
16548
16549 TemplateArgument Pack = E->getArgumentPack();
16551 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16552 E->getAssociatedDecl(), E->getParameterPack(),
16553 E->getParameterPackLocation(), Arg, SemaRef.getPackIndex(Pack),
16554 E->getFinal());
16555}
16556
16557template <typename Derived>
16560 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16561 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16562 if (Replacement.isInvalid())
16563 return true;
16564
16565 Decl *AssociatedDecl =
16566 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16567 if (!AssociatedDecl)
16568 return true;
16569
16570 if (Replacement.get() == OrigReplacement &&
16571 AssociatedDecl == E->getAssociatedDecl())
16572 return E;
16573
16574 auto getParamAndType = [E](Decl *AssociatedDecl)
16575 -> std::tuple<NonTypeTemplateParmDecl *, QualType> {
16576 auto [PDecl, Arg] =
16577 getReplacedTemplateParameter(AssociatedDecl, E->getIndex());
16578 auto *Param = cast<NonTypeTemplateParmDecl>(PDecl);
16579 if (Arg.isNull())
16580 return {Param, Param->getType()};
16581 if (UnsignedOrNone PackIndex = E->getPackIndex())
16582 Arg = Arg.getPackAsArray()[*PackIndex];
16583 return {Param, Arg.getNonTypeTemplateArgumentType()};
16584 };
16585
16586 // If the replacement expression did not change, and the parameter type
16587 // did not change, we can skip the semantic action because it would
16588 // produce the same result anyway.
16589 if (auto [Param, ParamType] = getParamAndType(AssociatedDecl);
16590 !SemaRef.Context.hasSameType(
16591 ParamType, std::get<1>(getParamAndType(E->getAssociatedDecl()))) ||
16592 Replacement.get() != OrigReplacement) {
16593 // When transforming the replacement expression previously, all Sema
16594 // specific annotations, such as implicit casts, are discarded. Calling the
16595 // corresponding sema action is necessary to recover those. Otherwise,
16596 // equivalency of the result would be lost.
16597 TemplateArgument SugaredConverted, CanonicalConverted;
16598 Replacement = SemaRef.CheckTemplateArgument(
16599 Param, ParamType, Replacement.get(), SugaredConverted,
16600 CanonicalConverted,
16601 /*StrictCheck=*/false, Sema::CTAK_Specified);
16602 if (Replacement.isInvalid())
16603 return true;
16604 } else {
16605 // Otherwise, the same expression would have been produced.
16606 Replacement = E->getReplacement();
16607 }
16608
16609 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16610 AssociatedDecl, E->getParameter(), E->getNameLoc(),
16611 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
16612 E->getPackIndex(), E->getFinal());
16613}
16614
16615template<typename Derived>
16618 // Default behavior is to do nothing with this transformation.
16619 return E;
16620}
16621
16622template<typename Derived>
16626 return getDerived().TransformExpr(E->getSubExpr());
16627}
16628
16629template<typename Derived>
16632 UnresolvedLookupExpr *Callee = nullptr;
16633 if (Expr *OldCallee = E->getCallee()) {
16634 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16635 if (CalleeResult.isInvalid())
16636 return ExprError();
16637 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16638 }
16639
16640 Expr *Pattern = E->getPattern();
16641
16643 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16644 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16645
16646 // Determine whether the set of unexpanded parameter packs can and should
16647 // be expanded.
16648 bool Expand = true;
16649 bool RetainExpansion = false;
16650 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16651 NumExpansions = OrigNumExpansions;
16652 if (getDerived().TryExpandParameterPacks(
16653 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16654 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16655 NumExpansions))
16656 return true;
16657
16658 if (!Expand) {
16659 // Do not expand any packs here, just transform and rebuild a fold
16660 // expression.
16661 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16662
16663 ExprResult LHS =
16664 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16665 if (LHS.isInvalid())
16666 return true;
16667
16668 ExprResult RHS =
16669 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16670 if (RHS.isInvalid())
16671 return true;
16672
16673 if (!getDerived().AlwaysRebuild() &&
16674 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16675 return E;
16676
16677 return getDerived().RebuildCXXFoldExpr(
16678 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16679 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16680 }
16681
16682 // Formally a fold expression expands to nested parenthesized expressions.
16683 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16684 // them.
16685 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16686 SemaRef.Diag(E->getEllipsisLoc(),
16687 clang::diag::err_fold_expression_limit_exceeded)
16688 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16689 << E->getSourceRange();
16690 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16691 return ExprError();
16692 }
16693
16694 // The transform has determined that we should perform an elementwise
16695 // expansion of the pattern. Do so.
16696 ExprResult Result = getDerived().TransformExpr(E->getInit());
16697 if (Result.isInvalid())
16698 return true;
16699 bool LeftFold = E->isLeftFold();
16700
16701 // If we're retaining an expansion for a right fold, it is the innermost
16702 // component and takes the init (if any).
16703 if (!LeftFold && RetainExpansion) {
16704 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16705
16706 ExprResult Out = getDerived().TransformExpr(Pattern);
16707 if (Out.isInvalid())
16708 return true;
16709
16710 Result = getDerived().RebuildCXXFoldExpr(
16711 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16712 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16713 if (Result.isInvalid())
16714 return true;
16715 }
16716
16717 bool WarnedOnComparison = false;
16718 for (unsigned I = 0; I != *NumExpansions; ++I) {
16719 Sema::ArgPackSubstIndexRAII SubstIndex(
16720 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16721 ExprResult Out = getDerived().TransformExpr(Pattern);
16722 if (Out.isInvalid())
16723 return true;
16724
16725 if (Out.get()->containsUnexpandedParameterPack()) {
16726 // We still have a pack; retain a pack expansion for this slice.
16727 Result = getDerived().RebuildCXXFoldExpr(
16728 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16729 E->getOperator(), E->getEllipsisLoc(),
16730 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16731 OrigNumExpansions);
16732 } else if (Result.isUsable()) {
16733 // We've got down to a single element; build a binary operator.
16734 Expr *LHS = LeftFold ? Result.get() : Out.get();
16735 Expr *RHS = LeftFold ? Out.get() : Result.get();
16736 if (Callee) {
16737 UnresolvedSet<16> Functions;
16738 Functions.append(Callee->decls_begin(), Callee->decls_end());
16739 Result = getDerived().RebuildCXXOperatorCallExpr(
16740 BinaryOperator::getOverloadedOperator(E->getOperator()),
16741 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16742 Functions, LHS, RHS);
16743 } else {
16744 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16745 E->getOperator(), LHS, RHS,
16746 /*ForFoldExpresion=*/true);
16747 if (!WarnedOnComparison && Result.isUsable()) {
16748 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16749 BO && BO->isComparisonOp()) {
16750 WarnedOnComparison = true;
16751 SemaRef.Diag(BO->getBeginLoc(),
16752 diag::warn_comparison_in_fold_expression)
16753 << BO->getOpcodeStr();
16754 }
16755 }
16756 }
16757 } else
16758 Result = Out;
16759
16760 if (Result.isInvalid())
16761 return true;
16762 }
16763
16764 // If we're retaining an expansion for a left fold, it is the outermost
16765 // component and takes the complete expansion so far as its init (if any).
16766 if (LeftFold && RetainExpansion) {
16767 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16768
16769 ExprResult Out = getDerived().TransformExpr(Pattern);
16770 if (Out.isInvalid())
16771 return true;
16772
16773 Result = getDerived().RebuildCXXFoldExpr(
16774 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16775 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16776 if (Result.isInvalid())
16777 return true;
16778 }
16779
16780 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16781 PE->setIsProducedByFoldExpansion();
16782
16783 // If we had no init and an empty pack, and we're not retaining an expansion,
16784 // then produce a fallback value or error.
16785 if (Result.isUnset())
16786 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16787 E->getOperator());
16788 return Result;
16789}
16790
16791template <typename Derived>
16794 SmallVector<Expr *, 4> TransformedInits;
16795 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16796
16797 QualType T = getDerived().TransformType(E->getType());
16798
16799 bool ArgChanged = false;
16800
16801 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16802 TransformedInits, &ArgChanged))
16803 return ExprError();
16804
16805 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16806 return E;
16807
16808 return getDerived().RebuildCXXParenListInitExpr(
16809 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16810 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16811}
16812
16813template<typename Derived>
16817 return getDerived().TransformExpr(E->getSubExpr());
16818}
16819
16820template<typename Derived>
16823 return SemaRef.MaybeBindToTemporary(E);
16824}
16825
16826template<typename Derived>
16829 return E;
16830}
16831
16832template<typename Derived>
16835 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16836 if (SubExpr.isInvalid())
16837 return ExprError();
16838
16839 if (!getDerived().AlwaysRebuild() &&
16840 SubExpr.get() == E->getSubExpr())
16841 return E;
16842
16843 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16844}
16845
16846template<typename Derived>
16849 // Transform each of the elements.
16850 SmallVector<Expr *, 8> Elements;
16851 bool ArgChanged = false;
16852 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
16853 /*IsCall=*/false, Elements, &ArgChanged))
16854 return ExprError();
16855
16856 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16857 return SemaRef.MaybeBindToTemporary(E);
16858
16859 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
16860 Elements.data(),
16861 Elements.size());
16862}
16863
16864template<typename Derived>
16868 // Transform each of the elements.
16870 bool ArgChanged = false;
16871 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
16872 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
16873
16874 if (OrigElement.isPackExpansion()) {
16875 // This key/value element is a pack expansion.
16877 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
16878 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
16879 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16880
16881 // Determine whether the set of unexpanded parameter packs can
16882 // and should be expanded.
16883 bool Expand = true;
16884 bool RetainExpansion = false;
16885 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
16886 UnsignedOrNone NumExpansions = OrigNumExpansions;
16887 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
16888 OrigElement.Value->getEndLoc());
16889 if (getDerived().TryExpandParameterPacks(
16890 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
16891 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16892 NumExpansions))
16893 return ExprError();
16894
16895 if (!Expand) {
16896 // The transform has determined that we should perform a simple
16897 // transformation on the pack expansion, producing another pack
16898 // expansion.
16899 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16900 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16901 if (Key.isInvalid())
16902 return ExprError();
16903
16904 if (Key.get() != OrigElement.Key)
16905 ArgChanged = true;
16906
16907 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16908 if (Value.isInvalid())
16909 return ExprError();
16910
16911 if (Value.get() != OrigElement.Value)
16912 ArgChanged = true;
16913
16914 ObjCDictionaryElement Expansion = {
16915 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
16916 };
16917 Elements.push_back(Expansion);
16918 continue;
16919 }
16920
16921 // Record right away that the argument was changed. This needs
16922 // to happen even if the array expands to nothing.
16923 ArgChanged = true;
16924
16925 // The transform has determined that we should perform an elementwise
16926 // expansion of the pattern. Do so.
16927 for (unsigned I = 0; I != *NumExpansions; ++I) {
16928 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16929 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16930 if (Key.isInvalid())
16931 return ExprError();
16932
16933 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16934 if (Value.isInvalid())
16935 return ExprError();
16936
16937 ObjCDictionaryElement Element = {
16938 Key.get(), Value.get(), SourceLocation(), NumExpansions
16939 };
16940
16941 // If any unexpanded parameter packs remain, we still have a
16942 // pack expansion.
16943 // FIXME: Can this really happen?
16944 if (Key.get()->containsUnexpandedParameterPack() ||
16945 Value.get()->containsUnexpandedParameterPack())
16946 Element.EllipsisLoc = OrigElement.EllipsisLoc;
16947
16948 Elements.push_back(Element);
16949 }
16950
16951 // FIXME: Retain a pack expansion if RetainExpansion is true.
16952
16953 // We've finished with this pack expansion.
16954 continue;
16955 }
16956
16957 // Transform and check key.
16958 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16959 if (Key.isInvalid())
16960 return ExprError();
16961
16962 if (Key.get() != OrigElement.Key)
16963 ArgChanged = true;
16964
16965 // Transform and check value.
16967 = getDerived().TransformExpr(OrigElement.Value);
16968 if (Value.isInvalid())
16969 return ExprError();
16970
16971 if (Value.get() != OrigElement.Value)
16972 ArgChanged = true;
16973
16974 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
16975 std::nullopt};
16976 Elements.push_back(Element);
16977 }
16978
16979 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16980 return SemaRef.MaybeBindToTemporary(E);
16981
16982 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
16983 Elements);
16984}
16985
16986template<typename Derived>
16989 TypeSourceInfo *EncodedTypeInfo
16990 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
16991 if (!EncodedTypeInfo)
16992 return ExprError();
16993
16994 if (!getDerived().AlwaysRebuild() &&
16995 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
16996 return E;
16997
16998 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
16999 EncodedTypeInfo,
17000 E->getRParenLoc());
17001}
17002
17003template<typename Derived>
17006 // This is a kind of implicit conversion, and it needs to get dropped
17007 // and recomputed for the same general reasons that ImplicitCastExprs
17008 // do, as well a more specific one: this expression is only valid when
17009 // it appears *immediately* as an argument expression.
17010 return getDerived().TransformExpr(E->getSubExpr());
17011}
17012
17013template<typename Derived>
17016 TypeSourceInfo *TSInfo
17017 = getDerived().TransformType(E->getTypeInfoAsWritten());
17018 if (!TSInfo)
17019 return ExprError();
17020
17021 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
17022 if (Result.isInvalid())
17023 return ExprError();
17024
17025 if (!getDerived().AlwaysRebuild() &&
17026 TSInfo == E->getTypeInfoAsWritten() &&
17027 Result.get() == E->getSubExpr())
17028 return E;
17029
17030 return SemaRef.ObjC().BuildObjCBridgedCast(
17031 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
17032 Result.get());
17033}
17034
17035template <typename Derived>
17038 return E;
17039}
17040
17041template<typename Derived>
17044 // Transform arguments.
17045 bool ArgChanged = false;
17047 Args.reserve(E->getNumArgs());
17048 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
17049 &ArgChanged))
17050 return ExprError();
17051
17052 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
17053 // Class message: transform the receiver type.
17054 TypeSourceInfo *ReceiverTypeInfo
17055 = getDerived().TransformType(E->getClassReceiverTypeInfo());
17056 if (!ReceiverTypeInfo)
17057 return ExprError();
17058
17059 // If nothing changed, just retain the existing message send.
17060 if (!getDerived().AlwaysRebuild() &&
17061 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
17062 return SemaRef.MaybeBindToTemporary(E);
17063
17064 // Build a new class message send.
17066 E->getSelectorLocs(SelLocs);
17067 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
17068 E->getSelector(),
17069 SelLocs,
17070 E->getMethodDecl(),
17071 E->getLeftLoc(),
17072 Args,
17073 E->getRightLoc());
17074 }
17075 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17076 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17077 if (!E->getMethodDecl())
17078 return ExprError();
17079
17080 // Build a new class message send to 'super'.
17082 E->getSelectorLocs(SelLocs);
17083 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17084 E->getSelector(),
17085 SelLocs,
17086 E->getReceiverType(),
17087 E->getMethodDecl(),
17088 E->getLeftLoc(),
17089 Args,
17090 E->getRightLoc());
17091 }
17092
17093 // Instance message: transform the receiver
17094 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17095 "Only class and instance messages may be instantiated");
17096 ExprResult Receiver
17097 = getDerived().TransformExpr(E->getInstanceReceiver());
17098 if (Receiver.isInvalid())
17099 return ExprError();
17100
17101 // If nothing changed, just retain the existing message send.
17102 if (!getDerived().AlwaysRebuild() &&
17103 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17104 return SemaRef.MaybeBindToTemporary(E);
17105
17106 // Build a new instance message send.
17108 E->getSelectorLocs(SelLocs);
17109 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17110 E->getSelector(),
17111 SelLocs,
17112 E->getMethodDecl(),
17113 E->getLeftLoc(),
17114 Args,
17115 E->getRightLoc());
17116}
17117
17118template<typename Derived>
17121 return E;
17122}
17123
17124template<typename Derived>
17127 return E;
17128}
17129
17130template<typename Derived>
17133 // Transform the base expression.
17134 ExprResult Base = getDerived().TransformExpr(E->getBase());
17135 if (Base.isInvalid())
17136 return ExprError();
17137
17138 // We don't need to transform the ivar; it will never change.
17139
17140 // If nothing changed, just retain the existing expression.
17141 if (!getDerived().AlwaysRebuild() &&
17142 Base.get() == E->getBase())
17143 return E;
17144
17145 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17146 E->getLocation(),
17147 E->isArrow(), E->isFreeIvar());
17148}
17149
17150template<typename Derived>
17153 // 'super' and types never change. Property never changes. Just
17154 // retain the existing expression.
17155 if (!E->isObjectReceiver())
17156 return E;
17157
17158 // Transform the base expression.
17159 ExprResult Base = getDerived().TransformExpr(E->getBase());
17160 if (Base.isInvalid())
17161 return ExprError();
17162
17163 // We don't need to transform the property; it will never change.
17164
17165 // If nothing changed, just retain the existing expression.
17166 if (!getDerived().AlwaysRebuild() &&
17167 Base.get() == E->getBase())
17168 return E;
17169
17170 if (E->isExplicitProperty())
17171 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17172 E->getExplicitProperty(),
17173 E->getLocation());
17174
17175 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17176 SemaRef.Context.PseudoObjectTy,
17177 E->getImplicitPropertyGetter(),
17178 E->getImplicitPropertySetter(),
17179 E->getLocation());
17180}
17181
17182template<typename Derived>
17185 // Transform the base expression.
17186 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17187 if (Base.isInvalid())
17188 return ExprError();
17189
17190 // Transform the key expression.
17191 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17192 if (Key.isInvalid())
17193 return ExprError();
17194
17195 // If nothing changed, just retain the existing expression.
17196 if (!getDerived().AlwaysRebuild() &&
17197 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17198 return E;
17199
17200 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17201 Base.get(), Key.get(),
17202 E->getAtIndexMethodDecl(),
17203 E->setAtIndexMethodDecl());
17204}
17205
17206template<typename Derived>
17209 // Transform the base expression.
17210 ExprResult Base = getDerived().TransformExpr(E->getBase());
17211 if (Base.isInvalid())
17212 return ExprError();
17213
17214 // If nothing changed, just retain the existing expression.
17215 if (!getDerived().AlwaysRebuild() &&
17216 Base.get() == E->getBase())
17217 return E;
17218
17219 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17220 E->getOpLoc(),
17221 E->isArrow());
17222}
17223
17224template<typename Derived>
17227 bool ArgumentChanged = false;
17228 SmallVector<Expr*, 8> SubExprs;
17229 SubExprs.reserve(E->getNumSubExprs());
17230 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17231 SubExprs, &ArgumentChanged))
17232 return ExprError();
17233
17234 if (!getDerived().AlwaysRebuild() &&
17235 !ArgumentChanged)
17236 return E;
17237
17238 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17239 SubExprs,
17240 E->getRParenLoc());
17241}
17242
17243template<typename Derived>
17246 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17247 if (SrcExpr.isInvalid())
17248 return ExprError();
17249
17250 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17251 if (!Type)
17252 return ExprError();
17253
17254 if (!getDerived().AlwaysRebuild() &&
17255 Type == E->getTypeSourceInfo() &&
17256 SrcExpr.get() == E->getSrcExpr())
17257 return E;
17258
17259 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17260 SrcExpr.get(), Type,
17261 E->getRParenLoc());
17262}
17263
17264template<typename Derived>
17267 BlockDecl *oldBlock = E->getBlockDecl();
17268
17269 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17270 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17271
17272 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17273 blockScope->TheDecl->setBlockMissingReturnType(
17274 oldBlock->blockMissingReturnType());
17275
17277 SmallVector<QualType, 4> paramTypes;
17278
17279 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17280
17281 // Parameter substitution.
17282 Sema::ExtParameterInfoBuilder extParamInfos;
17283 if (getDerived().TransformFunctionTypeParams(
17284 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17285 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17286 extParamInfos)) {
17287 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17288 return ExprError();
17289 }
17290
17291 QualType exprResultType =
17292 getDerived().TransformType(exprFunctionType->getReturnType());
17293
17294 auto epi = exprFunctionType->getExtProtoInfo();
17295 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17296
17298 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17299 blockScope->FunctionType = functionType;
17300
17301 // Set the parameters on the block decl.
17302 if (!params.empty())
17303 blockScope->TheDecl->setParams(params);
17304
17305 if (!oldBlock->blockMissingReturnType()) {
17306 blockScope->HasImplicitReturnType = false;
17307 blockScope->ReturnType = exprResultType;
17308 }
17309
17310 // Transform the body
17311 StmtResult body = getDerived().TransformStmt(E->getBody());
17312 if (body.isInvalid()) {
17313 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17314 return ExprError();
17315 }
17316
17317#ifndef NDEBUG
17318 // In builds with assertions, make sure that we captured everything we
17319 // captured before.
17320 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17321 for (const auto &I : oldBlock->captures()) {
17322 VarDecl *oldCapture = I.getVariable();
17323
17324 // Ignore parameter packs.
17325 if (oldCapture->isParameterPack())
17326 continue;
17327
17328 VarDecl *newCapture =
17329 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17330 oldCapture));
17331 assert(blockScope->CaptureMap.count(newCapture));
17332 }
17333
17334 // The this pointer may not be captured by the instantiated block, even when
17335 // it's captured by the original block, if the expression causing the
17336 // capture is in the discarded branch of a constexpr if statement.
17337 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17338 "this pointer isn't captured in the old block");
17339 }
17340#endif
17341
17342 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17343 /*Scope=*/nullptr);
17344}
17345
17346template<typename Derived>
17349 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17350 if (SrcExpr.isInvalid())
17351 return ExprError();
17352
17353 QualType Type = getDerived().TransformType(E->getType());
17354
17355 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17356 E->getRParenLoc());
17357}
17358
17359template<typename Derived>
17362 bool ArgumentChanged = false;
17363 SmallVector<Expr*, 8> SubExprs;
17364 SubExprs.reserve(E->getNumSubExprs());
17365 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17366 SubExprs, &ArgumentChanged))
17367 return ExprError();
17368
17369 if (!getDerived().AlwaysRebuild() &&
17370 !ArgumentChanged)
17371 return E;
17372
17373 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17374 E->getOp(), E->getRParenLoc());
17375}
17376
17377//===----------------------------------------------------------------------===//
17378// Type reconstruction
17379//===----------------------------------------------------------------------===//
17380
17381template<typename Derived>
17384 return SemaRef.BuildPointerType(PointeeType, Star,
17386}
17387
17388template<typename Derived>
17391 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17393}
17394
17395template<typename Derived>
17398 bool WrittenAsLValue,
17399 SourceLocation Sigil) {
17400 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17401 Sigil, getDerived().getBaseEntity());
17402}
17403
17404template <typename Derived>
17406 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17407 SourceLocation Sigil) {
17408 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17410}
17411
17412template<typename Derived>
17414 const ObjCTypeParamDecl *Decl,
17415 SourceLocation ProtocolLAngleLoc,
17417 ArrayRef<SourceLocation> ProtocolLocs,
17418 SourceLocation ProtocolRAngleLoc) {
17419 return SemaRef.ObjC().BuildObjCTypeParamType(
17420 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17421 /*FailOnError=*/true);
17422}
17423
17424template<typename Derived>
17426 QualType BaseType,
17427 SourceLocation Loc,
17428 SourceLocation TypeArgsLAngleLoc,
17430 SourceLocation TypeArgsRAngleLoc,
17431 SourceLocation ProtocolLAngleLoc,
17433 ArrayRef<SourceLocation> ProtocolLocs,
17434 SourceLocation ProtocolRAngleLoc) {
17435 return SemaRef.ObjC().BuildObjCObjectType(
17436 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17437 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17438 /*FailOnError=*/true,
17439 /*Rebuilding=*/true);
17440}
17441
17442template<typename Derived>
17444 QualType PointeeType,
17446 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17447}
17448
17449template <typename Derived>
17451 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17452 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17453 if (SizeExpr || !Size)
17454 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17455 IndexTypeQuals, BracketsRange,
17457
17458 QualType Types[] = {
17459 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17460 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17461 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17462 };
17463 QualType SizeType;
17464 for (const auto &T : Types)
17465 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17466 SizeType = T;
17467 break;
17468 }
17469
17470 // Note that we can return a VariableArrayType here in the case where
17471 // the element type was a dependent VariableArrayType.
17472 IntegerLiteral *ArraySize
17473 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17474 /*FIXME*/BracketsRange.getBegin());
17475 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17476 IndexTypeQuals, BracketsRange,
17478}
17479
17480template <typename Derived>
17482 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17483 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17484 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17485 IndexTypeQuals, BracketsRange);
17486}
17487
17488template <typename Derived>
17490 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17491 SourceRange BracketsRange) {
17492 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17493 IndexTypeQuals, BracketsRange);
17494}
17495
17496template <typename Derived>
17498 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17499 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17500 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17501 SizeExpr,
17502 IndexTypeQuals, BracketsRange);
17503}
17504
17505template <typename Derived>
17507 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17508 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17509 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17510 SizeExpr,
17511 IndexTypeQuals, BracketsRange);
17512}
17513
17514template <typename Derived>
17516 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17517 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17518 AttributeLoc);
17519}
17520
17521template <typename Derived>
17523 unsigned NumElements,
17524 VectorKind VecKind) {
17525 // FIXME: semantic checking!
17526 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17527}
17528
17529template <typename Derived>
17531 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17532 VectorKind VecKind) {
17533 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17534}
17535
17536template<typename Derived>
17538 unsigned NumElements,
17539 SourceLocation AttributeLoc) {
17540 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17541 NumElements, true);
17542 IntegerLiteral *VectorSize
17543 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17544 AttributeLoc);
17545 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17546}
17547
17548template<typename Derived>
17551 Expr *SizeExpr,
17552 SourceLocation AttributeLoc) {
17553 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17554}
17555
17556template <typename Derived>
17558 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17559 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17560 NumColumns);
17561}
17562
17563template <typename Derived>
17565 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17566 SourceLocation AttributeLoc) {
17567 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17568 AttributeLoc);
17569}
17570
17571template <typename Derived>
17575 return SemaRef.BuildFunctionType(T, ParamTypes,
17578 EPI);
17579}
17580
17581template<typename Derived>
17583 return SemaRef.Context.getFunctionNoProtoType(T);
17584}
17585
17586template <typename Derived>
17589 SourceLocation NameLoc, Decl *D) {
17590 assert(D && "no decl found");
17591 if (D->isInvalidDecl()) return QualType();
17592
17593 // FIXME: Doesn't account for ObjCInterfaceDecl!
17594 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17595 // A valid resolved using typename pack expansion decl can have multiple
17596 // UsingDecls, but they must each have exactly one type, and it must be
17597 // the same type in every case. But we must have at least one expansion!
17598 if (UPD->expansions().empty()) {
17599 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17600 << UPD->isCXXClassMember() << UPD;
17601 return QualType();
17602 }
17603
17604 // We might still have some unresolved types. Try to pick a resolved type
17605 // if we can. The final instantiation will check that the remaining
17606 // unresolved types instantiate to the type we pick.
17607 QualType FallbackT;
17608 QualType T;
17609 for (auto *E : UPD->expansions()) {
17610 QualType ThisT =
17611 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17612 if (ThisT.isNull())
17613 continue;
17614 if (ThisT->getAs<UnresolvedUsingType>())
17615 FallbackT = ThisT;
17616 else if (T.isNull())
17617 T = ThisT;
17618 else
17619 assert(getSema().Context.hasSameType(ThisT, T) &&
17620 "mismatched resolved types in using pack expansion");
17621 }
17622 return T.isNull() ? FallbackT : T;
17623 }
17624 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17625 assert(Using->hasTypename() &&
17626 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17627
17628 // A valid resolved using typename decl points to exactly one type decl.
17629 assert(++Using->shadow_begin() == Using->shadow_end());
17630
17631 UsingShadowDecl *Shadow = *Using->shadow_begin();
17632 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17633 return QualType();
17634 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17635 }
17637 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17638 return SemaRef.Context.getUnresolvedUsingType(
17640}
17641
17642template <typename Derived>
17644 TypeOfKind Kind) {
17645 return SemaRef.BuildTypeofExprType(E, Kind);
17646}
17647
17648template<typename Derived>
17650 TypeOfKind Kind) {
17651 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17652}
17653
17654template <typename Derived>
17656 return SemaRef.BuildDecltypeType(E);
17657}
17658
17659template <typename Derived>
17661 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17662 SourceLocation EllipsisLoc, bool FullySubstituted,
17663 ArrayRef<QualType> Expansions) {
17664 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17665 FullySubstituted, Expansions);
17666}
17667
17668template<typename Derived>
17670 UnaryTransformType::UTTKind UKind,
17671 SourceLocation Loc) {
17672 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17673}
17674
17675template <typename Derived>
17678 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17679 return SemaRef.CheckTemplateIdType(
17680 Keyword, Template, TemplateNameLoc, TemplateArgs,
17681 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17682}
17683
17684template<typename Derived>
17686 SourceLocation KWLoc) {
17687 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17688}
17689
17690template<typename Derived>
17692 SourceLocation KWLoc,
17693 bool isReadPipe) {
17694 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17695 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17696}
17697
17698template <typename Derived>
17700 unsigned NumBits,
17701 SourceLocation Loc) {
17702 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17703 NumBits, true);
17704 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17705 SemaRef.Context.IntTy, Loc);
17706 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17707}
17708
17709template <typename Derived>
17711 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17712 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17713}
17714
17715template <typename Derived>
17717 bool TemplateKW,
17718 TemplateName Name) {
17719 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17720 Name);
17721}
17722
17723template <typename Derived>
17725 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17726 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17728 TemplateName.setIdentifier(&Name, NameLoc);
17730 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17731 TemplateName, ParsedType::make(ObjectType),
17732 /*EnteringContext=*/false, Template,
17733 AllowInjectedClassName);
17734 return Template.get();
17735}
17736
17737template<typename Derived>
17740 SourceLocation TemplateKWLoc,
17741 OverloadedOperatorKind Operator,
17742 SourceLocation NameLoc,
17743 QualType ObjectType,
17744 bool AllowInjectedClassName) {
17745 UnqualifiedId Name;
17746 // FIXME: Bogus location information.
17747 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17748 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17750 getSema().ActOnTemplateName(
17751 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17752 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17753 return Template.get();
17754}
17755
17756template <typename Derived>
17759 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17760 Expr *Second) {
17761 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17762
17763 if (First->getObjectKind() == OK_ObjCProperty) {
17766 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17767 Opc, First, Second);
17768 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17769 if (Result.isInvalid())
17770 return ExprError();
17771 First = Result.get();
17772 }
17773
17774 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17775 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17776 if (Result.isInvalid())
17777 return ExprError();
17778 Second = Result.get();
17779 }
17780
17781 // Determine whether this should be a builtin operation.
17782 if (Op == OO_Subscript) {
17783 if (!First->getType()->isOverloadableType() &&
17784 !Second->getType()->isOverloadableType())
17785 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17786 OpLoc);
17787 } else if (Op == OO_Arrow) {
17788 // It is possible that the type refers to a RecoveryExpr created earlier
17789 // in the tree transformation.
17790 if (First->getType()->isDependentType())
17791 return ExprError();
17792 // -> is never a builtin operation.
17793 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17794 } else if (Second == nullptr || isPostIncDec) {
17795 if (!First->getType()->isOverloadableType() ||
17796 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17797 // The argument is not of overloadable type, or this is an expression
17798 // of the form &Class::member, so try to create a built-in unary
17799 // operation.
17801 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17802
17803 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17804 }
17805 } else {
17806 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17807 !First->getType()->isOverloadableType() &&
17808 !Second->getType()->isOverloadableType()) {
17809 // Neither of the arguments is type-dependent or has an overloadable
17810 // type, so try to create a built-in binary operation.
17813 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17814 if (Result.isInvalid())
17815 return ExprError();
17816
17817 return Result;
17818 }
17819 }
17820
17821 // Create the overloaded operator invocation for unary operators.
17822 if (!Second || isPostIncDec) {
17824 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17825 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17826 RequiresADL);
17827 }
17828
17829 // Create the overloaded operator invocation for binary operators.
17831 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17832 First, Second, RequiresADL);
17833 if (Result.isInvalid())
17834 return ExprError();
17835
17836 return Result;
17837}
17838
17839template<typename Derived>
17842 SourceLocation OperatorLoc,
17843 bool isArrow,
17844 CXXScopeSpec &SS,
17845 TypeSourceInfo *ScopeType,
17846 SourceLocation CCLoc,
17847 SourceLocation TildeLoc,
17848 PseudoDestructorTypeStorage Destroyed) {
17849 QualType CanonicalBaseType = Base->getType().getCanonicalType();
17850 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
17851 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
17852 (isArrow && isa<PointerType>(CanonicalBaseType) &&
17853 !cast<PointerType>(CanonicalBaseType)
17854 ->getPointeeType()
17855 ->getAsCanonical<RecordType>())) {
17856 // This pseudo-destructor expression is still a pseudo-destructor.
17857 return SemaRef.BuildPseudoDestructorExpr(
17858 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
17859 CCLoc, TildeLoc, Destroyed);
17860 }
17861
17862 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
17863 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
17864 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
17865 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
17866 NameInfo.setNamedTypeInfo(DestroyedType);
17867
17868 // The scope type is now known to be a valid nested name specifier
17869 // component. Tack it on to the nested name specifier.
17870 if (ScopeType) {
17871 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
17872 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
17873 diag::err_expected_class_or_namespace)
17874 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
17875 return ExprError();
17876 }
17877 SS.clear();
17878 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
17879 }
17880
17881 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
17882 return getSema().BuildMemberReferenceExpr(
17883 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
17884 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
17885 /*TemplateArgs*/ nullptr,
17886 /*S*/ nullptr);
17887}
17888
17889template<typename Derived>
17892 SourceLocation Loc = S->getBeginLoc();
17893 CapturedDecl *CD = S->getCapturedDecl();
17894 unsigned NumParams = CD->getNumParams();
17895 unsigned ContextParamPos = CD->getContextParamPosition();
17897 for (unsigned I = 0; I < NumParams; ++I) {
17898 if (I != ContextParamPos) {
17899 Params.push_back(
17900 std::make_pair(
17901 CD->getParam(I)->getName(),
17902 getDerived().TransformType(CD->getParam(I)->getType())));
17903 } else {
17904 Params.push_back(std::make_pair(StringRef(), QualType()));
17905 }
17906 }
17907 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
17908 S->getCapturedRegionKind(), Params);
17909 StmtResult Body;
17910 {
17911 Sema::CompoundScopeRAII CompoundScope(getSema());
17912 Body = getDerived().TransformStmt(S->getCapturedStmt());
17913 }
17914
17915 if (Body.isInvalid()) {
17916 getSema().ActOnCapturedRegionError();
17917 return StmtError();
17918 }
17919
17920 return getSema().ActOnCapturedRegionEnd(Body.get());
17921}
17922
17923template <typename Derived>
17926 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
17927 // function definition or instantiation of a function template specialization
17928 // and will therefore never appear in a dependent context.
17929 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
17930 "context");
17931}
17932
17933template <typename Derived>
17935 // We can transform the base expression and allow argument resolution to fill
17936 // in the rest.
17937 return getDerived().TransformExpr(E->getArgLValue());
17938}
17939
17940} // end namespace clang
17941
17942#endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
static Decl::Kind getKind(const Decl *D)
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
TokenType getType() const
Returns the token's type, e.g.
SmallVector< AnnotatedLine *, 1 > Children
If this token starts a block, this contains all the unwrapped lines in it.
#define X(type, name)
Definition Value.h:97
llvm::MachO::Record Record
Definition MachO.h:31
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenACC constructs and clauses.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis for expressions involving.
This file declares semantic analysis for SYCL constructs.
static bool PreparePackForExpansion(Sema &S, const CXXBaseSpecifier &Base, const MultiLevelTemplateArgumentList &TemplateArgs, TypeSourceInfo *&Out, UnexpandedInfo &Info)
Defines the Objective-C statement AST node classes.
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
static QualType getPointeeType(const MemRegion *R)
This represents 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>.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
QualType getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
PtrTy get() const
Definition Ownership.h:171
bool isInvalid() const
Definition Ownership.h:167
bool isUsable() const
Definition Ownership.h:169
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition Expr.h:4550
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:6021
Represents a loop initializing the elements of an array.
Definition Expr.h:5968
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1805
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7171
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2721
Wrapper for source info for arrays.
Definition TypeLoc.h:1749
void setLBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1755
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition ExprCXX.h:2996
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:3034
ArrayTypeTrait getTrait() const
Definition ExprCXX.h:3036
Expr * getDimensionExpression() const
Definition ExprCXX.h:3046
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition ExprCXX.h:3042
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:3033
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3723
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6685
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6880
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2645
Attr - This represents one attribute.
Definition Attr.h:46
attr::Kind getKind() const
Definition Attr.h:92
Represents an attribute applied to a statement.
Definition Stmt.h:2195
Stmt * getSubStmt()
Definition Stmt.h:2231
SourceLocation getAttrLoc() const
Definition Stmt.h:2226
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2227
Type source information for an attributed type.
Definition TypeLoc.h:1008
void setAttr(const Attr *A)
Definition TypeLoc.h:1034
Type source information for an btf_tag attributed type.
Definition TypeLoc.h:1058
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition Expr.h:4453
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4038
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition Expr.cpp:2179
static bool isAssignmentOp(Opcode Opc)
Definition Expr.h:4174
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:2141
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8154
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4671
void setIsVariadic(bool value)
Definition Decl.h:4747
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6624
Wrapper for source info for block pointers.
Definition TypeLoc.h:1498
BreakStmt - This represents a break.
Definition Stmt.h:3127
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5476
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:5495
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:5494
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition Expr.h:3969
Represents a call to a CUDA kernel function.
Definition ExprCXX.h:234
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition ExprCXX.h:604
Represents binding an expression to a temporary.
Definition ExprCXX.h:1493
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition ExprCXX.h:723
CXXCatchStmt - This represents a C++ catch block.
Definition StmtCXX.h:28
A C++ const_cast expression (C++ [expr.const.cast]).
Definition ExprCXX.h:566
Represents a call to a C++ constructor.
Definition ExprCXX.h:1548
SourceRange getParenOrBraceRange() const
Definition ExprCXX.h:1729
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition ExprCXX.h:1691
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition ExprCXX.h:1641
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:581
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:575
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition ExprCXX.h:1630
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition ExprCXX.h:1688
Represents a C++ constructor within a class.
Definition DeclCXX.h:2604
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1270
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition ExprCXX.cpp:1039
A use of a default initializer in a constructor or in aggregate initialization.
Definition ExprCXX.h:1377
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2626
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition ExprCXX.h:3870
Represents a C++ destructor within a class.
Definition DeclCXX.h:2869
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:481
Represents a folding of a pack over an operator.
Definition ExprCXX.h:5032
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition StmtCXX.h:135
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition ExprCXX.h:1831
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition ExprCXX.h:1751
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:179
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2129
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition ExprCXX.h:375
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition ExprCXX.h:406
SourceRange getAngleBrackets() const LLVM_READONLY
Definition ExprCXX.h:413
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition ExprCXX.h:409
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition ExprCXX.h:2355
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition ExprCXX.h:4309
The null pointer literal (C++11 [lex.nullptr])
Definition ExprCXX.h:768
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:84
Represents a list-initialization with parenthesis.
Definition ExprCXX.h:5141
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition ExprCXX.h:2745
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
unsigned getLambdaDependencyKind() const
Definition DeclCXX.h:1854
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition ExprCXX.h:526
A rewritten comparison expression that was originally written using operator syntax.
Definition ExprCXX.h:286
An expression "T()" which creates an rvalue of a non-class type T.
Definition ExprCXX.h:2196
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:73
void Make(ASTContext &Context, TypeLoc TL, SourceLocation ColonColonLoc)
Make a nested-name-specifier of the form 'type::'.
Definition DeclSpec.cpp:51
char * location_data() const
Retrieve the data associated with the source-location information.
Definition DeclSpec.h:206
SourceRange getRange() const
Definition DeclSpec.h:79
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition DeclSpec.cpp:75
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition DeclSpec.h:94
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition DeclSpec.cpp:123
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition DeclSpec.h:210
void Extend(ASTContext &Context, NamespaceBaseDecl *Namespace, SourceLocation NamespaceLoc, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'name...
Definition DeclSpec.cpp:62
void MakeMicrosoftSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition DeclSpec.cpp:85
bool isEmpty() const
No scope specifier.
Definition DeclSpec.h:178
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition DeclSpec.cpp:103
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition ExprCXX.h:800
Represents a C++ functional cast expression that builds a temporary object.
Definition ExprCXX.h:1899
Represents the this expression in C++.
Definition ExprCXX.h:1154
A C++ throw-expression (C++ [except.throw]).
Definition ExprCXX.h:1208
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:69
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition ExprCXX.h:848
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition ExprCXX.h:3744
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition ExprCXX.h:3788
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition ExprCXX.h:3799
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition ExprCXX.h:3782
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition ExprCXX.h:3793
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition ExprCXX.h:3802
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1068
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2943
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
Definition Expr.cpp:1516
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4943
unsigned getNumParams() const
Definition Decl.h:4981
unsigned getContextParamPosition() const
Definition Decl.h:5010
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4983
This captures a statement into a function.
Definition Stmt.h:3929
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1488
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:4033
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:4124
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition Stmt.cpp:1503
CaseStmt - Represent a case statement.
Definition Stmt.h:1912
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition Expr.cpp:1979
Expr * getSubExpr()
Definition Expr.h:3726
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4848
Represents a 'co_await' expression.
Definition ExprCXX.h:5369
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4300
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3605
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1732
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Stmt.h:1782
body_range body()
Definition Stmt.h:1795
SourceLocation getLBracLoc() const
Definition Stmt.h:1849
bool hasStoredFPFeatures() const
Definition Stmt.h:1779
Stmt * body_back()
Definition Stmt.h:1800
SourceLocation getRBracLoc() const
Definition Stmt.h:1850
Declaration of a C++20 concept.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
Represents the specialization of a concept - evaluates to a prvalue of type bool.
const TypeClass * getTypePtr() const
Definition TypeLoc.h:433
ConditionalOperator - The ?
Definition Expr.h:4391
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3761
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition Expr.h:1082
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4388
ContinueStmt - This represents a continue.
Definition Stmt.h:3111
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4719
Represents a 'co_return' statement in the C++ Coroutines TS.
Definition StmtCXX.h:473
Represents the body of a coroutine.
Definition StmtCXX.h:320
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
Definition TypeBase.h:3437
Represents a 'co_yield' expression.
Definition ExprCXX.h:5450
Wrapper for source info for pointers decayed from arrays and functions.
Definition TypeLoc.h:1446
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1449
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2109
DeclContextLookupResult lookup_result
Definition DeclBase.h:2577
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addDecl(Decl *D)
Add the declaration D into this context.
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1270
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1623
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
bool isInvalidDecl() const
Definition DeclBase.h:588
SourceLocation getLocation() const
Definition DeclBase.h:439
DeclContext * getDeclContext()
Definition DeclBase.h:448
AccessSpecifier getAccess() const
Definition DeclBase.h:507
The name of a declaration.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition Decl.h:822
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:809
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:1874
void setDecltypeLoc(SourceLocation Loc)
Definition TypeLoc.h:2260
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2485
DeferStmt - This represents a deferred statement.
Definition Stmt.h:3228
static DeferStmt * Create(ASTContext &Context, SourceLocation DeferLoc, Stmt *Body)
Definition Stmt.cpp:1547
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:1970
Represents an extended address space qualifier where the input address space value is dependent.
Definition TypeBase.h:4062
Represents a 'co_await' expression while the type of the promise is dependent.
Definition ExprCXX.h:5401
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2553
A qualified reference to a name whose declaration cannot yet be resolved.
Definition ExprCXX.h:3510
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3584
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition ExprCXX.h:3558
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3576
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition ExprCXX.h:3594
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3568
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3611
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3549
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3604
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3546
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4012
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2068
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4102
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition TypeBase.h:4435
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2040
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4228
Represents a single C99 designator.
Definition Expr.h:5594
Represents a C99 designated initializer expression.
Definition Expr.h:5551
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:208
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
Definition Designator.h:172
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
Definition Designator.h:142
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
Definition Designator.h:115
bool hasErrorOccurred() const
Definition Diagnostic.h:872
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2824
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Definition TypeBase.h:4989
Expr * getCondition() const
Definition TypeBase.h:4996
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:744
Represents a reference to emded data.
Definition Expr.h:5126
RAII object that enters a new expression evaluation context.
Wrapper for source info for enum types.
Definition TypeLoc.h:863
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Definition Expr.h:3950
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition ExprCXX.h:3661
This represents one expression.
Definition Expr.h:112
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition Expr.h:177
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:194
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition Expr.h:451
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3081
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3213
QualType getType() const
Definition Expr.h:144
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition Expr.h:523
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition Expr.h:434
An expression trait intrinsic.
Definition ExprCXX.h:3069
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h:6564
Represents difference between two FPOptions values.
FPOptions applyOverrides(FPOptions Base)
Represents a member of a struct/union/class.
Definition Decl.h:3160
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2880
Represents a function declaration or definition.
Definition Decl.h:2000
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2774
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5237
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4882
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5522
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5508
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5103
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4847
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4841
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5269
param_type_iterator param_type_begin() const
Definition TypeBase.h:5713
unsigned getNumParams() const
Definition TypeLoc.h:1688
SourceLocation getLocalRangeEnd() const
Definition TypeLoc.h:1640
void setLocalRangeBegin(SourceLocation L)
Definition TypeLoc.h:1636
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1652
SourceRange getExceptionSpecRange() const
Definition TypeLoc.h:1668
void setParam(unsigned i, ParmVarDecl *VD)
Definition TypeLoc.h:1695
ArrayRef< ParmVarDecl * > getParams() const
Definition TypeLoc.h:1679
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1660
void setLocalRangeEnd(SourceLocation L)
Definition TypeLoc.h:1644
void setExceptionSpecRange(SourceRange R)
Definition TypeLoc.h:1674
TypeLoc getReturnLoc() const
Definition TypeLoc.h:1697
SourceLocation getLocalRangeBegin() const
Definition TypeLoc.h:1632
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1648
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1656
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4491
This represents a GCC inline-assembly statement extension.
Definition Stmt.h:3438
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition Expr.h:4923
Represents a C11 generic selection.
Definition Expr.h:6178
AssociationTy< false > Association
Definition Expr.h:6409
GotoStmt - This represents a direct goto.
Definition Stmt.h:2961
Type source information for HLSL attributed resource type.
Definition TypeLoc.h:1085
void setSourceRange(const SourceRange &R)
Definition TypeLoc.h:1096
This class represents temporary values used to represent inout and out arguments in HLSL.
Definition Expr.h:7349
One of these records is kept for each identifier that is lexed.
IfStmt - This represents an if/then/else.
Definition Stmt.h:2251
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition Expr.h:1731
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition Expr.h:3853
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:6057
Represents a C array with an unspecified size.
Definition TypeBase.h:3910
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:3000
const TypeClass * getTypePtr() const
Definition TypeLoc.h:526
Describes an C or C++ initializer list.
Definition Expr.h:5299
InitListExpr * getSyntacticForm() const
Definition Expr.h:5472
Wrapper for source info for injected class names of class templates.
Definition TypeLoc.h:872
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition Expr.cpp:974
Represents the declaration of a label.
Definition Decl.h:524
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2138
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition ExprCXX.h:1968
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition ExprCXX.cpp:1363
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1358
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1367
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition ExprCXX.h:2033
Represents the results of name lookup.
Definition Lookup.h:147
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
Definition Lookup.h:607
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition Lookup.h:475
bool empty() const
Return true if no decls were found.
Definition Lookup.h:362
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Definition Lookup.h:666
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition Lookup.h:576
DeclarationName getLookupName() const
Gets the name to look up.
Definition Lookup.h:265
This represents a Microsoft inline-assembly statement extension.
Definition Stmt.h:3657
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition StmtCXX.h:253
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4340
A member reference to an MSPropertyDecl.
Definition ExprCXX.h:936
MS property subscript expression.
Definition ExprCXX.h:1006
void setExpansionLoc(SourceLocation Loc)
Definition TypeLoc.h:1355
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4920
MatrixSingleSubscriptExpr - Matrix single subscript expression for the MatrixType extension when you ...
Definition Expr.h:2795
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2865
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2097
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3364
Wrapper for source info for member pointers.
Definition TypeLoc.h:1516
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3654
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition Template.h:76
This represents a decl that may have a name.
Definition Decl.h:274
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition Decl.h:487
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition Decl.h:295
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:301
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:340
Represents C++ namespaces and their aliases.
Definition Decl.h:573
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents a place-holder for an object not to be initialized by anything.
Definition Expr.h:5877
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h:1695
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 '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:192
Represents Objective-C's @catch statement.
Definition StmtObjC.h:77
Represents Objective-C's @finally statement.
Definition StmtObjC.h:127
Represents Objective-C's @synchronized statement.
Definition StmtObjC.h:303
Represents Objective-C's @throw statement.
Definition StmtObjC.h:358
Represents Objective-C's @try ... @catch ... @finally statement.
Definition StmtObjC.h:167
Represents Objective-C's @autoreleasepool Statement.
Definition StmtObjC.h:394
A runtime availability query.
Definition ExprObjC.h:1700
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition ExprObjC.h:88
ObjCBoxedExpr - used for generalized expression boxing.
Definition ExprObjC.h:128
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition ExprObjC.h:1640
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition ExprObjC.h:307
ObjCEncodeExpr, used for @encode in Objective-C.
Definition ExprObjC.h:407
Represents Objective-C's collection statement.
Definition StmtObjC.h:23
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition ExprObjC.h:1579
Wrapper for source info for ObjC interfaces.
Definition TypeLoc.h:1275
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition ExprObjC.h:1495
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1952
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:546
An expression that sends a message to the given Objective-C object or class.
Definition ExprObjC.h:937
@ SuperInstance
The receiver is the instance of the superclass object.
Definition ExprObjC.h:951
@ Instance
The receiver is an object instance.
Definition ExprObjC.h:945
@ SuperClass
The receiver is a superclass.
Definition ExprObjC.h:948
@ Class
The receiver is a class.
Definition ExprObjC.h:942
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Wraps an ObjCPointerType with source location information.
Definition TypeLoc.h:1558
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1564
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition TypeLoc.h:1230
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:731
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition ExprObjC.h:614
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition ExprObjC.h:502
ObjCSelectorExpr used for @selector in Objective-C.
Definition ExprObjC.h:452
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition ExprObjC.h:52
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition ExprObjC.h:836
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:578
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition TypeLoc.h:895
@ Array
An index into an array.
Definition Expr.h:2426
@ Identifier
A field in a dependent type, known only by its name.
Definition Expr.h:2430
@ Field
A field.
Definition Expr.h:2428
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition Expr.h:2433
static OpaquePtr make(QualType P)
Definition Ownership.h:61
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition Expr.h:1178
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1228
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition Expr.h:2090
static OpenACCAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCAttachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCAutoClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
This is the base type for all OpenACC Clauses.
Represents a 'collapse' clause on a 'loop' construct.
static OpenACCCollapseClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, bool HasForce, Expr *LoopCount, SourceLocation EndLoc)
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A 'default' clause, has the optional 'none' or 'present' argument.
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCDeleteClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDetachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceNumClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCFinalizeClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCFirstPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCHostClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
An 'if' clause, which has a required condition expression.
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCIfPresentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCIndependentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCNoCreateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCPrivateRecipe > InitRecipes, SourceLocation EndLoc)
A 'self' clause, which has an optional condition expression, or, in the event of an 'update' directiv...
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCTileClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > SizeExprs, SourceLocation EndLoc)
static OpenACCUseDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWaitClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition ExprCXX.h:3128
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition ExprCXX.h:3280
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3262
SourceLocation getNameLoc() const
Gets the location of the name.
Definition ExprCXX.h:3241
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3254
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition ExprCXX.h:3250
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3324
llvm::iterator_range< decls_iterator > decls() const
Definition ExprCXX.h:3227
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3330
DeclarationName getName() const
Gets the name looked up.
Definition ExprCXX.h:3238
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3270
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition ExprCXX.h:3277
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition ExprCXX.h:4363
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2605
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2601
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2617
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2288
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2182
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition Expr.h:2207
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition Expr.h:2211
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1383
Represents a parameter to a function.
Definition Decl.h:1790
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1850
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1823
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition Decl.cpp:2957
unsigned getFunctionScopeDepth() const
Definition Decl.h:1840
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2697
PipeType - OpenCL20.
Definition TypeBase.h:8120
bool isReadOnly() const
Definition TypeBase.h:8150
Pointer-authentication qualifiers.
Definition TypeBase.h:152
void setSigilLoc(SourceLocation Loc)
Definition TypeLoc.h:1462
TypeLoc getPointeeLoc() const
Definition TypeLoc.h:1466
SourceLocation getSigilLoc() const
Definition TypeLoc.h:1458
Wrapper for source info for pointers.
Definition TypeLoc.h:1485
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3329
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2005
Stores the type being destroyed by a pseudo-destructor expression.
Definition ExprCXX.h:2694
const IdentifierInfo * getIdentifier() const
Definition ExprCXX.h:2714
SourceLocation getLocation() const
Definition ExprCXX.h:2718
TypeSourceInfo * getTypeSourceInfo() const
Definition ExprCXX.h:2710
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h:6756
A (possibly-)qualified type.
Definition TypeBase.h:937
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition TypeBase.h:1004
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition TypeBase.h:8302
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition TypeBase.h:8342
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition TypeBase.h:8396
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8334
Represents a template name as written in source code.
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition TypeLoc.h:300
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
void removeObjCLifetime()
Definition TypeBase.h:551
bool hasRestrict() const
Definition TypeBase.h:477
static Qualifiers fromCVRMask(unsigned CVR)
Definition TypeBase.h:435
PointerAuthQualifier getPointerAuth() const
Definition TypeBase.h:603
bool hasObjCLifetime() const
Definition TypeBase.h:544
bool empty() const
Definition TypeBase.h:647
LangAS getAddressSpace() const
Definition TypeBase.h:571
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition Expr.h:7455
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3574
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3590
Represents the body of a requires-expression.
Definition DeclCXX.h:2098
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition DeclCXX.cpp:2389
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3152
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition Stmt.cpp:1356
Represents a __leave statement.
Definition Stmt.h:3890
SYCLKernelCallStmt represents the transformation that is applied to the body of a function declared w...
Definition StmtSYCL.h:37
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
Definition SemaObjC.cpp:36
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
Definition SemaObjC.cpp:193
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition SemaObjC.cpp:320
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
Definition SemaObjC.cpp:218
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:213
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition SemaObjC.cpp:238
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition SemaObjC.cpp:282
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Definition SemaObjC.cpp:202
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:329
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
Helper type for the registration/assignment of constructs that need to 'know' about their parent cons...
Helper type to restore the state of various 'loop' constructs when we run into a loop (for,...
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
void ActOnWhileStmt(SourceLocation WhileLoc)
ExprResult ActOnOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
void ActOnDoStmt(SourceLocation DoLoc)
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *OldRangeFor, const Stmt *RangeFor)
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation MiscLoc, ArrayRef< Expr * > Exprs, OpenACCAtomicKind AK, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
void ActOnForStmtEnd(SourceLocation ForLoc, StmtResult Body)
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *First, const Stmt *Second, const Stmt *Third)
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
OMPClause * ActOnOpenMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nocontext' clause.
OMPClause * ActOnOpenMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_dyn_cgroup_mem' clause.
OMPClause * ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'safelen' clause.
OMPClause * ActOnOpenMPHoldsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'holds' clause.
OMPClause * ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'filter' clause.
OMPClause * ActOnOpenMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on well-form 'full' clauses.
OMPClause * ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'detach' clause.
OMPClause * ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'use' clause.
OMPClause * ActOnOpenMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'private' clause.
OMPClause * ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc=SourceLocation(), Expr *NumForLoops=nullptr)
Called on well-formed 'ordered' clause.
OMPClause * ActOnOpenMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'is_device_ptr' clause.
OMPClause * ActOnOpenMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'has_device_addr' clause.
OMPClause * ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'partial' clauses.
OMPClause * ActOnOpenMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'lastprivate' clause.
OMPClause * ActOnOpenMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'firstprivate' clause.
OMPClause * ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'priority' clause.
OMPClause * ActOnOpenMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'dist_schedule' clause.
OMPClause * ActOnOpenMPLoopRangeClause(Expr *First, Expr *Count, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc)
Called on well-form 'looprange' clause after parsing its arguments.
OMPClause * ActOnOpenMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'permutation' clause after parsing its arguments.
OMPClause * ActOnOpenMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nontemporal' clause.
OMPClause * ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'bind' clause.
OMPClause * ActOnOpenMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' clause.
OMPClause * ActOnOpenMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'shared' clause.
OMPClause * ActOnOpenMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyin' clause.
OMPClause * ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'destroy' clause.
OMPClause * ActOnOpenMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Called on well-formed 'affinity' clause.
OMPClause * ActOnOpenMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' clause.
OMPClause * ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depend' clause.
OMPClause * ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'doacross' clause.
OMPClause * 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)
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition SemaSYCL.cpp:143
RAII object used to change the argument pack substitution index within a Sema object.
Definition Sema.h:13662
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8474
A RAII object to enter scope of a compound statement.
Definition Sema.h:1295
A RAII object to temporarily push a declaration context.
Definition Sema.h:3494
A helper class for building up ExtParameterInfos.
Definition Sema.h:13048
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:13067
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13055
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14067
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:856
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:9357
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9365
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9360
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:1508
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:7864
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7866
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7865
ExprResult BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP, SourceLocation loc, TemplateArgument Replacement, UnsignedOrNone PackIndex, bool Final)
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:438
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E, bool IsImplicit=false)
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition SemaStmt.cpp:485
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition Sema.h:1533
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:11993
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:1288
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:924
SemaObjC & ObjC()
Definition Sema.h:1493
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:927
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, bool DoCheckConstraintSatisfaction=true)
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition Sema.cpp:83
const LangOptions & getLangOpts() const
Definition Sema.h:920
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
SemaOpenACC & OpenACC()
Definition Sema.h:1498
@ ReuseLambdaContextDecl
Definition Sema.h:7042
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:11796
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:1321
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:11791
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition Sema.cpp:2519
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1421
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:13656
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:6755
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6765
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6734
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6760
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:75
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition Sema.h:8343
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:11080
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition SemaStmt.cpp:563
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParen)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition SemaCast.cpp:337
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel)
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition SemaStmt.cpp:950
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, SourceLocation RParenLoc, MultiExprArg Args, AtomicExpr::AtomicOp Op, AtomicArgumentOrder ArgOrder=AtomicArgumentOrder::API)
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
OpaquePtr< TemplateName > TemplateTy
Definition Sema.h:1280
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static ConditionResult ConditionError()
Definition Sema.h:7850
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:436
SemaPseudoObject & PseudoObject()
Definition Sema.h:1518
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:1279
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:8685
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition Expr.h:4643
Represents an expression that computes the length of a parameter pack.
Definition ExprCXX.h:4441
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition ExprCXX.h:4503
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
Definition ExprCXX.h:4526
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Definition ExprCXX.cpp:1709
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition ExprCXX.h:4531
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
Definition ExprCXX.h:4500
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition ExprCXX.h:4506
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition ExprCXX.h:4509
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition Expr.h:5017
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition Expr.h:5077
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition Expr.h:4595
Stmt - This represents one statement.
Definition Stmt.h:86
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.cpp:362
@ NoStmtClass
Definition Stmt.h:89
StmtClass getStmtClass() const
Definition Stmt.h:1485
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:338
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1799
Wrapper for substituted template type parameters.
Definition TypeLoc.h:998
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition ExprCXX.h:4664
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition ExprCXX.h:4754
A structure for storing an already-substituted template template parameter pack.
A structure for storing the information associated with a substituted template template parameter.
Wrapper for substituted template type parameters.
Definition TypeLoc.h:992
SwitchStmt - This represents a 'switch' stmt.
Definition Stmt.h:2501
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3717
SourceLocation getNameLoc() const
Definition TypeLoc.h:822
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:801
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:809
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:816
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:824
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:805
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
const TemplateArgumentLoc * operator->() const
Simple iterator that traverses the template arguments in a container that provides a getArgLoc() memb...
TemplateArgumentLocContainerIterator operator++(int)
friend bool operator!=(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator(ArgLocContainer &Container, unsigned Index)
friend bool operator==(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator & operator++()
const TemplateArgumentLoc * operator->() const
Iterator adaptor that invents template argument location information for each of the template argumen...
TemplateArgumentLocInventIterator & operator++()
std::iterator_traits< InputIterator >::difference_type difference_type
TemplateArgumentLocInventIterator operator++(int)
friend bool operator==(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
TemplateArgumentLocInventIterator(TreeTransform< Derived > &Self, InputIterator Iter)
friend bool operator!=(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
TypeSourceInfo * getTypeSourceInfo() const
Expr * getSourceExpression() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
const TemplateArgument * pack_iterator
Iterator that traverses the elements of a template argument pack.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DeducedTemplateStorage * getAsDeducedTemplateName() const
Retrieve the deduced template info, if any.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
NestedNameSpecifier getQualifier() const
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceLocation getLAngleLoc() const
Definition TypeLoc.h:1879
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:1894
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:1877
SourceLocation getTemplateKeywordLoc() const
Definition TypeLoc.h:1873
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1863
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:1859
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.
QualType RebuildDeducedTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, QualType Deduced)
By default, builds a new DeducedTemplateSpecializationType with the given deduced type.
ExprResult RebuildPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new expression pack expansion.
ExprResult TransformUnresolvedLookupExpr(UnresolvedLookupExpr *E, bool IsAddressOfOperand)
ExprResult RebuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
Build a new expression representing a call to a source location builtin.
TemplateName RebuildTemplateName(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final)
Build a new template name given a template template parameter pack and the.
QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL)
Transforms a reference type.
OMPClause * RebuildOMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'message' clause.
ExprResult RebuildCXXAddrspaceCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
QualType RebuildTypeOfType(QualType Underlying, TypeOfKind Kind)
Build a new typeof(type) type.
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, Expr *SubExpr, TypeSourceInfo *TInfo, SourceLocation RParenLoc)
Build a new va_arg expression.
ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, SourceLocation RParenLoc)
Build a new C++ zero-initialization expression.
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr)
OMPClause * RebuildOMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'thread_limit' clause.
StmtResult RebuildSEHFinallyStmt(SourceLocation Loc, Stmt *Block)
OMPClause * RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'simdlen' clause.
StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
Build a new C++ try statement.
StmtDiscardKind
The reason why the value of a statement is not discarded, if any.
ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, UnresolvedLookupExpr *OpCoawaitLookup, bool IsImplicit)
Build a new co_await expression.
bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, unsigned NumInputs, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
ExprResult RebuildDesignatedInitExpr(Designation &Desig, MultiExprArg ArrayExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Build a new designated initializer expression.
QualType RebuildUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, SourceLocation NameLoc, Decl *D)
Rebuild an unresolved typename type, given the decl that the UnresolvedUsingTypenameDecl was transfor...
OMPClause * RebuildOMPSizesClause(ArrayRef< Expr * > Sizes, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
ExprResult RebuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
Build a new predefined expression.
ExprResult RebuildCXXStaticCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ static_cast expression.
StmtResult RebuildForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *Init, Sema::ConditionResult Cond, Sema::FullExprArg Inc, SourceLocation RParenLoc, Stmt *Body)
Build a new for statement.
StmtResult RebuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Build a new C++0x range-based for statement.
ExprResult RebuildStmtExpr(SourceLocation LParenLoc, Stmt *SubStmt, SourceLocation RParenLoc, unsigned TemplateDepth)
Build a new GNU statement expression.
QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo *Id, SourceLocation IdLoc, bool DeducedTSTContext)
Build a new typename type that refers to an identifier.
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.
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)
ExprResult RebuildRecoveryExpr(SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< Expr * > SubExprs, QualType Type)
ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, LambdaScopeInfo *LSI)
QualType RebuildIncompleteArrayType(QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new incomplete array type given the element type, size modifier, and index type qualifiers.
CXXRecordDecl::LambdaDependencyKind ComputeLambdaDependency(LambdaScopeInfo *LSI)
ExprResult RebuildPackIndexingExpr(SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpression, Expr *IndexExpr, ArrayRef< Expr * > ExpandedExprs, bool FullySubstituted=false)
StmtResult RebuildOpenACCInitConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, SourceLocation LParenLoc, Expr *Sub, SourceLocation RParenLoc, bool ListInitialization)
Build a new C++ functional-style cast expression.
QualType RebuildCanonicalTagType(TagDecl *Tag)
ExprResult RebuildObjCDictionaryLiteral(SourceRange Range, MutableArrayRef< ObjCDictionaryElement > Elements)
Build a new Objective-C dictionary literal.
StmtResult RebuildIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *Target)
Build a new indirect goto statement.
ExprResult RebuildExtVectorElementExpr(Expr *Base, SourceLocation OpLoc, bool IsArrow, SourceLocation AccessorLoc, IdentifierInfo &Accessor)
Build a new extended vector element access expression.
ExprResult RebuildParenListExpr(SourceLocation LParenLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new expression list in parentheses.
OMPClause * RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocator' clause.
QualType RebuildDependentSizedArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new dependent-sized array type given the element type, size modifier, size expression,...
NamedDecl * TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc)
Transform the given declaration, which was the first part of a nested-name-specifier in a member acce...
OMPClause * RebuildOMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'inclusive' clause.
StmtResult TransformOMPInformationalDirective(OMPExecutableDirective *S)
This is mostly the same as above, but allows 'informational' class directives when rebuilding the stm...
concepts::ExprRequirement * RebuildExprRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
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 RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, bool ListInitialization)
Build a new object-construction expression.
ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, SourceLocation OpLoc, SourceLocation CalleeLoc, bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First, Expr *Second)
Build a new overloaded operator call expression.
OMPClause * RebuildOMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'use_device_addr' clause.
QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc)
Build a dependent bit-precise int given its value type.
OMPClause * RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'hint' clause.
Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var, Expr *Expr, Sema::ConditionKind Kind)
Transform the specified condition.
OMPClause * RebuildOMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'severity' clause.
OMPClause * RebuildOMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'firstprivate' clause.
StmtResult RebuildMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
Build a new MS style inline asm statement.
VarDecl * RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TInfo, QualType T)
Rebuild an Objective-C exception declaration.
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, IdentifierOrOverloadedOperator IO, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
concepts::NestedRequirement * TransformNestedRequirement(concepts::NestedRequirement *Req)
QualType RebuildConstantArrayType(QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new constant array type given the element type, size modifier, (known) size of the array,...
ExprResult RebuildOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > BracketsRanges)
Build a new array shaping expression.
MultiLevelTemplateArgumentList ForgetSubstitution()
"Forget" the template substitution to allow transforming the AST without any template instantiations.
ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc, bool IsGlobalDelete, bool IsArrayForm, Expr *Operand)
Build a new C++ "delete" expression.
ExprResult RebuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP, SourceLocation Loc, TemplateArgument Arg, UnsignedOrNone PackIndex, bool Final)
bool TransformExceptionSpec(SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, SmallVectorImpl< QualType > &Exceptions, bool &Changed)
ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait, SourceLocation StartLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParenLoc)
Build a new array type trait expression.
OMPClause * RebuildOMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'is_device_ptr' clause.
QualType RebuildMacroQualifiedType(QualType T, const IdentifierInfo *MacroII)
Build a new MacroDefined type.
concepts::NestedRequirement * RebuildNestedRequirement(Expr *Constraint)
ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length, ArrayRef< TemplateArgument > PartialArgs)
Build a new expression to compute the length of a parameter pack.
ExprResult RebuildMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBracketLoc)
Build a new matrix subscript expression.
ExprResult TransformParenDependentScopeDeclRefExpr(ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
TemplateParameterList * TransformTemplateParameterList(TemplateParameterList *TPL)
void transformAttrs(Decl *Old, Decl *New)
Transform the attributes associated with the given declaration and place them on the new declaration.
QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL)
QualType RebuildTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &Args)
Build a new template specialization type.
Decl * TransformDecl(SourceLocation Loc, Decl *D)
Transform the given declaration, which is referenced from a type or expression.
bool AlwaysRebuild()
Whether the transformation should always rebuild AST nodes, even if none of the children have changed...
ExprResult RebuildObjCMessageExpr(SourceLocation SuperLoc, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, QualType SuperType, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C instance/class message to 'super'.
OMPClause * RebuildOMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'lastprivate' clause.
QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc, VectorKind)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
bool AllowSkippingCXXConstructExpr()
Wether CXXConstructExpr can be skipped when they are implicit.
OMPClause * RebuildOMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'safelen' clause.
StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *Init, Sema::ConditionResult Cond, SourceLocation RParenLoc)
Start building a new switch statement.
StmtResult RebuildDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new default statement.
StmtResult RebuildObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParenLoc, VarDecl *Var, Stmt *Body)
Build a new Objective-C @catch statement.
OMPClause * RebuildOMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'filter' clause.
ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base, SourceLocation OperatorLoc, bool isArrow, CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage Destroyed)
Build a new pseudo-destructor expression.
QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits, SourceLocation Loc)
Build a bit-precise int given its value type.
ExprResult RebuildObjCArrayLiteral(SourceRange Range, Expr **Elements, unsigned NumElements)
Build a new Objective-C array literal.
ExprResult RebuildCXXUuidofExpr(QualType Type, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(type) expression.
ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE, QualType BaseType, SourceLocation OperatorLoc, bool IsArrow, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs)
Build a new member reference expression.
OMPClause * RebuildOMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'bind' clause.
concepts::NestedRequirement * RebuildNestedRequirement(StringRef InvalidConstraintEntity, const ASTConstraintSatisfaction &Satisfaction)
OMPClause * RebuildOMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'copyprivate' clause.
QualType RebuildAutoType(QualType Deduced, AutoTypeKeyword Keyword, ConceptDecl *TypeConstraintConcept, ArrayRef< TemplateArgument > TypeConstraintArgs)
Build a new C++11 auto type.
QualType RebuildPackExpansionType(QualType Pattern, SourceRange PatternRange, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Build a new pack expansion type.
QualType RebuildVariableArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new variable-length array type given the element type, size modifier, size expression,...
ExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ dynamic_cast expression.
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, TypeSourceInfo *ControllingType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
Build a new generic selection expression with a type predicate.
QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new pointer type given its pointee type.
concepts::TypeRequirement * RebuildTypeRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag)
OMPClause * RebuildOMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'permutation' clause.
OMPClause * RebuildOMPUsesAllocatorsClause(ArrayRef< SemaOpenMP::UsesAllocatorsData > Data, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'uses_allocators' clause.
ExprResult RebuildCXXInheritedCtorInitExpr(QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor, bool ConstructsVBase, bool InheritedFromVBase)
Build a new implicit construction via inherited constructor expression.
ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ const_cast expression.
OMPClause * RebuildOMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'to' clause.
ExprResult RebuildCXXParenListInitExpr(ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
TypeSourceInfo * TransformTypeWithDeducedTST(TypeSourceInfo *TSI)
ExprResult RebuildAtomicExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, AtomicExpr::AtomicOp Op, SourceLocation RParenLoc)
Build a new atomic operation expression.
DeclarationNameInfo TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
Transform the given declaration name.
OMPClause * RebuildOMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_attribute' clause.
void RememberSubstitution(MultiLevelTemplateArgumentList)
StmtResult RebuildDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation LParenLoc, Expr *Cond, SourceLocation RParenLoc)
Build a new do-while statement.
OMPClause * RebuildOMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'if' clause.
StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body)
Attach the body to a new case statement.
ExprResult RebuildTypeTrait(TypeTrait Trait, SourceLocation StartLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
Build a new type trait expression.
ExprResult RebuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Build an empty C++1z fold-expression with the given operator.
QualType TransformTypeWithDeducedTST(QualType T)
Transform a type that is permitted to produce a DeducedTemplateSpecializationType.
OMPClause * RebuildOMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'init' clause.
OMPClause * RebuildOMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'detach' clause.
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, MultiStmtArg Statements, SourceLocation RBraceLoc, bool IsStmtExpr)
Build a new compound statement.
ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, ValueDecl *VD, const DeclarationNameInfo &NameInfo, NamedDecl *Found, TemplateArgumentListInfo *TemplateArgs)
Build a new expression that references a declaration.
QualType RebuildArrayType(QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new array type given the element type, size modifier, size of the array (if known),...
StmtResult RebuildDeclStmt(MutableArrayRef< Decl * > Decls, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new declaration statement.
ExprResult RebuildConvertVectorExpr(SourceLocation BuiltinLoc, Expr *SrcExpr, TypeSourceInfo *DstTInfo, SourceLocation RParenLoc)
Build a new convert vector expression.
QualType RebuildQualifiedType(QualType T, QualifiedTypeLoc TL)
Build a new qualified type given its unqualified type and type location.
OMPClause * RebuildOMPDependClause(OMPDependClause::DependDataTy Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'depend' pseudo clause.
OMPClause * RebuildOMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'aligned' clause.
unsigned TransformTemplateDepth(unsigned Depth)
Transform a template parameter depth level.
QualType RebuildFunctionNoProtoType(QualType ResultType)
Build a new unprototyped function type.
QualType RebuildTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, TypedefNameDecl *Typedef)
Build a new typedef type.
QualType TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, Fn TransformExceptionSpec)
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:2707
SourceLocation getBeginLoc() const
Get the begin source location.
Definition TypeLoc.cpp:193
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Definition TypeBase.h:6180
A container of type source information.
Definition TypeBase.h:8273
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:8284
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:551
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition ExprCXX.h:2896
The base class of the type hierarchy.
Definition TypeBase.h:1833
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition TypeBase.h:2783
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition TypeBase.h:2405
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition TypeBase.h:9044
bool isObjCObjectPointerType() const
Definition TypeBase.h:8714
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9121
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3562
Wrapper for source info for typedefs.
Definition TypeLoc.h:777
void setTypeofLoc(SourceLocation Loc)
Definition TypeLoc.h:2172
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2625
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2244
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition Expr.h:2289
Expr * getSubExpr() const
Definition Expr.h:2285
Opcode getOpcode() const
Definition Expr.h:2280
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:1414
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2316
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:998
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3390
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition ExprCXX.h:3464
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition ExprCXX.h:3459
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Definition ExprCXX.cpp:432
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4126
A set of unresolved declarations.
void append(iterator I, iterator E)
A set of unresolved declarations.
Wrapper for source info for unresolved typename using decls.
Definition TypeLoc.h:782
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition TypeBase.h:5985
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition ExprCXX.h:640
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3395
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3459
Wrapper for source info for types used via transparent aliases.
Definition TypeLoc.h:785
Represents a call to the builtin function __builtin_va_arg.
Definition Expr.h:4957
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
QualType getType() const
Definition Decl.h:723
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Definition Decl.cpp:5588
Value()=default
Represents a variable declaration or definition.
Definition Decl.h:926
@ CInit
C-style initialization with assignment.
Definition Decl.h:931
@ CallInit
Call-style initialization (C++98)
Definition Decl.h:934
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1168
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:3967
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2017
Represents a GCC generic vector type.
Definition TypeBase.h:4176
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2689
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
SourceLocation getNoexceptLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
Retains information about a block that is currently being parsed.
Definition ScopeInfo.h:790
bool ContainsUnexpandedParameterPack
Whether this contains an unexpanded parameter pack.
Definition ScopeInfo.h:728
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition ScopeInfo.h:871
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Definition ScopeInfo.h:874
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
VE builtins.
const AstTypeMatcher< FunctionType > functionType
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition Descriptor.h:29
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
Definition Interp.h:1020
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:804
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OpenMPOriginalSharingModifier
OpenMP 6.0 original sharing modifiers.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
OpenACCDirectiveKind
bool isa(CodeGen::Address addr)
Definition Address.h:330
ArrayTypeTrait
Names for the array type traits.
Definition TypeTraits.h:42
@ CPlusPlus23
OpenACCAtomicKind
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition TypeBase.h:1792
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
TryCaptureKind
Definition Sema.h: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:39
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:61
CXXConstructionKind
Definition ExprCXX.h:1540
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
Definition Specifiers.h:161
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
Definition Lambda.h:36
@ LCK_ByRef
Capturing by reference.
Definition Lambda.h:37
@ LCK_StarThis
Capturing the *this object by copy.
Definition Lambda.h:35
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition Sema.h: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:3720
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
@ Template
We are parsing a template declaration.
Definition Parser.h:81
ActionResult< CXXBaseSpecifier * > BaseResult
Definition Ownership.h:252
OpenMPGrainsizeClauseModifier
OpenMPNumTasksClauseModifier
TagTypeKind
The kind of a tag type.
Definition TypeBase.h:5893
bool transformOMPMappableExprListClause(TreeTransform< Derived > &TT, OMPMappableExprListClause< T > *C, llvm::SmallVectorImpl< Expr * > &Vars, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperIdInfo, llvm::SmallVectorImpl< Expr * > &UnresolvedMappers)
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.
std::tuple< NamedDecl *, TemplateArgument > getReplacedTemplateParameter(Decl *D, unsigned Index)
Internal helper used by Subst* nodes to retrieve a parameter from the AssociatedDecl,...
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
OpenMPAllocateClauseModifier
OpenMP modifiers for 'allocate' clause.
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition OpenMPKinds.h:63
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition OpenMPKinds.h:25
OpenMPDynGroupprivateClauseModifier
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:135
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition Specifiers.h:139
@ Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition Sema.h:800
@ Exists
The symbol exists.
Definition Sema.h:793
@ Error
An error occurred.
Definition Sema.h:803
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:796
MutableArrayRef< Stmt * > MultiStmtArg
Definition Ownership.h:260
OpenMPNumThreadsClauseModifier
U cast(CodeGen::Address addr)
Definition Address.h:327
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition OpenMPKinds.h:48
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition Ownership.h:230
SourceLocIdentKind
Definition Expr.h:5004
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5868
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5889
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5879
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5886
ActionResult< Expr * > ExprResult
Definition Ownership.h:249
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
TypeTrait
Names for traits that operate specifically on types.
Definition TypeTraits.h:21
@ Parens
New-expression has a C++98 paren-delimited initializer.
Definition ExprCXX.h:2245
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Uninstantiated
not instantiated yet
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition Expr.h:1989
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition OpenMPKinds.h:31
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition OpenMPKinds.h:71
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:5006
Holds information about the various types of exception specification.
Definition TypeBase.h:5326
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5342
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5328
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5331
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5334
Extra information about a function prototype.
Definition TypeBase.h:5354
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5359
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
Definition Type.cpp:3276
const NamespaceBaseDecl * Namespace
Iterator range representation begin:end[:step].
Definition ExprOpenMP.h:154
This structure contains most locations needed for by an OMPVarListClause.
An element in an Objective-C dictionary literal.
Definition ExprObjC.h:260
Data for list of allocators.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition Sema.h:13128
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13159
An RAII helper that pops function a function scope on exit.
Definition Sema.h:1310
Keeps information about an identifier in a nested-name-spec.
Definition Sema.h:3294
Location information for a TemplateArgument.
UnsignedOrNone OrigNumExpansions
SourceLocation Ellipsis
UnsignedOrNone NumExpansions