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.
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>
13081 // TODO(reflection): Implement its transform
13082 assert(false && "not implemented yet");
13083 return ExprError();
13084}
13085
13086template<typename Derived>
13089 if (!E->isTypeDependent())
13090 return E;
13091
13092 return getDerived().RebuildPredefinedExpr(E->getLocation(),
13093 E->getIdentKind());
13094}
13095
13096template<typename Derived>
13099 NestedNameSpecifierLoc QualifierLoc;
13100 if (E->getQualifierLoc()) {
13101 QualifierLoc
13102 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13103 if (!QualifierLoc)
13104 return ExprError();
13105 }
13106
13107 ValueDecl *ND
13108 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
13109 E->getDecl()));
13110 if (!ND || ND->isInvalidDecl())
13111 return ExprError();
13112
13113 NamedDecl *Found = ND;
13114 if (E->getFoundDecl() != E->getDecl()) {
13115 Found = cast_or_null<NamedDecl>(
13116 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
13117 if (!Found)
13118 return ExprError();
13119 }
13120
13121 DeclarationNameInfo NameInfo = E->getNameInfo();
13122 if (NameInfo.getName()) {
13123 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
13124 if (!NameInfo.getName())
13125 return ExprError();
13126 }
13127
13128 if (!getDerived().AlwaysRebuild() &&
13129 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
13130 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
13131 Found == E->getFoundDecl() &&
13132 NameInfo.getName() == E->getDecl()->getDeclName() &&
13133 !E->hasExplicitTemplateArgs()) {
13134
13135 // Mark it referenced in the new context regardless.
13136 // FIXME: this is a bit instantiation-specific.
13137 SemaRef.MarkDeclRefReferenced(E);
13138
13139 return E;
13140 }
13141
13142 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
13143 if (E->hasExplicitTemplateArgs()) {
13144 TemplateArgs = &TransArgs;
13145 TransArgs.setLAngleLoc(E->getLAngleLoc());
13146 TransArgs.setRAngleLoc(E->getRAngleLoc());
13147 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13148 E->getNumTemplateArgs(),
13149 TransArgs))
13150 return ExprError();
13151 }
13152
13153 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
13154 Found, TemplateArgs);
13155}
13156
13157template<typename Derived>
13160 return E;
13161}
13162
13163template <typename Derived>
13165 FixedPointLiteral *E) {
13166 return E;
13167}
13168
13169template<typename Derived>
13172 return E;
13173}
13174
13175template<typename Derived>
13178 return E;
13179}
13180
13181template<typename Derived>
13184 return E;
13185}
13186
13187template<typename Derived>
13190 return E;
13191}
13192
13193template<typename Derived>
13196 return getDerived().TransformCallExpr(E);
13197}
13198
13199template<typename Derived>
13202 ExprResult ControllingExpr;
13203 TypeSourceInfo *ControllingType = nullptr;
13204 if (E->isExprPredicate())
13205 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
13206 else
13207 ControllingType = getDerived().TransformType(E->getControllingType());
13208
13209 if (ControllingExpr.isInvalid() && !ControllingType)
13210 return ExprError();
13211
13212 SmallVector<Expr *, 4> AssocExprs;
13214 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
13215 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
13216 if (TSI) {
13217 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
13218 if (!AssocType)
13219 return ExprError();
13220 AssocTypes.push_back(AssocType);
13221 } else {
13222 AssocTypes.push_back(nullptr);
13223 }
13224
13225 ExprResult AssocExpr =
13226 getDerived().TransformExpr(Assoc.getAssociationExpr());
13227 if (AssocExpr.isInvalid())
13228 return ExprError();
13229 AssocExprs.push_back(AssocExpr.get());
13230 }
13231
13232 if (!ControllingType)
13233 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
13234 E->getDefaultLoc(),
13235 E->getRParenLoc(),
13236 ControllingExpr.get(),
13237 AssocTypes,
13238 AssocExprs);
13239 return getDerived().RebuildGenericSelectionExpr(
13240 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
13241 ControllingType, AssocTypes, AssocExprs);
13242}
13243
13244template<typename Derived>
13247 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13248 if (SubExpr.isInvalid())
13249 return ExprError();
13250
13251 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13252 return E;
13253
13254 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
13255 E->getRParen());
13256}
13257
13258/// The operand of a unary address-of operator has special rules: it's
13259/// allowed to refer to a non-static member of a class even if there's no 'this'
13260/// object available.
13261template<typename Derived>
13264 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
13265 return getDerived().TransformDependentScopeDeclRefExpr(
13266 DRE, /*IsAddressOfOperand=*/true, nullptr);
13267 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
13268 return getDerived().TransformUnresolvedLookupExpr(
13269 ULE, /*IsAddressOfOperand=*/true);
13270 else
13271 return getDerived().TransformExpr(E);
13272}
13273
13274template<typename Derived>
13277 ExprResult SubExpr;
13278 if (E->getOpcode() == UO_AddrOf)
13279 SubExpr = TransformAddressOfOperand(E->getSubExpr());
13280 else
13281 SubExpr = TransformExpr(E->getSubExpr());
13282 if (SubExpr.isInvalid())
13283 return ExprError();
13284
13285 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
13286 return E;
13287
13288 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
13289 E->getOpcode(),
13290 SubExpr.get());
13291}
13292
13293template<typename Derived>
13295TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
13296 // Transform the type.
13297 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13298 if (!Type)
13299 return ExprError();
13300
13301 // Transform all of the components into components similar to what the
13302 // parser uses.
13303 // FIXME: It would be slightly more efficient in the non-dependent case to
13304 // just map FieldDecls, rather than requiring the rebuilder to look for
13305 // the fields again. However, __builtin_offsetof is rare enough in
13306 // template code that we don't care.
13307 bool ExprChanged = false;
13308 typedef Sema::OffsetOfComponent Component;
13309 SmallVector<Component, 4> Components;
13310 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
13311 const OffsetOfNode &ON = E->getComponent(I);
13312 Component Comp;
13313 Comp.isBrackets = true;
13314 Comp.LocStart = ON.getSourceRange().getBegin();
13315 Comp.LocEnd = ON.getSourceRange().getEnd();
13316 switch (ON.getKind()) {
13317 case OffsetOfNode::Array: {
13318 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
13319 ExprResult Index = getDerived().TransformExpr(FromIndex);
13320 if (Index.isInvalid())
13321 return ExprError();
13322
13323 ExprChanged = ExprChanged || Index.get() != FromIndex;
13324 Comp.isBrackets = true;
13325 Comp.U.E = Index.get();
13326 break;
13327 }
13328
13331 Comp.isBrackets = false;
13332 Comp.U.IdentInfo = ON.getFieldName();
13333 if (!Comp.U.IdentInfo)
13334 continue;
13335
13336 break;
13337
13338 case OffsetOfNode::Base:
13339 // Will be recomputed during the rebuild.
13340 continue;
13341 }
13342
13343 Components.push_back(Comp);
13344 }
13345
13346 // If nothing changed, retain the existing expression.
13347 if (!getDerived().AlwaysRebuild() &&
13348 Type == E->getTypeSourceInfo() &&
13349 !ExprChanged)
13350 return E;
13351
13352 // Build a new offsetof expression.
13353 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
13354 Components, E->getRParenLoc());
13355}
13356
13357template<typename Derived>
13360 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
13361 "opaque value expression requires transformation");
13362 return E;
13363}
13364
13365template <typename Derived>
13368 bool Changed = false;
13369 for (Expr *C : E->subExpressions()) {
13370 ExprResult NewC = getDerived().TransformExpr(C);
13371 if (NewC.isInvalid())
13372 return ExprError();
13373 Children.push_back(NewC.get());
13374
13375 Changed |= NewC.get() != C;
13376 }
13377 if (!getDerived().AlwaysRebuild() && !Changed)
13378 return E;
13379 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
13380 Children, E->getType());
13381}
13382
13383template<typename Derived>
13386 // Rebuild the syntactic form. The original syntactic form has
13387 // opaque-value expressions in it, so strip those away and rebuild
13388 // the result. This is a really awful way of doing this, but the
13389 // better solution (rebuilding the semantic expressions and
13390 // rebinding OVEs as necessary) doesn't work; we'd need
13391 // TreeTransform to not strip away implicit conversions.
13392 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
13393 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13394 if (result.isInvalid()) return ExprError();
13395
13396 // If that gives us a pseudo-object result back, the pseudo-object
13397 // expression must have been an lvalue-to-rvalue conversion which we
13398 // should reapply.
13399 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13400 result = SemaRef.PseudoObject().checkRValue(result.get());
13401
13402 return result;
13403}
13404
13405template<typename Derived>
13409 if (E->isArgumentType()) {
13410 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13411
13412 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13413 if (!NewT)
13414 return ExprError();
13415
13416 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13417 return E;
13418
13419 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13420 E->getKind(),
13421 E->getSourceRange());
13422 }
13423
13424 // C++0x [expr.sizeof]p1:
13425 // The operand is either an expression, which is an unevaluated operand
13426 // [...]
13430
13431 // Try to recover if we have something like sizeof(T::X) where X is a type.
13432 // Notably, there must be *exactly* one set of parens if X is a type.
13433 TypeSourceInfo *RecoveryTSI = nullptr;
13434 ExprResult SubExpr;
13435 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13436 if (auto *DRE =
13437 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13438 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13439 PE, DRE, false, &RecoveryTSI);
13440 else
13441 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13442
13443 if (RecoveryTSI) {
13444 return getDerived().RebuildUnaryExprOrTypeTrait(
13445 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13446 } else if (SubExpr.isInvalid())
13447 return ExprError();
13448
13449 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13450 return E;
13451
13452 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13453 E->getOperatorLoc(),
13454 E->getKind(),
13455 E->getSourceRange());
13456}
13457
13458template<typename Derived>
13461 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13462 if (LHS.isInvalid())
13463 return ExprError();
13464
13465 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13466 if (RHS.isInvalid())
13467 return ExprError();
13468
13469
13470 if (!getDerived().AlwaysRebuild() &&
13471 LHS.get() == E->getLHS() &&
13472 RHS.get() == E->getRHS())
13473 return E;
13474
13475 return getDerived().RebuildArraySubscriptExpr(
13476 LHS.get(),
13477 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13478}
13479
13480template <typename Derived>
13483 ExprResult Base = getDerived().TransformExpr(E->getBase());
13484 if (Base.isInvalid())
13485 return ExprError();
13486
13487 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13488 if (RowIdx.isInvalid())
13489 return ExprError();
13490
13491 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13492 RowIdx.get() == E->getRowIdx())
13493 return E;
13494
13495 return getDerived().RebuildMatrixSingleSubscriptExpr(Base.get(), RowIdx.get(),
13496 E->getRBracketLoc());
13497}
13498
13499template <typename Derived>
13502 ExprResult Base = getDerived().TransformExpr(E->getBase());
13503 if (Base.isInvalid())
13504 return ExprError();
13505
13506 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13507 if (RowIdx.isInvalid())
13508 return ExprError();
13509
13510 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13511 if (ColumnIdx.isInvalid())
13512 return ExprError();
13513
13514 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13515 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13516 return E;
13517
13518 return getDerived().RebuildMatrixSubscriptExpr(
13519 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13520}
13521
13522template <typename Derived>
13525 ExprResult Base = getDerived().TransformExpr(E->getBase());
13526 if (Base.isInvalid())
13527 return ExprError();
13528
13529 ExprResult LowerBound;
13530 if (E->getLowerBound()) {
13531 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13532 if (LowerBound.isInvalid())
13533 return ExprError();
13534 }
13535
13536 ExprResult Length;
13537 if (E->getLength()) {
13538 Length = getDerived().TransformExpr(E->getLength());
13539 if (Length.isInvalid())
13540 return ExprError();
13541 }
13542
13543 ExprResult Stride;
13544 if (E->isOMPArraySection()) {
13545 if (Expr *Str = E->getStride()) {
13546 Stride = getDerived().TransformExpr(Str);
13547 if (Stride.isInvalid())
13548 return ExprError();
13549 }
13550 }
13551
13552 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13553 LowerBound.get() == E->getLowerBound() &&
13554 Length.get() == E->getLength() &&
13555 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13556 return E;
13557
13558 return getDerived().RebuildArraySectionExpr(
13559 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13560 LowerBound.get(), E->getColonLocFirst(),
13561 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13562 Length.get(), Stride.get(), E->getRBracketLoc());
13563}
13564
13565template <typename Derived>
13568 ExprResult Base = getDerived().TransformExpr(E->getBase());
13569 if (Base.isInvalid())
13570 return ExprError();
13571
13573 bool ErrorFound = false;
13574 for (Expr *Dim : E->getDimensions()) {
13575 ExprResult DimRes = getDerived().TransformExpr(Dim);
13576 if (DimRes.isInvalid()) {
13577 ErrorFound = true;
13578 continue;
13579 }
13580 Dims.push_back(DimRes.get());
13581 }
13582
13583 if (ErrorFound)
13584 return ExprError();
13585 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13586 E->getRParenLoc(), Dims,
13587 E->getBracketsRanges());
13588}
13589
13590template <typename Derived>
13593 unsigned NumIterators = E->numOfIterators();
13595
13596 bool ErrorFound = false;
13597 bool NeedToRebuild = getDerived().AlwaysRebuild();
13598 for (unsigned I = 0; I < NumIterators; ++I) {
13599 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13600 Data[I].DeclIdent = D->getIdentifier();
13601 Data[I].DeclIdentLoc = D->getLocation();
13602 if (D->getLocation() == D->getBeginLoc()) {
13603 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13604 "Implicit type must be int.");
13605 } else {
13606 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13607 QualType DeclTy = getDerived().TransformType(D->getType());
13608 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13609 }
13610 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13611 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13612 ExprResult End = getDerived().TransformExpr(Range.End);
13613 ExprResult Step = getDerived().TransformExpr(Range.Step);
13614 ErrorFound = ErrorFound ||
13615 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13616 !Data[I].Type.get().isNull())) ||
13617 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13618 if (ErrorFound)
13619 continue;
13620 Data[I].Range.Begin = Begin.get();
13621 Data[I].Range.End = End.get();
13622 Data[I].Range.Step = Step.get();
13623 Data[I].AssignLoc = E->getAssignLoc(I);
13624 Data[I].ColonLoc = E->getColonLoc(I);
13625 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13626 NeedToRebuild =
13627 NeedToRebuild ||
13628 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13629 D->getType().getTypePtrOrNull()) ||
13630 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13631 Range.Step != Data[I].Range.Step;
13632 }
13633 if (ErrorFound)
13634 return ExprError();
13635 if (!NeedToRebuild)
13636 return E;
13637
13638 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13639 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13640 if (!Res.isUsable())
13641 return Res;
13642 auto *IE = cast<OMPIteratorExpr>(Res.get());
13643 for (unsigned I = 0; I < NumIterators; ++I)
13644 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13645 IE->getIteratorDecl(I));
13646 return Res;
13647}
13648
13649template<typename Derived>
13652 // Transform the callee.
13653 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13654 if (Callee.isInvalid())
13655 return ExprError();
13656
13657 // Transform arguments.
13658 bool ArgChanged = false;
13660 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13661 &ArgChanged))
13662 return ExprError();
13663
13664 if (!getDerived().AlwaysRebuild() &&
13665 Callee.get() == E->getCallee() &&
13666 !ArgChanged)
13667 return SemaRef.MaybeBindToTemporary(E);
13668
13669 // FIXME: Wrong source location information for the '('.
13670 SourceLocation FakeLParenLoc
13671 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13672
13673 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13674 if (E->hasStoredFPFeatures()) {
13675 FPOptionsOverride NewOverrides = E->getFPFeatures();
13676 getSema().CurFPFeatures =
13677 NewOverrides.applyOverrides(getSema().getLangOpts());
13678 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13679 }
13680
13681 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13682 Args,
13683 E->getRParenLoc());
13684}
13685
13686template<typename Derived>
13689 ExprResult Base = getDerived().TransformExpr(E->getBase());
13690 if (Base.isInvalid())
13691 return ExprError();
13692
13693 NestedNameSpecifierLoc QualifierLoc;
13694 if (E->hasQualifier()) {
13695 QualifierLoc
13696 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13697
13698 if (!QualifierLoc)
13699 return ExprError();
13700 }
13701 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13702
13704 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13705 E->getMemberDecl()));
13706 if (!Member)
13707 return ExprError();
13708
13709 NamedDecl *FoundDecl = E->getFoundDecl();
13710 if (FoundDecl == E->getMemberDecl()) {
13711 FoundDecl = Member;
13712 } else {
13713 FoundDecl = cast_or_null<NamedDecl>(
13714 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13715 if (!FoundDecl)
13716 return ExprError();
13717 }
13718
13719 if (!getDerived().AlwaysRebuild() &&
13720 Base.get() == E->getBase() &&
13721 QualifierLoc == E->getQualifierLoc() &&
13722 Member == E->getMemberDecl() &&
13723 FoundDecl == E->getFoundDecl() &&
13724 !E->hasExplicitTemplateArgs()) {
13725
13726 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13727 // for Openmp where the field need to be privatizized in the case.
13728 if (!(isa<CXXThisExpr>(E->getBase()) &&
13729 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13731 // Mark it referenced in the new context regardless.
13732 // FIXME: this is a bit instantiation-specific.
13733 SemaRef.MarkMemberReferenced(E);
13734 return E;
13735 }
13736 }
13737
13738 TemplateArgumentListInfo TransArgs;
13739 if (E->hasExplicitTemplateArgs()) {
13740 TransArgs.setLAngleLoc(E->getLAngleLoc());
13741 TransArgs.setRAngleLoc(E->getRAngleLoc());
13742 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13743 E->getNumTemplateArgs(),
13744 TransArgs))
13745 return ExprError();
13746 }
13747
13748 // FIXME: Bogus source location for the operator
13749 SourceLocation FakeOperatorLoc =
13750 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13751
13752 // FIXME: to do this check properly, we will need to preserve the
13753 // first-qualifier-in-scope here, just in case we had a dependent
13754 // base (and therefore couldn't do the check) and a
13755 // nested-name-qualifier (and therefore could do the lookup).
13756 NamedDecl *FirstQualifierInScope = nullptr;
13757 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13758 if (MemberNameInfo.getName()) {
13759 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13760 if (!MemberNameInfo.getName())
13761 return ExprError();
13762 }
13763
13764 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13765 E->isArrow(),
13766 QualifierLoc,
13767 TemplateKWLoc,
13768 MemberNameInfo,
13769 Member,
13770 FoundDecl,
13771 (E->hasExplicitTemplateArgs()
13772 ? &TransArgs : nullptr),
13773 FirstQualifierInScope);
13774}
13775
13776template<typename Derived>
13779 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13780 if (LHS.isInvalid())
13781 return ExprError();
13782
13783 ExprResult RHS =
13784 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13785 if (RHS.isInvalid())
13786 return ExprError();
13787
13788 if (!getDerived().AlwaysRebuild() &&
13789 LHS.get() == E->getLHS() &&
13790 RHS.get() == E->getRHS())
13791 return E;
13792
13793 if (E->isCompoundAssignmentOp())
13794 // FPFeatures has already been established from trailing storage
13795 return getDerived().RebuildBinaryOperator(
13796 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13797 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13798 FPOptionsOverride NewOverrides(E->getFPFeatures());
13799 getSema().CurFPFeatures =
13800 NewOverrides.applyOverrides(getSema().getLangOpts());
13801 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13802 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13803 LHS.get(), RHS.get());
13804}
13805
13806template <typename Derived>
13809 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13810
13811 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13812 if (LHS.isInvalid())
13813 return ExprError();
13814
13815 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13816 if (RHS.isInvalid())
13817 return ExprError();
13818
13819 // Extract the already-resolved callee declarations so that we can restrict
13820 // ourselves to using them as the unqualified lookup results when rebuilding.
13821 UnresolvedSet<2> UnqualLookups;
13822 bool ChangedAnyLookups = false;
13823 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13824 const_cast<Expr *>(Decomp.InnerBinOp)};
13825 for (Expr *PossibleBinOp : PossibleBinOps) {
13826 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13827 if (!Op)
13828 continue;
13829 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13830 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13831 continue;
13832
13833 // Transform the callee in case we built a call to a local extern
13834 // declaration.
13835 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13836 E->getOperatorLoc(), Callee->getFoundDecl()));
13837 if (!Found)
13838 return ExprError();
13839 if (Found != Callee->getFoundDecl())
13840 ChangedAnyLookups = true;
13841 UnqualLookups.addDecl(Found);
13842 }
13843
13844 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13845 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13846 // Mark all functions used in the rewrite as referenced. Note that when
13847 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13848 // function calls, and/or there might be a user-defined conversion sequence
13849 // applied to the operands of the <.
13850 // FIXME: this is a bit instantiation-specific.
13851 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13852 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13853 return E;
13854 }
13855
13856 return getDerived().RebuildCXXRewrittenBinaryOperator(
13857 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13858}
13859
13860template<typename Derived>
13864 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13865 FPOptionsOverride NewOverrides(E->getFPFeatures());
13866 getSema().CurFPFeatures =
13867 NewOverrides.applyOverrides(getSema().getLangOpts());
13868 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13869 return getDerived().TransformBinaryOperator(E);
13870}
13871
13872template<typename Derived>
13875 // Just rebuild the common and RHS expressions and see whether we
13876 // get any changes.
13877
13878 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13879 if (commonExpr.isInvalid())
13880 return ExprError();
13881
13882 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13883 if (rhs.isInvalid())
13884 return ExprError();
13885
13886 if (!getDerived().AlwaysRebuild() &&
13887 commonExpr.get() == e->getCommon() &&
13888 rhs.get() == e->getFalseExpr())
13889 return e;
13890
13891 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13892 e->getQuestionLoc(),
13893 nullptr,
13894 e->getColonLoc(),
13895 rhs.get());
13896}
13897
13898template<typename Derived>
13901 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13902 if (Cond.isInvalid())
13903 return ExprError();
13904
13905 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13906 if (LHS.isInvalid())
13907 return ExprError();
13908
13909 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13910 if (RHS.isInvalid())
13911 return ExprError();
13912
13913 if (!getDerived().AlwaysRebuild() &&
13914 Cond.get() == E->getCond() &&
13915 LHS.get() == E->getLHS() &&
13916 RHS.get() == E->getRHS())
13917 return E;
13918
13919 return getDerived().RebuildConditionalOperator(Cond.get(),
13920 E->getQuestionLoc(),
13921 LHS.get(),
13922 E->getColonLoc(),
13923 RHS.get());
13924}
13925
13926template<typename Derived>
13929 // Implicit casts are eliminated during transformation, since they
13930 // will be recomputed by semantic analysis after transformation.
13931 return getDerived().TransformExpr(E->getSubExprAsWritten());
13932}
13933
13934template<typename Derived>
13937 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
13938 if (!Type)
13939 return ExprError();
13940
13941 ExprResult SubExpr
13942 = getDerived().TransformExpr(E->getSubExprAsWritten());
13943 if (SubExpr.isInvalid())
13944 return ExprError();
13945
13946 if (!getDerived().AlwaysRebuild() &&
13947 Type == E->getTypeInfoAsWritten() &&
13948 SubExpr.get() == E->getSubExpr())
13949 return E;
13950
13951 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
13952 Type,
13953 E->getRParenLoc(),
13954 SubExpr.get());
13955}
13956
13957template<typename Derived>
13960 TypeSourceInfo *OldT = E->getTypeSourceInfo();
13961 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13962 if (!NewT)
13963 return ExprError();
13964
13965 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
13966 if (Init.isInvalid())
13967 return ExprError();
13968
13969 if (!getDerived().AlwaysRebuild() &&
13970 OldT == NewT &&
13971 Init.get() == E->getInitializer())
13972 return SemaRef.MaybeBindToTemporary(E);
13973
13974 // Note: the expression type doesn't necessarily match the
13975 // type-as-written, but that's okay, because it should always be
13976 // derivable from the initializer.
13977
13978 return getDerived().RebuildCompoundLiteralExpr(
13979 E->getLParenLoc(), NewT,
13980 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
13981}
13982
13983template<typename Derived>
13986 ExprResult Base = getDerived().TransformExpr(E->getBase());
13987 if (Base.isInvalid())
13988 return ExprError();
13989
13990 if (!getDerived().AlwaysRebuild() &&
13991 Base.get() == E->getBase())
13992 return E;
13993
13994 // FIXME: Bad source location
13995 SourceLocation FakeOperatorLoc =
13996 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
13997 return getDerived().RebuildExtVectorOrMatrixElementExpr(
13998 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
13999 E->getAccessor());
14000}
14001
14002template <typename Derived>
14005 ExprResult Base = getDerived().TransformExpr(E->getBase());
14006 if (Base.isInvalid())
14007 return ExprError();
14008
14009 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase())
14010 return E;
14011
14012 // FIXME: Bad source location
14013 SourceLocation FakeOperatorLoc =
14014 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
14015 return getDerived().RebuildExtVectorOrMatrixElementExpr(
14016 Base.get(), FakeOperatorLoc, /*isArrow*/ false, E->getAccessorLoc(),
14017 E->getAccessor());
14018}
14019
14020template<typename Derived>
14023 if (InitListExpr *Syntactic = E->getSyntacticForm())
14024 E = Syntactic;
14025
14026 bool InitChanged = false;
14027
14030
14032 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
14033 Inits, &InitChanged))
14034 return ExprError();
14035
14036 if (!getDerived().AlwaysRebuild() && !InitChanged) {
14037 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
14038 // in some cases. We can't reuse it in general, because the syntactic and
14039 // semantic forms are linked, and we can't know that semantic form will
14040 // match even if the syntactic form does.
14041 }
14042
14043 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
14044 E->getRBraceLoc());
14045}
14046
14047template<typename Derived>
14050 Designation Desig;
14051
14052 // transform the initializer value
14053 ExprResult Init = getDerived().TransformExpr(E->getInit());
14054 if (Init.isInvalid())
14055 return ExprError();
14056
14057 // transform the designators.
14058 SmallVector<Expr*, 4> ArrayExprs;
14059 bool ExprChanged = false;
14060 for (const DesignatedInitExpr::Designator &D : E->designators()) {
14061 if (D.isFieldDesignator()) {
14062 if (D.getFieldDecl()) {
14063 FieldDecl *Field = cast_or_null<FieldDecl>(
14064 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
14065 if (Field != D.getFieldDecl())
14066 // Rebuild the expression when the transformed FieldDecl is
14067 // different to the already assigned FieldDecl.
14068 ExprChanged = true;
14069 if (Field->isAnonymousStructOrUnion())
14070 continue;
14071 } else {
14072 // Ensure that the designator expression is rebuilt when there isn't
14073 // a resolved FieldDecl in the designator as we don't want to assign
14074 // a FieldDecl to a pattern designator that will be instantiated again.
14075 ExprChanged = true;
14076 }
14077 Desig.AddDesignator(Designator::CreateFieldDesignator(
14078 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
14079 continue;
14080 }
14081
14082 if (D.isArrayDesignator()) {
14083 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
14084 if (Index.isInvalid())
14085 return ExprError();
14086
14087 Desig.AddDesignator(
14088 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
14089
14090 ExprChanged = ExprChanged || Index.get() != E->getArrayIndex(D);
14091 ArrayExprs.push_back(Index.get());
14092 continue;
14093 }
14094
14095 assert(D.isArrayRangeDesignator() && "New kind of designator?");
14096 ExprResult Start
14097 = getDerived().TransformExpr(E->getArrayRangeStart(D));
14098 if (Start.isInvalid())
14099 return ExprError();
14100
14101 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
14102 if (End.isInvalid())
14103 return ExprError();
14104
14105 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
14106 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
14107
14108 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
14109 End.get() != E->getArrayRangeEnd(D);
14110
14111 ArrayExprs.push_back(Start.get());
14112 ArrayExprs.push_back(End.get());
14113 }
14114
14115 if (!getDerived().AlwaysRebuild() &&
14116 Init.get() == E->getInit() &&
14117 !ExprChanged)
14118 return E;
14119
14120 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
14121 E->getEqualOrColonLoc(),
14122 E->usesGNUSyntax(), Init.get());
14123}
14124
14125// Seems that if TransformInitListExpr() only works on the syntactic form of an
14126// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
14127template<typename Derived>
14131 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
14132 "initializer");
14133 return ExprError();
14134}
14135
14136template<typename Derived>
14139 NoInitExpr *E) {
14140 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
14141 return ExprError();
14142}
14143
14144template<typename Derived>
14147 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
14148 return ExprError();
14149}
14150
14151template<typename Derived>
14154 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
14155 return ExprError();
14156}
14157
14158template<typename Derived>
14162 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
14163
14164 // FIXME: Will we ever have proper type location here? Will we actually
14165 // need to transform the type?
14166 QualType T = getDerived().TransformType(E->getType());
14167 if (T.isNull())
14168 return ExprError();
14169
14170 if (!getDerived().AlwaysRebuild() &&
14171 T == E->getType())
14172 return E;
14173
14174 return getDerived().RebuildImplicitValueInitExpr(T);
14175}
14176
14177template<typename Derived>
14180 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
14181 if (!TInfo)
14182 return ExprError();
14183
14184 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14185 if (SubExpr.isInvalid())
14186 return ExprError();
14187
14188 if (!getDerived().AlwaysRebuild() &&
14189 TInfo == E->getWrittenTypeInfo() &&
14190 SubExpr.get() == E->getSubExpr())
14191 return E;
14192
14193 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
14194 TInfo, E->getRParenLoc());
14195}
14196
14197template<typename Derived>
14200 bool ArgumentChanged = false;
14202 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
14203 &ArgumentChanged))
14204 return ExprError();
14205
14206 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
14207 Inits,
14208 E->getRParenLoc());
14209}
14210
14211/// Transform an address-of-label expression.
14212///
14213/// By default, the transformation of an address-of-label expression always
14214/// rebuilds the expression, so that the label identifier can be resolved to
14215/// the corresponding label statement by semantic analysis.
14216template<typename Derived>
14219 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
14220 E->getLabel());
14221 if (!LD)
14222 return ExprError();
14223
14224 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
14225 cast<LabelDecl>(LD));
14226}
14227
14228template<typename Derived>
14231 SemaRef.ActOnStartStmtExpr();
14232 StmtResult SubStmt
14233 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
14234 if (SubStmt.isInvalid()) {
14235 SemaRef.ActOnStmtExprError();
14236 return ExprError();
14237 }
14238
14239 unsigned OldDepth = E->getTemplateDepth();
14240 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
14241
14242 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
14243 SubStmt.get() == E->getSubStmt()) {
14244 // Calling this an 'error' is unintuitive, but it does the right thing.
14245 SemaRef.ActOnStmtExprError();
14246 return SemaRef.MaybeBindToTemporary(E);
14247 }
14248
14249 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
14250 E->getRParenLoc(), NewDepth);
14251}
14252
14253template<typename Derived>
14256 ExprResult Cond = getDerived().TransformExpr(E->getCond());
14257 if (Cond.isInvalid())
14258 return ExprError();
14259
14260 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
14261 if (LHS.isInvalid())
14262 return ExprError();
14263
14264 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
14265 if (RHS.isInvalid())
14266 return ExprError();
14267
14268 if (!getDerived().AlwaysRebuild() &&
14269 Cond.get() == E->getCond() &&
14270 LHS.get() == E->getLHS() &&
14271 RHS.get() == E->getRHS())
14272 return E;
14273
14274 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
14275 Cond.get(), LHS.get(), RHS.get(),
14276 E->getRParenLoc());
14277}
14278
14279template<typename Derived>
14282 return E;
14283}
14284
14285template<typename Derived>
14288 switch (E->getOperator()) {
14289 case OO_New:
14290 case OO_Delete:
14291 case OO_Array_New:
14292 case OO_Array_Delete:
14293 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
14294
14295 case OO_Subscript:
14296 case OO_Call: {
14297 // This is a call to an object's operator().
14298 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
14299
14300 // Transform the object itself.
14301 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
14302 if (Object.isInvalid())
14303 return ExprError();
14304
14305 // FIXME: Poor location information. Also, if the location for the end of
14306 // the token is within a macro expansion, getLocForEndOfToken() will return
14307 // an invalid source location. If that happens and we have an otherwise
14308 // valid end location, use the valid one instead of the invalid one.
14309 SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
14310 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
14311 if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
14312 FakeLParenLoc = EndLoc;
14313
14314 // Transform the call arguments.
14316 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
14317 Args))
14318 return ExprError();
14319
14320 if (E->getOperator() == OO_Subscript)
14321 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
14322 Args, E->getEndLoc());
14323
14324 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
14325 E->getEndLoc());
14326 }
14327
14328#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
14329 case OO_##Name: \
14330 break;
14331
14332#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
14333#include "clang/Basic/OperatorKinds.def"
14334
14335 case OO_Conditional:
14336 llvm_unreachable("conditional operator is not actually overloadable");
14337
14338 case OO_None:
14340 llvm_unreachable("not an overloaded operator?");
14341 }
14342
14344 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
14345 First = getDerived().TransformAddressOfOperand(E->getArg(0));
14346 else
14347 First = getDerived().TransformExpr(E->getArg(0));
14348 if (First.isInvalid())
14349 return ExprError();
14350
14351 ExprResult Second;
14352 if (E->getNumArgs() == 2) {
14353 Second =
14354 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
14355 if (Second.isInvalid())
14356 return ExprError();
14357 }
14358
14359 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
14360 FPOptionsOverride NewOverrides(E->getFPFeatures());
14361 getSema().CurFPFeatures =
14362 NewOverrides.applyOverrides(getSema().getLangOpts());
14363 getSema().FpPragmaStack.CurrentValue = NewOverrides;
14364
14365 Expr *Callee = E->getCallee();
14366 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
14367 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
14369 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
14370 return ExprError();
14371
14372 return getDerived().RebuildCXXOperatorCallExpr(
14373 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14374 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
14375 }
14376
14377 UnresolvedSet<1> Functions;
14378 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
14379 Callee = ICE->getSubExprAsWritten();
14380 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
14381 ValueDecl *VD = cast_or_null<ValueDecl>(
14382 getDerived().TransformDecl(DR->getLocation(), DR));
14383 if (!VD)
14384 return ExprError();
14385
14386 if (!isa<CXXMethodDecl>(VD))
14387 Functions.addDecl(VD);
14388
14389 return getDerived().RebuildCXXOperatorCallExpr(
14390 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
14391 /*RequiresADL=*/false, Functions, First.get(), Second.get());
14392}
14393
14394template<typename Derived>
14397 return getDerived().TransformCallExpr(E);
14398}
14399
14400template <typename Derived>
14402 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
14403 getSema().CurContext != E->getParentContext();
14404
14405 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
14406 return E;
14407
14408 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
14409 E->getBeginLoc(), E->getEndLoc(),
14410 getSema().CurContext);
14411}
14412
14413template <typename Derived>
14415 return E;
14416}
14417
14418template<typename Derived>
14421 // Transform the callee.
14422 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
14423 if (Callee.isInvalid())
14424 return ExprError();
14425
14426 // Transform exec config.
14427 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
14428 if (EC.isInvalid())
14429 return ExprError();
14430
14431 // Transform arguments.
14432 bool ArgChanged = false;
14434 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
14435 &ArgChanged))
14436 return ExprError();
14437
14438 if (!getDerived().AlwaysRebuild() &&
14439 Callee.get() == E->getCallee() &&
14440 !ArgChanged)
14441 return SemaRef.MaybeBindToTemporary(E);
14442
14443 // FIXME: Wrong source location information for the '('.
14444 SourceLocation FakeLParenLoc
14445 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14446 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14447 Args,
14448 E->getRParenLoc(), EC.get());
14449}
14450
14451template<typename Derived>
14454 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14455 if (!Type)
14456 return ExprError();
14457
14458 ExprResult SubExpr
14459 = getDerived().TransformExpr(E->getSubExprAsWritten());
14460 if (SubExpr.isInvalid())
14461 return ExprError();
14462
14463 if (!getDerived().AlwaysRebuild() &&
14464 Type == E->getTypeInfoAsWritten() &&
14465 SubExpr.get() == E->getSubExpr())
14466 return E;
14467 return getDerived().RebuildCXXNamedCastExpr(
14470 // FIXME. this should be '(' location
14471 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14472}
14473
14474template<typename Derived>
14477 TypeSourceInfo *TSI =
14478 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14479 if (!TSI)
14480 return ExprError();
14481
14482 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14483 if (Sub.isInvalid())
14484 return ExprError();
14485
14486 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14487 Sub.get(), BCE->getEndLoc());
14488}
14489
14490template<typename Derived>
14492TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14493 return getDerived().TransformCXXNamedCastExpr(E);
14494}
14495
14496template<typename Derived>
14499 return getDerived().TransformCXXNamedCastExpr(E);
14500}
14501
14502template<typename Derived>
14506 return getDerived().TransformCXXNamedCastExpr(E);
14507}
14508
14509template<typename Derived>
14512 return getDerived().TransformCXXNamedCastExpr(E);
14513}
14514
14515template<typename Derived>
14518 return getDerived().TransformCXXNamedCastExpr(E);
14519}
14520
14521template<typename Derived>
14526 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14527 if (!Type)
14528 return ExprError();
14529
14530 ExprResult SubExpr
14531 = getDerived().TransformExpr(E->getSubExprAsWritten());
14532 if (SubExpr.isInvalid())
14533 return ExprError();
14534
14535 if (!getDerived().AlwaysRebuild() &&
14536 Type == E->getTypeInfoAsWritten() &&
14537 SubExpr.get() == E->getSubExpr())
14538 return E;
14539
14540 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14541 E->getLParenLoc(),
14542 SubExpr.get(),
14543 E->getRParenLoc(),
14544 E->isListInitialization());
14545}
14546
14547template<typename Derived>
14550 if (E->isTypeOperand()) {
14551 TypeSourceInfo *TInfo
14552 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14553 if (!TInfo)
14554 return ExprError();
14555
14556 if (!getDerived().AlwaysRebuild() &&
14557 TInfo == E->getTypeOperandSourceInfo())
14558 return E;
14559
14560 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14561 TInfo, E->getEndLoc());
14562 }
14563
14564 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14565 // type. We must not unilaterally enter unevaluated context here, as then
14566 // semantic processing can re-transform an already transformed operand.
14567 Expr *Op = E->getExprOperand();
14569 if (E->isGLValue())
14570 if (auto *RD = Op->getType()->getAsCXXRecordDecl();
14571 RD && RD->isPolymorphic())
14572 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14573
14576
14577 ExprResult SubExpr = getDerived().TransformExpr(Op);
14578 if (SubExpr.isInvalid())
14579 return ExprError();
14580
14581 if (!getDerived().AlwaysRebuild() &&
14582 SubExpr.get() == E->getExprOperand())
14583 return E;
14584
14585 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14586 SubExpr.get(), E->getEndLoc());
14587}
14588
14589template<typename Derived>
14592 if (E->isTypeOperand()) {
14593 TypeSourceInfo *TInfo
14594 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14595 if (!TInfo)
14596 return ExprError();
14597
14598 if (!getDerived().AlwaysRebuild() &&
14599 TInfo == E->getTypeOperandSourceInfo())
14600 return E;
14601
14602 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14603 TInfo, E->getEndLoc());
14604 }
14605
14608
14609 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14610 if (SubExpr.isInvalid())
14611 return ExprError();
14612
14613 if (!getDerived().AlwaysRebuild() &&
14614 SubExpr.get() == E->getExprOperand())
14615 return E;
14616
14617 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14618 SubExpr.get(), E->getEndLoc());
14619}
14620
14621template<typename Derived>
14624 return E;
14625}
14626
14627template<typename Derived>
14631 return E;
14632}
14633
14634template<typename Derived>
14637
14638 // In lambdas, the qualifiers of the type depends of where in
14639 // the call operator `this` appear, and we do not have a good way to
14640 // rebuild this information, so we transform the type.
14641 //
14642 // In other contexts, the type of `this` may be overrided
14643 // for type deduction, so we need to recompute it.
14644 //
14645 // Always recompute the type if we're in the body of a lambda, and
14646 // 'this' is dependent on a lambda's explicit object parameter; we
14647 // also need to always rebuild the expression in this case to clear
14648 // the flag.
14649 QualType T = [&]() {
14650 auto &S = getSema();
14651 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14652 return S.getCurrentThisType();
14653 if (S.getCurLambda())
14654 return getDerived().TransformType(E->getType());
14655 return S.getCurrentThisType();
14656 }();
14657
14658 if (!getDerived().AlwaysRebuild() && T == E->getType() &&
14659 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) {
14660 // Mark it referenced in the new context regardless.
14661 // FIXME: this is a bit instantiation-specific.
14662 getSema().MarkThisReferenced(E);
14663 return E;
14664 }
14665
14666 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14667}
14668
14669template<typename Derived>
14672 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14673 if (SubExpr.isInvalid())
14674 return ExprError();
14675
14676 getSema().DiagnoseExceptionUse(E->getThrowLoc(), /* IsTry= */ false);
14677
14678 if (!getDerived().AlwaysRebuild() &&
14679 SubExpr.get() == E->getSubExpr())
14680 return E;
14681
14682 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14683 E->isThrownVariableInScope());
14684}
14685
14686template<typename Derived>
14689 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14690 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14691 if (!Param)
14692 return ExprError();
14693
14694 ExprResult InitRes;
14695 if (E->hasRewrittenInit()) {
14696 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14697 if (InitRes.isInvalid())
14698 return ExprError();
14699 }
14700
14701 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14702 E->getUsedContext() == SemaRef.CurContext &&
14703 InitRes.get() == E->getRewrittenExpr())
14704 return E;
14705
14706 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14707 InitRes.get());
14708}
14709
14710template<typename Derived>
14713 FieldDecl *Field = cast_or_null<FieldDecl>(
14714 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14715 if (!Field)
14716 return ExprError();
14717
14718 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14719 E->getUsedContext() == SemaRef.CurContext)
14720 return E;
14721
14722 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14723}
14724
14725template<typename Derived>
14729 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14730 if (!T)
14731 return ExprError();
14732
14733 if (!getDerived().AlwaysRebuild() &&
14734 T == E->getTypeSourceInfo())
14735 return E;
14736
14737 return getDerived().RebuildCXXScalarValueInitExpr(T,
14738 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14739 E->getRParenLoc());
14740}
14741
14742template<typename Derived>
14745 // Transform the type that we're allocating
14746 TypeSourceInfo *AllocTypeInfo =
14747 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14748 if (!AllocTypeInfo)
14749 return ExprError();
14750
14751 // Transform the size of the array we're allocating (if any).
14752 std::optional<Expr *> ArraySize;
14753 if (E->isArray()) {
14754 ExprResult NewArraySize;
14755 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14756 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14757 if (NewArraySize.isInvalid())
14758 return ExprError();
14759 }
14760 ArraySize = NewArraySize.get();
14761 }
14762
14763 // Transform the placement arguments (if any).
14764 bool ArgumentChanged = false;
14765 SmallVector<Expr*, 8> PlacementArgs;
14766 if (getDerived().TransformExprs(E->getPlacementArgs(),
14767 E->getNumPlacementArgs(), true,
14768 PlacementArgs, &ArgumentChanged))
14769 return ExprError();
14770
14771 // Transform the initializer (if any).
14772 Expr *OldInit = E->getInitializer();
14773 ExprResult NewInit;
14774 if (OldInit)
14775 NewInit = getDerived().TransformInitializer(OldInit, true);
14776 if (NewInit.isInvalid())
14777 return ExprError();
14778
14779 // Transform new operator and delete operator.
14780 FunctionDecl *OperatorNew = nullptr;
14781 if (E->getOperatorNew()) {
14782 OperatorNew = cast_or_null<FunctionDecl>(
14783 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14784 if (!OperatorNew)
14785 return ExprError();
14786 }
14787
14788 FunctionDecl *OperatorDelete = nullptr;
14789 if (E->getOperatorDelete()) {
14790 OperatorDelete = cast_or_null<FunctionDecl>(
14791 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14792 if (!OperatorDelete)
14793 return ExprError();
14794 }
14795
14796 if (!getDerived().AlwaysRebuild() &&
14797 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14798 ArraySize == E->getArraySize() &&
14799 NewInit.get() == OldInit &&
14800 OperatorNew == E->getOperatorNew() &&
14801 OperatorDelete == E->getOperatorDelete() &&
14802 !ArgumentChanged) {
14803 // Mark any declarations we need as referenced.
14804 // FIXME: instantiation-specific.
14805 if (OperatorNew)
14806 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14807 if (OperatorDelete)
14808 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14809
14810 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14811 QualType ElementType
14812 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14813 if (CXXRecordDecl *Record = ElementType->getAsCXXRecordDecl()) {
14815 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
14816 }
14817 }
14818
14819 return E;
14820 }
14821
14822 QualType AllocType = AllocTypeInfo->getType();
14823 if (!ArraySize) {
14824 // If no array size was specified, but the new expression was
14825 // instantiated with an array type (e.g., "new T" where T is
14826 // instantiated with "int[4]"), extract the outer bound from the
14827 // array type as our array size. We do this with constant and
14828 // dependently-sized array types.
14829 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14830 if (!ArrayT) {
14831 // Do nothing
14832 } else if (const ConstantArrayType *ConsArrayT
14833 = dyn_cast<ConstantArrayType>(ArrayT)) {
14834 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14835 SemaRef.Context.getSizeType(),
14836 /*FIXME:*/ E->getBeginLoc());
14837 AllocType = ConsArrayT->getElementType();
14838 } else if (const DependentSizedArrayType *DepArrayT
14839 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14840 if (DepArrayT->getSizeExpr()) {
14841 ArraySize = DepArrayT->getSizeExpr();
14842 AllocType = DepArrayT->getElementType();
14843 }
14844 }
14845 }
14846
14847 return getDerived().RebuildCXXNewExpr(
14848 E->getBeginLoc(), E->isGlobalNew(),
14849 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14850 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14851 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14852}
14853
14854template<typename Derived>
14857 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14858 if (Operand.isInvalid())
14859 return ExprError();
14860
14861 // Transform the delete operator, if known.
14862 FunctionDecl *OperatorDelete = nullptr;
14863 if (E->getOperatorDelete()) {
14864 OperatorDelete = cast_or_null<FunctionDecl>(
14865 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14866 if (!OperatorDelete)
14867 return ExprError();
14868 }
14869
14870 if (!getDerived().AlwaysRebuild() &&
14871 Operand.get() == E->getArgument() &&
14872 OperatorDelete == E->getOperatorDelete()) {
14873 // Mark any declarations we need as referenced.
14874 // FIXME: instantiation-specific.
14875 if (OperatorDelete)
14876 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14877
14878 if (!E->getArgument()->isTypeDependent()) {
14879 QualType Destroyed = SemaRef.Context.getBaseElementType(
14880 E->getDestroyedType());
14881 if (auto *Record = Destroyed->getAsCXXRecordDecl())
14882 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
14883 SemaRef.LookupDestructor(Record));
14884 }
14885
14886 return E;
14887 }
14888
14889 return getDerived().RebuildCXXDeleteExpr(
14890 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14891}
14892
14893template<typename Derived>
14897 ExprResult Base = getDerived().TransformExpr(E->getBase());
14898 if (Base.isInvalid())
14899 return ExprError();
14900
14901 ParsedType ObjectTypePtr;
14902 bool MayBePseudoDestructor = false;
14903 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14904 E->getOperatorLoc(),
14905 E->isArrow()? tok::arrow : tok::period,
14906 ObjectTypePtr,
14907 MayBePseudoDestructor);
14908 if (Base.isInvalid())
14909 return ExprError();
14910
14911 QualType ObjectType = ObjectTypePtr.get();
14912 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
14913 if (QualifierLoc) {
14914 QualifierLoc
14915 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
14916 if (!QualifierLoc)
14917 return ExprError();
14918 }
14919 CXXScopeSpec SS;
14920 SS.Adopt(QualifierLoc);
14921
14923 if (E->getDestroyedTypeInfo()) {
14924 TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(
14925 E->getDestroyedTypeInfo(), ObjectType,
14926 /*FirstQualifierInScope=*/nullptr);
14927 if (!DestroyedTypeInfo)
14928 return ExprError();
14929 Destroyed = DestroyedTypeInfo;
14930 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
14931 // We aren't likely to be able to resolve the identifier down to a type
14932 // now anyway, so just retain the identifier.
14933 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
14934 E->getDestroyedTypeLoc());
14935 } else {
14936 // Look for a destructor known with the given name.
14937 ParsedType T = SemaRef.getDestructorName(
14938 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
14939 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
14940 if (!T)
14941 return ExprError();
14942
14943 Destroyed
14945 E->getDestroyedTypeLoc());
14946 }
14947
14948 TypeSourceInfo *ScopeTypeInfo = nullptr;
14949 if (E->getScopeTypeInfo()) {
14950 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
14951 E->getScopeTypeInfo(), ObjectType, nullptr);
14952 if (!ScopeTypeInfo)
14953 return ExprError();
14954 }
14955
14956 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
14957 E->getOperatorLoc(),
14958 E->isArrow(),
14959 SS,
14960 ScopeTypeInfo,
14961 E->getColonColonLoc(),
14962 E->getTildeLoc(),
14963 Destroyed);
14964}
14965
14966template <typename Derived>
14968 bool RequiresADL,
14969 LookupResult &R) {
14970 // Transform all the decls.
14971 bool AllEmptyPacks = true;
14972 for (auto *OldD : Old->decls()) {
14973 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
14974 if (!InstD) {
14975 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
14976 // This can happen because of dependent hiding.
14977 if (isa<UsingShadowDecl>(OldD))
14978 continue;
14979 else {
14980 R.clear();
14981 return true;
14982 }
14983 }
14984
14985 // Expand using pack declarations.
14986 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
14987 ArrayRef<NamedDecl*> Decls = SingleDecl;
14988 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
14989 Decls = UPD->expansions();
14990
14991 // Expand using declarations.
14992 for (auto *D : Decls) {
14993 if (auto *UD = dyn_cast<UsingDecl>(D)) {
14994 for (auto *SD : UD->shadows())
14995 R.addDecl(SD);
14996 } else {
14997 R.addDecl(D);
14998 }
14999 }
15000
15001 AllEmptyPacks &= Decls.empty();
15002 }
15003
15004 // C++ [temp.res]/8.4.2:
15005 // The program is ill-formed, no diagnostic required, if [...] lookup for
15006 // a name in the template definition found a using-declaration, but the
15007 // lookup in the corresponding scope in the instantiation odoes not find
15008 // any declarations because the using-declaration was a pack expansion and
15009 // the corresponding pack is empty
15010 if (AllEmptyPacks && !RequiresADL) {
15011 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
15012 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
15013 return true;
15014 }
15015
15016 // Resolve a kind, but don't do any further analysis. If it's
15017 // ambiguous, the callee needs to deal with it.
15018 R.resolveKind();
15019
15020 if (Old->hasTemplateKeyword() && !R.empty()) {
15022 getSema().FilterAcceptableTemplateNames(R,
15023 /*AllowFunctionTemplates=*/true,
15024 /*AllowDependent=*/true);
15025 if (R.empty()) {
15026 // If a 'template' keyword was used, a lookup that finds only non-template
15027 // names is an error.
15028 getSema().Diag(R.getNameLoc(),
15029 diag::err_template_kw_refers_to_non_template)
15031 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
15032 getSema().Diag(FoundDecl->getLocation(),
15033 diag::note_template_kw_refers_to_non_template)
15034 << R.getLookupName();
15035 return true;
15036 }
15037 }
15038
15039 return false;
15040}
15041
15042template <typename Derived>
15047
15048template <typename Derived>
15051 bool IsAddressOfOperand) {
15052 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
15054
15055 // Transform the declaration set.
15056 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
15057 return ExprError();
15058
15059 // Rebuild the nested-name qualifier, if present.
15060 CXXScopeSpec SS;
15061 if (Old->getQualifierLoc()) {
15062 NestedNameSpecifierLoc QualifierLoc
15063 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
15064 if (!QualifierLoc)
15065 return ExprError();
15066
15067 SS.Adopt(QualifierLoc);
15068 }
15069
15070 if (Old->getNamingClass()) {
15071 CXXRecordDecl *NamingClass
15072 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
15073 Old->getNameLoc(),
15074 Old->getNamingClass()));
15075 if (!NamingClass) {
15076 R.clear();
15077 return ExprError();
15078 }
15079
15080 R.setNamingClass(NamingClass);
15081 }
15082
15083 // Rebuild the template arguments, if any.
15084 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
15085 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
15086 if (Old->hasExplicitTemplateArgs() &&
15087 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15088 Old->getNumTemplateArgs(),
15089 TransArgs)) {
15090 R.clear();
15091 return ExprError();
15092 }
15093
15094 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
15095 // a non-static data member is named in an unevaluated operand, or when
15096 // a member is named in a dependent class scope function template explicit
15097 // specialization that is neither declared static nor with an explicit object
15098 // parameter.
15099 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
15100 return SemaRef.BuildPossibleImplicitMemberExpr(
15101 SS, TemplateKWLoc, R,
15102 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
15103 /*S=*/nullptr);
15104
15105 // If we have neither explicit template arguments, nor the template keyword,
15106 // it's a normal declaration name or member reference.
15107 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
15108 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
15109
15110 // If we have template arguments, then rebuild the template-id expression.
15111 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
15112 Old->requiresADL(), &TransArgs);
15113}
15114
15115template<typename Derived>
15118 bool ArgChanged = false;
15120 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
15121 TypeSourceInfo *From = E->getArg(I);
15122 TypeLoc FromTL = From->getTypeLoc();
15123 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
15124 TypeLocBuilder TLB;
15125 TLB.reserve(FromTL.getFullDataSize());
15126 QualType To = getDerived().TransformType(TLB, FromTL);
15127 if (To.isNull())
15128 return ExprError();
15129
15130 if (To == From->getType())
15131 Args.push_back(From);
15132 else {
15133 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15134 ArgChanged = true;
15135 }
15136 continue;
15137 }
15138
15139 ArgChanged = true;
15140
15141 // We have a pack expansion. Instantiate it.
15142 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
15143 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
15145 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
15146
15147 // Determine whether the set of unexpanded parameter packs can and should
15148 // be expanded.
15149 bool Expand = true;
15150 bool RetainExpansion = false;
15151 UnsignedOrNone OrigNumExpansions =
15152 ExpansionTL.getTypePtr()->getNumExpansions();
15153 UnsignedOrNone NumExpansions = OrigNumExpansions;
15154 if (getDerived().TryExpandParameterPacks(
15155 ExpansionTL.getEllipsisLoc(), PatternTL.getSourceRange(),
15156 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15157 RetainExpansion, NumExpansions))
15158 return ExprError();
15159
15160 if (!Expand) {
15161 // The transform has determined that we should perform a simple
15162 // transformation on the pack expansion, producing another pack
15163 // expansion.
15164 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
15165
15166 TypeLocBuilder TLB;
15167 TLB.reserve(From->getTypeLoc().getFullDataSize());
15168
15169 QualType To = getDerived().TransformType(TLB, PatternTL);
15170 if (To.isNull())
15171 return ExprError();
15172
15173 To = getDerived().RebuildPackExpansionType(To,
15174 PatternTL.getSourceRange(),
15175 ExpansionTL.getEllipsisLoc(),
15176 NumExpansions);
15177 if (To.isNull())
15178 return ExprError();
15179
15180 PackExpansionTypeLoc ToExpansionTL
15181 = TLB.push<PackExpansionTypeLoc>(To);
15182 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15183 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15184 continue;
15185 }
15186
15187 // Expand the pack expansion by substituting for each argument in the
15188 // pack(s).
15189 for (unsigned I = 0; I != *NumExpansions; ++I) {
15190 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
15191 TypeLocBuilder TLB;
15192 TLB.reserve(PatternTL.getFullDataSize());
15193 QualType To = getDerived().TransformType(TLB, PatternTL);
15194 if (To.isNull())
15195 return ExprError();
15196
15197 if (To->containsUnexpandedParameterPack()) {
15198 To = getDerived().RebuildPackExpansionType(To,
15199 PatternTL.getSourceRange(),
15200 ExpansionTL.getEllipsisLoc(),
15201 NumExpansions);
15202 if (To.isNull())
15203 return ExprError();
15204
15205 PackExpansionTypeLoc ToExpansionTL
15206 = TLB.push<PackExpansionTypeLoc>(To);
15207 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15208 }
15209
15210 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15211 }
15212
15213 if (!RetainExpansion)
15214 continue;
15215
15216 // If we're supposed to retain a pack expansion, do so by temporarily
15217 // forgetting the partially-substituted parameter pack.
15218 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
15219
15220 TypeLocBuilder TLB;
15221 TLB.reserve(From->getTypeLoc().getFullDataSize());
15222
15223 QualType To = getDerived().TransformType(TLB, PatternTL);
15224 if (To.isNull())
15225 return ExprError();
15226
15227 To = getDerived().RebuildPackExpansionType(To,
15228 PatternTL.getSourceRange(),
15229 ExpansionTL.getEllipsisLoc(),
15230 NumExpansions);
15231 if (To.isNull())
15232 return ExprError();
15233
15234 PackExpansionTypeLoc ToExpansionTL
15235 = TLB.push<PackExpansionTypeLoc>(To);
15236 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
15237 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
15238 }
15239
15240 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15241 return E;
15242
15243 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
15244 E->getEndLoc());
15245}
15246
15247template<typename Derived>
15251 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
15252 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
15253 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
15254 Old->NumTemplateArgs, TransArgs))
15255 return ExprError();
15256
15257 return getDerived().RebuildConceptSpecializationExpr(
15258 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
15259 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
15260 &TransArgs);
15261}
15262
15263template<typename Derived>
15266 SmallVector<ParmVarDecl*, 4> TransParams;
15267 SmallVector<QualType, 4> TransParamTypes;
15268 Sema::ExtParameterInfoBuilder ExtParamInfos;
15269
15270 // C++2a [expr.prim.req]p2
15271 // Expressions appearing within a requirement-body are unevaluated operands.
15275
15277 getSema().Context, getSema().CurContext,
15278 E->getBody()->getBeginLoc());
15279
15280 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
15281
15282 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
15283 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
15284 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
15285
15286 for (ParmVarDecl *Param : TransParams)
15287 if (Param)
15288 Param->setDeclContext(Body);
15289
15290 // On failure to transform, TransformRequiresTypeParams returns an expression
15291 // in the event that the transformation of the type params failed in some way.
15292 // It is expected that this will result in a 'not satisfied' Requires clause
15293 // when instantiating.
15294 if (!TypeParamResult.isUnset())
15295 return TypeParamResult;
15296
15298 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
15299 TransReqs))
15300 return ExprError();
15301
15302 for (concepts::Requirement *Req : TransReqs) {
15303 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
15304 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
15305 ER->getReturnTypeRequirement()
15306 .getTypeConstraintTemplateParameterList()->getParam(0)
15307 ->setDeclContext(Body);
15308 }
15309 }
15310 }
15311
15312 return getDerived().RebuildRequiresExpr(
15313 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
15314 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
15315}
15316
15317template<typename Derived>
15321 for (concepts::Requirement *Req : Reqs) {
15322 concepts::Requirement *TransReq = nullptr;
15323 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
15324 TransReq = getDerived().TransformTypeRequirement(TypeReq);
15325 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
15326 TransReq = getDerived().TransformExprRequirement(ExprReq);
15327 else
15328 TransReq = getDerived().TransformNestedRequirement(
15330 if (!TransReq)
15331 return true;
15332 Transformed.push_back(TransReq);
15333 }
15334 return false;
15335}
15336
15337template<typename Derived>
15341 if (Req->isSubstitutionFailure()) {
15342 if (getDerived().AlwaysRebuild())
15343 return getDerived().RebuildTypeRequirement(
15345 return Req;
15346 }
15347 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
15348 if (!TransType)
15349 return nullptr;
15350 return getDerived().RebuildTypeRequirement(TransType);
15351}
15352
15353template<typename Derived>
15356 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
15357 if (Req->isExprSubstitutionFailure())
15358 TransExpr = Req->getExprSubstitutionDiagnostic();
15359 else {
15360 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
15361 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
15362 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
15363 if (TransExprRes.isInvalid())
15364 return nullptr;
15365 TransExpr = TransExprRes.get();
15366 }
15367
15368 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
15369 const auto &RetReq = Req->getReturnTypeRequirement();
15370 if (RetReq.isEmpty())
15371 TransRetReq.emplace();
15372 else if (RetReq.isSubstitutionFailure())
15373 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
15374 else if (RetReq.isTypeConstraint()) {
15375 TemplateParameterList *OrigTPL =
15376 RetReq.getTypeConstraintTemplateParameterList();
15378 getDerived().TransformTemplateParameterList(OrigTPL);
15379 if (!TPL)
15380 return nullptr;
15381 TransRetReq.emplace(TPL);
15382 }
15383 assert(TransRetReq && "All code paths leading here must set TransRetReq");
15384 if (Expr *E = dyn_cast<Expr *>(TransExpr))
15385 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
15386 Req->getNoexceptLoc(),
15387 std::move(*TransRetReq));
15388 return getDerived().RebuildExprRequirement(
15390 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
15391}
15392
15393template<typename Derived>
15397 if (Req->hasInvalidConstraint()) {
15398 if (getDerived().AlwaysRebuild())
15399 return getDerived().RebuildNestedRequirement(
15401 return Req;
15402 }
15403 ExprResult TransConstraint =
15404 getDerived().TransformExpr(Req->getConstraintExpr());
15405 if (TransConstraint.isInvalid())
15406 return nullptr;
15407 return getDerived().RebuildNestedRequirement(TransConstraint.get());
15408}
15409
15410template<typename Derived>
15413 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
15414 if (!T)
15415 return ExprError();
15416
15417 if (!getDerived().AlwaysRebuild() &&
15418 T == E->getQueriedTypeSourceInfo())
15419 return E;
15420
15421 ExprResult SubExpr;
15422 {
15425 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
15426 if (SubExpr.isInvalid())
15427 return ExprError();
15428 }
15429
15430 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
15431 SubExpr.get(), E->getEndLoc());
15432}
15433
15434template<typename Derived>
15437 ExprResult SubExpr;
15438 {
15441 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15442 if (SubExpr.isInvalid())
15443 return ExprError();
15444
15445 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15446 return E;
15447 }
15448
15449 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15450 SubExpr.get(), E->getEndLoc());
15451}
15452
15453template <typename Derived>
15455 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15456 TypeSourceInfo **RecoveryTSI) {
15457 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15458 DRE, AddrTaken, RecoveryTSI);
15459
15460 // Propagate both errors and recovered types, which return ExprEmpty.
15461 if (!NewDRE.isUsable())
15462 return NewDRE;
15463
15464 // We got an expr, wrap it up in parens.
15465 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15466 return PE;
15467 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15468 PE->getRParen());
15469}
15470
15471template <typename Derived>
15477
15478template <typename Derived>
15480 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15481 TypeSourceInfo **RecoveryTSI) {
15482 assert(E->getQualifierLoc());
15483 NestedNameSpecifierLoc QualifierLoc =
15484 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15485 if (!QualifierLoc)
15486 return ExprError();
15487 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15488
15489 // TODO: If this is a conversion-function-id, verify that the
15490 // destination type name (if present) resolves the same way after
15491 // instantiation as it did in the local scope.
15492
15493 DeclarationNameInfo NameInfo =
15494 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15495 if (!NameInfo.getName())
15496 return ExprError();
15497
15498 if (!E->hasExplicitTemplateArgs()) {
15499 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15500 // Note: it is sufficient to compare the Name component of NameInfo:
15501 // if name has not changed, DNLoc has not changed either.
15502 NameInfo.getName() == E->getDeclName())
15503 return E;
15504
15505 return getDerived().RebuildDependentScopeDeclRefExpr(
15506 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15507 IsAddressOfOperand, RecoveryTSI);
15508 }
15509
15510 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15511 if (getDerived().TransformTemplateArguments(
15512 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15513 return ExprError();
15514
15515 return getDerived().RebuildDependentScopeDeclRefExpr(
15516 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15517 RecoveryTSI);
15518}
15519
15520template<typename Derived>
15523 // CXXConstructExprs other than for list-initialization and
15524 // CXXTemporaryObjectExpr are always implicit, so when we have
15525 // a 1-argument construction we just transform that argument.
15526 if (getDerived().AllowSkippingCXXConstructExpr() &&
15527 ((E->getNumArgs() == 1 ||
15528 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15529 (!getDerived().DropCallArgument(E->getArg(0))) &&
15530 !E->isListInitialization()))
15531 return getDerived().TransformInitializer(E->getArg(0),
15532 /*DirectInit*/ false);
15533
15534 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15535
15536 QualType T = getDerived().TransformType(E->getType());
15537 if (T.isNull())
15538 return ExprError();
15539
15540 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15541 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15542 if (!Constructor)
15543 return ExprError();
15544
15545 bool ArgumentChanged = false;
15547 {
15550 E->isListInitialization());
15551 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15552 &ArgumentChanged))
15553 return ExprError();
15554 }
15555
15556 if (!getDerived().AlwaysRebuild() &&
15557 T == E->getType() &&
15558 Constructor == E->getConstructor() &&
15559 !ArgumentChanged) {
15560 // Mark the constructor as referenced.
15561 // FIXME: Instantiation-specific
15562 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15563 return E;
15564 }
15565
15566 return getDerived().RebuildCXXConstructExpr(
15567 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15568 E->hadMultipleCandidates(), E->isListInitialization(),
15569 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15570 E->getConstructionKind(), E->getParenOrBraceRange());
15571}
15572
15573template<typename Derived>
15576 QualType T = getDerived().TransformType(E->getType());
15577 if (T.isNull())
15578 return ExprError();
15579
15580 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15581 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15582 if (!Constructor)
15583 return ExprError();
15584
15585 if (!getDerived().AlwaysRebuild() &&
15586 T == E->getType() &&
15587 Constructor == E->getConstructor()) {
15588 // Mark the constructor as referenced.
15589 // FIXME: Instantiation-specific
15590 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15591 return E;
15592 }
15593
15594 return getDerived().RebuildCXXInheritedCtorInitExpr(
15595 T, E->getLocation(), Constructor,
15596 E->constructsVBase(), E->inheritedFromVBase());
15597}
15598
15599/// Transform a C++ temporary-binding expression.
15600///
15601/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15602/// transform the subexpression and return that.
15603template<typename Derived>
15606 if (auto *Dtor = E->getTemporary()->getDestructor())
15607 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
15608 const_cast<CXXDestructorDecl *>(Dtor));
15609 return getDerived().TransformExpr(E->getSubExpr());
15610}
15611
15612/// Transform a C++ expression that contains cleanups that should
15613/// be run after the expression is evaluated.
15614///
15615/// Since ExprWithCleanups nodes are implicitly generated, we
15616/// just transform the subexpression and return that.
15617template<typename Derived>
15620 return getDerived().TransformExpr(E->getSubExpr());
15621}
15622
15623template<typename Derived>
15627 TypeSourceInfo *T =
15628 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15629 if (!T)
15630 return ExprError();
15631
15632 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15633 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15634 if (!Constructor)
15635 return ExprError();
15636
15637 bool ArgumentChanged = false;
15639 Args.reserve(E->getNumArgs());
15640 {
15643 E->isListInitialization());
15644 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15645 &ArgumentChanged))
15646 return ExprError();
15647
15648 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15649 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc());
15650 if (Res.isInvalid())
15651 return ExprError();
15652 Args = {Res.get()};
15653 }
15654 }
15655
15656 if (!getDerived().AlwaysRebuild() &&
15657 T == E->getTypeSourceInfo() &&
15658 Constructor == E->getConstructor() &&
15659 !ArgumentChanged) {
15660 // FIXME: Instantiation-specific
15661 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15662 return SemaRef.MaybeBindToTemporary(E);
15663 }
15664
15665 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15666 return getDerived().RebuildCXXTemporaryObjectExpr(
15667 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15668}
15669
15670template<typename Derived>
15673 // Transform any init-capture expressions before entering the scope of the
15674 // lambda body, because they are not semantically within that scope.
15675 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15676 struct TransformedInitCapture {
15677 // The location of the ... if the result is retaining a pack expansion.
15678 SourceLocation EllipsisLoc;
15679 // Zero or more expansions of the init-capture.
15680 SmallVector<InitCaptureInfoTy, 4> Expansions;
15681 };
15683 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15684 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15685 CEnd = E->capture_end();
15686 C != CEnd; ++C) {
15687 if (!E->isInitCapture(C))
15688 continue;
15689
15690 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15691 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15692
15693 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15694 UnsignedOrNone NumExpansions) {
15695 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15696 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15697
15698 if (NewExprInitResult.isInvalid()) {
15699 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15700 return;
15701 }
15702 Expr *NewExprInit = NewExprInitResult.get();
15703
15704 QualType NewInitCaptureType =
15705 getSema().buildLambdaInitCaptureInitialization(
15706 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15707 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15708 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15710 NewExprInit);
15711 Result.Expansions.push_back(
15712 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15713 };
15714
15715 // If this is an init-capture pack, consider expanding the pack now.
15716 if (OldVD->isParameterPack()) {
15717 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15718 ->getTypeLoc()
15721 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15722
15723 // Determine whether the set of unexpanded parameter packs can and should
15724 // be expanded.
15725 bool Expand = true;
15726 bool RetainExpansion = false;
15727 UnsignedOrNone OrigNumExpansions =
15728 ExpansionTL.getTypePtr()->getNumExpansions();
15729 UnsignedOrNone NumExpansions = OrigNumExpansions;
15730 if (getDerived().TryExpandParameterPacks(
15731 ExpansionTL.getEllipsisLoc(), OldVD->getInit()->getSourceRange(),
15732 Unexpanded, /*FailOnPackProducingTemplates=*/true, Expand,
15733 RetainExpansion, NumExpansions))
15734 return ExprError();
15735 assert(!RetainExpansion && "Should not need to retain expansion after a "
15736 "capture since it cannot be extended");
15737 if (Expand) {
15738 for (unsigned I = 0; I != *NumExpansions; ++I) {
15739 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15740 SubstInitCapture(SourceLocation(), std::nullopt);
15741 }
15742 } else {
15743 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15744 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15745 }
15746 } else {
15747 SubstInitCapture(SourceLocation(), std::nullopt);
15748 }
15749 }
15750
15751 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15752 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15753
15754 // Create the local class that will describe the lambda.
15755
15756 // FIXME: DependencyKind below is wrong when substituting inside a templated
15757 // context that isn't a DeclContext (such as a variable template), or when
15758 // substituting an unevaluated lambda inside of a function's parameter's type
15759 // - as parameter types are not instantiated from within a function's DC. We
15760 // use evaluation contexts to distinguish the function parameter case.
15763 DeclContext *DC = getSema().CurContext;
15764 // A RequiresExprBodyDecl is not interesting for dependencies.
15765 // For the following case,
15766 //
15767 // template <typename>
15768 // concept C = requires { [] {}; };
15769 //
15770 // template <class F>
15771 // struct Widget;
15772 //
15773 // template <C F>
15774 // struct Widget<F> {};
15775 //
15776 // While we are substituting Widget<F>, the parent of DC would be
15777 // the template specialization itself. Thus, the lambda expression
15778 // will be deemed as dependent even if there are no dependent template
15779 // arguments.
15780 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15781 while (DC->isRequiresExprBody())
15782 DC = DC->getParent();
15783 if ((getSema().isUnevaluatedContext() ||
15784 getSema().isConstantEvaluatedContext()) &&
15785 !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15786 cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
15787 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15788 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15789
15790 CXXRecordDecl *OldClass = E->getLambdaClass();
15791 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15792 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15793 E->getCaptureDefault());
15794 getDerived().transformedLocalDecl(OldClass, {Class});
15795
15796 CXXMethodDecl *NewCallOperator =
15797 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15798
15799 // Enter the scope of the lambda.
15800 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15801 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15802 E->hasExplicitParameters(), E->isMutable());
15803
15804 // Introduce the context of the call operator.
15805 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15806 /*NewThisContext*/false);
15807
15808 bool Invalid = false;
15809
15810 // Transform captures.
15811 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15812 CEnd = E->capture_end();
15813 C != CEnd; ++C) {
15814 // When we hit the first implicit capture, tell Sema that we've finished
15815 // the list of explicit captures.
15816 if (C->isImplicit())
15817 break;
15818
15819 // Capturing 'this' is trivial.
15820 if (C->capturesThis()) {
15821 // If this is a lambda that is part of a default member initialiser
15822 // and which we're instantiating outside the class that 'this' is
15823 // supposed to refer to, adjust the type of 'this' accordingly.
15824 //
15825 // Otherwise, leave the type of 'this' as-is.
15826 Sema::CXXThisScopeRAII ThisScope(
15827 getSema(),
15828 dyn_cast_if_present<CXXRecordDecl>(
15829 getSema().getFunctionLevelDeclContext()),
15830 Qualifiers());
15831 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15832 /*BuildAndDiagnose*/ true, nullptr,
15833 C->getCaptureKind() == LCK_StarThis);
15834 continue;
15835 }
15836 // Captured expression will be recaptured during captured variables
15837 // rebuilding.
15838 if (C->capturesVLAType())
15839 continue;
15840
15841 // Rebuild init-captures, including the implied field declaration.
15842 if (E->isInitCapture(C)) {
15843 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15844
15845 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15847
15848 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15849 ExprResult Init = Info.first;
15850 QualType InitQualType = Info.second;
15851 if (Init.isInvalid() || InitQualType.isNull()) {
15852 Invalid = true;
15853 break;
15854 }
15855 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15856 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15857 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15858 getSema().CurContext);
15859 if (!NewVD) {
15860 Invalid = true;
15861 break;
15862 }
15863 NewVDs.push_back(NewVD);
15864 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15865 // Cases we want to tackle:
15866 // ([C(Pack)] {}, ...)
15867 // But rule out cases e.g.
15868 // [...C = Pack()] {}
15869 if (NewC.EllipsisLoc.isInvalid())
15870 LSI->ContainsUnexpandedParameterPack |=
15871 Init.get()->containsUnexpandedParameterPack();
15872 }
15873
15874 if (Invalid)
15875 break;
15876
15877 getDerived().transformedLocalDecl(OldVD, NewVDs);
15878 continue;
15879 }
15880
15881 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15882
15883 // Determine the capture kind for Sema.
15885 : C->getCaptureKind() == LCK_ByCopy
15888 SourceLocation EllipsisLoc;
15889 if (C->isPackExpansion()) {
15890 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15891 bool ShouldExpand = false;
15892 bool RetainExpansion = false;
15893 UnsignedOrNone NumExpansions = std::nullopt;
15894 if (getDerived().TryExpandParameterPacks(
15895 C->getEllipsisLoc(), C->getLocation(), Unexpanded,
15896 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
15897 RetainExpansion, NumExpansions)) {
15898 Invalid = true;
15899 continue;
15900 }
15901
15902 if (ShouldExpand) {
15903 // The transform has determined that we should perform an expansion;
15904 // transform and capture each of the arguments.
15905 // expansion of the pattern. Do so.
15906 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
15907 for (unsigned I = 0; I != *NumExpansions; ++I) {
15908 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
15909 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
15910 getDerived().TransformDecl(C->getLocation(), Pack));
15911 if (!CapturedVar) {
15912 Invalid = true;
15913 continue;
15914 }
15915
15916 // Capture the transformed variable.
15917 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
15918 }
15919
15920 // FIXME: Retain a pack expansion if RetainExpansion is true.
15921
15922 continue;
15923 }
15924
15925 EllipsisLoc = C->getEllipsisLoc();
15926 }
15927
15928 // Transform the captured variable.
15929 auto *CapturedVar = cast_or_null<ValueDecl>(
15930 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15931 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
15932 Invalid = true;
15933 continue;
15934 }
15935
15936 // This is not an init-capture; however it contains an unexpanded pack e.g.
15937 // ([Pack] {}(), ...)
15938 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
15939 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
15940
15941 // Capture the transformed variable.
15942 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
15943 EllipsisLoc);
15944 }
15945 getSema().finishLambdaExplicitCaptures(LSI);
15946
15947 // Transform the template parameters, and add them to the current
15948 // instantiation scope. The null case is handled correctly.
15949 auto TPL = getDerived().TransformTemplateParameterList(
15950 E->getTemplateParameterList());
15951 LSI->GLTemplateParameterList = TPL;
15952 if (TPL) {
15953 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
15954 TPL);
15955 LSI->ContainsUnexpandedParameterPack |=
15956 TPL->containsUnexpandedParameterPack();
15957 }
15958
15959 TypeLocBuilder NewCallOpTLBuilder;
15960 TypeLoc OldCallOpTypeLoc =
15961 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
15962 QualType NewCallOpType =
15963 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
15964 if (NewCallOpType.isNull())
15965 return ExprError();
15966 LSI->ContainsUnexpandedParameterPack |=
15967 NewCallOpType->containsUnexpandedParameterPack();
15968 TypeSourceInfo *NewCallOpTSI =
15969 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
15970
15971 // The type may be an AttributedType or some other kind of sugar;
15972 // get the actual underlying FunctionProtoType.
15973 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
15974 assert(FPTL && "Not a FunctionProtoType?");
15975
15976 AssociatedConstraint TRC = E->getCallOperator()->getTrailingRequiresClause();
15977 if (!TRC.ArgPackSubstIndex)
15979
15980 getSema().CompleteLambdaCallOperator(
15981 NewCallOperator, E->getCallOperator()->getLocation(),
15982 E->getCallOperator()->getInnerLocStart(), TRC, NewCallOpTSI,
15983 E->getCallOperator()->getConstexprKind(),
15984 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
15985 E->hasExplicitResultType());
15986
15987 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
15988 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
15989
15990 {
15991 // Number the lambda for linkage purposes if necessary.
15992 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
15993
15994 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
15995 if (getDerived().ReplacingOriginal()) {
15996 Numbering = OldClass->getLambdaNumbering();
15997 }
15998
15999 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
16000 }
16001
16002 // FIXME: Sema's lambda-building mechanism expects us to push an expression
16003 // evaluation context even if we're not transforming the function body.
16004 getSema().PushExpressionEvaluationContextForFunction(
16006 E->getCallOperator());
16007
16008 StmtResult Body;
16009 {
16010 Sema::NonSFINAEContext _(getSema());
16013 C.PointOfInstantiation = E->getBody()->getBeginLoc();
16014 getSema().pushCodeSynthesisContext(C);
16015
16016 // Instantiate the body of the lambda expression.
16017 Body = Invalid ? StmtError()
16018 : getDerived().TransformLambdaBody(E, E->getBody());
16019
16020 getSema().popCodeSynthesisContext();
16021 }
16022
16023 // ActOnLambda* will pop the function scope for us.
16024 FuncScopeCleanup.disable();
16025
16026 if (Body.isInvalid()) {
16027 SavedContext.pop();
16028 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
16029 /*IsInstantiation=*/true);
16030 return ExprError();
16031 }
16032
16033 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
16034 /*IsInstantiation=*/true,
16035 /*RetainFunctionScopeInfo=*/true);
16036 SavedContext.pop();
16037
16038 // Recompute the dependency of the lambda so that we can defer the lambda call
16039 // construction until after we have all the necessary template arguments. For
16040 // example, given
16041 //
16042 // template <class> struct S {
16043 // template <class U>
16044 // using Type = decltype([](U){}(42.0));
16045 // };
16046 // void foo() {
16047 // using T = S<int>::Type<float>;
16048 // ^~~~~~
16049 // }
16050 //
16051 // We would end up here from instantiating S<int> when ensuring its
16052 // completeness. That would transform the lambda call expression regardless of
16053 // the absence of the corresponding argument for U.
16054 //
16055 // Going ahead with unsubstituted type U makes things worse: we would soon
16056 // compare the argument type (which is float) against the parameter U
16057 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
16058 // error suggesting unmatched types 'U' and 'float'!
16059 //
16060 // That said, everything will be fine if we defer that semantic checking.
16061 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
16062 // dependent. Since the CallExpr's dependency boils down to the lambda's
16063 // dependency in this case, we can harness that by recomputing the dependency
16064 // from the instantiation arguments.
16065 //
16066 // FIXME: Creating the type of a lambda requires us to have a dependency
16067 // value, which happens before its substitution. We update its dependency
16068 // *after* the substitution in case we can't decide the dependency
16069 // so early, e.g. because we want to see if any of the *substituted*
16070 // parameters are dependent.
16071 DependencyKind = getDerived().ComputeLambdaDependency(LSI);
16072 Class->setLambdaDependencyKind(DependencyKind);
16073
16074 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
16075 Body.get()->getEndLoc(), LSI);
16076}
16077
16078template<typename Derived>
16083
16084template<typename Derived>
16087 // Transform captures.
16089 CEnd = E->capture_end();
16090 C != CEnd; ++C) {
16091 // When we hit the first implicit capture, tell Sema that we've finished
16092 // the list of explicit captures.
16093 if (!C->isImplicit())
16094 continue;
16095
16096 // Capturing 'this' is trivial.
16097 if (C->capturesThis()) {
16098 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
16099 /*BuildAndDiagnose*/ true, nullptr,
16100 C->getCaptureKind() == LCK_StarThis);
16101 continue;
16102 }
16103 // Captured expression will be recaptured during captured variables
16104 // rebuilding.
16105 if (C->capturesVLAType())
16106 continue;
16107
16108 assert(C->capturesVariable() && "unexpected kind of lambda capture");
16109 assert(!E->isInitCapture(C) && "implicit init-capture?");
16110
16111 // Transform the captured variable.
16112 VarDecl *CapturedVar = cast_or_null<VarDecl>(
16113 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
16114 if (!CapturedVar || CapturedVar->isInvalidDecl())
16115 return StmtError();
16116
16117 // Capture the transformed variable.
16118 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
16119 }
16120
16121 return S;
16122}
16123
16124template<typename Derived>
16128 TypeSourceInfo *T =
16129 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
16130 if (!T)
16131 return ExprError();
16132
16133 bool ArgumentChanged = false;
16135 Args.reserve(E->getNumArgs());
16136 {
16140 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
16141 &ArgumentChanged))
16142 return ExprError();
16143 }
16144
16145 if (!getDerived().AlwaysRebuild() &&
16146 T == E->getTypeSourceInfo() &&
16147 !ArgumentChanged)
16148 return E;
16149
16150 // FIXME: we're faking the locations of the commas
16151 return getDerived().RebuildCXXUnresolvedConstructExpr(
16152 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
16153}
16154
16155template<typename Derived>
16159 // Transform the base of the expression.
16160 ExprResult Base((Expr*) nullptr);
16161 Expr *OldBase;
16162 QualType BaseType;
16163 QualType ObjectType;
16164 if (!E->isImplicitAccess()) {
16165 OldBase = E->getBase();
16166 Base = getDerived().TransformExpr(OldBase);
16167 if (Base.isInvalid())
16168 return ExprError();
16169
16170 // Start the member reference and compute the object's type.
16171 ParsedType ObjectTy;
16172 bool MayBePseudoDestructor = false;
16173 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
16174 E->getOperatorLoc(),
16175 E->isArrow()? tok::arrow : tok::period,
16176 ObjectTy,
16177 MayBePseudoDestructor);
16178 if (Base.isInvalid())
16179 return ExprError();
16180
16181 ObjectType = ObjectTy.get();
16182 BaseType = ((Expr*) Base.get())->getType();
16183 } else {
16184 OldBase = nullptr;
16185 BaseType = getDerived().TransformType(E->getBaseType());
16186 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
16187 }
16188
16189 // Transform the first part of the nested-name-specifier that qualifies
16190 // the member name.
16191 NamedDecl *FirstQualifierInScope
16192 = getDerived().TransformFirstQualifierInScope(
16193 E->getFirstQualifierFoundInScope(),
16194 E->getQualifierLoc().getBeginLoc());
16195
16196 NestedNameSpecifierLoc QualifierLoc;
16197 if (E->getQualifier()) {
16198 QualifierLoc
16199 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
16200 ObjectType,
16201 FirstQualifierInScope);
16202 if (!QualifierLoc)
16203 return ExprError();
16204 }
16205
16206 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
16207
16208 // TODO: If this is a conversion-function-id, verify that the
16209 // destination type name (if present) resolves the same way after
16210 // instantiation as it did in the local scope.
16211
16212 DeclarationNameInfo NameInfo
16213 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
16214 if (!NameInfo.getName())
16215 return ExprError();
16216
16217 if (!E->hasExplicitTemplateArgs()) {
16218 // This is a reference to a member without an explicitly-specified
16219 // template argument list. Optimize for this common case.
16220 if (!getDerived().AlwaysRebuild() &&
16221 Base.get() == OldBase &&
16222 BaseType == E->getBaseType() &&
16223 QualifierLoc == E->getQualifierLoc() &&
16224 NameInfo.getName() == E->getMember() &&
16225 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
16226 return E;
16227
16228 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16229 BaseType,
16230 E->isArrow(),
16231 E->getOperatorLoc(),
16232 QualifierLoc,
16233 TemplateKWLoc,
16234 FirstQualifierInScope,
16235 NameInfo,
16236 /*TemplateArgs*/nullptr);
16237 }
16238
16239 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
16240 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
16241 E->getNumTemplateArgs(),
16242 TransArgs))
16243 return ExprError();
16244
16245 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
16246 BaseType,
16247 E->isArrow(),
16248 E->getOperatorLoc(),
16249 QualifierLoc,
16250 TemplateKWLoc,
16251 FirstQualifierInScope,
16252 NameInfo,
16253 &TransArgs);
16254}
16255
16256template <typename Derived>
16258 UnresolvedMemberExpr *Old) {
16259 // Transform the base of the expression.
16260 ExprResult Base((Expr *)nullptr);
16261 QualType BaseType;
16262 if (!Old->isImplicitAccess()) {
16263 Base = getDerived().TransformExpr(Old->getBase());
16264 if (Base.isInvalid())
16265 return ExprError();
16266 Base =
16267 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
16268 if (Base.isInvalid())
16269 return ExprError();
16270 BaseType = Base.get()->getType();
16271 } else {
16272 BaseType = getDerived().TransformType(Old->getBaseType());
16273 }
16274
16275 NestedNameSpecifierLoc QualifierLoc;
16276 if (Old->getQualifierLoc()) {
16277 QualifierLoc =
16278 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
16279 if (!QualifierLoc)
16280 return ExprError();
16281 }
16282
16283 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
16284
16285 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
16286
16287 // Transform the declaration set.
16288 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
16289 return ExprError();
16290
16291 // Determine the naming class.
16292 if (Old->getNamingClass()) {
16293 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
16294 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
16295 if (!NamingClass)
16296 return ExprError();
16297
16298 R.setNamingClass(NamingClass);
16299 }
16300
16301 TemplateArgumentListInfo TransArgs;
16302 if (Old->hasExplicitTemplateArgs()) {
16303 TransArgs.setLAngleLoc(Old->getLAngleLoc());
16304 TransArgs.setRAngleLoc(Old->getRAngleLoc());
16305 if (getDerived().TransformTemplateArguments(
16306 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
16307 return ExprError();
16308 }
16309
16310 // FIXME: to do this check properly, we will need to preserve the
16311 // first-qualifier-in-scope here, just in case we had a dependent
16312 // base (and therefore couldn't do the check) and a
16313 // nested-name-qualifier (and therefore could do the lookup).
16314 NamedDecl *FirstQualifierInScope = nullptr;
16315
16316 return getDerived().RebuildUnresolvedMemberExpr(
16317 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
16318 TemplateKWLoc, FirstQualifierInScope, R,
16319 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
16320}
16321
16322template<typename Derived>
16327 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
16328 if (SubExpr.isInvalid())
16329 return ExprError();
16330
16331 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
16332 return E;
16333
16334 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
16335}
16336
16337template<typename Derived>
16340 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
16341 if (Pattern.isInvalid())
16342 return ExprError();
16343
16344 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
16345 return E;
16346
16347 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
16348 E->getNumExpansions());
16349}
16350
16351template <typename Derived>
16353 ArrayRef<TemplateArgument> PackArgs) {
16355 for (const TemplateArgument &Arg : PackArgs) {
16356 if (!Arg.isPackExpansion()) {
16357 Result = *Result + 1;
16358 continue;
16359 }
16360
16361 TemplateArgumentLoc ArgLoc;
16362 InventTemplateArgumentLoc(Arg, ArgLoc);
16363
16364 // Find the pattern of the pack expansion.
16365 SourceLocation Ellipsis;
16366 UnsignedOrNone OrigNumExpansions = std::nullopt;
16367 TemplateArgumentLoc Pattern =
16368 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16369 OrigNumExpansions);
16370
16371 // Substitute under the pack expansion. Do not expand the pack (yet).
16372 TemplateArgumentLoc OutPattern;
16373 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16374 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16375 /*Uneval*/ true))
16376 return 1u;
16377
16378 // See if we can determine the number of arguments from the result.
16379 UnsignedOrNone NumExpansions =
16380 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16381 if (!NumExpansions) {
16382 // No: we must be in an alias template expansion, and we're going to
16383 // need to actually expand the packs.
16384 Result = std::nullopt;
16385 break;
16386 }
16387
16388 Result = *Result + *NumExpansions;
16389 }
16390 return Result;
16391}
16392
16393template<typename Derived>
16396 // If E is not value-dependent, then nothing will change when we transform it.
16397 // Note: This is an instantiation-centric view.
16398 if (!E->isValueDependent())
16399 return E;
16400
16403
16405 TemplateArgument ArgStorage;
16406
16407 // Find the argument list to transform.
16408 if (E->isPartiallySubstituted()) {
16409 PackArgs = E->getPartialArguments();
16410 } else if (E->isValueDependent()) {
16411 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
16412 bool ShouldExpand = false;
16413 bool RetainExpansion = false;
16414 UnsignedOrNone NumExpansions = std::nullopt;
16415 if (getDerived().TryExpandParameterPacks(
16416 E->getOperatorLoc(), E->getPackLoc(), Unexpanded,
16417 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16418 RetainExpansion, NumExpansions))
16419 return ExprError();
16420
16421 // If we need to expand the pack, build a template argument from it and
16422 // expand that.
16423 if (ShouldExpand) {
16424 auto *Pack = E->getPack();
16425 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
16426 ArgStorage = getSema().Context.getPackExpansionType(
16427 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
16428 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
16429 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
16430 } else {
16431 auto *VD = cast<ValueDecl>(Pack);
16432 ExprResult DRE = getSema().BuildDeclRefExpr(
16433 VD, VD->getType().getNonLValueExprType(getSema().Context),
16434 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
16435 E->getPackLoc());
16436 if (DRE.isInvalid())
16437 return ExprError();
16438 ArgStorage = TemplateArgument(
16439 new (getSema().Context)
16440 PackExpansionExpr(DRE.get(), E->getPackLoc(), std::nullopt),
16441 /*IsCanonical=*/false);
16442 }
16443 PackArgs = ArgStorage;
16444 }
16445 }
16446
16447 // If we're not expanding the pack, just transform the decl.
16448 if (!PackArgs.size()) {
16449 auto *Pack = cast_or_null<NamedDecl>(
16450 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
16451 if (!Pack)
16452 return ExprError();
16453 return getDerived().RebuildSizeOfPackExpr(
16454 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
16455 std::nullopt, {});
16456 }
16457
16458 // Try to compute the result without performing a partial substitution.
16460 getDerived().ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
16461
16462 // Common case: we could determine the number of expansions without
16463 // substituting.
16464 if (Result)
16465 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16466 E->getPackLoc(),
16467 E->getRParenLoc(), *Result, {});
16468
16469 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16470 E->getPackLoc());
16471 {
16472 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16474 Derived, const TemplateArgument*> PackLocIterator;
16475 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16476 PackLocIterator(*this, PackArgs.end()),
16477 TransformedPackArgs, /*Uneval*/true))
16478 return ExprError();
16479 }
16480
16481 // Check whether we managed to fully-expand the pack.
16482 // FIXME: Is it possible for us to do so and not hit the early exit path?
16484 bool PartialSubstitution = false;
16485 for (auto &Loc : TransformedPackArgs.arguments()) {
16486 Args.push_back(Loc.getArgument());
16487 if (Loc.getArgument().isPackExpansion())
16488 PartialSubstitution = true;
16489 }
16490
16491 if (PartialSubstitution)
16492 return getDerived().RebuildSizeOfPackExpr(
16493 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16494 std::nullopt, Args);
16495
16496 return getDerived().RebuildSizeOfPackExpr(
16497 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16498 /*Length=*/static_cast<unsigned>(Args.size()),
16499 /*PartialArgs=*/{});
16500}
16501
16502template <typename Derived>
16505 if (!E->isValueDependent())
16506 return E;
16507
16508 // Transform the index
16509 ExprResult IndexExpr;
16510 {
16511 EnterExpressionEvaluationContext ConstantContext(
16513 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16514 if (IndexExpr.isInvalid())
16515 return ExprError();
16516 }
16517
16518 SmallVector<Expr *, 5> ExpandedExprs;
16519 bool FullySubstituted = true;
16520 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16521 Expr *Pattern = E->getPackIdExpression();
16523 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16524 Unexpanded);
16525 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16526
16527 // Determine whether the set of unexpanded parameter packs can and should
16528 // be expanded.
16529 bool ShouldExpand = true;
16530 bool RetainExpansion = false;
16531 UnsignedOrNone OrigNumExpansions = std::nullopt,
16532 NumExpansions = std::nullopt;
16533 if (getDerived().TryExpandParameterPacks(
16534 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16535 /*FailOnPackProducingTemplates=*/true, ShouldExpand,
16536 RetainExpansion, NumExpansions))
16537 return true;
16538 if (!ShouldExpand) {
16539 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16540 ExprResult Pack = getDerived().TransformExpr(Pattern);
16541 if (Pack.isInvalid())
16542 return ExprError();
16543 return getDerived().RebuildPackIndexingExpr(
16544 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16545 {}, /*FullySubstituted=*/false);
16546 }
16547 for (unsigned I = 0; I != *NumExpansions; ++I) {
16548 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16549 ExprResult Out = getDerived().TransformExpr(Pattern);
16550 if (Out.isInvalid())
16551 return true;
16552 if (Out.get()->containsUnexpandedParameterPack()) {
16553 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16554 OrigNumExpansions);
16555 if (Out.isInvalid())
16556 return true;
16557 FullySubstituted = false;
16558 }
16559 ExpandedExprs.push_back(Out.get());
16560 }
16561 // If we're supposed to retain a pack expansion, do so by temporarily
16562 // forgetting the partially-substituted parameter pack.
16563 if (RetainExpansion) {
16564 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16565
16566 ExprResult Out = getDerived().TransformExpr(Pattern);
16567 if (Out.isInvalid())
16568 return true;
16569
16570 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16571 OrigNumExpansions);
16572 if (Out.isInvalid())
16573 return true;
16574 FullySubstituted = false;
16575 ExpandedExprs.push_back(Out.get());
16576 }
16577 } else if (!E->expandsToEmptyPack()) {
16578 if (getDerived().TransformExprs(E->getExpressions().data(),
16579 E->getExpressions().size(), false,
16580 ExpandedExprs))
16581 return ExprError();
16582 }
16583
16584 return getDerived().RebuildPackIndexingExpr(
16585 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16586 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16587}
16588
16589template <typename Derived>
16592 if (!getSema().ArgPackSubstIndex)
16593 // We aren't expanding the parameter pack, so just return ourselves.
16594 return E;
16595
16596 TemplateArgument Pack = E->getArgumentPack();
16598 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16599 E->getAssociatedDecl(), E->getParameterPack(),
16600 E->getParameterPackLocation(), Arg, SemaRef.getPackIndex(Pack),
16601 E->getFinal());
16602}
16603
16604template <typename Derived>
16607 Expr *OrigReplacement = E->getReplacement()->IgnoreImplicitAsWritten();
16608 ExprResult Replacement = getDerived().TransformExpr(OrigReplacement);
16609 if (Replacement.isInvalid())
16610 return true;
16611
16612 Decl *AssociatedDecl =
16613 getDerived().TransformDecl(E->getNameLoc(), E->getAssociatedDecl());
16614 if (!AssociatedDecl)
16615 return true;
16616
16617 if (Replacement.get() == OrigReplacement &&
16618 AssociatedDecl == E->getAssociatedDecl())
16619 return E;
16620
16621 auto getParamAndType = [E](Decl *AssociatedDecl)
16622 -> std::tuple<NonTypeTemplateParmDecl *, QualType> {
16623 auto [PDecl, Arg] =
16624 getReplacedTemplateParameter(AssociatedDecl, E->getIndex());
16625 auto *Param = cast<NonTypeTemplateParmDecl>(PDecl);
16626 if (Arg.isNull())
16627 return {Param, Param->getType()};
16628 if (UnsignedOrNone PackIndex = E->getPackIndex())
16629 Arg = Arg.getPackAsArray()[*PackIndex];
16630 return {Param, Arg.getNonTypeTemplateArgumentType()};
16631 };
16632
16633 // If the replacement expression did not change, and the parameter type
16634 // did not change, we can skip the semantic action because it would
16635 // produce the same result anyway.
16636 if (auto [Param, ParamType] = getParamAndType(AssociatedDecl);
16637 !SemaRef.Context.hasSameType(
16638 ParamType, std::get<1>(getParamAndType(E->getAssociatedDecl()))) ||
16639 Replacement.get() != OrigReplacement) {
16640 // When transforming the replacement expression previously, all Sema
16641 // specific annotations, such as implicit casts, are discarded. Calling the
16642 // corresponding sema action is necessary to recover those. Otherwise,
16643 // equivalency of the result would be lost.
16644 TemplateArgument SugaredConverted, CanonicalConverted;
16645 Replacement = SemaRef.CheckTemplateArgument(
16646 Param, ParamType, Replacement.get(), SugaredConverted,
16647 CanonicalConverted,
16648 /*StrictCheck=*/false, Sema::CTAK_Specified);
16649 if (Replacement.isInvalid())
16650 return true;
16651 } else {
16652 // Otherwise, the same expression would have been produced.
16653 Replacement = E->getReplacement();
16654 }
16655
16656 return getDerived().RebuildSubstNonTypeTemplateParmExpr(
16657 AssociatedDecl, E->getParameter(), E->getNameLoc(),
16658 TemplateArgument(Replacement.get(), /*IsCanonical=*/false),
16659 E->getPackIndex(), E->getFinal());
16660}
16661
16662template<typename Derived>
16665 // Default behavior is to do nothing with this transformation.
16666 return E;
16667}
16668
16669template<typename Derived>
16673 return getDerived().TransformExpr(E->getSubExpr());
16674}
16675
16676template<typename Derived>
16679 UnresolvedLookupExpr *Callee = nullptr;
16680 if (Expr *OldCallee = E->getCallee()) {
16681 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16682 if (CalleeResult.isInvalid())
16683 return ExprError();
16684 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16685 }
16686
16687 Expr *Pattern = E->getPattern();
16688
16690 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16691 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16692
16693 // Determine whether the set of unexpanded parameter packs can and should
16694 // be expanded.
16695 bool Expand = true;
16696 bool RetainExpansion = false;
16697 UnsignedOrNone OrigNumExpansions = E->getNumExpansions(),
16698 NumExpansions = OrigNumExpansions;
16699 if (getDerived().TryExpandParameterPacks(
16700 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16701 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16702 NumExpansions))
16703 return true;
16704
16705 if (!Expand) {
16706 // Do not expand any packs here, just transform and rebuild a fold
16707 // expression.
16708 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16709
16710 ExprResult LHS =
16711 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16712 if (LHS.isInvalid())
16713 return true;
16714
16715 ExprResult RHS =
16716 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16717 if (RHS.isInvalid())
16718 return true;
16719
16720 if (!getDerived().AlwaysRebuild() &&
16721 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16722 return E;
16723
16724 return getDerived().RebuildCXXFoldExpr(
16725 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16726 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16727 }
16728
16729 // Formally a fold expression expands to nested parenthesized expressions.
16730 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16731 // them.
16732 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < *NumExpansions) {
16733 SemaRef.Diag(E->getEllipsisLoc(),
16734 clang::diag::err_fold_expression_limit_exceeded)
16735 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16736 << E->getSourceRange();
16737 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16738 return ExprError();
16739 }
16740
16741 // The transform has determined that we should perform an elementwise
16742 // expansion of the pattern. Do so.
16743 ExprResult Result = getDerived().TransformExpr(E->getInit());
16744 if (Result.isInvalid())
16745 return true;
16746 bool LeftFold = E->isLeftFold();
16747
16748 // If we're retaining an expansion for a right fold, it is the innermost
16749 // component and takes the init (if any).
16750 if (!LeftFold && RetainExpansion) {
16751 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16752
16753 ExprResult Out = getDerived().TransformExpr(Pattern);
16754 if (Out.isInvalid())
16755 return true;
16756
16757 Result = getDerived().RebuildCXXFoldExpr(
16758 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16759 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16760 if (Result.isInvalid())
16761 return true;
16762 }
16763
16764 bool WarnedOnComparison = false;
16765 for (unsigned I = 0; I != *NumExpansions; ++I) {
16766 Sema::ArgPackSubstIndexRAII SubstIndex(
16767 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16768 ExprResult Out = getDerived().TransformExpr(Pattern);
16769 if (Out.isInvalid())
16770 return true;
16771
16772 if (Out.get()->containsUnexpandedParameterPack()) {
16773 // We still have a pack; retain a pack expansion for this slice.
16774 Result = getDerived().RebuildCXXFoldExpr(
16775 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16776 E->getOperator(), E->getEllipsisLoc(),
16777 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16778 OrigNumExpansions);
16779 } else if (Result.isUsable()) {
16780 // We've got down to a single element; build a binary operator.
16781 Expr *LHS = LeftFold ? Result.get() : Out.get();
16782 Expr *RHS = LeftFold ? Out.get() : Result.get();
16783 if (Callee) {
16784 UnresolvedSet<16> Functions;
16785 Functions.append(Callee->decls_begin(), Callee->decls_end());
16786 Result = getDerived().RebuildCXXOperatorCallExpr(
16787 BinaryOperator::getOverloadedOperator(E->getOperator()),
16788 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16789 Functions, LHS, RHS);
16790 } else {
16791 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16792 E->getOperator(), LHS, RHS,
16793 /*ForFoldExpresion=*/true);
16794 if (!WarnedOnComparison && Result.isUsable()) {
16795 if (auto *BO = dyn_cast<BinaryOperator>(Result.get());
16796 BO && BO->isComparisonOp()) {
16797 WarnedOnComparison = true;
16798 SemaRef.Diag(BO->getBeginLoc(),
16799 diag::warn_comparison_in_fold_expression)
16800 << BO->getOpcodeStr();
16801 }
16802 }
16803 }
16804 } else
16805 Result = Out;
16806
16807 if (Result.isInvalid())
16808 return true;
16809 }
16810
16811 // If we're retaining an expansion for a left fold, it is the outermost
16812 // component and takes the complete expansion so far as its init (if any).
16813 if (LeftFold && RetainExpansion) {
16814 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16815
16816 ExprResult Out = getDerived().TransformExpr(Pattern);
16817 if (Out.isInvalid())
16818 return true;
16819
16820 Result = getDerived().RebuildCXXFoldExpr(
16821 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16822 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16823 if (Result.isInvalid())
16824 return true;
16825 }
16826
16827 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16828 PE->setIsProducedByFoldExpansion();
16829
16830 // If we had no init and an empty pack, and we're not retaining an expansion,
16831 // then produce a fallback value or error.
16832 if (Result.isUnset())
16833 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16834 E->getOperator());
16835 return Result;
16836}
16837
16838template <typename Derived>
16841 SmallVector<Expr *, 4> TransformedInits;
16842 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16843
16844 QualType T = getDerived().TransformType(E->getType());
16845
16846 bool ArgChanged = false;
16847
16848 if (getDerived().TransformExprs(InitExprs.data(), InitExprs.size(), true,
16849 TransformedInits, &ArgChanged))
16850 return ExprError();
16851
16852 if (!getDerived().AlwaysRebuild() && !ArgChanged && T == E->getType())
16853 return E;
16854
16855 return getDerived().RebuildCXXParenListInitExpr(
16856 TransformedInits, T, E->getUserSpecifiedInitExprs().size(),
16857 E->getInitLoc(), E->getBeginLoc(), E->getEndLoc());
16858}
16859
16860template<typename Derived>
16864 return getDerived().TransformExpr(E->getSubExpr());
16865}
16866
16867template<typename Derived>
16870 return SemaRef.MaybeBindToTemporary(E);
16871}
16872
16873template<typename Derived>
16876 return E;
16877}
16878
16879template<typename Derived>
16882 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16883 if (SubExpr.isInvalid())
16884 return ExprError();
16885
16886 if (!getDerived().AlwaysRebuild() &&
16887 SubExpr.get() == E->getSubExpr())
16888 return E;
16889
16890 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16891}
16892
16893template<typename Derived>
16896 // Transform each of the elements.
16897 SmallVector<Expr *, 8> Elements;
16898 bool ArgChanged = false;
16899 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
16900 /*IsCall=*/false, Elements, &ArgChanged))
16901 return ExprError();
16902
16903 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16904 return SemaRef.MaybeBindToTemporary(E);
16905
16906 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
16907 Elements.data(),
16908 Elements.size());
16909}
16910
16911template<typename Derived>
16915 // Transform each of the elements.
16917 bool ArgChanged = false;
16918 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
16919 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
16920
16921 if (OrigElement.isPackExpansion()) {
16922 // This key/value element is a pack expansion.
16924 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
16925 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
16926 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16927
16928 // Determine whether the set of unexpanded parameter packs can
16929 // and should be expanded.
16930 bool Expand = true;
16931 bool RetainExpansion = false;
16932 UnsignedOrNone OrigNumExpansions = OrigElement.NumExpansions;
16933 UnsignedOrNone NumExpansions = OrigNumExpansions;
16934 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
16935 OrigElement.Value->getEndLoc());
16936 if (getDerived().TryExpandParameterPacks(
16937 OrigElement.EllipsisLoc, PatternRange, Unexpanded,
16938 /*FailOnPackProducingTemplates=*/true, Expand, RetainExpansion,
16939 NumExpansions))
16940 return ExprError();
16941
16942 if (!Expand) {
16943 // The transform has determined that we should perform a simple
16944 // transformation on the pack expansion, producing another pack
16945 // expansion.
16946 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt);
16947 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16948 if (Key.isInvalid())
16949 return ExprError();
16950
16951 if (Key.get() != OrigElement.Key)
16952 ArgChanged = true;
16953
16954 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16955 if (Value.isInvalid())
16956 return ExprError();
16957
16958 if (Value.get() != OrigElement.Value)
16959 ArgChanged = true;
16960
16961 ObjCDictionaryElement Expansion = {
16962 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
16963 };
16964 Elements.push_back(Expansion);
16965 continue;
16966 }
16967
16968 // Record right away that the argument was changed. This needs
16969 // to happen even if the array expands to nothing.
16970 ArgChanged = true;
16971
16972 // The transform has determined that we should perform an elementwise
16973 // expansion of the pattern. Do so.
16974 for (unsigned I = 0; I != *NumExpansions; ++I) {
16975 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
16976 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16977 if (Key.isInvalid())
16978 return ExprError();
16979
16980 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16981 if (Value.isInvalid())
16982 return ExprError();
16983
16984 ObjCDictionaryElement Element = {
16985 Key.get(), Value.get(), SourceLocation(), NumExpansions
16986 };
16987
16988 // If any unexpanded parameter packs remain, we still have a
16989 // pack expansion.
16990 // FIXME: Can this really happen?
16991 if (Key.get()->containsUnexpandedParameterPack() ||
16992 Value.get()->containsUnexpandedParameterPack())
16993 Element.EllipsisLoc = OrigElement.EllipsisLoc;
16994
16995 Elements.push_back(Element);
16996 }
16997
16998 // FIXME: Retain a pack expansion if RetainExpansion is true.
16999
17000 // We've finished with this pack expansion.
17001 continue;
17002 }
17003
17004 // Transform and check key.
17005 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
17006 if (Key.isInvalid())
17007 return ExprError();
17008
17009 if (Key.get() != OrigElement.Key)
17010 ArgChanged = true;
17011
17012 // Transform and check value.
17014 = getDerived().TransformExpr(OrigElement.Value);
17015 if (Value.isInvalid())
17016 return ExprError();
17017
17018 if (Value.get() != OrigElement.Value)
17019 ArgChanged = true;
17020
17021 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
17022 std::nullopt};
17023 Elements.push_back(Element);
17024 }
17025
17026 if (!getDerived().AlwaysRebuild() && !ArgChanged)
17027 return SemaRef.MaybeBindToTemporary(E);
17028
17029 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
17030 Elements);
17031}
17032
17033template<typename Derived>
17036 TypeSourceInfo *EncodedTypeInfo
17037 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
17038 if (!EncodedTypeInfo)
17039 return ExprError();
17040
17041 if (!getDerived().AlwaysRebuild() &&
17042 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
17043 return E;
17044
17045 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
17046 EncodedTypeInfo,
17047 E->getRParenLoc());
17048}
17049
17050template<typename Derived>
17053 // This is a kind of implicit conversion, and it needs to get dropped
17054 // and recomputed for the same general reasons that ImplicitCastExprs
17055 // do, as well a more specific one: this expression is only valid when
17056 // it appears *immediately* as an argument expression.
17057 return getDerived().TransformExpr(E->getSubExpr());
17058}
17059
17060template<typename Derived>
17063 TypeSourceInfo *TSInfo
17064 = getDerived().TransformType(E->getTypeInfoAsWritten());
17065 if (!TSInfo)
17066 return ExprError();
17067
17068 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
17069 if (Result.isInvalid())
17070 return ExprError();
17071
17072 if (!getDerived().AlwaysRebuild() &&
17073 TSInfo == E->getTypeInfoAsWritten() &&
17074 Result.get() == E->getSubExpr())
17075 return E;
17076
17077 return SemaRef.ObjC().BuildObjCBridgedCast(
17078 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
17079 Result.get());
17080}
17081
17082template <typename Derived>
17085 return E;
17086}
17087
17088template<typename Derived>
17091 // Transform arguments.
17092 bool ArgChanged = false;
17094 Args.reserve(E->getNumArgs());
17095 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
17096 &ArgChanged))
17097 return ExprError();
17098
17099 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
17100 // Class message: transform the receiver type.
17101 TypeSourceInfo *ReceiverTypeInfo
17102 = getDerived().TransformType(E->getClassReceiverTypeInfo());
17103 if (!ReceiverTypeInfo)
17104 return ExprError();
17105
17106 // If nothing changed, just retain the existing message send.
17107 if (!getDerived().AlwaysRebuild() &&
17108 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
17109 return SemaRef.MaybeBindToTemporary(E);
17110
17111 // Build a new class message send.
17113 E->getSelectorLocs(SelLocs);
17114 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
17115 E->getSelector(),
17116 SelLocs,
17117 E->getMethodDecl(),
17118 E->getLeftLoc(),
17119 Args,
17120 E->getRightLoc());
17121 }
17122 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
17123 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
17124 if (!E->getMethodDecl())
17125 return ExprError();
17126
17127 // Build a new class message send to 'super'.
17129 E->getSelectorLocs(SelLocs);
17130 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
17131 E->getSelector(),
17132 SelLocs,
17133 E->getReceiverType(),
17134 E->getMethodDecl(),
17135 E->getLeftLoc(),
17136 Args,
17137 E->getRightLoc());
17138 }
17139
17140 // Instance message: transform the receiver
17141 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
17142 "Only class and instance messages may be instantiated");
17143 ExprResult Receiver
17144 = getDerived().TransformExpr(E->getInstanceReceiver());
17145 if (Receiver.isInvalid())
17146 return ExprError();
17147
17148 // If nothing changed, just retain the existing message send.
17149 if (!getDerived().AlwaysRebuild() &&
17150 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
17151 return SemaRef.MaybeBindToTemporary(E);
17152
17153 // Build a new instance message send.
17155 E->getSelectorLocs(SelLocs);
17156 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
17157 E->getSelector(),
17158 SelLocs,
17159 E->getMethodDecl(),
17160 E->getLeftLoc(),
17161 Args,
17162 E->getRightLoc());
17163}
17164
17165template<typename Derived>
17168 return E;
17169}
17170
17171template<typename Derived>
17174 return E;
17175}
17176
17177template<typename Derived>
17180 // Transform the base expression.
17181 ExprResult Base = getDerived().TransformExpr(E->getBase());
17182 if (Base.isInvalid())
17183 return ExprError();
17184
17185 // We don't need to transform the ivar; it will never change.
17186
17187 // If nothing changed, just retain the existing expression.
17188 if (!getDerived().AlwaysRebuild() &&
17189 Base.get() == E->getBase())
17190 return E;
17191
17192 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
17193 E->getLocation(),
17194 E->isArrow(), E->isFreeIvar());
17195}
17196
17197template<typename Derived>
17200 // 'super' and types never change. Property never changes. Just
17201 // retain the existing expression.
17202 if (!E->isObjectReceiver())
17203 return E;
17204
17205 // Transform the base expression.
17206 ExprResult Base = getDerived().TransformExpr(E->getBase());
17207 if (Base.isInvalid())
17208 return ExprError();
17209
17210 // We don't need to transform the property; it will never change.
17211
17212 // If nothing changed, just retain the existing expression.
17213 if (!getDerived().AlwaysRebuild() &&
17214 Base.get() == E->getBase())
17215 return E;
17216
17217 if (E->isExplicitProperty())
17218 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17219 E->getExplicitProperty(),
17220 E->getLocation());
17221
17222 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
17223 SemaRef.Context.PseudoObjectTy,
17224 E->getImplicitPropertyGetter(),
17225 E->getImplicitPropertySetter(),
17226 E->getLocation());
17227}
17228
17229template<typename Derived>
17232 // Transform the base expression.
17233 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
17234 if (Base.isInvalid())
17235 return ExprError();
17236
17237 // Transform the key expression.
17238 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
17239 if (Key.isInvalid())
17240 return ExprError();
17241
17242 // If nothing changed, just retain the existing expression.
17243 if (!getDerived().AlwaysRebuild() &&
17244 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
17245 return E;
17246
17247 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
17248 Base.get(), Key.get(),
17249 E->getAtIndexMethodDecl(),
17250 E->setAtIndexMethodDecl());
17251}
17252
17253template<typename Derived>
17256 // Transform the base expression.
17257 ExprResult Base = getDerived().TransformExpr(E->getBase());
17258 if (Base.isInvalid())
17259 return ExprError();
17260
17261 // If nothing changed, just retain the existing expression.
17262 if (!getDerived().AlwaysRebuild() &&
17263 Base.get() == E->getBase())
17264 return E;
17265
17266 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
17267 E->getOpLoc(),
17268 E->isArrow());
17269}
17270
17271template<typename Derived>
17274 bool ArgumentChanged = false;
17275 SmallVector<Expr*, 8> SubExprs;
17276 SubExprs.reserve(E->getNumSubExprs());
17277 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17278 SubExprs, &ArgumentChanged))
17279 return ExprError();
17280
17281 if (!getDerived().AlwaysRebuild() &&
17282 !ArgumentChanged)
17283 return E;
17284
17285 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
17286 SubExprs,
17287 E->getRParenLoc());
17288}
17289
17290template<typename Derived>
17293 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17294 if (SrcExpr.isInvalid())
17295 return ExprError();
17296
17297 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
17298 if (!Type)
17299 return ExprError();
17300
17301 if (!getDerived().AlwaysRebuild() &&
17302 Type == E->getTypeSourceInfo() &&
17303 SrcExpr.get() == E->getSrcExpr())
17304 return E;
17305
17306 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
17307 SrcExpr.get(), Type,
17308 E->getRParenLoc());
17309}
17310
17311template<typename Derived>
17314 BlockDecl *oldBlock = E->getBlockDecl();
17315
17316 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
17317 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
17318
17319 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
17320 blockScope->TheDecl->setBlockMissingReturnType(
17321 oldBlock->blockMissingReturnType());
17322
17324 SmallVector<QualType, 4> paramTypes;
17325
17326 const FunctionProtoType *exprFunctionType = E->getFunctionType();
17327
17328 // Parameter substitution.
17329 Sema::ExtParameterInfoBuilder extParamInfos;
17330 if (getDerived().TransformFunctionTypeParams(
17331 E->getCaretLocation(), oldBlock->parameters(), nullptr,
17332 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
17333 extParamInfos)) {
17334 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17335 return ExprError();
17336 }
17337
17338 QualType exprResultType =
17339 getDerived().TransformType(exprFunctionType->getReturnType());
17340
17341 auto epi = exprFunctionType->getExtProtoInfo();
17342 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
17343
17345 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
17346 blockScope->FunctionType = functionType;
17347
17348 // Set the parameters on the block decl.
17349 if (!params.empty())
17350 blockScope->TheDecl->setParams(params);
17351
17352 if (!oldBlock->blockMissingReturnType()) {
17353 blockScope->HasImplicitReturnType = false;
17354 blockScope->ReturnType = exprResultType;
17355 }
17356
17357 // Transform the body
17358 StmtResult body = getDerived().TransformStmt(E->getBody());
17359 if (body.isInvalid()) {
17360 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
17361 return ExprError();
17362 }
17363
17364#ifndef NDEBUG
17365 // In builds with assertions, make sure that we captured everything we
17366 // captured before.
17367 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
17368 for (const auto &I : oldBlock->captures()) {
17369 VarDecl *oldCapture = I.getVariable();
17370
17371 // Ignore parameter packs.
17372 if (oldCapture->isParameterPack())
17373 continue;
17374
17375 VarDecl *newCapture =
17376 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
17377 oldCapture));
17378 assert(blockScope->CaptureMap.count(newCapture));
17379 }
17380
17381 // The this pointer may not be captured by the instantiated block, even when
17382 // it's captured by the original block, if the expression causing the
17383 // capture is in the discarded branch of a constexpr if statement.
17384 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
17385 "this pointer isn't captured in the old block");
17386 }
17387#endif
17388
17389 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
17390 /*Scope=*/nullptr);
17391}
17392
17393template<typename Derived>
17396 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
17397 if (SrcExpr.isInvalid())
17398 return ExprError();
17399
17400 QualType Type = getDerived().TransformType(E->getType());
17401
17402 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
17403 E->getRParenLoc());
17404}
17405
17406template<typename Derived>
17409 bool ArgumentChanged = false;
17410 SmallVector<Expr*, 8> SubExprs;
17411 SubExprs.reserve(E->getNumSubExprs());
17412 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
17413 SubExprs, &ArgumentChanged))
17414 return ExprError();
17415
17416 if (!getDerived().AlwaysRebuild() &&
17417 !ArgumentChanged)
17418 return E;
17419
17420 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
17421 E->getOp(), E->getRParenLoc());
17422}
17423
17424//===----------------------------------------------------------------------===//
17425// Type reconstruction
17426//===----------------------------------------------------------------------===//
17427
17428template<typename Derived>
17431 return SemaRef.BuildPointerType(PointeeType, Star,
17433}
17434
17435template<typename Derived>
17438 return SemaRef.BuildBlockPointerType(PointeeType, Star,
17440}
17441
17442template<typename Derived>
17445 bool WrittenAsLValue,
17446 SourceLocation Sigil) {
17447 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
17448 Sigil, getDerived().getBaseEntity());
17449}
17450
17451template <typename Derived>
17453 QualType PointeeType, const CXXScopeSpec &SS, CXXRecordDecl *Cls,
17454 SourceLocation Sigil) {
17455 return SemaRef.BuildMemberPointerType(PointeeType, SS, Cls, Sigil,
17457}
17458
17459template<typename Derived>
17461 const ObjCTypeParamDecl *Decl,
17462 SourceLocation ProtocolLAngleLoc,
17464 ArrayRef<SourceLocation> ProtocolLocs,
17465 SourceLocation ProtocolRAngleLoc) {
17466 return SemaRef.ObjC().BuildObjCTypeParamType(
17467 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17468 /*FailOnError=*/true);
17469}
17470
17471template<typename Derived>
17473 QualType BaseType,
17474 SourceLocation Loc,
17475 SourceLocation TypeArgsLAngleLoc,
17477 SourceLocation TypeArgsRAngleLoc,
17478 SourceLocation ProtocolLAngleLoc,
17480 ArrayRef<SourceLocation> ProtocolLocs,
17481 SourceLocation ProtocolRAngleLoc) {
17482 return SemaRef.ObjC().BuildObjCObjectType(
17483 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
17484 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
17485 /*FailOnError=*/true,
17486 /*Rebuilding=*/true);
17487}
17488
17489template<typename Derived>
17491 QualType PointeeType,
17493 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
17494}
17495
17496template <typename Derived>
17498 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
17499 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17500 if (SizeExpr || !Size)
17501 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17502 IndexTypeQuals, BracketsRange,
17504
17505 QualType Types[] = {
17506 SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
17507 SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
17508 SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
17509 };
17510 QualType SizeType;
17511 for (const auto &T : Types)
17512 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17513 SizeType = T;
17514 break;
17515 }
17516
17517 // Note that we can return a VariableArrayType here in the case where
17518 // the element type was a dependent VariableArrayType.
17519 IntegerLiteral *ArraySize
17520 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17521 /*FIXME*/BracketsRange.getBegin());
17522 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17523 IndexTypeQuals, BracketsRange,
17525}
17526
17527template <typename Derived>
17529 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17530 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17531 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17532 IndexTypeQuals, BracketsRange);
17533}
17534
17535template <typename Derived>
17537 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17538 SourceRange BracketsRange) {
17539 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17540 IndexTypeQuals, BracketsRange);
17541}
17542
17543template <typename Derived>
17545 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17546 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17547 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17548 SizeExpr,
17549 IndexTypeQuals, BracketsRange);
17550}
17551
17552template <typename Derived>
17554 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17555 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17556 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17557 SizeExpr,
17558 IndexTypeQuals, BracketsRange);
17559}
17560
17561template <typename Derived>
17563 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17564 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17565 AttributeLoc);
17566}
17567
17568template <typename Derived>
17570 unsigned NumElements,
17571 VectorKind VecKind) {
17572 // FIXME: semantic checking!
17573 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17574}
17575
17576template <typename Derived>
17578 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17579 VectorKind VecKind) {
17580 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17581}
17582
17583template<typename Derived>
17585 unsigned NumElements,
17586 SourceLocation AttributeLoc) {
17587 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17588 NumElements, true);
17589 IntegerLiteral *VectorSize
17590 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17591 AttributeLoc);
17592 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17593}
17594
17595template<typename Derived>
17598 Expr *SizeExpr,
17599 SourceLocation AttributeLoc) {
17600 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17601}
17602
17603template <typename Derived>
17605 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17606 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17607 NumColumns);
17608}
17609
17610template <typename Derived>
17612 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17613 SourceLocation AttributeLoc) {
17614 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17615 AttributeLoc);
17616}
17617
17618template <typename Derived>
17620 QualType T, MutableArrayRef<QualType> ParamTypes,
17622 return SemaRef.BuildFunctionType(T, ParamTypes,
17625 EPI);
17626}
17627
17628template<typename Derived>
17630 return SemaRef.Context.getFunctionNoProtoType(T);
17631}
17632
17633template <typename Derived>
17636 SourceLocation NameLoc, Decl *D) {
17637 assert(D && "no decl found");
17638 if (D->isInvalidDecl()) return QualType();
17639
17640 // FIXME: Doesn't account for ObjCInterfaceDecl!
17641 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17642 // A valid resolved using typename pack expansion decl can have multiple
17643 // UsingDecls, but they must each have exactly one type, and it must be
17644 // the same type in every case. But we must have at least one expansion!
17645 if (UPD->expansions().empty()) {
17646 getSema().Diag(NameLoc, diag::err_using_pack_expansion_empty)
17647 << UPD->isCXXClassMember() << UPD;
17648 return QualType();
17649 }
17650
17651 // We might still have some unresolved types. Try to pick a resolved type
17652 // if we can. The final instantiation will check that the remaining
17653 // unresolved types instantiate to the type we pick.
17654 QualType FallbackT;
17655 QualType T;
17656 for (auto *E : UPD->expansions()) {
17657 QualType ThisT =
17658 RebuildUnresolvedUsingType(Keyword, Qualifier, NameLoc, E);
17659 if (ThisT.isNull())
17660 continue;
17661 if (ThisT->getAs<UnresolvedUsingType>())
17662 FallbackT = ThisT;
17663 else if (T.isNull())
17664 T = ThisT;
17665 else
17666 assert(getSema().Context.hasSameType(ThisT, T) &&
17667 "mismatched resolved types in using pack expansion");
17668 }
17669 return T.isNull() ? FallbackT : T;
17670 }
17671 if (auto *Using = dyn_cast<UsingDecl>(D)) {
17672 assert(Using->hasTypename() &&
17673 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17674
17675 // A valid resolved using typename decl points to exactly one type decl.
17676 assert(++Using->shadow_begin() == Using->shadow_end());
17677
17678 UsingShadowDecl *Shadow = *Using->shadow_begin();
17679 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), NameLoc))
17680 return QualType();
17681 return SemaRef.Context.getUsingType(Keyword, Qualifier, Shadow);
17682 }
17684 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17685 return SemaRef.Context.getUnresolvedUsingType(
17687}
17688
17689template <typename Derived>
17691 TypeOfKind Kind) {
17692 return SemaRef.BuildTypeofExprType(E, Kind);
17693}
17694
17695template<typename Derived>
17697 TypeOfKind Kind) {
17698 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17699}
17700
17701template <typename Derived>
17703 return SemaRef.BuildDecltypeType(E);
17704}
17705
17706template <typename Derived>
17708 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17709 SourceLocation EllipsisLoc, bool FullySubstituted,
17710 ArrayRef<QualType> Expansions) {
17711 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17712 FullySubstituted, Expansions);
17713}
17714
17715template<typename Derived>
17717 UnaryTransformType::UTTKind UKind,
17718 SourceLocation Loc) {
17719 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17720}
17721
17722template <typename Derived>
17725 SourceLocation TemplateNameLoc, TemplateArgumentListInfo &TemplateArgs) {
17726 return SemaRef.CheckTemplateIdType(
17727 Keyword, Template, TemplateNameLoc, TemplateArgs,
17728 /*Scope=*/nullptr, /*ForNestedNameSpecifier=*/false);
17729}
17730
17731template<typename Derived>
17733 SourceLocation KWLoc) {
17734 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17735}
17736
17737template<typename Derived>
17739 SourceLocation KWLoc,
17740 bool isReadPipe) {
17741 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17742 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17743}
17744
17745template <typename Derived>
17747 unsigned NumBits,
17748 SourceLocation Loc) {
17749 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17750 NumBits, true);
17751 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17752 SemaRef.Context.IntTy, Loc);
17753 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17754}
17755
17756template <typename Derived>
17758 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17759 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17760}
17761
17762template <typename Derived>
17764 bool TemplateKW,
17765 TemplateName Name) {
17766 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17767 Name);
17768}
17769
17770template <typename Derived>
17772 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const IdentifierInfo &Name,
17773 SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName) {
17775 TemplateName.setIdentifier(&Name, NameLoc);
17777 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17778 TemplateName, ParsedType::make(ObjectType),
17779 /*EnteringContext=*/false, Template,
17780 AllowInjectedClassName);
17781 return Template.get();
17782}
17783
17784template<typename Derived>
17787 SourceLocation TemplateKWLoc,
17788 OverloadedOperatorKind Operator,
17789 SourceLocation NameLoc,
17790 QualType ObjectType,
17791 bool AllowInjectedClassName) {
17792 UnqualifiedId Name;
17793 // FIXME: Bogus location information.
17794 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17795 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17797 getSema().ActOnTemplateName(
17798 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17799 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17800 return Template.get();
17801}
17802
17803template <typename Derived>
17806 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17807 Expr *Second) {
17808 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17809
17810 if (First->getObjectKind() == OK_ObjCProperty) {
17813 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17814 Opc, First, Second);
17815 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
17816 if (Result.isInvalid())
17817 return ExprError();
17818 First = Result.get();
17819 }
17820
17821 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17822 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17823 if (Result.isInvalid())
17824 return ExprError();
17825 Second = Result.get();
17826 }
17827
17828 // Determine whether this should be a builtin operation.
17829 if (Op == OO_Subscript) {
17830 if (!First->getType()->isOverloadableType() &&
17831 !Second->getType()->isOverloadableType())
17832 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17833 OpLoc);
17834 } else if (Op == OO_Arrow) {
17835 // It is possible that the type refers to a RecoveryExpr created earlier
17836 // in the tree transformation.
17837 if (First->getType()->isDependentType())
17838 return ExprError();
17839 // -> is never a builtin operation.
17840 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17841 } else if (Second == nullptr || isPostIncDec) {
17842 if (!First->getType()->isOverloadableType() ||
17843 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17844 // The argument is not of overloadable type, or this is an expression
17845 // of the form &Class::member, so try to create a built-in unary
17846 // operation.
17848 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17849
17850 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17851 }
17852 } else {
17853 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17854 !First->getType()->isOverloadableType() &&
17855 !Second->getType()->isOverloadableType()) {
17856 // Neither of the arguments is type-dependent or has an overloadable
17857 // type, so try to create a built-in binary operation.
17860 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17861 if (Result.isInvalid())
17862 return ExprError();
17863
17864 return Result;
17865 }
17866 }
17867
17868 // Create the overloaded operator invocation for unary operators.
17869 if (!Second || isPostIncDec) {
17871 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17872 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17873 RequiresADL);
17874 }
17875
17876 // Create the overloaded operator invocation for binary operators.
17878 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17879 First, Second, RequiresADL);
17880 if (Result.isInvalid())
17881 return ExprError();
17882
17883 return Result;
17884}
17885
17886template<typename Derived>
17889 SourceLocation OperatorLoc,
17890 bool isArrow,
17891 CXXScopeSpec &SS,
17892 TypeSourceInfo *ScopeType,
17893 SourceLocation CCLoc,
17894 SourceLocation TildeLoc,
17895 PseudoDestructorTypeStorage Destroyed) {
17896 QualType CanonicalBaseType = Base->getType().getCanonicalType();
17897 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
17898 (!isArrow && !isa<RecordType>(CanonicalBaseType)) ||
17899 (isArrow && isa<PointerType>(CanonicalBaseType) &&
17900 !cast<PointerType>(CanonicalBaseType)
17901 ->getPointeeType()
17902 ->getAsCanonical<RecordType>())) {
17903 // This pseudo-destructor expression is still a pseudo-destructor.
17904 return SemaRef.BuildPseudoDestructorExpr(
17905 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
17906 CCLoc, TildeLoc, Destroyed);
17907 }
17908
17909 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
17910 DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
17911 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
17912 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
17913 NameInfo.setNamedTypeInfo(DestroyedType);
17914
17915 // The scope type is now known to be a valid nested name specifier
17916 // component. Tack it on to the nested name specifier.
17917 if (ScopeType) {
17918 if (!isa<TagType>(ScopeType->getType().getCanonicalType())) {
17919 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
17920 diag::err_expected_class_or_namespace)
17921 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
17922 return ExprError();
17923 }
17924 SS.clear();
17925 SS.Make(SemaRef.Context, ScopeType->getTypeLoc(), CCLoc);
17926 }
17927
17928 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
17929 return getSema().BuildMemberReferenceExpr(
17930 Base, Base->getType(), OperatorLoc, isArrow, SS, TemplateKWLoc,
17931 /*FIXME: FirstQualifier*/ nullptr, NameInfo,
17932 /*TemplateArgs*/ nullptr,
17933 /*S*/ nullptr);
17934}
17935
17936template<typename Derived>
17939 SourceLocation Loc = S->getBeginLoc();
17940 CapturedDecl *CD = S->getCapturedDecl();
17941 unsigned NumParams = CD->getNumParams();
17942 unsigned ContextParamPos = CD->getContextParamPosition();
17944 for (unsigned I = 0; I < NumParams; ++I) {
17945 if (I != ContextParamPos) {
17946 Params.push_back(
17947 std::make_pair(
17948 CD->getParam(I)->getName(),
17949 getDerived().TransformType(CD->getParam(I)->getType())));
17950 } else {
17951 Params.push_back(std::make_pair(StringRef(), QualType()));
17952 }
17953 }
17954 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
17955 S->getCapturedRegionKind(), Params);
17956 StmtResult Body;
17957 {
17958 Sema::CompoundScopeRAII CompoundScope(getSema());
17959 Body = getDerived().TransformStmt(S->getCapturedStmt());
17960 }
17961
17962 if (Body.isInvalid()) {
17963 getSema().ActOnCapturedRegionError();
17964 return StmtError();
17965 }
17966
17967 return getSema().ActOnCapturedRegionEnd(Body.get());
17968}
17969
17970template <typename Derived>
17973 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
17974 // function definition or instantiation of a function template specialization
17975 // and will therefore never appear in a dependent context.
17976 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
17977 "context");
17978}
17979
17980template <typename Derived>
17982 // We can transform the base expression and allow argument resolution to fill
17983 // in the rest.
17984 return getDerived().TransformExpr(E->getArgLValue());
17985}
17986
17987} // end namespace clang
17988
17989#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::json::Object Object
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
attr::Kind getKind() const
Definition Attr.h:92
Represents an attribute applied to a statement.
Definition Stmt.h:2195
Stmt * getSubStmt()
Definition Stmt.h:2231
SourceLocation getAttrLoc() const
Definition Stmt.h:2226
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2227
Type source information for an attributed type.
Definition TypeLoc.h:1008
void setAttr(const Attr *A)
Definition TypeLoc.h:1034
Type source information for an btf_tag attributed type.
Definition TypeLoc.h:1058
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition Expr.h: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:8201
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4671
void setIsVariadic(bool value)
Definition Decl.h:4747
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h: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:2610
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:2875
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:2135
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:1860
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:4943
unsigned getNumParams() const
Definition Decl.h:4981
unsigned getContextParamPosition() const
Definition Decl.h:5010
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4983
This captures a statement into a function.
Definition Stmt.h:3929
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp: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:4442
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:4996
Expr * getCondition() const
Definition TypeBase.h:5003
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:5244
Represents an abstract function effect, using just an enumeration describing its kind.
Definition TypeBase.h:4889
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition Type.cpp:5598
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition Type.cpp:5584
ArrayRef< EffectConditionExpr > conditions() const
Definition TypeBase.h:5110
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4854
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:5276
param_type_iterator param_type_begin() const
Definition TypeBase.h:5720
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:4498
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
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
Definition Lookup.h:607
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition Lookup.h:475
bool empty() const
Return true if no decls were found.
Definition Lookup.h:362
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Definition Lookup.h:666
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition Lookup.h:576
DeclarationName getLookupName() const
Gets the name to look up.
Definition Lookup.h:265
This represents a Microsoft inline-assembly statement extension.
Definition Stmt.h:3657
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition StmtCXX.h:253
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4346
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
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition Decl.h:487
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition Decl.h:295
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:301
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:340
Represents C++ namespaces and their aliases.
Definition Decl.h:573
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents a place-holder for an object not to be initialized by anything.
Definition Expr.h: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:8167
bool isReadOnly() const
Definition TypeBase.h:8197
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:8349
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition TypeBase.h:8389
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition TypeBase.h:8443
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8381
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:2104
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition DeclCXX.cpp:2403
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:37
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
Definition SemaObjC.cpp:36
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
Definition SemaObjC.cpp:193
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition SemaObjC.cpp:320
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
Definition SemaObjC.cpp:218
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:213
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition SemaObjC.cpp:238
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition SemaObjC.cpp:282
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Definition SemaObjC.cpp:202
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition SemaObjC.cpp:329
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
Helper type for the registration/assignment of constructs that need to 'know' about their parent cons...
Helper type to restore the state of various 'loop' constructs when we run into a loop (for,...
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
void ActOnWhileStmt(SourceLocation WhileLoc)
ExprResult ActOnOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
void ActOnDoStmt(SourceLocation DoLoc)
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *OldRangeFor, const Stmt *RangeFor)
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation MiscLoc, ArrayRef< Expr * > Exprs, OpenACCAtomicKind AK, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
void ActOnForStmtEnd(SourceLocation ForLoc, StmtResult Body)
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *First, const Stmt *Second, const Stmt *Third)
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
OMPClause * ActOnOpenMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nocontext' clause.
OMPClause * ActOnOpenMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_dyn_cgroup_mem' clause.
OMPClause * ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'safelen' clause.
OMPClause * ActOnOpenMPHoldsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'holds' clause.
OMPClause * ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'filter' clause.
OMPClause * ActOnOpenMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on well-form 'full' clauses.
OMPClause * ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'detach' clause.
OMPClause * ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'use' clause.
OMPClause * ActOnOpenMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'private' clause.
OMPClause * ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc=SourceLocation(), Expr *NumForLoops=nullptr)
Called on well-formed 'ordered' clause.
OMPClause * ActOnOpenMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'is_device_ptr' clause.
OMPClause * ActOnOpenMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'has_device_addr' clause.
OMPClause * ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'partial' clauses.
OMPClause * ActOnOpenMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'lastprivate' clause.
OMPClause * ActOnOpenMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'firstprivate' clause.
OMPClause * ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'priority' clause.
OMPClause * ActOnOpenMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'dist_schedule' clause.
OMPClause * ActOnOpenMPLoopRangeClause(Expr *First, Expr *Count, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc)
Called on well-form 'looprange' clause after parsing its arguments.
OMPClause * ActOnOpenMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'permutation' clause after parsing its arguments.
OMPClause * ActOnOpenMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nontemporal' clause.
OMPClause * ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'bind' clause.
OMPClause * ActOnOpenMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' clause.
OMPClause * ActOnOpenMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'shared' clause.
OMPClause * ActOnOpenMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyin' clause.
OMPClause * ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'destroy' clause.
OMPClause * ActOnOpenMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Called on well-formed 'affinity' clause.
OMPClause * ActOnOpenMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' clause.
OMPClause * ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depend' clause.
OMPClause * ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'doacross' clause.
OMPClause * ActOnOpenMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, OpenMPUseDevicePtrFallbackModifier FallbackModifier, SourceLocation FallbackModifierLoc)
Called on well-formed 'use_device_ptr' clause.
OMPClause * ActOnOpenMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'grainsize' clause.
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
ExprResult ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< OMPIteratorData > Data)
OMPClause * ActOnOpenMPUsesAllocatorClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< UsesAllocatorsData > Data)
Called on well-formed 'uses_allocators' clause.
OMPClause * ActOnOpenMPAllocatorClause(Expr *Allocator, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocator' clause.
OMPClause * ActOnOpenMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'inclusive' clause.
OMPClause * ActOnOpenMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'task_reduction' clause.
OMPClause * ActOnOpenMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Condition)
Called on well-formed 'nowait' clause.
OMPClause * ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, OpenMPOrderClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'order' clause.
OMPClause * ActOnOpenMPSizesClause(ArrayRef< Expr * > SizeExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'sizes' clause.
OMPClause * ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'device' clause.
OMPClause * ActOnOpenMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'in_reduction' clause.
OMPClause * ActOnOpenMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'flush' pseudo clause.
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
OMPClause * ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'message' clause.
OMPClause * ActOnOpenMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'schedule' clause.
OMPClause * ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'simdlen' clause.
OMPClause * ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'proc_bind' clause.
OMPClause * ActOnOpenMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_bare' clause.
StmtResult ActOnOpenMPInformationalDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Process an OpenMP informational directive.
StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt)
Called for syntactical loops (ForStmt or CXXForRangeStmt) associated to an OpenMP loop directive.
OMPClause * ActOnOpenMPTransparentClause(Expr *Transparent, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'transparent' clause.
OMPClause * ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'hint' clause.
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
OMPClause * ActOnOpenMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_threads' clause.
OMPClause * ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'at' clause.
OMPClause * ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'init' clause.
OMPClause * ActOnOpenMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_addr' clause.
OMPClause * ActOnOpenMPAllocateClause(Expr *Allocator, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocate' clause.
OMPClause * ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'final' clause.
OMPClause * ActOnOpenMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, bool NoDiagnose=false, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'map' clause.
OMPClause * ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_tasks' clause.
OMPClause * ActOnOpenMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'from' clause.
OMPClause * ActOnOpenMPDynGroupprivateClause(OpenMPDynGroupprivateClauseModifier M1, OpenMPDynGroupprivateClauseFallbackModifier M2, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation EndLoc)
Called on a well-formed 'dyn_groupprivate' clause.
void StartOpenMPDSABlock(OpenMPDirectiveKind K, const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc)
Called on start of new data sharing attribute block.
OMPClause * ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'severity' clause.
OMPClause * ActOnOpenMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, Expr *IteratorModifier, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'to' clause.
OMPClause * ActOnOpenMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind LinKind, SourceLocation LinLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Called on well-formed 'linear' clause.
OMPClause * ActOnOpenMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'defaultmap' clause.
OMPClause * ActOnOpenMPReductionClause(ArrayRef< Expr * > VarList, OpenMPVarListDataTy::OpenMPReductionClauseModifiers Modifiers, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'reduction' clause.
OMPClause * ActOnOpenMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'aligned' clause.
OMPClause * ActOnOpenMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depobj' pseudo clause.
OMPClause * ActOnOpenMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'novariants' clause.
OMPClause * ActOnOpenMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyprivate' clause.
OMPClause * ActOnOpenMPCollapseClause(Expr *NumForLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'collapse' clause.
OMPClause * ActOnOpenMPDefaultClause(llvm::omp::DefaultKind M, SourceLocation MLoc, OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCKindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'default' clause.
OMPClause * ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'align' clause.
OMPClause * ActOnOpenMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_attribute' clause.
OMPClause * ActOnOpenMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'exclusive' clause.
OMPClause * ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'if' clause.
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
Given a pseudo-object expression, recreate what it looks like syntactically without the attendant Opa...
ExprResult checkRValue(Expr *E)
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition SemaSYCL.cpp:143
RAII object used to change the argument pack substitution index within a Sema object.
Definition Sema.h:13697
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition Sema.h:8497
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:3517
A helper class for building up ExtParameterInfos.
Definition Sema.h:13083
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:13102
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13090
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition Sema.h:14102
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:9380
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9388
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9383
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:1524
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:7887
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7889
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7888
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:1549
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:12028
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:1509
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:83
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:1514
@ ReuseLambdaContextDecl
Definition Sema.h:7065
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:11831
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:11826
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition Sema.cpp:2533
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1437
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:13691
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:6778
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6788
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6757
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6783
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:75
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition Sema.h:8366
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:11115
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:7873
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:436
SemaPseudoObject & PseudoObject()
Definition Sema.h:1534
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:8708
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:6187
A container of type source information.
Definition TypeBase.h:8320
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:8331
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:9102
bool isObjCObjectPointerType() const
Definition TypeBase.h:8765
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9179
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:5992
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:3401
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3465
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:5590
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:790
bool ContainsUnexpandedParameterPack
Whether this contains an unexpanded parameter pack.
Definition ScopeInfo.h:728
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition ScopeInfo.h:871
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Definition ScopeInfo.h:874
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
VE builtins.
const AstTypeMatcher< FunctionType > functionType
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition Descriptor.h:29
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
Definition Interp.h:1024
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:808
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:5900
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:5875
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5896
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5886
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5893
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:5013
Holds information about the various types of exception specification.
Definition TypeBase.h:5333
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition TypeBase.h:5349
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5335
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5338
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5341
Extra information about a function prototype.
Definition TypeBase.h:5361
const ExtParameterInfo * ExtParameterInfos
Definition TypeBase.h:5366
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:3340
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:13163
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13194
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:3317
Location information for a TemplateArgument.
UnsignedOrNone OrigNumExpansions
SourceLocation Ellipsis
UnsignedOrNone NumExpansions