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 or matrix 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 SourceLocation OpLoc,
3107 bool IsArrow,
3108 SourceLocation AccessorLoc,
3109 IdentifierInfo &Accessor) {
3110
3111 CXXScopeSpec SS;
3112 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3114 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3115 /*FirstQualifierInScope*/ nullptr, NameInfo,
3116 /* TemplateArgs */ nullptr,
3117 /*S*/ nullptr);
3118 }
3119
3120 /// Build a new initializer list expression.
3121 ///
3122 /// By default, performs semantic analysis to build the new expression.
3123 /// Subclasses may override this routine to provide different behavior.
3126 SourceLocation RBraceLoc) {
3127 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
3128 }
3129
3130 /// Build a new designated initializer expression.
3131 ///
3132 /// By default, performs semantic analysis to build the new expression.
3133 /// Subclasses may override this routine to provide different behavior.
3135 MultiExprArg ArrayExprs,
3136 SourceLocation EqualOrColonLoc,
3137 bool GNUSyntax,
3138 Expr *Init) {
3140 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3141 Init);
3142 if (Result.isInvalid())
3143 return ExprError();
3144
3145 return Result;
3146 }
3147
3148 /// Build a new value-initialized expression.
3149 ///
3150 /// By default, builds the implicit value initialization without performing
3151 /// any semantic analysis. Subclasses may override this routine to provide
3152 /// different behavior.
3156
3157 /// Build a new \c va_arg expression.
3158 ///
3159 /// By default, performs semantic analysis to build the new expression.
3160 /// Subclasses may override this routine to provide different behavior.
3162 Expr *SubExpr, TypeSourceInfo *TInfo,
3163 SourceLocation RParenLoc) {
3164 return getSema().BuildVAArgExpr(BuiltinLoc,
3165 SubExpr, TInfo,
3166 RParenLoc);
3167 }
3168
3169 /// Build a new expression list in parentheses.
3170 ///
3171 /// By default, performs semantic analysis to build the new expression.
3172 /// Subclasses may override this routine to provide different behavior.
3174 MultiExprArg SubExprs,
3175 SourceLocation RParenLoc) {
3176 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3177 }
3178
3180 unsigned NumUserSpecifiedExprs,
3181 SourceLocation InitLoc,
3182 SourceLocation LParenLoc,
3183 SourceLocation RParenLoc) {
3184 return getSema().ActOnCXXParenListInitExpr(Args, T, NumUserSpecifiedExprs,
3185 InitLoc, LParenLoc, RParenLoc);
3186 }
3187
3188 /// Build a new address-of-label expression.
3189 ///
3190 /// By default, performs semantic analysis, using the name of the label
3191 /// rather than attempting to map the label statement itself.
3192 /// Subclasses may override this routine to provide different behavior.
3194 SourceLocation LabelLoc, LabelDecl *Label) {
3195 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3196 }
3197
3198 /// Build a new GNU statement expression.
3199 ///
3200 /// By default, performs semantic analysis to build the new expression.
3201 /// Subclasses may override this routine to provide different behavior.
3203 SourceLocation RParenLoc, unsigned TemplateDepth) {
3204 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3205 TemplateDepth);
3206 }
3207
3208 /// Build a new __builtin_choose_expr expression.
3209 ///
3210 /// By default, performs semantic analysis to build the new expression.
3211 /// Subclasses may override this routine to provide different behavior.
3213 Expr *Cond, Expr *LHS, Expr *RHS,
3214 SourceLocation RParenLoc) {
3215 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3216 Cond, LHS, RHS,
3217 RParenLoc);
3218 }
3219
3220 /// Build a new generic selection expression with an expression predicate.
3221 ///
3222 /// By default, performs semantic analysis to build the new expression.
3223 /// Subclasses may override this routine to provide different behavior.
3225 SourceLocation DefaultLoc,
3226 SourceLocation RParenLoc,
3227 Expr *ControllingExpr,
3229 ArrayRef<Expr *> Exprs) {
3230 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3231 /*PredicateIsExpr=*/true,
3232 ControllingExpr, Types, Exprs);
3233 }
3234
3235 /// Build a new generic selection expression with a type predicate.
3236 ///
3237 /// By default, performs semantic analysis to build the new expression.
3238 /// Subclasses may override this routine to provide different behavior.
3240 SourceLocation DefaultLoc,
3241 SourceLocation RParenLoc,
3242 TypeSourceInfo *ControllingType,
3244 ArrayRef<Expr *> Exprs) {
3245 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3246 /*PredicateIsExpr=*/false,
3247 ControllingType, Types, Exprs);
3248 }
3249
3250 /// Build a new overloaded operator call expression.
3251 ///
3252 /// By default, performs semantic analysis to build the new expression.
3253 /// The semantic analysis provides the behavior of template instantiation,
3254 /// copying with transformations that turn what looks like an overloaded
3255 /// operator call into a use of a builtin operator, performing
3256 /// argument-dependent lookup, etc. Subclasses may override this routine to
3257 /// provide different behavior.
3259 SourceLocation OpLoc,
3260 SourceLocation CalleeLoc,
3261 bool RequiresADL,
3262 const UnresolvedSetImpl &Functions,
3263 Expr *First, Expr *Second);
3264
3265 /// Build a new C++ "named" cast expression, such as static_cast or
3266 /// reinterpret_cast.
3267 ///
3268 /// By default, this routine dispatches to one of the more-specific routines
3269 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3270 /// Subclasses may override this routine to provide different behavior.
3273 SourceLocation LAngleLoc,
3274 TypeSourceInfo *TInfo,
3275 SourceLocation RAngleLoc,
3276 SourceLocation LParenLoc,
3277 Expr *SubExpr,
3278 SourceLocation RParenLoc) {
3279 switch (Class) {
3280 case Stmt::CXXStaticCastExprClass:
3281 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3282 RAngleLoc, LParenLoc,
3283 SubExpr, RParenLoc);
3284
3285 case Stmt::CXXDynamicCastExprClass:
3286 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3287 RAngleLoc, LParenLoc,
3288 SubExpr, RParenLoc);
3289
3290 case Stmt::CXXReinterpretCastExprClass:
3291 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3292 RAngleLoc, LParenLoc,
3293 SubExpr,
3294 RParenLoc);
3295
3296 case Stmt::CXXConstCastExprClass:
3297 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3298 RAngleLoc, LParenLoc,
3299 SubExpr, RParenLoc);
3300
3301 case Stmt::CXXAddrspaceCastExprClass:
3302 return getDerived().RebuildCXXAddrspaceCastExpr(
3303 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3304
3305 default:
3306 llvm_unreachable("Invalid C++ named cast");
3307 }
3308 }
3309
3310 /// Build a new C++ static_cast expression.
3311 ///
3312 /// By default, performs semantic analysis to build the new expression.
3313 /// Subclasses may override this routine to provide different behavior.
3315 SourceLocation LAngleLoc,
3316 TypeSourceInfo *TInfo,
3317 SourceLocation RAngleLoc,
3318 SourceLocation LParenLoc,
3319 Expr *SubExpr,
3320 SourceLocation RParenLoc) {
3321 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3322 TInfo, SubExpr,
3323 SourceRange(LAngleLoc, RAngleLoc),
3324 SourceRange(LParenLoc, RParenLoc));
3325 }
3326
3327 /// Build a new C++ dynamic_cast expression.
3328 ///
3329 /// By default, performs semantic analysis to build the new expression.
3330 /// Subclasses may override this routine to provide different behavior.
3332 SourceLocation LAngleLoc,
3333 TypeSourceInfo *TInfo,
3334 SourceLocation RAngleLoc,
3335 SourceLocation LParenLoc,
3336 Expr *SubExpr,
3337 SourceLocation RParenLoc) {
3338 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3339 TInfo, SubExpr,
3340 SourceRange(LAngleLoc, RAngleLoc),
3341 SourceRange(LParenLoc, RParenLoc));
3342 }
3343
3344 /// Build a new C++ reinterpret_cast expression.
3345 ///
3346 /// By default, performs semantic analysis to build the new expression.
3347 /// Subclasses may override this routine to provide different behavior.
3349 SourceLocation LAngleLoc,
3350 TypeSourceInfo *TInfo,
3351 SourceLocation RAngleLoc,
3352 SourceLocation LParenLoc,
3353 Expr *SubExpr,
3354 SourceLocation RParenLoc) {
3355 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3356 TInfo, SubExpr,
3357 SourceRange(LAngleLoc, RAngleLoc),
3358 SourceRange(LParenLoc, RParenLoc));
3359 }
3360
3361 /// Build a new C++ const_cast expression.
3362 ///
3363 /// By default, performs semantic analysis to build the new expression.
3364 /// Subclasses may override this routine to provide different behavior.
3366 SourceLocation LAngleLoc,
3367 TypeSourceInfo *TInfo,
3368 SourceLocation RAngleLoc,
3369 SourceLocation LParenLoc,
3370 Expr *SubExpr,
3371 SourceLocation RParenLoc) {
3372 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3373 TInfo, SubExpr,
3374 SourceRange(LAngleLoc, RAngleLoc),
3375 SourceRange(LParenLoc, RParenLoc));
3376 }
3377
3380 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3381 SourceLocation LParenLoc, Expr *SubExpr,
3382 SourceLocation RParenLoc) {
3383 return getSema().BuildCXXNamedCast(
3384 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3385 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3386 }
3387
3388 /// Build a new C++ functional-style cast expression.
3389 ///
3390 /// By default, performs semantic analysis to build the new expression.
3391 /// Subclasses may override this routine to provide different behavior.
3393 SourceLocation LParenLoc,
3394 Expr *Sub,
3395 SourceLocation RParenLoc,
3396 bool ListInitialization) {
3397 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3398 // CXXParenListInitExpr. Pass its expanded arguments so that the
3399 // CXXParenListInitExpr can be rebuilt.
3400 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3402 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3403 RParenLoc, ListInitialization);
3404
3405 if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub))
3407 TInfo, LParenLoc, PLE->getInitExprs(), RParenLoc, ListInitialization);
3408
3409 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3410 MultiExprArg(&Sub, 1), RParenLoc,
3411 ListInitialization);
3412 }
3413
3414 /// Build a new C++ __builtin_bit_cast expression.
3415 ///
3416 /// By default, performs semantic analysis to build the new expression.
3417 /// Subclasses may override this routine to provide different behavior.
3419 TypeSourceInfo *TSI, Expr *Sub,
3420 SourceLocation RParenLoc) {
3421 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3422 }
3423
3424 /// Build a new C++ typeid(type) expression.
3425 ///
3426 /// By default, performs semantic analysis to build the new expression.
3427 /// Subclasses may override this routine to provide different behavior.
3429 SourceLocation TypeidLoc,
3430 TypeSourceInfo *Operand,
3431 SourceLocation RParenLoc) {
3432 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3433 RParenLoc);
3434 }
3435
3436
3437 /// Build a new C++ typeid(expr) expression.
3438 ///
3439 /// By default, performs semantic analysis to build the new expression.
3440 /// Subclasses may override this routine to provide different behavior.
3442 SourceLocation TypeidLoc,
3443 Expr *Operand,
3444 SourceLocation RParenLoc) {
3445 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3446 RParenLoc);
3447 }
3448
3449 /// Build a new C++ __uuidof(type) expression.
3450 ///
3451 /// By default, performs semantic analysis to build the new expression.
3452 /// Subclasses may override this routine to provide different behavior.
3454 TypeSourceInfo *Operand,
3455 SourceLocation RParenLoc) {
3456 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3457 }
3458
3459 /// Build a new C++ __uuidof(expr) expression.
3460 ///
3461 /// By default, performs semantic analysis to build the new expression.
3462 /// Subclasses may override this routine to provide different behavior.
3464 Expr *Operand, SourceLocation RParenLoc) {
3465 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3466 }
3467
3468 /// Build a new C++ "this" expression.
3469 ///
3470 /// By default, performs semantic analysis to build a new "this" expression.
3471 /// Subclasses may override this routine to provide different behavior.
3473 QualType ThisType,
3474 bool isImplicit) {
3475 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3476 return ExprError();
3477 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3478 }
3479
3480 /// Build a new C++ throw expression.
3481 ///
3482 /// By default, performs semantic analysis to build the new expression.
3483 /// Subclasses may override this routine to provide different behavior.
3485 bool IsThrownVariableInScope) {
3486 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3487 }
3488
3489 /// Build a new C++ default-argument expression.
3490 ///
3491 /// By default, builds a new default-argument expression, which does not
3492 /// require any semantic analysis. Subclasses may override this routine to
3493 /// provide different behavior.
3495 Expr *RewrittenExpr) {
3496 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3497 RewrittenExpr, getSema().CurContext);
3498 }
3499
3500 /// Build a new C++11 default-initialization expression.
3501 ///
3502 /// By default, builds a new default field initialization expression, which
3503 /// does not require any semantic analysis. Subclasses may override this
3504 /// routine to provide different behavior.
3509
3510 /// Build a new C++ zero-initialization expression.
3511 ///
3512 /// By default, performs semantic analysis to build the new expression.
3513 /// Subclasses may override this routine to provide different behavior.
3515 SourceLocation LParenLoc,
3516 SourceLocation RParenLoc) {
3517 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3518 /*ListInitialization=*/false);
3519 }
3520
3521 /// Build a new C++ "new" expression.
3522 ///
3523 /// By default, performs semantic analysis to build the new expression.
3524 /// Subclasses may override this routine to provide different behavior.
3526 SourceLocation PlacementLParen,
3527 MultiExprArg PlacementArgs,
3528 SourceLocation PlacementRParen,
3529 SourceRange TypeIdParens, QualType AllocatedType,
3530 TypeSourceInfo *AllocatedTypeInfo,
3531 std::optional<Expr *> ArraySize,
3532 SourceRange DirectInitRange, Expr *Initializer) {
3533 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3534 PlacementLParen,
3535 PlacementArgs,
3536 PlacementRParen,
3537 TypeIdParens,
3538 AllocatedType,
3539 AllocatedTypeInfo,
3540 ArraySize,
3541 DirectInitRange,
3542 Initializer);
3543 }
3544
3545 /// Build a new C++ "delete" expression.
3546 ///
3547 /// By default, performs semantic analysis to build the new expression.
3548 /// Subclasses may override this routine to provide different behavior.
3550 bool IsGlobalDelete,
3551 bool IsArrayForm,
3552 Expr *Operand) {
3553 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3554 Operand);
3555 }
3556
3557 /// Build a new type trait expression.
3558 ///
3559 /// By default, performs semantic analysis to build the new expression.
3560 /// Subclasses may override this routine to provide different behavior.
3562 SourceLocation StartLoc,
3564 SourceLocation RParenLoc) {
3565 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3566 }
3567
3568 /// Build a new array type trait expression.
3569 ///
3570 /// By default, performs semantic analysis to build the new expression.
3571 /// Subclasses may override this routine to provide different behavior.
3573 SourceLocation StartLoc,
3574 TypeSourceInfo *TSInfo,
3575 Expr *DimExpr,
3576 SourceLocation RParenLoc) {
3577 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3578 }
3579
3580 /// Build a new expression trait expression.
3581 ///
3582 /// By default, performs semantic analysis to build the new expression.
3583 /// Subclasses may override this routine to provide different behavior.
3585 SourceLocation StartLoc,
3586 Expr *Queried,
3587 SourceLocation RParenLoc) {
3588 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3589 }
3590
3591 /// Build a new (previously unresolved) declaration reference
3592 /// expression.
3593 ///
3594 /// By default, performs semantic analysis to build the new expression.
3595 /// Subclasses may override this routine to provide different behavior.
3597 NestedNameSpecifierLoc QualifierLoc,
3598 SourceLocation TemplateKWLoc,
3599 const DeclarationNameInfo &NameInfo,
3600 const TemplateArgumentListInfo *TemplateArgs,
3601 bool IsAddressOfOperand,
3602 TypeSourceInfo **RecoveryTSI) {
3603 CXXScopeSpec SS;
3604 SS.Adopt(QualifierLoc);
3605
3606 if (TemplateArgs || TemplateKWLoc.isValid())
3608 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3609
3611 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3612 }
3613
3614 /// Build a new template-id expression.
3615 ///
3616 /// By default, performs semantic analysis to build the new expression.
3617 /// Subclasses may override this routine to provide different behavior.
3619 SourceLocation TemplateKWLoc,
3620 LookupResult &R,
3621 bool RequiresADL,
3622 const TemplateArgumentListInfo *TemplateArgs) {
3623 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3624 TemplateArgs);
3625 }
3626
3627 /// Build a new object-construction expression.
3628 ///
3629 /// By default, performs semantic analysis to build the new expression.
3630 /// Subclasses may override this routine to provide different behavior.
3633 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3634 bool ListInitialization, bool StdInitListInitialization,
3635 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3636 SourceRange ParenRange) {
3637 // Reconstruct the constructor we originally found, which might be
3638 // different if this is a call to an inherited constructor.
3639 CXXConstructorDecl *FoundCtor = Constructor;
3640 if (Constructor->isInheritingConstructor())
3641 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3642
3643 SmallVector<Expr *, 8> ConvertedArgs;
3644 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3645 ConvertedArgs))
3646 return ExprError();
3647
3648 return getSema().BuildCXXConstructExpr(Loc, T, Constructor,
3649 IsElidable,
3650 ConvertedArgs,
3651 HadMultipleCandidates,
3652 ListInitialization,
3653 StdInitListInitialization,
3654 RequiresZeroInit, ConstructKind,
3655 ParenRange);
3656 }
3657
3658 /// Build a new implicit construction via inherited constructor
3659 /// expression.
3662 bool ConstructsVBase,
3663 bool InheritedFromVBase) {
3665 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3666 }
3667
3668 /// Build a new object-construction expression.
3669 ///
3670 /// By default, performs semantic analysis to build the new expression.
3671 /// Subclasses may override this routine to provide different behavior.
3673 SourceLocation LParenOrBraceLoc,
3674 MultiExprArg Args,
3675 SourceLocation RParenOrBraceLoc,
3676 bool ListInitialization) {
3678 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3679 }
3680
3681 /// Build a new object-construction expression.
3682 ///
3683 /// By default, performs semantic analysis to build the new expression.
3684 /// Subclasses may override this routine to provide different behavior.
3686 SourceLocation LParenLoc,
3687 MultiExprArg Args,
3688 SourceLocation RParenLoc,
3689 bool ListInitialization) {
3690 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3691 RParenLoc, ListInitialization);
3692 }
3693
3694 /// Build a new member reference expression.
3695 ///
3696 /// By default, performs semantic analysis to build the new expression.
3697 /// Subclasses may override this routine to provide different behavior.
3699 QualType BaseType,
3700 bool IsArrow,
3701 SourceLocation OperatorLoc,
3702 NestedNameSpecifierLoc QualifierLoc,
3703 SourceLocation TemplateKWLoc,
3704 NamedDecl *FirstQualifierInScope,
3705 const DeclarationNameInfo &MemberNameInfo,
3706 const TemplateArgumentListInfo *TemplateArgs) {
3707 CXXScopeSpec SS;
3708 SS.Adopt(QualifierLoc);
3709
3710 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3711 OperatorLoc, IsArrow,
3712 SS, TemplateKWLoc,
3713 FirstQualifierInScope,
3714 MemberNameInfo,
3715 TemplateArgs, /*S*/nullptr);
3716 }
3717
3718 /// Build a new member reference expression.
3719 ///
3720 /// By default, performs semantic analysis to build the new expression.
3721 /// Subclasses may override this routine to provide different behavior.
3723 SourceLocation OperatorLoc,
3724 bool IsArrow,
3725 NestedNameSpecifierLoc QualifierLoc,
3726 SourceLocation TemplateKWLoc,
3727 NamedDecl *FirstQualifierInScope,
3728 LookupResult &R,
3729 const TemplateArgumentListInfo *TemplateArgs) {
3730 CXXScopeSpec SS;
3731 SS.Adopt(QualifierLoc);
3732
3733 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3734 OperatorLoc, IsArrow,
3735 SS, TemplateKWLoc,
3736 FirstQualifierInScope,
3737 R, TemplateArgs, /*S*/nullptr);
3738 }
3739
3740 /// Build a new noexcept expression.
3741 ///
3742 /// By default, performs semantic analysis to build the new expression.
3743 /// Subclasses may override this routine to provide different behavior.
3745 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3746 }
3747
3750
3751 /// Build a new expression to compute the length of a parameter pack.
3753 SourceLocation PackLoc,
3754 SourceLocation RParenLoc,
3755 UnsignedOrNone Length,
3756 ArrayRef<TemplateArgument> PartialArgs) {
3757 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3758 RParenLoc, Length, PartialArgs);
3759 }
3760
3762 SourceLocation RSquareLoc,
3763 Expr *PackIdExpression, Expr *IndexExpr,
3764 ArrayRef<Expr *> ExpandedExprs,
3765 bool FullySubstituted = false) {
3766 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3767 IndexExpr, RSquareLoc, ExpandedExprs,
3768 FullySubstituted);
3769 }
3770
3771 /// Build a new expression representing a call to a source location
3772 /// builtin.
3773 ///
3774 /// By default, performs semantic analysis to build the new expression.
3775 /// Subclasses may override this routine to provide different behavior.
3777 SourceLocation BuiltinLoc,
3778 SourceLocation RPLoc,
3779 DeclContext *ParentContext) {
3780 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3781 ParentContext);
3782 }
3783
3785 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3786 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3788 CXXScopeSpec SS;
3789 SS.Adopt(NNS);
3790 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3791 ConceptNameInfo,
3792 FoundDecl,
3793 NamedConcept, TALI);
3794 if (Result.isInvalid())
3795 return ExprError();
3796 return Result;
3797 }
3798
3799 /// \brief Build a new requires expression.
3800 ///
3801 /// By default, performs semantic analysis to build the new expression.
3802 /// Subclasses may override this routine to provide different behavior.
3805 SourceLocation LParenLoc,
3806 ArrayRef<ParmVarDecl *> LocalParameters,
3807 SourceLocation RParenLoc,
3809 SourceLocation ClosingBraceLoc) {
3810 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3811 LocalParameters, RParenLoc, Requirements,
3812 ClosingBraceLoc);
3813 }
3814
3818 return SemaRef.BuildTypeRequirement(SubstDiag);
3819 }
3820
3822 return SemaRef.BuildTypeRequirement(T);
3823 }
3824
3827 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3828 SourceLocation NoexceptLoc,
3830 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3831 std::move(Ret));
3832 }
3833
3835 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3837 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3838 std::move(Ret));
3839 }
3840
3842 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3843 const ASTConstraintSatisfaction &Satisfaction) {
3844 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3845 Satisfaction);
3846 }
3847
3849 return SemaRef.BuildNestedRequirement(Constraint);
3850 }
3851
3852 /// \brief Build a new Objective-C boxed expression.
3853 ///
3854 /// By default, performs semantic analysis to build the new expression.
3855 /// Subclasses may override this routine to provide different behavior.
3857 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3858 }
3859
3860 /// Build a new Objective-C array literal.
3861 ///
3862 /// By default, performs semantic analysis to build the new expression.
3863 /// Subclasses may override this routine to provide different behavior.
3865 Expr **Elements, unsigned NumElements) {
3867 Range, MultiExprArg(Elements, NumElements));
3868 }
3869
3871 Expr *Base, Expr *Key,
3872 ObjCMethodDecl *getterMethod,
3873 ObjCMethodDecl *setterMethod) {
3875 RB, Base, Key, getterMethod, setterMethod);
3876 }
3877
3878 /// Build a new Objective-C dictionary literal.
3879 ///
3880 /// By default, performs semantic analysis to build the new expression.
3881 /// Subclasses may override this routine to provide different behavior.
3886
3887 /// Build a new Objective-C \@encode expression.
3888 ///
3889 /// By default, performs semantic analysis to build the new expression.
3890 /// Subclasses may override this routine to provide different behavior.
3892 TypeSourceInfo *EncodeTypeInfo,
3893 SourceLocation RParenLoc) {
3894 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3895 RParenLoc);
3896 }
3897
3898 /// Build a new Objective-C class message.
3900 Selector Sel,
3901 ArrayRef<SourceLocation> SelectorLocs,
3903 SourceLocation LBracLoc,
3904 MultiExprArg Args,
3905 SourceLocation RBracLoc) {
3906 return SemaRef.ObjC().BuildClassMessage(
3907 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3908 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3909 RBracLoc, Args);
3910 }
3911
3912 /// Build a new Objective-C instance message.
3914 Selector Sel,
3915 ArrayRef<SourceLocation> SelectorLocs,
3917 SourceLocation LBracLoc,
3918 MultiExprArg Args,
3919 SourceLocation RBracLoc) {
3920 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3921 /*SuperLoc=*/SourceLocation(),
3922 Sel, Method, LBracLoc,
3923 SelectorLocs, RBracLoc, Args);
3924 }
3925
3926 /// Build a new Objective-C instance/class message to 'super'.
3928 Selector Sel,
3929 ArrayRef<SourceLocation> SelectorLocs,
3930 QualType SuperType,
3932 SourceLocation LBracLoc,
3933 MultiExprArg Args,
3934 SourceLocation RBracLoc) {
3935 return Method->isInstanceMethod()
3936 ? SemaRef.ObjC().BuildInstanceMessage(
3937 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3938 SelectorLocs, RBracLoc, Args)
3939 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3940 Sel, Method, LBracLoc,
3941 SelectorLocs, RBracLoc, Args);
3942 }
3943
3944 /// Build a new Objective-C ivar reference expression.
3945 ///
3946 /// By default, performs semantic analysis to build the new expression.
3947 /// Subclasses may override this routine to provide different behavior.
3949 SourceLocation IvarLoc,
3950 bool IsArrow, bool IsFreeIvar) {
3951 CXXScopeSpec SS;
3952 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3954 BaseArg, BaseArg->getType(),
3955 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3956 /*FirstQualifierInScope=*/nullptr, NameInfo,
3957 /*TemplateArgs=*/nullptr,
3958 /*S=*/nullptr);
3959 if (IsFreeIvar && Result.isUsable())
3960 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3961 return Result;
3962 }
3963
3964 /// Build a new Objective-C property reference expression.
3965 ///
3966 /// By default, performs semantic analysis to build the new expression.
3967 /// Subclasses may override this routine to provide different behavior.
3970 SourceLocation PropertyLoc) {
3971 CXXScopeSpec SS;
3972 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3973 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3974 /*FIXME:*/PropertyLoc,
3975 /*IsArrow=*/false,
3976 SS, SourceLocation(),
3977 /*FirstQualifierInScope=*/nullptr,
3978 NameInfo,
3979 /*TemplateArgs=*/nullptr,
3980 /*S=*/nullptr);
3981 }
3982
3983 /// Build a new Objective-C property reference expression.
3984 ///
3985 /// By default, performs semantic analysis to build the new expression.
3986 /// Subclasses may override this routine to provide different behavior.
3988 ObjCMethodDecl *Getter,
3989 ObjCMethodDecl *Setter,
3990 SourceLocation PropertyLoc) {
3991 // Since these expressions can only be value-dependent, we do not
3992 // need to perform semantic analysis again.
3993 return Owned(
3994 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3996 PropertyLoc, Base));
3997 }
3998
3999 /// Build a new Objective-C "isa" expression.
4000 ///
4001 /// By default, performs semantic analysis to build the new expression.
4002 /// Subclasses may override this routine to provide different behavior.
4004 SourceLocation OpLoc, bool IsArrow) {
4005 CXXScopeSpec SS;
4006 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
4007 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
4008 OpLoc, IsArrow,
4009 SS, SourceLocation(),
4010 /*FirstQualifierInScope=*/nullptr,
4011 NameInfo,
4012 /*TemplateArgs=*/nullptr,
4013 /*S=*/nullptr);
4014 }
4015
4016 /// Build a new shuffle vector expression.
4017 ///
4018 /// By default, performs semantic analysis to build the new expression.
4019 /// Subclasses may override this routine to provide different behavior.
4021 MultiExprArg SubExprs,
4022 SourceLocation RParenLoc) {
4023 // Find the declaration for __builtin_shufflevector
4024 const IdentifierInfo &Name
4025 = SemaRef.Context.Idents.get("__builtin_shufflevector");
4026 TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
4027 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
4028 assert(!Lookup.empty() && "No __builtin_shufflevector?");
4029
4030 // Build a reference to the __builtin_shufflevector builtin
4032 Expr *Callee = new (SemaRef.Context)
4033 DeclRefExpr(SemaRef.Context, Builtin, false,
4034 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
4035 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
4036 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
4037 CK_BuiltinFnToFnPtr).get();
4038
4039 // Build the CallExpr
4040 ExprResult TheCall = CallExpr::Create(
4041 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
4042 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
4044
4045 // Type-check the __builtin_shufflevector expression.
4046 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
4047 }
4048
4049 /// Build a new convert vector expression.
4051 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
4052 SourceLocation RParenLoc) {
4053 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
4054 }
4055
4056 /// Build a new template argument pack expansion.
4057 ///
4058 /// By default, performs semantic analysis to build a new pack expansion
4059 /// for a template argument. Subclasses may override this routine to provide
4060 /// different behavior.
4062 SourceLocation EllipsisLoc,
4063 UnsignedOrNone NumExpansions) {
4064 switch (Pattern.getArgument().getKind()) {
4068 EllipsisLoc, NumExpansions);
4069 if (Result.isInvalid())
4070 return TemplateArgumentLoc();
4071
4073 /*IsCanonical=*/false),
4074 Result.get());
4075 }
4076
4078 return TemplateArgumentLoc(
4079 SemaRef.Context,
4081 NumExpansions),
4082 Pattern.getTemplateKWLoc(), Pattern.getTemplateQualifierLoc(),
4083 Pattern.getTemplateNameLoc(), EllipsisLoc);
4084
4092 llvm_unreachable("Pack expansion pattern has no parameter packs");
4093
4095 if (TypeSourceInfo *Expansion
4096 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4097 EllipsisLoc,
4098 NumExpansions))
4099 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4100 Expansion);
4101 break;
4102 }
4103
4104 return TemplateArgumentLoc();
4105 }
4106
4107 /// Build a new expression pack expansion.
4108 ///
4109 /// By default, performs semantic analysis to build a new pack expansion
4110 /// for an expression. Subclasses may override this routine to provide
4111 /// different behavior.
4113 UnsignedOrNone NumExpansions) {
4114 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4115 }
4116
4117 /// Build a new C++1z fold-expression.
4118 ///
4119 /// By default, performs semantic analysis in order to build a new fold
4120 /// expression.
4122 SourceLocation LParenLoc, Expr *LHS,
4123 BinaryOperatorKind Operator,
4124 SourceLocation EllipsisLoc, Expr *RHS,
4125 SourceLocation RParenLoc,
4126 UnsignedOrNone NumExpansions) {
4127 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4128 EllipsisLoc, RHS, RParenLoc,
4129 NumExpansions);
4130 }
4131
4133 LambdaScopeInfo *LSI) {
4134 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4135 if (Expr *Init = PVD->getInit())
4137 Init->containsUnexpandedParameterPack();
4138 else if (PVD->hasUninstantiatedDefaultArg())
4140 PVD->getUninstantiatedDefaultArg()
4141 ->containsUnexpandedParameterPack();
4142 }
4143 return getSema().BuildLambdaExpr(StartLoc, EndLoc);
4144 }
4145
4146 /// Build an empty C++1z fold-expression with the given operator.
4147 ///
4148 /// By default, produces the fallback value for the fold-expression, or
4149 /// produce an error if there is no fallback value.
4151 BinaryOperatorKind Operator) {
4152 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4153 }
4154
4155 /// Build a new atomic operation expression.
4156 ///
4157 /// By default, performs semantic analysis to build the new expression.
4158 /// Subclasses may override this routine to provide different behavior.
4161 SourceLocation RParenLoc) {
4162 // Use this for all of the locations, since we don't know the difference
4163 // between the call and the expr at this point.
4164 SourceRange Range{BuiltinLoc, RParenLoc};
4165 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4167 }
4168
4170 ArrayRef<Expr *> SubExprs, QualType Type) {
4171 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4172 }
4173
4175 SourceLocation BeginLoc,
4176 SourceLocation DirLoc,
4177 SourceLocation EndLoc,
4179 StmtResult StrBlock) {
4181 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4182 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, StrBlock);
4183 }
4184
4195
4197 SourceLocation BeginLoc,
4198 SourceLocation DirLoc,
4199 SourceLocation EndLoc,
4201 StmtResult Loop) {
4203 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4204 OpenACCAtomicKind::None, SourceLocation{}, EndLoc, Clauses, Loop);
4205 }
4206
4208 SourceLocation DirLoc,
4209 SourceLocation EndLoc,
4211 StmtResult StrBlock) {
4213 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4215 Clauses, StrBlock);
4216 }
4217
4227
4237
4239 SourceLocation DirLoc,
4240 SourceLocation EndLoc,
4242 StmtResult StrBlock) {
4246 Clauses, StrBlock);
4247 }
4248
4250 SourceLocation DirLoc,
4251 SourceLocation EndLoc,
4252 ArrayRef<OpenACCClause *> Clauses) {
4254 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4256 Clauses, {});
4257 }
4258
4268
4270 SourceLocation DirLoc,
4271 SourceLocation EndLoc,
4272 ArrayRef<OpenACCClause *> Clauses) {
4274 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4276 Clauses, {});
4277 }
4278
4280 SourceLocation DirLoc,
4281 SourceLocation EndLoc,
4282 ArrayRef<OpenACCClause *> Clauses) {
4284 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4286 Clauses, {});
4287 }
4288
4290 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4291 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4292 SourceLocation RParenLoc, SourceLocation EndLoc,
4293 ArrayRef<OpenACCClause *> Clauses) {
4295 Exprs.push_back(DevNumExpr);
4296 llvm::append_range(Exprs, QueueIdExprs);
4298 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4299 Exprs, OpenACCAtomicKind::None, RParenLoc, EndLoc, Clauses, {});
4300 }
4301
4303 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4304 SourceLocation ReadOnlyLoc, ArrayRef<Expr *> VarList,
4305 SourceLocation RParenLoc, SourceLocation EndLoc) {
4307 OpenACCDirectiveKind::Cache, BeginLoc, DirLoc, LParenLoc, ReadOnlyLoc,
4308 VarList, OpenACCAtomicKind::None, RParenLoc, EndLoc, {}, {});
4309 }
4310
4312 SourceLocation DirLoc,
4313 OpenACCAtomicKind AtKind,
4314 SourceLocation EndLoc,
4316 StmtResult AssociatedStmt) {
4318 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4319 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, Clauses,
4320 AssociatedStmt);
4321 }
4322
4326
4329 const NonTypeTemplateParmDecl *NTTP,
4331 UnsignedOrNone PackIndex, bool Final) {
4333 AssociatedDecl, NTTP, Loc, Arg, PackIndex, Final);
4334 }
4335
4337 SourceLocation StartLoc,
4338 SourceLocation LParenLoc,
4339 SourceLocation EndLoc) {
4340 return getSema().OpenMP().ActOnOpenMPTransparentClause(ImpexType, StartLoc,
4341 LParenLoc, EndLoc);
4342 }
4343
4344private:
4345 QualType TransformTypeInObjectScope(TypeLocBuilder &TLB, TypeLoc TL,
4346 QualType ObjectType,
4347 NamedDecl *FirstQualifierInScope);
4348
4349 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4350 QualType ObjectType,
4351 NamedDecl *FirstQualifierInScope) {
4352 if (getDerived().AlreadyTransformed(TSInfo->getType()))
4353 return TSInfo;
4354
4355 TypeLocBuilder TLB;
4356 QualType T = TransformTypeInObjectScope(TLB, TSInfo->getTypeLoc(),
4357 ObjectType, FirstQualifierInScope);
4358 if (T.isNull())
4359 return nullptr;
4360 return TLB.getTypeSourceInfo(SemaRef.Context, T);
4361 }
4362
4363 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4364 DependentNameTypeLoc TL,
4365 bool DeducibleTSTContext,
4366 QualType ObjectType = QualType(),
4367 NamedDecl *UnqualLookup = nullptr);
4368
4370 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4372
4373 OpenACCClause *
4374 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4375 OpenACCDirectiveKind DirKind,
4376 const OpenACCClause *OldClause);
4377};
4378
4379template <typename Derived>
4381 if (!S)
4382 return S;
4383
4384 switch (S->getStmtClass()) {
4385 case Stmt::NoStmtClass: break;
4386
4387 // Transform individual statement nodes
4388 // Pass SDK into statements that can produce a value
4389#define STMT(Node, Parent) \
4390 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4391#define VALUESTMT(Node, Parent) \
4392 case Stmt::Node##Class: \
4393 return getDerived().Transform##Node(cast<Node>(S), SDK);
4394#define ABSTRACT_STMT(Node)
4395#define EXPR(Node, Parent)
4396#include "clang/AST/StmtNodes.inc"
4397
4398 // Transform expressions by calling TransformExpr.
4399#define STMT(Node, Parent)
4400#define ABSTRACT_STMT(Stmt)
4401#define EXPR(Node, Parent) case Stmt::Node##Class:
4402#include "clang/AST/StmtNodes.inc"
4403 {
4404 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4405
4407 E = getSema().ActOnStmtExprResult(E);
4408 return getSema().ActOnExprStmt(E, SDK == StmtDiscardKind::Discarded);
4409 }
4410 }
4411
4412 return S;
4413}
4414
4415template<typename Derived>
4417 if (!S)
4418 return S;
4419
4420 switch (S->getClauseKind()) {
4421 default: break;
4422 // Transform individual clause nodes
4423#define GEN_CLANG_CLAUSE_CLASS
4424#define CLAUSE_CLASS(Enum, Str, Class) \
4425 case Enum: \
4426 return getDerived().Transform##Class(cast<Class>(S));
4427#include "llvm/Frontend/OpenMP/OMP.inc"
4428 }
4429
4430 return S;
4431}
4432
4433
4434template<typename Derived>
4436 if (!E)
4437 return E;
4438
4439 switch (E->getStmtClass()) {
4440 case Stmt::NoStmtClass: break;
4441#define STMT(Node, Parent) case Stmt::Node##Class: break;
4442#define ABSTRACT_STMT(Stmt)
4443#define EXPR(Node, Parent) \
4444 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4445#include "clang/AST/StmtNodes.inc"
4446 }
4447
4448 return E;
4449}
4450
4451template<typename Derived>
4453 bool NotCopyInit) {
4454 // Initializers are instantiated like expressions, except that various outer
4455 // layers are stripped.
4456 if (!Init)
4457 return Init;
4458
4459 if (auto *FE = dyn_cast<FullExpr>(Init))
4460 Init = FE->getSubExpr();
4461
4462 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4463 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4464 Init = OVE->getSourceExpr();
4465 }
4466
4467 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4468 Init = MTE->getSubExpr();
4469
4470 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4471 Init = Binder->getSubExpr();
4472
4473 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4474 Init = ICE->getSubExprAsWritten();
4475
4476 if (CXXStdInitializerListExpr *ILE =
4477 dyn_cast<CXXStdInitializerListExpr>(Init))
4478 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4479
4480 // If this is copy-initialization, we only need to reconstruct
4481 // InitListExprs. Other forms of copy-initialization will be a no-op if
4482 // the initializer is already the right type.
4483 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4484 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4485 return getDerived().TransformExpr(Init);
4486
4487 // Revert value-initialization back to empty parens.
4488 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4489 SourceRange Parens = VIE->getSourceRange();
4490 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4491 Parens.getEnd());
4492 }
4493
4494 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4496 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4497 SourceLocation());
4498
4499 // Revert initialization by constructor back to a parenthesized or braced list
4500 // of expressions. Any other form of initializer can just be reused directly.
4501 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4502 return getDerived().TransformExpr(Init);
4503
4504 // If the initialization implicitly converted an initializer list to a
4505 // std::initializer_list object, unwrap the std::initializer_list too.
4506 if (Construct && Construct->isStdInitListInitialization())
4507 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4508
4509 // Enter a list-init context if this was list initialization.
4512 Construct->isListInitialization());
4513
4514 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4515 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4516 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4517 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4518 SmallVector<Expr*, 8> NewArgs;
4519 bool ArgChanged = false;
4520 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4521 /*IsCall*/true, NewArgs, &ArgChanged))
4522 return ExprError();
4523
4524 // If this was list initialization, revert to syntactic list form.
4525 if (Construct->isListInitialization())
4526 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4527 Construct->getEndLoc());
4528
4529 // Build a ParenListExpr to represent anything else.
4531 if (Parens.isInvalid()) {
4532 // This was a variable declaration's initialization for which no initializer
4533 // was specified.
4534 assert(NewArgs.empty() &&
4535 "no parens or braces but have direct init with arguments?");
4536 return ExprEmpty();
4537 }
4538 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4539 Parens.getEnd());
4540}
4541
4542template<typename Derived>
4544 unsigned NumInputs,
4545 bool IsCall,
4546 SmallVectorImpl<Expr *> &Outputs,
4547 bool *ArgChanged) {
4548 for (unsigned I = 0; I != NumInputs; ++I) {
4549 // If requested, drop call arguments that need to be dropped.
4550 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4551 if (ArgChanged)
4552 *ArgChanged = true;
4553
4554 break;
4555 }
4556
4557 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4558 Expr *Pattern = Expansion->getPattern();
4559
4561 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4562 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4563
4564 // Determine whether the set of unexpanded parameter packs can and should
4565 // be expanded.
4566 bool Expand = true;
4567 bool RetainExpansion = false;
4568 UnsignedOrNone OrigNumExpansions = Expansion->getNumExpansions();
4569 UnsignedOrNone NumExpansions = OrigNumExpansions;
4571 Expansion->getEllipsisLoc(), Pattern->getSourceRange(),
4572 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
4573 RetainExpansion, NumExpansions))
4574 return true;
4575
4576 if (!Expand) {
4577 // The transform has determined that we should perform a simple
4578 // transformation on the pack expansion, producing another pack
4579 // expansion.
4580 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
4581 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4582 if (OutPattern.isInvalid())
4583 return true;
4584
4585 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4586 Expansion->getEllipsisLoc(),
4587 NumExpansions);
4588 if (Out.isInvalid())
4589 return true;
4590
4591 if (ArgChanged)
4592 *ArgChanged = true;
4593 Outputs.push_back(Out.get());
4594 continue;
4595 }
4596
4597 // Record right away that the argument was changed. This needs
4598 // to happen even if the array expands to nothing.
4599 if (ArgChanged) *ArgChanged = true;
4600
4601 // The transform has determined that we should perform an elementwise
4602 // expansion of the pattern. Do so.
4603 for (unsigned I = 0; I != *NumExpansions; ++I) {
4604 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
4605 ExprResult Out = getDerived().TransformExpr(Pattern);
4606 if (Out.isInvalid())
4607 return true;
4608
4609 if (Out.get()->containsUnexpandedParameterPack()) {
4610 Out = getDerived().RebuildPackExpansion(
4611 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4612 if (Out.isInvalid())
4613 return true;
4614 }
4615
4616 Outputs.push_back(Out.get());
4617 }
4618
4619 // If we're supposed to retain a pack expansion, do so by temporarily
4620 // forgetting the partially-substituted parameter pack.
4621 if (RetainExpansion) {
4622 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4623
4624 ExprResult Out = getDerived().TransformExpr(Pattern);
4625 if (Out.isInvalid())
4626 return true;
4627
4628 Out = getDerived().RebuildPackExpansion(
4629 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4630 if (Out.isInvalid())
4631 return true;
4632
4633 Outputs.push_back(Out.get());
4634 }
4635
4636 continue;
4637 }
4638
4640 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4641 : getDerived().TransformExpr(Inputs[I]);
4642 if (Result.isInvalid())
4643 return true;
4644
4645 if (Result.get() != Inputs[I] && ArgChanged)
4646 *ArgChanged = true;
4647
4648 Outputs.push_back(Result.get());
4649 }
4650
4651 return false;
4652}
4653
4654template <typename Derived>
4657
4660 /*LambdaContextDecl=*/nullptr,
4662 /*ShouldEnter=*/Kind == Sema::ConditionKind::ConstexprIf);
4663
4664 if (Var) {
4665 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4667
4668 if (!ConditionVar)
4669 return Sema::ConditionError();
4670
4671 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4672 }
4673
4674 if (Expr) {
4675 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4676
4677 if (CondExpr.isInvalid())
4678 return Sema::ConditionError();
4679
4680 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4681 /*MissingOK=*/true);
4682 }
4683
4684 return Sema::ConditionResult();
4685}
4686
4687template <typename Derived>
4689 NestedNameSpecifierLoc NNS, QualType ObjectType,
4690 NamedDecl *FirstQualifierInScope) {
4692
4693 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4694 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4695 Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix)
4696 Qualifiers.push_back(Qualifier);
4697 };
4698 insertNNS(NNS);
4699
4700 CXXScopeSpec SS;
4701 while (!Qualifiers.empty()) {
4702 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4704
4705 switch (QNNS.getKind()) {
4707 llvm_unreachable("unexpected null nested name specifier");
4708
4711 Q.getLocalBeginLoc(), const_cast<NamespaceBaseDecl *>(
4713 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4714 break;
4715 }
4716
4718 // There is no meaningful transformation that one could perform on the
4719 // global scope.
4720 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4721 break;
4722
4724 CXXRecordDecl *RD = cast_or_null<CXXRecordDecl>(
4726 SS.MakeMicrosoftSuper(SemaRef.Context, RD, Q.getBeginLoc(),
4727 Q.getEndLoc());
4728 break;
4729 }
4730
4732 assert(SS.isEmpty());
4733 TypeLoc TL = Q.castAsTypeLoc();
4734
4735 if (auto DNT = TL.getAs<DependentNameTypeLoc>()) {
4736 NestedNameSpecifierLoc QualifierLoc = DNT.getQualifierLoc();
4737 if (QualifierLoc) {
4738 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4739 QualifierLoc, ObjectType, FirstQualifierInScope);
4740 if (!QualifierLoc)
4741 return NestedNameSpecifierLoc();
4742 ObjectType = QualType();
4743 FirstQualifierInScope = nullptr;
4744 }
4745 SS.Adopt(QualifierLoc);
4747 const_cast<IdentifierInfo *>(DNT.getTypePtr()->getIdentifier()),
4748 DNT.getNameLoc(), Q.getLocalEndLoc(), ObjectType);
4749 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo,
4750 false, SS,
4751 FirstQualifierInScope, false))
4752 return NestedNameSpecifierLoc();
4753 return SS.getWithLocInContext(SemaRef.Context);
4754 }
4755
4756 QualType T = TL.getType();
4757 TypeLocBuilder TLB;
4758 if (!getDerived().AlreadyTransformed(T)) {
4759 T = TransformTypeInObjectScope(TLB, TL, ObjectType,
4760 FirstQualifierInScope);
4761 if (T.isNull())
4762 return NestedNameSpecifierLoc();
4763 TL = TLB.getTypeLocInContext(SemaRef.Context, T);
4764 }
4765
4766 if (T->isDependentType() || T->isRecordType() ||
4767 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4768 if (T->isEnumeralType())
4769 SemaRef.Diag(TL.getBeginLoc(),
4770 diag::warn_cxx98_compat_enum_nested_name_spec);
4771 SS.Make(SemaRef.Context, TL, Q.getLocalEndLoc());
4772 break;
4773 }
4774 // If the nested-name-specifier is an invalid type def, don't emit an
4775 // error because a previous error should have already been emitted.
4777 if (!TTL || !TTL.getDecl()->isInvalidDecl()) {
4778 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4779 << T << SS.getRange();
4780 }
4781 return NestedNameSpecifierLoc();
4782 }
4783 }
4784 }
4785
4786 // Don't rebuild the nested-name-specifier if we don't have to.
4787 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4789 return NNS;
4790
4791 // If we can re-use the source-location data from the original
4792 // nested-name-specifier, do so.
4793 if (SS.location_size() == NNS.getDataLength() &&
4794 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4796
4797 // Allocate new nested-name-specifier location information.
4798 return SS.getWithLocInContext(SemaRef.Context);
4799}
4800
4801template<typename Derived>
4805 DeclarationName Name = NameInfo.getName();
4806 if (!Name)
4807 return DeclarationNameInfo();
4808
4809 switch (Name.getNameKind()) {
4817 return NameInfo;
4818
4820 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4821 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4822 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4823 if (!NewTemplate)
4824 return DeclarationNameInfo();
4825
4826 DeclarationNameInfo NewNameInfo(NameInfo);
4827 NewNameInfo.setName(
4828 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
4829 return NewNameInfo;
4830 }
4831
4835 TypeSourceInfo *NewTInfo;
4836 CanQualType NewCanTy;
4837 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4838 NewTInfo = getDerived().TransformType(OldTInfo);
4839 if (!NewTInfo)
4840 return DeclarationNameInfo();
4841 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4842 }
4843 else {
4844 NewTInfo = nullptr;
4845 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4846 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4847 if (NewT.isNull())
4848 return DeclarationNameInfo();
4849 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4850 }
4851
4852 DeclarationName NewName
4853 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4854 NewCanTy);
4855 DeclarationNameInfo NewNameInfo(NameInfo);
4856 NewNameInfo.setName(NewName);
4857 NewNameInfo.setNamedTypeInfo(NewTInfo);
4858 return NewNameInfo;
4859 }
4860 }
4861
4862 llvm_unreachable("Unknown name kind.");
4863}
4864
4865template <typename Derived>
4867 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
4869 QualType ObjectType, bool AllowInjectedClassName) {
4870 if (const IdentifierInfo *II = IO.getIdentifier())
4871 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, *II, NameLoc,
4872 ObjectType, AllowInjectedClassName);
4873 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, IO.getOperator(),
4874 NameLoc, ObjectType,
4875 AllowInjectedClassName);
4876}
4877
4878template <typename Derived>
4880 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
4881 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
4882 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
4884 TemplateName UnderlyingName = QTN->getUnderlyingTemplate();
4885
4886 if (QualifierLoc) {
4887 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4888 QualifierLoc, ObjectType, FirstQualifierInScope);
4889 if (!QualifierLoc)
4890 return TemplateName();
4891 }
4892
4893 NestedNameSpecifierLoc UnderlyingQualifier;
4894 TemplateName NewUnderlyingName = getDerived().TransformTemplateName(
4895 UnderlyingQualifier, TemplateKWLoc, UnderlyingName, NameLoc, ObjectType,
4896 FirstQualifierInScope, AllowInjectedClassName);
4897 if (NewUnderlyingName.isNull())
4898 return TemplateName();
4899 assert(!UnderlyingQualifier && "unexpected qualifier");
4900
4901 if (!getDerived().AlwaysRebuild() &&
4902 QualifierLoc.getNestedNameSpecifier() == QTN->getQualifier() &&
4903 NewUnderlyingName == UnderlyingName)
4904 return Name;
4905 CXXScopeSpec SS;
4906 SS.Adopt(QualifierLoc);
4907 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4908 NewUnderlyingName);
4909 }
4910
4912 if (QualifierLoc) {
4913 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
4914 QualifierLoc, ObjectType, FirstQualifierInScope);
4915 if (!QualifierLoc)
4916 return TemplateName();
4917 // The qualifier-in-scope and object type only apply to the leftmost
4918 // entity.
4919 ObjectType = QualType();
4920 }
4921
4922 if (!getDerived().AlwaysRebuild() &&
4923 QualifierLoc.getNestedNameSpecifier() == DTN->getQualifier() &&
4924 ObjectType.isNull())
4925 return Name;
4926
4927 CXXScopeSpec SS;
4928 SS.Adopt(QualifierLoc);
4929 return getDerived().RebuildTemplateName(SS, TemplateKWLoc, DTN->getName(),
4930 NameLoc, ObjectType,
4931 AllowInjectedClassName);
4932 }
4933
4936 assert(!QualifierLoc && "Unexpected qualified SubstTemplateTemplateParm");
4937
4938 NestedNameSpecifierLoc ReplacementQualifierLoc;
4939 TemplateName ReplacementName = S->getReplacement();
4940 if (NestedNameSpecifier Qualifier = ReplacementName.getQualifier()) {
4942 Builder.MakeTrivial(SemaRef.Context, Qualifier, NameLoc);
4943 ReplacementQualifierLoc = Builder.getWithLocInContext(SemaRef.Context);
4944 }
4945
4946 TemplateName NewName = getDerived().TransformTemplateName(
4947 ReplacementQualifierLoc, TemplateKWLoc, ReplacementName, NameLoc,
4948 ObjectType, FirstQualifierInScope, AllowInjectedClassName);
4949 if (NewName.isNull())
4950 return TemplateName();
4951 Decl *AssociatedDecl =
4952 getDerived().TransformDecl(NameLoc, S->getAssociatedDecl());
4953 if (!getDerived().AlwaysRebuild() && NewName == S->getReplacement() &&
4954 AssociatedDecl == S->getAssociatedDecl())
4955 return Name;
4956 return SemaRef.Context.getSubstTemplateTemplateParm(
4957 NewName, AssociatedDecl, S->getIndex(), S->getPackIndex(),
4958 S->getFinal());
4959 }
4960
4961 assert(!Name.getAsDeducedTemplateName() &&
4962 "DeducedTemplateName should not escape partial ordering");
4963
4964 // FIXME: Preserve UsingTemplateName.
4965 if (auto *Template = Name.getAsTemplateDecl()) {
4966 assert(!QualifierLoc && "Unexpected qualifier");
4967 return TemplateName(cast_or_null<TemplateDecl>(
4968 getDerived().TransformDecl(NameLoc, Template)));
4969 }
4970
4973 assert(!QualifierLoc &&
4974 "Unexpected qualified SubstTemplateTemplateParmPack");
4975 return getDerived().RebuildTemplateName(
4976 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4977 SubstPack->getIndex(), SubstPack->getFinal());
4978 }
4979
4980 // These should be getting filtered out before they reach the AST.
4981 llvm_unreachable("overloaded function decl survived to here");
4982}
4983
4984template <typename Derived>
4986 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc,
4987 TemplateName Name, SourceLocation NameLoc) {
4988 TemplateName TN = getDerived().TransformTemplateName(
4989 QualifierLoc, TemplateKeywordLoc, Name, NameLoc);
4990 if (TN.isNull())
4991 return TemplateArgument();
4992 return TemplateArgument(TN);
4993}
4994
4995template<typename Derived>
4997 const TemplateArgument &Arg,
4998 TemplateArgumentLoc &Output) {
4999 Output = getSema().getTrivialTemplateArgumentLoc(
5000 Arg, QualType(), getDerived().getBaseLocation());
5001}
5002
5003template <typename Derived>
5005 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
5006 bool Uneval) {
5007 const TemplateArgument &Arg = Input.getArgument();
5008 switch (Arg.getKind()) {
5011 llvm_unreachable("Unexpected TemplateArgument");
5012
5017 // Transform a resolved template argument straight to a resolved template
5018 // argument. We get here when substituting into an already-substituted
5019 // template type argument during concept satisfaction checking.
5021 QualType NewT = getDerived().TransformType(T);
5022 if (NewT.isNull())
5023 return true;
5024
5026 ? Arg.getAsDecl()
5027 : nullptr;
5028 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
5030 : nullptr;
5031 if (D && !NewD)
5032 return true;
5033
5034 if (NewT == T && D == NewD)
5035 Output = Input;
5036 else if (Arg.getKind() == TemplateArgument::Integral)
5037 Output = TemplateArgumentLoc(
5038 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
5040 else if (Arg.getKind() == TemplateArgument::NullPtr)
5041 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
5043 else if (Arg.getKind() == TemplateArgument::Declaration)
5044 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
5047 Output = TemplateArgumentLoc(
5048 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
5050 else
5051 llvm_unreachable("unexpected template argument kind");
5052
5053 return false;
5054 }
5055
5057 TypeSourceInfo *TSI = Input.getTypeSourceInfo();
5058 if (!TSI)
5060
5061 TSI = getDerived().TransformType(TSI);
5062 if (!TSI)
5063 return true;
5064
5065 Output = TemplateArgumentLoc(TemplateArgument(TSI->getType()), TSI);
5066 return false;
5067 }
5068
5070 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
5071
5072 TemplateArgument Out = getDerived().TransformNamedTemplateTemplateArgument(
5073 QualifierLoc, Input.getTemplateKWLoc(), Arg.getAsTemplate(),
5074 Input.getTemplateNameLoc());
5075 if (Out.isNull())
5076 return true;
5077 Output = TemplateArgumentLoc(SemaRef.Context, Out, Input.getTemplateKWLoc(),
5078 QualifierLoc, Input.getTemplateNameLoc());
5079 return false;
5080 }
5081
5083 llvm_unreachable("Caller should expand pack expansions");
5084
5086 // Template argument expressions are constant expressions.
5088 getSema(),
5091 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
5093
5094 Expr *InputExpr = Input.getSourceExpression();
5095 if (!InputExpr)
5096 InputExpr = Input.getArgument().getAsExpr();
5097
5098 ExprResult E = getDerived().TransformExpr(InputExpr);
5099 E = SemaRef.ActOnConstantExpression(E);
5100 if (E.isInvalid())
5101 return true;
5102 Output = TemplateArgumentLoc(
5103 TemplateArgument(E.get(), /*IsCanonical=*/false), E.get());
5104 return false;
5105 }
5106 }
5107
5108 // Work around bogus GCC warning
5109 return true;
5110}
5111
5112/// Iterator adaptor that invents template argument location information
5113/// for each of the template arguments in its underlying iterator.
5114template<typename Derived, typename InputIterator>
5117 InputIterator Iter;
5118
5119public:
5122 typedef typename std::iterator_traits<InputIterator>::difference_type
5124 typedef std::input_iterator_tag iterator_category;
5125
5126 class pointer {
5128
5129 public:
5130 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5131
5132 const TemplateArgumentLoc *operator->() const { return &Arg; }
5133 };
5134
5136 InputIterator Iter)
5137 : Self(Self), Iter(Iter) { }
5138
5140 ++Iter;
5141 return *this;
5142 }
5143
5146 ++(*this);
5147 return Old;
5148 }
5149
5152 Self.InventTemplateArgumentLoc(*Iter, Result);
5153 return Result;
5154 }
5155
5156 pointer operator->() const { return pointer(**this); }
5157
5160 return X.Iter == Y.Iter;
5161 }
5162
5165 return X.Iter != Y.Iter;
5166 }
5167};
5168
5169template<typename Derived>
5170template<typename InputIterator>
5172 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5173 bool Uneval) {
5174 for (TemplateArgumentLoc In : llvm::make_range(First, Last)) {
5176 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5177 // Unpack argument packs, which we translate them into separate
5178 // arguments.
5179 // FIXME: We could do much better if we could guarantee that the
5180 // TemplateArgumentLocInfo for the pack expansion would be usable for
5181 // all of the template arguments in the argument pack.
5182 typedef TemplateArgumentLocInventIterator<Derived,
5184 PackLocIterator;
5185
5186 TemplateArgumentListInfo *PackOutput = &Outputs;
5188
5190 PackLocIterator(*this, In.getArgument().pack_begin()),
5191 PackLocIterator(*this, In.getArgument().pack_end()), *PackOutput,
5192 Uneval))
5193 return true;
5194
5195 continue;
5196 }
5197
5198 if (In.getArgument().isPackExpansion()) {
5199 UnexpandedInfo Info;
5200 TemplateArgumentLoc Prepared;
5201 if (getDerived().PreparePackForExpansion(In, Uneval, Prepared, Info))
5202 return true;
5203 if (!Info.Expand) {
5204 Outputs.addArgument(Prepared);
5205 continue;
5206 }
5207
5208 // The transform has determined that we should perform an elementwise
5209 // expansion of the pattern. Do so.
5210 std::optional<ForgetSubstitutionRAII> ForgetSubst;
5212 ForgetSubst.emplace(getDerived());
5213 for (unsigned I = 0; I != *Info.NumExpansions; ++I) {
5214 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
5215
5217 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5218 return true;
5219
5220 if (Out.getArgument().containsUnexpandedParameterPack()) {
5221 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5222 Info.OrigNumExpansions);
5223 if (Out.getArgument().isNull())
5224 return true;
5225 }
5226
5227 Outputs.addArgument(Out);
5228 }
5229
5230 // If we're supposed to retain a pack expansion, do so by temporarily
5231 // forgetting the partially-substituted parameter pack.
5232 if (Info.RetainExpansion) {
5233 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5234
5236 if (getDerived().TransformTemplateArgument(Prepared, Out, Uneval))
5237 return true;
5238
5239 Out = getDerived().RebuildPackExpansion(Out, Info.Ellipsis,
5240 Info.OrigNumExpansions);
5241 if (Out.getArgument().isNull())
5242 return true;
5243
5244 Outputs.addArgument(Out);
5245 }
5246
5247 continue;
5248 }
5249
5250 // The simple case:
5251 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5252 return true;
5253
5254 Outputs.addArgument(Out);
5255 }
5256
5257 return false;
5258}
5259
5260template <typename Derived>
5261template <typename InputIterator>
5263 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5264 bool Uneval) {
5265
5266 // [C++26][temp.constr.normal]
5267 // any non-dependent concept template argument
5268 // is substituted into the constraint-expression of C.
5269 auto isNonDependentConceptArgument = [](const TemplateArgument &Arg) {
5270 return !Arg.isDependent() && Arg.isConceptOrConceptTemplateParameter();
5271 };
5272
5273 for (; First != Last; ++First) {
5276
5277 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5278 typedef TemplateArgumentLocInventIterator<Derived,
5280 PackLocIterator;
5282 PackLocIterator(*this, In.getArgument().pack_begin()),
5283 PackLocIterator(*this, In.getArgument().pack_end()), Outputs,
5284 Uneval))
5285 return true;
5286 continue;
5287 }
5288
5289 if (!isNonDependentConceptArgument(In.getArgument())) {
5290 Outputs.addArgument(In);
5291 continue;
5292 }
5293
5294 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5295 return true;
5296
5297 Outputs.addArgument(Out);
5298 }
5299
5300 return false;
5301}
5302
5303// FIXME: Find ways to reduce code duplication for pack expansions.
5304template <typename Derived>
5306 bool Uneval,
5308 UnexpandedInfo &Info) {
5309 auto ComputeInfo = [this](TemplateArgumentLoc Arg,
5310 bool IsLateExpansionAttempt, UnexpandedInfo &Info,
5311 TemplateArgumentLoc &Pattern) {
5312 assert(Arg.getArgument().isPackExpansion());
5313 // We have a pack expansion, for which we will be substituting into the
5314 // pattern.
5315 Pattern = getSema().getTemplateArgumentPackExpansionPattern(
5316 Arg, Info.Ellipsis, Info.OrigNumExpansions);
5318 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5319 if (IsLateExpansionAttempt) {
5320 // Request expansion only when there is an opportunity to expand a pack
5321 // that required a substituion first.
5322 bool SawPackTypes =
5323 llvm::any_of(Unexpanded, [](UnexpandedParameterPack P) {
5324 return P.first.dyn_cast<const SubstBuiltinTemplatePackType *>();
5325 });
5326 if (!SawPackTypes) {
5327 Info.Expand = false;
5328 return false;
5329 }
5330 }
5331 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5332
5333 // Determine whether the set of unexpanded parameter packs can and
5334 // should be expanded.
5335 Info.Expand = true;
5336 Info.RetainExpansion = false;
5337 Info.NumExpansions = Info.OrigNumExpansions;
5338 return getDerived().TryExpandParameterPacks(
5339 Info.Ellipsis, Pattern.getSourceRange(), Unexpanded,
5340 /*FailOnPackProducingTemplates=*/false, Info.Expand,
5341 Info.RetainExpansion, Info.NumExpansions);
5342 };
5343
5344 TemplateArgumentLoc Pattern;
5345 if (ComputeInfo(In, false, Info, Pattern))
5346 return true;
5347
5348 if (Info.Expand) {
5349 Out = Pattern;
5350 return false;
5351 }
5352
5353 // The transform has determined that we should perform a simple
5354 // transformation on the pack expansion, producing another pack
5355 // expansion.
5356 TemplateArgumentLoc OutPattern;
5357 std::optional<Sema::ArgPackSubstIndexRAII> SubstIndex(
5358 std::in_place, getSema(), std::nullopt);
5359 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5360 return true;
5361
5362 Out = getDerived().RebuildPackExpansion(OutPattern, Info.Ellipsis,
5363 Info.NumExpansions);
5364 if (Out.getArgument().isNull())
5365 return true;
5366 SubstIndex.reset();
5367
5368 if (!OutPattern.getArgument().containsUnexpandedParameterPack())
5369 return false;
5370
5371 // Some packs will learn their length after substitution, e.g.
5372 // __builtin_dedup_pack<T,int> has size 1 or 2, depending on the substitution
5373 // value of `T`.
5374 //
5375 // We only expand after we know sizes of all packs, check if this is the case
5376 // or not. However, we avoid a full template substitution and only do
5377 // expanstions after this point.
5378
5379 // E.g. when substituting template arguments of tuple with {T -> int} in the
5380 // following example:
5381 // template <class T>
5382 // struct TupleWithInt {
5383 // using type = std::tuple<__builtin_dedup_pack<T, int>...>;
5384 // };
5385 // TupleWithInt<int>::type y;
5386 // At this point we will see the `__builtin_dedup_pack<int, int>` with a known
5387 // length and run `ComputeInfo()` to provide the necessary information to our
5388 // caller.
5389 //
5390 // Note that we may still have situations where builtin is not going to be
5391 // expanded. For example:
5392 // template <class T>
5393 // struct Foo {
5394 // template <class U> using tuple_with_t =
5395 // std::tuple<__builtin_dedup_pack<T, U, int>...>; using type =
5396 // tuple_with_t<short>;
5397 // }
5398 // Because the substitution into `type` happens in dependent context, `type`
5399 // will be `tuple<builtin_dedup_pack<T, short, int>...>` after substitution
5400 // and the caller will not be able to expand it.
5401 ForgetSubstitutionRAII ForgetSubst(getDerived());
5402 if (ComputeInfo(Out, true, Info, OutPattern))
5403 return true;
5404 if (!Info.Expand)
5405 return false;
5406 Out = OutPattern;
5407 Info.ExpandUnderForgetSubstitions = true;
5408 return false;
5409}
5410
5411//===----------------------------------------------------------------------===//
5412// Type transformation
5413//===----------------------------------------------------------------------===//
5414
5415template<typename Derived>
5418 return T;
5419
5420 // Temporary workaround. All of these transformations should
5421 // eventually turn into transformations on TypeLocs.
5422 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5424
5425 TypeSourceInfo *NewTSI = getDerived().TransformType(TSI);
5426
5427 if (!NewTSI)
5428 return QualType();
5429
5430 return NewTSI->getType();
5431}
5432
5433template <typename Derived>
5435 // Refine the base location to the type's location.
5436 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5439 return TSI;
5440
5441 TypeLocBuilder TLB;
5442
5443 TypeLoc TL = TSI->getTypeLoc();
5444 TLB.reserve(TL.getFullDataSize());
5445
5446 QualType Result = getDerived().TransformType(TLB, TL);
5447 if (Result.isNull())
5448 return nullptr;
5449
5450 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5451}
5452
5453template<typename Derived>
5456 switch (T.getTypeLocClass()) {
5457#define ABSTRACT_TYPELOC(CLASS, PARENT)
5458#define TYPELOC(CLASS, PARENT) \
5459 case TypeLoc::CLASS: \
5460 return getDerived().Transform##CLASS##Type(TLB, \
5461 T.castAs<CLASS##TypeLoc>());
5462#include "clang/AST/TypeLocNodes.def"
5463 }
5464
5465 llvm_unreachable("unhandled type loc!");
5466}
5467
5468template<typename Derived>
5470 if (!isa<DependentNameType>(T))
5471 return TransformType(T);
5472
5474 return T;
5475 TypeSourceInfo *TSI = getSema().Context.getTrivialTypeSourceInfo(
5477 TypeSourceInfo *NewTSI = getDerived().TransformTypeWithDeducedTST(TSI);
5478 return NewTSI ? NewTSI->getType() : QualType();
5479}
5480
5481template <typename Derived>
5484 if (!isa<DependentNameType>(TSI->getType()))
5485 return TransformType(TSI);
5486
5487 // Refine the base location to the type's location.
5488 TemporaryBase Rebase(*this, TSI->getTypeLoc().getBeginLoc(),
5491 return TSI;
5492
5493 TypeLocBuilder TLB;
5494
5495 TypeLoc TL = TSI->getTypeLoc();
5496 TLB.reserve(TL.getFullDataSize());
5497
5498 auto QTL = TL.getAs<QualifiedTypeLoc>();
5499 if (QTL)
5500 TL = QTL.getUnqualifiedLoc();
5501
5502 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5503
5504 QualType Result = getDerived().TransformDependentNameType(
5505 TLB, DNTL, /*DeducedTSTContext*/true);
5506 if (Result.isNull())
5507 return nullptr;
5508
5509 if (QTL) {
5510 Result = getDerived().RebuildQualifiedType(Result, QTL);
5511 if (Result.isNull())
5512 return nullptr;
5514 }
5515
5516 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5517}
5518
5519template<typename Derived>
5522 QualifiedTypeLoc T) {
5524 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5525 auto SuppressObjCLifetime =
5527 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5528 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5529 SuppressObjCLifetime);
5530 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5531 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5532 TLB, STTP, SuppressObjCLifetime);
5533 } else {
5534 Result = getDerived().TransformType(TLB, UnqualTL);
5535 }
5536
5537 if (Result.isNull())
5538 return QualType();
5539
5540 Result = getDerived().RebuildQualifiedType(Result, T);
5541
5542 if (Result.isNull())
5543 return QualType();
5544
5545 // RebuildQualifiedType might have updated the type, but not in a way
5546 // that invalidates the TypeLoc. (There's no location information for
5547 // qualifiers.)
5549
5550 return Result;
5551}
5552
5553template <typename Derived>
5555 QualifiedTypeLoc TL) {
5556
5557 SourceLocation Loc = TL.getBeginLoc();
5558 Qualifiers Quals = TL.getType().getLocalQualifiers();
5559
5560 if ((T.getAddressSpace() != LangAS::Default &&
5561 Quals.getAddressSpace() != LangAS::Default) &&
5562 T.getAddressSpace() != Quals.getAddressSpace()) {
5563 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5564 << TL.getType() << T;
5565 return QualType();
5566 }
5567
5568 PointerAuthQualifier LocalPointerAuth = Quals.getPointerAuth();
5569 if (LocalPointerAuth.isPresent()) {
5570 if (T.getPointerAuth().isPresent()) {
5571 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_redundant) << TL.getType();
5572 return QualType();
5573 }
5574 if (!T->isDependentType()) {
5575 if (!T->isSignableType(SemaRef.getASTContext())) {
5576 SemaRef.Diag(Loc, diag::err_ptrauth_qualifier_invalid_target) << T;
5577 return QualType();
5578 }
5579 }
5580 }
5581 // C++ [dcl.fct]p7:
5582 // [When] adding cv-qualifications on top of the function type [...] the
5583 // cv-qualifiers are ignored.
5584 if (T->isFunctionType()) {
5585 T = SemaRef.getASTContext().getAddrSpaceQualType(T,
5586 Quals.getAddressSpace());
5587 return T;
5588 }
5589
5590 // C++ [dcl.ref]p1:
5591 // when the cv-qualifiers are introduced through the use of a typedef-name
5592 // or decltype-specifier [...] the cv-qualifiers are ignored.
5593 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5594 // applied to a reference type.
5595 if (T->isReferenceType()) {
5596 // The only qualifier that applies to a reference type is restrict.
5597 if (!Quals.hasRestrict())
5598 return T;
5600 }
5601
5602 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5603 // resulting type.
5604 if (Quals.hasObjCLifetime()) {
5605 if (!T->isObjCLifetimeType() && !T->isDependentType())
5606 Quals.removeObjCLifetime();
5607 else if (T.getObjCLifetime()) {
5608 // Objective-C ARC:
5609 // A lifetime qualifier applied to a substituted template parameter
5610 // overrides the lifetime qualifier from the template argument.
5611 const AutoType *AutoTy;
5612 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5613 // 'auto' types behave the same way as template parameters.
5614 QualType Deduced = AutoTy->getDeducedType();
5615 Qualifiers Qs = Deduced.getQualifiers();
5616 Qs.removeObjCLifetime();
5617 Deduced =
5618 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5619 T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
5620 AutoTy->isDependentType(),
5621 /*isPack=*/false,
5622 AutoTy->getTypeConstraintConcept(),
5623 AutoTy->getTypeConstraintArguments());
5624 } else {
5625 // Otherwise, complain about the addition of a qualifier to an
5626 // already-qualified type.
5627 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5628 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5629 Quals.removeObjCLifetime();
5630 }
5631 }
5632 }
5633
5634 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5635}
5636
5637template <typename Derived>
5638QualType TreeTransform<Derived>::TransformTypeInObjectScope(
5639 TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType,
5640 NamedDecl *FirstQualifierInScope) {
5641 assert(!getDerived().AlreadyTransformed(TL.getType()));
5642
5643 switch (TL.getTypeLocClass()) {
5644 case TypeLoc::TemplateSpecialization:
5645 return getDerived().TransformTemplateSpecializationType(
5646 TLB, TL.castAs<TemplateSpecializationTypeLoc>(), ObjectType,
5647 FirstQualifierInScope, /*AllowInjectedClassName=*/true);
5648 case TypeLoc::DependentName:
5649 return getDerived().TransformDependentNameType(
5650 TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
5651 ObjectType, FirstQualifierInScope);
5652 default:
5653 // Any dependent canonical type can appear here, through type alias
5654 // templates.
5655 return getDerived().TransformType(TLB, TL);
5656 }
5657}
5658
5659template <class TyLoc> static inline
5661 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5662 NewT.setNameLoc(T.getNameLoc());
5663 return T.getType();
5664}
5665
5666template<typename Derived>
5667QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5668 BuiltinTypeLoc T) {
5669 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5670 NewT.setBuiltinLoc(T.getBuiltinLoc());
5671 if (T.needsExtraLocalData())
5672 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5673 return T.getType();
5674}
5675
5676template<typename Derived>
5678 ComplexTypeLoc T) {
5679 // FIXME: recurse?
5680 return TransformTypeSpecType(TLB, T);
5681}
5682
5683template <typename Derived>
5685 AdjustedTypeLoc TL) {
5686 // Adjustments applied during transformation are handled elsewhere.
5687 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5688}
5689
5690template<typename Derived>
5692 DecayedTypeLoc TL) {
5693 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5694 if (OriginalType.isNull())
5695 return QualType();
5696
5697 QualType Result = TL.getType();
5698 if (getDerived().AlwaysRebuild() ||
5699 OriginalType != TL.getOriginalLoc().getType())
5700 Result = SemaRef.Context.getDecayedType(OriginalType);
5701 TLB.push<DecayedTypeLoc>(Result);
5702 // Nothing to set for DecayedTypeLoc.
5703 return Result;
5704}
5705
5706template <typename Derived>
5710 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5711 if (OriginalType.isNull())
5712 return QualType();
5713
5714 QualType Result = TL.getType();
5715 if (getDerived().AlwaysRebuild() ||
5716 OriginalType != TL.getElementLoc().getType())
5717 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5718 TLB.push<ArrayParameterTypeLoc>(Result);
5719 // Nothing to set for ArrayParameterTypeLoc.
5720 return Result;
5721}
5722
5723template<typename Derived>
5725 PointerTypeLoc TL) {
5726 QualType PointeeType
5727 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5728 if (PointeeType.isNull())
5729 return QualType();
5730
5731 QualType Result = TL.getType();
5732 if (PointeeType->getAs<ObjCObjectType>()) {
5733 // A dependent pointer type 'T *' has is being transformed such
5734 // that an Objective-C class type is being replaced for 'T'. The
5735 // resulting pointer type is an ObjCObjectPointerType, not a
5736 // PointerType.
5737 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5738
5740 NewT.setStarLoc(TL.getStarLoc());
5741 return Result;
5742 }
5743
5744 if (getDerived().AlwaysRebuild() ||
5745 PointeeType != TL.getPointeeLoc().getType()) {
5746 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5747 if (Result.isNull())
5748 return QualType();
5749 }
5750
5751 // Objective-C ARC can add lifetime qualifiers to the type that we're
5752 // pointing to.
5753 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5754
5755 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5756 NewT.setSigilLoc(TL.getSigilLoc());
5757 return Result;
5758}
5759
5760template<typename Derived>
5764 QualType PointeeType
5765 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5766 if (PointeeType.isNull())
5767 return QualType();
5768
5769 QualType Result = TL.getType();
5770 if (getDerived().AlwaysRebuild() ||
5771 PointeeType != TL.getPointeeLoc().getType()) {
5772 Result = getDerived().RebuildBlockPointerType(PointeeType,
5773 TL.getSigilLoc());
5774 if (Result.isNull())
5775 return QualType();
5776 }
5777
5779 NewT.setSigilLoc(TL.getSigilLoc());
5780 return Result;
5781}
5782
5783/// Transforms a reference type. Note that somewhat paradoxically we
5784/// don't care whether the type itself is an l-value type or an r-value
5785/// type; we only care if the type was *written* as an l-value type
5786/// or an r-value type.
5787template<typename Derived>
5790 ReferenceTypeLoc TL) {
5791 const ReferenceType *T = TL.getTypePtr();
5792
5793 // Note that this works with the pointee-as-written.
5794 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5795 if (PointeeType.isNull())
5796 return QualType();
5797
5798 QualType Result = TL.getType();
5799 if (getDerived().AlwaysRebuild() ||
5800 PointeeType != T->getPointeeTypeAsWritten()) {
5801 Result = getDerived().RebuildReferenceType(PointeeType,
5802 T->isSpelledAsLValue(),
5803 TL.getSigilLoc());
5804 if (Result.isNull())
5805 return QualType();
5806 }
5807
5808 // Objective-C ARC can add lifetime qualifiers to the type that we're
5809 // referring to.
5812
5813 // r-value references can be rebuilt as l-value references.
5814 ReferenceTypeLoc NewTL;
5816 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5817 else
5818 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5819 NewTL.setSigilLoc(TL.getSigilLoc());
5820
5821 return Result;
5822}
5823
5824template<typename Derived>
5828 return TransformReferenceType(TLB, TL);
5829}
5830
5831template<typename Derived>
5832QualType
5833TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5834 RValueReferenceTypeLoc TL) {
5835 return TransformReferenceType(TLB, TL);
5836}
5837
5838template<typename Derived>
5842 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5843 if (PointeeType.isNull())
5844 return QualType();
5845
5846 const MemberPointerType *T = TL.getTypePtr();
5847
5848 NestedNameSpecifierLoc OldQualifierLoc = TL.getQualifierLoc();
5849 NestedNameSpecifierLoc NewQualifierLoc =
5850 getDerived().TransformNestedNameSpecifierLoc(OldQualifierLoc);
5851 if (!NewQualifierLoc)
5852 return QualType();
5853
5854 CXXRecordDecl *OldCls = T->getMostRecentCXXRecordDecl(), *NewCls = nullptr;
5855 if (OldCls) {
5856 NewCls = cast_or_null<CXXRecordDecl>(
5857 getDerived().TransformDecl(TL.getStarLoc(), OldCls));
5858 if (!NewCls)
5859 return QualType();
5860 }
5861
5862 QualType Result = TL.getType();
5863 if (getDerived().AlwaysRebuild() || PointeeType != T->getPointeeType() ||
5864 NewQualifierLoc.getNestedNameSpecifier() !=
5865 OldQualifierLoc.getNestedNameSpecifier() ||
5866 NewCls != OldCls) {
5867 CXXScopeSpec SS;
5868 SS.Adopt(NewQualifierLoc);
5869 Result = getDerived().RebuildMemberPointerType(PointeeType, SS, NewCls,
5870 TL.getStarLoc());
5871 if (Result.isNull())
5872 return QualType();
5873 }
5874
5875 // If we had to adjust the pointee type when building a member pointer, make
5876 // sure to push TypeLoc info for it.
5877 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5878 if (MPT && PointeeType != MPT->getPointeeType()) {
5879 assert(isa<AdjustedType>(MPT->getPointeeType()));
5880 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5881 }
5882
5884 NewTL.setSigilLoc(TL.getSigilLoc());
5885 NewTL.setQualifierLoc(NewQualifierLoc);
5886
5887 return Result;
5888}
5889
5890template<typename Derived>
5894 const ConstantArrayType *T = TL.getTypePtr();
5895 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5896 if (ElementType.isNull())
5897 return QualType();
5898
5899 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5900 Expr *OldSize = TL.getSizeExpr();
5901 if (!OldSize)
5902 OldSize = const_cast<Expr*>(T->getSizeExpr());
5903 Expr *NewSize = nullptr;
5904 if (OldSize) {
5907 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5908 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5909 }
5910
5911 QualType Result = TL.getType();
5912 if (getDerived().AlwaysRebuild() ||
5913 ElementType != T->getElementType() ||
5914 (T->getSizeExpr() && NewSize != OldSize)) {
5915 Result = getDerived().RebuildConstantArrayType(ElementType,
5916 T->getSizeModifier(),
5917 T->getSize(), NewSize,
5918 T->getIndexTypeCVRQualifiers(),
5919 TL.getBracketsRange());
5920 if (Result.isNull())
5921 return QualType();
5922 }
5923
5924 // We might have either a ConstantArrayType or a VariableArrayType now:
5925 // a ConstantArrayType is allowed to have an element type which is a
5926 // VariableArrayType if the type is dependent. Fortunately, all array
5927 // types have the same location layout.
5928 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5929 NewTL.setLBracketLoc(TL.getLBracketLoc());
5930 NewTL.setRBracketLoc(TL.getRBracketLoc());
5931 NewTL.setSizeExpr(NewSize);
5932
5933 return Result;
5934}
5935
5936template<typename Derived>
5938 TypeLocBuilder &TLB,
5940 const IncompleteArrayType *T = TL.getTypePtr();
5941 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5942 if (ElementType.isNull())
5943 return QualType();
5944
5945 QualType Result = TL.getType();
5946 if (getDerived().AlwaysRebuild() ||
5947 ElementType != T->getElementType()) {
5948 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5949 T->getSizeModifier(),
5950 T->getIndexTypeCVRQualifiers(),
5951 TL.getBracketsRange());
5952 if (Result.isNull())
5953 return QualType();
5954 }
5955
5957 NewTL.setLBracketLoc(TL.getLBracketLoc());
5958 NewTL.setRBracketLoc(TL.getRBracketLoc());
5959 NewTL.setSizeExpr(nullptr);
5960
5961 return Result;
5962}
5963
5964template<typename Derived>
5968 const VariableArrayType *T = TL.getTypePtr();
5969 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5970 if (ElementType.isNull())
5971 return QualType();
5972
5973 ExprResult SizeResult;
5974 {
5977 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5978 }
5979 if (SizeResult.isInvalid())
5980 return QualType();
5981 SizeResult =
5982 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5983 if (SizeResult.isInvalid())
5984 return QualType();
5985
5986 Expr *Size = SizeResult.get();
5987
5988 QualType Result = TL.getType();
5989 if (getDerived().AlwaysRebuild() ||
5990 ElementType != T->getElementType() ||
5991 Size != T->getSizeExpr()) {
5992 Result = getDerived().RebuildVariableArrayType(ElementType,
5993 T->getSizeModifier(),
5994 Size,
5995 T->getIndexTypeCVRQualifiers(),
5996 TL.getBracketsRange());
5997 if (Result.isNull())
5998 return QualType();
5999 }
6000
6001 // We might have constant size array now, but fortunately it has the same
6002 // location layout.
6003 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6004 NewTL.setLBracketLoc(TL.getLBracketLoc());
6005 NewTL.setRBracketLoc(TL.getRBracketLoc());
6006 NewTL.setSizeExpr(Size);
6007
6008 return Result;
6009}
6010
6011template<typename Derived>
6015 const DependentSizedArrayType *T = TL.getTypePtr();
6016 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6017 if (ElementType.isNull())
6018 return QualType();
6019
6020 // Array bounds are constant expressions.
6023
6024 // If we have a VLA then it won't be a constant.
6025 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
6026
6027 // Prefer the expression from the TypeLoc; the other may have been uniqued.
6028 Expr *origSize = TL.getSizeExpr();
6029 if (!origSize) origSize = T->getSizeExpr();
6030
6031 ExprResult sizeResult
6032 = getDerived().TransformExpr(origSize);
6033 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
6034 if (sizeResult.isInvalid())
6035 return QualType();
6036
6037 Expr *size = sizeResult.get();
6038
6039 QualType Result = TL.getType();
6040 if (getDerived().AlwaysRebuild() ||
6041 ElementType != T->getElementType() ||
6042 size != origSize) {
6043 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
6044 T->getSizeModifier(),
6045 size,
6046 T->getIndexTypeCVRQualifiers(),
6047 TL.getBracketsRange());
6048 if (Result.isNull())
6049 return QualType();
6050 }
6051
6052 // We might have any sort of array type now, but fortunately they
6053 // all have the same location layout.
6054 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
6055 NewTL.setLBracketLoc(TL.getLBracketLoc());
6056 NewTL.setRBracketLoc(TL.getRBracketLoc());
6057 NewTL.setSizeExpr(size);
6058
6059 return Result;
6060}
6061
6062template <typename Derived>
6065 const DependentVectorType *T = TL.getTypePtr();
6066 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6067 if (ElementType.isNull())
6068 return QualType();
6069
6072
6073 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6074 Size = SemaRef.ActOnConstantExpression(Size);
6075 if (Size.isInvalid())
6076 return QualType();
6077
6078 QualType Result = TL.getType();
6079 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6080 Size.get() != T->getSizeExpr()) {
6081 Result = getDerived().RebuildDependentVectorType(
6082 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
6083 if (Result.isNull())
6084 return QualType();
6085 }
6086
6087 // Result might be dependent or not.
6090 TLB.push<DependentVectorTypeLoc>(Result);
6091 NewTL.setNameLoc(TL.getNameLoc());
6092 } else {
6093 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6094 NewTL.setNameLoc(TL.getNameLoc());
6095 }
6096
6097 return Result;
6098}
6099
6100template<typename Derived>
6102 TypeLocBuilder &TLB,
6104 const DependentSizedExtVectorType *T = TL.getTypePtr();
6105
6106 // FIXME: ext vector locs should be nested
6107 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6108 if (ElementType.isNull())
6109 return QualType();
6110
6111 // Vector sizes are constant expressions.
6114
6115 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
6116 Size = SemaRef.ActOnConstantExpression(Size);
6117 if (Size.isInvalid())
6118 return QualType();
6119
6120 QualType Result = TL.getType();
6121 if (getDerived().AlwaysRebuild() ||
6122 ElementType != T->getElementType() ||
6123 Size.get() != T->getSizeExpr()) {
6124 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
6125 Size.get(),
6126 T->getAttributeLoc());
6127 if (Result.isNull())
6128 return QualType();
6129 }
6130
6131 // Result might be dependent or not.
6135 NewTL.setNameLoc(TL.getNameLoc());
6136 } else {
6137 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6138 NewTL.setNameLoc(TL.getNameLoc());
6139 }
6140
6141 return Result;
6142}
6143
6144template <typename Derived>
6148 const ConstantMatrixType *T = TL.getTypePtr();
6149 QualType ElementType = getDerived().TransformType(T->getElementType());
6150 if (ElementType.isNull())
6151 return QualType();
6152
6153 QualType Result = TL.getType();
6154 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
6155 Result = getDerived().RebuildConstantMatrixType(
6156 ElementType, T->getNumRows(), T->getNumColumns());
6157 if (Result.isNull())
6158 return QualType();
6159 }
6160
6162 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6163 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6164 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
6165 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
6166
6167 return Result;
6168}
6169
6170template <typename Derived>
6173 const DependentSizedMatrixType *T = TL.getTypePtr();
6174
6175 QualType ElementType = getDerived().TransformType(T->getElementType());
6176 if (ElementType.isNull()) {
6177 return QualType();
6178 }
6179
6180 // Matrix dimensions are constant expressions.
6183
6184 Expr *origRows = TL.getAttrRowOperand();
6185 if (!origRows)
6186 origRows = T->getRowExpr();
6187 Expr *origColumns = TL.getAttrColumnOperand();
6188 if (!origColumns)
6189 origColumns = T->getColumnExpr();
6190
6191 ExprResult rowResult = getDerived().TransformExpr(origRows);
6192 rowResult = SemaRef.ActOnConstantExpression(rowResult);
6193 if (rowResult.isInvalid())
6194 return QualType();
6195
6196 ExprResult columnResult = getDerived().TransformExpr(origColumns);
6197 columnResult = SemaRef.ActOnConstantExpression(columnResult);
6198 if (columnResult.isInvalid())
6199 return QualType();
6200
6201 Expr *rows = rowResult.get();
6202 Expr *columns = columnResult.get();
6203
6204 QualType Result = TL.getType();
6205 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
6206 rows != origRows || columns != origColumns) {
6207 Result = getDerived().RebuildDependentSizedMatrixType(
6208 ElementType, rows, columns, T->getAttributeLoc());
6209
6210 if (Result.isNull())
6211 return QualType();
6212 }
6213
6214 // We might have any sort of matrix type now, but fortunately they
6215 // all have the same location layout.
6216 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
6217 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6218 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6219 NewTL.setAttrRowOperand(rows);
6220 NewTL.setAttrColumnOperand(columns);
6221 return Result;
6222}
6223
6224template <typename Derived>
6227 const DependentAddressSpaceType *T = TL.getTypePtr();
6228
6229 QualType pointeeType =
6230 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
6231
6232 if (pointeeType.isNull())
6233 return QualType();
6234
6235 // Address spaces are constant expressions.
6238
6239 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
6240 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
6241 if (AddrSpace.isInvalid())
6242 return QualType();
6243
6244 QualType Result = TL.getType();
6245 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
6246 AddrSpace.get() != T->getAddrSpaceExpr()) {
6247 Result = getDerived().RebuildDependentAddressSpaceType(
6248 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6249 if (Result.isNull())
6250 return QualType();
6251 }
6252
6253 // Result might be dependent or not.
6257
6258 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6259 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6260 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6261
6262 } else {
6263 TLB.TypeWasModifiedSafely(Result);
6264 }
6265
6266 return Result;
6267}
6268
6269template <typename Derived>
6271 VectorTypeLoc TL) {
6272 const VectorType *T = TL.getTypePtr();
6273 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6274 if (ElementType.isNull())
6275 return QualType();
6276
6277 QualType Result = TL.getType();
6278 if (getDerived().AlwaysRebuild() ||
6279 ElementType != T->getElementType()) {
6280 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6281 T->getVectorKind());
6282 if (Result.isNull())
6283 return QualType();
6284 }
6285
6286 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6287 NewTL.setNameLoc(TL.getNameLoc());
6288
6289 return Result;
6290}
6291
6292template<typename Derived>
6294 ExtVectorTypeLoc TL) {
6295 const VectorType *T = TL.getTypePtr();
6296 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6297 if (ElementType.isNull())
6298 return QualType();
6299
6300 QualType Result = TL.getType();
6301 if (getDerived().AlwaysRebuild() ||
6302 ElementType != T->getElementType()) {
6303 Result = getDerived().RebuildExtVectorType(ElementType,
6304 T->getNumElements(),
6305 /*FIXME*/ SourceLocation());
6306 if (Result.isNull())
6307 return QualType();
6308 }
6309
6310 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6311 NewTL.setNameLoc(TL.getNameLoc());
6312
6313 return Result;
6314}
6315
6316template <typename Derived>
6318 ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions,
6319 bool ExpectParameterPack) {
6320 TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
6321 TypeSourceInfo *NewTSI = nullptr;
6322
6323 if (NumExpansions && isa<PackExpansionType>(OldTSI->getType())) {
6324 // If we're substituting into a pack expansion type and we know the
6325 // length we want to expand to, just substitute for the pattern.
6326 TypeLoc OldTL = OldTSI->getTypeLoc();
6327 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6328
6329 TypeLocBuilder TLB;
6330 TypeLoc NewTL = OldTSI->getTypeLoc();
6331 TLB.reserve(NewTL.getFullDataSize());
6332
6333 QualType Result = getDerived().TransformType(TLB,
6334 OldExpansionTL.getPatternLoc());
6335 if (Result.isNull())
6336 return nullptr;
6337
6339 OldExpansionTL.getPatternLoc().getSourceRange(),
6340 OldExpansionTL.getEllipsisLoc(),
6341 NumExpansions);
6342 if (Result.isNull())
6343 return nullptr;
6344
6345 PackExpansionTypeLoc NewExpansionTL
6346 = TLB.push<PackExpansionTypeLoc>(Result);
6347 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6348 NewTSI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6349 } else
6350 NewTSI = getDerived().TransformType(OldTSI);
6351 if (!NewTSI)
6352 return nullptr;
6353
6354 if (NewTSI == OldTSI && indexAdjustment == 0)
6355 return OldParm;
6356
6358 SemaRef.Context, OldParm->getDeclContext(), OldParm->getInnerLocStart(),
6359 OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
6360 NewTSI, OldParm->getStorageClass(),
6361 /* DefArg */ nullptr);
6362 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6363 OldParm->getFunctionScopeIndex() + indexAdjustment);
6364 getDerived().transformedLocalDecl(OldParm, {newParm});
6365 return newParm;
6366}
6367
6368template <typename Derived>
6371 const QualType *ParamTypes,
6372 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6373 SmallVectorImpl<QualType> &OutParamTypes,
6376 unsigned *LastParamTransformed) {
6377 int indexAdjustment = 0;
6378
6379 unsigned NumParams = Params.size();
6380 for (unsigned i = 0; i != NumParams; ++i) {
6381 if (LastParamTransformed)
6382 *LastParamTransformed = i;
6383 if (ParmVarDecl *OldParm = Params[i]) {
6384 assert(OldParm->getFunctionScopeIndex() == i);
6385
6386 UnsignedOrNone NumExpansions = std::nullopt;
6387 ParmVarDecl *NewParm = nullptr;
6388 if (OldParm->isParameterPack()) {
6389 // We have a function parameter pack that may need to be expanded.
6391
6392 // Find the parameter packs that could be expanded.
6393 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6395 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6396 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6397
6398 // Determine whether we should expand the parameter packs.
6399 bool ShouldExpand = false;
6400 bool RetainExpansion = false;
6401 UnsignedOrNone OrigNumExpansions = std::nullopt;
6402 if (Unexpanded.size() > 0) {
6403 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6404 NumExpansions = OrigNumExpansions;
6406 ExpansionTL.getEllipsisLoc(), Pattern.getSourceRange(),
6407 Unexpanded, /*FailOnPackProducingTemplates=*/true,
6408 ShouldExpand, RetainExpansion, NumExpansions)) {
6409 return true;
6410 }
6411 } else {
6412#ifndef NDEBUG
6413 const AutoType *AT =
6414 Pattern.getType().getTypePtr()->getContainedAutoType();
6415 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6416 "Could not find parameter packs or undeduced auto type!");
6417#endif
6418 }
6419
6420 if (ShouldExpand) {
6421 // Expand the function parameter pack into multiple, separate
6422 // parameters.
6423 getDerived().ExpandingFunctionParameterPack(OldParm);
6424 for (unsigned I = 0; I != *NumExpansions; ++I) {
6425 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6426 ParmVarDecl *NewParm
6427 = getDerived().TransformFunctionTypeParam(OldParm,
6428 indexAdjustment++,
6429 OrigNumExpansions,
6430 /*ExpectParameterPack=*/false);
6431 if (!NewParm)
6432 return true;
6433
6434 if (ParamInfos)
6435 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6436 OutParamTypes.push_back(NewParm->getType());
6437 if (PVars)
6438 PVars->push_back(NewParm);
6439 }
6440
6441 // If we're supposed to retain a pack expansion, do so by temporarily
6442 // forgetting the partially-substituted parameter pack.
6443 if (RetainExpansion) {
6444 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6445 ParmVarDecl *NewParm
6446 = getDerived().TransformFunctionTypeParam(OldParm,
6447 indexAdjustment++,
6448 OrigNumExpansions,
6449 /*ExpectParameterPack=*/false);
6450 if (!NewParm)
6451 return true;
6452
6453 if (ParamInfos)
6454 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6455 OutParamTypes.push_back(NewParm->getType());
6456 if (PVars)
6457 PVars->push_back(NewParm);
6458 }
6459
6460 // The next parameter should have the same adjustment as the
6461 // last thing we pushed, but we post-incremented indexAdjustment
6462 // on every push. Also, if we push nothing, the adjustment should
6463 // go down by one.
6464 indexAdjustment--;
6465
6466 // We're done with the pack expansion.
6467 continue;
6468 }
6469
6470 // We'll substitute the parameter now without expanding the pack
6471 // expansion.
6472 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6473 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6474 indexAdjustment,
6475 NumExpansions,
6476 /*ExpectParameterPack=*/true);
6477 assert(NewParm->isParameterPack() &&
6478 "Parameter pack no longer a parameter pack after "
6479 "transformation.");
6480 } else {
6481 NewParm = getDerived().TransformFunctionTypeParam(
6482 OldParm, indexAdjustment, std::nullopt,
6483 /*ExpectParameterPack=*/false);
6484 }
6485
6486 if (!NewParm)
6487 return true;
6488
6489 if (ParamInfos)
6490 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6491 OutParamTypes.push_back(NewParm->getType());
6492 if (PVars)
6493 PVars->push_back(NewParm);
6494 continue;
6495 }
6496
6497 // Deal with the possibility that we don't have a parameter
6498 // declaration for this parameter.
6499 assert(ParamTypes);
6500 QualType OldType = ParamTypes[i];
6501 bool IsPackExpansion = false;
6502 UnsignedOrNone NumExpansions = std::nullopt;
6503 QualType NewType;
6504 if (const PackExpansionType *Expansion
6505 = dyn_cast<PackExpansionType>(OldType)) {
6506 // We have a function parameter pack that may need to be expanded.
6507 QualType Pattern = Expansion->getPattern();
6509 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6510
6511 // Determine whether we should expand the parameter packs.
6512 bool ShouldExpand = false;
6513 bool RetainExpansion = false;
6515 Loc, SourceRange(), Unexpanded,
6516 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
6517 RetainExpansion, NumExpansions)) {
6518 return true;
6519 }
6520
6521 if (ShouldExpand) {
6522 // Expand the function parameter pack into multiple, separate
6523 // parameters.
6524 for (unsigned I = 0; I != *NumExpansions; ++I) {
6525 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
6526 QualType NewType = getDerived().TransformType(Pattern);
6527 if (NewType.isNull())
6528 return true;
6529
6530 if (NewType->containsUnexpandedParameterPack()) {
6531 NewType = getSema().getASTContext().getPackExpansionType(
6532 NewType, std::nullopt);
6533
6534 if (NewType.isNull())
6535 return true;
6536 }
6537
6538 if (ParamInfos)
6539 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6540 OutParamTypes.push_back(NewType);
6541 if (PVars)
6542 PVars->push_back(nullptr);
6543 }
6544
6545 // We're done with the pack expansion.
6546 continue;
6547 }
6548
6549 // If we're supposed to retain a pack expansion, do so by temporarily
6550 // forgetting the partially-substituted parameter pack.
6551 if (RetainExpansion) {
6552 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6553 QualType NewType = getDerived().TransformType(Pattern);
6554 if (NewType.isNull())
6555 return true;
6556
6557 if (ParamInfos)
6558 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6559 OutParamTypes.push_back(NewType);
6560 if (PVars)
6561 PVars->push_back(nullptr);
6562 }
6563
6564 // We'll substitute the parameter now without expanding the pack
6565 // expansion.
6566 OldType = Expansion->getPattern();
6567 IsPackExpansion = true;
6568 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6569 NewType = getDerived().TransformType(OldType);
6570 } else {
6571 NewType = getDerived().TransformType(OldType);
6572 }
6573
6574 if (NewType.isNull())
6575 return true;
6576
6577 if (IsPackExpansion)
6578 NewType = getSema().Context.getPackExpansionType(NewType,
6579 NumExpansions);
6580
6581 if (ParamInfos)
6582 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6583 OutParamTypes.push_back(NewType);
6584 if (PVars)
6585 PVars->push_back(nullptr);
6586 }
6587
6588#ifndef NDEBUG
6589 if (PVars) {
6590 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6591 if (ParmVarDecl *parm = (*PVars)[i])
6592 assert(parm->getFunctionScopeIndex() == i);
6593 }
6594#endif
6595
6596 return false;
6597}
6598
6599template<typename Derived>
6603 SmallVector<QualType, 4> ExceptionStorage;
6604 return getDerived().TransformFunctionProtoType(
6605 TLB, TL, nullptr, Qualifiers(),
6606 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6607 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6608 ExceptionStorage, Changed);
6609 });
6610}
6611
6612template<typename Derived> template<typename Fn>
6614 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6615 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6616
6617 // Transform the parameters and return type.
6618 //
6619 // We are required to instantiate the params and return type in source order.
6620 // When the function has a trailing return type, we instantiate the
6621 // parameters before the return type, since the return type can then refer
6622 // to the parameters themselves (via decltype, sizeof, etc.).
6623 //
6624 SmallVector<QualType, 4> ParamTypes;
6626 Sema::ExtParameterInfoBuilder ExtParamInfos;
6627 const FunctionProtoType *T = TL.getTypePtr();
6628
6629 QualType ResultType;
6630
6631 if (T->hasTrailingReturn()) {
6633 TL.getBeginLoc(), TL.getParams(),
6635 T->getExtParameterInfosOrNull(),
6636 ParamTypes, &ParamDecls, ExtParamInfos))
6637 return QualType();
6638
6639 {
6640 // C++11 [expr.prim.general]p3:
6641 // If a declaration declares a member function or member function
6642 // template of a class X, the expression this is a prvalue of type
6643 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6644 // and the end of the function-definition, member-declarator, or
6645 // declarator.
6646 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6647 Sema::CXXThisScopeRAII ThisScope(
6648 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6649
6650 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6651 if (ResultType.isNull())
6652 return QualType();
6653 }
6654 }
6655 else {
6656 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6657 if (ResultType.isNull())
6658 return QualType();
6659
6661 TL.getBeginLoc(), TL.getParams(),
6663 T->getExtParameterInfosOrNull(),
6664 ParamTypes, &ParamDecls, ExtParamInfos))
6665 return QualType();
6666 }
6667
6668 FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
6669
6670 bool EPIChanged = false;
6671 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6672 return QualType();
6673
6674 // Handle extended parameter information.
6675 if (auto NewExtParamInfos =
6676 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6677 if (!EPI.ExtParameterInfos ||
6679 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6680 EPIChanged = true;
6681 }
6682 EPI.ExtParameterInfos = NewExtParamInfos;
6683 } else if (EPI.ExtParameterInfos) {
6684 EPIChanged = true;
6685 EPI.ExtParameterInfos = nullptr;
6686 }
6687
6688 // Transform any function effects with unevaluated conditions.
6689 // Hold this set in a local for the rest of this function, since EPI
6690 // may need to hold a FunctionEffectsRef pointing into it.
6691 std::optional<FunctionEffectSet> NewFX;
6692 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6693 NewFX.emplace();
6696
6697 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6698 FunctionEffectWithCondition NewEC = PrevEC;
6699 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6700 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6701 if (NewExpr.isInvalid())
6702 return QualType();
6703 std::optional<FunctionEffectMode> Mode =
6704 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6705 if (!Mode)
6706 return QualType();
6707
6708 // The condition expression has been transformed, and re-evaluated.
6709 // It may or may not have become constant.
6710 switch (*Mode) {
6712 NewEC.Cond = {};
6713 break;
6715 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6716 NewEC.Cond = {};
6717 break;
6719 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6720 break;
6722 llvm_unreachable(
6723 "FunctionEffectMode::None shouldn't be possible here");
6724 }
6725 }
6726 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6727 TL.getBeginLoc())) {
6729 NewFX->insert(NewEC, Errs);
6730 assert(Errs.empty());
6731 }
6732 }
6733 EPI.FunctionEffects = *NewFX;
6734 EPIChanged = true;
6735 }
6736
6737 QualType Result = TL.getType();
6738 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6739 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6740 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6741 if (Result.isNull())
6742 return QualType();
6743 }
6744
6747 NewTL.setLParenLoc(TL.getLParenLoc());
6748 NewTL.setRParenLoc(TL.getRParenLoc());
6751 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6752 NewTL.setParam(i, ParamDecls[i]);
6753
6754 return Result;
6755}
6756
6757template<typename Derived>
6760 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6761 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6762
6763 // Instantiate a dynamic noexcept expression, if any.
6764 if (isComputedNoexcept(ESI.Type)) {
6765 // Update this scrope because ContextDecl in Sema will be used in
6766 // TransformExpr.
6767 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6768 Sema::CXXThisScopeRAII ThisScope(
6769 SemaRef, Method ? Method->getParent() : nullptr,
6770 Method ? Method->getMethodQualifiers() : Qualifiers{},
6771 Method != nullptr);
6774 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6775 if (NoexceptExpr.isInvalid())
6776 return true;
6777
6779 NoexceptExpr =
6780 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6781 if (NoexceptExpr.isInvalid())
6782 return true;
6783
6784 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6785 Changed = true;
6786 ESI.NoexceptExpr = NoexceptExpr.get();
6787 ESI.Type = EST;
6788 }
6789
6790 if (ESI.Type != EST_Dynamic)
6791 return false;
6792
6793 // Instantiate a dynamic exception specification's type.
6794 for (QualType T : ESI.Exceptions) {
6795 if (const PackExpansionType *PackExpansion =
6796 T->getAs<PackExpansionType>()) {
6797 Changed = true;
6798
6799 // We have a pack expansion. Instantiate it.
6801 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6802 Unexpanded);
6803 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6804
6805 // Determine whether the set of unexpanded parameter packs can and
6806 // should
6807 // be expanded.
6808 bool Expand = false;
6809 bool RetainExpansion = false;
6810 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
6811 // FIXME: Track the location of the ellipsis (and track source location
6812 // information for the types in the exception specification in general).
6814 Loc, SourceRange(), Unexpanded,
6815 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
6816 NumExpansions))
6817 return true;
6818
6819 if (!Expand) {
6820 // We can't expand this pack expansion into separate arguments yet;
6821 // just substitute into the pattern and create a new pack expansion
6822 // type.
6823 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
6824 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6825 if (U.isNull())
6826 return true;
6827
6828 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6829 Exceptions.push_back(U);
6830 continue;
6831 }
6832
6833 // Substitute into the pack expansion pattern for each slice of the
6834 // pack.
6835 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6836 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
6837
6838 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6839 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6840 return true;
6841
6842 Exceptions.push_back(U);
6843 }
6844 } else {
6845 QualType U = getDerived().TransformType(T);
6846 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6847 return true;
6848 if (T != U)
6849 Changed = true;
6850
6851 Exceptions.push_back(U);
6852 }
6853 }
6854
6855 ESI.Exceptions = Exceptions;
6856 if (ESI.Exceptions.empty())
6857 ESI.Type = EST_DynamicNone;
6858 return false;
6859}
6860
6861template<typename Derived>
6863 TypeLocBuilder &TLB,
6865 const FunctionNoProtoType *T = TL.getTypePtr();
6866 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6867 if (ResultType.isNull())
6868 return QualType();
6869
6870 QualType Result = TL.getType();
6871 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6872 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6873
6876 NewTL.setLParenLoc(TL.getLParenLoc());
6877 NewTL.setRParenLoc(TL.getRParenLoc());
6879
6880 return Result;
6881}
6882
6883template <typename Derived>
6884QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6885 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6886
6887 const UnresolvedUsingType *T = TL.getTypePtr();
6888 bool Changed = false;
6889
6890 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6891 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6892 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6893 if (!QualifierLoc)
6894 return QualType();
6895 Changed |= QualifierLoc != OldQualifierLoc;
6896 }
6897
6898 auto *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6899 if (!D)
6900 return QualType();
6901 Changed |= D != T->getDecl();
6902
6903 QualType Result = TL.getType();
6904 if (getDerived().AlwaysRebuild() || Changed) {
6905 Result = getDerived().RebuildUnresolvedUsingType(
6906 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TL.getNameLoc(),
6907 D);
6908 if (Result.isNull())
6909 return QualType();
6910 }
6911
6913 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6914 QualifierLoc, TL.getNameLoc());
6915 else
6916 TLB.push<UnresolvedUsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6917 QualifierLoc, TL.getNameLoc());
6918 return Result;
6919}
6920
6921template <typename Derived>
6923 UsingTypeLoc TL) {
6924 const UsingType *T = TL.getTypePtr();
6925 bool Changed = false;
6926
6927 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6928 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6929 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6930 if (!QualifierLoc)
6931 return QualType();
6932 Changed |= QualifierLoc != OldQualifierLoc;
6933 }
6934
6935 auto *D = cast_or_null<UsingShadowDecl>(
6936 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6937 if (!D)
6938 return QualType();
6939 Changed |= D != T->getDecl();
6940
6941 QualType UnderlyingType = getDerived().TransformType(T->desugar());
6942 if (UnderlyingType.isNull())
6943 return QualType();
6944 Changed |= UnderlyingType != T->desugar();
6945
6946 QualType Result = TL.getType();
6947 if (getDerived().AlwaysRebuild() || Changed) {
6948 Result = getDerived().RebuildUsingType(
6949 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), D,
6950 UnderlyingType);
6951 if (Result.isNull())
6952 return QualType();
6953 }
6954 TLB.push<UsingTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(), QualifierLoc,
6955 TL.getNameLoc());
6956 return Result;
6957}
6958
6959template<typename Derived>
6961 TypedefTypeLoc TL) {
6962 const TypedefType *T = TL.getTypePtr();
6963 bool Changed = false;
6964
6965 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
6966 if (NestedNameSpecifierLoc OldQualifierLoc = QualifierLoc) {
6967 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
6968 if (!QualifierLoc)
6969 return QualType();
6970 Changed |= QualifierLoc != OldQualifierLoc;
6971 }
6972
6973 auto *Typedef = cast_or_null<TypedefNameDecl>(
6974 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
6975 if (!Typedef)
6976 return QualType();
6977 Changed |= Typedef != T->getDecl();
6978
6979 // FIXME: Transform the UnderlyingType if different from decl.
6980
6981 QualType Result = TL.getType();
6982 if (getDerived().AlwaysRebuild() || Changed) {
6983 Result = getDerived().RebuildTypedefType(
6984 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), Typedef);
6985 if (Result.isNull())
6986 return QualType();
6987 }
6988
6989 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
6990 QualifierLoc, TL.getNameLoc());
6991 return Result;
6992}
6993
6994template<typename Derived>
6996 TypeOfExprTypeLoc TL) {
6997 // typeof expressions are not potentially evaluated contexts
7001
7002 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
7003 if (E.isInvalid())
7004 return QualType();
7005
7006 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
7007 if (E.isInvalid())
7008 return QualType();
7009
7010 QualType Result = TL.getType();
7012 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
7013 Result =
7014 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
7015 if (Result.isNull())
7016 return QualType();
7017 }
7018
7019 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
7020 NewTL.setTypeofLoc(TL.getTypeofLoc());
7021 NewTL.setLParenLoc(TL.getLParenLoc());
7022 NewTL.setRParenLoc(TL.getRParenLoc());
7023
7024 return Result;
7025}
7026
7027template<typename Derived>
7029 TypeOfTypeLoc TL) {
7030 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
7031 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
7032 if (!New_Under_TI)
7033 return QualType();
7034
7035 QualType Result = TL.getType();
7036 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
7037 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
7038 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
7039 if (Result.isNull())
7040 return QualType();
7041 }
7042
7043 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
7044 NewTL.setTypeofLoc(TL.getTypeofLoc());
7045 NewTL.setLParenLoc(TL.getLParenLoc());
7046 NewTL.setRParenLoc(TL.getRParenLoc());
7047 NewTL.setUnmodifiedTInfo(New_Under_TI);
7048
7049 return Result;
7050}
7051
7052template<typename Derived>
7054 DecltypeTypeLoc TL) {
7055 const DecltypeType *T = TL.getTypePtr();
7056
7057 // decltype expressions are not potentially evaluated contexts
7061
7062 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
7063 if (E.isInvalid())
7064 return QualType();
7065
7066 E = getSema().ActOnDecltypeExpression(E.get());
7067 if (E.isInvalid())
7068 return QualType();
7069
7070 QualType Result = TL.getType();
7071 if (getDerived().AlwaysRebuild() ||
7072 E.get() != T->getUnderlyingExpr()) {
7073 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
7074 if (Result.isNull())
7075 return QualType();
7076 }
7077 else E.get();
7078
7079 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
7080 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
7081 NewTL.setRParenLoc(TL.getRParenLoc());
7082 return Result;
7083}
7084
7085template <typename Derived>
7089 // Transform the index
7090 ExprResult IndexExpr;
7091 {
7092 EnterExpressionEvaluationContext ConstantContext(
7094
7095 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
7096 if (IndexExpr.isInvalid())
7097 return QualType();
7098 }
7099 QualType Pattern = TL.getPattern();
7100
7101 const PackIndexingType *PIT = TL.getTypePtr();
7102 SmallVector<QualType, 5> SubtitutedTypes;
7103 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
7104
7105 bool NotYetExpanded = Types.empty();
7106 bool FullySubstituted = true;
7107
7108 if (Types.empty() && !PIT->expandsToEmptyPack())
7109 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
7110
7111 for (QualType T : Types) {
7112 if (!T->containsUnexpandedParameterPack()) {
7113 QualType Transformed = getDerived().TransformType(T);
7114 if (Transformed.isNull())
7115 return QualType();
7116 SubtitutedTypes.push_back(Transformed);
7117 continue;
7118 }
7119
7121 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
7122 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7123 // Determine whether the set of unexpanded parameter packs can and should
7124 // be expanded.
7125 bool ShouldExpand = true;
7126 bool RetainExpansion = false;
7127 UnsignedOrNone NumExpansions = std::nullopt;
7128 if (getDerived().TryExpandParameterPacks(
7129 TL.getEllipsisLoc(), SourceRange(), Unexpanded,
7130 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
7131 RetainExpansion, NumExpansions))
7132 return QualType();
7133 if (!ShouldExpand) {
7134 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7135 // FIXME: should we keep TypeLoc for individual expansions in
7136 // PackIndexingTypeLoc?
7137 TypeSourceInfo *TI =
7138 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
7139 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
7140 if (Pack.isNull())
7141 return QualType();
7142 if (NotYetExpanded) {
7143 FullySubstituted = false;
7144 QualType Out = getDerived().RebuildPackIndexingType(
7145 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7146 FullySubstituted);
7147 if (Out.isNull())
7148 return QualType();
7149
7151 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7152 return Out;
7153 }
7154 SubtitutedTypes.push_back(Pack);
7155 continue;
7156 }
7157 for (unsigned I = 0; I != *NumExpansions; ++I) {
7158 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
7159 QualType Out = getDerived().TransformType(T);
7160 if (Out.isNull())
7161 return QualType();
7162 SubtitutedTypes.push_back(Out);
7163 FullySubstituted &= !Out->containsUnexpandedParameterPack();
7164 }
7165 // If we're supposed to retain a pack expansion, do so by temporarily
7166 // forgetting the partially-substituted parameter pack.
7167 if (RetainExpansion) {
7168 FullySubstituted = false;
7169 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
7170 QualType Out = getDerived().TransformType(T);
7171 if (Out.isNull())
7172 return QualType();
7173 SubtitutedTypes.push_back(Out);
7174 }
7175 }
7176
7177 // A pack indexing type can appear in a larger pack expansion,
7178 // e.g. `Pack...[pack_of_indexes]...`
7179 // so we need to temporarily disable substitution of pack elements
7180 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
7181 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
7182
7183 QualType Out = getDerived().RebuildPackIndexingType(
7184 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
7185 FullySubstituted, SubtitutedTypes);
7186 if (Out.isNull())
7187 return Out;
7188
7190 Loc.setEllipsisLoc(TL.getEllipsisLoc());
7191 return Out;
7192}
7193
7194template<typename Derived>
7196 TypeLocBuilder &TLB,
7198 QualType Result = TL.getType();
7199 TypeSourceInfo *NewBaseTSI = TL.getUnderlyingTInfo();
7200 if (Result->isDependentType()) {
7201 const UnaryTransformType *T = TL.getTypePtr();
7202
7203 NewBaseTSI = getDerived().TransformType(TL.getUnderlyingTInfo());
7204 if (!NewBaseTSI)
7205 return QualType();
7206 QualType NewBase = NewBaseTSI->getType();
7207
7208 Result = getDerived().RebuildUnaryTransformType(NewBase,
7209 T->getUTTKind(),
7210 TL.getKWLoc());
7211 if (Result.isNull())
7212 return QualType();
7213 }
7214
7216 NewTL.setKWLoc(TL.getKWLoc());
7217 NewTL.setParensRange(TL.getParensRange());
7218 NewTL.setUnderlyingTInfo(NewBaseTSI);
7219 return Result;
7220}
7221
7222template<typename Derived>
7225 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
7226
7227 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7228 TemplateName TemplateName = getDerived().TransformTemplateName(
7229 QualifierLoc, /*TemplateKELoc=*/SourceLocation(), T->getTemplateName(),
7230 TL.getTemplateNameLoc());
7231 if (TemplateName.isNull())
7232 return QualType();
7233
7234 QualType OldDeduced = T->getDeducedType();
7235 QualType NewDeduced;
7236 if (!OldDeduced.isNull()) {
7237 NewDeduced = getDerived().TransformType(OldDeduced);
7238 if (NewDeduced.isNull())
7239 return QualType();
7240 }
7241
7242 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
7243 T->getKeyword(), TemplateName, NewDeduced);
7244 if (Result.isNull())
7245 return QualType();
7246
7247 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7248 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7249 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7250 NewTL.setQualifierLoc(QualifierLoc);
7251 return Result;
7252}
7253
7254template <typename Derived>
7256 TagTypeLoc TL) {
7257 const TagType *T = TL.getTypePtr();
7258
7259 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7260 if (QualifierLoc) {
7261 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
7262 if (!QualifierLoc)
7263 return QualType();
7264 }
7265
7266 auto *TD = cast_or_null<TagDecl>(
7267 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
7268 if (!TD)
7269 return QualType();
7270
7271 QualType Result = TL.getType();
7272 if (getDerived().AlwaysRebuild() || QualifierLoc != TL.getQualifierLoc() ||
7273 TD != T->getDecl()) {
7274 if (T->isCanonicalUnqualified())
7275 Result = getDerived().RebuildCanonicalTagType(TD);
7276 else
7277 Result = getDerived().RebuildTagType(
7278 T->getKeyword(), QualifierLoc.getNestedNameSpecifier(), TD);
7279 if (Result.isNull())
7280 return QualType();
7281 }
7282
7283 TagTypeLoc NewTL = TLB.push<TagTypeLoc>(Result);
7285 NewTL.setQualifierLoc(QualifierLoc);
7286 NewTL.setNameLoc(TL.getNameLoc());
7287
7288 return Result;
7289}
7290
7291template <typename Derived>
7293 EnumTypeLoc TL) {
7294 return getDerived().TransformTagType(TLB, TL);
7295}
7296
7297template <typename Derived>
7298QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
7299 RecordTypeLoc TL) {
7300 return getDerived().TransformTagType(TLB, TL);
7301}
7302
7303template<typename Derived>
7305 TypeLocBuilder &TLB,
7307 return getDerived().TransformTagType(TLB, TL);
7308}
7309
7310template<typename Derived>
7312 TypeLocBuilder &TLB,
7314 return getDerived().TransformTemplateTypeParmType(
7315 TLB, TL,
7316 /*SuppressObjCLifetime=*/false);
7317}
7318
7319template <typename Derived>
7321 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7322 return TransformTypeSpecType(TLB, TL);
7323}
7324
7325template<typename Derived>
7326QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7327 TypeLocBuilder &TLB,
7328 SubstTemplateTypeParmTypeLoc TL) {
7329 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7330
7331 Decl *NewReplaced =
7332 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7333
7334 // Substitute into the replacement type, which itself might involve something
7335 // that needs to be transformed. This only tends to occur with default
7336 // template arguments of template template parameters.
7337 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7338 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7339 if (Replacement.isNull())
7340 return QualType();
7341
7342 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7343 Replacement, NewReplaced, T->getIndex(), T->getPackIndex(),
7344 T->getFinal());
7345
7346 // Propagate type-source information.
7347 SubstTemplateTypeParmTypeLoc NewTL
7348 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7349 NewTL.setNameLoc(TL.getNameLoc());
7350 return Result;
7351
7352}
7353template <typename Derived>
7356 return TransformTypeSpecType(TLB, TL);
7357}
7358
7359template<typename Derived>
7361 TypeLocBuilder &TLB,
7363 return getDerived().TransformSubstTemplateTypeParmPackType(
7364 TLB, TL, /*SuppressObjCLifetime=*/false);
7365}
7366
7367template <typename Derived>
7370 return TransformTypeSpecType(TLB, TL);
7371}
7372
7373template<typename Derived>
7374QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
7375 AtomicTypeLoc TL) {
7376 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7377 if (ValueType.isNull())
7378 return QualType();
7379
7380 QualType Result = TL.getType();
7381 if (getDerived().AlwaysRebuild() ||
7382 ValueType != TL.getValueLoc().getType()) {
7383 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7384 if (Result.isNull())
7385 return QualType();
7386 }
7387
7388 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7389 NewTL.setKWLoc(TL.getKWLoc());
7390 NewTL.setLParenLoc(TL.getLParenLoc());
7391 NewTL.setRParenLoc(TL.getRParenLoc());
7392
7393 return Result;
7394}
7395
7396template <typename Derived>
7398 PipeTypeLoc TL) {
7399 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7400 if (ValueType.isNull())
7401 return QualType();
7402
7403 QualType Result = TL.getType();
7404 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7405 const PipeType *PT = Result->castAs<PipeType>();
7406 bool isReadPipe = PT->isReadOnly();
7407 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7408 if (Result.isNull())
7409 return QualType();
7410 }
7411
7412 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7413 NewTL.setKWLoc(TL.getKWLoc());
7414
7415 return Result;
7416}
7417
7418template <typename Derived>
7420 BitIntTypeLoc TL) {
7421 const BitIntType *EIT = TL.getTypePtr();
7422 QualType Result = TL.getType();
7423
7424 if (getDerived().AlwaysRebuild()) {
7425 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7426 EIT->getNumBits(), TL.getNameLoc());
7427 if (Result.isNull())
7428 return QualType();
7429 }
7430
7431 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7432 NewTL.setNameLoc(TL.getNameLoc());
7433 return Result;
7434}
7435
7436template <typename Derived>
7439 const DependentBitIntType *EIT = TL.getTypePtr();
7440
7443 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7444 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7445
7446 if (BitsExpr.isInvalid())
7447 return QualType();
7448
7449 QualType Result = TL.getType();
7450
7451 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7452 Result = getDerived().RebuildDependentBitIntType(
7453 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7454
7455 if (Result.isNull())
7456 return QualType();
7457 }
7458
7461 NewTL.setNameLoc(TL.getNameLoc());
7462 } else {
7463 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7464 NewTL.setNameLoc(TL.getNameLoc());
7465 }
7466 return Result;
7467}
7468
7469template <typename Derived>
7472 llvm_unreachable("This type does not need to be transformed.");
7473}
7474
7475 /// Simple iterator that traverses the template arguments in a
7476 /// container that provides a \c getArgLoc() member function.
7477 ///
7478 /// This iterator is intended to be used with the iterator form of
7479 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7480 template<typename ArgLocContainer>
7482 ArgLocContainer *Container;
7483 unsigned Index;
7484
7485 public:
7488 typedef int difference_type;
7489 typedef std::input_iterator_tag iterator_category;
7490
7491 class pointer {
7493
7494 public:
7495 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7496
7498 return &Arg;
7499 }
7500 };
7501
7502
7504
7505 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7506 unsigned Index)
7507 : Container(&Container), Index(Index) { }
7508
7510 ++Index;
7511 return *this;
7512 }
7513
7516 ++(*this);
7517 return Old;
7518 }
7519
7521 return Container->getArgLoc(Index);
7522 }
7523
7525 return pointer(Container->getArgLoc(Index));
7526 }
7527
7530 return X.Container == Y.Container && X.Index == Y.Index;
7531 }
7532
7535 return !(X == Y);
7536 }
7537 };
7538
7539template<typename Derived>
7540QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7541 AutoTypeLoc TL) {
7542 const AutoType *T = TL.getTypePtr();
7543 QualType OldDeduced = T->getDeducedType();
7544 QualType NewDeduced;
7545 if (!OldDeduced.isNull()) {
7546 NewDeduced = getDerived().TransformType(OldDeduced);
7547 if (NewDeduced.isNull())
7548 return QualType();
7549 }
7550
7551 ConceptDecl *NewCD = nullptr;
7552 TemplateArgumentListInfo NewTemplateArgs;
7553 NestedNameSpecifierLoc NewNestedNameSpec;
7554 if (T->isConstrained()) {
7555 assert(TL.getConceptReference());
7556 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7557 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7558
7559 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7560 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7562 if (getDerived().TransformTemplateArguments(
7563 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7564 NewTemplateArgs))
7565 return QualType();
7566
7567 if (TL.getNestedNameSpecifierLoc()) {
7568 NewNestedNameSpec
7569 = getDerived().TransformNestedNameSpecifierLoc(
7570 TL.getNestedNameSpecifierLoc());
7571 if (!NewNestedNameSpec)
7572 return QualType();
7573 }
7574 }
7575
7576 QualType Result = TL.getType();
7577 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7578 T->isDependentType() || T->isConstrained()) {
7579 // FIXME: Maybe don't rebuild if all template arguments are the same.
7581 NewArgList.reserve(NewTemplateArgs.size());
7582 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7583 NewArgList.push_back(ArgLoc.getArgument());
7584 Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword(), NewCD,
7585 NewArgList);
7586 if (Result.isNull())
7587 return QualType();
7588 }
7589
7590 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7591 NewTL.setNameLoc(TL.getNameLoc());
7592 NewTL.setRParenLoc(TL.getRParenLoc());
7593 NewTL.setConceptReference(nullptr);
7594
7595 if (T->isConstrained()) {
7597 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7598 TL.getConceptNameLoc(),
7599 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7600 auto *CR = ConceptReference::Create(
7601 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7602 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7603 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7604 NewTL.setConceptReference(CR);
7605 }
7606
7607 return Result;
7608}
7609
7610template <typename Derived>
7613 return getDerived().TransformTemplateSpecializationType(
7614 TLB, TL, /*ObjectType=*/QualType(), /*FirstQualifierInScope=*/nullptr,
7615 /*AllowInjectedClassName=*/false);
7616}
7617
7618template <typename Derived>
7621 NamedDecl *FirstQualifierInScope, bool AllowInjectedClassName) {
7622 const TemplateSpecializationType *T = TL.getTypePtr();
7623
7624 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7625 TemplateName Template = getDerived().TransformTemplateName(
7626 QualifierLoc, TL.getTemplateKeywordLoc(), T->getTemplateName(),
7627 TL.getTemplateNameLoc(), ObjectType, FirstQualifierInScope,
7628 AllowInjectedClassName);
7629 if (Template.isNull())
7630 return QualType();
7631
7632 TemplateArgumentListInfo NewTemplateArgs;
7633 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7634 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7636 ArgIterator;
7637 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7638 ArgIterator(TL, TL.getNumArgs()),
7639 NewTemplateArgs))
7640 return QualType();
7641
7642 // This needs to be rebuilt if either the arguments changed, or if the
7643 // original template changed. If the template changed, and even if the
7644 // arguments didn't change, these arguments might not correspond to their
7645 // respective parameters, therefore needing conversions.
7646 QualType Result = getDerived().RebuildTemplateSpecializationType(
7647 TL.getTypePtr()->getKeyword(), Template, TL.getTemplateNameLoc(),
7648 NewTemplateArgs);
7649
7650 if (!Result.isNull()) {
7652 TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getTemplateKeywordLoc(),
7653 TL.getTemplateNameLoc(), NewTemplateArgs);
7654 }
7655
7656 return Result;
7657}
7658
7659template <typename Derived>
7661 AttributedTypeLoc TL) {
7662 const AttributedType *oldType = TL.getTypePtr();
7663 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7664 if (modifiedType.isNull())
7665 return QualType();
7666
7667 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7668 const Attr *oldAttr = TL.getAttr();
7669 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7670 if (oldAttr && !newAttr)
7671 return QualType();
7672
7673 QualType result = TL.getType();
7674
7675 // FIXME: dependent operand expressions?
7676 if (getDerived().AlwaysRebuild() ||
7677 modifiedType != oldType->getModifiedType()) {
7678 // If the equivalent type is equal to the modified type, we don't want to
7679 // transform it as well because:
7680 //
7681 // 1. The transformation would yield the same result and is therefore
7682 // superfluous, and
7683 //
7684 // 2. Transforming the same type twice can cause problems, e.g. if it
7685 // is a FunctionProtoType, we may end up instantiating the function
7686 // parameters twice, which causes an assertion since the parameters
7687 // are already bound to their counterparts in the template for this
7688 // instantiation.
7689 //
7690 QualType equivalentType = modifiedType;
7691 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7692 TypeLocBuilder AuxiliaryTLB;
7693 AuxiliaryTLB.reserve(TL.getFullDataSize());
7694 equivalentType =
7695 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7696 if (equivalentType.isNull())
7697 return QualType();
7698 }
7699
7700 // Check whether we can add nullability; it is only represented as
7701 // type sugar, and therefore cannot be diagnosed in any other way.
7702 if (auto nullability = oldType->getImmediateNullability()) {
7703 if (!modifiedType->canHaveNullability()) {
7704 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7705 : TL.getModifiedLoc().getBeginLoc()),
7706 diag::err_nullability_nonpointer)
7707 << DiagNullabilityKind(*nullability, false) << modifiedType;
7708 return QualType();
7709 }
7710 }
7711
7712 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7713 modifiedType,
7714 equivalentType,
7715 TL.getAttr());
7716 }
7717
7718 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7719 newTL.setAttr(newAttr);
7720 return result;
7721}
7722
7723template <typename Derived>
7726 const CountAttributedType *OldTy = TL.getTypePtr();
7727 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7728 if (InnerTy.isNull())
7729 return QualType();
7730
7731 Expr *OldCount = TL.getCountExpr();
7732 Expr *NewCount = nullptr;
7733 if (OldCount) {
7734 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7735 if (CountResult.isInvalid())
7736 return QualType();
7737 NewCount = CountResult.get();
7738 }
7739
7740 QualType Result = TL.getType();
7741 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7742 OldCount != NewCount) {
7743 // Currently, CountAttributedType can only wrap incomplete array types.
7745 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7746 }
7747
7748 TLB.push<CountAttributedTypeLoc>(Result);
7749 return Result;
7750}
7751
7752template <typename Derived>
7755 // The BTFTagAttributedType is available for C only.
7756 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7757}
7758
7759template <typename Derived>
7762 const OverflowBehaviorType *OldTy = TL.getTypePtr();
7763 QualType InnerTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7764 if (InnerTy.isNull())
7765 return QualType();
7766
7767 QualType Result = TL.getType();
7768 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->getUnderlyingType()) {
7769 Result = SemaRef.Context.getOverflowBehaviorType(OldTy->getBehaviorKind(),
7770 InnerTy);
7771 if (Result.isNull())
7772 return QualType();
7773 }
7774
7776 NewTL.initializeLocal(SemaRef.Context, TL.getAttrLoc());
7777 return Result;
7778}
7779
7780template <typename Derived>
7783
7784 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7785
7786 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7787 if (WrappedTy.isNull())
7788 return QualType();
7789
7790 QualType ContainedTy = QualType();
7791 QualType OldContainedTy = oldType->getContainedType();
7792 TypeSourceInfo *ContainedTSI = nullptr;
7793 if (!OldContainedTy.isNull()) {
7794 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7795 if (!oldContainedTSI)
7796 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7797 OldContainedTy, SourceLocation());
7798 ContainedTSI = getDerived().TransformType(oldContainedTSI);
7799 if (!ContainedTSI)
7800 return QualType();
7801 ContainedTy = ContainedTSI->getType();
7802 }
7803
7804 QualType Result = TL.getType();
7805 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7806 ContainedTy != oldType->getContainedType()) {
7808 WrappedTy, ContainedTy, oldType->getAttrs());
7809 }
7810
7813 NewTL.setSourceRange(TL.getLocalSourceRange());
7814 NewTL.setContainedTypeSourceInfo(ContainedTSI);
7815 return Result;
7816}
7817
7818template <typename Derived>
7821 // No transformations needed.
7822 return TL.getType();
7823}
7824
7825template<typename Derived>
7828 ParenTypeLoc TL) {
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() ||
7835 Inner != TL.getInnerLoc().getType()) {
7836 Result = getDerived().RebuildParenType(Inner);
7837 if (Result.isNull())
7838 return QualType();
7839 }
7840
7841 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7842 NewTL.setLParenLoc(TL.getLParenLoc());
7843 NewTL.setRParenLoc(TL.getRParenLoc());
7844 return Result;
7845}
7846
7847template <typename Derived>
7851 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7852 if (Inner.isNull())
7853 return QualType();
7854
7855 QualType Result = TL.getType();
7856 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7857 Result =
7858 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7859 if (Result.isNull())
7860 return QualType();
7861 }
7862
7864 NewTL.setExpansionLoc(TL.getExpansionLoc());
7865 return Result;
7866}
7867
7868template<typename Derived>
7869QualType TreeTransform<Derived>::TransformDependentNameType(
7871 return TransformDependentNameType(TLB, TL, false);
7872}
7873
7874template <typename Derived>
7875QualType TreeTransform<Derived>::TransformDependentNameType(
7876 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext,
7877 QualType ObjectType, NamedDecl *UnqualLookup) {
7878 const DependentNameType *T = TL.getTypePtr();
7879
7880 NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
7881 if (QualifierLoc) {
7882 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(
7883 QualifierLoc, ObjectType, UnqualLookup);
7884 if (!QualifierLoc)
7885 return QualType();
7886 } else {
7887 assert((ObjectType.isNull() && !UnqualLookup) &&
7888 "must be transformed by TransformNestedNameSpecifierLoc");
7889 }
7890
7892 = getDerived().RebuildDependentNameType(T->getKeyword(),
7893 TL.getElaboratedKeywordLoc(),
7894 QualifierLoc,
7895 T->getIdentifier(),
7896 TL.getNameLoc(),
7897 DeducedTSTContext);
7898 if (Result.isNull())
7899 return QualType();
7900
7901 if (isa<TagType>(Result)) {
7902 auto NewTL = TLB.push<TagTypeLoc>(Result);
7903 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7904 NewTL.setQualifierLoc(QualifierLoc);
7905 NewTL.setNameLoc(TL.getNameLoc());
7907 auto NewTL = TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
7908 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7909 NewTL.setTemplateNameLoc(TL.getNameLoc());
7910 NewTL.setQualifierLoc(QualifierLoc);
7911 } else if (isa<TypedefType>(Result)) {
7912 TLB.push<TypedefTypeLoc>(Result).set(TL.getElaboratedKeywordLoc(),
7913 QualifierLoc, TL.getNameLoc());
7914 } else if (isa<UnresolvedUsingType>(Result)) {
7915 auto NewTL = TLB.push<UnresolvedUsingTypeLoc>(Result);
7916 NewTL.set(TL.getElaboratedKeywordLoc(), QualifierLoc, TL.getNameLoc());
7917 } else {
7918 auto NewTL = TLB.push<DependentNameTypeLoc>(Result);
7919 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7920 NewTL.setQualifierLoc(QualifierLoc);
7921 NewTL.setNameLoc(TL.getNameLoc());
7922 }
7923 return Result;
7924}
7925
7926template<typename Derived>
7929 QualType Pattern
7930 = getDerived().TransformType(TLB, TL.getPatternLoc());
7931 if (Pattern.isNull())
7932 return QualType();
7933
7934 QualType Result = TL.getType();
7935 if (getDerived().AlwaysRebuild() ||
7936 Pattern != TL.getPatternLoc().getType()) {
7937 Result = getDerived().RebuildPackExpansionType(Pattern,
7938 TL.getPatternLoc().getSourceRange(),
7939 TL.getEllipsisLoc(),
7940 TL.getTypePtr()->getNumExpansions());
7941 if (Result.isNull())
7942 return QualType();
7943 }
7944
7946 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7947 return Result;
7948}
7949
7950template<typename Derived>
7954 // ObjCInterfaceType is never dependent.
7955 TLB.pushFullCopy(TL);
7956 return TL.getType();
7957}
7958
7959template<typename Derived>
7963 const ObjCTypeParamType *T = TL.getTypePtr();
7964 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7965 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7966 if (!OTP)
7967 return QualType();
7968
7969 QualType Result = TL.getType();
7970 if (getDerived().AlwaysRebuild() ||
7971 OTP != T->getDecl()) {
7972 Result = getDerived().RebuildObjCTypeParamType(
7973 OTP, TL.getProtocolLAngleLoc(),
7974 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7975 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7976 if (Result.isNull())
7977 return QualType();
7978 }
7979
7981 if (TL.getNumProtocols()) {
7982 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7983 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7984 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7985 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7986 }
7987 return Result;
7988}
7989
7990template<typename Derived>
7993 ObjCObjectTypeLoc TL) {
7994 // Transform base type.
7995 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
7996 if (BaseType.isNull())
7997 return QualType();
7998
7999 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
8000
8001 // Transform type arguments.
8002 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
8003 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
8004 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
8005 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
8006 QualType TypeArg = TypeArgInfo->getType();
8007 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
8008 AnyChanged = true;
8009
8010 // We have a pack expansion. Instantiate it.
8011 const auto *PackExpansion = PackExpansionLoc.getType()
8012 ->castAs<PackExpansionType>();
8014 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
8015 Unexpanded);
8016 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
8017
8018 // Determine whether the set of unexpanded parameter packs can
8019 // and should be expanded.
8020 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
8021 bool Expand = false;
8022 bool RetainExpansion = false;
8023 UnsignedOrNone NumExpansions = PackExpansion->getNumExpansions();
8024 if (getDerived().TryExpandParameterPacks(
8025 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
8026 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
8027 RetainExpansion, NumExpansions))
8028 return QualType();
8029
8030 if (!Expand) {
8031 // We can't expand this pack expansion into separate arguments yet;
8032 // just substitute into the pattern and create a new pack expansion
8033 // type.
8034 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
8035
8036 TypeLocBuilder TypeArgBuilder;
8037 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8038 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
8039 PatternLoc);
8040 if (NewPatternType.isNull())
8041 return QualType();
8042
8043 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
8044 NewPatternType, NumExpansions);
8045 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
8046 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
8047 NewTypeArgInfos.push_back(
8048 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
8049 continue;
8050 }
8051
8052 // Substitute into the pack expansion pattern for each slice of the
8053 // pack.
8054 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
8055 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), ArgIdx);
8056
8057 TypeLocBuilder TypeArgBuilder;
8058 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
8059
8060 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
8061 PatternLoc);
8062 if (NewTypeArg.isNull())
8063 return QualType();
8064
8065 NewTypeArgInfos.push_back(
8066 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8067 }
8068
8069 continue;
8070 }
8071
8072 TypeLocBuilder TypeArgBuilder;
8073 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
8074 QualType NewTypeArg =
8075 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
8076 if (NewTypeArg.isNull())
8077 return QualType();
8078
8079 // If nothing changed, just keep the old TypeSourceInfo.
8080 if (NewTypeArg == TypeArg) {
8081 NewTypeArgInfos.push_back(TypeArgInfo);
8082 continue;
8083 }
8084
8085 NewTypeArgInfos.push_back(
8086 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
8087 AnyChanged = true;
8088 }
8089
8090 QualType Result = TL.getType();
8091 if (getDerived().AlwaysRebuild() || AnyChanged) {
8092 // Rebuild the type.
8093 Result = getDerived().RebuildObjCObjectType(
8094 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
8095 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
8096 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
8097 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
8098
8099 if (Result.isNull())
8100 return QualType();
8101 }
8102
8103 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
8104 NewT.setHasBaseTypeAsWritten(true);
8105 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
8106 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
8107 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
8108 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
8109 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
8110 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
8111 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
8112 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
8113 return Result;
8114}
8115
8116template<typename Derived>
8120 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8121 if (PointeeType.isNull())
8122 return QualType();
8123
8124 QualType Result = TL.getType();
8125 if (getDerived().AlwaysRebuild() ||
8126 PointeeType != TL.getPointeeLoc().getType()) {
8127 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8128 TL.getStarLoc());
8129 if (Result.isNull())
8130 return QualType();
8131 }
8132
8134 NewT.setStarLoc(TL.getStarLoc());
8135 return Result;
8136}
8137
8138//===----------------------------------------------------------------------===//
8139// Statement transformation
8140//===----------------------------------------------------------------------===//
8141template<typename Derived>
8144 return S;
8145}
8146
8147template<typename Derived>
8150 return getDerived().TransformCompoundStmt(S, false);
8151}
8152
8153template<typename Derived>
8156 bool IsStmtExpr) {
8157 Sema::CompoundScopeRAII CompoundScope(getSema());
8158 Sema::FPFeaturesStateRAII FPSave(getSema());
8159 if (S->hasStoredFPFeatures())
8160 getSema().resetFPOptions(
8161 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8162
8163 bool SubStmtInvalid = false;
8164 bool SubStmtChanged = false;
8165 SmallVector<Stmt*, 8> Statements;
8166 for (auto *B : S->body()) {
8167 StmtResult Result = getDerived().TransformStmt(
8168 B, IsStmtExpr && B == S->body_back() ? StmtDiscardKind::StmtExprResult
8169 : StmtDiscardKind::Discarded);
8170
8171 if (Result.isInvalid()) {
8172 // Immediately fail if this was a DeclStmt, since it's very
8173 // likely that this will cause problems for future statements.
8174 if (isa<DeclStmt>(B))
8175 return StmtError();
8176
8177 // Otherwise, just keep processing substatements and fail later.
8178 SubStmtInvalid = true;
8179 continue;
8180 }
8181
8182 SubStmtChanged = SubStmtChanged || Result.get() != B;
8183 Statements.push_back(Result.getAs<Stmt>());
8184 }
8185
8186 if (SubStmtInvalid)
8187 return StmtError();
8188
8189 if (!getDerived().AlwaysRebuild() &&
8190 !SubStmtChanged)
8191 return S;
8192
8193 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8194 Statements,
8195 S->getRBracLoc(),
8196 IsStmtExpr);
8197}
8198
8199template<typename Derived>
8202 ExprResult LHS, RHS;
8203 {
8206
8207 // Transform the left-hand case value.
8208 LHS = getDerived().TransformExpr(S->getLHS());
8209 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8210 if (LHS.isInvalid())
8211 return StmtError();
8212
8213 // Transform the right-hand case value (for the GNU case-range extension).
8214 RHS = getDerived().TransformExpr(S->getRHS());
8215 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8216 if (RHS.isInvalid())
8217 return StmtError();
8218 }
8219
8220 // Build the case statement.
8221 // Case statements are always rebuilt so that they will attached to their
8222 // transformed switch statement.
8223 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8224 LHS.get(),
8225 S->getEllipsisLoc(),
8226 RHS.get(),
8227 S->getColonLoc());
8228 if (Case.isInvalid())
8229 return StmtError();
8230
8231 // Transform the statement following the case
8232 StmtResult SubStmt =
8233 getDerived().TransformStmt(S->getSubStmt());
8234 if (SubStmt.isInvalid())
8235 return StmtError();
8236
8237 // Attach the body to the case statement
8238 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8239}
8240
8241template <typename Derived>
8243 // Transform the statement following the default case
8244 StmtResult SubStmt =
8245 getDerived().TransformStmt(S->getSubStmt());
8246 if (SubStmt.isInvalid())
8247 return StmtError();
8248
8249 // Default statements are always rebuilt
8250 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8251 SubStmt.get());
8252}
8253
8254template<typename Derived>
8257 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8258 if (SubStmt.isInvalid())
8259 return StmtError();
8260
8261 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8262 S->getDecl());
8263 if (!LD)
8264 return StmtError();
8265
8266 // If we're transforming "in-place" (we're not creating new local
8267 // declarations), assume we're replacing the old label statement
8268 // and clear out the reference to it.
8269 if (LD == S->getDecl())
8270 S->getDecl()->setStmt(nullptr);
8271
8272 // FIXME: Pass the real colon location in.
8273 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8275 SubStmt.get());
8276}
8277
8278template <typename Derived>
8280 if (!R)
8281 return R;
8282
8283 switch (R->getKind()) {
8284// Transform attributes by calling TransformXXXAttr.
8285#define ATTR(X) \
8286 case attr::X: \
8287 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8288#include "clang/Basic/AttrList.inc"
8289 }
8290 return R;
8291}
8292
8293template <typename Derived>
8295 const Stmt *InstS,
8296 const Attr *R) {
8297 if (!R)
8298 return R;
8299
8300 switch (R->getKind()) {
8301// Transform attributes by calling TransformStmtXXXAttr.
8302#define ATTR(X) \
8303 case attr::X: \
8304 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8305#include "clang/Basic/AttrList.inc"
8306 }
8307 return TransformAttr(R);
8308}
8309
8310template <typename Derived>
8313 StmtDiscardKind SDK) {
8314 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8315 if (SubStmt.isInvalid())
8316 return StmtError();
8317
8318 bool AttrsChanged = false;
8320
8321 // Visit attributes and keep track if any are transformed.
8322 for (const auto *I : S->getAttrs()) {
8323 const Attr *R =
8324 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8325 AttrsChanged |= (I != R);
8326 if (R)
8327 Attrs.push_back(R);
8328 }
8329
8330 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8331 return S;
8332
8333 // If transforming the attributes failed for all of the attributes in the
8334 // statement, don't make an AttributedStmt without attributes.
8335 if (Attrs.empty())
8336 return SubStmt;
8337
8338 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8339 SubStmt.get());
8340}
8341
8342template<typename Derived>
8345 // Transform the initialization statement
8346 StmtResult Init = getDerived().TransformStmt(S->getInit());
8347 if (Init.isInvalid())
8348 return StmtError();
8349
8351 if (!S->isConsteval()) {
8352 // Transform the condition
8353 Cond = getDerived().TransformCondition(
8354 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8355 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8357 if (Cond.isInvalid())
8358 return StmtError();
8359 }
8360
8361 // If this is a constexpr if, determine which arm we should instantiate.
8362 std::optional<bool> ConstexprConditionValue;
8363 if (S->isConstexpr())
8364 ConstexprConditionValue = Cond.getKnownValue();
8365
8366 // Transform the "then" branch.
8367 StmtResult Then;
8368 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8372 S->isNonNegatedConsteval());
8373
8374 Then = getDerived().TransformStmt(S->getThen());
8375 if (Then.isInvalid())
8376 return StmtError();
8377 } else {
8378 // Discarded branch is replaced with empty CompoundStmt so we can keep
8379 // proper source location for start and end of original branch, so
8380 // subsequent transformations like CoverageMapping work properly
8381 Then = new (getSema().Context)
8382 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8383 }
8384
8385 // Transform the "else" branch.
8386 StmtResult Else;
8387 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8391 S->isNegatedConsteval());
8392
8393 Else = getDerived().TransformStmt(S->getElse());
8394 if (Else.isInvalid())
8395 return StmtError();
8396 } else if (S->getElse() && ConstexprConditionValue &&
8397 *ConstexprConditionValue) {
8398 // Same thing here as with <then> branch, we are discarding it, we can't
8399 // replace it with NULL nor NullStmt as we need to keep for source location
8400 // range, for CoverageMapping
8401 Else = new (getSema().Context)
8402 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8403 }
8404
8405 if (!getDerived().AlwaysRebuild() &&
8406 Init.get() == S->getInit() &&
8407 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8408 Then.get() == S->getThen() &&
8409 Else.get() == S->getElse())
8410 return S;
8411
8412 return getDerived().RebuildIfStmt(
8413 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8414 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8415}
8416
8417template<typename Derived>
8420 // Transform the initialization statement
8421 StmtResult Init = getDerived().TransformStmt(S->getInit());
8422 if (Init.isInvalid())
8423 return StmtError();
8424
8425 // Transform the condition.
8426 Sema::ConditionResult Cond = getDerived().TransformCondition(
8427 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8429 if (Cond.isInvalid())
8430 return StmtError();
8431
8432 // Rebuild the switch statement.
8434 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8435 Init.get(), Cond, S->getRParenLoc());
8436 if (Switch.isInvalid())
8437 return StmtError();
8438
8439 // Transform the body of the switch statement.
8440 StmtResult Body = getDerived().TransformStmt(S->getBody());
8441 if (Body.isInvalid())
8442 return StmtError();
8443
8444 // Complete the switch statement.
8445 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8446 Body.get());
8447}
8448
8449template<typename Derived>
8452 // Transform the condition
8453 Sema::ConditionResult Cond = getDerived().TransformCondition(
8454 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8456 if (Cond.isInvalid())
8457 return StmtError();
8458
8459 // OpenACC Restricts a while-loop inside of certain construct/clause
8460 // combinations, so diagnose that here in OpenACC mode.
8462 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8463
8464 // Transform the body
8465 StmtResult Body = getDerived().TransformStmt(S->getBody());
8466 if (Body.isInvalid())
8467 return StmtError();
8468
8469 if (!getDerived().AlwaysRebuild() &&
8470 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8471 Body.get() == S->getBody())
8472 return Owned(S);
8473
8474 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8475 Cond, S->getRParenLoc(), Body.get());
8476}
8477
8478template<typename Derived>
8481 // OpenACC Restricts a do-loop inside of certain construct/clause
8482 // combinations, so diagnose that here in OpenACC mode.
8484 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8485
8486 // Transform the body
8487 StmtResult Body = getDerived().TransformStmt(S->getBody());
8488 if (Body.isInvalid())
8489 return StmtError();
8490
8491 // Transform the condition
8492 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8493 if (Cond.isInvalid())
8494 return StmtError();
8495
8496 if (!getDerived().AlwaysRebuild() &&
8497 Cond.get() == S->getCond() &&
8498 Body.get() == S->getBody())
8499 return S;
8500
8501 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8502 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8503 S->getRParenLoc());
8504}
8505
8506template<typename Derived>
8509 if (getSema().getLangOpts().OpenMP)
8510 getSema().OpenMP().startOpenMPLoop();
8511
8512 // Transform the initialization statement
8513 StmtResult Init = getDerived().TransformStmt(S->getInit());
8514 if (Init.isInvalid())
8515 return StmtError();
8516
8517 // In OpenMP loop region loop control variable must be captured and be
8518 // private. Perform analysis of first part (if any).
8519 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8520 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8521 Init.get());
8522
8523 // Transform the condition
8524 Sema::ConditionResult Cond = getDerived().TransformCondition(
8525 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8527 if (Cond.isInvalid())
8528 return StmtError();
8529
8530 // Transform the increment
8531 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8532 if (Inc.isInvalid())
8533 return StmtError();
8534
8535 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8536 if (S->getInc() && !FullInc.get())
8537 return StmtError();
8538
8539 // OpenACC Restricts a for-loop inside of certain construct/clause
8540 // combinations, so diagnose that here in OpenACC mode.
8542 SemaRef.OpenACC().ActOnForStmtBegin(
8543 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8544 Cond.get().second, S->getInc(), Inc.get());
8545
8546 // Transform the body
8547 StmtResult Body = getDerived().TransformStmt(S->getBody());
8548 if (Body.isInvalid())
8549 return StmtError();
8550
8551 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8552
8553 if (!getDerived().AlwaysRebuild() &&
8554 Init.get() == S->getInit() &&
8555 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8556 Inc.get() == S->getInc() &&
8557 Body.get() == S->getBody())
8558 return S;
8559
8560 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8561 Init.get(), Cond, FullInc,
8562 S->getRParenLoc(), Body.get());
8563}
8564
8565template<typename Derived>
8568 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8569 S->getLabel());
8570 if (!LD)
8571 return StmtError();
8572
8573 // Goto statements must always be rebuilt, to resolve the label.
8574 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8575 cast<LabelDecl>(LD));
8576}
8577
8578template<typename Derived>
8581 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8582 if (Target.isInvalid())
8583 return StmtError();
8584 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8585
8586 if (!getDerived().AlwaysRebuild() &&
8587 Target.get() == S->getTarget())
8588 return S;
8589
8590 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8591 Target.get());
8592}
8593
8594template<typename Derived>
8597 if (!S->hasLabelTarget())
8598 return S;
8599
8600 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8601 S->getLabelDecl());
8602 if (!LD)
8603 return StmtError();
8604
8605 return new (SemaRef.Context)
8606 ContinueStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8607}
8608
8609template<typename Derived>
8612 if (!S->hasLabelTarget())
8613 return S;
8614
8615 Decl *LD = getDerived().TransformDecl(S->getLabelDecl()->getLocation(),
8616 S->getLabelDecl());
8617 if (!LD)
8618 return StmtError();
8619
8620 return new (SemaRef.Context)
8621 BreakStmt(S->getKwLoc(), S->getLabelLoc(), cast<LabelDecl>(LD));
8622}
8623
8624template <typename Derived>
8626 StmtResult Result = getDerived().TransformStmt(S->getBody());
8627 if (!Result.isUsable())
8628 return StmtError();
8629 return DeferStmt::Create(getSema().Context, S->getDeferLoc(), Result.get());
8630}
8631
8632template<typename Derived>
8635 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8636 /*NotCopyInit*/false);
8637 if (Result.isInvalid())
8638 return StmtError();
8639
8640 // FIXME: We always rebuild the return statement because there is no way
8641 // to tell whether the return type of the function has changed.
8642 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8643}
8644
8645template<typename Derived>
8648 bool DeclChanged = false;
8650 LambdaScopeInfo *LSI = getSema().getCurLambda();
8651 for (auto *D : S->decls()) {
8652 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8653 if (!Transformed)
8654 return StmtError();
8655
8656 if (Transformed != D)
8657 DeclChanged = true;
8658
8659 if (LSI) {
8660 if (auto *TD = dyn_cast<TypeDecl>(Transformed)) {
8661 if (auto *TN = dyn_cast<TypedefNameDecl>(TD)) {
8662 LSI->ContainsUnexpandedParameterPack |=
8663 TN->getUnderlyingType()->containsUnexpandedParameterPack();
8664 } else {
8665 LSI->ContainsUnexpandedParameterPack |=
8666 getSema()
8667 .getASTContext()
8668 .getTypeDeclType(TD)
8669 ->containsUnexpandedParameterPack();
8670 }
8671 }
8672 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8673 LSI->ContainsUnexpandedParameterPack |=
8674 VD->getType()->containsUnexpandedParameterPack();
8675 }
8676
8677 Decls.push_back(Transformed);
8678 }
8679
8680 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8681 return S;
8682
8683 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8684}
8685
8686template<typename Derived>
8689
8690 SmallVector<Expr*, 8> Constraints;
8693
8694 SmallVector<Expr*, 8> Clobbers;
8695
8696 bool ExprsChanged = false;
8697
8698 auto RebuildString = [&](Expr *E) {
8699 ExprResult Result = getDerived().TransformExpr(E);
8700 if (!Result.isUsable())
8701 return Result;
8702 if (Result.get() != E) {
8703 ExprsChanged = true;
8704 Result = SemaRef.ActOnGCCAsmStmtString(Result.get(), /*ForLabel=*/false);
8705 }
8706 return Result;
8707 };
8708
8709 // Go through the outputs.
8710 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8711 Names.push_back(S->getOutputIdentifier(I));
8712
8713 ExprResult Result = RebuildString(S->getOutputConstraintExpr(I));
8714 if (Result.isInvalid())
8715 return StmtError();
8716
8717 Constraints.push_back(Result.get());
8718
8719 // Transform the output expr.
8720 Expr *OutputExpr = S->getOutputExpr(I);
8721 Result = getDerived().TransformExpr(OutputExpr);
8722 if (Result.isInvalid())
8723 return StmtError();
8724
8725 ExprsChanged |= Result.get() != OutputExpr;
8726
8727 Exprs.push_back(Result.get());
8728 }
8729
8730 // Go through the inputs.
8731 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8732 Names.push_back(S->getInputIdentifier(I));
8733
8734 ExprResult Result = RebuildString(S->getInputConstraintExpr(I));
8735 if (Result.isInvalid())
8736 return StmtError();
8737
8738 Constraints.push_back(Result.get());
8739
8740 // Transform the input expr.
8741 Expr *InputExpr = S->getInputExpr(I);
8742 Result = getDerived().TransformExpr(InputExpr);
8743 if (Result.isInvalid())
8744 return StmtError();
8745
8746 ExprsChanged |= Result.get() != InputExpr;
8747
8748 Exprs.push_back(Result.get());
8749 }
8750
8751 // Go through the Labels.
8752 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8753 Names.push_back(S->getLabelIdentifier(I));
8754
8755 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8756 if (Result.isInvalid())
8757 return StmtError();
8758 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8759 Exprs.push_back(Result.get());
8760 }
8761
8762 // Go through the clobbers.
8763 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) {
8764 ExprResult Result = RebuildString(S->getClobberExpr(I));
8765 if (Result.isInvalid())
8766 return StmtError();
8767 Clobbers.push_back(Result.get());
8768 }
8769
8770 ExprResult AsmString = RebuildString(S->getAsmStringExpr());
8771 if (AsmString.isInvalid())
8772 return StmtError();
8773
8774 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8775 return S;
8776
8777 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8778 S->isVolatile(), S->getNumOutputs(),
8779 S->getNumInputs(), Names.data(),
8780 Constraints, Exprs, AsmString.get(),
8781 Clobbers, S->getNumLabels(),
8782 S->getRParenLoc());
8783}
8784
8785template<typename Derived>
8788 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8789
8790 bool HadError = false, HadChange = false;
8791
8792 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8793 SmallVector<Expr*, 8> TransformedExprs;
8794 TransformedExprs.reserve(SrcExprs.size());
8795 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8796 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8797 if (!Result.isUsable()) {
8798 HadError = true;
8799 } else {
8800 HadChange |= (Result.get() != SrcExprs[i]);
8801 TransformedExprs.push_back(Result.get());
8802 }
8803 }
8804
8805 if (HadError) return StmtError();
8806 if (!HadChange && !getDerived().AlwaysRebuild())
8807 return Owned(S);
8808
8809 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8810 AsmToks, S->getAsmString(),
8811 S->getNumOutputs(), S->getNumInputs(),
8812 S->getAllConstraints(), S->getClobbers(),
8813 TransformedExprs, S->getEndLoc());
8814}
8815
8816// C++ Coroutines
8817template<typename Derived>
8820 auto *ScopeInfo = SemaRef.getCurFunction();
8821 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8822 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8823 ScopeInfo->NeedsCoroutineSuspends &&
8824 ScopeInfo->CoroutineSuspends.first == nullptr &&
8825 ScopeInfo->CoroutineSuspends.second == nullptr &&
8826 "expected clean scope info");
8827
8828 // Set that we have (possibly-invalid) suspend points before we do anything
8829 // that may fail.
8830 ScopeInfo->setNeedsCoroutineSuspends(false);
8831
8832 // We re-build the coroutine promise object (and the coroutine parameters its
8833 // type and constructor depend on) based on the types used in our current
8834 // function. We must do so, and set it on the current FunctionScopeInfo,
8835 // before attempting to transform the other parts of the coroutine body
8836 // statement, such as the implicit suspend statements (because those
8837 // statements reference the FunctionScopeInfo::CoroutinePromise).
8838 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8839 return StmtError();
8840 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8841 if (!Promise)
8842 return StmtError();
8843 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8844 ScopeInfo->CoroutinePromise = Promise;
8845
8846 // Transform the implicit coroutine statements constructed using dependent
8847 // types during the previous parse: initial and final suspensions, the return
8848 // object, and others. We also transform the coroutine function's body.
8849 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8850 if (InitSuspend.isInvalid())
8851 return StmtError();
8852 StmtResult FinalSuspend =
8853 getDerived().TransformStmt(S->getFinalSuspendStmt());
8854 if (FinalSuspend.isInvalid() ||
8855 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8856 return StmtError();
8857 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8858 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8859
8860 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8861 if (BodyRes.isInvalid())
8862 return StmtError();
8863
8864 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8865 if (Builder.isInvalid())
8866 return StmtError();
8867
8868 Expr *ReturnObject = S->getReturnValueInit();
8869 assert(ReturnObject && "the return object is expected to be valid");
8870 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8871 /*NoCopyInit*/ false);
8872 if (Res.isInvalid())
8873 return StmtError();
8874 Builder.ReturnValue = Res.get();
8875
8876 // If during the previous parse the coroutine still had a dependent promise
8877 // statement, we may need to build some implicit coroutine statements
8878 // (such as exception and fallthrough handlers) for the first time.
8879 if (S->hasDependentPromiseType()) {
8880 // We can only build these statements, however, if the current promise type
8881 // is not dependent.
8882 if (!Promise->getType()->isDependentType()) {
8883 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8884 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8885 "these nodes should not have been built yet");
8886 if (!Builder.buildDependentStatements())
8887 return StmtError();
8888 }
8889 } else {
8890 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8891 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8892 if (Res.isInvalid())
8893 return StmtError();
8894 Builder.OnFallthrough = Res.get();
8895 }
8896
8897 if (auto *OnException = S->getExceptionHandler()) {
8898 StmtResult Res = getDerived().TransformStmt(OnException);
8899 if (Res.isInvalid())
8900 return StmtError();
8901 Builder.OnException = Res.get();
8902 }
8903
8904 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8905 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8906 if (Res.isInvalid())
8907 return StmtError();
8908 Builder.ReturnStmtOnAllocFailure = Res.get();
8909 }
8910
8911 // Transform any additional statements we may have already built
8912 assert(S->getAllocate() && S->getDeallocate() &&
8913 "allocation and deallocation calls must already be built");
8914 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8915 if (AllocRes.isInvalid())
8916 return StmtError();
8917 Builder.Allocate = AllocRes.get();
8918
8919 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8920 if (DeallocRes.isInvalid())
8921 return StmtError();
8922 Builder.Deallocate = DeallocRes.get();
8923
8924 if (auto *ResultDecl = S->getResultDecl()) {
8925 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8926 if (Res.isInvalid())
8927 return StmtError();
8928 Builder.ResultDecl = Res.get();
8929 }
8930
8931 if (auto *ReturnStmt = S->getReturnStmt()) {
8932 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8933 if (Res.isInvalid())
8934 return StmtError();
8935 Builder.ReturnStmt = Res.get();
8936 }
8937 }
8938
8939 return getDerived().RebuildCoroutineBodyStmt(Builder);
8940}
8941
8942template<typename Derived>
8945 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8946 /*NotCopyInit*/false);
8947 if (Result.isInvalid())
8948 return StmtError();
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().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8953 S->isImplicit());
8954}
8955
8956template <typename Derived>
8958 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8959 /*NotCopyInit*/ false);
8960 if (Operand.isInvalid())
8961 return ExprError();
8962
8963 // Rebuild the common-expr from the operand rather than transforming it
8964 // separately.
8965
8966 // FIXME: getCurScope() should not be used during template instantiation.
8967 // We should pick up the set of unqualified lookup results for operator
8968 // co_await during the initial parse.
8969 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8970 getSema().getCurScope(), E->getKeywordLoc());
8971
8972 // Always rebuild; we don't know if this needs to be injected into a new
8973 // context or if the promise type has changed.
8974 return getDerived().RebuildCoawaitExpr(
8975 E->getKeywordLoc(), Operand.get(),
8976 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8977}
8978
8979template <typename Derived>
8982 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8983 /*NotCopyInit*/ false);
8984 if (OperandResult.isInvalid())
8985 return ExprError();
8986
8987 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8988 E->getOperatorCoawaitLookup());
8989
8990 if (LookupResult.isInvalid())
8991 return ExprError();
8992
8993 // Always rebuild; we don't know if this needs to be injected into a new
8994 // context or if the promise type has changed.
8995 return getDerived().RebuildDependentCoawaitExpr(
8996 E->getKeywordLoc(), OperandResult.get(),
8998}
8999
9000template<typename Derived>
9003 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
9004 /*NotCopyInit*/false);
9005 if (Result.isInvalid())
9006 return ExprError();
9007
9008 // Always rebuild; we don't know if this needs to be injected into a new
9009 // context or if the promise type has changed.
9010 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
9011}
9012
9013// Objective-C Statements.
9014
9015template<typename Derived>
9018 // Transform the body of the @try.
9019 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
9020 if (TryBody.isInvalid())
9021 return StmtError();
9022
9023 // Transform the @catch statements (if present).
9024 bool AnyCatchChanged = false;
9025 SmallVector<Stmt*, 8> CatchStmts;
9026 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
9027 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
9028 if (Catch.isInvalid())
9029 return StmtError();
9030 if (Catch.get() != S->getCatchStmt(I))
9031 AnyCatchChanged = true;
9032 CatchStmts.push_back(Catch.get());
9033 }
9034
9035 // Transform the @finally statement (if present).
9036 StmtResult Finally;
9037 if (S->getFinallyStmt()) {
9038 Finally = getDerived().TransformStmt(S->getFinallyStmt());
9039 if (Finally.isInvalid())
9040 return StmtError();
9041 }
9042
9043 // If nothing changed, just retain this statement.
9044 if (!getDerived().AlwaysRebuild() &&
9045 TryBody.get() == S->getTryBody() &&
9046 !AnyCatchChanged &&
9047 Finally.get() == S->getFinallyStmt())
9048 return S;
9049
9050 // Build a new statement.
9051 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
9052 CatchStmts, Finally.get());
9053}
9054
9055template<typename Derived>
9058 // Transform the @catch parameter, if there is one.
9059 VarDecl *Var = nullptr;
9060 if (VarDecl *FromVar = S->getCatchParamDecl()) {
9061 TypeSourceInfo *TSInfo = nullptr;
9062 if (FromVar->getTypeSourceInfo()) {
9063 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
9064 if (!TSInfo)
9065 return StmtError();
9066 }
9067
9068 QualType T;
9069 if (TSInfo)
9070 T = TSInfo->getType();
9071 else {
9072 T = getDerived().TransformType(FromVar->getType());
9073 if (T.isNull())
9074 return StmtError();
9075 }
9076
9077 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
9078 if (!Var)
9079 return StmtError();
9080 }
9081
9082 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
9083 if (Body.isInvalid())
9084 return StmtError();
9085
9086 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
9087 S->getRParenLoc(),
9088 Var, Body.get());
9089}
9090
9091template<typename Derived>
9094 // Transform the body.
9095 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
9096 if (Body.isInvalid())
9097 return StmtError();
9098
9099 // If nothing changed, just retain this statement.
9100 if (!getDerived().AlwaysRebuild() &&
9101 Body.get() == S->getFinallyBody())
9102 return S;
9103
9104 // Build a new statement.
9105 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
9106 Body.get());
9107}
9108
9109template<typename Derived>
9113 if (S->getThrowExpr()) {
9114 Operand = getDerived().TransformExpr(S->getThrowExpr());
9115 if (Operand.isInvalid())
9116 return StmtError();
9117 }
9118
9119 if (!getDerived().AlwaysRebuild() &&
9120 Operand.get() == S->getThrowExpr())
9121 return S;
9122
9123 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
9124}
9125
9126template<typename Derived>
9130 // Transform the object we are locking.
9131 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
9132 if (Object.isInvalid())
9133 return StmtError();
9134 Object =
9135 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
9136 Object.get());
9137 if (Object.isInvalid())
9138 return StmtError();
9139
9140 // Transform the body.
9141 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
9142 if (Body.isInvalid())
9143 return StmtError();
9144
9145 // If nothing change, just retain the current statement.
9146 if (!getDerived().AlwaysRebuild() &&
9147 Object.get() == S->getSynchExpr() &&
9148 Body.get() == S->getSynchBody())
9149 return S;
9150
9151 // Build a new statement.
9152 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
9153 Object.get(), Body.get());
9154}
9155
9156template<typename Derived>
9160 // Transform the body.
9161 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
9162 if (Body.isInvalid())
9163 return StmtError();
9164
9165 // If nothing changed, just retain this statement.
9166 if (!getDerived().AlwaysRebuild() &&
9167 Body.get() == S->getSubStmt())
9168 return S;
9169
9170 // Build a new statement.
9171 return getDerived().RebuildObjCAutoreleasePoolStmt(
9172 S->getAtLoc(), Body.get());
9173}
9174
9175template<typename Derived>
9179 // Transform the element statement.
9180 StmtResult Element = getDerived().TransformStmt(
9181 S->getElement(), StmtDiscardKind::NotDiscarded);
9182 if (Element.isInvalid())
9183 return StmtError();
9184
9185 // Transform the collection expression.
9186 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9187 if (Collection.isInvalid())
9188 return StmtError();
9189
9190 // Transform the body.
9191 StmtResult Body = getDerived().TransformStmt(S->getBody());
9192 if (Body.isInvalid())
9193 return StmtError();
9194
9195 // If nothing changed, just retain this statement.
9196 if (!getDerived().AlwaysRebuild() &&
9197 Element.get() == S->getElement() &&
9198 Collection.get() == S->getCollection() &&
9199 Body.get() == S->getBody())
9200 return S;
9201
9202 // Build a new statement.
9203 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9204 Element.get(),
9205 Collection.get(),
9206 S->getRParenLoc(),
9207 Body.get());
9208}
9209
9210template <typename Derived>
9212 // Transform the exception declaration, if any.
9213 VarDecl *Var = nullptr;
9214 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9215 TypeSourceInfo *T =
9216 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9217 if (!T)
9218 return StmtError();
9219
9220 Var = getDerived().RebuildExceptionDecl(
9221 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9222 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9223 if (!Var || Var->isInvalidDecl())
9224 return StmtError();
9225 }
9226
9227 // Transform the actual exception handler.
9228 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9229 if (Handler.isInvalid())
9230 return StmtError();
9231
9232 if (!getDerived().AlwaysRebuild() && !Var &&
9233 Handler.get() == S->getHandlerBlock())
9234 return S;
9235
9236 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9237}
9238
9239template <typename Derived>
9241 // Transform the try block itself.
9242 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9243 if (TryBlock.isInvalid())
9244 return StmtError();
9245
9246 // Transform the handlers.
9247 bool HandlerChanged = false;
9248 SmallVector<Stmt *, 8> Handlers;
9249 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9250 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9251 if (Handler.isInvalid())
9252 return StmtError();
9253
9254 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9255 Handlers.push_back(Handler.getAs<Stmt>());
9256 }
9257
9258 getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
9259
9260 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9261 !HandlerChanged)
9262 return S;
9263
9264 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9265 Handlers);
9266}
9267
9268template<typename Derived>
9271 EnterExpressionEvaluationContext ForRangeInitContext(
9273 /*LambdaContextDecl=*/nullptr,
9275 getSema().getLangOpts().CPlusPlus23);
9276
9277 // P2718R0 - Lifetime extension in range-based for loops.
9278 if (getSema().getLangOpts().CPlusPlus23) {
9279 auto &LastRecord = getSema().currentEvaluationContext();
9280 LastRecord.InLifetimeExtendingContext = true;
9281 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9282 }
9284 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9285 if (Init.isInvalid())
9286 return StmtError();
9287
9288 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9289 if (Range.isInvalid())
9290 return StmtError();
9291
9292 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9293 assert(getSema().getLangOpts().CPlusPlus23 ||
9294 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9295 auto ForRangeLifetimeExtendTemps =
9296 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9297
9298 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9299 if (Begin.isInvalid())
9300 return StmtError();
9301 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9302 if (End.isInvalid())
9303 return StmtError();
9304
9305 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9306 if (Cond.isInvalid())
9307 return StmtError();
9308 if (Cond.get())
9309 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9310 if (Cond.isInvalid())
9311 return StmtError();
9312 if (Cond.get())
9313 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9314
9315 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9316 if (Inc.isInvalid())
9317 return StmtError();
9318 if (Inc.get())
9319 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9320
9321 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9322 if (LoopVar.isInvalid())
9323 return StmtError();
9324
9325 StmtResult NewStmt = S;
9326 if (getDerived().AlwaysRebuild() ||
9327 Init.get() != S->getInit() ||
9328 Range.get() != S->getRangeStmt() ||
9329 Begin.get() != S->getBeginStmt() ||
9330 End.get() != S->getEndStmt() ||
9331 Cond.get() != S->getCond() ||
9332 Inc.get() != S->getInc() ||
9333 LoopVar.get() != S->getLoopVarStmt()) {
9334 NewStmt = getDerived().RebuildCXXForRangeStmt(
9335 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9336 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9337 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9338 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9339 // Might not have attached any initializer to the loop variable.
9340 getSema().ActOnInitializerError(
9341 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9342 return StmtError();
9343 }
9344 }
9345
9346 // OpenACC Restricts a while-loop inside of certain construct/clause
9347 // combinations, so diagnose that here in OpenACC mode.
9349 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9350
9351 StmtResult Body = getDerived().TransformStmt(S->getBody());
9352 if (Body.isInvalid())
9353 return StmtError();
9354
9355 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9356
9357 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9358 // it now so we have a new statement to attach the body to.
9359 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9360 NewStmt = getDerived().RebuildCXXForRangeStmt(
9361 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9362 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9363 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9364 if (NewStmt.isInvalid())
9365 return StmtError();
9366 }
9367
9368 if (NewStmt.get() == S)
9369 return S;
9370
9371 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9372}
9373
9374template<typename Derived>
9378 // Transform the nested-name-specifier, if any.
9379 NestedNameSpecifierLoc QualifierLoc;
9380 if (S->getQualifierLoc()) {
9381 QualifierLoc
9382 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9383 if (!QualifierLoc)
9384 return StmtError();
9385 }
9386
9387 // Transform the declaration name.
9388 DeclarationNameInfo NameInfo = S->getNameInfo();
9389 if (NameInfo.getName()) {
9390 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9391 if (!NameInfo.getName())
9392 return StmtError();
9393 }
9394
9395 // Check whether anything changed.
9396 if (!getDerived().AlwaysRebuild() &&
9397 QualifierLoc == S->getQualifierLoc() &&
9398 NameInfo.getName() == S->getNameInfo().getName())
9399 return S;
9400
9401 // Determine whether this name exists, if we can.
9402 CXXScopeSpec SS;
9403 SS.Adopt(QualifierLoc);
9404 bool Dependent = false;
9405 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9407 if (S->isIfExists())
9408 break;
9409
9410 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9411
9413 if (S->isIfNotExists())
9414 break;
9415
9416 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9417
9419 Dependent = true;
9420 break;
9421
9423 return StmtError();
9424 }
9425
9426 // We need to continue with the instantiation, so do so now.
9427 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9428 if (SubStmt.isInvalid())
9429 return StmtError();
9430
9431 // If we have resolved the name, just transform to the substatement.
9432 if (!Dependent)
9433 return SubStmt;
9434
9435 // The name is still dependent, so build a dependent expression again.
9436 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9437 S->isIfExists(),
9438 QualifierLoc,
9439 NameInfo,
9440 SubStmt.get());
9441}
9442
9443template<typename Derived>
9446 NestedNameSpecifierLoc QualifierLoc;
9447 if (E->getQualifierLoc()) {
9448 QualifierLoc
9449 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9450 if (!QualifierLoc)
9451 return ExprError();
9452 }
9453
9454 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9455 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9456 if (!PD)
9457 return ExprError();
9458
9459 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9460 if (Base.isInvalid())
9461 return ExprError();
9462
9463 return new (SemaRef.getASTContext())
9464 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9466 QualifierLoc, E->getMemberLoc());
9467}
9468
9469template <typename Derived>
9472 auto BaseRes = getDerived().TransformExpr(E->getBase());
9473 if (BaseRes.isInvalid())
9474 return ExprError();
9475 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9476 if (IdxRes.isInvalid())
9477 return ExprError();
9478
9479 if (!getDerived().AlwaysRebuild() &&
9480 BaseRes.get() == E->getBase() &&
9481 IdxRes.get() == E->getIdx())
9482 return E;
9483
9484 return getDerived().RebuildArraySubscriptExpr(
9485 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9486}
9487
9488template <typename Derived>
9490 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9491 if (TryBlock.isInvalid())
9492 return StmtError();
9493
9494 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9495 if (Handler.isInvalid())
9496 return StmtError();
9497
9498 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9499 Handler.get() == S->getHandler())
9500 return S;
9501
9502 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9503 TryBlock.get(), Handler.get());
9504}
9505
9506template <typename Derived>
9508 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9509 if (Block.isInvalid())
9510 return StmtError();
9511
9512 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9513}
9514
9515template <typename Derived>
9517 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9518 if (FilterExpr.isInvalid())
9519 return StmtError();
9520
9521 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9522 if (Block.isInvalid())
9523 return StmtError();
9524
9525 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9526 Block.get());
9527}
9528
9529template <typename Derived>
9531 if (isa<SEHFinallyStmt>(Handler))
9532 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9533 else
9534 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9535}
9536
9537template<typename Derived>
9540 return S;
9541}
9542
9543//===----------------------------------------------------------------------===//
9544// OpenMP directive transformation
9545//===----------------------------------------------------------------------===//
9546
9547template <typename Derived>
9548StmtResult
9549TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9550 // OMPCanonicalLoops are eliminated during transformation, since they will be
9551 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9552 // after transformation.
9553 return getDerived().TransformStmt(L->getLoopStmt());
9554}
9555
9556template <typename Derived>
9559
9560 // Transform the clauses
9562 ArrayRef<OMPClause *> Clauses = D->clauses();
9563 TClauses.reserve(Clauses.size());
9564 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9565 I != E; ++I) {
9566 if (*I) {
9567 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9568 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9569 getDerived().getSema().OpenMP().EndOpenMPClause();
9570 if (Clause)
9571 TClauses.push_back(Clause);
9572 } else {
9573 TClauses.push_back(nullptr);
9574 }
9575 }
9576 StmtResult AssociatedStmt;
9577 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9578 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9579 D->getDirectiveKind(),
9580 /*CurScope=*/nullptr);
9581 StmtResult Body;
9582 {
9583 Sema::CompoundScopeRAII CompoundScope(getSema());
9584 Stmt *CS;
9585 if (D->getDirectiveKind() == OMPD_atomic ||
9586 D->getDirectiveKind() == OMPD_critical ||
9587 D->getDirectiveKind() == OMPD_section ||
9588 D->getDirectiveKind() == OMPD_master)
9589 CS = D->getAssociatedStmt();
9590 else
9591 CS = D->getRawStmt();
9592 Body = getDerived().TransformStmt(CS);
9593 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9594 getSema().getLangOpts().OpenMPIRBuilder)
9595 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9596 }
9597 AssociatedStmt =
9598 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9599 if (AssociatedStmt.isInvalid()) {
9600 return StmtError();
9601 }
9602 }
9603 if (TClauses.size() != Clauses.size()) {
9604 return StmtError();
9605 }
9606
9607 // Transform directive name for 'omp critical' directive.
9608 DeclarationNameInfo DirName;
9609 if (D->getDirectiveKind() == OMPD_critical) {
9610 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9611 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9612 }
9613 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9614 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9615 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9616 } else if (D->getDirectiveKind() == OMPD_cancel) {
9617 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9618 }
9619
9620 return getDerived().RebuildOMPExecutableDirective(
9621 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9622 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
9623}
9624
9625/// This is mostly the same as above, but allows 'informational' class
9626/// directives when rebuilding the stmt. It still takes an
9627/// OMPExecutableDirective-type argument because we're reusing that as the
9628/// superclass for the 'assume' directive at present, instead of defining a
9629/// mostly-identical OMPInformationalDirective parent class.
9630template <typename Derived>
9633
9634 // Transform the clauses
9636 ArrayRef<OMPClause *> Clauses = D->clauses();
9637 TClauses.reserve(Clauses.size());
9638 for (OMPClause *C : Clauses) {
9639 if (C) {
9640 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
9641 OMPClause *Clause = getDerived().TransformOMPClause(C);
9642 getDerived().getSema().OpenMP().EndOpenMPClause();
9643 if (Clause)
9644 TClauses.push_back(Clause);
9645 } else {
9646 TClauses.push_back(nullptr);
9647 }
9648 }
9649 StmtResult AssociatedStmt;
9650 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9651 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9652 D->getDirectiveKind(),
9653 /*CurScope=*/nullptr);
9654 StmtResult Body;
9655 {
9656 Sema::CompoundScopeRAII CompoundScope(getSema());
9657 assert(D->getDirectiveKind() == OMPD_assume &&
9658 "Unexpected informational directive");
9659 Stmt *CS = D->getAssociatedStmt();
9660 Body = getDerived().TransformStmt(CS);
9661 }
9662 AssociatedStmt =
9663 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9664 if (AssociatedStmt.isInvalid())
9665 return StmtError();
9666 }
9667 if (TClauses.size() != Clauses.size())
9668 return StmtError();
9669
9670 DeclarationNameInfo DirName;
9671
9672 return getDerived().RebuildOMPInformationalDirective(
9673 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
9674 D->getBeginLoc(), D->getEndLoc());
9675}
9676
9677template <typename Derived>
9680 // TODO: Fix This
9681 unsigned OMPVersion = getDerived().getSema().getLangOpts().OpenMP;
9682 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9683 << getOpenMPDirectiveName(D->getDirectiveKind(), OMPVersion);
9684 return StmtError();
9685}
9686
9687template <typename Derived>
9688StmtResult
9689TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9690 DeclarationNameInfo DirName;
9691 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9692 OMPD_parallel, 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 OMPD_simd, 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>
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>
9755 OMPInterchangeDirective *D) {
9756 DeclarationNameInfo DirName;
9757 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9758 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9759 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9760 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9761 return Res;
9762}
9763
9764template <typename Derived>
9767 DeclarationNameInfo DirName;
9768 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9769 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9770 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9771 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9772 return Res;
9773}
9774
9775template <typename Derived>
9778 DeclarationNameInfo DirName;
9779 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9780 OMPD_for, 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_for_simd, 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_sections, 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_section, 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_scope, DirName, nullptr, D->getBeginLoc());
9825 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9826 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9827 return Res;
9828}
9829
9830template <typename Derived>
9833 DeclarationNameInfo DirName;
9834 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9835 OMPD_single, DirName, nullptr, D->getBeginLoc());
9836 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9837 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9838 return Res;
9839}
9840
9841template <typename Derived>
9844 DeclarationNameInfo DirName;
9845 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9846 OMPD_master, DirName, nullptr, D->getBeginLoc());
9847 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9848 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9849 return Res;
9850}
9851
9852template <typename Derived>
9855 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9856 OMPD_critical, D->getDirectiveName(), 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 OMPParallelForDirective *D) {
9865 DeclarationNameInfo DirName;
9866 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9867 OMPD_parallel_for, 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 OMPParallelForSimdDirective *D) {
9876 DeclarationNameInfo DirName;
9877 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9878 OMPD_parallel_for_simd, 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 OMPParallelMasterDirective *D) {
9887 DeclarationNameInfo DirName;
9888 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9889 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
9890 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9891 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9892 return Res;
9893}
9894
9895template <typename Derived>
9897 OMPParallelMaskedDirective *D) {
9898 DeclarationNameInfo DirName;
9899 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9900 OMPD_parallel_masked, 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 OMPParallelSectionsDirective *D) {
9909 DeclarationNameInfo DirName;
9910 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9911 OMPD_parallel_sections, 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_task, DirName, nullptr, D->getBeginLoc());
9923 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9924 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9925 return Res;
9926}
9927
9928template <typename Derived>
9930 OMPTaskyieldDirective *D) {
9931 DeclarationNameInfo DirName;
9932 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9933 OMPD_taskyield, 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_barrier, DirName, nullptr, D->getBeginLoc());
9945 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9946 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9947 return Res;
9948}
9949
9950template <typename Derived>
9953 DeclarationNameInfo DirName;
9954 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9955 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
9956 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9957 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9958 return Res;
9959}
9960
9961template <typename Derived>
9964 DeclarationNameInfo DirName;
9965 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9966 OMPD_assume, DirName, nullptr, D->getBeginLoc());
9967 StmtResult Res = getDerived().TransformOMPInformationalDirective(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_error, 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>
9985 OMPTaskgroupDirective *D) {
9986 DeclarationNameInfo DirName;
9987 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9988 OMPD_taskgroup, 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_flush, 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_depobj, 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_scan, 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_ordered, DirName, nullptr, D->getBeginLoc());
10033 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10034 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10035 return Res;
10036}
10037
10038template <typename Derived>
10041 DeclarationNameInfo DirName;
10042 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10043 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
10044 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10045 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10046 return Res;
10047}
10048
10049template <typename Derived>
10052 DeclarationNameInfo DirName;
10053 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10054 OMPD_target, 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 OMPTargetDataDirective *D) {
10063 DeclarationNameInfo DirName;
10064 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10065 OMPD_target_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 OMPTargetEnterDataDirective *D) {
10074 DeclarationNameInfo DirName;
10075 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10076 OMPD_target_enter_data, 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 OMPTargetExitDataDirective *D) {
10085 DeclarationNameInfo DirName;
10086 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10087 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
10088 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10089 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10090 return Res;
10091}
10092
10093template <typename Derived>
10095 OMPTargetParallelDirective *D) {
10096 DeclarationNameInfo DirName;
10097 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10098 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
10099 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10100 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10101 return Res;
10102}
10103
10104template <typename Derived>
10106 OMPTargetParallelForDirective *D) {
10107 DeclarationNameInfo DirName;
10108 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10109 OMPD_target_parallel_for, 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 OMPTargetUpdateDirective *D) {
10118 DeclarationNameInfo DirName;
10119 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10120 OMPD_target_update, 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_teams, DirName, nullptr, D->getBeginLoc());
10132 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10133 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10134 return Res;
10135}
10136
10137template <typename Derived>
10139 OMPCancellationPointDirective *D) {
10140 DeclarationNameInfo DirName;
10141 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10142 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
10143 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10144 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10145 return Res;
10146}
10147
10148template <typename Derived>
10151 DeclarationNameInfo DirName;
10152 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10153 OMPD_cancel, 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>
10162 DeclarationNameInfo DirName;
10163 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10164 OMPD_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 OMPTaskLoopSimdDirective *D) {
10173 DeclarationNameInfo DirName;
10174 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10175 OMPD_taskloop_simd, 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 OMPMasterTaskLoopDirective *D) {
10184 DeclarationNameInfo DirName;
10185 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10186 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
10187 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10188 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10189 return Res;
10190}
10191
10192template <typename Derived>
10194 OMPMaskedTaskLoopDirective *D) {
10195 DeclarationNameInfo DirName;
10196 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10197 OMPD_masked_taskloop, 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 OMPMasterTaskLoopSimdDirective *D) {
10206 DeclarationNameInfo DirName;
10207 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10208 OMPD_master_taskloop_simd, 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 OMPMaskedTaskLoopSimdDirective *D) {
10217 DeclarationNameInfo DirName;
10218 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10219 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10220 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10221 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10222 return Res;
10223}
10224
10225template <typename Derived>
10227 OMPParallelMasterTaskLoopDirective *D) {
10228 DeclarationNameInfo DirName;
10229 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10230 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10231 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10232 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10233 return Res;
10234}
10235
10236template <typename Derived>
10238 OMPParallelMaskedTaskLoopDirective *D) {
10239 DeclarationNameInfo DirName;
10240 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10241 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10242 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10243 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10244 return Res;
10245}
10246
10247template <typename Derived>
10250 OMPParallelMasterTaskLoopSimdDirective *D) {
10251 DeclarationNameInfo DirName;
10252 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10253 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10254 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10255 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10256 return Res;
10257}
10258
10259template <typename Derived>
10262 OMPParallelMaskedTaskLoopSimdDirective *D) {
10263 DeclarationNameInfo DirName;
10264 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10265 OMPD_parallel_masked_taskloop_simd, 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>
10273 OMPDistributeDirective *D) {
10274 DeclarationNameInfo DirName;
10275 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10276 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10277 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10278 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10279 return Res;
10280}
10281
10282template <typename Derived>
10284 OMPDistributeParallelForDirective *D) {
10285 DeclarationNameInfo DirName;
10286 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10287 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10288 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10289 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10290 return Res;
10291}
10292
10293template <typename Derived>
10296 OMPDistributeParallelForSimdDirective *D) {
10297 DeclarationNameInfo DirName;
10298 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10299 OMPD_distribute_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 OMPDistributeSimdDirective *D) {
10308 DeclarationNameInfo DirName;
10309 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10310 OMPD_distribute_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 OMPTargetParallelForSimdDirective *D) {
10319 DeclarationNameInfo DirName;
10320 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10321 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10322 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10323 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10324 return Res;
10325}
10326
10327template <typename Derived>
10329 OMPTargetSimdDirective *D) {
10330 DeclarationNameInfo DirName;
10331 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10332 OMPD_target_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 OMPTeamsDistributeDirective *D) {
10341 DeclarationNameInfo DirName;
10342 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10343 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10344 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10345 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10346 return Res;
10347}
10348
10349template <typename Derived>
10351 OMPTeamsDistributeSimdDirective *D) {
10352 DeclarationNameInfo DirName;
10353 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10354 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10355 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10356 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10357 return Res;
10358}
10359
10360template <typename Derived>
10362 OMPTeamsDistributeParallelForSimdDirective *D) {
10363 DeclarationNameInfo DirName;
10364 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10365 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10366 D->getBeginLoc());
10367 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10368 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10369 return Res;
10370}
10371
10372template <typename Derived>
10374 OMPTeamsDistributeParallelForDirective *D) {
10375 DeclarationNameInfo DirName;
10376 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10377 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10378 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10379 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10380 return Res;
10381}
10382
10383template <typename Derived>
10385 OMPTargetTeamsDirective *D) {
10386 DeclarationNameInfo DirName;
10387 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10388 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10389 auto Res = getDerived().TransformOMPExecutableDirective(D);
10390 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10391 return Res;
10392}
10393
10394template <typename Derived>
10396 OMPTargetTeamsDistributeDirective *D) {
10397 DeclarationNameInfo DirName;
10398 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10399 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10400 auto Res = getDerived().TransformOMPExecutableDirective(D);
10401 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10402 return Res;
10403}
10404
10405template <typename Derived>
10408 OMPTargetTeamsDistributeParallelForDirective *D) {
10409 DeclarationNameInfo DirName;
10410 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10411 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10412 D->getBeginLoc());
10413 auto Res = getDerived().TransformOMPExecutableDirective(D);
10414 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10415 return Res;
10416}
10417
10418template <typename Derived>
10421 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10422 DeclarationNameInfo DirName;
10423 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10424 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10425 D->getBeginLoc());
10426 auto Res = getDerived().TransformOMPExecutableDirective(D);
10427 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10428 return Res;
10429}
10430
10431template <typename Derived>
10434 OMPTargetTeamsDistributeSimdDirective *D) {
10435 DeclarationNameInfo DirName;
10436 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10437 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10438 auto 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_interop, 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>
10457 DeclarationNameInfo DirName;
10458 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10459 OMPD_dispatch, 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>
10468 DeclarationNameInfo DirName;
10469 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10470 OMPD_masked, 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 OMPGenericLoopDirective *D) {
10479 DeclarationNameInfo DirName;
10480 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10481 OMPD_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 OMPTeamsGenericLoopDirective *D) {
10490 DeclarationNameInfo DirName;
10491 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10492 OMPD_teams_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>
10500 OMPTargetTeamsGenericLoopDirective *D) {
10501 DeclarationNameInfo DirName;
10502 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10503 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
10504 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10505 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10506 return Res;
10507}
10508
10509template <typename Derived>
10511 OMPParallelGenericLoopDirective *D) {
10512 DeclarationNameInfo DirName;
10513 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10514 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
10515 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10516 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10517 return Res;
10518}
10519
10520template <typename Derived>
10523 OMPTargetParallelGenericLoopDirective *D) {
10524 DeclarationNameInfo DirName;
10525 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10526 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10527 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10528 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10529 return Res;
10530}
10531
10532//===----------------------------------------------------------------------===//
10533// OpenMP clause transformation
10534//===----------------------------------------------------------------------===//
10535template <typename Derived>
10537 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10538 if (Cond.isInvalid())
10539 return nullptr;
10540 return getDerived().RebuildOMPIfClause(
10541 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10542 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10543}
10544
10545template <typename Derived>
10547 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10548 if (Cond.isInvalid())
10549 return nullptr;
10550 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10551 C->getLParenLoc(), C->getEndLoc());
10552}
10553
10554template <typename Derived>
10555OMPClause *
10557 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
10558 if (NumThreads.isInvalid())
10559 return nullptr;
10560 return getDerived().RebuildOMPNumThreadsClause(
10561 C->getModifier(), NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(),
10562 C->getModifierLoc(), C->getEndLoc());
10563}
10564
10565template <typename Derived>
10566OMPClause *
10568 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10569 if (E.isInvalid())
10570 return nullptr;
10571 return getDerived().RebuildOMPSafelenClause(
10572 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10573}
10574
10575template <typename Derived>
10576OMPClause *
10578 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10579 if (E.isInvalid())
10580 return nullptr;
10581 return getDerived().RebuildOMPAllocatorClause(
10582 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10583}
10584
10585template <typename Derived>
10586OMPClause *
10588 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
10589 if (E.isInvalid())
10590 return nullptr;
10591 return getDerived().RebuildOMPSimdlenClause(
10592 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10593}
10594
10595template <typename Derived>
10597 SmallVector<Expr *, 4> TransformedSizes;
10598 TransformedSizes.reserve(C->getNumSizes());
10599 bool Changed = false;
10600 for (Expr *E : C->getSizesRefs()) {
10601 if (!E) {
10602 TransformedSizes.push_back(nullptr);
10603 continue;
10604 }
10605
10606 ExprResult T = getDerived().TransformExpr(E);
10607 if (T.isInvalid())
10608 return nullptr;
10609 if (E != T.get())
10610 Changed = true;
10611 TransformedSizes.push_back(T.get());
10612 }
10613
10614 if (!Changed && !getDerived().AlwaysRebuild())
10615 return C;
10616 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
10617 C->getLParenLoc(), C->getEndLoc());
10618}
10619
10620template <typename Derived>
10621OMPClause *
10623 SmallVector<Expr *> TransformedArgs;
10624 TransformedArgs.reserve(C->getNumLoops());
10625 bool Changed = false;
10626 for (Expr *E : C->getArgsRefs()) {
10627 if (!E) {
10628 TransformedArgs.push_back(nullptr);
10629 continue;
10630 }
10631
10632 ExprResult T = getDerived().TransformExpr(E);
10633 if (T.isInvalid())
10634 return nullptr;
10635 if (E != T.get())
10636 Changed = true;
10637 TransformedArgs.push_back(T.get());
10638 }
10639
10640 if (!Changed && !getDerived().AlwaysRebuild())
10641 return C;
10642 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
10643 C->getLParenLoc(), C->getEndLoc());
10644}
10645
10646template <typename Derived>
10648 if (!getDerived().AlwaysRebuild())
10649 return C;
10650 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10651}
10652
10653template <typename Derived>
10654OMPClause *
10656 ExprResult T = getDerived().TransformExpr(C->getFactor());
10657 if (T.isInvalid())
10658 return nullptr;
10659 Expr *Factor = T.get();
10660 bool Changed = Factor != C->getFactor();
10661
10662 if (!Changed && !getDerived().AlwaysRebuild())
10663 return C;
10664 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10665 C->getEndLoc());
10666}
10667
10668template <typename Derived>
10669OMPClause *
10671 ExprResult F = getDerived().TransformExpr(C->getFirst());
10672 if (F.isInvalid())
10673 return nullptr;
10674
10675 ExprResult Cn = getDerived().TransformExpr(C->getCount());
10676 if (Cn.isInvalid())
10677 return nullptr;
10678
10679 Expr *First = F.get();
10680 Expr *Count = Cn.get();
10681
10682 bool Changed = (First != C->getFirst()) || (Count != C->getCount());
10683
10684 // If no changes and AlwaysRebuild() is false, return the original clause
10685 if (!Changed && !getDerived().AlwaysRebuild())
10686 return C;
10687
10688 return RebuildOMPLoopRangeClause(First, Count, C->getBeginLoc(),
10689 C->getLParenLoc(), C->getFirstLoc(),
10690 C->getCountLoc(), C->getEndLoc());
10691}
10692
10693template <typename Derived>
10694OMPClause *
10696 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10697 if (E.isInvalid())
10698 return nullptr;
10699 return getDerived().RebuildOMPCollapseClause(
10700 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10701}
10702
10703template <typename Derived>
10704OMPClause *
10706 return getDerived().RebuildOMPDefaultClause(
10707 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getDefaultVC(),
10708 C->getDefaultVCLoc(), C->getBeginLoc(), C->getLParenLoc(),
10709 C->getEndLoc());
10710}
10711
10712template <typename Derived>
10713OMPClause *
10715 // No need to rebuild this clause, no template-dependent parameters.
10716 return C;
10717}
10718
10719template <typename Derived>
10720OMPClause *
10722 Expr *Impex = C->getImpexType();
10723 ExprResult TransformedImpex = getDerived().TransformExpr(Impex);
10724
10725 if (TransformedImpex.isInvalid())
10726 return nullptr;
10727
10728 return getDerived().RebuildOMPTransparentClause(
10729 TransformedImpex.get(), C->getBeginLoc(), C->getLParenLoc(),
10730 C->getEndLoc());
10731}
10732
10733template <typename Derived>
10734OMPClause *
10736 return getDerived().RebuildOMPProcBindClause(
10737 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10738 C->getLParenLoc(), C->getEndLoc());
10739}
10740
10741template <typename Derived>
10742OMPClause *
10744 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10745 if (E.isInvalid())
10746 return nullptr;
10747 return getDerived().RebuildOMPScheduleClause(
10748 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10749 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10750 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10751 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10752}
10753
10754template <typename Derived>
10755OMPClause *
10757 ExprResult E;
10758 if (auto *Num = C->getNumForLoops()) {
10759 E = getDerived().TransformExpr(Num);
10760 if (E.isInvalid())
10761 return nullptr;
10762 }
10763 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10764 C->getLParenLoc(), E.get());
10765}
10766
10767template <typename Derived>
10768OMPClause *
10770 ExprResult E;
10771 if (Expr *Evt = C->getEventHandler()) {
10772 E = getDerived().TransformExpr(Evt);
10773 if (E.isInvalid())
10774 return nullptr;
10775 }
10776 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10777 C->getLParenLoc(), C->getEndLoc());
10778}
10779
10780template <typename Derived>
10781OMPClause *
10784 if (auto *Condition = C->getCondition()) {
10785 Cond = getDerived().TransformExpr(Condition);
10786 if (Cond.isInvalid())
10787 return nullptr;
10788 }
10789 return getDerived().RebuildOMPNowaitClause(Cond.get(), C->getBeginLoc(),
10790 C->getLParenLoc(), C->getEndLoc());
10791}
10792
10793template <typename Derived>
10794OMPClause *
10796 // No need to rebuild this clause, no template-dependent parameters.
10797 return C;
10798}
10799
10800template <typename Derived>
10801OMPClause *
10803 // No need to rebuild this clause, no template-dependent parameters.
10804 return C;
10805}
10806
10807template <typename Derived>
10809 // No need to rebuild this clause, no template-dependent parameters.
10810 return C;
10811}
10812
10813template <typename Derived>
10815 // No need to rebuild this clause, no template-dependent parameters.
10816 return C;
10817}
10818
10819template <typename Derived>
10820OMPClause *
10822 // No need to rebuild this clause, no template-dependent parameters.
10823 return C;
10824}
10825
10826template <typename Derived>
10827OMPClause *
10829 // No need to rebuild this clause, no template-dependent parameters.
10830 return C;
10831}
10832
10833template <typename Derived>
10834OMPClause *
10836 // No need to rebuild this clause, no template-dependent parameters.
10837 return C;
10838}
10839
10840template <typename Derived>
10842 // No need to rebuild this clause, no template-dependent parameters.
10843 return C;
10844}
10845
10846template <typename Derived>
10847OMPClause *
10849 return C;
10850}
10851
10852template <typename Derived>
10854 ExprResult E = getDerived().TransformExpr(C->getExpr());
10855 if (E.isInvalid())
10856 return nullptr;
10857 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
10858 C->getLParenLoc(), C->getEndLoc());
10859}
10860
10861template <typename Derived>
10862OMPClause *
10864 return C;
10865}
10866
10867template <typename Derived>
10868OMPClause *
10870 return C;
10871}
10872template <typename Derived>
10874 OMPNoOpenMPRoutinesClause *C) {
10875 return C;
10876}
10877template <typename Derived>
10879 OMPNoOpenMPConstructsClause *C) {
10880 return C;
10881}
10882template <typename Derived>
10884 OMPNoParallelismClause *C) {
10885 return C;
10886}
10887
10888template <typename Derived>
10889OMPClause *
10891 // No need to rebuild this clause, no template-dependent parameters.
10892 return C;
10893}
10894
10895template <typename Derived>
10896OMPClause *
10898 // No need to rebuild this clause, no template-dependent parameters.
10899 return C;
10900}
10901
10902template <typename Derived>
10903OMPClause *
10905 // No need to rebuild this clause, no template-dependent parameters.
10906 return C;
10907}
10908
10909template <typename Derived>
10910OMPClause *
10912 // No need to rebuild this clause, no template-dependent parameters.
10913 return C;
10914}
10915
10916template <typename Derived>
10917OMPClause *
10919 // No need to rebuild this clause, no template-dependent parameters.
10920 return C;
10921}
10922
10923template <typename Derived>
10925 // No need to rebuild this clause, no template-dependent parameters.
10926 return C;
10927}
10928
10929template <typename Derived>
10930OMPClause *
10932 // No need to rebuild this clause, no template-dependent parameters.
10933 return C;
10934}
10935
10936template <typename Derived>
10938 // No need to rebuild this clause, no template-dependent parameters.
10939 return C;
10940}
10941
10942template <typename Derived>
10943OMPClause *
10945 // No need to rebuild this clause, no template-dependent parameters.
10946 return C;
10947}
10948
10949template <typename Derived>
10951 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
10952 if (IVR.isInvalid())
10953 return nullptr;
10954
10955 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
10956 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
10957 for (Expr *E : llvm::drop_begin(C->varlist())) {
10958 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
10959 if (ER.isInvalid())
10960 return nullptr;
10961 InteropInfo.PreferTypes.push_back(ER.get());
10962 }
10963 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
10964 C->getBeginLoc(), C->getLParenLoc(),
10965 C->getVarLoc(), C->getEndLoc());
10966}
10967
10968template <typename Derived>
10970 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
10971 if (ER.isInvalid())
10972 return nullptr;
10973 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
10974 C->getLParenLoc(), C->getVarLoc(),
10975 C->getEndLoc());
10976}
10977
10978template <typename Derived>
10979OMPClause *
10981 ExprResult ER;
10982 if (Expr *IV = C->getInteropVar()) {
10983 ER = getDerived().TransformExpr(IV);
10984 if (ER.isInvalid())
10985 return nullptr;
10986 }
10987 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
10988 C->getLParenLoc(), C->getVarLoc(),
10989 C->getEndLoc());
10990}
10991
10992template <typename Derived>
10993OMPClause *
10995 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10996 if (Cond.isInvalid())
10997 return nullptr;
10998 return getDerived().RebuildOMPNovariantsClause(
10999 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11000}
11001
11002template <typename Derived>
11003OMPClause *
11005 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
11006 if (Cond.isInvalid())
11007 return nullptr;
11008 return getDerived().RebuildOMPNocontextClause(
11009 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11010}
11011
11012template <typename Derived>
11013OMPClause *
11015 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
11016 if (ThreadID.isInvalid())
11017 return nullptr;
11018 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
11019 C->getLParenLoc(), C->getEndLoc());
11020}
11021
11022template <typename Derived>
11024 ExprResult E = getDerived().TransformExpr(C->getAlignment());
11025 if (E.isInvalid())
11026 return nullptr;
11027 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
11028 C->getLParenLoc(), C->getEndLoc());
11029}
11030
11031template <typename Derived>
11033 OMPUnifiedAddressClause *C) {
11034 llvm_unreachable("unified_address clause cannot appear in dependent context");
11035}
11036
11037template <typename Derived>
11039 OMPUnifiedSharedMemoryClause *C) {
11040 llvm_unreachable(
11041 "unified_shared_memory clause cannot appear in dependent context");
11042}
11043
11044template <typename Derived>
11046 OMPReverseOffloadClause *C) {
11047 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
11048}
11049
11050template <typename Derived>
11052 OMPDynamicAllocatorsClause *C) {
11053 llvm_unreachable(
11054 "dynamic_allocators clause cannot appear in dependent context");
11055}
11056
11057template <typename Derived>
11059 OMPAtomicDefaultMemOrderClause *C) {
11060 llvm_unreachable(
11061 "atomic_default_mem_order clause cannot appear in dependent context");
11062}
11063
11064template <typename Derived>
11065OMPClause *
11067 llvm_unreachable("self_maps clause cannot appear in dependent context");
11068}
11069
11070template <typename Derived>
11072 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
11073 C->getBeginLoc(), C->getLParenLoc(),
11074 C->getEndLoc());
11075}
11076
11077template <typename Derived>
11078OMPClause *
11080 return getDerived().RebuildOMPSeverityClause(
11081 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
11082 C->getLParenLoc(), C->getEndLoc());
11083}
11084
11085template <typename Derived>
11086OMPClause *
11088 ExprResult E = getDerived().TransformExpr(C->getMessageString());
11089 if (E.isInvalid())
11090 return nullptr;
11091 return getDerived().RebuildOMPMessageClause(
11092 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11093}
11094
11095template <typename Derived>
11096OMPClause *
11099 Vars.reserve(C->varlist_size());
11100 for (auto *VE : C->varlist()) {
11101 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11102 if (EVar.isInvalid())
11103 return nullptr;
11104 Vars.push_back(EVar.get());
11105 }
11106 return getDerived().RebuildOMPPrivateClause(
11107 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11108}
11109
11110template <typename Derived>
11112 OMPFirstprivateClause *C) {
11114 Vars.reserve(C->varlist_size());
11115 for (auto *VE : C->varlist()) {
11116 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11117 if (EVar.isInvalid())
11118 return nullptr;
11119 Vars.push_back(EVar.get());
11120 }
11121 return getDerived().RebuildOMPFirstprivateClause(
11122 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11123}
11124
11125template <typename Derived>
11126OMPClause *
11129 Vars.reserve(C->varlist_size());
11130 for (auto *VE : C->varlist()) {
11131 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11132 if (EVar.isInvalid())
11133 return nullptr;
11134 Vars.push_back(EVar.get());
11135 }
11136 return getDerived().RebuildOMPLastprivateClause(
11137 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
11138 C->getLParenLoc(), C->getEndLoc());
11139}
11140
11141template <typename Derived>
11142OMPClause *
11145 Vars.reserve(C->varlist_size());
11146 for (auto *VE : C->varlist()) {
11147 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11148 if (EVar.isInvalid())
11149 return nullptr;
11150 Vars.push_back(EVar.get());
11151 }
11152 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
11153 C->getLParenLoc(), C->getEndLoc());
11154}
11155
11156template <typename Derived>
11157OMPClause *
11160 Vars.reserve(C->varlist_size());
11161 for (auto *VE : C->varlist()) {
11162 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11163 if (EVar.isInvalid())
11164 return nullptr;
11165 Vars.push_back(EVar.get());
11166 }
11167 CXXScopeSpec ReductionIdScopeSpec;
11168 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11169
11170 DeclarationNameInfo NameInfo = C->getNameInfo();
11171 if (NameInfo.getName()) {
11172 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11173 if (!NameInfo.getName())
11174 return nullptr;
11175 }
11176 // Build a list of all UDR decls with the same names ranged by the Scopes.
11177 // The Scope boundary is a duplication of the previous decl.
11178 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11179 for (auto *E : C->reduction_ops()) {
11180 // Transform all the decls.
11181 if (E) {
11182 auto *ULE = cast<UnresolvedLookupExpr>(E);
11183 UnresolvedSet<8> Decls;
11184 for (auto *D : ULE->decls()) {
11185 NamedDecl *InstD =
11186 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11187 Decls.addDecl(InstD, InstD->getAccess());
11188 }
11189 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11190 SemaRef.Context, /*NamingClass=*/nullptr,
11191 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11192 /*ADL=*/true, Decls.begin(), Decls.end(),
11193 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11194 } else
11195 UnresolvedReductions.push_back(nullptr);
11196 }
11197 return getDerived().RebuildOMPReductionClause(
11198 Vars, C->getModifier(), C->getOriginalSharingModifier(), C->getBeginLoc(),
11199 C->getLParenLoc(), C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
11200 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11201}
11202
11203template <typename Derived>
11205 OMPTaskReductionClause *C) {
11207 Vars.reserve(C->varlist_size());
11208 for (auto *VE : C->varlist()) {
11209 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11210 if (EVar.isInvalid())
11211 return nullptr;
11212 Vars.push_back(EVar.get());
11213 }
11214 CXXScopeSpec ReductionIdScopeSpec;
11215 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11216
11217 DeclarationNameInfo NameInfo = C->getNameInfo();
11218 if (NameInfo.getName()) {
11219 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11220 if (!NameInfo.getName())
11221 return nullptr;
11222 }
11223 // Build a list of all UDR decls with the same names ranged by the Scopes.
11224 // The Scope boundary is a duplication of the previous decl.
11225 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11226 for (auto *E : C->reduction_ops()) {
11227 // Transform all the decls.
11228 if (E) {
11229 auto *ULE = cast<UnresolvedLookupExpr>(E);
11230 UnresolvedSet<8> Decls;
11231 for (auto *D : ULE->decls()) {
11232 NamedDecl *InstD =
11233 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11234 Decls.addDecl(InstD, InstD->getAccess());
11235 }
11236 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11237 SemaRef.Context, /*NamingClass=*/nullptr,
11238 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11239 /*ADL=*/true, Decls.begin(), Decls.end(),
11240 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11241 } else
11242 UnresolvedReductions.push_back(nullptr);
11243 }
11244 return getDerived().RebuildOMPTaskReductionClause(
11245 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11246 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11247}
11248
11249template <typename Derived>
11250OMPClause *
11253 Vars.reserve(C->varlist_size());
11254 for (auto *VE : C->varlist()) {
11255 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11256 if (EVar.isInvalid())
11257 return nullptr;
11258 Vars.push_back(EVar.get());
11259 }
11260 CXXScopeSpec ReductionIdScopeSpec;
11261 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11262
11263 DeclarationNameInfo NameInfo = C->getNameInfo();
11264 if (NameInfo.getName()) {
11265 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11266 if (!NameInfo.getName())
11267 return nullptr;
11268 }
11269 // Build a list of all UDR decls with the same names ranged by the Scopes.
11270 // The Scope boundary is a duplication of the previous decl.
11271 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11272 for (auto *E : C->reduction_ops()) {
11273 // Transform all the decls.
11274 if (E) {
11275 auto *ULE = cast<UnresolvedLookupExpr>(E);
11276 UnresolvedSet<8> Decls;
11277 for (auto *D : ULE->decls()) {
11278 NamedDecl *InstD =
11279 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11280 Decls.addDecl(InstD, InstD->getAccess());
11281 }
11282 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11283 SemaRef.Context, /*NamingClass=*/nullptr,
11284 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11285 /*ADL=*/true, Decls.begin(), Decls.end(),
11286 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11287 } else
11288 UnresolvedReductions.push_back(nullptr);
11289 }
11290 return getDerived().RebuildOMPInReductionClause(
11291 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11292 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11293}
11294
11295template <typename Derived>
11296OMPClause *
11299 Vars.reserve(C->varlist_size());
11300 for (auto *VE : C->varlist()) {
11301 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11302 if (EVar.isInvalid())
11303 return nullptr;
11304 Vars.push_back(EVar.get());
11305 }
11306 ExprResult Step = getDerived().TransformExpr(C->getStep());
11307 if (Step.isInvalid())
11308 return nullptr;
11309 return getDerived().RebuildOMPLinearClause(
11310 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11311 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11312 C->getEndLoc());
11313}
11314
11315template <typename Derived>
11316OMPClause *
11319 Vars.reserve(C->varlist_size());
11320 for (auto *VE : C->varlist()) {
11321 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11322 if (EVar.isInvalid())
11323 return nullptr;
11324 Vars.push_back(EVar.get());
11325 }
11326 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11327 if (Alignment.isInvalid())
11328 return nullptr;
11329 return getDerived().RebuildOMPAlignedClause(
11330 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11331 C->getColonLoc(), C->getEndLoc());
11332}
11333
11334template <typename Derived>
11335OMPClause *
11338 Vars.reserve(C->varlist_size());
11339 for (auto *VE : C->varlist()) {
11340 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11341 if (EVar.isInvalid())
11342 return nullptr;
11343 Vars.push_back(EVar.get());
11344 }
11345 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11346 C->getLParenLoc(), C->getEndLoc());
11347}
11348
11349template <typename Derived>
11350OMPClause *
11353 Vars.reserve(C->varlist_size());
11354 for (auto *VE : C->varlist()) {
11355 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11356 if (EVar.isInvalid())
11357 return nullptr;
11358 Vars.push_back(EVar.get());
11359 }
11360 return getDerived().RebuildOMPCopyprivateClause(
11361 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11362}
11363
11364template <typename Derived>
11367 Vars.reserve(C->varlist_size());
11368 for (auto *VE : C->varlist()) {
11369 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11370 if (EVar.isInvalid())
11371 return nullptr;
11372 Vars.push_back(EVar.get());
11373 }
11374 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11375 C->getLParenLoc(), C->getEndLoc());
11376}
11377
11378template <typename Derived>
11379OMPClause *
11381 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11382 if (E.isInvalid())
11383 return nullptr;
11384 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11385 C->getLParenLoc(), C->getEndLoc());
11386}
11387
11388template <typename Derived>
11389OMPClause *
11392 Expr *DepModifier = C->getModifier();
11393 if (DepModifier) {
11394 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11395 if (DepModRes.isInvalid())
11396 return nullptr;
11397 DepModifier = DepModRes.get();
11398 }
11399 Vars.reserve(C->varlist_size());
11400 for (auto *VE : C->varlist()) {
11401 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11402 if (EVar.isInvalid())
11403 return nullptr;
11404 Vars.push_back(EVar.get());
11405 }
11406 return getDerived().RebuildOMPDependClause(
11407 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11408 C->getOmpAllMemoryLoc()},
11409 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11410}
11411
11412template <typename Derived>
11413OMPClause *
11415 ExprResult E = getDerived().TransformExpr(C->getDevice());
11416 if (E.isInvalid())
11417 return nullptr;
11418 return getDerived().RebuildOMPDeviceClause(
11419 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11420 C->getModifierLoc(), C->getEndLoc());
11421}
11422
11423template <typename Derived, class T>
11426 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11427 DeclarationNameInfo &MapperIdInfo,
11428 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11429 // Transform expressions in the list.
11430 Vars.reserve(C->varlist_size());
11431 for (auto *VE : C->varlist()) {
11432 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11433 if (EVar.isInvalid())
11434 return true;
11435 Vars.push_back(EVar.get());
11436 }
11437 // Transform mapper scope specifier and identifier.
11438 NestedNameSpecifierLoc QualifierLoc;
11439 if (C->getMapperQualifierLoc()) {
11440 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11441 C->getMapperQualifierLoc());
11442 if (!QualifierLoc)
11443 return true;
11444 }
11445 MapperIdScopeSpec.Adopt(QualifierLoc);
11446 MapperIdInfo = C->getMapperIdInfo();
11447 if (MapperIdInfo.getName()) {
11448 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11449 if (!MapperIdInfo.getName())
11450 return true;
11451 }
11452 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11453 // the previous user-defined mapper lookup in dependent environment.
11454 for (auto *E : C->mapperlists()) {
11455 // Transform all the decls.
11456 if (E) {
11457 auto *ULE = cast<UnresolvedLookupExpr>(E);
11458 UnresolvedSet<8> Decls;
11459 for (auto *D : ULE->decls()) {
11460 NamedDecl *InstD =
11461 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11462 Decls.addDecl(InstD, InstD->getAccess());
11463 }
11464 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11465 TT.getSema().Context, /*NamingClass=*/nullptr,
11466 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11467 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11468 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11469 } else {
11470 UnresolvedMappers.push_back(nullptr);
11471 }
11472 }
11473 return false;
11474}
11475
11476template <typename Derived>
11477OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11478 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11480 Expr *IteratorModifier = C->getIteratorModifier();
11481 if (IteratorModifier) {
11482 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11483 if (MapModRes.isInvalid())
11484 return nullptr;
11485 IteratorModifier = MapModRes.get();
11486 }
11487 CXXScopeSpec MapperIdScopeSpec;
11488 DeclarationNameInfo MapperIdInfo;
11489 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11491 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11492 return nullptr;
11493 return getDerived().RebuildOMPMapClause(
11494 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11495 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11496 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11497}
11498
11499template <typename Derived>
11500OMPClause *
11502 Expr *Allocator = C->getAllocator();
11503 if (Allocator) {
11504 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11505 if (AllocatorRes.isInvalid())
11506 return nullptr;
11507 Allocator = AllocatorRes.get();
11508 }
11509 Expr *Alignment = C->getAlignment();
11510 if (Alignment) {
11511 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11512 if (AlignmentRes.isInvalid())
11513 return nullptr;
11514 Alignment = AlignmentRes.get();
11515 }
11517 Vars.reserve(C->varlist_size());
11518 for (auto *VE : C->varlist()) {
11519 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11520 if (EVar.isInvalid())
11521 return nullptr;
11522 Vars.push_back(EVar.get());
11523 }
11524 return getDerived().RebuildOMPAllocateClause(
11525 Allocator, Alignment, C->getFirstAllocateModifier(),
11526 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11527 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11528 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11529}
11530
11531template <typename Derived>
11532OMPClause *
11535 Vars.reserve(C->varlist_size());
11536 for (auto *VE : C->varlist()) {
11537 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11538 if (EVar.isInvalid())
11539 return nullptr;
11540 Vars.push_back(EVar.get());
11541 }
11542 return getDerived().RebuildOMPNumTeamsClause(
11543 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11544}
11545
11546template <typename Derived>
11547OMPClause *
11550 Vars.reserve(C->varlist_size());
11551 for (auto *VE : C->varlist()) {
11552 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11553 if (EVar.isInvalid())
11554 return nullptr;
11555 Vars.push_back(EVar.get());
11556 }
11557 return getDerived().RebuildOMPThreadLimitClause(
11558 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11559}
11560
11561template <typename Derived>
11562OMPClause *
11564 ExprResult E = getDerived().TransformExpr(C->getPriority());
11565 if (E.isInvalid())
11566 return nullptr;
11567 return getDerived().RebuildOMPPriorityClause(
11568 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11569}
11570
11571template <typename Derived>
11572OMPClause *
11574 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11575 if (E.isInvalid())
11576 return nullptr;
11577 return getDerived().RebuildOMPGrainsizeClause(
11578 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11579 C->getModifierLoc(), C->getEndLoc());
11580}
11581
11582template <typename Derived>
11583OMPClause *
11585 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11586 if (E.isInvalid())
11587 return nullptr;
11588 return getDerived().RebuildOMPNumTasksClause(
11589 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11590 C->getModifierLoc(), C->getEndLoc());
11591}
11592
11593template <typename Derived>
11595 ExprResult E = getDerived().TransformExpr(C->getHint());
11596 if (E.isInvalid())
11597 return nullptr;
11598 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11599 C->getLParenLoc(), C->getEndLoc());
11600}
11601
11602template <typename Derived>
11604 OMPDistScheduleClause *C) {
11605 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11606 if (E.isInvalid())
11607 return nullptr;
11608 return getDerived().RebuildOMPDistScheduleClause(
11609 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11610 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11611}
11612
11613template <typename Derived>
11614OMPClause *
11616 // Rebuild Defaultmap Clause since we need to invoke the checking of
11617 // defaultmap(none:variable-category) after template initialization.
11618 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11619 C->getDefaultmapKind(),
11620 C->getBeginLoc(),
11621 C->getLParenLoc(),
11622 C->getDefaultmapModifierLoc(),
11623 C->getDefaultmapKindLoc(),
11624 C->getEndLoc());
11625}
11626
11627template <typename Derived>
11629 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11631 Expr *IteratorModifier = C->getIteratorModifier();
11632 if (IteratorModifier) {
11633 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11634 if (MapModRes.isInvalid())
11635 return nullptr;
11636 IteratorModifier = MapModRes.get();
11637 }
11638 CXXScopeSpec MapperIdScopeSpec;
11639 DeclarationNameInfo MapperIdInfo;
11640 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11642 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11643 return nullptr;
11644 return getDerived().RebuildOMPToClause(
11645 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11646 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11647 UnresolvedMappers);
11648}
11649
11650template <typename Derived>
11652 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11654 Expr *IteratorModifier = C->getIteratorModifier();
11655 if (IteratorModifier) {
11656 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11657 if (MapModRes.isInvalid())
11658 return nullptr;
11659 IteratorModifier = MapModRes.get();
11660 }
11661 CXXScopeSpec MapperIdScopeSpec;
11662 DeclarationNameInfo MapperIdInfo;
11663 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11665 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11666 return nullptr;
11667 return getDerived().RebuildOMPFromClause(
11668 C->getMotionModifiers(), C->getMotionModifiersLoc(), IteratorModifier,
11669 MapperIdScopeSpec, MapperIdInfo, C->getColonLoc(), Vars, Locs,
11670 UnresolvedMappers);
11671}
11672
11673template <typename Derived>
11675 OMPUseDevicePtrClause *C) {
11677 Vars.reserve(C->varlist_size());
11678 for (auto *VE : C->varlist()) {
11679 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11680 if (EVar.isInvalid())
11681 return nullptr;
11682 Vars.push_back(EVar.get());
11683 }
11684 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11685 return getDerived().RebuildOMPUseDevicePtrClause(
11686 Vars, Locs, C->getFallbackModifier(), C->getFallbackModifierLoc());
11687}
11688
11689template <typename Derived>
11691 OMPUseDeviceAddrClause *C) {
11693 Vars.reserve(C->varlist_size());
11694 for (auto *VE : C->varlist()) {
11695 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11696 if (EVar.isInvalid())
11697 return nullptr;
11698 Vars.push_back(EVar.get());
11699 }
11700 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11701 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11702}
11703
11704template <typename Derived>
11705OMPClause *
11708 Vars.reserve(C->varlist_size());
11709 for (auto *VE : C->varlist()) {
11710 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11711 if (EVar.isInvalid())
11712 return nullptr;
11713 Vars.push_back(EVar.get());
11714 }
11715 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11716 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11717}
11718
11719template <typename Derived>
11721 OMPHasDeviceAddrClause *C) {
11723 Vars.reserve(C->varlist_size());
11724 for (auto *VE : C->varlist()) {
11725 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11726 if (EVar.isInvalid())
11727 return nullptr;
11728 Vars.push_back(EVar.get());
11729 }
11730 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11731 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11732}
11733
11734template <typename Derived>
11735OMPClause *
11738 Vars.reserve(C->varlist_size());
11739 for (auto *VE : C->varlist()) {
11740 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11741 if (EVar.isInvalid())
11742 return nullptr;
11743 Vars.push_back(EVar.get());
11744 }
11745 return getDerived().RebuildOMPNontemporalClause(
11746 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11747}
11748
11749template <typename Derived>
11750OMPClause *
11753 Vars.reserve(C->varlist_size());
11754 for (auto *VE : C->varlist()) {
11755 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11756 if (EVar.isInvalid())
11757 return nullptr;
11758 Vars.push_back(EVar.get());
11759 }
11760 return getDerived().RebuildOMPInclusiveClause(
11761 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11762}
11763
11764template <typename Derived>
11765OMPClause *
11768 Vars.reserve(C->varlist_size());
11769 for (auto *VE : C->varlist()) {
11770 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11771 if (EVar.isInvalid())
11772 return nullptr;
11773 Vars.push_back(EVar.get());
11774 }
11775 return getDerived().RebuildOMPExclusiveClause(
11776 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11777}
11778
11779template <typename Derived>
11781 OMPUsesAllocatorsClause *C) {
11783 Data.reserve(C->getNumberOfAllocators());
11784 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11785 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11786 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11787 if (Allocator.isInvalid())
11788 continue;
11789 ExprResult AllocatorTraits;
11790 if (Expr *AT = D.AllocatorTraits) {
11791 AllocatorTraits = getDerived().TransformExpr(AT);
11792 if (AllocatorTraits.isInvalid())
11793 continue;
11794 }
11795 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11796 NewD.Allocator = Allocator.get();
11797 NewD.AllocatorTraits = AllocatorTraits.get();
11798 NewD.LParenLoc = D.LParenLoc;
11799 NewD.RParenLoc = D.RParenLoc;
11800 }
11801 return getDerived().RebuildOMPUsesAllocatorsClause(
11802 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11803}
11804
11805template <typename Derived>
11806OMPClause *
11808 SmallVector<Expr *, 4> Locators;
11809 Locators.reserve(C->varlist_size());
11810 ExprResult ModifierRes;
11811 if (Expr *Modifier = C->getModifier()) {
11812 ModifierRes = getDerived().TransformExpr(Modifier);
11813 if (ModifierRes.isInvalid())
11814 return nullptr;
11815 }
11816 for (Expr *E : C->varlist()) {
11817 ExprResult Locator = getDerived().TransformExpr(E);
11818 if (Locator.isInvalid())
11819 continue;
11820 Locators.push_back(Locator.get());
11821 }
11822 return getDerived().RebuildOMPAffinityClause(
11823 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11824 ModifierRes.get(), Locators);
11825}
11826
11827template <typename Derived>
11829 return getDerived().RebuildOMPOrderClause(
11830 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11831 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11832}
11833
11834template <typename Derived>
11836 return getDerived().RebuildOMPBindClause(
11837 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11838 C->getLParenLoc(), C->getEndLoc());
11839}
11840
11841template <typename Derived>
11843 OMPXDynCGroupMemClause *C) {
11844 ExprResult Size = getDerived().TransformExpr(C->getSize());
11845 if (Size.isInvalid())
11846 return nullptr;
11847 return getDerived().RebuildOMPXDynCGroupMemClause(
11848 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11849}
11850
11851template <typename Derived>
11853 OMPDynGroupprivateClause *C) {
11854 ExprResult Size = getDerived().TransformExpr(C->getSize());
11855 if (Size.isInvalid())
11856 return nullptr;
11857 return getDerived().RebuildOMPDynGroupprivateClause(
11858 C->getDynGroupprivateModifier(), C->getDynGroupprivateFallbackModifier(),
11859 Size.get(), C->getBeginLoc(), C->getLParenLoc(),
11860 C->getDynGroupprivateModifierLoc(),
11861 C->getDynGroupprivateFallbackModifierLoc(), C->getEndLoc());
11862}
11863
11864template <typename Derived>
11865OMPClause *
11868 Vars.reserve(C->varlist_size());
11869 for (auto *VE : C->varlist()) {
11870 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11871 if (EVar.isInvalid())
11872 return nullptr;
11873 Vars.push_back(EVar.get());
11874 }
11875 return getDerived().RebuildOMPDoacrossClause(
11876 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11877 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11878}
11879
11880template <typename Derived>
11881OMPClause *
11884 for (auto *A : C->getAttrs())
11885 NewAttrs.push_back(getDerived().TransformAttr(A));
11886 return getDerived().RebuildOMPXAttributeClause(
11887 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11888}
11889
11890template <typename Derived>
11892 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11893}
11894
11895//===----------------------------------------------------------------------===//
11896// OpenACC transformation
11897//===----------------------------------------------------------------------===//
11898namespace {
11899template <typename Derived>
11900class OpenACCClauseTransform final
11901 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11902 TreeTransform<Derived> &Self;
11903 ArrayRef<const OpenACCClause *> ExistingClauses;
11904 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11905 OpenACCClause *NewClause = nullptr;
11906
11907 ExprResult VisitVar(Expr *VarRef) {
11908 ExprResult Res = Self.TransformExpr(VarRef);
11909
11910 if (!Res.isUsable())
11911 return Res;
11912
11913 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11914 ParsedClause.getClauseKind(),
11915 Res.get());
11916
11917 return Res;
11918 }
11919
11920 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11921 llvm::SmallVector<Expr *> InstantiatedVarList;
11922 for (Expr *CurVar : VarList) {
11923 ExprResult VarRef = VisitVar(CurVar);
11924
11925 if (VarRef.isUsable())
11926 InstantiatedVarList.push_back(VarRef.get());
11927 }
11928
11929 return InstantiatedVarList;
11930 }
11931
11932public:
11933 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11934 ArrayRef<const OpenACCClause *> ExistingClauses,
11935 SemaOpenACC::OpenACCParsedClause &PC)
11936 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
11937
11938 OpenACCClause *CreatedClause() const { return NewClause; }
11939
11940#define VISIT_CLAUSE(CLAUSE_NAME) \
11941 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11942#include "clang/Basic/OpenACCClauses.def"
11943};
11944
11945template <typename Derived>
11946void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11947 const OpenACCDefaultClause &C) {
11948 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
11949
11950 NewClause = OpenACCDefaultClause::Create(
11951 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
11952 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11953 ParsedClause.getEndLoc());
11954}
11955
11956template <typename Derived>
11957void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
11958 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11959 assert(Cond && "If constructed with invalid Condition");
11960 Sema::ConditionResult Res = Self.TransformCondition(
11961 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
11962
11963 if (Res.isInvalid() || !Res.get().second)
11964 return;
11965
11966 ParsedClause.setConditionDetails(Res.get().second);
11967
11968 NewClause = OpenACCIfClause::Create(
11969 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11970 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11971 ParsedClause.getEndLoc());
11972}
11973
11974template <typename Derived>
11975void OpenACCClauseTransform<Derived>::VisitSelfClause(
11976 const OpenACCSelfClause &C) {
11977
11978 // If this is an 'update' 'self' clause, this is actually a var list instead.
11979 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
11980 llvm::SmallVector<Expr *> InstantiatedVarList;
11981 for (Expr *CurVar : C.getVarList()) {
11982 ExprResult Res = Self.TransformExpr(CurVar);
11983
11984 if (!Res.isUsable())
11985 continue;
11986
11987 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
11988 ParsedClause.getClauseKind(),
11989 Res.get());
11990
11991 if (Res.isUsable())
11992 InstantiatedVarList.push_back(Res.get());
11993 }
11994
11995 ParsedClause.setVarListDetails(InstantiatedVarList,
11997
11998 NewClause = OpenACCSelfClause::Create(
11999 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12000 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12001 ParsedClause.getEndLoc());
12002 } else {
12003
12004 if (C.hasConditionExpr()) {
12005 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
12007 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
12009
12010 if (Res.isInvalid() || !Res.get().second)
12011 return;
12012
12013 ParsedClause.setConditionDetails(Res.get().second);
12014 }
12015
12016 NewClause = OpenACCSelfClause::Create(
12017 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12018 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
12019 ParsedClause.getEndLoc());
12020 }
12021}
12022
12023template <typename Derived>
12024void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
12025 const OpenACCNumGangsClause &C) {
12026 llvm::SmallVector<Expr *> InstantiatedIntExprs;
12027
12028 for (Expr *CurIntExpr : C.getIntExprs()) {
12029 ExprResult Res = Self.TransformExpr(CurIntExpr);
12030
12031 if (!Res.isUsable())
12032 return;
12033
12034 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12035 C.getClauseKind(),
12036 C.getBeginLoc(), Res.get());
12037 if (!Res.isUsable())
12038 return;
12039
12040 InstantiatedIntExprs.push_back(Res.get());
12041 }
12042
12043 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
12045 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12046 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12047 ParsedClause.getEndLoc());
12048}
12049
12050template <typename Derived>
12051void OpenACCClauseTransform<Derived>::VisitPrivateClause(
12052 const OpenACCPrivateClause &C) {
12053 llvm::SmallVector<Expr *> InstantiatedVarList;
12055
12056 for (const auto [RefExpr, InitRecipe] :
12057 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12058 ExprResult VarRef = VisitVar(RefExpr);
12059
12060 if (VarRef.isUsable()) {
12061 InstantiatedVarList.push_back(VarRef.get());
12062
12063 // We only have to create a new one if it is dependent, and Sema won't
12064 // make one of these unless the type is non-dependent.
12065 if (InitRecipe.isSet())
12066 InitRecipes.push_back(InitRecipe);
12067 else
12068 InitRecipes.push_back(
12069 Self.getSema().OpenACC().CreatePrivateInitRecipe(VarRef.get()));
12070 }
12071 }
12072 ParsedClause.setVarListDetails(InstantiatedVarList,
12074
12075 NewClause = OpenACCPrivateClause::Create(
12076 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12077 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12078 ParsedClause.getEndLoc());
12079}
12080
12081template <typename Derived>
12082void OpenACCClauseTransform<Derived>::VisitHostClause(
12083 const OpenACCHostClause &C) {
12084 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12086
12087 NewClause = OpenACCHostClause::Create(
12088 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12089 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12090 ParsedClause.getEndLoc());
12091}
12092
12093template <typename Derived>
12094void OpenACCClauseTransform<Derived>::VisitDeviceClause(
12095 const OpenACCDeviceClause &C) {
12096 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12098
12099 NewClause = OpenACCDeviceClause::Create(
12100 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12101 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12102 ParsedClause.getEndLoc());
12103}
12104
12105template <typename Derived>
12106void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
12108 llvm::SmallVector<Expr *> InstantiatedVarList;
12110
12111 for (const auto [RefExpr, InitRecipe] :
12112 llvm::zip(C.getVarList(), C.getInitRecipes())) {
12113 ExprResult VarRef = VisitVar(RefExpr);
12114
12115 if (VarRef.isUsable()) {
12116 InstantiatedVarList.push_back(VarRef.get());
12117
12118 // We only have to create a new one if it is dependent, and Sema won't
12119 // make one of these unless the type is non-dependent.
12120 if (InitRecipe.isSet())
12121 InitRecipes.push_back(InitRecipe);
12122 else
12123 InitRecipes.push_back(
12124 Self.getSema().OpenACC().CreateFirstPrivateInitRecipe(
12125 VarRef.get()));
12126 }
12127 }
12128 ParsedClause.setVarListDetails(InstantiatedVarList,
12130
12132 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12133 ParsedClause.getLParenLoc(), ParsedClause.getVarList(), InitRecipes,
12134 ParsedClause.getEndLoc());
12135}
12136
12137template <typename Derived>
12138void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
12139 const OpenACCNoCreateClause &C) {
12140 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12142
12144 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12145 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12146 ParsedClause.getEndLoc());
12147}
12148
12149template <typename Derived>
12150void OpenACCClauseTransform<Derived>::VisitPresentClause(
12151 const OpenACCPresentClause &C) {
12152 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12154
12155 NewClause = OpenACCPresentClause::Create(
12156 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12157 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12158 ParsedClause.getEndLoc());
12159}
12160
12161template <typename Derived>
12162void OpenACCClauseTransform<Derived>::VisitCopyClause(
12163 const OpenACCCopyClause &C) {
12164 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12165 C.getModifierList());
12166
12167 NewClause = OpenACCCopyClause::Create(
12168 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12169 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12170 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12171 ParsedClause.getEndLoc());
12172}
12173
12174template <typename Derived>
12175void OpenACCClauseTransform<Derived>::VisitLinkClause(
12176 const OpenACCLinkClause &C) {
12177 llvm_unreachable("link clause not valid unless a decl transform");
12178}
12179
12180template <typename Derived>
12181void OpenACCClauseTransform<Derived>::VisitDeviceResidentClause(
12183 llvm_unreachable("device_resident clause not valid unless a decl transform");
12184}
12185template <typename Derived>
12186void OpenACCClauseTransform<Derived>::VisitNoHostClause(
12187 const OpenACCNoHostClause &C) {
12188 llvm_unreachable("nohost clause not valid unless a decl transform");
12189}
12190template <typename Derived>
12191void OpenACCClauseTransform<Derived>::VisitBindClause(
12192 const OpenACCBindClause &C) {
12193 llvm_unreachable("bind clause not valid unless a decl transform");
12194}
12195
12196template <typename Derived>
12197void OpenACCClauseTransform<Derived>::VisitCopyInClause(
12198 const OpenACCCopyInClause &C) {
12199 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12200 C.getModifierList());
12201
12202 NewClause = OpenACCCopyInClause::Create(
12203 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12204 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12205 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12206 ParsedClause.getEndLoc());
12207}
12208
12209template <typename Derived>
12210void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
12211 const OpenACCCopyOutClause &C) {
12212 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12213 C.getModifierList());
12214
12215 NewClause = OpenACCCopyOutClause::Create(
12216 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12217 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12218 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12219 ParsedClause.getEndLoc());
12220}
12221
12222template <typename Derived>
12223void OpenACCClauseTransform<Derived>::VisitCreateClause(
12224 const OpenACCCreateClause &C) {
12225 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12226 C.getModifierList());
12227
12228 NewClause = OpenACCCreateClause::Create(
12229 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
12230 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12231 ParsedClause.getModifierList(), ParsedClause.getVarList(),
12232 ParsedClause.getEndLoc());
12233}
12234template <typename Derived>
12235void OpenACCClauseTransform<Derived>::VisitAttachClause(
12236 const OpenACCAttachClause &C) {
12237 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12238
12239 // Ensure each var is a pointer type.
12240 llvm::erase_if(VarList, [&](Expr *E) {
12241 return Self.getSema().OpenACC().CheckVarIsPointerType(
12243 });
12244
12245 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12246 NewClause = OpenACCAttachClause::Create(
12247 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12248 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12249 ParsedClause.getEndLoc());
12250}
12251
12252template <typename Derived>
12253void OpenACCClauseTransform<Derived>::VisitDetachClause(
12254 const OpenACCDetachClause &C) {
12255 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12256
12257 // Ensure each var is a pointer type.
12258 llvm::erase_if(VarList, [&](Expr *E) {
12259 return Self.getSema().OpenACC().CheckVarIsPointerType(
12261 });
12262
12263 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12264 NewClause = OpenACCDetachClause::Create(
12265 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12266 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12267 ParsedClause.getEndLoc());
12268}
12269
12270template <typename Derived>
12271void OpenACCClauseTransform<Derived>::VisitDeleteClause(
12272 const OpenACCDeleteClause &C) {
12273 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12275 NewClause = OpenACCDeleteClause::Create(
12276 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12277 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12278 ParsedClause.getEndLoc());
12279}
12280
12281template <typename Derived>
12282void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
12283 const OpenACCUseDeviceClause &C) {
12284 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
12287 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12288 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12289 ParsedClause.getEndLoc());
12290}
12291
12292template <typename Derived>
12293void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
12294 const OpenACCDevicePtrClause &C) {
12295 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
12296
12297 // Ensure each var is a pointer type.
12298 llvm::erase_if(VarList, [&](Expr *E) {
12299 return Self.getSema().OpenACC().CheckVarIsPointerType(
12301 });
12302
12303 ParsedClause.setVarListDetails(VarList, OpenACCModifierKind::Invalid);
12305 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12306 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
12307 ParsedClause.getEndLoc());
12308}
12309
12310template <typename Derived>
12311void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
12312 const OpenACCNumWorkersClause &C) {
12313 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12314 assert(IntExpr && "num_workers clause constructed with invalid int expr");
12315
12316 ExprResult Res = Self.TransformExpr(IntExpr);
12317 if (!Res.isUsable())
12318 return;
12319
12320 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12321 C.getClauseKind(),
12322 C.getBeginLoc(), Res.get());
12323 if (!Res.isUsable())
12324 return;
12325
12326 ParsedClause.setIntExprDetails(Res.get());
12328 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12329 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12330 ParsedClause.getEndLoc());
12331}
12332
12333template <typename Derived>
12334void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
12335 const OpenACCDeviceNumClause &C) {
12336 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12337 assert(IntExpr && "device_num clause constructed with invalid int expr");
12338
12339 ExprResult Res = Self.TransformExpr(IntExpr);
12340 if (!Res.isUsable())
12341 return;
12342
12343 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12344 C.getClauseKind(),
12345 C.getBeginLoc(), Res.get());
12346 if (!Res.isUsable())
12347 return;
12348
12349 ParsedClause.setIntExprDetails(Res.get());
12351 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12352 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12353 ParsedClause.getEndLoc());
12354}
12355
12356template <typename Derived>
12357void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12359 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12360 assert(IntExpr && "default_async clause constructed with invalid int expr");
12361
12362 ExprResult Res = Self.TransformExpr(IntExpr);
12363 if (!Res.isUsable())
12364 return;
12365
12366 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12367 C.getClauseKind(),
12368 C.getBeginLoc(), Res.get());
12369 if (!Res.isUsable())
12370 return;
12371
12372 ParsedClause.setIntExprDetails(Res.get());
12374 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12375 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12376 ParsedClause.getEndLoc());
12377}
12378
12379template <typename Derived>
12380void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12382 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12383 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12384
12385 ExprResult Res = Self.TransformExpr(IntExpr);
12386 if (!Res.isUsable())
12387 return;
12388
12389 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12390 C.getClauseKind(),
12391 C.getBeginLoc(), Res.get());
12392 if (!Res.isUsable())
12393 return;
12394
12395 ParsedClause.setIntExprDetails(Res.get());
12397 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12398 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12399 ParsedClause.getEndLoc());
12400}
12401
12402template <typename Derived>
12403void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12404 const OpenACCAsyncClause &C) {
12405 if (C.hasIntExpr()) {
12406 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12407 if (!Res.isUsable())
12408 return;
12409
12410 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12411 C.getClauseKind(),
12412 C.getBeginLoc(), Res.get());
12413 if (!Res.isUsable())
12414 return;
12415 ParsedClause.setIntExprDetails(Res.get());
12416 }
12417
12418 NewClause = OpenACCAsyncClause::Create(
12419 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12420 ParsedClause.getLParenLoc(),
12421 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12422 : nullptr,
12423 ParsedClause.getEndLoc());
12424}
12425
12426template <typename Derived>
12427void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12428 const OpenACCWorkerClause &C) {
12429 if (C.hasIntExpr()) {
12430 // restrictions on this expression are all "does it exist in certain
12431 // situations" that are not possible to be dependent, so the only check we
12432 // have is that it transforms, and is an int expression.
12433 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12434 if (!Res.isUsable())
12435 return;
12436
12437 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12438 C.getClauseKind(),
12439 C.getBeginLoc(), Res.get());
12440 if (!Res.isUsable())
12441 return;
12442 ParsedClause.setIntExprDetails(Res.get());
12443 }
12444
12445 NewClause = OpenACCWorkerClause::Create(
12446 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12447 ParsedClause.getLParenLoc(),
12448 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12449 : nullptr,
12450 ParsedClause.getEndLoc());
12451}
12452
12453template <typename Derived>
12454void OpenACCClauseTransform<Derived>::VisitVectorClause(
12455 const OpenACCVectorClause &C) {
12456 if (C.hasIntExpr()) {
12457 // restrictions on this expression are all "does it exist in certain
12458 // situations" that are not possible to be dependent, so the only check we
12459 // have is that it transforms, and is an int expression.
12460 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12461 if (!Res.isUsable())
12462 return;
12463
12464 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12465 C.getClauseKind(),
12466 C.getBeginLoc(), Res.get());
12467 if (!Res.isUsable())
12468 return;
12469 ParsedClause.setIntExprDetails(Res.get());
12470 }
12471
12472 NewClause = OpenACCVectorClause::Create(
12473 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12474 ParsedClause.getLParenLoc(),
12475 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12476 : nullptr,
12477 ParsedClause.getEndLoc());
12478}
12479
12480template <typename Derived>
12481void OpenACCClauseTransform<Derived>::VisitWaitClause(
12482 const OpenACCWaitClause &C) {
12483 if (C.hasExprs()) {
12484 Expr *DevNumExpr = nullptr;
12485 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12486
12487 // Instantiate devnum expr if it exists.
12488 if (C.getDevNumExpr()) {
12489 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12490 if (!Res.isUsable())
12491 return;
12492 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12493 C.getClauseKind(),
12494 C.getBeginLoc(), Res.get());
12495 if (!Res.isUsable())
12496 return;
12497
12498 DevNumExpr = Res.get();
12499 }
12500
12501 // Instantiate queue ids.
12502 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12503 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12504 if (!Res.isUsable())
12505 return;
12506 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12507 C.getClauseKind(),
12508 C.getBeginLoc(), Res.get());
12509 if (!Res.isUsable())
12510 return;
12511
12512 InstantiatedQueueIdExprs.push_back(Res.get());
12513 }
12514
12515 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12516 std::move(InstantiatedQueueIdExprs));
12517 }
12518
12519 NewClause = OpenACCWaitClause::Create(
12520 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12521 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12522 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12523 ParsedClause.getEndLoc());
12524}
12525
12526template <typename Derived>
12527void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12528 const OpenACCDeviceTypeClause &C) {
12529 // Nothing to transform here, just create a new version of 'C'.
12531 Self.getSema().getASTContext(), C.getClauseKind(),
12532 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12533 C.getArchitectures(), ParsedClause.getEndLoc());
12534}
12535
12536template <typename Derived>
12537void OpenACCClauseTransform<Derived>::VisitAutoClause(
12538 const OpenACCAutoClause &C) {
12539 // Nothing to do, so just create a new node.
12540 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12541 ParsedClause.getBeginLoc(),
12542 ParsedClause.getEndLoc());
12543}
12544
12545template <typename Derived>
12546void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12547 const OpenACCIndependentClause &C) {
12548 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12549 ParsedClause.getBeginLoc(),
12550 ParsedClause.getEndLoc());
12551}
12552
12553template <typename Derived>
12554void OpenACCClauseTransform<Derived>::VisitSeqClause(
12555 const OpenACCSeqClause &C) {
12556 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12557 ParsedClause.getBeginLoc(),
12558 ParsedClause.getEndLoc());
12559}
12560template <typename Derived>
12561void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12562 const OpenACCFinalizeClause &C) {
12563 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12564 ParsedClause.getBeginLoc(),
12565 ParsedClause.getEndLoc());
12566}
12567
12568template <typename Derived>
12569void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12570 const OpenACCIfPresentClause &C) {
12571 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12572 ParsedClause.getBeginLoc(),
12573 ParsedClause.getEndLoc());
12574}
12575
12576template <typename Derived>
12577void OpenACCClauseTransform<Derived>::VisitReductionClause(
12578 const OpenACCReductionClause &C) {
12579 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12580 SmallVector<Expr *> ValidVars;
12582
12583 for (const auto [Var, OrigRecipe] :
12584 llvm::zip(TransformedVars, C.getRecipes())) {
12585 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12586 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12587 if (Res.isUsable()) {
12588 ValidVars.push_back(Res.get());
12589
12590 if (OrigRecipe.isSet())
12591 Recipes.emplace_back(OrigRecipe.AllocaDecl, OrigRecipe.CombinerRecipes);
12592 else
12593 Recipes.push_back(Self.getSema().OpenACC().CreateReductionInitRecipe(
12594 C.getReductionOp(), Res.get()));
12595 }
12596 }
12597
12598 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12599 ExistingClauses, ParsedClause.getDirectiveKind(),
12600 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12601 C.getReductionOp(), ValidVars, Recipes, ParsedClause.getEndLoc());
12602}
12603
12604template <typename Derived>
12605void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12606 const OpenACCCollapseClause &C) {
12607 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12608 assert(LoopCount && "collapse clause constructed with invalid loop count");
12609
12610 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12611
12612 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12613 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12614 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12615
12616 NewLoopCount =
12617 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12618
12619 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12621 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12622 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12623 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12624}
12625
12626template <typename Derived>
12627void OpenACCClauseTransform<Derived>::VisitTileClause(
12628 const OpenACCTileClause &C) {
12629
12630 llvm::SmallVector<Expr *> TransformedExprs;
12631
12632 for (Expr *E : C.getSizeExprs()) {
12633 ExprResult NewSizeExpr = Self.TransformExpr(E);
12634
12635 if (!NewSizeExpr.isUsable())
12636 return;
12637
12638 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12639 OpenACCDirectiveKind::Invalid, ParsedClause.getClauseKind(),
12640 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12641
12642 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12643
12644 if (!NewSizeExpr.isUsable())
12645 return;
12646 TransformedExprs.push_back(NewSizeExpr.get());
12647 }
12648
12649 ParsedClause.setIntExprDetails(TransformedExprs);
12650 NewClause = OpenACCTileClause::Create(
12651 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12652 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12653 ParsedClause.getEndLoc());
12654}
12655template <typename Derived>
12656void OpenACCClauseTransform<Derived>::VisitGangClause(
12657 const OpenACCGangClause &C) {
12658 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12659 llvm::SmallVector<Expr *> TransformedIntExprs;
12660
12661 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12662 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12663 if (!ER.isUsable())
12664 continue;
12665
12666 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12667 ParsedClause.getDirectiveKind(),
12668 C.getExpr(I).first, ER.get());
12669 if (!ER.isUsable())
12670 continue;
12671 TransformedGangKinds.push_back(C.getExpr(I).first);
12672 TransformedIntExprs.push_back(ER.get());
12673 }
12674
12675 NewClause = Self.getSema().OpenACC().CheckGangClause(
12676 ParsedClause.getDirectiveKind(), ExistingClauses,
12677 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12678 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12679}
12680} // namespace
12681template <typename Derived>
12682OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12683 ArrayRef<const OpenACCClause *> ExistingClauses,
12684 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12685
12687 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12688 ParsedClause.setEndLoc(OldClause->getEndLoc());
12689
12690 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12691 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12692
12693 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12694 ParsedClause};
12695 Transform.Visit(OldClause);
12696
12697 return Transform.CreatedClause();
12698}
12699
12700template <typename Derived>
12702TreeTransform<Derived>::TransformOpenACCClauseList(
12704 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12705 for (const auto *Clause : OldClauses) {
12706 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12707 TransformedClauses, DirKind, Clause))
12708 TransformedClauses.push_back(TransformedClause);
12709 }
12710 return TransformedClauses;
12711}
12712
12713template <typename Derived>
12716 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12717
12718 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12719 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12720 C->clauses());
12721
12722 if (getSema().OpenACC().ActOnStartStmtDirective(
12723 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12724 return StmtError();
12725
12726 // Transform Structured Block.
12727 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12728 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12729 C->clauses(), TransformedClauses);
12730 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12731 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12732 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12733
12734 return getDerived().RebuildOpenACCComputeConstruct(
12735 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12736 C->getEndLoc(), TransformedClauses, StrBlock);
12737}
12738
12739template <typename Derived>
12742
12743 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12744
12745 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12746 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12747 C->clauses());
12748
12749 if (getSema().OpenACC().ActOnStartStmtDirective(
12750 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12751 return StmtError();
12752
12753 // Transform Loop.
12754 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12755 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12756 C->clauses(), TransformedClauses);
12757 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12758 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12759 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12760
12761 return getDerived().RebuildOpenACCLoopConstruct(
12762 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12763 TransformedClauses, Loop);
12764}
12765
12766template <typename Derived>
12768 OpenACCCombinedConstruct *C) {
12769 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12770
12771 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12772 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12773 C->clauses());
12774
12775 if (getSema().OpenACC().ActOnStartStmtDirective(
12776 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12777 return StmtError();
12778
12779 // Transform Loop.
12780 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12781 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12782 C->clauses(), TransformedClauses);
12783 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12784 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12785 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12786
12787 return getDerived().RebuildOpenACCCombinedConstruct(
12788 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12789 C->getEndLoc(), TransformedClauses, Loop);
12790}
12791
12792template <typename Derived>
12795 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12796
12797 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12798 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12799 C->clauses());
12800 if (getSema().OpenACC().ActOnStartStmtDirective(
12801 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12802 return StmtError();
12803
12804 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12805 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12806 C->clauses(), TransformedClauses);
12807 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12808 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12809 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12810
12811 return getDerived().RebuildOpenACCDataConstruct(
12812 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12813 TransformedClauses, StrBlock);
12814}
12815
12816template <typename Derived>
12818 OpenACCEnterDataConstruct *C) {
12819 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12820
12821 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12822 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12823 C->clauses());
12824 if (getSema().OpenACC().ActOnStartStmtDirective(
12825 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12826 return StmtError();
12827
12828 return getDerived().RebuildOpenACCEnterDataConstruct(
12829 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12830 TransformedClauses);
12831}
12832
12833template <typename Derived>
12835 OpenACCExitDataConstruct *C) {
12836 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12837
12838 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12839 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12840 C->clauses());
12841 if (getSema().OpenACC().ActOnStartStmtDirective(
12842 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12843 return StmtError();
12844
12845 return getDerived().RebuildOpenACCExitDataConstruct(
12846 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12847 TransformedClauses);
12848}
12849
12850template <typename Derived>
12852 OpenACCHostDataConstruct *C) {
12853 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12854
12855 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12856 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12857 C->clauses());
12858 if (getSema().OpenACC().ActOnStartStmtDirective(
12859 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12860 return StmtError();
12861
12862 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12863 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12864 C->clauses(), TransformedClauses);
12865 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12866 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12867 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12868
12869 return getDerived().RebuildOpenACCHostDataConstruct(
12870 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12871 TransformedClauses, StrBlock);
12872}
12873
12874template <typename Derived>
12877 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12878
12879 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12880 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12881 C->clauses());
12882 if (getSema().OpenACC().ActOnStartStmtDirective(
12883 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12884 return StmtError();
12885
12886 return getDerived().RebuildOpenACCInitConstruct(
12887 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12888 TransformedClauses);
12889}
12890
12891template <typename Derived>
12893 OpenACCShutdownConstruct *C) {
12894 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12895
12896 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12897 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12898 C->clauses());
12899 if (getSema().OpenACC().ActOnStartStmtDirective(
12900 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12901 return StmtError();
12902
12903 return getDerived().RebuildOpenACCShutdownConstruct(
12904 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12905 TransformedClauses);
12906}
12907template <typename Derived>
12910 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12911
12912 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12913 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12914 C->clauses());
12915 if (getSema().OpenACC().ActOnStartStmtDirective(
12916 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12917 return StmtError();
12918
12919 return getDerived().RebuildOpenACCSetConstruct(
12920 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12921 TransformedClauses);
12922}
12923
12924template <typename Derived>
12926 OpenACCUpdateConstruct *C) {
12927 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12928
12929 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12930 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12931 C->clauses());
12932 if (getSema().OpenACC().ActOnStartStmtDirective(
12933 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12934 return StmtError();
12935
12936 return getDerived().RebuildOpenACCUpdateConstruct(
12937 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12938 TransformedClauses);
12939}
12940
12941template <typename Derived>
12944 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12945
12946 ExprResult DevNumExpr;
12947 if (C->hasDevNumExpr()) {
12948 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
12949
12950 if (DevNumExpr.isUsable())
12951 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
12953 C->getBeginLoc(), DevNumExpr.get());
12954 }
12955
12956 llvm::SmallVector<Expr *> QueueIdExprs;
12957
12958 for (Expr *QE : C->getQueueIdExprs()) {
12959 assert(QE && "Null queue id expr?");
12960 ExprResult NewEQ = getDerived().TransformExpr(QE);
12961
12962 if (!NewEQ.isUsable())
12963 break;
12964 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
12966 C->getBeginLoc(), NewEQ.get());
12967 if (NewEQ.isUsable())
12968 QueueIdExprs.push_back(NewEQ.get());
12969 }
12970
12971 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12972 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12973 C->clauses());
12974
12975 if (getSema().OpenACC().ActOnStartStmtDirective(
12976 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12977 return StmtError();
12978
12979 return getDerived().RebuildOpenACCWaitConstruct(
12980 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12981 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
12982 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
12983}
12984template <typename Derived>
12986 OpenACCCacheConstruct *C) {
12987 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12988
12989 llvm::SmallVector<Expr *> TransformedVarList;
12990 for (Expr *Var : C->getVarList()) {
12991 assert(Var && "Null var listexpr?");
12992
12993 ExprResult NewVar = getDerived().TransformExpr(Var);
12994
12995 if (!NewVar.isUsable())
12996 break;
12997
12998 NewVar = getSema().OpenACC().ActOnVar(
12999 C->getDirectiveKind(), OpenACCClauseKind::Invalid, NewVar.get());
13000 if (!NewVar.isUsable())
13001 break;
13002
13003 TransformedVarList.push_back(NewVar.get());
13004 }
13005
13006 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13007 C->getBeginLoc(), {}))
13008 return StmtError();
13009
13010 return getDerived().RebuildOpenACCCacheConstruct(
13011 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
13012 C->getReadOnlyLoc(), TransformedVarList, C->getRParenLoc(),
13013 C->getEndLoc());
13014}
13015
13016template <typename Derived>
13018 OpenACCAtomicConstruct *C) {
13019 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
13020
13021 llvm::SmallVector<OpenACCClause *> TransformedClauses =
13022 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
13023 C->clauses());
13024
13025 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
13026 C->getBeginLoc(), {}))
13027 return StmtError();
13028
13029 // Transform Associated Stmt.
13030 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
13031 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
13032
13033 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
13034 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
13035 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
13036 AssocStmt);
13037
13038 return getDerived().RebuildOpenACCAtomicConstruct(
13039 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
13040 C->getEndLoc(), TransformedClauses, AssocStmt);
13041}
13042
13043template <typename Derived>
13046 if (getDerived().AlwaysRebuild())
13047 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
13048 // Nothing can ever change, so there is never anything to transform.
13049 return E;
13050}
13051
13052//===----------------------------------------------------------------------===//
13053// Expression transformation
13054//===----------------------------------------------------------------------===//
13055template<typename Derived>
13058 return TransformExpr(E->getSubExpr());
13059}
13060
13061template <typename Derived>
13064 if (!E->isTypeDependent())
13065 return E;
13066
13067 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
13068
13069 if (!NewT)
13070 return ExprError();
13071
13072 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
13073 return E;
13074
13075 return getDerived().RebuildSYCLUniqueStableNameExpr(
13076 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
13077}
13078
13079template <typename Derived>
13082 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
13083 const auto *SKEPAttr = FD->template getAttr<SYCLKernelEntryPointAttr>();
13084 if (!SKEPAttr || SKEPAttr->isInvalidAttr())
13085 return StmtError();
13086
13087 ExprResult IdExpr = getDerived().TransformExpr(S->getKernelLaunchIdExpr());
13088 if (IdExpr.isInvalid())
13089 return StmtError();
13090
13091 StmtResult Body = getDerived().TransformStmt(S->getOriginalStmt());
13092 if (Body.isInvalid())
13093 return StmtError();
13094
13096 cast<FunctionDecl>(SemaRef.CurContext), cast<CompoundStmt>(Body.get()),
13097 IdExpr.get());
13098 if (SR.isInvalid())
13099 return StmtError();
13100
13101 return SR;
13102}
13103
13104template <typename Derived>
13106 // TODO(reflection): Implement its transform
13107 assert(false && "not implemented yet");
13108 return ExprError();
13109}
13110
13111template<typename Derived>
13114 if (!E->isTypeDependent())
13115 return E;
13116
13117 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13118 E->getIdentKind());
13119}
13120
13121template<typename Derived>
13124 NestedNameSpecifierLoc QualifierLoc;
13125 if (E->getQualifierLoc()) {
13126 QualifierLoc
13127 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13128 if (!QualifierLoc)
13129 return ExprError();
13130 }
13131
13132 ValueDecl *ND
13133 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13134 E->getDecl()));
13135 if (!ND || ND->isInvalidDecl())
13136 return ExprError();
13137
13138 NamedDecl *Found = ND;
13139 if (E->getFoundDecl() != E->getDecl()) {
13140 Found = cast_or_null<NamedDecl>(
13141 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13142 if (!Found)
13143 return ExprError();
13144 }
13145
13146 DeclarationNameInfo NameInfo = E->getNameInfo();
13147 if (NameInfo.getName()) {
13148 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13149 if (!NameInfo.getName())
13150 return ExprError();
13151 }
13152
13153 if (!getDerived().AlwaysRebuild() &&
13154 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13155 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13156 Found == E->getFoundDecl() &&
13157 NameInfo.getName() == E->getDecl()->getDeclName() &&
13158 !E->hasExplicitTemplateArgs()) {
13159
13160 // Mark it referenced in the new context regardless.
13161 // FIXME: this is a bit instantiation-specific.
13162 SemaRef.MarkDeclRefReferenced(E);
13163
13164 return E;
13165 }
13166
13167 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13168 if (E->hasExplicitTemplateArgs()) {
13169 TemplateArgs = &TransArgs;
13170 TransArgs.setLAngleLoc(E->getLAngleLoc());
13171 TransArgs.setRAngleLoc(E->getRAngleLoc());
13172 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13173 E->getNumTemplateArgs(),
13174 TransArgs))
13175 return ExprError();
13176 }
13177
13178 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13179 Found, TemplateArgs);
13180}
13181
13182template<typename Derived>
13185 return E;
13186}
13187
13188template <typename Derived>
13190 FixedPointLiteral *E) {
13191 return E;
13192}
13193
13194template<typename Derived>
13197 return E;
13198}
13199
13200template<typename Derived>
13203 return E;
13204}
13205
13206template<typename Derived>
13209 return E;
13210}
13211
13212template<typename Derived>
13215 return E;
13216}
13217
13218template<typename Derived>
13221 return getDerived().TransformCallExpr(E);
13222}
13223
13224template<typename Derived>
13227 ExprResult ControllingExpr;
13228 TypeSourceInfo *ControllingType = nullptr;
13229 if (E->isExprPredicate())
13230 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13231 else
13232 ControllingType = getDerived().TransformType(E->getControllingType());
13233
13234 if (ControllingExpr.isInvalid() && !ControllingType)
13235 return ExprError();
13236
13237 SmallVector<Expr *, 4> AssocExprs;
13239 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13240 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13241 if (TSI) {
13242 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13243 if (!AssocType)
13244 return ExprError();
13245 AssocTypes.push_back(AssocType);
13246 } else {
13247 AssocTypes.push_back(nullptr);
13248 }
13249
13250 ExprResult AssocExpr =
13251 getDerived().TransformExpr(Assoc.getAssociationExpr());
13252 if (AssocExpr.isInvalid())
13253 return ExprError();
13254 AssocExprs.push_back(AssocExpr.get());
13255 }
13256
13257 if (!ControllingType)
13258 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13259 E->getDefaultLoc(),
13260 E->getRParenLoc(),
13261 ControllingExpr.get(),
13262 AssocTypes,
13263 AssocExprs);
13264 return getDerived().RebuildGenericSelectionExpr(
13265 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13266 ControllingType, AssocTypes, AssocExprs);
13267}
13268
13269template<typename Derived>
13272 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13273 if (SubExpr.isInvalid())
13274 return ExprError();
13275
13276 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13277 return E;
13278
13279 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13280 E->getRParen());
13281}
13282
13283/// The operand of a unary address-of operator has special rules: it's
13284/// allowed to refer to a non-static member of a class even if there's no 'this'
13285/// object available.
13286template<typename Derived>
13289 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13290 return getDerived().TransformDependentScopeDeclRefExpr(
13291 DRE, /*IsAddressOfOperand=*/true, nullptr);
13292 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13293 return getDerived().TransformUnresolvedLookupExpr(
13294 ULE, /*IsAddressOfOperand=*/true);
13295 else
13296 return getDerived().TransformExpr(E);
13297}
13298
13299template<typename Derived>
13302 ExprResult SubExpr;
13303 if (E->getOpcode() == UO_AddrOf)
13304 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13305 else
13306 SubExpr = TransformExpr(E->getSubExpr());
13307 if (SubExpr.isInvalid())
13308 return ExprError();
13309
13310 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13311 return E;
13312
13313 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13314 E->getOpcode(),
13315 SubExpr.get());
13316}
13317
13318template<typename Derived>
13320TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13321 // Transform the type.
13322 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13323 if (!Type)
13324 return ExprError();
13325
13326 // Transform all of the components into components similar to what the
13327 // parser uses.
13328 // FIXME: It would be slightly more efficient in the non-dependent case to
13329 // just map FieldDecls, rather than requiring the rebuilder to look for
13330 // the fields again. However, __builtin_offsetof is rare enough in
13331 // template code that we don't care.
13332 bool ExprChanged = false;
13333 typedef Sema::OffsetOfComponent Component;
13334 SmallVector<Component, 4> Components;
13335 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13336 const OffsetOfNode &ON = E->getComponent(I);
13337 Component Comp;
13338 Comp.isBrackets = true;
13339 Comp.LocStart = ON.getSourceRange().getBegin();
13340 Comp.LocEnd = ON.getSourceRange().getEnd();
13341 switch (ON.getKind()) {
13342 case OffsetOfNode::Array: {
13343 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13344 ExprResult Index = getDerived().TransformExpr(FromIndex);
13345 if (Index.isInvalid())
13346 return ExprError();
13347
13348 ExprChanged = ExprChanged || Index.get() != FromIndex;
13349 Comp.isBrackets = true;
13350 Comp.U.E = Index.get();
13351 break;
13352 }
13353
13356 Comp.isBrackets = false;
13357 Comp.U.IdentInfo = ON.getFieldName();
13358 if (!Comp.U.IdentInfo)
13359 continue;
13360
13361 break;
13362
13363 case OffsetOfNode::Base:
13364 // Will be recomputed during the rebuild.
13365 continue;
13366 }
13367
13368 Components.push_back(Comp);
13369 }
13370
13371 // If nothing changed, retain the existing expression.
13372 if (!getDerived().AlwaysRebuild() &&
13373 Type == E->getTypeSourceInfo() &&
13374 !ExprChanged)
13375 return E;
13376
13377 // Build a new offsetof expression.
13378 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13379 Components, E->getRParenLoc());
13380}
13381
13382template<typename Derived>
13385 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13386 "opaque value expression requires transformation");
13387 return E;
13388}
13389
13390template <typename Derived>
13393 bool Changed = false;
13394 for (Expr *C : E->subExpressions()) {
13395 ExprResult NewC = getDerived().TransformExpr(C);
13396 if (NewC.isInvalid())
13397 return ExprError();
13398 Children.push_back(NewC.get());
13399
13400 Changed |= NewC.get() != C;
13401 }
13402 if (!getDerived().AlwaysRebuild() && !Changed)
13403 return E;
13404 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13405 Children, E->getType());
13406}
13407
13408template<typename Derived>
13411 // Rebuild the syntactic form. The original syntactic form has
13412 // opaque-value expressions in it, so strip those away and rebuild
13413 // the result. This is a really awful way of doing this, but the
13414 // better solution (rebuilding the semantic expressions and
13415 // rebinding OVEs as necessary) doesn't work; we'd need
13416 // TreeTransform to not strip away implicit conversions.
13417 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13418 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13419 if (result.isInvalid()) return ExprError();
13420
13421 // If that gives us a pseudo-object result back, the pseudo-object
13422 // expression must have been an lvalue-to-rvalue conversion which we
13423 // should reapply.
13424 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13425 result = SemaRef.PseudoObject().checkRValue(result.get());
13426
13427 return result;
13428}
13429
13430template<typename Derived>
13434 if (E->isArgumentType()) {
13435 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13436
13437 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13438 if (!NewT)
13439 return ExprError();
13440
13441 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13442 return E;
13443
13444 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13445 E->getKind(),
13446 E->getSourceRange());
13447 }
13448
13449 // C++0x [expr.sizeof]p1:
13450 // The operand is either an expression, which is an unevaluated operand
13451 // [...]
13455
13456 // Try to recover if we have something like sizeof(T::X) where X is a type.
13457 // Notably, there must be *exactly* one set of parens if X is a type.
13458 TypeSourceInfo *RecoveryTSI = nullptr;
13459 ExprResult SubExpr;
13460 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13461 if (auto *DRE =
13462 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13463 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13464 PE, DRE, false, &RecoveryTSI);
13465 else
13466 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13467
13468 if (RecoveryTSI) {
13469 return getDerived().RebuildUnaryExprOrTypeTrait(
13470 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13471 } else if (SubExpr.isInvalid())
13472 return ExprError();
13473
13474 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13475 return E;
13476
13477 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13478 E->getOperatorLoc(),
13479 E->getKind(),
13480 E->getSourceRange());
13481}
13482
13483template<typename Derived>
13486 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13487 if (LHS.isInvalid())
13488 return ExprError();
13489
13490 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13491 if (RHS.isInvalid())
13492 return ExprError();
13493
13494
13495 if (!getDerived().AlwaysRebuild() &&
13496 LHS.get() == E->getLHS() &&
13497 RHS.get() == E->getRHS())
13498 return E;
13499
13500 return getDerived().RebuildArraySubscriptExpr(
13501 LHS.get(),
13502 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13503}
13504
13505template <typename Derived>
13508 ExprResult Base = getDerived().TransformExpr(E->getBase());
13509 if (Base.isInvalid())
13510 return ExprError();
13511
13512 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13513 if (RowIdx.isInvalid())
13514 return ExprError();
13515
13516 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13517 RowIdx.get() == E->getRowIdx())
13518 return E;
13519
13520 return getDerived().RebuildMatrixSingleSubscriptExpr(Base.get(), RowIdx.get(),
13521 E->getRBracketLoc());
13522}
13523
13524template <typename Derived>
13527 ExprResult Base = getDerived().TransformExpr(E->getBase());
13528 if (Base.isInvalid())
13529 return ExprError();
13530
13531 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13532 if (RowIdx.isInvalid())
13533 return ExprError();
13534
13535 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13536 if (ColumnIdx.isInvalid())
13537 return ExprError();
13538
13539 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13540 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13541 return E;
13542
13543 return getDerived().RebuildMatrixSubscriptExpr(
13544 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13545}
13546
13547template <typename Derived>
13550 ExprResult Base = getDerived().TransformExpr(E->getBase());
13551 if (Base.isInvalid())
13552 return ExprError();
13553
13554 ExprResult LowerBound;
13555 if (E->getLowerBound()) {
13556 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13557 if (LowerBound.isInvalid())
13558 return ExprError();
13559 }
13560
13561 ExprResult Length;
13562 if (E->getLength()) {
13563 Length = getDerived().TransformExpr(E->getLength());
13564 if (Length.isInvalid())
13565 return ExprError();
13566 }
13567
13568 ExprResult Stride;
13569 if (E->isOMPArraySection()) {
13570 if (Expr *Str = E->getStride()) {
13571 Stride = getDerived().TransformExpr(Str);
13572 if (Stride.isInvalid())
13573 return ExprError();
13574 }
13575 }
13576
13577 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13578 LowerBound.get() == E->getLowerBound() &&
13579 Length.get() == E->getLength() &&
13580 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13581 return E;
13582
13583 return getDerived().RebuildArraySectionExpr(
13584 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13585 LowerBound.get(), E->getColonLocFirst(),
13586 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13587 Length.get(), Stride.get(), E->getRBracketLoc());
13588}
13589
13590template <typename Derived>
13593 ExprResult Base = getDerived().TransformExpr(E->getBase());
13594 if (Base.isInvalid())
13595 return ExprError();
13596
13598 bool ErrorFound = false;
13599 for (Expr *Dim : E->getDimensions()) {
13600 ExprResult DimRes = getDerived().TransformExpr(Dim);
13601 if (DimRes.isInvalid()) {
13602 ErrorFound = true;
13603 continue;
13604 }
13605 Dims.push_back(DimRes.get());
13606 }
13607
13608 if (ErrorFound)
13609 return ExprError();
13610 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13611 E->getRParenLoc(), Dims,
13612 E->getBracketsRanges());
13613}
13614
13615template <typename Derived>
13618 unsigned NumIterators = E->numOfIterators();
13620
13621 bool ErrorFound = false;
13622 bool NeedToRebuild = getDerived().AlwaysRebuild();
13623 for (unsigned I = 0; I < NumIterators; ++I) {
13624 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13625 Data[I].DeclIdent = D->getIdentifier();
13626 Data[I].DeclIdentLoc = D->getLocation();
13627 if (D->getLocation() == D->getBeginLoc()) {
13628 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13629 "Implicit type must be int.");
13630 } else {
13631 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13632 QualType DeclTy = getDerived().TransformType(D->getType());
13633 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13634 }
13635 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13636 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13637 ExprResult End = getDerived().TransformExpr(Range.End);
13638 ExprResult Step = getDerived().TransformExpr(Range.Step);
13639 ErrorFound = ErrorFound ||
13640 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13641 !Data[I].Type.get().isNull())) ||
13642 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13643 if (ErrorFound)
13644 continue;
13645 Data[I].Range.Begin = Begin.get();
13646 Data[I].Range.End = End.get();
13647 Data[I].Range.Step = Step.get();
13648 Data[I].AssignLoc = E->getAssignLoc(I);
13649 Data[I].ColonLoc = E->getColonLoc(I);
13650 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13651 NeedToRebuild =
13652 NeedToRebuild ||
13653 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13654 D->getType().getTypePtrOrNull()) ||
13655 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13656 Range.Step != Data[I].Range.Step;
13657 }
13658 if (ErrorFound)
13659 return ExprError();
13660 if (!NeedToRebuild)
13661 return E;
13662
13663 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13664 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13665 if (!Res.isUsable())
13666 return Res;
13667 auto *IE = cast<OMPIteratorExpr>(Res.get());
13668 for (unsigned I = 0; I < NumIterators; ++I)
13669 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13670 IE->getIteratorDecl(I));
13671 return Res;
13672}
13673
13674template<typename Derived>
13677 // Transform the callee.
13678 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13679 if (Callee.isInvalid())
13680 return ExprError();
13681
13682 // Transform arguments.
13683 bool ArgChanged = false;
13685 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13686 &ArgChanged))
13687 return ExprError();
13688
13689 if (!getDerived().AlwaysRebuild() &&
13690 Callee.get() == E->getCallee() &&
13691 !ArgChanged)
13692 return SemaRef.MaybeBindToTemporary(E);
13693
13694 // FIXME: Wrong source location information for the '('.
13695 SourceLocation FakeLParenLoc
13696 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13697
13698 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13699 if (E->hasStoredFPFeatures()) {
13700 FPOptionsOverride NewOverrides = E->getFPFeatures();
13701 getSema().CurFPFeatures =
13702 NewOverrides.applyOverrides(getSema().getLangOpts());
13703 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13704 }
13705
13706 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13707 Args,
13708 E->getRParenLoc());
13709}
13710
13711template<typename Derived>
13714 ExprResult Base = getDerived().TransformExpr(E->getBase());
13715 if (Base.isInvalid())
13716 return ExprError();
13717
13718 NestedNameSpecifierLoc QualifierLoc;
13719 if (E->hasQualifier()) {
13720 QualifierLoc
13721 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13722
13723 if (!QualifierLoc)
13724 return ExprError();
13725 }
13726 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13727
13729 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13730 E->getMemberDecl()));
13731 if (!Member)
13732 return ExprError();
13733
13734 NamedDecl *FoundDecl = E->getFoundDecl();
13735 if (FoundDecl == E->getMemberDecl()) {
13736 FoundDecl = Member;
13737 } else {
13738 FoundDecl = cast_or_null<NamedDecl>(
13739 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13740 if (!FoundDecl)
13741 return ExprError();
13742 }
13743
13744 if (!getDerived().AlwaysRebuild() &&
13745 Base.get() == E->getBase() &&
13746 QualifierLoc == E->getQualifierLoc() &&
13747 Member == E->getMemberDecl() &&
13748 FoundDecl == E->getFoundDecl() &&
13749 !E->hasExplicitTemplateArgs()) {
13750
13751 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13752 // for Openmp where the field need to be privatizized in the case.
13753 if (!(isa<CXXThisExpr>(E->getBase()) &&
13754 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13756 // Mark it referenced in the new context regardless.
13757 // FIXME: this is a bit instantiation-specific.
13758 SemaRef.MarkMemberReferenced(E);
13759 return E;
13760 }
13761 }
13762
13763 TemplateArgumentListInfo TransArgs;
13764 if (E->hasExplicitTemplateArgs()) {
13765 TransArgs.setLAngleLoc(E->getLAngleLoc());
13766 TransArgs.setRAngleLoc(E->getRAngleLoc());
13767 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13768 E->getNumTemplateArgs(),
13769 TransArgs))
13770 return ExprError();
13771 }
13772
13773 // FIXME: Bogus source location for the operator
13774 SourceLocation FakeOperatorLoc =
13775 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13776
13777 // FIXME: to do this check properly, we will need to preserve the
13778 // first-qualifier-in-scope here, just in case we had a dependent
13779 // base (and therefore couldn't do the check) and a
13780 // nested-name-qualifier (and therefore could do the lookup).
13781 NamedDecl *FirstQualifierInScope = nullptr;
13782 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13783 if (MemberNameInfo.getName()) {
13784 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13785 if (!MemberNameInfo.getName())
13786 return ExprError();
13787 }
13788
13789 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13790 E->isArrow(),
13791 QualifierLoc,
13792 TemplateKWLoc,
13793 MemberNameInfo,
13794 Member,
13795 FoundDecl,
13796 (E->hasExplicitTemplateArgs()
13797 ? &TransArgs : nullptr),
13798 FirstQualifierInScope);
13799}
13800
13801template<typename Derived>
13804 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13805 if (LHS.isInvalid())
13806 return ExprError();
13807
13808 ExprResult RHS =
13809 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13810 if (RHS.isInvalid())
13811 return ExprError();
13812
13813 if (!getDerived().AlwaysRebuild() &&
13814 LHS.get() == E->getLHS() &&
13815 RHS.get() == E->getRHS())
13816 return E;
13817
13818 if (E->isCompoundAssignmentOp())
13819 // FPFeatures has already been established from trailing storage
13820 return getDerived().RebuildBinaryOperator(
13821 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13822 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13823 FPOptionsOverride NewOverrides(E->getFPFeatures());
13824 getSema().CurFPFeatures =
13825 NewOverrides.applyOverrides(getSema().getLangOpts());
13826 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13827 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13828 LHS.get(), RHS.get());
13829}
13830
13831template <typename Derived>
13834 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13835
13836 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13837 if (LHS.isInvalid())
13838 return ExprError();
13839
13840 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13841 if (RHS.isInvalid())
13842 return ExprError();
13843
13844 // Extract the already-resolved callee declarations so that we can restrict
13845 // ourselves to using them as the unqualified lookup results when rebuilding.
13846 UnresolvedSet<2> UnqualLookups;
13847 bool ChangedAnyLookups = false;
13848 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13849 const_cast<Expr *>(Decomp.InnerBinOp)};
13850 for (Expr *PossibleBinOp : PossibleBinOps) {
13851 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13852 if (!Op)
13853 continue;
13854 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13855 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13856 continue;
13857
13858 // Transform the callee in case we built a call to a local extern
13859 // declaration.
13860 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13861 E->getOperatorLoc(), Callee->getFoundDecl()));
13862 if (!Found)
13863 return ExprError();
13864 if (Found != Callee->getFoundDecl())
13865 ChangedAnyLookups = true;
13866 UnqualLookups.addDecl(Found);
13867 }
13868
13869 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13870 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13871 // Mark all functions used in the rewrite as referenced. Note that when
13872 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13873 // function calls, and/or there might be a user-defined conversion sequence
13874 // applied to the operands of the <.
13875 // FIXME: this is a bit instantiation-specific.
13876 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13877 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13878 return E;
13879 }
13880
13881 return getDerived().RebuildCXXRewrittenBinaryOperator(
13882 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13883}
13884
13885template<typename Derived>
13889 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13890 FPOptionsOverride NewOverrides(E->getFPFeatures());
13891 getSema().CurFPFeatures =
13892 NewOverrides.applyOverrides(getSema().getLangOpts());
13893 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13894 return getDerived().TransformBinaryOperator(E);
13895}
13896
13897template<typename Derived>
13900 // Just rebuild the common and RHS expressions and see whether we
13901 // get any changes.
13902
13903 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13904 if (commonExpr.isInvalid())
13905 return ExprError();
13906
13907 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13908 if (rhs.isInvalid())
13909 return ExprError();
13910
13911 if (!getDerived().AlwaysRebuild() &&
13912 commonExpr.get() == e->getCommon() &&
13913 rhs.get() == e->getFalseExpr())
13914 return e;
13915
13916 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13917 e->getQuestionLoc(),
13918 nullptr,
13919 e->getColonLoc(),
13920 rhs.get());
13921}
13922
13923template<typename Derived>
13926 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13927 if (Cond.isInvalid())
13928 return ExprError();
13929
13930 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13931 if (LHS.isInvalid())
13932 return ExprError();
13933
13934 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13935 if (RHS.isInvalid())
13936 return ExprError();
13937
13938 if (!getDerived().AlwaysRebuild() &&
13939 Cond.get() == E->getCond() &&
13940 LHS.get() == E->getLHS() &&
13941 RHS.get() == E->getRHS())
13942 return E;
13943
13944 return getDerived().RebuildConditionalOperator(Cond.get(),
13945 E->getQuestionLoc(),
13946 LHS.get(),
13947 E->getColonLoc(),
13948 RHS.get());
13949}
13950
13951template<typename Derived>
13954 // Implicit casts are eliminated during transformation, since they
13955 // will be recomputed by semantic analysis after transformation.
13956 return getDerived().TransformExpr(E->getSubExprAsWritten());
13957}
13958
13959template<typename Derived>
13962 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
13963 if (!Type)
13964 return ExprError();
13965
13966 ExprResult SubExpr
13967 = getDerived().TransformExpr(E->getSubExprAsWritten());
13968 if (SubExpr.isInvalid())
13969 return ExprError();
13970
13971 if (!getDerived().AlwaysRebuild() &&
13972 Type == E->getTypeInfoAsWritten() &&
13973 SubExpr.get() == E->getSubExpr())
13974 return E;
13975
13976 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
13977 Type,
13978 E->getRParenLoc(),
13979 SubExpr.get());
13980}
13981
13982template<typename Derived>
13985 TypeSourceInfo *OldT = E->getTypeSourceInfo();
13986 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13987 if (!NewT)
13988 return ExprError();
13989
13990 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
13991 if (Init.isInvalid())
13992 return ExprError();
13993
13994 if (!getDerived().AlwaysRebuild() &&
13995 OldT == NewT &&
13996 Init.get() == E->getInitializer())
13997 return SemaRef.MaybeBindToTemporary(E);
13998
13999 // Note: the expression type doesn't necessarily match the
14000 // type-as-written, but that's okay, because it should always be
14001 // derivable from the initializer.
14002
14003 return getDerived().RebuildCompoundLiteralExpr(
14004 E->getLParenLoc(), NewT,
14005 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
14006}
14007
14008template<typename Derived>
14011 ExprResult Base = getDerived().TransformExpr(E->getBase());
14012 if (Base.isInvalid())
14013 return ExprError();
14014
14015 if (!getDerived().AlwaysRebuild() &&
14016 Base.get() == E->getBase())
14017 return E;
14018
14019 // FIXME: Bad source location
14020 SourceLocation FakeOperatorLoc =
14021 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14022 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14023 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
14024 E->getAccessor());
14025}
14026
14027template <typename Derived>
14030 ExprResult Base = getDerived().TransformExpr(E->getBase());
14031 if (Base.isInvalid())
14032 return ExprError();
14033
14034 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase())
14035 return E;
14036
14037 // FIXME: Bad source location
14038 SourceLocation FakeOperatorLoc =
14039 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14040 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14041 Base.get(), FakeOperatorLoc, /*isArrow*/ false, E->getAccessorLoc(),
14042 E->getAccessor());
14043}
14044
14045template<typename Derived>
14048 if (InitListExpr *Syntactic = E->getSyntacticForm())
14049 E = Syntactic;
14050
14051 bool InitChanged = false;
14052
14055
14057 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
14058 Inits, &InitChanged))
14059 return ExprError();
14060
14061 if (!getDerived().AlwaysRebuild() && !InitChanged) {
14062 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
14063 // in some cases. We can't reuse it in general, because the syntactic and
14064 // semantic forms are linked, and we can't know that semantic form will
14065 // match even if the syntactic form does.
14066 }
14067
14068 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
14069 E->getRBraceLoc());
14070}
14071
14072template<typename Derived>
14075 Designation Desig;
14076
14077 // transform the initializer value
14078 ExprResult Init = getDerived().TransformExpr(E->getInit());
14079 if (Init.isInvalid())
14080 return ExprError();
14081
14082 // transform the designators.
14083 SmallVector<Expr*, 4> ArrayExprs;
14084 bool ExprChanged = false;
14085 for (const DesignatedInitExpr::Designator &D : E->designators()) {
14086 if (D.isFieldDesignator()) {
14087 if (D.getFieldDecl()) {
14088 FieldDecl *Field = cast_or_null<FieldDecl>(
14089 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
14090 if (Field != D.getFieldDecl())
14091 // Rebuild the expression when the transformed FieldDecl is
14092 // different to the already assigned FieldDecl.
14093 ExprChanged = true;
14094 if (Field->isAnonymousStructOrUnion())
14095 continue;
14096 } else {
14097 // Ensure that the designator expression is rebuilt when there isn't
14098 // a resolved FieldDecl in the designator as we don't want to assign
14099 // a FieldDecl to a pattern designator that will be instantiated again.
14100 ExprChanged = true;
14101 }
14102 Desig.AddDesignator(Designator::CreateFieldDesignator(
14103 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
14104 continue;
14105 }
14106
14107 if (D.isArrayDesignator()) {
14108 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
14109 if (Index.isInvalid())
14110 return ExprError();
14111
14112 Desig.AddDesignator(
14113 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
14114
14115 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
14116 ArrayExprs.push_back(Index.get());
14117 continue;
14118 }
14119
14120 assert(D.isArrayRangeDesignator() && "New kind of designator?");
14121 ExprResult Start
14122 = getDerived().TransformExpr(E->getArrayRangeStart(D));
14123 if (Start.isInvalid())
14124 return ExprError();
14125
14126 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
14127 if (End.isInvalid())
14128 return ExprError();
14129
14130 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
14131 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
14132
14133 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
14134 End.get() != E->getArrayRangeEnd(D);
14135
14136 ArrayExprs.push_back(Start.get());
14137 ArrayExprs.push_back(End.get());
14138 }
14139
14140 if (!getDerived().AlwaysRebuild() &&
14141 Init.get() == E->getInit() &&
14142 !ExprChanged)
14143 return E;
14144
14145 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14146 E->getEqualOrColonLoc(),
14147 E->usesGNUSyntax(), Init.get());
14148}
14149
14150// Seems that if TransformInitListExpr() only works on the syntactic form of an
14151// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14152template<typename Derived>
14156 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14157 "initializer");
14158 return ExprError();
14159}
14160
14161template<typename Derived>
14164 NoInitExpr *E) {
14165 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14166 return ExprError();
14167}
14168
14169template<typename Derived>
14172 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14173 return ExprError();
14174}
14175
14176template<typename Derived>
14179 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14180 return ExprError();
14181}
14182
14183template<typename Derived>
14187 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14188
14189 // FIXME: Will we ever have proper type location here? Will we actually
14190 // need to transform the type?
14191 QualType T = getDerived().TransformType(E->getType());
14192 if (T.isNull())
14193 return ExprError();
14194
14195 if (!getDerived().AlwaysRebuild() &&
14196 T == E->getType())
14197 return E;
14198
14199 return getDerived().RebuildImplicitValueInitExpr(T);
14200}
14201
14202template<typename Derived>
14205 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14206 if (!TInfo)
14207 return ExprError();
14208
14209 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14210 if (SubExpr.isInvalid())
14211 return ExprError();
14212
14213 if (!getDerived().AlwaysRebuild() &&
14214 TInfo == E->getWrittenTypeInfo() &&
14215 SubExpr.get() == E->getSubExpr())
14216 return E;
14217
14218 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14219 TInfo, E->getRParenLoc());
14220}
14221
14222template<typename Derived>
14225 bool ArgumentChanged = false;
14227 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14228 &ArgumentChanged))
14229 return ExprError();
14230
14231 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14232 Inits,
14233 E->getRParenLoc());
14234}
14235
14236/// Transform an address-of-label expression.
14237///
14238/// By default, the transformation of an address-of-label expression always
14239/// rebuilds the expression, so that the label identifier can be resolved to
14240/// the corresponding label statement by semantic analysis.
14241template<typename Derived>
14244 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14245 E->getLabel());
14246 if (!LD)
14247 return ExprError();
14248
14249 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14250 cast<LabelDecl>(LD));
14251}
14252
14253template<typename Derived>
14256 SemaRef.ActOnStartStmtExpr();
14257 StmtResult SubStmt
14258 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14259 if (SubStmt.isInvalid()) {
14260 SemaRef.ActOnStmtExprError();
14261 return ExprError();
14262 }
14263
14264 unsigned OldDepth = E->getTemplateDepth();
14265 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14266
14267 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14268 SubStmt.get() == E->getSubStmt()) {
14269 // Calling this an 'error' is unintuitive, but it does the right thing.
14270 SemaRef.ActOnStmtExprError();
14271 return SemaRef.MaybeBindToTemporary(E);
14272 }
14273
14274 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14275 E->getRParenLoc(), NewDepth);
14276}
14277
14278template<typename Derived>
14281 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14282 if (Cond.isInvalid())
14283 return ExprError();
14284
14285 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14286 if (LHS.isInvalid())
14287 return ExprError();
14288
14289 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14290 if (RHS.isInvalid())
14291 return ExprError();
14292
14293 if (!getDerived().AlwaysRebuild() &&
14294 Cond.get() == E->getCond() &&
14295 LHS.get() == E->getLHS() &&
14296 RHS.get() == E->getRHS())
14297 return E;
14298
14299 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14300 Cond.get(), LHS.get(), RHS.get(),
14301 E->getRParenLoc());
14302}
14303
14304template<typename Derived>
14307 return E;
14308}
14309
14310template<typename Derived>
14313 switch (E->getOperator()) {
14314 case OO_New:
14315 case OO_Delete:
14316 case OO_Array_New:
14317 case OO_Array_Delete:
14318 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14319
14320 case OO_Subscript:
14321 case OO_Call: {
14322 // This is a call to an object's operator().
14323 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14324
14325 // Transform the object itself.
14326 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14327 if (Object.isInvalid())
14328 return ExprError();
14329
14330 // FIXME: Poor location information. Also, if the location for the end of
14331 // the token is within a macro expansion, getLocForEndOfToken() will return
14332 // an invalid source location. If that happens and we have an otherwise
14333 // valid end location, use the valid one instead of the invalid one.
14334 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14335 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14336 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14337 FakeLParenLoc = EndLoc;
14338
14339 // Transform the call arguments.
14341 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14342 Args))
14343 return ExprError();
14344
14345 if (E->getOperator() == OO_Subscript)
14346 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14347 Args, E->getEndLoc());
14348
14349 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14350 E->getEndLoc());
14351 }
14352
14353#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14354 case OO_##Name: \
14355 break;
14356
14357#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14358#include "clang/Basic/OperatorKinds.def"
14359
14360 case OO_Conditional:
14361 llvm_unreachable("conditional operator is not actually overloadable");
14362
14363 case OO_None:
14365 llvm_unreachable("not an overloaded operator?");
14366 }
14367
14369 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14370 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14371 else
14372 First = getDerived().TransformExpr(E->getArg(0));
14373 if (First.isInvalid())
14374 return ExprError();
14375
14376 ExprResult Second;
14377 if (E->getNumArgs() == 2) {
14378 Second =
14379 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14380 if (Second.isInvalid())
14381 return ExprError();
14382 }
14383
14384 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14385 FPOptionsOverride NewOverrides(E->getFPFeatures());
14386 getSema().CurFPFeatures =
14387 NewOverrides.applyOverrides(getSema().getLangOpts());
14388 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14389
14390 Expr *Callee = E->getCallee();
14391 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14392 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14394 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14395 return ExprError();
14396
14397 return getDerived().RebuildCXXOperatorCallExpr(
14398 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14399 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14400 }
14401
14402 UnresolvedSet<1> Functions;
14403 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14404 Callee = ICE->getSubExprAsWritten();
14405 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14406 ValueDecl *VD = cast_or_null<ValueDecl>(
14407 getDerived().TransformDecl(DR->getLocation(), DR));
14408 if (!VD)
14409 return ExprError();
14410
14411 if (!isa<CXXMethodDecl>(VD))
14412 Functions.addDecl(VD);
14413
14414 return getDerived().RebuildCXXOperatorCallExpr(
14415 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14416 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14417}
14418
14419template<typename Derived>
14422 return getDerived().TransformCallExpr(E);
14423}
14424
14425template <typename Derived>
14427 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14428 getSema().CurContext != E->getParentContext();
14429
14430 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14431 return E;
14432
14433 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14434 E->getBeginLoc(), E->getEndLoc(),
14435 getSema().CurContext);
14436}
14437
14438template <typename Derived>
14440 return E;
14441}
14442
14443template<typename Derived>
14446 // Transform the callee.
14447 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14448 if (Callee.isInvalid())
14449 return ExprError();
14450
14451 // Transform exec config.
14452 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14453 if (EC.isInvalid())
14454 return ExprError();
14455
14456 // Transform arguments.
14457 bool ArgChanged = false;
14459 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14460 &ArgChanged))
14461 return ExprError();
14462
14463 if (!getDerived().AlwaysRebuild() &&
14464 Callee.get() == E->getCallee() &&
14465 !ArgChanged)
14466 return SemaRef.MaybeBindToTemporary(E);
14467
14468 // FIXME: Wrong source location information for the '('.
14469 SourceLocation FakeLParenLoc
14470 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14471 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14472 Args,
14473 E->getRParenLoc(), EC.get());
14474}
14475
14476template<typename Derived>
14479 TypeSourceInfo *Type = getDerived().TransformType(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 return getDerived().RebuildCXXNamedCastExpr(
14495 // FIXME. this should be '(' location
14496 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14497}
14498
14499template<typename Derived>
14502 TypeSourceInfo *TSI =
14503 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14504 if (!TSI)
14505 return ExprError();
14506
14507 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14508 if (Sub.isInvalid())
14509 return ExprError();
14510
14511 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14512 Sub.get(), BCE->getEndLoc());
14513}
14514
14515template<typename Derived>
14517TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14518 return getDerived().TransformCXXNamedCastExpr(E);
14519}
14520
14521template<typename Derived>
14524 return getDerived().TransformCXXNamedCastExpr(E);
14525}
14526
14527template<typename Derived>
14531 return getDerived().TransformCXXNamedCastExpr(E);
14532}
14533
14534template<typename Derived>
14537 return getDerived().TransformCXXNamedCastExpr(E);
14538}
14539
14540template<typename Derived>
14543 return getDerived().TransformCXXNamedCastExpr(E);
14544}
14545
14546template<typename Derived>
14551 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14552 if (!Type)
14553 return ExprError();
14554
14555 ExprResult SubExpr
14556 = getDerived().TransformExpr(E->getSubExprAsWritten());
14557 if (SubExpr.isInvalid())
14558 return ExprError();
14559
14560 if (!getDerived().AlwaysRebuild() &&
14561 Type == E->getTypeInfoAsWritten() &&
14562 SubExpr.get() == E->getSubExpr())
14563 return E;
14564
14565 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14566 E->getLParenLoc(),
14567 SubExpr.get(),
14568 E->getRParenLoc(),
14569 E->isListInitialization());
14570}
14571
14572template<typename Derived>
14575 if (E->isTypeOperand()) {
14576 TypeSourceInfo *TInfo
14577 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14578 if (!TInfo)
14579 return ExprError();
14580
14581 if (!getDerived().AlwaysRebuild() &&
14582 TInfo == E->getTypeOperandSourceInfo())
14583 return E;
14584
14585 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14586 TInfo, E->getEndLoc());
14587 }
14588
14589 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14590 // type. We must not unilaterally enter unevaluated context here, as then
14591 // semantic processing can re-transform an already transformed operand.
14592 Expr *Op = E->getExprOperand();
14594 if (E->isGLValue()) {
14595 QualType OpType = Op->getType();
14596 if (auto *RD = OpType->getAsCXXRecordDecl()) {
14597 if (SemaRef.RequireCompleteType(E->getBeginLoc(), OpType,
14598 diag::err_incomplete_typeid))
14599 return ExprError();
14600
14601 if (RD->isPolymorphic())
14602 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14603 }
14604 }
14605
14608
14609 ExprResult SubExpr = getDerived().TransformExpr(Op);
14610 if (SubExpr.isInvalid())
14611 return ExprError();
14612
14613 if (!getDerived().AlwaysRebuild() &&
14614 SubExpr.get() == E->getExprOperand())
14615 return E;
14616
14617 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14618 SubExpr.get(), E->getEndLoc());
14619}
14620
14621template<typename Derived>
14624 if (E->isTypeOperand()) {
14625 TypeSourceInfo *TInfo
14626 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14627 if (!TInfo)
14628 return ExprError();
14629
14630 if (!getDerived().AlwaysRebuild() &&
14631 TInfo == E->getTypeOperandSourceInfo())
14632 return E;
14633
14634 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14635 TInfo, E->getEndLoc());
14636 }
14637
14640
14641 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14642 if (SubExpr.isInvalid())
14643 return ExprError();
14644
14645 if (!getDerived().AlwaysRebuild() &&
14646 SubExpr.get() == E->getExprOperand())
14647 return E;
14648
14649 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14650 SubExpr.get(), E->getEndLoc());
14651}
14652
14653template<typename Derived>
14656 return E;
14657}
14658
14659template<typename Derived>
14663 return E;
14664}
14665
14666template<typename Derived>
14669
14670 // In lambdas, the qualifiers of the type depends of where in
14671 // the call operator `this` appear, and we do not have a good way to
14672 // rebuild this information, so we transform the type.
14673 //
14674 // In other contexts, the type of `this` may be overrided
14675 // for type deduction, so we need to recompute it.
14676 //
14677 // Always recompute the type if we're in the body of a lambda, and
14678 // 'this' is dependent on a lambda's explicit object parameter; we
14679 // also need to always rebuild the expression in this case to clear
14680 // the flag.
14681 QualType T = [&]() {
14682 auto &S = getSema();
14683 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14684 return S.getCurrentThisType();
14685 if (S.getCurLambda())
14686 return getDerived().TransformType(E->getType());
14687 return S.getCurrentThisType();
14688 }();
14689
14690 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14691 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14692 // Mark it referenced in the new context regardless.
14693 // FIXME: this is a bit instantiation-specific.
14694 getSema().MarkThisReferenced(E);
14695 return E;
14696 }
14697
14698 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14699}
14700
14701template<typename Derived>
14704 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14705 if (SubExpr.isInvalid())
14706 return ExprError();
14707
14708 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14709
14710 if (!getDerived().AlwaysRebuild() &&
14711 SubExpr.get() == E->getSubExpr())
14712 return E;
14713
14714 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14715 E->isThrownVariableInScope());
14716}
14717
14718template<typename Derived>
14721 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14722 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14723 if (!Param)
14724 return ExprError();
14725
14726 ExprResult InitRes;
14727 if (E->hasRewrittenInit()) {
14728 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14729 if (InitRes.isInvalid())
14730 return ExprError();
14731 }
14732
14733 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14734 E->getUsedContext() == SemaRef.CurContext &&
14735 InitRes.get() == E->getRewrittenExpr())
14736 return E;
14737
14738 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14739 InitRes.get());
14740}
14741
14742template<typename Derived>
14745 FieldDecl *Field = cast_or_null<FieldDecl>(
14746 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14747 if (!Field)
14748 return ExprError();
14749
14750 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14751 E->getUsedContext() == SemaRef.CurContext)
14752 return E;
14753
14754 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14755}
14756
14757template<typename Derived>
14761 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14762 if (!T)
14763 return ExprError();
14764
14765 if (!getDerived().AlwaysRebuild() &&
14766 T == E->getTypeSourceInfo())
14767 return E;
14768
14769 return getDerived().RebuildCXXScalarValueInitExpr(T,
14770 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14771 E->getRParenLoc());
14772}
14773
14774template<typename Derived>
14777 // Transform the type that we're allocating
14778 TypeSourceInfo *AllocTypeInfo =
14779 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14780 if (!AllocTypeInfo)
14781 return ExprError();
14782
14783 // Transform the size of the array we're allocating (if any).
14784 std::optional<Expr *> ArraySize;
14785 if (E->isArray()) {
14786 ExprResult NewArraySize;
14787 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14788 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14789 if (NewArraySize.isInvalid())
14790 return ExprError();
14791 }
14792 ArraySize = NewArraySize.get();
14793 }
14794
14795 // Transform the placement arguments (if any).
14796 bool ArgumentChanged = false;
14797 SmallVector<Expr*, 8> PlacementArgs;
14798 if (getDerived().TransformExprs(E->getPlacementArgs(),
14799 E->getNumPlacementArgs(), true,
14800 PlacementArgs, &ArgumentChanged))
14801 return ExprError();
14802
14803 // Transform the initializer (if any).
14804 Expr *OldInit = E->getInitializer();
14805 ExprResult NewInit;
14806 if (OldInit)
14807 NewInit = getDerived().TransformInitializer(OldInit, true);
14808 if (NewInit.isInvalid())
14809 return ExprError();
14810
14811 // Transform new operator and delete operator.
14812 FunctionDecl *OperatorNew = nullptr;
14813 if (E->getOperatorNew()) {
14814 OperatorNew = cast_or_null<FunctionDecl>(
14815 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14816 if (!OperatorNew)
14817 return ExprError();
14818 }
14819
14820 FunctionDecl *OperatorDelete = nullptr;
14821 if (E->getOperatorDelete()) {
14822 OperatorDelete = cast_or_null<FunctionDecl>(
14823 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14824 if (!OperatorDelete)
14825 return ExprError();
14826 }
14827
14828 if (!getDerived().AlwaysRebuild() &&
14829 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14830 ArraySize == E->getArraySize() &&
14831 NewInit.get() == OldInit &&
14832 OperatorNew == E->getOperatorNew() &&
14833 OperatorDelete == E->getOperatorDelete() &&
14834 !ArgumentChanged) {
14835 // Mark any declarations we need as referenced.
14836 // FIXME: instantiation-specific.
14837 if (OperatorNew)
14838 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14839 if (OperatorDelete)
14840 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14841
14842 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14843 QualType ElementType
14844 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14845 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14847 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14848 }
14849 }
14850
14851 return E;
14852 }
14853
14854 QualType AllocType = AllocTypeInfo->getType();
14855 if (!ArraySize) {
14856 // If no array size was specified, but the new expression was
14857 // instantiated with an array type (e.g., "new T" where T is
14858 // instantiated with "int[4]"), extract the outer bound from the
14859 // array type as our array size. We do this with constant and
14860 // dependently-sized array types.
14861 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14862 if (!ArrayT) {
14863 // Do nothing
14864 } else if (const ConstantArrayType *ConsArrayT
14865 = dyn_cast<ConstantArrayType>(ArrayT)) {
14866 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14867 SemaRef.Context.getSizeType(),
14868 /*FIXME:*/ E->getBeginLoc());
14869 AllocType = ConsArrayT->getElementType();
14870 } else if (const DependentSizedArrayType *DepArrayT
14871 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14872 if (DepArrayT->getSizeExpr()) {
14873 ArraySize = DepArrayT->getSizeExpr();
14874 AllocType = DepArrayT->getElementType();
14875 }
14876 }
14877 }
14878
14879 return getDerived().RebuildCXXNewExpr(
14880 E->getBeginLoc(), E->isGlobalNew(),
14881 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14882 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14883 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14884}
14885
14886template<typename Derived>
14889 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14890 if (Operand.isInvalid())
14891 return ExprError();
14892
14893 // Transform the delete operator, if known.
14894 FunctionDecl *OperatorDelete = nullptr;
14895 if (E->getOperatorDelete()) {
14896 OperatorDelete = cast_or_null<FunctionDecl>(
14897 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14898 if (!OperatorDelete)
14899 return ExprError();
14900 }
14901
14902 if (!getDerived().AlwaysRebuild() &&
14903 Operand.get() == E->getArgument() &&
14904 OperatorDelete == E->getOperatorDelete()) {
14905 // Mark any declarations we need as referenced.
14906 // FIXME: instantiation-specific.
14907 if (OperatorDelete)
14908 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14909
14910 if (!E->getArgument()->isTypeDependent()) {
14911 QualType Destroyed = SemaRef.Context.getBaseElementType(
14912 E->getDestroyedType());
14913 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14914 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14915 SemaRef.LookupDestructor(Record));
14916 }
14917
14918 return E;
14919 }
14920
14921 return getDerived().RebuildCXXDeleteExpr(
14922 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14923}
14924
14925template<typename Derived>
14929 ExprResult Base = getDerived().TransformExpr(E->getBase());
14930 if (Base.isInvalid())
14931 return ExprError();
14932
14933 ParsedType ObjectTypePtr;
14934 bool MayBePseudoDestructor = false;
14935 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14936 E->getOperatorLoc(),
14937 E->isArrow()? tok::arrow : tok::period,
14938 ObjectTypePtr,
14939 MayBePseudoDestructor);
14940 if (Base.isInvalid())
14941 return ExprError();
14942
14943 QualType ObjectType = ObjectTypePtr.get();
14944 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
14945 if (QualifierLoc) {
14946 QualifierLoc
14947 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
14948 if (!QualifierLoc)
14949 return ExprError();
14950 }
14951 CXXScopeSpec SS;
14952 SS.Adopt(QualifierLoc);
14953
14955 if (E->getDestroyedTypeInfo()) {
14956 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
14957 E->getDestroyedTypeInfo(), ObjectType,
14958 /*FirstQualifierInScope=*/nullptr);
14959 if (!DestroyedTypeInfo)
14960 return ExprError();
14961 Destroyed = DestroyedTypeInfo;
14962 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
14963 // We aren't likely to be able to resolve the identifier down to a type
14964 // now anyway, so just retain the identifier.
14965 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
14966 E->getDestroyedTypeLoc());
14967 } else {
14968 // Look for a destructor known with the given name.
14969 ParsedType T = SemaRef.getDestructorName(
14970 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
14971 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
14972 if (!T)
14973 return ExprError();
14974
14975 Destroyed
14977 E->getDestroyedTypeLoc());
14978 }
14979
14980 TypeSourceInfo *ScopeTypeInfo = nullptr;
14981 if (E->getScopeTypeInfo()) {
14982 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
14983 E->getScopeTypeInfo(), ObjectType, nullptr);
14984 if (!ScopeTypeInfo)
14985 return ExprError();
14986 }
14987
14988 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
14989 E->getOperatorLoc(),
14990 E->isArrow(),
14991 SS,
14992 ScopeTypeInfo,
14993 E->getColonColonLoc(),
14994 E->getTildeLoc(),
14995 Destroyed);
14996}
14997
14998template <typename Derived>
15000 bool RequiresADL,
15001 LookupResult &R) {
15002 // Transform all the decls.
15003 bool AllEmptyPacks = true;
15004 for (auto *OldD : Old->decls()) {
15005 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
15006 if (!InstD) {
15007 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
15008 // This can happen because of dependent hiding.
15009 if (isa<UsingShadowDecl>(OldD))
15010 continue;
15011 else {
15012 R.clear();
15013 return true;
15014 }
15015 }
15016
15017 // Expand using pack declarations.
15018 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
15019 ArrayRef<NamedDecl*> Decls = SingleDecl;
15020 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
15021 Decls = UPD->expansions();
15022
15023 // Expand using declarations.
15024 for (auto *D : Decls) {
15025 if (auto *UD = dyn_cast<UsingDecl>(D)) {
15026 for (auto *SD : UD->shadows())
15027 R.addDecl(SD);
15028 } else {
15029 R.addDecl(D);
15030 }
15031 }
15032
15033 AllEmptyPacks &= Decls.empty();
15034 }
15035
15036 // C++ [temp.res]/8.4.2:
15037 // The program is ill-formed, no diagnostic required, if [...] lookup for
15038 // a name in the template definition found a using-declaration, but the
15039 // lookup in the corresponding scope in the instantiation odoes not find
15040 // any declarations because the using-declaration was a pack expansion and
15041 // the corresponding pack is empty
15042 if (AllEmptyPacks && !RequiresADL) {
15043 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
15044 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
15045 return true;
15046 }
15047
15048 // Resolve a kind, but don't do any further analysis. If it's
15049 // ambiguous, the callee needs to deal with it.
15050 R.resolveKind();
15051
15052 if (Old->hasTemplateKeyword() && !R.empty()) {
15053 NamedDecl *FoundDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
15054 getSema().FilterAcceptableTemplateNames(R,
15055 /*AllowFunctionTemplates=*/true,
15056 /*AllowDependent=*/true);
15057 if (R.empty()) {
15058 // If a 'template' keyword was used, a lookup that finds only non-template
15059 // names is an error.
15060 getSema().Diag(R.getNameLoc(),
15061 diag::err_template_kw_refers_to_non_template)
15062 << R.getLookupName() << Old->getQualifierLoc().getSourceRange()
15063 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
15064 getSema().Diag(FoundDecl->getLocation(),
15065 diag::note_template_kw_refers_to_non_template)
15066 << R.getLookupName();
15067 return true;
15068 }
15069 }
15070
15071 return false;
15072}
15073
15074template <typename Derived>
15079
15080template <typename Derived>
15083 bool IsAddressOfOperand) {
15084 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
15086
15087 // Transform the declaration set.
15088 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
15089 return ExprError();
15090
15091 // Rebuild the nested-name qualifier, if present.
15092 CXXScopeSpec SS;
15093 if (Old->getQualifierLoc()) {
15094 NestedNameSpecifierLoc QualifierLoc
15095 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
15096 if (!QualifierLoc)
15097 return ExprError();
15098
15099 SS.Adopt(QualifierLoc);
15100 }
15101
15102 if (Old->getNamingClass()) {
15103 CXXRecordDecl *NamingClass
15104 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
15105 Old->getNameLoc(),
15106 Old->getNamingClass()));
15107 if (!NamingClass) {
15108 R.clear();
15109 return ExprError();
15110 }
15111
15112 R.setNamingClass(NamingClass);
15113 }
15114
15115 // Rebuild the template arguments, if any.
15116 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
15117 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
15118 if (Old->hasExplicitTemplateArgs() &&
15119 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15120 Old->getNumTemplateArgs(),
15121 TransArgs)) {
15122 R.clear();
15123 return ExprError();
15124 }
15125
15126 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
15127 // a non-static data member is named in an unevaluated operand, or when
15128 // a member is named in a dependent class scope function template explicit
15129 // specialization that is neither declared static nor with an explicit object
15130 // parameter.
15131 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
15132 return SemaRef.BuildPossibleImplicitMemberExpr(
15133 SS, TemplateKWLoc, R,
15134 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
15135 /*S=*/nullptr);
15136
15137 // If we have neither explicit template arguments, nor the template keyword,
15138 // it's a normal declaration name or member reference.
15139 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
15140 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
15141
15142 // If we have template arguments, then rebuild the template-id expression.
15143 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
15144 Old->requiresADL(), &TransArgs);
15145}
15146
15147template<typename Derived>
15150 bool ArgChanged = false;
15152 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15153 TypeSourceInfo *From = E->getArg(I);
15154 TypeLoc FromTL = From->getTypeLoc();
15155 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15156 TypeLocBuilder TLB;
15157 TLB.reserve(FromTL.getFullDataSize());
15158 QualType To = getDerived().TransformType(TLB, FromTL);
15159 if (To.isNull())
15160 return ExprError();
15161
15162 if (To == From->getType())
15163 Args.push_back(From);
15164 else {
15165 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15166 ArgChanged = true;
15167 }
15168 continue;
15169 }
15170
15171 ArgChanged = true;
15172
15173 // We have a pack expansion. Instantiate it.
15174 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15175 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15177 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15178
15179 // Determine whether the set of unexpanded parameter packs can and should
15180 // be expanded.
15181 bool Expand = true;
15182 bool RetainExpansion = false;
15183 UnsignedOrNone OrigNumExpansions =
15184 ExpansionTL.getTypePtr()->getNumExpansions();
15185 UnsignedOrNone NumExpansions = OrigNumExpansions;
15186 if (getDerived().TryExpandParameterPacks(
15187 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15188 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15189 RetainExpansion, NumExpansions))
15190 return ExprError();
15191
15192 if (!Expand) {
15193 // The transform has determined that we should perform a simple
15194 // transformation on the pack expansion, producing another pack
15195 // expansion.
15196 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15197
15198 TypeLocBuilder TLB;
15199 TLB.reserve(From->getTypeLoc().getFullDataSize());
15200
15201 QualType To = getDerived().TransformType(TLB, PatternTL);
15202 if (To.isNull())
15203 return ExprError();
15204
15205 To = getDerived().RebuildPackExpansionType(To,
15206 PatternTL.getSourceRange(),
15207 ExpansionTL.getEllipsisLoc(),
15208 NumExpansions);
15209 if (To.isNull())
15210 return ExprError();
15211
15212 PackExpansionTypeLoc ToExpansionTL
15213 = TLB.push<PackExpansionTypeLoc>(To);
15214 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15215 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15216 continue;
15217 }
15218
15219 // Expand the pack expansion by substituting for each argument in the
15220 // pack(s).
15221 for (unsigned I = 0; I != *NumExpansions; ++I) {
15222 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15223 TypeLocBuilder TLB;
15224 TLB.reserve(PatternTL.getFullDataSize());
15225 QualType To = getDerived().TransformType(TLB, PatternTL);
15226 if (To.isNull())
15227 return ExprError();
15228
15229 if (To->containsUnexpandedParameterPack()) {
15230 To = getDerived().RebuildPackExpansionType(To,
15231 PatternTL.getSourceRange(),
15232 ExpansionTL.getEllipsisLoc(),
15233 NumExpansions);
15234 if (To.isNull())
15235 return ExprError();
15236
15237 PackExpansionTypeLoc ToExpansionTL
15238 = TLB.push<PackExpansionTypeLoc>(To);
15239 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15240 }
15241
15242 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15243 }
15244
15245 if (!RetainExpansion)
15246 continue;
15247
15248 // If we're supposed to retain a pack expansion, do so by temporarily
15249 // forgetting the partially-substituted parameter pack.
15250 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15251
15252 TypeLocBuilder TLB;
15253 TLB.reserve(From->getTypeLoc().getFullDataSize());
15254
15255 QualType To = getDerived().TransformType(TLB, PatternTL);
15256 if (To.isNull())
15257 return ExprError();
15258
15259 To = getDerived().RebuildPackExpansionType(To,
15260 PatternTL.getSourceRange(),
15261 ExpansionTL.getEllipsisLoc(),
15262 NumExpansions);
15263 if (To.isNull())
15264 return ExprError();
15265
15266 PackExpansionTypeLoc ToExpansionTL
15267 = TLB.push<PackExpansionTypeLoc>(To);
15268 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15269 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15270 }
15271
15272 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15273 return E;
15274
15275 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15276 E->getEndLoc());
15277}
15278
15279template<typename Derived>
15283 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15284 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15285 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15286 Old->NumTemplateArgs, TransArgs))
15287 return ExprError();
15288
15289 return getDerived().RebuildConceptSpecializationExpr(
15290 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15291 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15292 &TransArgs);
15293}
15294
15295template<typename Derived>
15298 SmallVector<ParmVarDecl*, 4> TransParams;
15299 SmallVector<QualType, 4> TransParamTypes;
15300 Sema::ExtParameterInfoBuilder ExtParamInfos;
15301
15302 // C++2a [expr.prim.req]p2
15303 // Expressions appearing within a requirement-body are unevaluated operands.
15307
15309 getSema().Context, getSema().CurContext,
15310 E->getBody()->getBeginLoc());
15311
15312 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15313
15314 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15315 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15316 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15317
15318 for (ParmVarDecl *Param : TransParams)
15319 if (Param)
15320 Param->setDeclContext(Body);
15321
15322 // On failure to transform, TransformRequiresTypeParams returns an expression
15323 // in the event that the transformation of the type params failed in some way.
15324 // It is expected that this will result in a 'not satisfied' Requires clause
15325 // when instantiating.
15326 if (!TypeParamResult.isUnset())
15327 return TypeParamResult;
15328
15330 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15331 TransReqs))
15332 return ExprError();
15333
15334 for (concepts::Requirement *Req : TransReqs) {
15335 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15336 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15337 ER->getReturnTypeRequirement()
15338 .getTypeConstraintTemplateParameterList()->getParam(0)
15339 ->setDeclContext(Body);
15340 }
15341 }
15342 }
15343
15344 return getDerived().RebuildRequiresExpr(
15345 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15346 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15347}
15348
15349template<typename Derived>
15353 for (concepts::Requirement *Req : Reqs) {
15354 concepts::Requirement *TransReq = nullptr;
15355 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15356 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15357 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15358 TransReq = getDerived().TransformExprRequirement(ExprReq);
15359 else
15360 TransReq = getDerived().TransformNestedRequirement(
15362 if (!TransReq)
15363 return true;
15364 Transformed.push_back(TransReq);
15365 }
15366 return false;
15367}
15368
15369template<typename Derived>
15373 if (Req->isSubstitutionFailure()) {
15374 if (getDerived().AlwaysRebuild())
15375 return getDerived().RebuildTypeRequirement(
15377 return Req;
15378 }
15379 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15380 if (!TransType)
15381 return nullptr;
15382 return getDerived().RebuildTypeRequirement(TransType);
15383}
15384
15385template<typename Derived>
15388 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15389 if (Req->isExprSubstitutionFailure())
15390 TransExpr = Req->getExprSubstitutionDiagnostic();
15391 else {
15392 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15393 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15394 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15395 if (TransExprRes.isInvalid())
15396 return nullptr;
15397 TransExpr = TransExprRes.get();
15398 }
15399
15400 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15401 const auto &RetReq = Req->getReturnTypeRequirement();
15402 if (RetReq.isEmpty())
15403 TransRetReq.emplace();
15404 else if (RetReq.isSubstitutionFailure())
15405 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15406 else if (RetReq.isTypeConstraint()) {
15407 TemplateParameterList *OrigTPL =
15408 RetReq.getTypeConstraintTemplateParameterList();
15410 getDerived().TransformTemplateParameterList(OrigTPL);
15411 if (!TPL)
15412 return nullptr;
15413 TransRetReq.emplace(TPL);
15414 }
15415 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15416 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15417 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15418 Req->getNoexceptLoc(),
15419 std::move(*TransRetReq));
15420 return getDerived().RebuildExprRequirement(
15422 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15423}
15424
15425template<typename Derived>
15429 if (Req->hasInvalidConstraint()) {
15430 if (getDerived().AlwaysRebuild())
15431 return getDerived().RebuildNestedRequirement(
15433 return Req;
15434 }
15435 ExprResult TransConstraint =
15436 getDerived().TransformExpr(Req->getConstraintExpr());
15437 if (TransConstraint.isInvalid())
15438 return nullptr;
15439 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15440}
15441
15442template<typename Derived>
15445 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15446 if (!T)
15447 return ExprError();
15448
15449 if (!getDerived().AlwaysRebuild() &&
15450 T == E->getQueriedTypeSourceInfo())
15451 return E;
15452
15453 ExprResult SubExpr;
15454 {
15457 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15458 if (SubExpr.isInvalid())
15459 return ExprError();
15460 }
15461
15462 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15463 SubExpr.get(), E->getEndLoc());
15464}
15465
15466template<typename Derived>
15469 ExprResult SubExpr;
15470 {
15473 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15474 if (SubExpr.isInvalid())
15475 return ExprError();
15476
15477 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15478 return E;
15479 }
15480
15481 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15482 SubExpr.get(), E->getEndLoc());
15483}
15484
15485template <typename Derived>
15487 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15488 TypeSourceInfo **RecoveryTSI) {
15489 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15490 DRE, AddrTaken, RecoveryTSI);
15491
15492 // Propagate both errors and recovered types, which return ExprEmpty.
15493 if (!NewDRE.isUsable())
15494 return NewDRE;
15495
15496 // We got an expr, wrap it up in parens.
15497 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15498 return PE;
15499 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15500 PE->getRParen());
15501}
15502
15503template <typename Derived>
15509
15510template <typename Derived>
15512 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15513 TypeSourceInfo **RecoveryTSI) {
15514 assert(E->getQualifierLoc());
15515 NestedNameSpecifierLoc QualifierLoc =
15516 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15517 if (!QualifierLoc)
15518 return ExprError();
15519 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15520
15521 // TODO: If this is a conversion-function-id, verify that the
15522 // destination type name (if present) resolves the same way after
15523 // instantiation as it did in the local scope.
15524
15525 DeclarationNameInfo NameInfo =
15526 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15527 if (!NameInfo.getName())
15528 return ExprError();
15529
15530 if (!E->hasExplicitTemplateArgs()) {
15531 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15532 // Note: it is sufficient to compare the Name component of NameInfo:
15533 // if name has not changed, DNLoc has not changed either.
15534 NameInfo.getName() == E->getDeclName())
15535 return E;
15536
15537 return getDerived().RebuildDependentScopeDeclRefExpr(
15538 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15539 IsAddressOfOperand, RecoveryTSI);
15540 }
15541
15542 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15543 if (getDerived().TransformTemplateArguments(
15544 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15545 return ExprError();
15546
15547 return getDerived().RebuildDependentScopeDeclRefExpr(
15548 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15549 RecoveryTSI);
15550}
15551
15552template<typename Derived>
15555 // CXXConstructExprs other than for list-initialization and
15556 // CXXTemporaryObjectExpr are always implicit, so when we have
15557 // a 1-argument construction we just transform that argument.
15558 if (getDerived().AllowSkippingCXXConstructExpr() &&
15559 ((E->getNumArgs() == 1 ||
15560 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15561 (!getDerived().DropCallArgument(E->getArg(0))) &&
15562 !E->isListInitialization()))
15563 return getDerived().TransformInitializer(E->getArg(0),
15564 /*DirectInit*/ false);
15565
15566 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15567
15568 QualType T = getDerived().TransformType(E->getType());
15569 if (T.isNull())
15570 return ExprError();
15571
15572 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15573 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15574 if (!Constructor)
15575 return ExprError();
15576
15577 bool ArgumentChanged = false;
15579 {
15582 E->isListInitialization());
15583 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15584 &ArgumentChanged))
15585 return ExprError();
15586 }
15587
15588 if (!getDerived().AlwaysRebuild() &&
15589 T == E->getType() &&
15590 Constructor == E->getConstructor() &&
15591 !ArgumentChanged) {
15592 // Mark the constructor as referenced.
15593 // FIXME: Instantiation-specific
15594 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15595 return E;
15596 }
15597
15598 return getDerived().RebuildCXXConstructExpr(
15599 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15600 E->hadMultipleCandidates(), E->isListInitialization(),
15601 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15602 E->getConstructionKind(), E->getParenOrBraceRange());
15603}
15604
15605template<typename Derived>
15608 QualType T = getDerived().TransformType(E->getType());
15609 if (T.isNull())
15610 return ExprError();
15611
15612 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15613 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15614 if (!Constructor)
15615 return ExprError();
15616
15617 if (!getDerived().AlwaysRebuild() &&
15618 T == E->getType() &&
15619 Constructor == E->getConstructor()) {
15620 // Mark the constructor as referenced.
15621 // FIXME: Instantiation-specific
15622 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15623 return E;
15624 }
15625
15626 return getDerived().RebuildCXXInheritedCtorInitExpr(
15627 T, E->getLocation(), Constructor,
15628 E->constructsVBase(), E->inheritedFromVBase());
15629}
15630
15631/// Transform a C++ temporary-binding expression.
15632///
15633/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15634/// transform the subexpression and return that.
15635template<typename Derived>
15638 if (auto *Dtor = E->getTemporary()->getDestructor())
15639 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15640 const_cast<CXXDestructorDecl *>(Dtor));
15641 return getDerived().TransformExpr(E->getSubExpr());
15642}
15643
15644/// Transform a C++ expression that contains cleanups that should
15645/// be run after the expression is evaluated.
15646///
15647/// Since ExprWithCleanups nodes are implicitly generated, we
15648/// just transform the subexpression and return that.
15649template<typename Derived>
15652 return getDerived().TransformExpr(E->getSubExpr());
15653}
15654
15655template<typename Derived>
15659 TypeSourceInfo *T =
15660 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15661 if (!T)
15662 return ExprError();
15663
15664 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15665 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15666 if (!Constructor)
15667 return ExprError();
15668
15669 bool ArgumentChanged = false;
15671 Args.reserve(E->getNumArgs());
15672 {
15675 E->isListInitialization());
15676 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15677 &ArgumentChanged))
15678 return ExprError();
15679
15680 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15681 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc());
15682 if (Res.isInvalid())
15683 return ExprError();
15684 Args = {Res.get()};
15685 }
15686 }
15687
15688 if (!getDerived().AlwaysRebuild() &&
15689 T == E->getTypeSourceInfo() &&
15690 Constructor == E->getConstructor() &&
15691 !ArgumentChanged) {
15692 // FIXME: Instantiation-specific
15693 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15694 return SemaRef.MaybeBindToTemporary(E);
15695 }
15696
15697 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15698 return getDerived().RebuildCXXTemporaryObjectExpr(
15699 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15700}
15701
15702template<typename Derived>
15705 // Transform any init-capture expressions before entering the scope of the
15706 // lambda body, because they are not semantically within that scope.
15707 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15708 struct TransformedInitCapture {
15709 // The location of the ... if the result is retaining a pack expansion.
15710 SourceLocation EllipsisLoc;
15711 // Zero or more expansions of the init-capture.
15712 SmallVector<InitCaptureInfoTy, 4> Expansions;
15713 };
15715 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15716 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15717 CEnd = E->capture_end();
15718 C != CEnd; ++C) {
15719 if (!E->isInitCapture(C))
15720 continue;
15721
15722 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15723 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15724
15725 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15726 UnsignedOrNone NumExpansions) {
15727 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15728 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15729
15730 if (NewExprInitResult.isInvalid()) {
15731 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15732 return;
15733 }
15734 Expr *NewExprInit = NewExprInitResult.get();
15735
15736 QualType NewInitCaptureType =
15737 getSema().buildLambdaInitCaptureInitialization(
15738 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15739 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15740 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15742 NewExprInit);
15743 Result.Expansions.push_back(
15744 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15745 };
15746
15747 // If this is an init-capture pack, consider expanding the pack now.
15748 if (OldVD->isParameterPack()) {
15749 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15750 ->getTypeLoc()
15753 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15754
15755 // Determine whether the set of unexpanded parameter packs can and should
15756 // be expanded.
15757 bool Expand = true;
15758 bool RetainExpansion = false;
15759 UnsignedOrNone OrigNumExpansions =
15760 ExpansionTL.getTypePtr()->getNumExpansions();
15761 UnsignedOrNone NumExpansions = OrigNumExpansions;
15762 if (getDerived().TryExpandParameterPacks(
15763 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15764 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15765 RetainExpansion, NumExpansions))
15766 return ExprError();
15767 assert(!RetainExpansion && "Should not need to retain expansion after a "
15768 "capture since it cannot be extended");
15769 if (Expand) {
15770 for (unsigned I = 0; I != *NumExpansions; ++I) {
15771 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15772 SubstInitCapture(SourceLocation(), std::nullopt);
15773 }
15774 } else {
15775 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15776 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15777 }
15778 } else {
15779 SubstInitCapture(SourceLocation(), std::nullopt);
15780 }
15781 }
15782
15783 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15784 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15785
15786 // Create the local class that will describe the lambda.
15787
15788 // FIXME: DependencyKind below is wrong when substituting inside a templated
15789 // context that isn't a DeclContext (such as a variable template), or when
15790 // substituting an unevaluated lambda inside of a function's parameter's type
15791 // - as parameter types are not instantiated from within a function's DC. We
15792 // use evaluation contexts to distinguish the function parameter case.
15795 DeclContext *DC = getSema().CurContext;
15796 // A RequiresExprBodyDecl is not interesting for dependencies.
15797 // For the following case,
15798 //
15799 // template <typename>
15800 // concept C = requires { [] {}; };
15801 //
15802 // template <class F>
15803 // struct Widget;
15804 //
15805 // template <C F>
15806 // struct Widget<F> {};
15807 //
15808 // While we are substituting Widget<F>, the parent of DC would be
15809 // the template specialization itself. Thus, the lambda expression
15810 // will be deemed as dependent even if there are no dependent template
15811 // arguments.
15812 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15813 while (DC->isRequiresExprBody())
15814 DC = DC->getParent();
15815 if ((getSema().isUnevaluatedContext() ||
15816 getSema().isConstantEvaluatedContext()) &&
15817 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15818 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
15819 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15820 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15821
15822 CXXRecordDecl *OldClass = E->getLambdaClass();
15823 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15824 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15825 E->getCaptureDefault());
15826 getDerived().transformedLocalDecl(OldClass, {Class});
15827
15828 CXXMethodDecl *NewCallOperator =
15829 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15830
15831 // Enter the scope of the lambda.
15832 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15833 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15834 E->hasExplicitParameters(), E->isMutable());
15835
15836 // Introduce the context of the call operator.
15837 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15838 /*NewThisContext*/false);
15839
15840 bool Invalid = false;
15841
15842 // Transform captures.
15843 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15844 CEnd = E->capture_end();
15845 C != CEnd; ++C) {
15846 // When we hit the first implicit capture, tell Sema that we've finished
15847 // the list of explicit captures.
15848 if (C->isImplicit())
15849 break;
15850
15851 // Capturing 'this' is trivial.
15852 if (C->capturesThis()) {
15853 // If this is a lambda that is part of a default member initialiser
15854 // and which we're instantiating outside the class that 'this' is
15855 // supposed to refer to, adjust the type of 'this' accordingly.
15856 //
15857 // Otherwise, leave the type of 'this' as-is.
15858 Sema::CXXThisScopeRAII ThisScope(
15859 getSema(),
15860 dyn_cast_if_present<CXXRecordDecl>(
15861 getSema().getFunctionLevelDeclContext()),
15862 Qualifiers());
15863 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15864 /*BuildAndDiagnose*/ true, nullptr,
15865 C->getCaptureKind() == LCK_StarThis);
15866 continue;
15867 }
15868 // Captured expression will be recaptured during captured variables
15869 // rebuilding.
15870 if (C->capturesVLAType())
15871 continue;
15872
15873 // Rebuild init-captures, including the implied field declaration.
15874 if (E->isInitCapture(C)) {
15875 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15876
15877 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15879
15880 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15881 ExprResult Init = Info.first;
15882 QualType InitQualType = Info.second;
15883 if (Init.isInvalid() || InitQualType.isNull()) {
15884 Invalid = true;
15885 break;
15886 }
15887 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15888 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15889 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15890 getSema().CurContext);
15891 if (!NewVD) {
15892 Invalid = true;
15893 break;
15894 }
15895 NewVDs.push_back(NewVD);
15896 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15897 // Cases we want to tackle:
15898 // ([C(Pack)] {}, ...)
15899 // But rule out cases e.g.
15900 // [...C = Pack()] {}
15901 if (NewC.EllipsisLoc.isInvalid())
15902 LSI->ContainsUnexpandedParameterPack |=
15903 Init.get()->containsUnexpandedParameterPack();
15904 }
15905
15906 if (Invalid)
15907 break;
15908
15909 getDerived().transformedLocalDecl(OldVD, NewVDs);
15910 continue;
15911 }
15912
15913 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15914
15915 // Determine the capture kind for Sema.
15917 : C->getCaptureKind() == LCK_ByCopy
15920 SourceLocation EllipsisLoc;
15921 if (C->isPackExpansion()) {
15922 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15923 bool ShouldExpand = false;
15924 bool RetainExpansion = false;
15925 UnsignedOrNone NumExpansions = std::nullopt;
15926 if (getDerived().TryExpandParameterPacks(
15927 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
15928 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
15929 RetainExpansion, NumExpansions)) {
15930 Invalid = true;
15931 continue;
15932 }
15933
15934 if (ShouldExpand) {
15935 // The transform has determined that we should perform an expansion;
15936 // transform and capture each of the arguments.
15937 // expansion of the pattern. Do so.
15938 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
15939 for (unsigned I = 0; I != *NumExpansions; ++I) {
15940 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15941 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
15942 getDerived().TransformDecl(C->getLocation(), Pack));
15943 if (!CapturedVar) {
15944 Invalid = true;
15945 continue;
15946 }
15947
15948 // Capture the transformed variable.
15949 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
15950 }
15951
15952 // FIXME: Retain a pack expansion if RetainExpansion is true.
15953
15954 continue;
15955 }
15956
15957 EllipsisLoc = C->getEllipsisLoc();
15958 }
15959
15960 // Transform the captured variable.
15961 auto *CapturedVar = cast_or_null<ValueDecl>(
15962 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15963 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
15964 Invalid = true;
15965 continue;
15966 }
15967
15968 // This is not an init-capture; however it contains an unexpanded pack e.g.
15969 // ([Pack] {}(), ...)
15970 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
15971 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
15972
15973 // Capture the transformed variable.
15974 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
15975 EllipsisLoc);
15976 }
15977 getSema().finishLambdaExplicitCaptures(LSI);
15978
15979 // Transform the template parameters, and add them to the current
15980 // instantiation scope. The null case is handled correctly.
15981 auto TPL = getDerived().TransformTemplateParameterList(
15982 E->getTemplateParameterList());
15983 LSI->GLTemplateParameterList = TPL;
15984 if (TPL) {
15985 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
15986 TPL);
15987 LSI->ContainsUnexpandedParameterPack |=
15988 TPL->containsUnexpandedParameterPack();
15989 }
15990
15991 TypeLocBuilder NewCallOpTLBuilder;
15992 TypeLoc OldCallOpTypeLoc =
15993 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
15994 QualType NewCallOpType =
15995 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
15996 if (NewCallOpType.isNull())
15997 return ExprError();
15998 LSI->ContainsUnexpandedParameterPack |=
15999 NewCallOpType->containsUnexpandedParameterPack();
16000 TypeSourceInfo *NewCallOpTSI =
16001 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
16002
16003 // The type may be an AttributedType or some other kind of sugar;
16004 // get the actual underlying FunctionProtoType.
16005 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
16006 assert(FPTL && "Not a FunctionProtoType?");
16007
16008 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
16009 if (!TRC.ArgPackSubstIndex)
16011
16012 getSema().CompleteLambdaCallOperator(
16013 NewCallOperator, E->getCallOperator()->getLocation(),
16014 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
16015 E->getCallOperator()->getConstexprKind(),
16016 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
16017 E->hasExplicitResultType());
16018
16019 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
16020 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
16021
16022 {
16023 // Number the lambda for linkage purposes if necessary.
16024 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
16025
16026 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
16027 if (getDerived().ReplacingOriginal()) {
16028 Numbering = OldClass->getLambdaNumbering();
16029 }
16030
16031 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
16032 }
16033
16034 // FIXME: Sema's lambda-building mechanism expects us to push an expression
16035 // evaluation context even if we're not transforming the function body.
16036 getSema().PushExpressionEvaluationContextForFunction(
16038 E->getCallOperator());
16039
16040 StmtResult Body;
16041 {
16042 Sema::NonSFINAEContext _(getSema());
16045 C.PointOfInstantiation = E->getBody()->getBeginLoc();
16046 getSema().pushCodeSynthesisContext(C);
16047
16048 // Instantiate the body of the lambda expression.
16049 Body = Invalid ? StmtError()
16050 : getDerived().TransformLambdaBody(E, E->getBody());
16051
16052 getSema().popCodeSynthesisContext();
16053 }
16054
16055 // ActOnLambda* will pop the function scope for us.
16056 FuncScopeCleanup.disable();
16057
16058 if (Body.isInvalid()) {
16059 SavedContext.pop();
16060 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
16061 /*IsInstantiation=*/true);
16062 return ExprError();
16063 }
16064
16065 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
16066 /*IsInstantiation=*/true,
16067 /*RetainFunctionScopeInfo=*/true);
16068 SavedContext.pop();
16069
16070 // Recompute the dependency of the lambda so that we can defer the lambda call
16071 // construction until after we have all the necessary template arguments. For
16072 // example, given
16073 //
16074 // template <class> struct S {
16075 // template <class U>
16076 // using Type = decltype([](U){}(42.0));
16077 // };
16078 // void foo() {
16079 // using T = S<int>::Type<float>;
16080 // ^~~~~~
16081 // }
16082 //
16083 // We would end up here from instantiating S<int> when ensuring its
16084 // completeness. That would transform the lambda call expression regardless of
16085 // the absence of the corresponding argument for U.
16086 //
16087 // Going ahead with unsubstituted type U makes things worse: we would soon
16088 // compare the argument type (which is float) against the parameter U
16089 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
16090 // error suggesting unmatched types 'U' and 'float'!
16091 //
16092 // That said, everything will be fine if we defer that semantic checking.
16093 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
16094 // dependent. Since the CallExpr's dependency boils down to the lambda's
16095 // dependency in this case, we can harness that by recomputing the dependency
16096 // from the instantiation arguments.
16097 //
16098 // FIXME: Creating the type of a lambda requires us to have a dependency
16099 // value, which happens before its substitution. We update its dependency
16100 // *after* the substitution in case we can't decide the dependency
16101 // so early, e.g. because we want to see if any of the *substituted*
16102 // parameters are dependent.
16103 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
16104 Class->setLambdaDependencyKind(DependencyKind);
16105
16106 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
16107 Body.get()->getEndLoc(), LSI);
16108}
16109
16110template<typename Derived>
16115
16116template<typename Derived>
16119 // Transform captures.
16121 CEnd = E->capture_end();
16122 C != CEnd; ++C) {
16123 // When we hit the first implicit capture, tell Sema that we've finished
16124 // the list of explicit captures.
16125 if (!C->isImplicit())
16126 continue;
16127
16128 // Capturing 'this' is trivial.
16129 if (C->capturesThis()) {
16130 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16131 /*BuildAndDiagnose*/ true, nullptr,
16132 C->getCaptureKind() == LCK_StarThis);
16133 continue;
16134 }
16135 // Captured expression will be recaptured during captured variables
16136 // rebuilding.
16137 if (C->capturesVLAType())
16138 continue;
16139
16140 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16141 assert(!E->isInitCapture(C) && "implicit init-capture?");
16142
16143 // Transform the captured variable.
16144 VarDecl *CapturedVar = cast_or_null<VarDecl>(
16145 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16146 if (!CapturedVar || CapturedVar->isInvalidDecl())
16147 return StmtError();
16148
16149 // Capture the transformed variable.
16150 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16151 }
16152
16153 return S;
16154}
16155
16156template<typename Derived>
16160 TypeSourceInfo *T =
16161 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16162 if (!T)
16163 return ExprError();
16164
16165 bool ArgumentChanged = false;
16167 Args.reserve(E->getNumArgs());
16168 {
16172 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16173 &ArgumentChanged))
16174 return ExprError();
16175 }
16176
16177 if (!getDerived().AlwaysRebuild() &&
16178 T == E->getTypeSourceInfo() &&
16179 !ArgumentChanged)
16180 return E;
16181
16182 // FIXME: we're faking the locations of the commas
16183 return getDerived().RebuildCXXUnresolvedConstructExpr(
16184 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16185}
16186
16187template<typename Derived>
16191 // Transform the base of the expression.
16192 ExprResult Base((Expr*) nullptr);
16193 Expr *OldBase;
16194 QualType BaseType;
16195 QualType ObjectType;
16196 if (!E->isImplicitAccess()) {
16197 OldBase = E->getBase();
16198 Base = getDerived().TransformExpr(OldBase);
16199 if (Base.isInvalid())
16200 return ExprError();
16201
16202 // Start the member reference and compute the object's type.
16203 ParsedType ObjectTy;
16204 bool MayBePseudoDestructor = false;
16205 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16206 E->getOperatorLoc(),
16207 E->isArrow()? tok::arrow : tok::period,
16208 ObjectTy,
16209 MayBePseudoDestructor);
16210 if (Base.isInvalid())
16211 return ExprError();
16212
16213 ObjectType = ObjectTy.get();
16214 BaseType = ((Expr*) Base.get())->getType();
16215 } else {
16216 OldBase = nullptr;
16217 BaseType = getDerived().TransformType(E->getBaseType());
16218 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16219 }
16220
16221 // Transform the first part of the nested-name-specifier that qualifies
16222 // the member name.
16223 NamedDecl *FirstQualifierInScope
16224 = getDerived().TransformFirstQualifierInScope(
16225 E->getFirstQualifierFoundInScope(),
16226 E->getQualifierLoc().getBeginLoc());
16227
16228 NestedNameSpecifierLoc QualifierLoc;
16229 if (E->getQualifier()) {
16230 QualifierLoc
16231 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16232 ObjectType,
16233 FirstQualifierInScope);
16234 if (!QualifierLoc)
16235 return ExprError();
16236 }
16237
16238 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16239
16240 // TODO: If this is a conversion-function-id, verify that the
16241 // destination type name (if present) resolves the same way after
16242 // instantiation as it did in the local scope.
16243
16244 DeclarationNameInfo NameInfo
16245 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16246 if (!NameInfo.getName())
16247 return ExprError();
16248
16249 if (!E->hasExplicitTemplateArgs()) {
16250 // This is a reference to a member without an explicitly-specified
16251 // template argument list. Optimize for this common case.
16252 if (!getDerived().AlwaysRebuild() &&
16253 Base.get() == OldBase &&
16254 BaseType == E->getBaseType() &&
16255 QualifierLoc == E->getQualifierLoc() &&
16256 NameInfo.getName() == E->getMember() &&
16257 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16258 return E;
16259
16260 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16261 BaseType,
16262 E->isArrow(),
16263 E->getOperatorLoc(),
16264 QualifierLoc,
16265 TemplateKWLoc,
16266 FirstQualifierInScope,
16267 NameInfo,
16268 /*TemplateArgs*/nullptr);
16269 }
16270
16271 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16272 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16273 E->getNumTemplateArgs(),
16274 TransArgs))
16275 return ExprError();
16276
16277 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16278 BaseType,
16279 E->isArrow(),
16280 E->getOperatorLoc(),
16281 QualifierLoc,
16282 TemplateKWLoc,
16283 FirstQualifierInScope,
16284 NameInfo,
16285 &TransArgs);
16286}
16287
16288template <typename Derived>
16290 UnresolvedMemberExpr *Old) {
16291 // Transform the base of the expression.
16292 ExprResult Base((Expr *)nullptr);
16293 QualType BaseType;
16294 if (!Old->isImplicitAccess()) {
16295 Base = getDerived().TransformExpr(Old->getBase());
16296 if (Base.isInvalid())
16297 return ExprError();
16298 Base =
16299 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16300 if (Base.isInvalid())
16301 return ExprError();
16302 BaseType = Base.get()->getType();
16303 } else {
16304 BaseType = getDerived().TransformType(Old->getBaseType());
16305 }
16306
16307 NestedNameSpecifierLoc QualifierLoc;
16308 if (Old->getQualifierLoc()) {
16309 QualifierLoc =
16310 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16311 if (!QualifierLoc)
16312 return ExprError();
16313 }
16314
16315 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16316
16317 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16318
16319 // Transform the declaration set.
16320 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16321 return ExprError();
16322
16323 // Determine the naming class.
16324 if (Old->getNamingClass()) {
16325 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16326 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16327 if (!NamingClass)
16328 return ExprError();
16329
16330 R.setNamingClass(NamingClass);
16331 }
16332
16333 TemplateArgumentListInfo TransArgs;
16334 if (Old->hasExplicitTemplateArgs()) {
16335 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16336 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16337 if (getDerived().TransformTemplateArguments(
16338 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16339 return ExprError();
16340 }
16341
16342 // FIXME: to do this check properly, we will need to preserve the
16343 // first-qualifier-in-scope here, just in case we had a dependent
16344 // base (and therefore couldn't do the check) and a
16345 // nested-name-qualifier (and therefore could do the lookup).
16346 NamedDecl *FirstQualifierInScope = nullptr;
16347
16348 return getDerived().RebuildUnresolvedMemberExpr(
16349 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16350 TemplateKWLoc, FirstQualifierInScope, R,
16351 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16352}
16353
16354template<typename Derived>
16359 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16360 if (SubExpr.isInvalid())
16361 return ExprError();
16362
16363 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16364 return E;
16365
16366 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16367}
16368
16369template<typename Derived>
16372 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16373 if (Pattern.isInvalid())
16374 return ExprError();
16375
16376 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16377 return E;
16378
16379 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16380 E->getNumExpansions());
16381}
16382
16383template <typename Derived>
16385 ArrayRef<TemplateArgument> PackArgs) {
16387 for (const TemplateArgument &Arg : PackArgs) {
16388 if (!Arg.isPackExpansion()) {
16389 Result = *Result + 1;
16390 continue;
16391 }
16392
16393 TemplateArgumentLoc ArgLoc;
16394 InventTemplateArgumentLoc(Arg, ArgLoc);
16395
16396 // Find the pattern of the pack expansion.
16397 SourceLocation Ellipsis;
16398 UnsignedOrNone OrigNumExpansions = std::nullopt;
16399 TemplateArgumentLoc Pattern =
16400 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16401 OrigNumExpansions);
16402
16403 // Substitute under the pack expansion. Do not expand the pack (yet).
16404 TemplateArgumentLoc OutPattern;
16405 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16406 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16407 /*Uneval*/ true))
16408 return 1u;
16409
16410 // See if we can determine the number of arguments from the result.
16411 UnsignedOrNone NumExpansions =
16412 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16413 if (!NumExpansions) {
16414 // No: we must be in an alias template expansion, and we're going to
16415 // need to actually expand the packs.
16416 Result = std::nullopt;
16417 break;
16418 }
16419
16420 Result = *Result + *NumExpansions;
16421 }
16422 return Result;
16423}
16424
16425template<typename Derived>
16428 // If E is not value-dependent, then nothing will change when we transform it.
16429 // Note: This is an instantiation-centric view.
16430 if (!E->isValueDependent())
16431 return E;
16432
16435
16437 TemplateArgument ArgStorage;
16438
16439 // Find the argument list to transform.
16440 if (E->isPartiallySubstituted()) {
16441 PackArgs = E->getPartialArguments();
16442 } else if (E->isValueDependent()) {
16443 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16444 bool ShouldExpand = false;
16445 bool RetainExpansion = false;
16446 UnsignedOrNone NumExpansions = std::nullopt;
16447 if (getDerived().TryExpandParameterPacks(
16448 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16449 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16450 RetainExpansion, NumExpansions))
16451 return ExprError();
16452
16453 // If we need to expand the pack, build a template argument from it and
16454 // expand that.
16455 if (ShouldExpand) {
16456 auto *Pack = E->getPack();
16457 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16458 ArgStorage = getSema().Context.getPackExpansionType(
16459 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16460 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16461 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16462 } else {
16463 auto *VD = cast<ValueDecl>(Pack);
16464 ExprResult DRE = getSema().BuildDeclRefExpr(
16465 VD, VD->getType().getNonLValueExprType(getSema().Context),
16466 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16467 E->getPackLoc());
16468 if (DRE.isInvalid())
16469 return ExprError();
16470 ArgStorage = TemplateArgument(
16471 new (getSema().Context)
16472 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16473 /*IsCanonical=*/false);
16474 }
16475 PackArgs = ArgStorage;
16476 }
16477 }
16478
16479 // If we're not expanding the pack, just transform the decl.
16480 if (!PackArgs.size()) {
16481 auto *Pack = cast_or_null<NamedDecl>(
16482 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16483 if (!Pack)
16484 return ExprError();
16485 return getDerived().RebuildSizeOfPackExpr(
16486 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16487 std::nullopt, {});
16488 }
16489
16490 // Try to compute the result without performing a partial substitution.
16492 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16493
16494 // Common case: we could determine the number of expansions without
16495 // substituting.
16496 if (Result)
16497 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16498 E->getPackLoc(),
16499 E->getRParenLoc(), *Result, {});
16500
16501 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16502 E->getPackLoc());
16503 {
16504 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16506 Derived, const TemplateArgument*> PackLocIterator;
16507 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16508 PackLocIterator(*this, PackArgs.end()),
16509 TransformedPackArgs, /*Uneval*/true))
16510 return ExprError();
16511 }
16512
16513 // Check whether we managed to fully-expand the pack.
16514 // FIXME: Is it possible for us to do so and not hit the early exit path?
16516 bool PartialSubstitution = false;
16517 for (auto &Loc : TransformedPackArgs.arguments()) {
16518 Args.push_back(Loc.getArgument());
16519 if (Loc.getArgument().isPackExpansion())
16520 PartialSubstitution = true;
16521 }
16522
16523 if (PartialSubstitution)
16524 return getDerived().RebuildSizeOfPackExpr(
16525 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16526 std::nullopt, Args);
16527
16528 return getDerived().RebuildSizeOfPackExpr(
16529 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16530 /*Length=*/static_cast<unsigned>(Args.size()),
16531 /*PartialArgs=*/{});
16532}
16533
16534template <typename Derived>
16537 if (!E->isValueDependent())
16538 return E;
16539
16540 // Transform the index
16541 ExprResult IndexExpr;
16542 {
16543 EnterExpressionEvaluationContext ConstantContext(
16545 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16546 if (IndexExpr.isInvalid())
16547 return ExprError();
16548 }
16549
16550 SmallVector<Expr *, 5> ExpandedExprs;
16551 bool FullySubstituted = true;
16552 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16553 Expr *Pattern = E->getPackIdExpression();
16555 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16556 Unexpanded);
16557 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16558
16559 // Determine whether the set of unexpanded parameter packs can and should
16560 // be expanded.
16561 bool ShouldExpand = true;
16562 bool RetainExpansion = false;
16563 UnsignedOrNone OrigNumExpansions = std::nullopt,
16564 NumExpansions = std::nullopt;
16565 if (getDerived().TryExpandParameterPacks(
16566 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16567 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16568 RetainExpansion, NumExpansions))
16569 return true;
16570 if (!ShouldExpand) {
16571 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16572 ExprResult Pack = getDerived().TransformExpr(Pattern);
16573 if (Pack.isInvalid())
16574 return ExprError();
16575 return getDerived().RebuildPackIndexingExpr(
16576 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16577 {}, /*FullySubstituted=*/false);
16578 }
16579 for (unsigned I = 0; I != *NumExpansions; ++I) {
16580 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16581 ExprResult Out = getDerived().TransformExpr(Pattern);
16582 if (Out.isInvalid())
16583 return true;
16584 if (Out.get()->containsUnexpandedParameterPack()) {
16585 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16586 OrigNumExpansions);
16587 if (Out.isInvalid())
16588 return true;
16589 FullySubstituted = false;
16590 }
16591 ExpandedExprs.push_back(Out.get());
16592 }
16593 // If we're supposed to retain a pack expansion, do so by temporarily
16594 // forgetting the partially-substituted parameter pack.
16595 if (RetainExpansion) {
16596 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16597
16598 ExprResult Out = getDerived().TransformExpr(Pattern);
16599 if (Out.isInvalid())
16600 return true;
16601
16602 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16603 OrigNumExpansions);
16604 if (Out.isInvalid())
16605 return true;
16606 FullySubstituted = false;
16607 ExpandedExprs.push_back(Out.get());
16608 }
16609 } else if (!E->expandsToEmptyPack()) {
16610 if (getDerived().TransformExprs(E->getExpressions().data(),
16611 E->getExpressions().size(), false,
16612 ExpandedExprs))
16613 return ExprError();
16614 }
16615
16616 return getDerived().RebuildPackIndexingExpr(
16617 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16618 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16619}
16620
16621template <typename Derived>
16624 if (!getSema().ArgPackSubstIndex)
16625 // We aren't expanding the parameter pack, so just return ourselves.
16626 return E;
16627
16628 TemplateArgument Pack = E->getArgumentPack();
16630 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16631 E->getAssociatedDecl(), E->getParameterPack(),
16632 E->getParameterPackLocation(), Arg, SemaRef.getPackIndex(Pack),
16633 E->getFinal());
16634}
16635
16636template <typename Derived>
16639 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16640 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16641 if (Replacement.isInvalid())
16642 return true;
16643
16644 Decl *AssociatedDecl =
16645 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16646 if (!AssociatedDecl)
16647 return true;
16648
16649 if (Replacement.get() == OrigReplacement &&
16650 AssociatedDecl == E->getAssociatedDecl())
16651 return E;
16652
16653 auto getParamAndType = [E](Decl *AssociatedDecl)
16654 -> std::tuple<NonTypeTemplateParmDecl *, QualType> {
16655 auto [PDecl, Arg] =
16656 getReplacedTemplateParameter(AssociatedDecl, E->getIndex());
16657 auto *Param = cast<NonTypeTemplateParmDecl>(PDecl);
16658 if (Arg.isNull())
16659 return {Param, Param->getType()};
16660 if (UnsignedOrNone PackIndex = E->getPackIndex())
16661 Arg = Arg.getPackAsArray()[*PackIndex];
16662 return {Param, Arg.getNonTypeTemplateArgumentType()};
16663 };
16664
16665 // If the replacement expression did not change, and the parameter type
16666 // did not change, we can skip the semantic action because it would
16667 // produce the same result anyway.
16668 if (auto [Param, ParamType] = getParamAndType(AssociatedDecl);
16669 !SemaRef.Context.hasSameType(
16670 ParamType, std::get<1>(getParamAndType(E->getAssociatedDecl()))) ||
16671 Replacement.get() != OrigReplacement) {
16672 // When transforming the replacement expression previously, all Sema
16673 // specific annotations, such as implicit casts, are discarded. Calling the
16674 // corresponding sema action is necessary to recover those. Otherwise,
16675 // equivalency of the result would be lost.
16676 TemplateArgument SugaredConverted, CanonicalConverted;
16677 Replacement = SemaRef.CheckTemplateArgument(
16678 Param, ParamType, Replacement.get(), SugaredConverted,
16679 CanonicalConverted,
16680 /*StrictCheck=*/false, Sema::CTAK_Specified);
16681 if (Replacement.isInvalid())
16682 return true;
16683 } else {
16684 // Otherwise, the same expression would have been produced.
16685 Replacement = E->getReplacement();
16686 }
16687
16688 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16689 AssociatedDecl, E->getParameter(), E->getNameLoc(),
16690 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
16691 E->getPackIndex(), E->getFinal());
16692}
16693
16694template<typename Derived>
16697 // Default behavior is to do nothing with this transformation.
16698 return E;
16699}
16700
16701template<typename Derived>
16705 return getDerived().TransformExpr(E->getSubExpr());
16706}
16707
16708template<typename Derived>
16711 UnresolvedLookupExpr *Callee = nullptr;
16712 if (Expr *OldCallee = E->getCallee()) {
16713 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16714 if (CalleeResult.isInvalid())
16715 return ExprError();
16716 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16717 }
16718
16719 Expr *Pattern = E->getPattern();
16720
16722 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16723 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16724
16725 // Determine whether the set of unexpanded parameter packs can and should
16726 // be expanded.
16727 bool Expand = true;
16728 bool RetainExpansion = false;
16729 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16730 NumExpansions = OrigNumExpansions;
16731 if (getDerived().TryExpandParameterPacks(
16732 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16733 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16734 NumExpansions))
16735 return true;
16736
16737 if (!Expand) {
16738 // Do not expand any packs here, just transform and rebuild a fold
16739 // expression.
16740 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16741
16742 ExprResult LHS =
16743 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16744 if (LHS.isInvalid())
16745 return true;
16746
16747 ExprResult RHS =
16748 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16749 if (RHS.isInvalid())
16750 return true;
16751
16752 if (!getDerived().AlwaysRebuild() &&
16753 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16754 return E;
16755
16756 return getDerived().RebuildCXXFoldExpr(
16757 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16758 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16759 }
16760
16761 // Formally a fold expression expands to nested parenthesized expressions.
16762 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16763 // them.
16764 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16765 SemaRef.Diag(E->getEllipsisLoc(),
16766 clang::diag::err_fold_expression_limit_exceeded)
16767 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16768 << E->getSourceRange();
16769 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16770 return ExprError();
16771 }
16772
16773 // The transform has determined that we should perform an elementwise
16774 // expansion of the pattern. Do so.
16775 ExprResult Result = getDerived().TransformExpr(E->getInit());
16776 if (Result.isInvalid())
16777 return true;
16778 bool LeftFold = E->isLeftFold();
16779
16780 // If we're retaining an expansion for a right fold, it is the innermost
16781 // component and takes the init (if any).
16782 if (!LeftFold && RetainExpansion) {
16783 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16784
16785 ExprResult Out = getDerived().TransformExpr(Pattern);
16786 if (Out.isInvalid())
16787 return true;
16788
16789 Result = getDerived().RebuildCXXFoldExpr(
16790 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16791 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16792 if (Result.isInvalid())
16793 return true;
16794 }
16795
16796 bool WarnedOnComparison = false;
16797 for (unsigned I = 0; I != *NumExpansions; ++I) {
16798 Sema::ArgPackSubstIndexRAII SubstIndex(
16799 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16800 ExprResult Out = getDerived().TransformExpr(Pattern);
16801 if (Out.isInvalid())
16802 return true;
16803
16804 if (Out.get()->containsUnexpandedParameterPack()) {
16805 // We still have a pack; retain a pack expansion for this slice.
16806 Result = getDerived().RebuildCXXFoldExpr(
16807 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16808 E->getOperator(), E->getEllipsisLoc(),
16809 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16810 OrigNumExpansions);
16811 } else if (Result.isUsable()) {
16812 // We've got down to a single element; build a binary operator.
16813 Expr *LHS = LeftFold ? Result.get() : Out.get();
16814 Expr *RHS = LeftFold ? Out.get() : Result.get();
16815 if (Callee) {
16816 UnresolvedSet<16> Functions;
16817 Functions.append(Callee->decls_begin(), Callee->decls_end());
16818 Result = getDerived().RebuildCXXOperatorCallExpr(
16819 BinaryOperator::getOverloadedOperator(E->getOperator()),
16820 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16821 Functions, LHS, RHS);
16822 } else {
16823 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16824 E->getOperator(), LHS, RHS,
16825 /*ForFoldExpresion=*/true);
16826 if (!WarnedOnComparison && Result.isUsable()) {
16827 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16828 BO && BO->isComparisonOp()) {
16829 WarnedOnComparison = true;
16830 SemaRef.Diag(BO->getBeginLoc(),
16831 diag::warn_comparison_in_fold_expression)
16832 << BO->getOpcodeStr();
16833 }
16834 }
16835 }
16836 } else
16837 Result = Out;
16838
16839 if (Result.isInvalid())
16840 return true;
16841 }
16842
16843 // If we're retaining an expansion for a left fold, it is the outermost
16844 // component and takes the complete expansion so far as its init (if any).
16845 if (LeftFold && RetainExpansion) {
16846 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16847
16848 ExprResult Out = getDerived().TransformExpr(Pattern);
16849 if (Out.isInvalid())
16850 return true;
16851
16852 Result = getDerived().RebuildCXXFoldExpr(
16853 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16854 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16855 if (Result.isInvalid())
16856 return true;
16857 }
16858
16859 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16860 PE->setIsProducedByFoldExpansion();
16861
16862 // If we had no init and an empty pack, and we're not retaining an expansion,
16863 // then produce a fallback value or error.
16864 if (Result.isUnset())
16865 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16866 E->getOperator());
16867 return Result;
16868}
16869
16870template <typename Derived>
16873 SmallVector<Expr *, 4> TransformedInits;
16874 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16875
16876 QualType T = getDerived().TransformType(E->getType());
16877
16878 bool ArgChanged = false;
16879
16880 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16881 TransformedInits, &ArgChanged))
16882 return ExprError();
16883
16884 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16885 return E;
16886
16887 return getDerived().RebuildCXXParenListInitExpr(
16888 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16889 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16890}
16891
16892template<typename Derived>
16896 return getDerived().TransformExpr(E->getSubExpr());
16897}
16898
16899template<typename Derived>
16902 return SemaRef.MaybeBindToTemporary(E);
16903}
16904
16905template<typename Derived>
16908 return E;
16909}
16910
16911template<typename Derived>
16914 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16915 if (SubExpr.isInvalid())
16916 return ExprError();
16917
16918 if (!getDerived().AlwaysRebuild() &&
16919 SubExpr.get() == E->getSubExpr())
16920 return E;
16921
16922 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16923}
16924
16925template<typename Derived>
16928 // Transform each of the elements.
16929 SmallVector<Expr *, 8> Elements;
16930 bool ArgChanged = false;
16931 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
16932 /*IsCall=*/false, Elements, &ArgChanged))
16933 return ExprError();
16934
16935 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16936 return SemaRef.MaybeBindToTemporary(E);
16937
16938 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
16939 Elements.data(),
16940 Elements.size());
16941}
16942
16943template<typename Derived>
16947 // Transform each of the elements.
16949 bool ArgChanged = false;
16950 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
16951 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
16952
16953 if (OrigElement.isPackExpansion()) {
16954 // This key/value element is a pack expansion.
16956 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
16957 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
16958 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16959
16960 // Determine whether the set of unexpanded parameter packs can
16961 // and should be expanded.
16962 bool Expand = true;
16963 bool RetainExpansion = false;
16964 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
16965 UnsignedOrNone NumExpansions = OrigNumExpansions;
16966 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
16967 OrigElement.Value->getEndLoc());
16968 if (getDerived().TryExpandParameterPacks(
16969 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
16970 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16971 NumExpansions))
16972 return ExprError();
16973
16974 if (!Expand) {
16975 // The transform has determined that we should perform a simple
16976 // transformation on the pack expansion, producing another pack
16977 // expansion.
16978 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16979 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16980 if (Key.isInvalid())
16981 return ExprError();
16982
16983 if (Key.get() != OrigElement.Key)
16984 ArgChanged = true;
16985
16986 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16987 if (Value.isInvalid())
16988 return ExprError();
16989
16990 if (Value.get() != OrigElement.Value)
16991 ArgChanged = true;
16992
16993 ObjCDictionaryElement Expansion = {
16994 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
16995 };
16996 Elements.push_back(Expansion);
16997 continue;
16998 }
16999
17000 // Record right away that the argument was changed. This needs
17001 // to happen even if the array expands to nothing.
17002 ArgChanged = true;
17003
17004 // The transform has determined that we should perform an elementwise
17005 // expansion of the pattern. Do so.
17006 for (unsigned I = 0; I != *NumExpansions; ++I) {
17007 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
17008 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17009 if (Key.isInvalid())
17010 return ExprError();
17011
17012 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
17013 if (Value.isInvalid())
17014 return ExprError();
17015
17016 ObjCDictionaryElement Element = {
17017 Key.get(), Value.get(), SourceLocation(), NumExpansions
17018 };
17019
17020 // If any unexpanded parameter packs remain, we still have a
17021 // pack expansion.
17022 // FIXME: Can this really happen?
17023 if (Key.get()->containsUnexpandedParameterPack() ||
17024 Value.get()->containsUnexpandedParameterPack())
17025 Element.EllipsisLoc = OrigElement.EllipsisLoc;
17026
17027 Elements.push_back(Element);
17028 }
17029
17030 // FIXME: Retain a pack expansion if RetainExpansion is true.
17031
17032 // We've finished with this pack expansion.
17033 continue;
17034 }
17035
17036 // Transform and check key.
17037 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17038 if (Key.isInvalid())
17039 return ExprError();
17040
17041 if (Key.get() != OrigElement.Key)
17042 ArgChanged = true;
17043
17044 // Transform and check value.
17046 = getDerived().TransformExpr(OrigElement.Value);
17047 if (Value.isInvalid())
17048 return ExprError();
17049
17050 if (Value.get() != OrigElement.Value)
17051 ArgChanged = true;
17052
17053 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
17054 std::nullopt};
17055 Elements.push_back(Element);
17056 }
17057
17058 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17059 return SemaRef.MaybeBindToTemporary(E);
17060
17061 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
17062 Elements);
17063}
17064
17065template<typename Derived>
17068 TypeSourceInfo *EncodedTypeInfo
17069 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
17070 if (!EncodedTypeInfo)
17071 return ExprError();
17072
17073 if (!getDerived().AlwaysRebuild() &&
17074 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
17075 return E;
17076
17077 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
17078 EncodedTypeInfo,
17079 E->getRParenLoc());
17080}
17081
17082template<typename Derived>
17085 // This is a kind of implicit conversion, and it needs to get dropped
17086 // and recomputed for the same general reasons that ImplicitCastExprs
17087 // do, as well a more specific one: this expression is only valid when
17088 // it appears *immediately* as an argument expression.
17089 return getDerived().TransformExpr(E->getSubExpr());
17090}
17091
17092template<typename Derived>
17095 TypeSourceInfo *TSInfo
17096 = getDerived().TransformType(E->getTypeInfoAsWritten());
17097 if (!TSInfo)
17098 return ExprError();
17099
17100 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
17101 if (Result.isInvalid())
17102 return ExprError();
17103
17104 if (!getDerived().AlwaysRebuild() &&
17105 TSInfo == E->getTypeInfoAsWritten() &&
17106 Result.get() == E->getSubExpr())
17107 return E;
17108
17109 return SemaRef.ObjC().BuildObjCBridgedCast(
17110 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
17111 Result.get());
17112}
17113
17114template <typename Derived>
17117 return E;
17118}
17119
17120template<typename Derived>
17123 // Transform arguments.
17124 bool ArgChanged = false;
17126 Args.reserve(E->getNumArgs());
17127 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
17128 &ArgChanged))
17129 return ExprError();
17130
17131 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
17132 // Class message: transform the receiver type.
17133 TypeSourceInfo *ReceiverTypeInfo
17134 = getDerived().TransformType(E->getClassReceiverTypeInfo());
17135 if (!ReceiverTypeInfo)
17136 return ExprError();
17137
17138 // If nothing changed, just retain the existing message send.
17139 if (!getDerived().AlwaysRebuild() &&
17140 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
17141 return SemaRef.MaybeBindToTemporary(E);
17142
17143 // Build a new class message send.
17145 E->getSelectorLocs(SelLocs);
17146 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
17147 E->getSelector(),
17148 SelLocs,
17149 E->getMethodDecl(),
17150 E->getLeftLoc(),
17151 Args,
17152 E->getRightLoc());
17153 }
17154 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17155 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17156 if (!E->getMethodDecl())
17157 return ExprError();
17158
17159 // Build a new class message send to 'super'.
17161 E->getSelectorLocs(SelLocs);
17162 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17163 E->getSelector(),
17164 SelLocs,
17165 E->getReceiverType(),
17166 E->getMethodDecl(),
17167 E->getLeftLoc(),
17168 Args,
17169 E->getRightLoc());
17170 }
17171
17172 // Instance message: transform the receiver
17173 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17174 "Only class and instance messages may be instantiated");
17175 ExprResult Receiver
17176 = getDerived().TransformExpr(E->getInstanceReceiver());
17177 if (Receiver.isInvalid())
17178 return ExprError();
17179
17180 // If nothing changed, just retain the existing message send.
17181 if (!getDerived().AlwaysRebuild() &&
17182 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17183 return SemaRef.MaybeBindToTemporary(E);
17184
17185 // Build a new instance message send.
17187 E->getSelectorLocs(SelLocs);
17188 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17189 E->getSelector(),
17190 SelLocs,
17191 E->getMethodDecl(),
17192 E->getLeftLoc(),
17193 Args,
17194 E->getRightLoc());
17195}
17196
17197template<typename Derived>
17200 return E;
17201}
17202
17203template<typename Derived>
17206 return E;
17207}
17208
17209template<typename Derived>
17212 // Transform the base expression.
17213 ExprResult Base = getDerived().TransformExpr(E->getBase());
17214 if (Base.isInvalid())
17215 return ExprError();
17216
17217 // We don't need to transform the ivar; it will never change.
17218
17219 // If nothing changed, just retain the existing expression.
17220 if (!getDerived().AlwaysRebuild() &&
17221 Base.get() == E->getBase())
17222 return E;
17223
17224 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17225 E->getLocation(),
17226 E->isArrow(), E->isFreeIvar());
17227}
17228
17229template<typename Derived>
17232 // 'super' and types never change. Property never changes. Just
17233 // retain the existing expression.
17234 if (!E->isObjectReceiver())
17235 return E;
17236
17237 // Transform the base expression.
17238 ExprResult Base = getDerived().TransformExpr(E->getBase());
17239 if (Base.isInvalid())
17240 return ExprError();
17241
17242 // We don't need to transform the property; it will never change.
17243
17244 // If nothing changed, just retain the existing expression.
17245 if (!getDerived().AlwaysRebuild() &&
17246 Base.get() == E->getBase())
17247 return E;
17248
17249 if (E->isExplicitProperty())
17250 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17251 E->getExplicitProperty(),
17252 E->getLocation());
17253
17254 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17255 SemaRef.Context.PseudoObjectTy,
17256 E->getImplicitPropertyGetter(),
17257 E->getImplicitPropertySetter(),
17258 E->getLocation());
17259}
17260
17261template<typename Derived>
17264 // Transform the base expression.
17265 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17266 if (Base.isInvalid())
17267 return ExprError();
17268
17269 // Transform the key expression.
17270 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17271 if (Key.isInvalid())
17272 return ExprError();
17273
17274 // If nothing changed, just retain the existing expression.
17275 if (!getDerived().AlwaysRebuild() &&
17276 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17277 return E;
17278
17279 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17280 Base.get(), Key.get(),
17281 E->getAtIndexMethodDecl(),
17282 E->setAtIndexMethodDecl());
17283}
17284
17285template<typename Derived>
17288 // Transform the base expression.
17289 ExprResult Base = getDerived().TransformExpr(E->getBase());
17290 if (Base.isInvalid())
17291 return ExprError();
17292
17293 // If nothing changed, just retain the existing expression.
17294 if (!getDerived().AlwaysRebuild() &&
17295 Base.get() == E->getBase())
17296 return E;
17297
17298 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17299 E->getOpLoc(),
17300 E->isArrow());
17301}
17302
17303template<typename Derived>
17306 bool ArgumentChanged = false;
17307 SmallVector<Expr*, 8> SubExprs;
17308 SubExprs.reserve(E->getNumSubExprs());
17309 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17310 SubExprs, &ArgumentChanged))
17311 return ExprError();
17312
17313 if (!getDerived().AlwaysRebuild() &&
17314 !ArgumentChanged)
17315 return E;
17316
17317 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17318 SubExprs,
17319 E->getRParenLoc());
17320}
17321
17322template<typename Derived>
17325 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17326 if (SrcExpr.isInvalid())
17327 return ExprError();
17328
17329 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17330 if (!Type)
17331 return ExprError();
17332
17333 if (!getDerived().AlwaysRebuild() &&
17334 Type == E->getTypeSourceInfo() &&
17335 SrcExpr.get() == E->getSrcExpr())
17336 return E;
17337
17338 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17339 SrcExpr.get(), Type,
17340 E->getRParenLoc());
17341}
17342
17343template<typename Derived>
17346 BlockDecl *oldBlock = E->getBlockDecl();
17347
17348 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17349 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17350
17351 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17352 blockScope->TheDecl->setBlockMissingReturnType(
17353 oldBlock->blockMissingReturnType());
17354
17356 SmallVector<QualType, 4> paramTypes;
17357
17358 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17359
17360 // Parameter substitution.
17361 Sema::ExtParameterInfoBuilder extParamInfos;
17362 if (getDerived().TransformFunctionTypeParams(
17363 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17364 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17365 extParamInfos)) {
17366 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17367 return ExprError();
17368 }
17369
17370 QualType exprResultType =
17371 getDerived().TransformType(exprFunctionType->getReturnType());
17372
17373 auto epi = exprFunctionType->getExtProtoInfo();
17374 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17375
17377 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17378 blockScope->FunctionType = functionType;
17379
17380 // Set the parameters on the block decl.
17381 if (!params.empty())
17382 blockScope->TheDecl->setParams(params);
17383
17384 if (!oldBlock->blockMissingReturnType()) {
17385 blockScope->HasImplicitReturnType = false;
17386 blockScope->ReturnType = exprResultType;
17387 }
17388
17389 // Transform the body
17390 StmtResult body = getDerived().TransformStmt(E->getBody());
17391 if (body.isInvalid()) {
17392 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17393 return ExprError();
17394 }
17395
17396#ifndef NDEBUG
17397 // In builds with assertions, make sure that we captured everything we
17398 // captured before.
17399 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17400 for (const auto &I : oldBlock->captures()) {
17401 VarDecl *oldCapture = I.getVariable();
17402
17403 // Ignore parameter packs.
17404 if (oldCapture->isParameterPack())
17405 continue;
17406
17407 VarDecl *newCapture =
17408 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17409 oldCapture));
17410 assert(blockScope->CaptureMap.count(newCapture));
17411 }
17412
17413 // The this pointer may not be captured by the instantiated block, even when
17414 // it's captured by the original block, if the expression causing the
17415 // capture is in the discarded branch of a constexpr if statement.
17416 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17417 "this pointer isn't captured in the old block");
17418 }
17419#endif
17420
17421 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17422 /*Scope=*/nullptr);
17423}
17424
17425template<typename Derived>
17428 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17429 if (SrcExpr.isInvalid())
17430 return ExprError();
17431
17432 QualType Type = getDerived().TransformType(E->getType());
17433
17434 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17435 E->getRParenLoc());
17436}
17437
17438template<typename Derived>
17441 bool ArgumentChanged = false;
17442 SmallVector<Expr*, 8> SubExprs;
17443 SubExprs.reserve(E->getNumSubExprs());
17444 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17445 SubExprs, &ArgumentChanged))
17446 return ExprError();
17447
17448 if (!getDerived().AlwaysRebuild() &&
17449 !ArgumentChanged)
17450 return E;
17451
17452 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17453 E->getOp(), E->getRParenLoc());
17454}
17455
17456//===----------------------------------------------------------------------===//
17457// Type reconstruction
17458//===----------------------------------------------------------------------===//
17459
17460template<typename Derived>
17463 return SemaRef.BuildPointerType(PointeeType, Star,
17465}
17466
17467template<typename Derived>
17470 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17472}
17473
17474template<typename Derived>
17477 bool WrittenAsLValue,
17478 SourceLocation Sigil) {
17479 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17480 Sigil, getDerived().getBaseEntity());
17481}
17482
17483template <typename Derived>
17485 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17486 SourceLocation Sigil) {
17487 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17489}
17490
17491template<typename Derived>
17493 const ObjCTypeParamDecl *Decl,
17494 SourceLocation ProtocolLAngleLoc,
17496 ArrayRef<SourceLocation> ProtocolLocs,
17497 SourceLocation ProtocolRAngleLoc) {
17498 return SemaRef.ObjC().BuildObjCTypeParamType(
17499 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17500 /*FailOnError=*/true);
17501}
17502
17503template<typename Derived>
17505 QualType BaseType,
17506 SourceLocation Loc,
17507 SourceLocation TypeArgsLAngleLoc,
17509 SourceLocation TypeArgsRAngleLoc,
17510 SourceLocation ProtocolLAngleLoc,
17512 ArrayRef<SourceLocation> ProtocolLocs,
17513 SourceLocation ProtocolRAngleLoc) {
17514 return SemaRef.ObjC().BuildObjCObjectType(
17515 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17516 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17517 /*FailOnError=*/true,
17518 /*Rebuilding=*/true);
17519}
17520
17521template<typename Derived>
17523 QualType PointeeType,
17525 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17526}
17527
17528template <typename Derived>
17530 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17531 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17532 if (SizeExpr || !Size)
17533 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17534 IndexTypeQuals, BracketsRange,
17536
17537 QualType Types[] = {
17538 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17539 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17540 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17541 };
17542 QualType SizeType;
17543 for (const auto &T : Types)
17544 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17545 SizeType = T;
17546 break;
17547 }
17548
17549 // Note that we can return a VariableArrayType here in the case where
17550 // the element type was a dependent VariableArrayType.
17551 IntegerLiteral *ArraySize
17552 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17553 /*FIXME*/BracketsRange.getBegin());
17554 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17555 IndexTypeQuals, BracketsRange,
17557}
17558
17559template <typename Derived>
17561 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17562 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17563 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17564 IndexTypeQuals, BracketsRange);
17565}
17566
17567template <typename Derived>
17569 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17570 SourceRange BracketsRange) {
17571 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17572 IndexTypeQuals, BracketsRange);
17573}
17574
17575template <typename Derived>
17577 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17578 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17579 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17580 SizeExpr,
17581 IndexTypeQuals, BracketsRange);
17582}
17583
17584template <typename Derived>
17586 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17587 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17588 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17589 SizeExpr,
17590 IndexTypeQuals, BracketsRange);
17591}
17592
17593template <typename Derived>
17595 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17596 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17597 AttributeLoc);
17598}
17599
17600template <typename Derived>
17602 unsigned NumElements,
17603 VectorKind VecKind) {
17604 // FIXME: semantic checking!
17605 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17606}
17607
17608template <typename Derived>
17610 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17611 VectorKind VecKind) {
17612 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17613}
17614
17615template<typename Derived>
17617 unsigned NumElements,
17618 SourceLocation AttributeLoc) {
17619 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17620 NumElements, true);
17621 IntegerLiteral *VectorSize
17622 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17623 AttributeLoc);
17624 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17625}
17626
17627template<typename Derived>
17630 Expr *SizeExpr,
17631 SourceLocation AttributeLoc) {
17632 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17633}
17634
17635template <typename Derived>
17637 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17638 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17639 NumColumns);
17640}
17641
17642template <typename Derived>
17644 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17645 SourceLocation AttributeLoc) {
17646 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17647 AttributeLoc);
17648}
17649
17650template <typename Derived>
17652 QualType T, MutableArrayRef<QualType> ParamTypes,
17654 return SemaRef.BuildFunctionType(T, ParamTypes,
17657 EPI);
17658}
17659
17660template<typename Derived>
17662 return SemaRef.Context.getFunctionNoProtoType(T);
17663}
17664
17665template <typename Derived>
17668 SourceLocation NameLoc, Decl *D) {
17669 assert(D && "no decl found");
17670 if (D->isInvalidDecl()) return QualType();
17671
17672 // FIXME: Doesn't account for ObjCInterfaceDecl!
17673 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17674 // A valid resolved using typename pack expansion decl can have multiple
17675 // UsingDecls, but they must each have exactly one type, and it must be
17676 // the same type in every case. But we must have at least one expansion!
17677 if (UPD->expansions().empty()) {
17678 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17679 << UPD->isCXXClassMember() << UPD;
17680 return QualType();
17681 }
17682
17683 // We might still have some unresolved types. Try to pick a resolved type
17684 // if we can. The final instantiation will check that the remaining
17685 // unresolved types instantiate to the type we pick.
17686 QualType FallbackT;
17687 QualType T;
17688 for (auto *E : UPD->expansions()) {
17689 QualType ThisT =
17690 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17691 if (ThisT.isNull())
17692 continue;
17693 if (ThisT->getAs<UnresolvedUsingType>())
17694 FallbackT = ThisT;
17695 else if (T.isNull())
17696 T = ThisT;
17697 else
17698 assert(getSema().Context.hasSameType(ThisT, T) &&
17699 "mismatched resolved types in using pack expansion");
17700 }
17701 return T.isNull() ? FallbackT : T;
17702 }
17703 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17704 assert(Using->hasTypename() &&
17705 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17706
17707 // A valid resolved using typename decl points to exactly one type decl.
17708 assert(++Using->shadow_begin() == Using->shadow_end());
17709
17710 UsingShadowDecl *Shadow = *Using->shadow_begin();
17711 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17712 return QualType();
17713 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17714 }
17716 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17717 return SemaRef.Context.getUnresolvedUsingType(
17719}
17720
17721template <typename Derived>
17723 TypeOfKind Kind) {
17724 return SemaRef.BuildTypeofExprType(E, Kind);
17725}
17726
17727template<typename Derived>
17729 TypeOfKind Kind) {
17730 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17731}
17732
17733template <typename Derived>
17735 return SemaRef.BuildDecltypeType(E);
17736}
17737
17738template <typename Derived>
17740 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17741 SourceLocation EllipsisLoc, bool FullySubstituted,
17742 ArrayRef<QualType> Expansions) {
17743 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17744 FullySubstituted, Expansions);
17745}
17746
17747template<typename Derived>
17749 UnaryTransformType::UTTKind UKind,
17750 SourceLocation Loc) {
17751 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17752}
17753
17754template <typename Derived>
17757 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17758 return SemaRef.CheckTemplateIdType(
17759 Keyword, Template, TemplateNameLoc, TemplateArgs,
17760 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17761}
17762
17763template<typename Derived>
17765 SourceLocation KWLoc) {
17766 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17767}
17768
17769template<typename Derived>
17771 SourceLocation KWLoc,
17772 bool isReadPipe) {
17773 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17774 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17775}
17776
17777template <typename Derived>
17779 unsigned NumBits,
17780 SourceLocation Loc) {
17781 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17782 NumBits, true);
17783 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17784 SemaRef.Context.IntTy, Loc);
17785 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17786}
17787
17788template <typename Derived>
17790 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17791 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17792}
17793
17794template <typename Derived>
17796 bool TemplateKW,
17797 TemplateName Name) {
17798 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17799 Name);
17800}
17801
17802template <typename Derived>
17804 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17805 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17807 TemplateName.setIdentifier(&Name, NameLoc);
17809 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17810 TemplateName, ParsedType::make(ObjectType),
17811 /*EnteringContext=*/false, Template,
17812 AllowInjectedClassName);
17813 return Template.get();
17814}
17815
17816template<typename Derived>
17819 SourceLocation TemplateKWLoc,
17820 OverloadedOperatorKind Operator,
17821 SourceLocation NameLoc,
17822 QualType ObjectType,
17823 bool AllowInjectedClassName) {
17824 UnqualifiedId Name;
17825 // FIXME: Bogus location information.
17826 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17827 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17829 getSema().ActOnTemplateName(
17830 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17831 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17832 return Template.get();
17833}
17834
17835template <typename Derived>
17838 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17839 Expr *Second) {
17840 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17841
17842 if (First->getObjectKind() == OK_ObjCProperty) {
17845 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17846 Opc, First, Second);
17847 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17848 if (Result.isInvalid())
17849 return ExprError();
17850 First = Result.get();
17851 }
17852
17853 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17854 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17855 if (Result.isInvalid())
17856 return ExprError();
17857 Second = Result.get();
17858 }
17859
17860 // Determine whether this should be a builtin operation.
17861 if (Op == OO_Subscript) {
17862 if (!First->getType()->isOverloadableType() &&
17863 !Second->getType()->isOverloadableType())
17864 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17865 OpLoc);
17866 } else if (Op == OO_Arrow) {
17867 // It is possible that the type refers to a RecoveryExpr created earlier
17868 // in the tree transformation.
17869 if (First->getType()->isDependentType())
17870 return ExprError();
17871 // -> is never a builtin operation.
17872 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17873 } else if (Second == nullptr || isPostIncDec) {
17874 if (!First->getType()->isOverloadableType() ||
17875 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17876 // The argument is not of overloadable type, or this is an expression
17877 // of the form &Class::member, so try to create a built-in unary
17878 // operation.
17880 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17881
17882 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17883 }
17884 } else {
17885 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17886 !First->getType()->isOverloadableType() &&
17887 !Second->getType()->isOverloadableType()) {
17888 // Neither of the arguments is type-dependent or has an overloadable
17889 // type, so try to create a built-in binary operation.
17892 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17893 if (Result.isInvalid())
17894 return ExprError();
17895
17896 return Result;
17897 }
17898 }
17899
17900 // Create the overloaded operator invocation for unary operators.
17901 if (!Second || isPostIncDec) {
17903 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17904 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17905 RequiresADL);
17906 }
17907
17908 // Create the overloaded operator invocation for binary operators.
17910 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17911 First, Second, RequiresADL);
17912 if (Result.isInvalid())
17913 return ExprError();
17914
17915 return Result;
17916}
17917
17918template<typename Derived>
17921 SourceLocation OperatorLoc,
17922 bool isArrow,
17923 CXXScopeSpec &SS,
17924 TypeSourceInfo *ScopeType,
17925 SourceLocation CCLoc,
17926 SourceLocation TildeLoc,
17927 PseudoDestructorTypeStorage Destroyed) {
17928 QualType CanonicalBaseType = Base->getType().getCanonicalType();
17929 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
17930 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
17931 (isArrow && isa<PointerType>(CanonicalBaseType) &&
17932 !cast<PointerType>(CanonicalBaseType)
17933 ->getPointeeType()
17934 ->getAsCanonical<RecordType>())) {
17935 // This pseudo-destructor expression is still a pseudo-destructor.
17936 return SemaRef.BuildPseudoDestructorExpr(
17937 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
17938 CCLoc, TildeLoc, Destroyed);
17939 }
17940
17941 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
17942 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
17943 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
17944 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
17945 NameInfo.setNamedTypeInfo(DestroyedType);
17946
17947 // The scope type is now known to be a valid nested name specifier
17948 // component. Tack it on to the nested name specifier.
17949 if (ScopeType) {
17950 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
17951 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
17952 diag::err_expected_class_or_namespace)
17953 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
17954 return ExprError();
17955 }
17956 SS.clear();
17957 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
17958 }
17959
17960 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
17961 return getSema().BuildMemberReferenceExpr(
17962 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
17963 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
17964 /*TemplateArgs*/ nullptr,
17965 /*S*/ nullptr);
17966}
17967
17968template<typename Derived>
17971 SourceLocation Loc = S->getBeginLoc();
17972 CapturedDecl *CD = S->getCapturedDecl();
17973 unsigned NumParams = CD->getNumParams();
17974 unsigned ContextParamPos = CD->getContextParamPosition();
17976 for (unsigned I = 0; I < NumParams; ++I) {
17977 if (I != ContextParamPos) {
17978 Params.push_back(
17979 std::make_pair(
17980 CD->getParam(I)->getName(),
17981 getDerived().TransformType(CD->getParam(I)->getType())));
17982 } else {
17983 Params.push_back(std::make_pair(StringRef(), QualType()));
17984 }
17985 }
17986 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
17987 S->getCapturedRegionKind(), Params);
17988 StmtResult Body;
17989 {
17990 Sema::CompoundScopeRAII CompoundScope(getSema());
17991 Body = getDerived().TransformStmt(S->getCapturedStmt());
17992 }
17993
17994 if (Body.isInvalid()) {
17995 getSema().ActOnCapturedRegionError();
17996 return StmtError();
17997 }
17998
17999 return getSema().ActOnCapturedRegionEnd(Body.get());
18000}
18001
18002template <typename Derived>
18005 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
18006 // function definition or instantiation of a function template specialization
18007 // and will therefore never appear in a dependent context.
18008 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
18009 "context");
18010}
18011
18012template <typename Derived>
18014 // We can transform the base expression and allow argument resolution to fill
18015 // in the rest.
18016 return getDerived().TransformExpr(E->getArgLValue());
18017}
18018
18019} // end namespace clang
18020
18021#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>.
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
QualType getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
PtrTy get() const
Definition Ownership.h:171
bool isInvalid() const
Definition Ownership.h:167
bool isUsable() const
Definition Ownership.h:169
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition Expr.h:4553
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:6024
Represents a loop initializing the elements of an array.
Definition Expr.h:5971
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1833
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7218
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2724
Wrapper for source info for arrays.
Definition TypeLoc.h:1777
void setLBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1783
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition ExprCXX.h:2997
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:3035
ArrayTypeTrait getTrait() const
Definition ExprCXX.h:3037
Expr * getDimensionExpression() const
Definition ExprCXX.h:3047
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition ExprCXX.h:3043
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:3034
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3730
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6732
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6927
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2673
Attr - This represents one attribute.
Definition Attr.h:46
Represents an attribute applied to a statement.
Definition Stmt.h: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:4456
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4041
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition Expr.cpp:2180
static bool isAssignmentOp(Opcode Opc)
Definition Expr.h:4177
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:2142
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8240
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4674
void setIsVariadic(bool value)
Definition Decl.h:4750
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6671
Wrapper for source info for block pointers.
Definition TypeLoc.h:1526
BreakStmt - This represents a break.
Definition Stmt.h:3127
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5477
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.h:5496
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.h:5495
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition Expr.h:3972
Represents a call to a CUDA kernel function.
Definition ExprCXX.h:235
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition ExprCXX.h:605
Represents binding an expression to a temporary.
Definition ExprCXX.h:1494
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition ExprCXX.h:724
CXXCatchStmt - This represents a C++ catch block.
Definition StmtCXX.h:28
A C++ const_cast expression (C++ [expr.const.cast]).
Definition ExprCXX.h:567
Represents a call to a C++ constructor.
Definition ExprCXX.h:1549
SourceRange getParenOrBraceRange() const
Definition ExprCXX.h:1730
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition ExprCXX.h:1692
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition ExprCXX.h:1642
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:1631
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition ExprCXX.h:1689
Represents a C++ constructor within a class.
Definition DeclCXX.h:2611
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1271
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:1378
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2627
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition ExprCXX.h:3871
Represents a C++ destructor within a class.
Definition DeclCXX.h:2876
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:482
Represents a folding of a pack over an operator.
Definition ExprCXX.h:5033
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:1832
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition ExprCXX.h:1752
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:180
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2136
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition ExprCXX.h:376
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition ExprCXX.h:407
SourceRange getAngleBrackets() const LLVM_READONLY
Definition ExprCXX.h:414
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition ExprCXX.h:410
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition ExprCXX.h:2356
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition ExprCXX.h:4310
The null pointer literal (C++11 [lex.nullptr])
Definition ExprCXX.h:769
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:85
Represents a list-initialization with parenthesis.
Definition ExprCXX.h:5142
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition ExprCXX.h:2746
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
unsigned getLambdaDependencyKind() const
Definition DeclCXX.h:1861
Represents a C++26 reflect expression [expr.reflect].
Definition ExprCXX.h:5509
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition ExprCXX.h:527
A rewritten comparison expression that was originally written using operator syntax.
Definition ExprCXX.h:287
An expression "T()" which creates an rvalue of a non-class type T.
Definition ExprCXX.h:2197
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:74
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:207
SourceRange getRange() const
Definition DeclSpec.h:80
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:95
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:211
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:179
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:801
Represents a C++ functional cast expression that builds a temporary object.
Definition ExprCXX.h:1900
Represents the this expression in C++.
Definition ExprCXX.h:1155
A C++ throw-expression (C++ [except.throw]).
Definition ExprCXX.h:1209
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:849
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition ExprCXX.h:3745
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition ExprCXX.h:3789
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition ExprCXX.h:3800
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition ExprCXX.h:3783
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition ExprCXX.h:3794
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition ExprCXX.h:3803
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1069
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2946
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
Definition Expr.cpp:1517
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4946
unsigned getNumParams() const
Definition Decl.h:4984
unsigned getContextParamPosition() const
Definition Decl.h:5013
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4986
This captures a statement into a function.
Definition Stmt.h:3929
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1493
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:1508
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:1980
Expr * getSubExpr()
Definition Expr.h:3729
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4851
Represents a 'co_await' expression.
Definition ExprCXX.h:5370
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4303
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3608
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h: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:4394
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3768
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition Expr.h:1085
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4395
ContinueStmt - This represents a continue.
Definition Stmt.h:3111
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4722
Represents a 'co_return' statement in the C++ Coroutines TS.
Definition StmtCXX.h:473
Represents the body of a coroutine.
Definition StmtCXX.h:320
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
Definition TypeBase.h:3444
Represents a 'co_yield' expression.
Definition ExprCXX.h:5451
Wrapper for source info for pointers decayed from arrays and functions.
Definition TypeLoc.h:1474
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h: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:1273
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:1921
void setDecltypeLoc(SourceLocation Loc)
Definition TypeLoc.h:2288
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2513
DeferStmt - This represents a deferred statement.
Definition Stmt.h:3228
static DeferStmt * Create(ASTContext &Context, SourceLocation DeferLoc, Stmt *Body)
Definition Stmt.cpp:1552
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:1998
Represents an extended address space qualifier where the input address space value is dependent.
Definition TypeBase.h:4069
Represents a 'co_await' expression while the type of the promise is dependent.
Definition ExprCXX.h:5402
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2581
A qualified reference to a name whose declaration cannot yet be resolved.
Definition ExprCXX.h:3511
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3585
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition ExprCXX.h:3559
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3577
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition ExprCXX.h:3595
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3569
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3612
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3550
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3605
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition ExprCXX.h:3547
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4019
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2096
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4109
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition TypeBase.h:4481
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2068
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4235
Represents a single C99 designator.
Definition Expr.h:5597
Represents a C99 designated initializer expression.
Definition Expr.h:5554
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:208
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
Definition Designator.h:172
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
Definition Designator.h:142
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
Definition Designator.h:115
bool hasErrorOccurred() const
Definition Diagnostic.h:880
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:5035
Expr * getCondition() const
Definition TypeBase.h:5042
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:744
Represents a reference to emded data.
Definition Expr.h:5129
RAII object that enters a new expression evaluation context.
Wrapper for source info for enum types.
Definition TypeLoc.h:863
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Definition Expr.h:3953
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition ExprCXX.h:3662
This represents one expression.
Definition Expr.h:112
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition Expr.h:177
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:194
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition Expr.h:454
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3082
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3214
QualType getType() const
Definition Expr.h:144
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition Expr.h:526
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition Expr.h:437
An expression trait intrinsic.
Definition ExprCXX.h:3070
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h:6609
Represents difference between two FPOptions values.
FPOptions applyOverrides(FPOptions Base)
Represents a member of a struct/union/class.
Definition Decl.h: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:5283
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4928
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5605
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5591
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5149
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4893
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4842
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5315
param_type_iterator param_type_begin() const
Definition TypeBase.h:5759
unsigned getNumParams() const
Definition TypeLoc.h:1716
SourceLocation getLocalRangeEnd() const
Definition TypeLoc.h:1668
void setLocalRangeBegin(SourceLocation L)
Definition TypeLoc.h:1664
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1680
SourceRange getExceptionSpecRange() const
Definition TypeLoc.h:1696
void setParam(unsigned i, ParmVarDecl *VD)
Definition TypeLoc.h:1723
ArrayRef< ParmVarDecl * > getParams() const
Definition TypeLoc.h:1707
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1688
void setLocalRangeEnd(SourceLocation L)
Definition TypeLoc.h:1672
void setExceptionSpecRange(SourceRange R)
Definition TypeLoc.h:1702
TypeLoc getReturnLoc() const
Definition TypeLoc.h:1725
SourceLocation getLocalRangeBegin() const
Definition TypeLoc.h:1660
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1676
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1684
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4537
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:4926
Represents a C11 generic selection.
Definition Expr.h:6181
AssociationTy< false > Association
Definition Expr.h:6414
GotoStmt - This represents a direct goto.
Definition Stmt.h:2961
Type source information for HLSL attributed resource type.
Definition TypeLoc.h:1113
void setSourceRange(const SourceRange &R)
Definition TypeLoc.h:1124
This class represents temporary values used to represent inout and out arguments in HLSL.
Definition Expr.h:7396
One of these records is kept for each identifier that is lexed.
IfStmt - This represents an if/then/else.
Definition Stmt.h:2251
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition Expr.h:1734
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition Expr.h:3856
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:6060
Represents a C array with an unspecified size.
Definition TypeBase.h:3917
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:5302
InitListExpr * getSyntacticForm() const
Definition Expr.h:5475
Wrapper for source info for injected class names of class templates.
Definition TypeLoc.h:872
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition Expr.cpp:975
Represents the declaration of a label.
Definition Decl.h:524
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2138
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition ExprCXX.h:1969
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:2034
Represents the results of name lookup.
Definition Lookup.h:147
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:4347
A member reference to an MSPropertyDecl.
Definition ExprCXX.h:937
MS property subscript expression.
Definition ExprCXX.h:1007
void setExpansionLoc(SourceLocation Loc)
Definition TypeLoc.h:1383
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4921
MatrixSingleSubscriptExpr - Matrix single subscript expression for the MatrixType extension when you ...
Definition Expr.h:2798
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2868
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2125
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3367
Wrapper for source info for member pointers.
Definition TypeLoc.h:1544
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3661
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition Template.h:76
This represents a decl that may have a name.
Definition Decl.h:274
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition Decl.h:295
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:301
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:340
Represents C++ namespaces and their aliases.
Definition Decl.h:573
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents a place-holder for an object not to be initialized by anything.
Definition Expr.h:5880
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h: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:1303
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:1586
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1592
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition TypeLoc.h:1258
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:731
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition ExprObjC.h: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:2429
@ Identifier
A field in a dependent type, known only by its name.
Definition Expr.h:2433
@ Field
A field.
Definition Expr.h:2431
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition Expr.h:2436
static OpaquePtr make(QualType P)
Definition Ownership.h:61
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition Expr.h:1181
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1231
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition Expr.h:2093
static OpenACCAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCAttachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCAutoClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
This is the base type for all OpenACC Clauses.
Represents a 'collapse' clause on a 'loop' construct.
static OpenACCCollapseClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, bool HasForce, Expr *LoopCount, SourceLocation EndLoc)
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A 'default' clause, has the optional 'none' or 'present' argument.
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCDeleteClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDetachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceNumClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCFinalizeClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCFirstPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCHostClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
An 'if' clause, which has a required condition expression.
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCIfPresentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCIndependentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCNoCreateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCPrivateRecipe > InitRecipes, SourceLocation EndLoc)
A 'self' clause, which has an optional condition expression, or, in the event of an 'update' directiv...
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCTileClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > SizeExprs, SourceLocation EndLoc)
static OpenACCUseDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWaitClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1093
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition ExprCXX.h:3129
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition ExprCXX.h:3281
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition ExprCXX.h:3263
SourceLocation getNameLoc() const
Gets the location of the name.
Definition ExprCXX.h:3242
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition ExprCXX.h:3255
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition ExprCXX.h:3251
TemplateArgumentLoc const * getTemplateArgs() const
Definition ExprCXX.h:3325
llvm::iterator_range< decls_iterator > decls() const
Definition ExprCXX.h:3228
unsigned getNumTemplateArgs() const
Definition ExprCXX.h:3331
DeclarationName getName() const
Gets the name looked up.
Definition ExprCXX.h:3239
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition ExprCXX.h:3271
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition ExprCXX.h:3278
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition ExprCXX.h:4364
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2633
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2629
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2645
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2316
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2185
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition Expr.h:2210
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition Expr.h:2214
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1411
Represents a parameter to a function.
Definition Decl.h: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:2958
unsigned getFunctionScopeDepth() const
Definition Decl.h:1840
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2725
PipeType - OpenCL20.
Definition TypeBase.h:8206
bool isReadOnly() const
Definition TypeBase.h:8236
Pointer-authentication qualifiers.
Definition TypeBase.h:152
void setSigilLoc(SourceLocation Loc)
Definition TypeLoc.h:1490
TypeLoc getPointeeLoc() const
Definition TypeLoc.h:1494
SourceLocation getSigilLoc() const
Definition TypeLoc.h:1486
Wrapper for source info for pointers.
Definition TypeLoc.h:1513
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3336
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2008
Stores the type being destroyed by a pseudo-destructor expression.
Definition ExprCXX.h:2695
const IdentifierInfo * getIdentifier() const
Definition ExprCXX.h:2715
SourceLocation getLocation() const
Definition ExprCXX.h:2719
TypeSourceInfo * getTypeSourceInfo() const
Definition ExprCXX.h:2711
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h:6803
A (possibly-)qualified type.
Definition TypeBase.h:937
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition TypeBase.h:1004
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition TypeBase.h:8388
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition TypeBase.h:8428
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition TypeBase.h:8482
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8420
Represents a template name as written in source code.
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition TypeLoc.h:300
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
void removeObjCLifetime()
Definition TypeBase.h:551
bool hasRestrict() const
Definition TypeBase.h:477
static Qualifiers fromCVRMask(unsigned CVR)
Definition TypeBase.h:435
PointerAuthQualifier getPointerAuth() const
Definition TypeBase.h:603
bool hasObjCLifetime() const
Definition TypeBase.h:544
bool empty() const
Definition TypeBase.h:647
LangAS getAddressSpace() const
Definition TypeBase.h:571
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition Expr.h:7502
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3581
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3597
Represents the body of a requires-expression.
Definition DeclCXX.h:2105
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition DeclCXX.cpp:2407
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3152
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition Stmt.cpp:1361
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:36
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
Definition SemaObjC.cpp:36
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
Definition SemaObjC.cpp:193
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition SemaObjC.cpp:320
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
Definition SemaObjC.cpp:218
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:213
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition SemaObjC.cpp:238
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition SemaObjC.cpp:282
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Definition SemaObjC.cpp:202
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:329
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
Helper type for the registration/assignment of constructs that need to 'know' about their parent cons...
Helper type to restore the state of various 'loop' constructs when we run into a loop (for,...
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
void ActOnWhileStmt(SourceLocation WhileLoc)
ExprResult ActOnOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
void ActOnDoStmt(SourceLocation DoLoc)
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *OldRangeFor, const Stmt *RangeFor)
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation MiscLoc, ArrayRef< Expr * > Exprs, OpenACCAtomicKind AK, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
void ActOnForStmtEnd(SourceLocation ForLoc, StmtResult Body)
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *First, const Stmt *Second, const Stmt *Third)
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
OMPClause * ActOnOpenMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nocontext' clause.
OMPClause * ActOnOpenMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_dyn_cgroup_mem' clause.
OMPClause * ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'safelen' clause.
OMPClause * ActOnOpenMPHoldsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'holds' clause.
OMPClause * ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'filter' clause.
OMPClause * ActOnOpenMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on well-form 'full' clauses.
OMPClause * ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'detach' clause.
OMPClause * ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'use' clause.
OMPClause * ActOnOpenMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'private' clause.
OMPClause * ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc=SourceLocation(), Expr *NumForLoops=nullptr)
Called on well-formed 'ordered' clause.
OMPClause * ActOnOpenMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'is_device_ptr' clause.
OMPClause * ActOnOpenMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'has_device_addr' clause.
OMPClause * ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'partial' clauses.
OMPClause * ActOnOpenMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'lastprivate' clause.
OMPClause * ActOnOpenMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'firstprivate' clause.
OMPClause * ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'priority' clause.
OMPClause * ActOnOpenMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'dist_schedule' clause.
OMPClause * ActOnOpenMPLoopRangeClause(Expr *First, Expr *Count, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc)
Called on well-form 'looprange' clause after parsing its arguments.
OMPClause * ActOnOpenMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'permutation' clause after parsing its arguments.
OMPClause * ActOnOpenMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nontemporal' clause.
OMPClause * ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'bind' clause.
OMPClause * ActOnOpenMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' clause.
OMPClause * ActOnOpenMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'shared' clause.
OMPClause * ActOnOpenMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyin' clause.
OMPClause * ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'destroy' clause.
OMPClause * ActOnOpenMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Called on well-formed 'affinity' clause.
OMPClause * ActOnOpenMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' clause.
OMPClause * ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depend' clause.
OMPClause * ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'doacross' clause.
OMPClause * ActOnOpenMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, OpenMPUseDevicePtrFallbackModifier FallbackModifier, SourceLocation FallbackModifierLoc)
Called on well-formed 'use_device_ptr' clause.
OMPClause * ActOnOpenMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'grainsize' clause.
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
ExprResult ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< OMPIteratorData > Data)
OMPClause * ActOnOpenMPUsesAllocatorClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< UsesAllocatorsData > Data)
Called on well-formed 'uses_allocators' clause.
OMPClause * ActOnOpenMPAllocatorClause(Expr *Allocator, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocator' clause.
OMPClause * ActOnOpenMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'inclusive' clause.
OMPClause * ActOnOpenMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'task_reduction' clause.
OMPClause * ActOnOpenMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Condition)
Called on well-formed 'nowait' clause.
OMPClause * ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, OpenMPOrderClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'order' clause.
OMPClause * ActOnOpenMPSizesClause(ArrayRef< Expr * > SizeExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'sizes' clause.
OMPClause * ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'device' clause.
OMPClause * ActOnOpenMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'in_reduction' clause.
OMPClause * ActOnOpenMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'flush' pseudo clause.
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
OMPClause * ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'message' clause.
OMPClause * ActOnOpenMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'schedule' clause.
OMPClause * ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'simdlen' clause.
OMPClause * ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'proc_bind' clause.
OMPClause * ActOnOpenMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_bare' clause.
StmtResult ActOnOpenMPInformationalDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Process an OpenMP informational directive.
StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt)
Called for syntactical loops (ForStmt or CXXForRangeStmt) associated to an OpenMP loop directive.
OMPClause * ActOnOpenMPTransparentClause(Expr *Transparent, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'transparent' clause.
OMPClause * ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'hint' clause.
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
OMPClause * ActOnOpenMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_threads' clause.
OMPClause * ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'at' clause.
OMPClause * ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'init' clause.
OMPClause * ActOnOpenMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_addr' clause.
OMPClause * ActOnOpenMPAllocateClause(Expr *Allocator, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocate' clause.
OMPClause * ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'final' clause.
OMPClause * ActOnOpenMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, bool NoDiagnose=false, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'map' clause.
OMPClause * ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_tasks' clause.
OMPClause * ActOnOpenMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'from' clause.
OMPClause * ActOnOpenMPDynGroupprivateClause(OpenMPDynGroupprivateClauseModifier M1, OpenMPDynGroupprivateClauseFallbackModifier M2, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation EndLoc)
Called on a well-formed 'dyn_groupprivate' clause.
void StartOpenMPDSABlock(OpenMPDirectiveKind K, const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc)
Called on start of new data sharing attribute block.
OMPClause * ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'severity' clause.
OMPClause * ActOnOpenMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'to' clause.
OMPClause * ActOnOpenMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind LinKind, SourceLocation LinLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Called on well-formed 'linear' clause.
OMPClause * ActOnOpenMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'defaultmap' clause.
OMPClause * ActOnOpenMPReductionClause(ArrayRef< Expr * > VarList, OpenMPVarListDataTy::OpenMPReductionClauseModifiers Modifiers, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'reduction' clause.
OMPClause * ActOnOpenMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'aligned' clause.
OMPClause * ActOnOpenMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depobj' pseudo clause.
OMPClause * ActOnOpenMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'novariants' clause.
OMPClause * ActOnOpenMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyprivate' clause.
OMPClause * ActOnOpenMPCollapseClause(Expr *NumForLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'collapse' clause.
OMPClause * ActOnOpenMPDefaultClause(llvm::omp::DefaultKind M, SourceLocation MLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCKindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'default' clause.
OMPClause * ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'align' clause.
OMPClause * ActOnOpenMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_attribute' clause.
OMPClause * ActOnOpenMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'exclusive' clause.
OMPClause * ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'if' clause.
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
Given a pseudo-object expression, recreate what it looks like syntactically without the attendant Opa...
ExprResult checkRValue(Expr *E)
StmtResult BuildSYCLKernelCallStmt(FunctionDecl *FD, CompoundStmt *Body, Expr *LaunchIdExpr)
Builds a SYCLKernelCallStmt to wrap 'Body' and to be used as the body of 'FD'.
Definition SemaSYCL.cpp:670
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition SemaSYCL.cpp:153
RAII object used to change the argument pack substitution index within a Sema object.
Definition Sema.h:13724
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8502
A RAII object to enter scope of a compound statement.
Definition Sema.h:1307
A RAII object to temporarily push a declaration context.
Definition Sema.h:3518
A helper class for building up ExtParameterInfos.
Definition Sema.h:13088
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:13107
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13095
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14129
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:868
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
ExprResult ActOnCXXParenListInitExpr(ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
ExprResult BuildOperatorCoawaitCall(SourceLocation Loc, Expr *E, UnresolvedLookupExpr *Lookup)
Build a call to 'operator co_await' if there is a suitable operator for the given expression.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition Sema.h:9385
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9393
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9388
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:1525
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:7892
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7894
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7893
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:1550
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:12033
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:1300
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
DiagnosticsEngine & getDiagnostics() const
Definition Sema.h:936
SemaObjC & ObjC()
Definition Sema.h:1510
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool FullySubstituted=false)
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
ASTContext & getASTContext() const
Definition Sema.h:939
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, bool DoCheckConstraintSatisfaction=true)
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition Sema.cpp:84
const LangOptions & getLangOpts() const
Definition Sema.h:932
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
SemaOpenACC & OpenACC()
Definition Sema.h:1515
@ ReuseLambdaContextDecl
Definition Sema.h:7070
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:11836
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:1333
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:11831
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition Sema.cpp:2551
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1438
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:13718
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:6783
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6793
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6762
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6788
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:75
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition Sema.h:8371
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:11120
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:1292
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static ConditionResult ConditionError()
Definition Sema.h:7878
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:436
SemaPseudoObject & PseudoObject()
Definition Sema.h:1535
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:1291
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:8713
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition Expr.h:4646
Represents an expression that computes the length of a parameter pack.
Definition ExprCXX.h:4442
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition ExprCXX.h:4504
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
Definition ExprCXX.h:4527
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:4532
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
Definition ExprCXX.h:4501
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition ExprCXX.h:4507
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition ExprCXX.h:4510
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition Expr.h:5020
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition Expr.h:5080
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition Expr.h:4598
Stmt - This represents one statement.
Definition Stmt.h:86
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.cpp:367
@ NoStmtClass
Definition Stmt.h:89
StmtClass getStmtClass() const
Definition Stmt.h:1485
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:343
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1802
Wrapper for substituted template type parameters.
Definition TypeLoc.h:998
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition ExprCXX.h:4665
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition ExprCXX.h:4755
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:1907
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:1922
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:1905
SourceLocation getTemplateKeywordLoc() const
Definition TypeLoc.h:1901
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1891
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:1887
Wrapper for template type parameters.
Definition TypeLoc.h:881
The top declaration context.
Definition Decl.h:105
RAII object that temporarily sets the base location and entity used for reporting diagnostics in type...
TemporaryBase(const TemporaryBase &)=delete
TemporaryBase(TreeTransform &Self, SourceLocation Location, DeclarationName Entity)
TemporaryBase & operator=(const TemporaryBase &)=delete
A semantic tree transformation that allows one to transform one abstract syntax tree into another.
ExprResult RebuildObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *object)
Rebuild the operand to an Objective-C @synchronized statement.
OMPClause * RebuildOMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nontemporal' clause.
StmtResult RebuildOpenACCDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
TemplateArgument TransformNamedTemplateTemplateArgument(NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName Name, SourceLocation NameLoc)
ExprResult TransformInitializer(Expr *Init, bool NotCopyInit)
Transform the given initializer.
StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new label statement.
StmtResult RebuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs Args)
StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @autoreleasepool statement.
OMPClause * RebuildOMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP 'dist_schedule' clause.
ExprResult RebuildUnaryOperator(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *SubExpr)
Build a new unary operator expression.
OMPClause * RebuildOMPProcBindClause(ProcBindKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'proc_bind' clause.
ParmVarDecl * TransformFunctionTypeParam(ParmVarDecl *OldParm, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack)
Transforms a single function-type parameter.
StmtResult RebuildOMPInformationalDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP informational directive.
ExprResult RebuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Build a new C++11 default-initialization expression.
OMPClause * RebuildOMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'priority' clause.
StmtResult RebuildOpenACCSetConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc, TypeSourceInfo *EncodeTypeInfo, SourceLocation RParenLoc)
Build a new Objective-C @encode expression.
StmtResult RebuildOpenACCCombinedConstruct(OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult Loop)
StmtResult SkipLambdaBody(LambdaExpr *E, Stmt *Body)
Alternative implementation of TransformLambdaBody that skips transforming the body.
StmtResult RebuildOpenACCExitDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
StmtResult RebuildOpenACCShutdownConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
OMPClause * RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocate' clause.
ExprResult RebuildObjCIsaExpr(Expr *BaseArg, SourceLocation IsaLoc, SourceLocation OpLoc, bool IsArrow)
Build a new Objective-C "isa" expression.
StmtResult RebuildObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @finally statement.
SourceLocation getBaseLocation()
Returns the location of the entity being transformed, if that information was not available elsewhere...
ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
Build a new call expression.
ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar, SourceLocation IvarLoc, bool IsArrow, bool IsFreeIvar)
Build a new Objective-C ivar reference expression.
OMPClause * RebuildOMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'at' clause.
StmtResult RebuildCoreturnStmt(SourceLocation CoreturnLoc, Expr *Result, bool IsImplicit)
Build a new co_return statement.
OMPClause * RebuildOMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'in_reduction' clause.
ExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *Init)
Build a new compound literal expression.
ExprResult TransformAddressOfOperand(Expr *E)
The operand of a unary address-of operator has special rules: it's allowed to refer to a non-static m...
ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc, QualType ThisType, bool isImplicit)
Build a new C++ "this" expression.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(expr) expression.
TreeTransform(Sema &SemaRef)
Initializes a new tree transformer.
QualType RebuildDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttributeLoc)
Build a new matrix type given the type and dependently-defined dimensions.
QualType RebuildTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, TagDecl *Tag)
Build a new class/struct/union/enum type.
QualType RebuildUnaryTransformType(QualType BaseType, UnaryTransformType::UTTKind UKind, SourceLocation Loc)
Build a new unary transform type.
ExprResult RebuildObjCPropertyRefExpr(Expr *BaseArg, ObjCPropertyDecl *Property, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
void InventTemplateArgumentLoc(const TemplateArgument &Arg, TemplateArgumentLoc &ArgLoc)
Fakes up a TemplateArgumentLoc for a given TemplateArgument.
OMPClause * RebuildOMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'use' clause.
StmtResult RebuildOpenACCEnterDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL)
Transform the given type-with-location into a new type, collecting location information in the given ...
ExprResult RebuildCXXRewrittenBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opcode, const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS)
Build a new rewritten operator expression.
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 RebuildParenListExpr(SourceLocation LParenLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new expression list in parentheses.
OMPClause * RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocator' clause.
QualType RebuildDependentSizedArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new dependent-sized array type given the element type, size modifier, size expression,...
NamedDecl * TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc)
Transform the given declaration, which was the first part of a nested-name-specifier in a member acce...
OMPClause * RebuildOMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'inclusive' clause.
StmtResult TransformOMPInformationalDirective(OMPExecutableDirective *S)
This is mostly the same as above, but allows 'informational' class directives when rebuilding the stm...
concepts::ExprRequirement * RebuildExprRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
OMPClause * RebuildOMPTransparentClause(Expr *ImpexTypeArg, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
ExprResult RebuildCXXFoldExpr(UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
Build a new C++1z fold-expression.
OMPClause * TransformOMPClause(OMPClause *S)
Transform the given statement.
QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc)
Build a new atomic type given its value type.
ExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *SubExpr)
Build a new C-style cast expression.
QualType RebuildObjCObjectPointerType(QualType PointeeType, SourceLocation Star)
Build a new Objective-C object pointer type given the pointee type.
OMPClause * RebuildOMPLoopRangeClause(Expr *First, Expr *Count, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc)
bool PreparePackForExpansion(TemplateArgumentLoc In, bool Uneval, TemplateArgumentLoc &Out, UnexpandedInfo &Info)
Checks if the argument pack from In will need to be expanded and does the necessary prework.
ExprResult TransformExpr(Expr *E)
Transform the given expression.
bool AlreadyTransformed(QualType T)
Determine whether the given type T has already been transformed.
concepts::TypeRequirement * RebuildTypeRequirement(TypeSourceInfo *T)
ExprResult RebuildOMPIteratorExpr(SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< SemaOpenMP::OMPIteratorData > Data)
Build a new iterator expression.
ExprResult RebuildSYCLUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
OMPClause * RebuildOMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'grainsize' clause.
OMPClause * RebuildOMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
bool TransformTemplateArguments(InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
OMPClause * RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'collapse' clause.
static ExprResult Owned(Expr *E)
ExprResult RebuildCXXUuidofExpr(QualType Type, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(expr) expression.
OMPClause * RebuildOMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_tasks' clause.
OMPClause * RebuildOMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'depobj' pseudo clause.
ExprResult RebuildChooseExpr(SourceLocation BuiltinLoc, Expr *Cond, Expr *LHS, Expr *RHS, SourceLocation RParenLoc)
Build a new __builtin_choose_expr expression.
OMPClause * RebuildOMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'align' clause.
ExprResult RebuildObjCMessageExpr(TypeSourceInfo *ReceiverTypeInfo, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C class message.
bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL, LookupResult &R)
Transform the set of declarations in an OverloadExpr.
QualType RebuildUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, UsingShadowDecl *D, QualType UnderlyingType)
Build a new type found via an alias.
ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, SourceLocation LParenOrBraceLoc, MultiExprArg Args, SourceLocation RParenOrBraceLoc, bool ListInitialization)
Build a new object-construction expression.
StmtResult RebuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init, SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps)
Build a new C++0x range-based for statement.
OMPClause * RebuildOMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Num)
Build a new OpenMP 'ordered' clause.
ExprResult RebuildCoyieldExpr(SourceLocation CoyieldLoc, Expr *Result)
Build a new co_yield expression.
StmtResult TransformStmt(Stmt *S, StmtDiscardKind SDK=StmtDiscardKind::Discarded)
Transform the given statement.
QualType RebuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo * > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build an Objective-C object type.
llvm::DenseMap< Decl *, Decl * > TransformedLocalDecls
OMPClause * RebuildOMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'novariants' clause.
StmtResult RebuildOpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E)
ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocatedType, TypeSourceInfo *AllocatedTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
Build a new C++ "new" expression.
StmtResult RebuildObjCForCollectionStmt(SourceLocation ForLoc, Stmt *Element, Expr *Collection, SourceLocation RParenLoc, Stmt *Body)
Build a new Objective-C fast enumeration statement.
ExprResult RebuildDependentScopeDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
Build a new (previously unresolved) declaration reference expression.
StmtResult RebuildObjCAtTryStmt(SourceLocation AtLoc, Stmt *TryBody, MultiStmtArg CatchStmts, Stmt *Finally)
Build a new Objective-C @try statement.
DeclarationName getBaseEntity()
Returns the name of the entity being transformed, if that information was not available elsewhere in ...
ExprResult RebuildExtVectorOrMatrixElementExpr(Expr *Base, SourceLocation OpLoc, bool IsArrow, SourceLocation AccessorLoc, IdentifierInfo &Accessor)
Build a new extended vector or matrix element access expression.
ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, bool ListInitialization)
Build a new object-construction expression.
ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, SourceLocation OpLoc, SourceLocation CalleeLoc, bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First, Expr *Second)
Build a new overloaded operator call expression.
OMPClause * RebuildOMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'use_device_addr' clause.
QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc)
Build a dependent bit-precise int given its value type.
OMPClause * RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'hint' clause.
Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var, Expr *Expr, Sema::ConditionKind Kind)
Transform the specified condition.
OMPClause * RebuildOMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'severity' clause.
OMPClause * RebuildOMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'firstprivate' clause.
StmtResult RebuildMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
Build a new MS style inline asm statement.
VarDecl * RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TInfo, QualType T)
Rebuild an Objective-C exception declaration.
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, IdentifierOrOverloadedOperator IO, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
concepts::NestedRequirement * TransformNestedRequirement(concepts::NestedRequirement *Req)
QualType RebuildConstantArrayType(QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new constant array type given the element type, size modifier, (known) size of the array,...
ExprResult RebuildOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > BracketsRanges)
Build a new array shaping expression.
MultiLevelTemplateArgumentList ForgetSubstitution()
"Forget" the template substitution to allow transforming the AST without any template instantiations.
ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc, bool IsGlobalDelete, bool IsArrayForm, Expr *Operand)
Build a new C++ "delete" expression.
ExprResult RebuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP, SourceLocation Loc, TemplateArgument Arg, UnsignedOrNone PackIndex, bool Final)
bool TransformExceptionSpec(SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, SmallVectorImpl< QualType > &Exceptions, bool &Changed)
ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait, SourceLocation StartLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParenLoc)
Build a new array type trait expression.
OMPClause * RebuildOMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'is_device_ptr' clause.
QualType RebuildMacroQualifiedType(QualType T, const IdentifierInfo *MacroII)
Build a new MacroDefined type.
concepts::NestedRequirement * RebuildNestedRequirement(Expr *Constraint)
ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length, ArrayRef< TemplateArgument > PartialArgs)
Build a new expression to compute the length of a parameter pack.
ExprResult RebuildMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBracketLoc)
Build a new matrix subscript expression.
ExprResult TransformParenDependentScopeDeclRefExpr(ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
TemplateParameterList * TransformTemplateParameterList(TemplateParameterList *TPL)
void transformAttrs(Decl *Old, Decl *New)
Transform the attributes associated with the given declaration and place them on the new declaration.
QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL)
QualType RebuildTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &Args)
Build a new template specialization type.
Decl * TransformDecl(SourceLocation Loc, Decl *D)
Transform the given declaration, which is referenced from a type or expression.
bool AlwaysRebuild()
Whether the transformation should always rebuild AST nodes, even if none of the children have changed...
ExprResult RebuildObjCMessageExpr(SourceLocation SuperLoc, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, QualType SuperType, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C instance/class message to 'super'.
OMPClause * RebuildOMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'lastprivate' clause.
QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc, VectorKind)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
bool AllowSkippingCXXConstructExpr()
Wether CXXConstructExpr can be skipped when they are implicit.
OMPClause * RebuildOMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'safelen' clause.
StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *Init, Sema::ConditionResult Cond, SourceLocation RParenLoc)
Start building a new switch statement.
StmtResult RebuildDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new default statement.
StmtResult RebuildObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParenLoc, VarDecl *Var, Stmt *Body)
Build a new Objective-C @catch statement.
OMPClause * RebuildOMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'filter' clause.
ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base, SourceLocation OperatorLoc, bool isArrow, CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage Destroyed)
Build a new pseudo-destructor expression.
QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits, SourceLocation Loc)
Build a bit-precise int given its value type.
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:2735
SourceLocation getBeginLoc() const
Get the begin source location.
Definition TypeLoc.cpp:193
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Definition TypeBase.h:6226
A container of type source information.
Definition TypeBase.h:8359
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:8370
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:2897
The base class of the type hierarchy.
Definition TypeBase.h:1839
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition TypeBase.h:2790
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition TypeBase.h:2411
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition TypeBase.h:9141
bool isObjCObjectPointerType() const
Definition TypeBase.h:8804
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9218
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:2200
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2628
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2247
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition Expr.h:2292
Expr * getSubExpr() const
Definition Expr.h:2288
Opcode getOpcode() const
Definition Expr.h:2283
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:1415
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2344
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:1033
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:3391
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition ExprCXX.h:3465
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition ExprCXX.h:3460
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:4127
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:6031
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition ExprCXX.h:641
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3402
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3466
Wrapper for source info for types used via transparent aliases.
Definition TypeLoc.h:785
Represents a call to the builtin function __builtin_va_arg.
Definition Expr.h:4960
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
QualType getType() const
Definition Decl.h:723
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Definition Decl.cpp:5594
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:3974
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2045
Represents a GCC generic vector type.
Definition TypeBase.h:4183
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:794
bool ContainsUnexpandedParameterPack
Whether this contains an unexpanded parameter pack.
Definition ScopeInfo.h:732
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition ScopeInfo.h:875
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Definition ScopeInfo.h:878
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
VE builtins.
const AstTypeMatcher< FunctionType > functionType
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition Descriptor.h:29
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
Definition Interp.h:1036
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:820
llvm::json::Object Object
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:1798
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:1541
@ 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:3727
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:5939
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:812
@ Exists
The symbol exists.
Definition Sema.h:805
@ Error
An error occurred.
Definition Sema.h:815
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:808
MutableArrayRef< Stmt * > MultiStmtArg
Definition Ownership.h:260
OpenMPNumThreadsClauseModifier
U cast(CodeGen::Address addr)
Definition Address.h:327
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition OpenMPKinds.h:48
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition Ownership.h:230
SourceLocIdentKind
Definition Expr.h:5007
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5914
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5935
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5925
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5932
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:2246
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Uninstantiated
not instantiated yet
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition Expr.h:1992
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition OpenMPKinds.h:31
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition OpenMPKinds.h:71
Expr * AllocatorTraits
Allocator traits.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition ASTConcept.h:91
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:89
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition TypeBase.h:5052
Holds information about the various types of exception specification.
Definition TypeBase.h:5372
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5388
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5374
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5377
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5380
Extra information about a function prototype.
Definition TypeBase.h:5400
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5405
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:3347
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:13168
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13199
An RAII helper that pops function a function scope on exit.
Definition Sema.h:1322
Keeps information about an identifier in a nested-name-spec.
Definition Sema.h:3318
Location information for a TemplateArgument.
UnsignedOrNone OrigNumExpansions
SourceLocation Ellipsis
UnsignedOrNone NumExpansions