clang  10.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 
16 #include "CoroutineStmtBuilder.h"
17 #include "TypeLocBuilder.h"
18 #include "clang/AST/Decl.h"
19 #include "clang/AST/DeclObjC.h"
20 #include "clang/AST/DeclTemplate.h"
21 #include "clang/AST/Expr.h"
22 #include "clang/AST/ExprConcepts.h"
23 #include "clang/AST/ExprCXX.h"
24 #include "clang/AST/ExprObjC.h"
25 #include "clang/AST/ExprOpenMP.h"
26 #include "clang/AST/OpenMPClause.h"
27 #include "clang/AST/Stmt.h"
28 #include "clang/AST/StmtCXX.h"
29 #include "clang/AST/StmtObjC.h"
30 #include "clang/AST/StmtOpenMP.h"
31 #include "clang/Sema/Designator.h"
32 #include "clang/Sema/Lookup.h"
33 #include "clang/Sema/Ownership.h"
35 #include "clang/Sema/ScopeInfo.h"
38 #include "llvm/ADT/ArrayRef.h"
39 #include "llvm/Support/ErrorHandling.h"
40 #include <algorithm>
41 
42 using namespace llvm::omp;
43 
44 namespace clang {
45 using namespace sema;
46 
47 /// A semantic tree transformation that allows one to transform one
48 /// abstract syntax tree into another.
49 ///
50 /// A new tree transformation is defined by creating a new subclass \c X of
51 /// \c TreeTransform<X> and then overriding certain operations to provide
52 /// behavior specific to that transformation. For example, template
53 /// instantiation is implemented as a tree transformation where the
54 /// transformation of TemplateTypeParmType nodes involves substituting the
55 /// template arguments for their corresponding template parameters; a similar
56 /// transformation is performed for non-type template parameters and
57 /// template template parameters.
58 ///
59 /// This tree-transformation template uses static polymorphism to allow
60 /// subclasses to customize any of its operations. Thus, a subclass can
61 /// override any of the transformation or rebuild operators by providing an
62 /// operation with the same signature as the default implementation. The
63 /// overriding function should not be virtual.
64 ///
65 /// Semantic tree transformations are split into two stages, either of which
66 /// can be replaced by a subclass. The "transform" step transforms an AST node
67 /// or the parts of an AST node using the various transformation functions,
68 /// then passes the pieces on to the "rebuild" step, which constructs a new AST
69 /// node of the appropriate kind from the pieces. The default transformation
70 /// routines recursively transform the operands to composite AST nodes (e.g.,
71 /// the pointee type of a PointerType node) and, if any of those operand nodes
72 /// were changed by the transformation, invokes the rebuild operation to create
73 /// a new AST node.
74 ///
75 /// Subclasses can customize the transformation at various levels. The
76 /// most coarse-grained transformations involve replacing TransformType(),
77 /// TransformExpr(), TransformDecl(), TransformNestedNameSpecifierLoc(),
78 /// TransformTemplateName(), or TransformTemplateArgument() with entirely
79 /// new implementations.
80 ///
81 /// For more fine-grained transformations, subclasses can replace any of the
82 /// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
83 /// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
84 /// replacing TransformTemplateTypeParmType() allows template instantiation
85 /// to substitute template arguments for their corresponding template
86 /// parameters. Additionally, subclasses can override the \c RebuildXXX
87 /// functions to control how AST nodes are rebuilt when their operands change.
88 /// By default, \c TreeTransform will invoke semantic analysis to rebuild
89 /// AST nodes. However, certain other tree transformations (e.g, cloning) may
90 /// be able to use more efficient rebuild steps.
91 ///
92 /// There are a handful of other functions that can be overridden, allowing one
93 /// to avoid traversing nodes that don't need any transformation
94 /// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
95 /// operands have not changed (\c AlwaysRebuild()), and customize the
96 /// default locations and entity names used for type-checking
97 /// (\c getBaseLocation(), \c getBaseEntity()).
98 template<typename Derived>
100  /// Private RAII object that helps us forget and then re-remember
101  /// the template argument corresponding to a partially-substituted parameter
102  /// pack.
103  class ForgetPartiallySubstitutedPackRAII {
104  Derived &Self;
105  TemplateArgument Old;
106 
107  public:
108  ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) {
109  Old = Self.ForgetPartiallySubstitutedPack();
110  }
111 
112  ~ForgetPartiallySubstitutedPackRAII() {
113  Self.RememberPartiallySubstitutedPack(Old);
114  }
115  };
116 
117 protected:
119 
120  /// The set of local declarations that have been transformed, for
121  /// cases where we are forced to build new declarations within the transformer
122  /// rather than in the subclass (e.g., lambda closure types).
123  llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls;
124 
125 public:
126  /// Initializes a new tree transformer.
127  TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { }
128 
129  /// Retrieves a reference to the derived class.
130  Derived &getDerived() { return static_cast<Derived&>(*this); }
131 
132  /// Retrieves a reference to the derived class.
133  const Derived &getDerived() const {
134  return static_cast<const Derived&>(*this);
135  }
136 
137  static inline ExprResult Owned(Expr *E) { return E; }
138  static inline StmtResult Owned(Stmt *S) { return S; }
139 
140  /// Retrieves a reference to the semantic analysis object used for
141  /// this tree transform.
142  Sema &getSema() const { return SemaRef; }
143 
144  /// Whether the transformation should always rebuild AST nodes, even
145  /// if none of the children have changed.
146  ///
147  /// Subclasses may override this function to specify when the transformation
148  /// should rebuild all AST nodes.
149  ///
150  /// We must always rebuild all AST nodes when performing variadic template
151  /// pack expansion, in order to avoid violating the AST invariant that each
152  /// statement node appears at most once in its containing declaration.
153  bool AlwaysRebuild() { return SemaRef.ArgumentPackSubstitutionIndex != -1; }
154 
155  /// Whether the transformation is forming an expression or statement that
156  /// replaces the original. In this case, we'll reuse mangling numbers from
157  /// existing lambdas.
158  bool ReplacingOriginal() { return false; }
159 
160  /// Returns the location of the entity being transformed, if that
161  /// information was not available elsewhere in the AST.
162  ///
163  /// By default, returns no source-location information. Subclasses can
164  /// provide an alternative implementation that provides better location
165  /// information.
167 
168  /// Returns the name of the entity being transformed, if that
169  /// information was not available elsewhere in the AST.
170  ///
171  /// By default, returns an empty name. Subclasses can provide an alternative
172  /// implementation with a more precise name.
174 
175  /// Sets the "base" location and entity when that
176  /// information is known based on another transformation.
177  ///
178  /// By default, the source location and entity are ignored. Subclasses can
179  /// override this function to provide a customized implementation.
180  void setBase(SourceLocation Loc, DeclarationName Entity) { }
181 
182  /// RAII object that temporarily sets the base location and entity
183  /// used for reporting diagnostics in types.
185  TreeTransform &Self;
186  SourceLocation OldLocation;
187  DeclarationName OldEntity;
188 
189  public:
191  DeclarationName Entity) : Self(Self) {
192  OldLocation = Self.getDerived().getBaseLocation();
193  OldEntity = Self.getDerived().getBaseEntity();
194 
195  if (Location.isValid())
196  Self.getDerived().setBase(Location, Entity);
197  }
198 
200  Self.getDerived().setBase(OldLocation, OldEntity);
201  }
202  };
203 
204  /// Determine whether the given type \p T has already been
205  /// transformed.
206  ///
207  /// Subclasses can provide an alternative implementation of this routine
208  /// to short-circuit evaluation when it is known that a given type will
209  /// not change. For example, template instantiation need not traverse
210  /// non-dependent types.
212  return T.isNull();
213  }
214 
215  /// Determine whether the given call argument should be dropped, e.g.,
216  /// because it is a default argument.
217  ///
218  /// Subclasses can provide an alternative implementation of this routine to
219  /// determine which kinds of call arguments get dropped. By default,
220  /// CXXDefaultArgument nodes are dropped (prior to transformation).
222  return E->isDefaultArgument();
223  }
224 
225  /// Determine whether we should expand a pack expansion with the
226  /// given set of parameter packs into separate arguments by repeatedly
227  /// transforming the pattern.
228  ///
229  /// By default, the transformer never tries to expand pack expansions.
230  /// Subclasses can override this routine to provide different behavior.
231  ///
232  /// \param EllipsisLoc The location of the ellipsis that identifies the
233  /// pack expansion.
234  ///
235  /// \param PatternRange The source range that covers the entire pattern of
236  /// the pack expansion.
237  ///
238  /// \param Unexpanded The set of unexpanded parameter packs within the
239  /// pattern.
240  ///
241  /// \param ShouldExpand Will be set to \c true if the transformer should
242  /// expand the corresponding pack expansions into separate arguments. When
243  /// set, \c NumExpansions must also be set.
244  ///
245  /// \param RetainExpansion Whether the caller should add an unexpanded
246  /// pack expansion after all of the expanded arguments. This is used
247  /// when extending explicitly-specified template argument packs per
248  /// C++0x [temp.arg.explicit]p9.
249  ///
250  /// \param NumExpansions The number of separate arguments that will be in
251  /// the expanded form of the corresponding pack expansion. This is both an
252  /// input and an output parameter, which can be set by the caller if the
253  /// number of expansions is known a priori (e.g., due to a prior substitution)
254  /// and will be set by the callee when the number of expansions is known.
255  /// The callee must set this value when \c ShouldExpand is \c true; it may
256  /// set this value in other cases.
257  ///
258  /// \returns true if an error occurred (e.g., because the parameter packs
259  /// are to be instantiated with arguments of different lengths), false
260  /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
261  /// must be set.
263  SourceRange PatternRange,
265  bool &ShouldExpand,
266  bool &RetainExpansion,
267  Optional<unsigned> &NumExpansions) {
268  ShouldExpand = false;
269  return false;
270  }
271 
272  /// "Forget" about the partially-substituted pack template argument,
273  /// when performing an instantiation that must preserve the parameter pack
274  /// use.
275  ///
276  /// This routine is meant to be overridden by the template instantiator.
278  return TemplateArgument();
279  }
280 
281  /// "Remember" the partially-substituted pack template argument
282  /// after performing an instantiation that must preserve the parameter pack
283  /// use.
284  ///
285  /// This routine is meant to be overridden by the template instantiator.
287 
288  /// Note to the derived class when a function parameter pack is
289  /// being expanded.
291 
292  /// Transforms the given type into another type.
293  ///
294  /// By default, this routine transforms a type by creating a
295  /// TypeSourceInfo for it and delegating to the appropriate
296  /// function. This is expensive, but we don't mind, because
297  /// this method is deprecated anyway; all users should be
298  /// switched to storing TypeSourceInfos.
299  ///
300  /// \returns the transformed type.
301  QualType TransformType(QualType T);
302 
303  /// Transforms the given type-with-location into a new
304  /// type-with-location.
305  ///
306  /// By default, this routine transforms a type by delegating to the
307  /// appropriate TransformXXXType to build a new type. Subclasses
308  /// may override this function (to take over all type
309  /// transformations) or some set of the TransformXXXType functions
310  /// to alter the transformation.
311  TypeSourceInfo *TransformType(TypeSourceInfo *DI);
312 
313  /// Transform the given type-with-location into a new
314  /// type, collecting location information in the given builder
315  /// as necessary.
316  ///
317  QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL);
318 
319  /// Transform a type that is permitted to produce a
320  /// DeducedTemplateSpecializationType.
321  ///
322  /// This is used in the (relatively rare) contexts where it is acceptable
323  /// for transformation to produce a class template type with deduced
324  /// template arguments.
325  /// @{
326  QualType TransformTypeWithDeducedTST(QualType T);
327  TypeSourceInfo *TransformTypeWithDeducedTST(TypeSourceInfo *DI);
328  /// @}
329 
330  /// The reason why the value of a statement is not discarded, if any.
335  };
336 
337  /// Transform the given statement.
338  ///
339  /// By default, this routine transforms a statement by delegating to the
340  /// appropriate TransformXXXStmt function to transform a specific kind of
341  /// statement or the TransformExpr() function to transform an expression.
342  /// Subclasses may override this function to transform statements using some
343  /// other mechanism.
344  ///
345  /// \returns the transformed statement.
346  StmtResult TransformStmt(Stmt *S, StmtDiscardKind SDK = SDK_Discarded);
347 
348  /// Transform the given statement.
349  ///
350  /// By default, this routine transforms a statement by delegating to the
351  /// appropriate TransformOMPXXXClause function to transform a specific kind
352  /// of clause. Subclasses may override this function to transform statements
353  /// using some other mechanism.
354  ///
355  /// \returns the transformed OpenMP clause.
356  OMPClause *TransformOMPClause(OMPClause *S);
357 
358  /// Transform the given attribute.
359  ///
360  /// By default, this routine transforms a statement by delegating to the
361  /// appropriate TransformXXXAttr function to transform a specific kind
362  /// of attribute. Subclasses may override this function to transform
363  /// attributed statements using some other mechanism.
364  ///
365  /// \returns the transformed attribute
366  const Attr *TransformAttr(const Attr *S);
367 
368 /// Transform the specified attribute.
369 ///
370 /// Subclasses should override the transformation of attributes with a pragma
371 /// spelling to transform expressions stored within the attribute.
372 ///
373 /// \returns the transformed attribute.
374 #define ATTR(X)
375 #define PRAGMA_SPELLING_ATTR(X) \
376  const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; }
377 #include "clang/Basic/AttrList.inc"
378 
379  /// Transform the given expression.
380  ///
381  /// By default, this routine transforms an expression by delegating to the
382  /// appropriate TransformXXXExpr function to build a new expression.
383  /// Subclasses may override this function to transform expressions using some
384  /// other mechanism.
385  ///
386  /// \returns the transformed expression.
387  ExprResult TransformExpr(Expr *E);
388 
389  /// Transform the given initializer.
390  ///
391  /// By default, this routine transforms an initializer by stripping off the
392  /// semantic nodes added by initialization, then passing the result to
393  /// TransformExpr or TransformExprs.
394  ///
395  /// \returns the transformed initializer.
396  ExprResult TransformInitializer(Expr *Init, bool NotCopyInit);
397 
398  /// Transform the given list of expressions.
399  ///
400  /// This routine transforms a list of expressions by invoking
401  /// \c TransformExpr() for each subexpression. However, it also provides
402  /// support for variadic templates by expanding any pack expansions (if the
403  /// derived class permits such expansion) along the way. When pack expansions
404  /// are present, the number of outputs may not equal the number of inputs.
405  ///
406  /// \param Inputs The set of expressions to be transformed.
407  ///
408  /// \param NumInputs The number of expressions in \c Inputs.
409  ///
410  /// \param IsCall If \c true, then this transform is being performed on
411  /// function-call arguments, and any arguments that should be dropped, will
412  /// be.
413  ///
414  /// \param Outputs The transformed input expressions will be added to this
415  /// vector.
416  ///
417  /// \param ArgChanged If non-NULL, will be set \c true if any argument changed
418  /// due to transformation.
419  ///
420  /// \returns true if an error occurred, false otherwise.
421  bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall,
422  SmallVectorImpl<Expr *> &Outputs,
423  bool *ArgChanged = nullptr);
424 
425  /// Transform the given declaration, which is referenced from a type
426  /// or expression.
427  ///
428  /// By default, acts as the identity function on declarations, unless the
429  /// transformer has had to transform the declaration itself. Subclasses
430  /// may override this function to provide alternate behavior.
432  llvm::DenseMap<Decl *, Decl *>::iterator Known
433  = TransformedLocalDecls.find(D);
434  if (Known != TransformedLocalDecls.end())
435  return Known->second;
436 
437  return D;
438  }
439 
440  /// Transform the specified condition.
441  ///
442  /// By default, this transforms the variable and expression and rebuilds
443  /// the condition.
444  Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var,
445  Expr *Expr,
447 
448  /// Transform the attributes associated with the given declaration and
449  /// place them on the new declaration.
450  ///
451  /// By default, this operation does nothing. Subclasses may override this
452  /// behavior to transform attributes.
453  void transformAttrs(Decl *Old, Decl *New) { }
454 
455  /// Note that a local declaration has been transformed by this
456  /// transformer.
457  ///
458  /// Local declarations are typically transformed via a call to
459  /// TransformDefinition. However, in some cases (e.g., lambda expressions),
460  /// the transformer itself has to transform the declarations. This routine
461  /// can be overridden by a subclass that keeps track of such mappings.
463  assert(New.size() == 1 &&
464  "must override transformedLocalDecl if performing pack expansion");
465  TransformedLocalDecls[Old] = New.front();
466  }
467 
468  /// Transform the definition of the given declaration.
469  ///
470  /// By default, invokes TransformDecl() to transform the declaration.
471  /// Subclasses may override this function to provide alternate behavior.
473  return getDerived().TransformDecl(Loc, D);
474  }
475 
476  /// Transform the given declaration, which was the first part of a
477  /// nested-name-specifier in a member access expression.
478  ///
479  /// This specific declaration transformation only applies to the first
480  /// identifier in a nested-name-specifier of a member access expression, e.g.,
481  /// the \c T in \c x->T::member
482  ///
483  /// By default, invokes TransformDecl() to transform the declaration.
484  /// Subclasses may override this function to provide alternate behavior.
486  return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D));
487  }
488 
489  /// Transform the set of declarations in an OverloadExpr.
490  bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL,
491  LookupResult &R);
492 
493  /// Transform the given nested-name-specifier with source-location
494  /// information.
495  ///
496  /// By default, transforms all of the types and declarations within the
497  /// nested-name-specifier. Subclasses may override this function to provide
498  /// alternate behavior.
500  TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
501  QualType ObjectType = QualType(),
502  NamedDecl *FirstQualifierInScope = nullptr);
503 
504  /// Transform the given declaration name.
505  ///
506  /// By default, transforms the types of conversion function, constructor,
507  /// and destructor names and then (if needed) rebuilds the declaration name.
508  /// Identifiers and selectors are returned unmodified. Sublcasses may
509  /// override this function to provide alternate behavior.
511  TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo);
512 
513  bool TransformRequiresExprRequirements(ArrayRef<concepts::Requirement *> Reqs,
516  TransformTypeRequirement(concepts::TypeRequirement *Req);
518  TransformExprRequirement(concepts::ExprRequirement *Req);
520  TransformNestedRequirement(concepts::NestedRequirement *Req);
521 
522  /// Transform the given template name.
523  ///
524  /// \param SS The nested-name-specifier that qualifies the template
525  /// name. This nested-name-specifier must already have been transformed.
526  ///
527  /// \param Name The template name to transform.
528  ///
529  /// \param NameLoc The source location of the template name.
530  ///
531  /// \param ObjectType If we're translating a template name within a member
532  /// access expression, this is the type of the object whose member template
533  /// is being referenced.
534  ///
535  /// \param FirstQualifierInScope If the first part of a nested-name-specifier
536  /// also refers to a name within the current (lexical) scope, this is the
537  /// declaration it refers to.
538  ///
539  /// By default, transforms the template name by transforming the declarations
540  /// and nested-name-specifiers that occur within the template name.
541  /// Subclasses may override this function to provide alternate behavior.
543  TransformTemplateName(CXXScopeSpec &SS, TemplateName Name,
544  SourceLocation NameLoc,
545  QualType ObjectType = QualType(),
546  NamedDecl *FirstQualifierInScope = nullptr,
547  bool AllowInjectedClassName = false);
548 
549  /// Transform the given template argument.
550  ///
551  /// By default, this operation transforms the type, expression, or
552  /// declaration stored within the template argument and constructs a
553  /// new template argument from the transformed result. Subclasses may
554  /// override this function to provide alternate behavior.
555  ///
556  /// Returns true if there was an error.
557  bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
558  TemplateArgumentLoc &Output,
559  bool Uneval = false);
560 
561  /// Transform the given set of template arguments.
562  ///
563  /// By default, this operation transforms all of the template arguments
564  /// in the input set using \c TransformTemplateArgument(), and appends
565  /// the transformed arguments to the output list.
566  ///
567  /// Note that this overload of \c TransformTemplateArguments() is merely
568  /// a convenience function. Subclasses that wish to override this behavior
569  /// should override the iterator-based member template version.
570  ///
571  /// \param Inputs The set of template arguments to be transformed.
572  ///
573  /// \param NumInputs The number of template arguments in \p Inputs.
574  ///
575  /// \param Outputs The set of transformed template arguments output by this
576  /// routine.
577  ///
578  /// Returns true if an error occurred.
580  unsigned NumInputs,
581  TemplateArgumentListInfo &Outputs,
582  bool Uneval = false) {
583  return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs,
584  Uneval);
585  }
586 
587  /// Transform the given set of template arguments.
588  ///
589  /// By default, this operation transforms all of the template arguments
590  /// in the input set using \c TransformTemplateArgument(), and appends
591  /// the transformed arguments to the output list.
592  ///
593  /// \param First An iterator to the first template argument.
594  ///
595  /// \param Last An iterator one step past the last template argument.
596  ///
597  /// \param Outputs The set of transformed template arguments output by this
598  /// routine.
599  ///
600  /// Returns true if an error occurred.
601  template<typename InputIterator>
602  bool TransformTemplateArguments(InputIterator First,
603  InputIterator Last,
604  TemplateArgumentListInfo &Outputs,
605  bool Uneval = false);
606 
607  /// Fakes up a TemplateArgumentLoc for a given TemplateArgument.
608  void InventTemplateArgumentLoc(const TemplateArgument &Arg,
609  TemplateArgumentLoc &ArgLoc);
610 
611  /// Fakes up a TypeSourceInfo for a type.
613  return SemaRef.Context.getTrivialTypeSourceInfo(T,
614  getDerived().getBaseLocation());
615  }
616 
617 #define ABSTRACT_TYPELOC(CLASS, PARENT)
618 #define TYPELOC(CLASS, PARENT) \
619  QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
620 #include "clang/AST/TypeLocNodes.def"
621 
622  template<typename Fn>
623  QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
624  FunctionProtoTypeLoc TL,
625  CXXRecordDecl *ThisContext,
626  Qualifiers ThisTypeQuals,
627  Fn TransformExceptionSpec);
628 
629  bool TransformExceptionSpec(SourceLocation Loc,
630  FunctionProtoType::ExceptionSpecInfo &ESI,
631  SmallVectorImpl<QualType> &Exceptions,
632  bool &Changed);
633 
634  StmtResult TransformSEHHandler(Stmt *Handler);
635 
636  QualType
637  TransformTemplateSpecializationType(TypeLocBuilder &TLB,
638  TemplateSpecializationTypeLoc TL,
639  TemplateName Template);
640 
641  QualType
642  TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB,
643  DependentTemplateSpecializationTypeLoc TL,
644  TemplateName Template,
645  CXXScopeSpec &SS);
646 
647  QualType TransformDependentTemplateSpecializationType(
648  TypeLocBuilder &TLB, DependentTemplateSpecializationTypeLoc TL,
649  NestedNameSpecifierLoc QualifierLoc);
650 
651  /// Transforms the parameters of a function type into the
652  /// given vectors.
653  ///
654  /// The result vectors should be kept in sync; null entries in the
655  /// variables vector are acceptable.
656  ///
657  /// Return true on error.
658  bool TransformFunctionTypeParams(
659  SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
660  const QualType *ParamTypes,
661  const FunctionProtoType::ExtParameterInfo *ParamInfos,
662  SmallVectorImpl<QualType> &PTypes, SmallVectorImpl<ParmVarDecl *> *PVars,
663  Sema::ExtParameterInfoBuilder &PInfos);
664 
665  /// Transforms a single function-type parameter. Return null
666  /// on error.
667  ///
668  /// \param indexAdjustment - A number to add to the parameter's
669  /// scope index; can be negative
670  ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
671  int indexAdjustment,
672  Optional<unsigned> NumExpansions,
673  bool ExpectParameterPack);
674 
675  /// Transform the body of a lambda-expression.
676  StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body);
677  /// Alternative implementation of TransformLambdaBody that skips transforming
678  /// the body.
679  StmtResult SkipLambdaBody(LambdaExpr *E, Stmt *Body);
680 
681  QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL);
682 
683  StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr);
684  ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E);
685 
687  TemplateParameterList *TPL) {
688  return TPL;
689  }
690 
691  ExprResult TransformAddressOfOperand(Expr *E);
692 
693  ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E,
694  bool IsAddressOfOperand,
695  TypeSourceInfo **RecoveryTSI);
696 
697  ExprResult TransformParenDependentScopeDeclRefExpr(
698  ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
699  TypeSourceInfo **RecoveryTSI);
700 
701  StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S);
702 
703 // FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
704 // amount of stack usage with clang.
705 #define STMT(Node, Parent) \
706  LLVM_ATTRIBUTE_NOINLINE \
707  StmtResult Transform##Node(Node *S);
708 #define VALUESTMT(Node, Parent) \
709  LLVM_ATTRIBUTE_NOINLINE \
710  StmtResult Transform##Node(Node *S, StmtDiscardKind SDK);
711 #define EXPR(Node, Parent) \
712  LLVM_ATTRIBUTE_NOINLINE \
713  ExprResult Transform##Node(Node *E);
714 #define ABSTRACT_STMT(Stmt)
715 #include "clang/AST/StmtNodes.inc"
716 
717 #define OPENMP_CLAUSE(Name, Class) \
718  LLVM_ATTRIBUTE_NOINLINE \
719  OMPClause *Transform ## Class(Class *S);
720 #include "clang/Basic/OpenMPKinds.def"
721 
722  /// Build a new qualified type given its unqualified type and type location.
723  ///
724  /// By default, this routine adds type qualifiers only to types that can
725  /// have qualifiers, and silently suppresses those qualifiers that are not
726  /// permitted. Subclasses may override this routine to provide different
727  /// behavior.
728  QualType RebuildQualifiedType(QualType T, QualifiedTypeLoc TL);
729 
730  /// Build a new pointer type given its pointee type.
731  ///
732  /// By default, performs semantic analysis when building the pointer type.
733  /// Subclasses may override this routine to provide different behavior.
734  QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil);
735 
736  /// Build a new block pointer type given its pointee type.
737  ///
738  /// By default, performs semantic analysis when building the block pointer
739  /// type. Subclasses may override this routine to provide different behavior.
740  QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil);
741 
742  /// Build a new reference type given the type it references.
743  ///
744  /// By default, performs semantic analysis when building the
745  /// reference type. Subclasses may override this routine to provide
746  /// different behavior.
747  ///
748  /// \param LValue whether the type was written with an lvalue sigil
749  /// or an rvalue sigil.
750  QualType RebuildReferenceType(QualType ReferentType,
751  bool LValue,
752  SourceLocation Sigil);
753 
754  /// Build a new member pointer type given the pointee type and the
755  /// class type it refers into.
756  ///
757  /// By default, performs semantic analysis when building the member pointer
758  /// type. Subclasses may override this routine to provide different behavior.
759  QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType,
760  SourceLocation Sigil);
761 
762  QualType RebuildObjCTypeParamType(const ObjCTypeParamDecl *Decl,
763  SourceLocation ProtocolLAngleLoc,
764  ArrayRef<ObjCProtocolDecl *> Protocols,
765  ArrayRef<SourceLocation> ProtocolLocs,
766  SourceLocation ProtocolRAngleLoc);
767 
768  /// Build an Objective-C object type.
769  ///
770  /// By default, performs semantic analysis when building the object type.
771  /// Subclasses may override this routine to provide different behavior.
772  QualType RebuildObjCObjectType(QualType BaseType,
773  SourceLocation Loc,
774  SourceLocation TypeArgsLAngleLoc,
775  ArrayRef<TypeSourceInfo *> TypeArgs,
776  SourceLocation TypeArgsRAngleLoc,
777  SourceLocation ProtocolLAngleLoc,
778  ArrayRef<ObjCProtocolDecl *> Protocols,
779  ArrayRef<SourceLocation> ProtocolLocs,
780  SourceLocation ProtocolRAngleLoc);
781 
782  /// Build a new Objective-C object pointer type given the pointee type.
783  ///
784  /// By default, directly builds the pointer type, with no additional semantic
785  /// analysis.
786  QualType RebuildObjCObjectPointerType(QualType PointeeType,
787  SourceLocation Star);
788 
789  /// Build a new array type given the element type, size
790  /// modifier, size of the array (if known), size expression, and index type
791  /// qualifiers.
792  ///
793  /// By default, performs semantic analysis when building the array type.
794  /// Subclasses may override this routine to provide different behavior.
795  /// Also by default, all of the other Rebuild*Array
796  QualType RebuildArrayType(QualType ElementType,
797  ArrayType::ArraySizeModifier SizeMod,
798  const llvm::APInt *Size,
799  Expr *SizeExpr,
800  unsigned IndexTypeQuals,
801  SourceRange BracketsRange);
802 
803  /// Build a new constant array type given the element type, size
804  /// modifier, (known) size of the array, and index type qualifiers.
805  ///
806  /// By default, performs semantic analysis when building the array type.
807  /// Subclasses may override this routine to provide different behavior.
808  QualType RebuildConstantArrayType(QualType ElementType,
809  ArrayType::ArraySizeModifier SizeMod,
810  const llvm::APInt &Size,
811  Expr *SizeExpr,
812  unsigned IndexTypeQuals,
813  SourceRange BracketsRange);
814 
815  /// Build a new incomplete array type given the element type, size
816  /// modifier, and index type qualifiers.
817  ///
818  /// By default, performs semantic analysis when building the array type.
819  /// Subclasses may override this routine to provide different behavior.
820  QualType RebuildIncompleteArrayType(QualType ElementType,
821  ArrayType::ArraySizeModifier SizeMod,
822  unsigned IndexTypeQuals,
823  SourceRange BracketsRange);
824 
825  /// Build a new variable-length array type given the element type,
826  /// size modifier, size expression, and index type qualifiers.
827  ///
828  /// By default, performs semantic analysis when building the array type.
829  /// Subclasses may override this routine to provide different behavior.
830  QualType RebuildVariableArrayType(QualType ElementType,
831  ArrayType::ArraySizeModifier SizeMod,
832  Expr *SizeExpr,
833  unsigned IndexTypeQuals,
834  SourceRange BracketsRange);
835 
836  /// Build a new dependent-sized array type given the element type,
837  /// size modifier, size expression, and index type qualifiers.
838  ///
839  /// By default, performs semantic analysis when building the array type.
840  /// Subclasses may override this routine to provide different behavior.
841  QualType RebuildDependentSizedArrayType(QualType ElementType,
842  ArrayType::ArraySizeModifier SizeMod,
843  Expr *SizeExpr,
844  unsigned IndexTypeQuals,
845  SourceRange BracketsRange);
846 
847  /// Build a new vector type given the element type and
848  /// number of elements.
849  ///
850  /// By default, performs semantic analysis when building the vector type.
851  /// Subclasses may override this routine to provide different behavior.
852  QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
853  VectorType::VectorKind VecKind);
854 
855  /// Build a new potentially dependently-sized extended vector type
856  /// given the element type and number of elements.
857  ///
858  /// By default, performs semantic analysis when building the vector type.
859  /// Subclasses may override this routine to provide different behavior.
860  QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr,
861  SourceLocation AttributeLoc,
862  VectorType::VectorKind);
863 
864  /// Build a new extended vector type given the element type and
865  /// number of elements.
866  ///
867  /// By default, performs semantic analysis when building the vector type.
868  /// Subclasses may override this routine to provide different behavior.
869  QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
870  SourceLocation AttributeLoc);
871 
872  /// Build a new potentially dependently-sized extended vector type
873  /// given the element type and number of elements.
874  ///
875  /// By default, performs semantic analysis when building the vector type.
876  /// Subclasses may override this routine to provide different behavior.
877  QualType RebuildDependentSizedExtVectorType(QualType ElementType,
878  Expr *SizeExpr,
879  SourceLocation AttributeLoc);
880 
881  /// Build a new DependentAddressSpaceType or return the pointee
882  /// type variable with the correct address space (retrieved from
883  /// AddrSpaceExpr) applied to it. The former will be returned in cases
884  /// where the address space remains dependent.
885  ///
886  /// By default, performs semantic analysis when building the type with address
887  /// space applied. Subclasses may override this routine to provide different
888  /// behavior.
889  QualType RebuildDependentAddressSpaceType(QualType PointeeType,
890  Expr *AddrSpaceExpr,
891  SourceLocation AttributeLoc);
892 
893  /// Build a new function type.
894  ///
895  /// By default, performs semantic analysis when building the function type.
896  /// Subclasses may override this routine to provide different behavior.
897  QualType RebuildFunctionProtoType(QualType T,
898  MutableArrayRef<QualType> ParamTypes,
899  const FunctionProtoType::ExtProtoInfo &EPI);
900 
901  /// Build a new unprototyped function type.
902  QualType RebuildFunctionNoProtoType(QualType ResultType);
903 
904  /// Rebuild an unresolved typename type, given the decl that
905  /// the UnresolvedUsingTypenameDecl was transformed to.
906  QualType RebuildUnresolvedUsingType(SourceLocation NameLoc, Decl *D);
907 
908  /// Build a new typedef type.
910  return SemaRef.Context.getTypeDeclType(Typedef);
911  }
912 
913  /// Build a new MacroDefined type.
915  const IdentifierInfo *MacroII) {
916  return SemaRef.Context.getMacroQualifiedType(T, MacroII);
917  }
918 
919  /// Build a new class/struct/union type.
921  return SemaRef.Context.getTypeDeclType(Record);
922  }
923 
924  /// Build a new Enum type.
926  return SemaRef.Context.getTypeDeclType(Enum);
927  }
928 
929  /// Build a new typeof(expr) type.
930  ///
931  /// By default, performs semantic analysis when building the typeof type.
932  /// Subclasses may override this routine to provide different behavior.
933  QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc);
934 
935  /// Build a new typeof(type) type.
936  ///
937  /// By default, builds a new TypeOfType with the given underlying type.
938  QualType RebuildTypeOfType(QualType Underlying);
939 
940  /// Build a new unary transform type.
941  QualType RebuildUnaryTransformType(QualType BaseType,
943  SourceLocation Loc);
944 
945  /// Build a new C++11 decltype type.
946  ///
947  /// By default, performs semantic analysis when building the decltype type.
948  /// Subclasses may override this routine to provide different behavior.
949  QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc);
950 
951  /// Build a new C++11 auto type.
952  ///
953  /// By default, builds a new AutoType with the given deduced type.
955  ConceptDecl *TypeConstraintConcept,
956  ArrayRef<TemplateArgument> TypeConstraintArgs) {
957  // Note, IsDependent is always false here: we implicitly convert an 'auto'
958  // which has been deduced to a dependent type into an undeduced 'auto', so
959  // that we'll retry deduction after the transformation.
960  return SemaRef.Context.getAutoType(Deduced, Keyword,
961  /*IsDependent*/ false, /*IsPack=*/false,
962  TypeConstraintConcept,
963  TypeConstraintArgs);
964  }
965 
966  /// By default, builds a new DeducedTemplateSpecializationType with the given
967  /// deduced type.
969  QualType Deduced) {
971  Template, Deduced, /*IsDependent*/ false);
972  }
973 
974  /// Build a new template specialization type.
975  ///
976  /// By default, performs semantic analysis when building the template
977  /// specialization type. Subclasses may override this routine to provide
978  /// different behavior.
979  QualType RebuildTemplateSpecializationType(TemplateName Template,
980  SourceLocation TemplateLoc,
982 
983  /// Build a new parenthesized type.
984  ///
985  /// By default, builds a new ParenType type from the inner type.
986  /// Subclasses may override this routine to provide different behavior.
988  return SemaRef.BuildParenType(InnerType);
989  }
990 
991  /// Build a new qualified name type.
992  ///
993  /// By default, builds a new ElaboratedType type from the keyword,
994  /// the nested-name-specifier and the named type.
995  /// Subclasses may override this routine to provide different behavior.
997  ElaboratedTypeKeyword Keyword,
998  NestedNameSpecifierLoc QualifierLoc,
999  QualType Named) {
1000  return SemaRef.Context.getElaboratedType(Keyword,
1001  QualifierLoc.getNestedNameSpecifier(),
1002  Named);
1003  }
1004 
1005  /// Build a new typename type that refers to a template-id.
1006  ///
1007  /// By default, builds a new DependentNameType type from the
1008  /// nested-name-specifier and the given type. Subclasses may override
1009  /// this routine to provide different behavior.
1011  ElaboratedTypeKeyword Keyword,
1012  NestedNameSpecifierLoc QualifierLoc,
1013  SourceLocation TemplateKWLoc,
1014  const IdentifierInfo *Name,
1015  SourceLocation NameLoc,
1017  bool AllowInjectedClassName) {
1018  // Rebuild the template name.
1019  // TODO: avoid TemplateName abstraction
1020  CXXScopeSpec SS;
1021  SS.Adopt(QualifierLoc);
1022  TemplateName InstName = getDerived().RebuildTemplateName(
1023  SS, TemplateKWLoc, *Name, NameLoc, QualType(), nullptr,
1024  AllowInjectedClassName);
1025 
1026  if (InstName.isNull())
1027  return QualType();
1028 
1029  // If it's still dependent, make a dependent specialization.
1030  if (InstName.getAsDependentTemplateName())
1031  return SemaRef.Context.getDependentTemplateSpecializationType(Keyword,
1032  QualifierLoc.getNestedNameSpecifier(),
1033  Name,
1034  Args);
1035 
1036  // Otherwise, make an elaborated type wrapping a non-dependent
1037  // specialization.
1038  QualType T =
1039  getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args);
1040  if (T.isNull()) return QualType();
1041 
1042  if (Keyword == ETK_None && QualifierLoc.getNestedNameSpecifier() == nullptr)
1043  return T;
1044 
1045  return SemaRef.Context.getElaboratedType(Keyword,
1046  QualifierLoc.getNestedNameSpecifier(),
1047  T);
1048  }
1049 
1050  /// Build a new typename type that refers to an identifier.
1051  ///
1052  /// By default, performs semantic analysis when building the typename type
1053  /// (or elaborated type). Subclasses may override this routine to provide
1054  /// different behavior.
1056  SourceLocation KeywordLoc,
1057  NestedNameSpecifierLoc QualifierLoc,
1058  const IdentifierInfo *Id,
1059  SourceLocation IdLoc,
1060  bool DeducedTSTContext) {
1061  CXXScopeSpec SS;
1062  SS.Adopt(QualifierLoc);
1063 
1064  if (QualifierLoc.getNestedNameSpecifier()->isDependent()) {
1065  // If the name is still dependent, just build a new dependent name type.
1066  if (!SemaRef.computeDeclContext(SS))
1067  return SemaRef.Context.getDependentNameType(Keyword,
1068  QualifierLoc.getNestedNameSpecifier(),
1069  Id);
1070  }
1071 
1072  if (Keyword == ETK_None || Keyword == ETK_Typename) {
1073  return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1074  *Id, IdLoc, DeducedTSTContext);
1075  }
1076 
1077  TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForKeyword(Keyword);
1078 
1079  // We had a dependent elaborated-type-specifier that has been transformed
1080  // into a non-dependent elaborated-type-specifier. Find the tag we're
1081  // referring to.
1082  LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
1083  DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1084  if (!DC)
1085  return QualType();
1086 
1087  if (SemaRef.RequireCompleteDeclContext(SS, DC))
1088  return QualType();
1089 
1090  TagDecl *Tag = nullptr;
1091  SemaRef.LookupQualifiedName(Result, DC);
1092  switch (Result.getResultKind()) {
1093  case LookupResult::NotFound:
1094  case LookupResult::NotFoundInCurrentInstantiation:
1095  break;
1096 
1097  case LookupResult::Found:
1098  Tag = Result.getAsSingle<TagDecl>();
1099  break;
1100 
1101  case LookupResult::FoundOverloaded:
1102  case LookupResult::FoundUnresolvedValue:
1103  llvm_unreachable("Tag lookup cannot find non-tags");
1104 
1105  case LookupResult::Ambiguous:
1106  // Let the LookupResult structure handle ambiguities.
1107  return QualType();
1108  }
1109 
1110  if (!Tag) {
1111  // Check where the name exists but isn't a tag type and use that to emit
1112  // better diagnostics.
1113  LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
1114  SemaRef.LookupQualifiedName(Result, DC);
1115  switch (Result.getResultKind()) {
1116  case LookupResult::Found:
1117  case LookupResult::FoundOverloaded:
1118  case LookupResult::FoundUnresolvedValue: {
1119  NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1120  Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1121  SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << SomeDecl
1122  << NTK << Kind;
1123  SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1124  break;
1125  }
1126  default:
1127  SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1128  << Kind << Id << DC << QualifierLoc.getSourceRange();
1129  break;
1130  }
1131  return QualType();
1132  }
1133 
1134  if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1135  IdLoc, Id)) {
1136  SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1137  SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1138  return QualType();
1139  }
1140 
1141  // Build the elaborated-type-specifier type.
1142  QualType T = SemaRef.Context.getTypeDeclType(Tag);
1143  return SemaRef.Context.getElaboratedType(Keyword,
1144  QualifierLoc.getNestedNameSpecifier(),
1145  T);
1146  }
1147 
1148  /// Build a new pack expansion type.
1149  ///
1150  /// By default, builds a new PackExpansionType type from the given pattern.
1151  /// Subclasses may override this routine to provide different behavior.
1153  SourceRange PatternRange,
1154  SourceLocation EllipsisLoc,
1155  Optional<unsigned> NumExpansions) {
1156  return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1157  NumExpansions);
1158  }
1159 
1160  /// Build a new atomic type given its value type.
1161  ///
1162  /// By default, performs semantic analysis when building the atomic type.
1163  /// Subclasses may override this routine to provide different behavior.
1164  QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc);
1165 
1166  /// Build a new pipe type given its value type.
1167  QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc,
1168  bool isReadPipe);
1169 
1170  /// Build a new template name given a nested name specifier, a flag
1171  /// indicating whether the "template" keyword was provided, and the template
1172  /// that the template name refers to.
1173  ///
1174  /// By default, builds the new template name directly. Subclasses may override
1175  /// this routine to provide different behavior.
1176  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1177  bool TemplateKW,
1178  TemplateDecl *Template);
1179 
1180  /// Build a new template name given a nested name specifier and the
1181  /// name that is referred to as a template.
1182  ///
1183  /// By default, performs semantic analysis to determine whether the name can
1184  /// be resolved to a specific template, then builds the appropriate kind of
1185  /// template name. Subclasses may override this routine to provide different
1186  /// behavior.
1187  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1188  SourceLocation TemplateKWLoc,
1189  const IdentifierInfo &Name,
1190  SourceLocation NameLoc, QualType ObjectType,
1191  NamedDecl *FirstQualifierInScope,
1192  bool AllowInjectedClassName);
1193 
1194  /// Build a new template name given a nested name specifier and the
1195  /// overloaded operator name that is referred to as a template.
1196  ///
1197  /// By default, performs semantic analysis to determine whether the name can
1198  /// be resolved to a specific template, then builds the appropriate kind of
1199  /// template name. Subclasses may override this routine to provide different
1200  /// behavior.
1201  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1202  SourceLocation TemplateKWLoc,
1203  OverloadedOperatorKind Operator,
1204  SourceLocation NameLoc, QualType ObjectType,
1205  bool AllowInjectedClassName);
1206 
1207  /// Build a new template name given a template template parameter pack
1208  /// and the
1209  ///
1210  /// By default, performs semantic analysis to determine whether the name can
1211  /// be resolved to a specific template, then builds the appropriate kind of
1212  /// template name. Subclasses may override this routine to provide different
1213  /// behavior.
1215  const TemplateArgument &ArgPack) {
1216  return getSema().Context.getSubstTemplateTemplateParmPack(Param, ArgPack);
1217  }
1218 
1219  /// Build a new compound statement.
1220  ///
1221  /// By default, performs semantic analysis to build the new statement.
1222  /// Subclasses may override this routine to provide different behavior.
1224  MultiStmtArg Statements,
1225  SourceLocation RBraceLoc,
1226  bool IsStmtExpr) {
1227  return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1228  IsStmtExpr);
1229  }
1230 
1231  /// Build a new case statement.
1232  ///
1233  /// By default, performs semantic analysis to build the new statement.
1234  /// Subclasses may override this routine to provide different behavior.
1236  Expr *LHS,
1237  SourceLocation EllipsisLoc,
1238  Expr *RHS,
1240  return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1241  ColonLoc);
1242  }
1243 
1244  /// Attach the body to a new case statement.
1245  ///
1246  /// By default, performs semantic analysis to build the new statement.
1247  /// Subclasses may override this routine to provide different behavior.
1249  getSema().ActOnCaseStmtBody(S, Body);
1250  return S;
1251  }
1252 
1253  /// Build a new default statement.
1254  ///
1255  /// By default, performs semantic analysis to build the new statement.
1256  /// Subclasses may override this routine to provide different behavior.
1259  Stmt *SubStmt) {
1260  return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1261  /*CurScope=*/nullptr);
1262  }
1263 
1264  /// Build a new label statement.
1265  ///
1266  /// By default, performs semantic analysis to build the new statement.
1267  /// Subclasses may override this routine to provide different behavior.
1269  SourceLocation ColonLoc, Stmt *SubStmt) {
1270  return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1271  }
1272 
1273  /// Build a new label statement.
1274  ///
1275  /// By default, performs semantic analysis to build the new statement.
1276  /// Subclasses may override this routine to provide different behavior.
1278  ArrayRef<const Attr*> Attrs,
1279  Stmt *SubStmt) {
1280  return SemaRef.ActOnAttributedStmt(AttrLoc, Attrs, SubStmt);
1281  }
1282 
1283  /// Build a new "if" statement.
1284  ///
1285  /// By default, performs semantic analysis to build the new statement.
1286  /// Subclasses may override this routine to provide different behavior.
1287  StmtResult RebuildIfStmt(SourceLocation IfLoc, bool IsConstexpr,
1288  Sema::ConditionResult Cond, Stmt *Init, Stmt *Then,
1289  SourceLocation ElseLoc, Stmt *Else) {
1290  return getSema().ActOnIfStmt(IfLoc, IsConstexpr, Init, Cond, Then,
1291  ElseLoc, Else);
1292  }
1293 
1294  /// Start building a new switch statement.
1295  ///
1296  /// By default, performs semantic analysis to build the new statement.
1297  /// Subclasses may override this routine to provide different behavior.
1299  Sema::ConditionResult Cond) {
1300  return getSema().ActOnStartOfSwitchStmt(SwitchLoc, Init, Cond);
1301  }
1302 
1303  /// Attach the body to the switch statement.
1304  ///
1305  /// By default, performs semantic analysis to build the new statement.
1306  /// Subclasses may override this routine to provide different behavior.
1308  Stmt *Switch, Stmt *Body) {
1309  return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1310  }
1311 
1312  /// Build a new while statement.
1313  ///
1314  /// By default, performs semantic analysis to build the new statement.
1315  /// Subclasses may override this routine to provide different behavior.
1317  Sema::ConditionResult Cond, Stmt *Body) {
1318  return getSema().ActOnWhileStmt(WhileLoc, Cond, Body);
1319  }
1320 
1321  /// Build a new do-while statement.
1322  ///
1323  /// By default, performs semantic analysis to build the new statement.
1324  /// Subclasses may override this routine to provide different behavior.
1326  SourceLocation WhileLoc, SourceLocation LParenLoc,
1327  Expr *Cond, SourceLocation RParenLoc) {
1328  return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1329  Cond, RParenLoc);
1330  }
1331 
1332  /// Build a new for statement.
1333  ///
1334  /// By default, performs semantic analysis to build the new statement.
1335  /// Subclasses may override this routine to provide different behavior.
1337  Stmt *Init, Sema::ConditionResult Cond,
1338  Sema::FullExprArg Inc, SourceLocation RParenLoc,
1339  Stmt *Body) {
1340  return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1341  Inc, RParenLoc, Body);
1342  }
1343 
1344  /// Build a new goto statement.
1345  ///
1346  /// By default, performs semantic analysis to build the new statement.
1347  /// Subclasses may override this routine to provide different behavior.
1349  LabelDecl *Label) {
1350  return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1351  }
1352 
1353  /// Build a new indirect goto statement.
1354  ///
1355  /// By default, performs semantic analysis to build the new statement.
1356  /// Subclasses may override this routine to provide different behavior.
1358  SourceLocation StarLoc,
1359  Expr *Target) {
1360  return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1361  }
1362 
1363  /// Build a new return statement.
1364  ///
1365  /// By default, performs semantic analysis to build the new statement.
1366  /// Subclasses may override this routine to provide different behavior.
1368  return getSema().BuildReturnStmt(ReturnLoc, Result);
1369  }
1370 
1371  /// Build a new declaration statement.
1372  ///
1373  /// By default, performs semantic analysis to build the new statement.
1374  /// Subclasses may override this routine to provide different behavior.
1376  SourceLocation StartLoc, SourceLocation EndLoc) {
1377  Sema::DeclGroupPtrTy DG = getSema().BuildDeclaratorGroup(Decls);
1378  return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1379  }
1380 
1381  /// Build a new inline asm statement.
1382  ///
1383  /// By default, performs semantic analysis to build the new statement.
1384  /// Subclasses may override this routine to provide different behavior.
1386  bool IsVolatile, unsigned NumOutputs,
1387  unsigned NumInputs, IdentifierInfo **Names,
1388  MultiExprArg Constraints, MultiExprArg Exprs,
1389  Expr *AsmString, MultiExprArg Clobbers,
1390  unsigned NumLabels,
1391  SourceLocation RParenLoc) {
1392  return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1393  NumInputs, Names, Constraints, Exprs,
1394  AsmString, Clobbers, NumLabels, RParenLoc);
1395  }
1396 
1397  /// Build a new MS style inline asm statement.
1398  ///
1399  /// By default, performs semantic analysis to build the new statement.
1400  /// Subclasses may override this routine to provide different behavior.
1402  ArrayRef<Token> AsmToks,
1403  StringRef AsmString,
1404  unsigned NumOutputs, unsigned NumInputs,
1405  ArrayRef<StringRef> Constraints,
1406  ArrayRef<StringRef> Clobbers,
1407  ArrayRef<Expr*> Exprs,
1408  SourceLocation EndLoc) {
1409  return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1410  NumOutputs, NumInputs,
1411  Constraints, Clobbers, Exprs, EndLoc);
1412  }
1413 
1414  /// Build a new co_return statement.
1415  ///
1416  /// By default, performs semantic analysis to build the new statement.
1417  /// Subclasses may override this routine to provide different behavior.
1419  bool IsImplicit) {
1420  return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1421  }
1422 
1423  /// Build a new co_await expression.
1424  ///
1425  /// By default, performs semantic analysis to build the new expression.
1426  /// Subclasses may override this routine to provide different behavior.
1428  bool IsImplicit) {
1429  return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Result, IsImplicit);
1430  }
1431 
1432  /// Build a new co_await expression.
1433  ///
1434  /// By default, performs semantic analysis to build the new expression.
1435  /// Subclasses may override this routine to provide different behavior.
1437  Expr *Result,
1438  UnresolvedLookupExpr *Lookup) {
1439  return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1440  }
1441 
1442  /// Build a new co_yield expression.
1443  ///
1444  /// By default, performs semantic analysis to build the new expression.
1445  /// Subclasses may override this routine to provide different behavior.
1447  return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1448  }
1449 
1451  return getSema().BuildCoroutineBodyStmt(Args);
1452  }
1453 
1454  /// Build a new Objective-C \@try statement.
1455  ///
1456  /// By default, performs semantic analysis to build the new statement.
1457  /// Subclasses may override this routine to provide different behavior.
1459  Stmt *TryBody,
1460  MultiStmtArg CatchStmts,
1461  Stmt *Finally) {
1462  return getSema().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1463  Finally);
1464  }
1465 
1466  /// Rebuild an Objective-C exception declaration.
1467  ///
1468  /// By default, performs semantic analysis to build the new declaration.
1469  /// Subclasses may override this routine to provide different behavior.
1471  TypeSourceInfo *TInfo, QualType T) {
1472  return getSema().BuildObjCExceptionDecl(TInfo, T,
1473  ExceptionDecl->getInnerLocStart(),
1474  ExceptionDecl->getLocation(),
1475  ExceptionDecl->getIdentifier());
1476  }
1477 
1478  /// Build a new Objective-C \@catch statement.
1479  ///
1480  /// By default, performs semantic analysis to build the new statement.
1481  /// Subclasses may override this routine to provide different behavior.
1483  SourceLocation RParenLoc,
1484  VarDecl *Var,
1485  Stmt *Body) {
1486  return getSema().ActOnObjCAtCatchStmt(AtLoc, RParenLoc,
1487  Var, Body);
1488  }
1489 
1490  /// Build a new Objective-C \@finally statement.
1491  ///
1492  /// By default, performs semantic analysis to build the new statement.
1493  /// Subclasses may override this routine to provide different behavior.
1495  Stmt *Body) {
1496  return getSema().ActOnObjCAtFinallyStmt(AtLoc, Body);
1497  }
1498 
1499  /// Build a new Objective-C \@throw statement.
1500  ///
1501  /// By default, performs semantic analysis to build the new statement.
1502  /// Subclasses may override this routine to provide different behavior.
1504  Expr *Operand) {
1505  return getSema().BuildObjCAtThrowStmt(AtLoc, Operand);
1506  }
1507 
1508  /// Build a new OpenMP executable directive.
1509  ///
1510  /// By default, performs semantic analysis to build the new statement.
1511  /// Subclasses may override this routine to provide different behavior.
1513  DeclarationNameInfo DirName,
1514  OpenMPDirectiveKind CancelRegion,
1515  ArrayRef<OMPClause *> Clauses,
1516  Stmt *AStmt, SourceLocation StartLoc,
1517  SourceLocation EndLoc) {
1518  return getSema().ActOnOpenMPExecutableDirective(
1519  Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1520  }
1521 
1522  /// Build a new OpenMP 'if' clause.
1523  ///
1524  /// By default, performs semantic analysis to build the new OpenMP clause.
1525  /// Subclasses may override this routine to provide different behavior.
1527  Expr *Condition, SourceLocation StartLoc,
1528  SourceLocation LParenLoc,
1529  SourceLocation NameModifierLoc,
1531  SourceLocation EndLoc) {
1532  return getSema().ActOnOpenMPIfClause(NameModifier, Condition, StartLoc,
1533  LParenLoc, NameModifierLoc, ColonLoc,
1534  EndLoc);
1535  }
1536 
1537  /// Build a new OpenMP 'final' clause.
1538  ///
1539  /// By default, performs semantic analysis to build the new OpenMP clause.
1540  /// Subclasses may override this routine to provide different behavior.
1542  SourceLocation LParenLoc,
1543  SourceLocation EndLoc) {
1544  return getSema().ActOnOpenMPFinalClause(Condition, StartLoc, LParenLoc,
1545  EndLoc);
1546  }
1547 
1548  /// Build a new OpenMP 'num_threads' clause.
1549  ///
1550  /// By default, performs semantic analysis to build the new OpenMP clause.
1551  /// Subclasses may override this routine to provide different behavior.
1553  SourceLocation StartLoc,
1554  SourceLocation LParenLoc,
1555  SourceLocation EndLoc) {
1556  return getSema().ActOnOpenMPNumThreadsClause(NumThreads, StartLoc,
1557  LParenLoc, EndLoc);
1558  }
1559 
1560  /// Build a new OpenMP 'safelen' clause.
1561  ///
1562  /// By default, performs semantic analysis to build the new OpenMP clause.
1563  /// Subclasses may override this routine to provide different behavior.
1565  SourceLocation LParenLoc,
1566  SourceLocation EndLoc) {
1567  return getSema().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc, EndLoc);
1568  }
1569 
1570  /// Build a new OpenMP 'simdlen' clause.
1571  ///
1572  /// By default, performs semantic analysis to build the new OpenMP clause.
1573  /// Subclasses may override this routine to provide different behavior.
1575  SourceLocation LParenLoc,
1576  SourceLocation EndLoc) {
1577  return getSema().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc, EndLoc);
1578  }
1579 
1580  /// Build a new OpenMP 'allocator' clause.
1581  ///
1582  /// By default, performs semantic analysis to build the new OpenMP clause.
1583  /// Subclasses may override this routine to provide different behavior.
1585  SourceLocation LParenLoc,
1586  SourceLocation EndLoc) {
1587  return getSema().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc, EndLoc);
1588  }
1589 
1590  /// Build a new OpenMP 'collapse' clause.
1591  ///
1592  /// By default, performs semantic analysis to build the new OpenMP clause.
1593  /// Subclasses may override this routine to provide different behavior.
1595  SourceLocation LParenLoc,
1596  SourceLocation EndLoc) {
1597  return getSema().ActOnOpenMPCollapseClause(Num, StartLoc, LParenLoc,
1598  EndLoc);
1599  }
1600 
1601  /// Build a new OpenMP 'default' clause.
1602  ///
1603  /// By default, performs semantic analysis to build the new OpenMP clause.
1604  /// Subclasses may override this routine to provide different behavior.
1606  SourceLocation KindKwLoc,
1607  SourceLocation StartLoc,
1608  SourceLocation LParenLoc,
1609  SourceLocation EndLoc) {
1610  return getSema().ActOnOpenMPDefaultClause(Kind, KindKwLoc,
1611  StartLoc, LParenLoc, EndLoc);
1612  }
1613 
1614  /// Build a new OpenMP 'proc_bind' clause.
1615  ///
1616  /// By default, performs semantic analysis to build the new OpenMP clause.
1617  /// Subclasses may override this routine to provide different behavior.
1619  SourceLocation KindKwLoc,
1620  SourceLocation StartLoc,
1621  SourceLocation LParenLoc,
1622  SourceLocation EndLoc) {
1623  return getSema().ActOnOpenMPProcBindClause(Kind, KindKwLoc,
1624  StartLoc, LParenLoc, EndLoc);
1625  }
1626 
1627  /// Build a new OpenMP 'schedule' clause.
1628  ///
1629  /// By default, performs semantic analysis to build the new OpenMP clause.
1630  /// Subclasses may override this routine to provide different behavior.
1633  OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1634  SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1635  SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1636  return getSema().ActOnOpenMPScheduleClause(
1637  M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1638  CommaLoc, EndLoc);
1639  }
1640 
1641  /// Build a new OpenMP 'ordered' clause.
1642  ///
1643  /// By default, performs semantic analysis to build the new OpenMP clause.
1644  /// Subclasses may override this routine to provide different behavior.
1646  SourceLocation EndLoc,
1647  SourceLocation LParenLoc, Expr *Num) {
1648  return getSema().ActOnOpenMPOrderedClause(StartLoc, EndLoc, LParenLoc, Num);
1649  }
1650 
1651  /// Build a new OpenMP 'private' clause.
1652  ///
1653  /// By default, performs semantic analysis to build the new OpenMP clause.
1654  /// Subclasses may override this routine to provide different behavior.
1656  SourceLocation StartLoc,
1657  SourceLocation LParenLoc,
1658  SourceLocation EndLoc) {
1659  return getSema().ActOnOpenMPPrivateClause(VarList, StartLoc, LParenLoc,
1660  EndLoc);
1661  }
1662 
1663  /// Build a new OpenMP 'firstprivate' clause.
1664  ///
1665  /// By default, performs semantic analysis to build the new OpenMP clause.
1666  /// Subclasses may override this routine to provide different behavior.
1668  SourceLocation StartLoc,
1669  SourceLocation LParenLoc,
1670  SourceLocation EndLoc) {
1671  return getSema().ActOnOpenMPFirstprivateClause(VarList, StartLoc, LParenLoc,
1672  EndLoc);
1673  }
1674 
1675  /// Build a new OpenMP 'lastprivate' clause.
1676  ///
1677  /// By default, performs semantic analysis to build the new OpenMP clause.
1678  /// Subclasses may override this routine to provide different behavior.
1681  SourceLocation LPKindLoc,
1683  SourceLocation StartLoc,
1684  SourceLocation LParenLoc,
1685  SourceLocation EndLoc) {
1686  return getSema().ActOnOpenMPLastprivateClause(
1687  VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1688  }
1689 
1690  /// Build a new OpenMP 'shared' clause.
1691  ///
1692  /// By default, performs semantic analysis to build the new OpenMP clause.
1693  /// Subclasses may override this routine to provide different behavior.
1695  SourceLocation StartLoc,
1696  SourceLocation LParenLoc,
1697  SourceLocation EndLoc) {
1698  return getSema().ActOnOpenMPSharedClause(VarList, StartLoc, LParenLoc,
1699  EndLoc);
1700  }
1701 
1702  /// Build a new OpenMP 'reduction' clause.
1703  ///
1704  /// By default, performs semantic analysis to build the new statement.
1705  /// Subclasses may override this routine to provide different behavior.
1707  SourceLocation StartLoc,
1708  SourceLocation LParenLoc,
1710  SourceLocation EndLoc,
1711  CXXScopeSpec &ReductionIdScopeSpec,
1712  const DeclarationNameInfo &ReductionId,
1713  ArrayRef<Expr *> UnresolvedReductions) {
1714  return getSema().ActOnOpenMPReductionClause(
1715  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1716  ReductionId, UnresolvedReductions);
1717  }
1718 
1719  /// Build a new OpenMP 'task_reduction' clause.
1720  ///
1721  /// By default, performs semantic analysis to build the new statement.
1722  /// Subclasses may override this routine to provide different behavior.
1724  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1726  CXXScopeSpec &ReductionIdScopeSpec,
1727  const DeclarationNameInfo &ReductionId,
1728  ArrayRef<Expr *> UnresolvedReductions) {
1729  return getSema().ActOnOpenMPTaskReductionClause(
1730  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1731  ReductionId, UnresolvedReductions);
1732  }
1733 
1734  /// Build a new OpenMP 'in_reduction' clause.
1735  ///
1736  /// By default, performs semantic analysis to build the new statement.
1737  /// Subclasses may override this routine to provide different behavior.
1738  OMPClause *
1741  SourceLocation EndLoc,
1742  CXXScopeSpec &ReductionIdScopeSpec,
1743  const DeclarationNameInfo &ReductionId,
1744  ArrayRef<Expr *> UnresolvedReductions) {
1745  return getSema().ActOnOpenMPInReductionClause(
1746  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1747  ReductionId, UnresolvedReductions);
1748  }
1749 
1750  /// Build a new OpenMP 'linear' clause.
1751  ///
1752  /// By default, performs semantic analysis to build the new OpenMP clause.
1753  /// Subclasses may override this routine to provide different behavior.
1755  SourceLocation StartLoc,
1756  SourceLocation LParenLoc,
1760  SourceLocation EndLoc) {
1761  return getSema().ActOnOpenMPLinearClause(VarList, Step, StartLoc, LParenLoc,
1762  Modifier, ModifierLoc, ColonLoc,
1763  EndLoc);
1764  }
1765 
1766  /// Build a new OpenMP 'aligned' clause.
1767  ///
1768  /// By default, performs semantic analysis to build the new OpenMP clause.
1769  /// Subclasses may override this routine to provide different behavior.
1771  SourceLocation StartLoc,
1772  SourceLocation LParenLoc,
1774  SourceLocation EndLoc) {
1775  return getSema().ActOnOpenMPAlignedClause(VarList, Alignment, StartLoc,
1776  LParenLoc, ColonLoc, EndLoc);
1777  }
1778 
1779  /// Build a new OpenMP 'copyin' clause.
1780  ///
1781  /// By default, performs semantic analysis to build the new OpenMP clause.
1782  /// Subclasses may override this routine to provide different behavior.
1784  SourceLocation StartLoc,
1785  SourceLocation LParenLoc,
1786  SourceLocation EndLoc) {
1787  return getSema().ActOnOpenMPCopyinClause(VarList, StartLoc, LParenLoc,
1788  EndLoc);
1789  }
1790 
1791  /// Build a new OpenMP 'copyprivate' clause.
1792  ///
1793  /// By default, performs semantic analysis to build the new OpenMP clause.
1794  /// Subclasses may override this routine to provide different behavior.
1796  SourceLocation StartLoc,
1797  SourceLocation LParenLoc,
1798  SourceLocation EndLoc) {
1799  return getSema().ActOnOpenMPCopyprivateClause(VarList, StartLoc, LParenLoc,
1800  EndLoc);
1801  }
1802 
1803  /// Build a new OpenMP 'flush' pseudo clause.
1804  ///
1805  /// By default, performs semantic analysis to build the new OpenMP clause.
1806  /// Subclasses may override this routine to provide different behavior.
1808  SourceLocation StartLoc,
1809  SourceLocation LParenLoc,
1810  SourceLocation EndLoc) {
1811  return getSema().ActOnOpenMPFlushClause(VarList, StartLoc, LParenLoc,
1812  EndLoc);
1813  }
1814 
1815  /// Build a new OpenMP 'depend' pseudo clause.
1816  ///
1817  /// By default, performs semantic analysis to build the new OpenMP clause.
1818  /// Subclasses may override this routine to provide different behavior.
1819  OMPClause *
1822  SourceLocation StartLoc, SourceLocation LParenLoc,
1823  SourceLocation EndLoc) {
1824  return getSema().ActOnOpenMPDependClause(DepKind, DepLoc, ColonLoc, VarList,
1825  StartLoc, LParenLoc, EndLoc);
1826  }
1827 
1828  /// Build a new OpenMP 'device' clause.
1829  ///
1830  /// By default, performs semantic analysis to build the new statement.
1831  /// Subclasses may override this routine to provide different behavior.
1833  SourceLocation LParenLoc,
1834  SourceLocation EndLoc) {
1835  return getSema().ActOnOpenMPDeviceClause(Device, StartLoc, LParenLoc,
1836  EndLoc);
1837  }
1838 
1839  /// Build a new OpenMP 'map' clause.
1840  ///
1841  /// By default, performs semantic analysis to build the new OpenMP clause.
1842  /// Subclasses may override this routine to provide different behavior.
1844  ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
1845  ArrayRef<SourceLocation> MapTypeModifiersLoc,
1846  CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId,
1847  OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
1849  const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) {
1850  return getSema().ActOnOpenMPMapClause(MapTypeModifiers, MapTypeModifiersLoc,
1851  MapperIdScopeSpec, MapperId, MapType,
1852  IsMapTypeImplicit, MapLoc, ColonLoc,
1853  VarList, Locs, UnresolvedMappers);
1854  }
1855 
1856  /// Build a new OpenMP 'allocate' clause.
1857  ///
1858  /// By default, performs semantic analysis to build the new OpenMP clause.
1859  /// Subclasses may override this routine to provide different behavior.
1861  SourceLocation StartLoc,
1862  SourceLocation LParenLoc,
1864  SourceLocation EndLoc) {
1865  return getSema().ActOnOpenMPAllocateClause(Allocate, VarList, StartLoc,
1866  LParenLoc, ColonLoc, EndLoc);
1867  }
1868 
1869  /// Build a new OpenMP 'num_teams' clause.
1870  ///
1871  /// By default, performs semantic analysis to build the new statement.
1872  /// Subclasses may override this routine to provide different behavior.
1874  SourceLocation LParenLoc,
1875  SourceLocation EndLoc) {
1876  return getSema().ActOnOpenMPNumTeamsClause(NumTeams, StartLoc, LParenLoc,
1877  EndLoc);
1878  }
1879 
1880  /// Build a new OpenMP 'thread_limit' clause.
1881  ///
1882  /// By default, performs semantic analysis to build the new statement.
1883  /// Subclasses may override this routine to provide different behavior.
1885  SourceLocation StartLoc,
1886  SourceLocation LParenLoc,
1887  SourceLocation EndLoc) {
1888  return getSema().ActOnOpenMPThreadLimitClause(ThreadLimit, StartLoc,
1889  LParenLoc, EndLoc);
1890  }
1891 
1892  /// Build a new OpenMP 'priority' clause.
1893  ///
1894  /// By default, performs semantic analysis to build the new statement.
1895  /// Subclasses may override this routine to provide different behavior.
1897  SourceLocation LParenLoc,
1898  SourceLocation EndLoc) {
1899  return getSema().ActOnOpenMPPriorityClause(Priority, StartLoc, LParenLoc,
1900  EndLoc);
1901  }
1902 
1903  /// Build a new OpenMP 'grainsize' clause.
1904  ///
1905  /// By default, performs semantic analysis to build the new statement.
1906  /// Subclasses may override this routine to provide different behavior.
1908  SourceLocation LParenLoc,
1909  SourceLocation EndLoc) {
1910  return getSema().ActOnOpenMPGrainsizeClause(Grainsize, StartLoc, LParenLoc,
1911  EndLoc);
1912  }
1913 
1914  /// Build a new OpenMP 'num_tasks' clause.
1915  ///
1916  /// By default, performs semantic analysis to build the new statement.
1917  /// Subclasses may override this routine to provide different behavior.
1919  SourceLocation LParenLoc,
1920  SourceLocation EndLoc) {
1921  return getSema().ActOnOpenMPNumTasksClause(NumTasks, StartLoc, LParenLoc,
1922  EndLoc);
1923  }
1924 
1925  /// Build a new OpenMP 'hint' clause.
1926  ///
1927  /// By default, performs semantic analysis to build the new statement.
1928  /// Subclasses may override this routine to provide different behavior.
1930  SourceLocation LParenLoc,
1931  SourceLocation EndLoc) {
1932  return getSema().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc, EndLoc);
1933  }
1934 
1935  /// Build a new OpenMP 'dist_schedule' clause.
1936  ///
1937  /// By default, performs semantic analysis to build the new OpenMP clause.
1938  /// Subclasses may override this routine to provide different behavior.
1939  OMPClause *
1941  Expr *ChunkSize, SourceLocation StartLoc,
1942  SourceLocation LParenLoc, SourceLocation KindLoc,
1943  SourceLocation CommaLoc, SourceLocation EndLoc) {
1944  return getSema().ActOnOpenMPDistScheduleClause(
1945  Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
1946  }
1947 
1948  /// Build a new OpenMP 'to' clause.
1949  ///
1950  /// By default, performs semantic analysis to build the new statement.
1951  /// Subclasses may override this routine to provide different behavior.
1953  CXXScopeSpec &MapperIdScopeSpec,
1954  DeclarationNameInfo &MapperId,
1955  const OMPVarListLocTy &Locs,
1956  ArrayRef<Expr *> UnresolvedMappers) {
1957  return getSema().ActOnOpenMPToClause(VarList, MapperIdScopeSpec, MapperId,
1958  Locs, UnresolvedMappers);
1959  }
1960 
1961  /// Build a new OpenMP 'from' clause.
1962  ///
1963  /// By default, performs semantic analysis to build the new statement.
1964  /// Subclasses may override this routine to provide different behavior.
1966  CXXScopeSpec &MapperIdScopeSpec,
1967  DeclarationNameInfo &MapperId,
1968  const OMPVarListLocTy &Locs,
1969  ArrayRef<Expr *> UnresolvedMappers) {
1970  return getSema().ActOnOpenMPFromClause(VarList, MapperIdScopeSpec, MapperId,
1971  Locs, UnresolvedMappers);
1972  }
1973 
1974  /// Build a new OpenMP 'use_device_ptr' clause.
1975  ///
1976  /// By default, performs semantic analysis to build the new OpenMP clause.
1977  /// Subclasses may override this routine to provide different behavior.
1979  const OMPVarListLocTy &Locs) {
1980  return getSema().ActOnOpenMPUseDevicePtrClause(VarList, Locs);
1981  }
1982 
1983  /// Build a new OpenMP 'is_device_ptr' clause.
1984  ///
1985  /// By default, performs semantic analysis to build the new OpenMP clause.
1986  /// Subclasses may override this routine to provide different behavior.
1988  const OMPVarListLocTy &Locs) {
1989  return getSema().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
1990  }
1991 
1992  /// Build a new OpenMP 'defaultmap' clause.
1993  ///
1994  /// By default, performs semantic analysis to build the new OpenMP clause.
1995  /// Subclasses may override this routine to provide different behavior.
1998  SourceLocation StartLoc,
1999  SourceLocation LParenLoc,
2000  SourceLocation MLoc,
2001  SourceLocation KindLoc,
2002  SourceLocation EndLoc) {
2003  return getSema().ActOnOpenMPDefaultmapClause(M, Kind, StartLoc, LParenLoc,
2004  MLoc, KindLoc, EndLoc);
2005  }
2006 
2007  /// Build a new OpenMP 'nontemporal' clause.
2008  ///
2009  /// By default, performs semantic analysis to build the new OpenMP clause.
2010  /// Subclasses may override this routine to provide different behavior.
2012  SourceLocation StartLoc,
2013  SourceLocation LParenLoc,
2014  SourceLocation EndLoc) {
2015  return getSema().ActOnOpenMPNontemporalClause(VarList, StartLoc, LParenLoc,
2016  EndLoc);
2017  }
2018 
2019  /// Rebuild the operand to an Objective-C \@synchronized statement.
2020  ///
2021  /// By default, performs semantic analysis to build the new statement.
2022  /// Subclasses may override this routine to provide different behavior.
2024  Expr *object) {
2025  return getSema().ActOnObjCAtSynchronizedOperand(atLoc, object);
2026  }
2027 
2028  /// Build a new Objective-C \@synchronized statement.
2029  ///
2030  /// By default, performs semantic analysis to build the new statement.
2031  /// Subclasses may override this routine to provide different behavior.
2033  Expr *Object, Stmt *Body) {
2034  return getSema().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
2035  }
2036 
2037  /// Build a new Objective-C \@autoreleasepool statement.
2038  ///
2039  /// By default, performs semantic analysis to build the new statement.
2040  /// Subclasses may override this routine to provide different behavior.
2042  Stmt *Body) {
2043  return getSema().ActOnObjCAutoreleasePoolStmt(AtLoc, Body);
2044  }
2045 
2046  /// Build a new Objective-C fast enumeration statement.
2047  ///
2048  /// By default, performs semantic analysis to build the new statement.
2049  /// Subclasses may override this routine to provide different behavior.
2051  Stmt *Element,
2052  Expr *Collection,
2053  SourceLocation RParenLoc,
2054  Stmt *Body) {
2055  StmtResult ForEachStmt = getSema().ActOnObjCForCollectionStmt(ForLoc,
2056  Element,
2057  Collection,
2058  RParenLoc);
2059  if (ForEachStmt.isInvalid())
2060  return StmtError();
2061 
2062  return getSema().FinishObjCForCollectionStmt(ForEachStmt.get(), Body);
2063  }
2064 
2065  /// Build a new C++ exception declaration.
2066  ///
2067  /// By default, performs semantic analysis to build the new decaration.
2068  /// Subclasses may override this routine to provide different behavior.
2071  SourceLocation StartLoc,
2072  SourceLocation IdLoc,
2073  IdentifierInfo *Id) {
2074  VarDecl *Var = getSema().BuildExceptionDeclaration(nullptr, Declarator,
2075  StartLoc, IdLoc, Id);
2076  if (Var)
2077  getSema().CurContext->addDecl(Var);
2078  return Var;
2079  }
2080 
2081  /// Build a new C++ catch statement.
2082  ///
2083  /// By default, performs semantic analysis to build the new statement.
2084  /// Subclasses may override this routine to provide different behavior.
2086  VarDecl *ExceptionDecl,
2087  Stmt *Handler) {
2088  return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2089  Handler));
2090  }
2091 
2092  /// Build a new C++ try statement.
2093  ///
2094  /// By default, performs semantic analysis to build the new statement.
2095  /// Subclasses may override this routine to provide different behavior.
2097  ArrayRef<Stmt *> Handlers) {
2098  return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2099  }
2100 
2101  /// Build a new C++0x range-based for statement.
2102  ///
2103  /// By default, performs semantic analysis to build the new statement.
2104  /// Subclasses may override this routine to provide different behavior.
2106  SourceLocation CoawaitLoc, Stmt *Init,
2107  SourceLocation ColonLoc, Stmt *Range,
2108  Stmt *Begin, Stmt *End, Expr *Cond,
2109  Expr *Inc, Stmt *LoopVar,
2110  SourceLocation RParenLoc) {
2111  // If we've just learned that the range is actually an Objective-C
2112  // collection, treat this as an Objective-C fast enumeration loop.
2113  if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2114  if (RangeStmt->isSingleDecl()) {
2115  if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2116  if (RangeVar->isInvalidDecl())
2117  return StmtError();
2118 
2119  Expr *RangeExpr = RangeVar->getInit();
2120  if (!RangeExpr->isTypeDependent() &&
2121  RangeExpr->getType()->isObjCObjectPointerType()) {
2122  // FIXME: Support init-statements in Objective-C++20 ranged for
2123  // statement.
2124  if (Init) {
2125  return SemaRef.Diag(Init->getBeginLoc(),
2126  diag::err_objc_for_range_init_stmt)
2127  << Init->getSourceRange();
2128  }
2129  return getSema().ActOnObjCForCollectionStmt(ForLoc, LoopVar,
2130  RangeExpr, RParenLoc);
2131  }
2132  }
2133  }
2134  }
2135 
2136  return getSema().BuildCXXForRangeStmt(ForLoc, CoawaitLoc, Init, ColonLoc,
2137  Range, Begin, End, Cond, Inc, LoopVar,
2138  RParenLoc, Sema::BFRK_Rebuild);
2139  }
2140 
2141  /// Build a new C++0x range-based for statement.
2142  ///
2143  /// By default, performs semantic analysis to build the new statement.
2144  /// Subclasses may override this routine to provide different behavior.
2146  bool IsIfExists,
2147  NestedNameSpecifierLoc QualifierLoc,
2148  DeclarationNameInfo NameInfo,
2149  Stmt *Nested) {
2150  return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2151  QualifierLoc, NameInfo, Nested);
2152  }
2153 
2154  /// Attach body to a C++0x range-based for statement.
2155  ///
2156  /// By default, performs semantic analysis to finish the new statement.
2157  /// Subclasses may override this routine to provide different behavior.
2159  return getSema().FinishCXXForRangeStmt(ForRange, Body);
2160  }
2161 
2163  Stmt *TryBlock, Stmt *Handler) {
2164  return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2165  }
2166 
2168  Stmt *Block) {
2169  return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2170  }
2171 
2173  return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2174  }
2175 
2176  /// Build a new predefined expression.
2177  ///
2178  /// By default, performs semantic analysis to build the new expression.
2179  /// Subclasses may override this routine to provide different behavior.
2182  return getSema().BuildPredefinedExpr(Loc, IK);
2183  }
2184 
2185  /// Build a new expression that references a declaration.
2186  ///
2187  /// By default, performs semantic analysis to build the new expression.
2188  /// Subclasses may override this routine to provide different behavior.
2190  LookupResult &R,
2191  bool RequiresADL) {
2192  return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2193  }
2194 
2195 
2196  /// Build a new expression that references a declaration.
2197  ///
2198  /// By default, performs semantic analysis to build the new expression.
2199  /// Subclasses may override this routine to provide different behavior.
2201  ValueDecl *VD,
2202  const DeclarationNameInfo &NameInfo,
2203  NamedDecl *Found,
2204  TemplateArgumentListInfo *TemplateArgs) {
2205  CXXScopeSpec SS;
2206  SS.Adopt(QualifierLoc);
2207  return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2208  TemplateArgs);
2209  }
2210 
2211  /// Build a new expression in parentheses.
2212  ///
2213  /// By default, performs semantic analysis to build the new expression.
2214  /// Subclasses may override this routine to provide different behavior.
2216  SourceLocation RParen) {
2217  return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2218  }
2219 
2220  /// Build a new pseudo-destructor expression.
2221  ///
2222  /// By default, performs semantic analysis to build the new expression.
2223  /// Subclasses may override this routine to provide different behavior.
2224  ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base,
2225  SourceLocation OperatorLoc,
2226  bool isArrow,
2227  CXXScopeSpec &SS,
2228  TypeSourceInfo *ScopeType,
2229  SourceLocation CCLoc,
2230  SourceLocation TildeLoc,
2231  PseudoDestructorTypeStorage Destroyed);
2232 
2233  /// Build a new unary operator expression.
2234  ///
2235  /// By default, performs semantic analysis to build the new expression.
2236  /// Subclasses may override this routine to provide different behavior.
2238  UnaryOperatorKind Opc,
2239  Expr *SubExpr) {
2240  return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2241  }
2242 
2243  /// Build a new builtin offsetof expression.
2244  ///
2245  /// By default, performs semantic analysis to build the new expression.
2246  /// Subclasses may override this routine to provide different behavior.
2250  SourceLocation RParenLoc) {
2251  return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2252  RParenLoc);
2253  }
2254 
2255  /// Build a new sizeof, alignof or vec_step expression with a
2256  /// type argument.
2257  ///
2258  /// By default, performs semantic analysis to build the new expression.
2259  /// Subclasses may override this routine to provide different behavior.
2261  SourceLocation OpLoc,
2262  UnaryExprOrTypeTrait ExprKind,
2263  SourceRange R) {
2264  return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2265  }
2266 
2267  /// Build a new sizeof, alignof or vec step expression with an
2268  /// expression argument.
2269  ///
2270  /// By default, performs semantic analysis to build the new expression.
2271  /// Subclasses may override this routine to provide different behavior.
2273  UnaryExprOrTypeTrait ExprKind,
2274  SourceRange R) {
2275  ExprResult Result
2276  = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2277  if (Result.isInvalid())
2278  return ExprError();
2279 
2280  return Result;
2281  }
2282 
2283  /// Build a new array subscript expression.
2284  ///
2285  /// By default, performs semantic analysis to build the new expression.
2286  /// Subclasses may override this routine to provide different behavior.
2288  SourceLocation LBracketLoc,
2289  Expr *RHS,
2290  SourceLocation RBracketLoc) {
2291  return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2292  LBracketLoc, RHS,
2293  RBracketLoc);
2294  }
2295 
2296  /// Build a new array section expression.
2297  ///
2298  /// By default, performs semantic analysis to build the new expression.
2299  /// Subclasses may override this routine to provide different behavior.
2301  Expr *LowerBound,
2302  SourceLocation ColonLoc, Expr *Length,
2303  SourceLocation RBracketLoc) {
2304  return getSema().ActOnOMPArraySectionExpr(Base, LBracketLoc, LowerBound,
2305  ColonLoc, Length, RBracketLoc);
2306  }
2307 
2308  /// Build a new call expression.
2309  ///
2310  /// By default, performs semantic analysis to build the new expression.
2311  /// Subclasses may override this routine to provide different behavior.
2313  MultiExprArg Args,
2314  SourceLocation RParenLoc,
2315  Expr *ExecConfig = nullptr) {
2316  return getSema().BuildCallExpr(/*Scope=*/nullptr, Callee, LParenLoc, Args,
2317  RParenLoc, ExecConfig);
2318  }
2319 
2320  /// Build a new member access expression.
2321  ///
2322  /// By default, performs semantic analysis to build the new expression.
2323  /// Subclasses may override this routine to provide different behavior.
2325  bool isArrow,
2326  NestedNameSpecifierLoc QualifierLoc,
2327  SourceLocation TemplateKWLoc,
2328  const DeclarationNameInfo &MemberNameInfo,
2329  ValueDecl *Member,
2330  NamedDecl *FoundDecl,
2331  const TemplateArgumentListInfo *ExplicitTemplateArgs,
2332  NamedDecl *FirstQualifierInScope) {
2333  ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base,
2334  isArrow);
2335  if (!Member->getDeclName()) {
2336  // We have a reference to an unnamed field. This is always the
2337  // base of an anonymous struct/union member access, i.e. the
2338  // field is always of record type.
2339  assert(Member->getType()->isRecordType() &&
2340  "unnamed member not of record type?");
2341 
2342  BaseResult =
2343  getSema().PerformObjectMemberConversion(BaseResult.get(),
2344  QualifierLoc.getNestedNameSpecifier(),
2345  FoundDecl, Member);
2346  if (BaseResult.isInvalid())
2347  return ExprError();
2348  Base = BaseResult.get();
2349 
2350  CXXScopeSpec EmptySS;
2351  return getSema().BuildFieldReferenceExpr(
2352  Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
2353  DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()), MemberNameInfo);
2354  }
2355 
2356  CXXScopeSpec SS;
2357  SS.Adopt(QualifierLoc);
2358 
2359  Base = BaseResult.get();
2360  QualType BaseType = Base->getType();
2361 
2362  if (isArrow && !BaseType->isPointerType())
2363  return ExprError();
2364 
2365  // FIXME: this involves duplicating earlier analysis in a lot of
2366  // cases; we should avoid this when possible.
2367  LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
2368  R.addDecl(FoundDecl);
2369  R.resolveKind();
2370 
2371  return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
2372  SS, TemplateKWLoc,
2373  FirstQualifierInScope,
2374  R, ExplicitTemplateArgs,
2375  /*S*/nullptr);
2376  }
2377 
2378  /// Build a new binary operator expression.
2379  ///
2380  /// By default, performs semantic analysis to build the new expression.
2381  /// Subclasses may override this routine to provide different behavior.
2383  BinaryOperatorKind Opc,
2384  Expr *LHS, Expr *RHS) {
2385  return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS);
2386  }
2387 
2388  /// Build a new rewritten operator expression.
2389  ///
2390  /// By default, performs semantic analysis to build the new expression.
2391  /// Subclasses may override this routine to provide different behavior.
2394  const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
2395  return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
2396  RHS, /*RequiresADL*/false);
2397  }
2398 
2399  /// Build a new conditional operator expression.
2400  ///
2401  /// By default, performs semantic analysis to build the new expression.
2402  /// Subclasses may override this routine to provide different behavior.
2404  SourceLocation QuestionLoc,
2405  Expr *LHS,
2407  Expr *RHS) {
2408  return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
2409  LHS, RHS);
2410  }
2411 
2412  /// Build a new C-style cast expression.
2413  ///
2414  /// By default, performs semantic analysis to build the new expression.
2415  /// Subclasses may override this routine to provide different behavior.
2417  TypeSourceInfo *TInfo,
2418  SourceLocation RParenLoc,
2419  Expr *SubExpr) {
2420  return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
2421  SubExpr);
2422  }
2423 
2424  /// Build a new compound literal expression.
2425  ///
2426  /// By default, performs semantic analysis to build the new expression.
2427  /// Subclasses may override this routine to provide different behavior.
2429  TypeSourceInfo *TInfo,
2430  SourceLocation RParenLoc,
2431  Expr *Init) {
2432  return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
2433  Init);
2434  }
2435 
2436  /// Build a new extended vector element access expression.
2437  ///
2438  /// By default, performs semantic analysis to build the new expression.
2439  /// Subclasses may override this routine to provide different behavior.
2441  SourceLocation OpLoc,
2442  SourceLocation AccessorLoc,
2443  IdentifierInfo &Accessor) {
2444 
2445  CXXScopeSpec SS;
2446  DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
2447  return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
2448  OpLoc, /*IsArrow*/ false,
2449  SS, SourceLocation(),
2450  /*FirstQualifierInScope*/ nullptr,
2451  NameInfo,
2452  /* TemplateArgs */ nullptr,
2453  /*S*/ nullptr);
2454  }
2455 
2456  /// Build a new initializer list expression.
2457  ///
2458  /// By default, performs semantic analysis to build the new expression.
2459  /// Subclasses may override this routine to provide different behavior.
2462  SourceLocation RBraceLoc) {
2463  return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
2464  }
2465 
2466  /// Build a new designated initializer expression.
2467  ///
2468  /// By default, performs semantic analysis to build the new expression.
2469  /// Subclasses may override this routine to provide different behavior.
2471  MultiExprArg ArrayExprs,
2472  SourceLocation EqualOrColonLoc,
2473  bool GNUSyntax,
2474  Expr *Init) {
2475  ExprResult Result
2476  = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
2477  Init);
2478  if (Result.isInvalid())
2479  return ExprError();
2480 
2481  return Result;
2482  }
2483 
2484  /// Build a new value-initialized expression.
2485  ///
2486  /// By default, builds the implicit value initialization without performing
2487  /// any semantic analysis. Subclasses may override this routine to provide
2488  /// different behavior.
2490  return new (SemaRef.Context) ImplicitValueInitExpr(T);
2491  }
2492 
2493  /// Build a new \c va_arg expression.
2494  ///
2495  /// By default, performs semantic analysis to build the new expression.
2496  /// Subclasses may override this routine to provide different behavior.
2498  Expr *SubExpr, TypeSourceInfo *TInfo,
2499  SourceLocation RParenLoc) {
2500  return getSema().BuildVAArgExpr(BuiltinLoc,
2501  SubExpr, TInfo,
2502  RParenLoc);
2503  }
2504 
2505  /// Build a new expression list in parentheses.
2506  ///
2507  /// By default, performs semantic analysis to build the new expression.
2508  /// Subclasses may override this routine to provide different behavior.
2510  MultiExprArg SubExprs,
2511  SourceLocation RParenLoc) {
2512  return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
2513  }
2514 
2515  /// Build a new address-of-label expression.
2516  ///
2517  /// By default, performs semantic analysis, using the name of the label
2518  /// rather than attempting to map the label statement itself.
2519  /// Subclasses may override this routine to provide different behavior.
2521  SourceLocation LabelLoc, LabelDecl *Label) {
2522  return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
2523  }
2524 
2525  /// Build a new GNU statement expression.
2526  ///
2527  /// By default, performs semantic analysis to build the new expression.
2528  /// Subclasses may override this routine to provide different behavior.
2530  Stmt *SubStmt,
2531  SourceLocation RParenLoc) {
2532  return getSema().ActOnStmtExpr(LParenLoc, SubStmt, RParenLoc);
2533  }
2534 
2535  /// Build a new __builtin_choose_expr expression.
2536  ///
2537  /// By default, performs semantic analysis to build the new expression.
2538  /// Subclasses may override this routine to provide different behavior.
2540  Expr *Cond, Expr *LHS, Expr *RHS,
2541  SourceLocation RParenLoc) {
2542  return SemaRef.ActOnChooseExpr(BuiltinLoc,
2543  Cond, LHS, RHS,
2544  RParenLoc);
2545  }
2546 
2547  /// Build a new generic selection expression.
2548  ///
2549  /// By default, performs semantic analysis to build the new expression.
2550  /// Subclasses may override this routine to provide different behavior.
2552  SourceLocation DefaultLoc,
2553  SourceLocation RParenLoc,
2554  Expr *ControllingExpr,
2556  ArrayRef<Expr *> Exprs) {
2557  return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
2558  ControllingExpr, Types, Exprs);
2559  }
2560 
2561  /// Build a new overloaded operator call expression.
2562  ///
2563  /// By default, performs semantic analysis to build the new expression.
2564  /// The semantic analysis provides the behavior of template instantiation,
2565  /// copying with transformations that turn what looks like an overloaded
2566  /// operator call into a use of a builtin operator, performing
2567  /// argument-dependent lookup, etc. Subclasses may override this routine to
2568  /// provide different behavior.
2569  ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
2570  SourceLocation OpLoc,
2571  Expr *Callee,
2572  Expr *First,
2573  Expr *Second);
2574 
2575  /// Build a new C++ "named" cast expression, such as static_cast or
2576  /// reinterpret_cast.
2577  ///
2578  /// By default, this routine dispatches to one of the more-specific routines
2579  /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
2580  /// Subclasses may override this routine to provide different behavior.
2582  Stmt::StmtClass Class,
2583  SourceLocation LAngleLoc,
2584  TypeSourceInfo *TInfo,
2585  SourceLocation RAngleLoc,
2586  SourceLocation LParenLoc,
2587  Expr *SubExpr,
2588  SourceLocation RParenLoc) {
2589  switch (Class) {
2590  case Stmt::CXXStaticCastExprClass:
2591  return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
2592  RAngleLoc, LParenLoc,
2593  SubExpr, RParenLoc);
2594 
2595  case Stmt::CXXDynamicCastExprClass:
2596  return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
2597  RAngleLoc, LParenLoc,
2598  SubExpr, RParenLoc);
2599 
2600  case Stmt::CXXReinterpretCastExprClass:
2601  return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
2602  RAngleLoc, LParenLoc,
2603  SubExpr,
2604  RParenLoc);
2605 
2606  case Stmt::CXXConstCastExprClass:
2607  return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
2608  RAngleLoc, LParenLoc,
2609  SubExpr, RParenLoc);
2610 
2611  default:
2612  llvm_unreachable("Invalid C++ named cast");
2613  }
2614  }
2615 
2616  /// Build a new C++ static_cast expression.
2617  ///
2618  /// By default, performs semantic analysis to build the new expression.
2619  /// Subclasses may override this routine to provide different behavior.
2621  SourceLocation LAngleLoc,
2622  TypeSourceInfo *TInfo,
2623  SourceLocation RAngleLoc,
2624  SourceLocation LParenLoc,
2625  Expr *SubExpr,
2626  SourceLocation RParenLoc) {
2627  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
2628  TInfo, SubExpr,
2629  SourceRange(LAngleLoc, RAngleLoc),
2630  SourceRange(LParenLoc, RParenLoc));
2631  }
2632 
2633  /// Build a new C++ dynamic_cast expression.
2634  ///
2635  /// By default, performs semantic analysis to build the new expression.
2636  /// Subclasses may override this routine to provide different behavior.
2638  SourceLocation LAngleLoc,
2639  TypeSourceInfo *TInfo,
2640  SourceLocation RAngleLoc,
2641  SourceLocation LParenLoc,
2642  Expr *SubExpr,
2643  SourceLocation RParenLoc) {
2644  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
2645  TInfo, SubExpr,
2646  SourceRange(LAngleLoc, RAngleLoc),
2647  SourceRange(LParenLoc, RParenLoc));
2648  }
2649 
2650  /// Build a new C++ reinterpret_cast expression.
2651  ///
2652  /// By default, performs semantic analysis to build the new expression.
2653  /// Subclasses may override this routine to provide different behavior.
2655  SourceLocation LAngleLoc,
2656  TypeSourceInfo *TInfo,
2657  SourceLocation RAngleLoc,
2658  SourceLocation LParenLoc,
2659  Expr *SubExpr,
2660  SourceLocation RParenLoc) {
2661  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
2662  TInfo, SubExpr,
2663  SourceRange(LAngleLoc, RAngleLoc),
2664  SourceRange(LParenLoc, RParenLoc));
2665  }
2666 
2667  /// Build a new C++ const_cast expression.
2668  ///
2669  /// By default, performs semantic analysis to build the new expression.
2670  /// Subclasses may override this routine to provide different behavior.
2672  SourceLocation LAngleLoc,
2673  TypeSourceInfo *TInfo,
2674  SourceLocation RAngleLoc,
2675  SourceLocation LParenLoc,
2676  Expr *SubExpr,
2677  SourceLocation RParenLoc) {
2678  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
2679  TInfo, SubExpr,
2680  SourceRange(LAngleLoc, RAngleLoc),
2681  SourceRange(LParenLoc, RParenLoc));
2682  }
2683 
2684  /// Build a new C++ functional-style cast expression.
2685  ///
2686  /// By default, performs semantic analysis to build the new expression.
2687  /// Subclasses may override this routine to provide different behavior.
2689  SourceLocation LParenLoc,
2690  Expr *Sub,
2691  SourceLocation RParenLoc,
2692  bool ListInitialization) {
2693  return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
2694  MultiExprArg(&Sub, 1), RParenLoc,
2695  ListInitialization);
2696  }
2697 
2698  /// Build a new C++ __builtin_bit_cast expression.
2699  ///
2700  /// By default, performs semantic analysis to build the new expression.
2701  /// Subclasses may override this routine to provide different behavior.
2703  TypeSourceInfo *TSI, Expr *Sub,
2704  SourceLocation RParenLoc) {
2705  return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
2706  }
2707 
2708  /// Build a new C++ typeid(type) expression.
2709  ///
2710  /// By default, performs semantic analysis to build the new expression.
2711  /// Subclasses may override this routine to provide different behavior.
2713  SourceLocation TypeidLoc,
2714  TypeSourceInfo *Operand,
2715  SourceLocation RParenLoc) {
2716  return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
2717  RParenLoc);
2718  }
2719 
2720 
2721  /// Build a new C++ typeid(expr) expression.
2722  ///
2723  /// By default, performs semantic analysis to build the new expression.
2724  /// Subclasses may override this routine to provide different behavior.
2726  SourceLocation TypeidLoc,
2727  Expr *Operand,
2728  SourceLocation RParenLoc) {
2729  return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
2730  RParenLoc);
2731  }
2732 
2733  /// Build a new C++ __uuidof(type) expression.
2734  ///
2735  /// By default, performs semantic analysis to build the new expression.
2736  /// Subclasses may override this routine to provide different behavior.
2738  SourceLocation TypeidLoc,
2739  TypeSourceInfo *Operand,
2740  SourceLocation RParenLoc) {
2741  return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand,
2742  RParenLoc);
2743  }
2744 
2745  /// Build a new C++ __uuidof(expr) expression.
2746  ///
2747  /// By default, performs semantic analysis to build the new expression.
2748  /// Subclasses may override this routine to provide different behavior.
2750  SourceLocation TypeidLoc,
2751  Expr *Operand,
2752  SourceLocation RParenLoc) {
2753  return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand,
2754  RParenLoc);
2755  }
2756 
2757  /// Build a new C++ "this" expression.
2758  ///
2759  /// By default, builds a new "this" expression without performing any
2760  /// semantic analysis. Subclasses may override this routine to provide
2761  /// different behavior.
2763  QualType ThisType,
2764  bool isImplicit) {
2765  return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
2766  }
2767 
2768  /// Build a new C++ throw expression.
2769  ///
2770  /// By default, performs semantic analysis to build the new expression.
2771  /// Subclasses may override this routine to provide different behavior.
2773  bool IsThrownVariableInScope) {
2774  return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
2775  }
2776 
2777  /// Build a new C++ default-argument expression.
2778  ///
2779  /// By default, builds a new default-argument expression, which does not
2780  /// require any semantic analysis. Subclasses may override this routine to
2781  /// provide different behavior.
2783  return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
2784  getSema().CurContext);
2785  }
2786 
2787  /// Build a new C++11 default-initialization expression.
2788  ///
2789  /// By default, builds a new default field initialization expression, which
2790  /// does not require any semantic analysis. Subclasses may override this
2791  /// routine to provide different behavior.
2793  FieldDecl *Field) {
2794  return CXXDefaultInitExpr::Create(getSema().Context, Loc, Field,
2795  getSema().CurContext);
2796  }
2797 
2798  /// Build a new C++ zero-initialization expression.
2799  ///
2800  /// By default, performs semantic analysis to build the new expression.
2801  /// Subclasses may override this routine to provide different behavior.
2803  SourceLocation LParenLoc,
2804  SourceLocation RParenLoc) {
2805  return getSema().BuildCXXTypeConstructExpr(
2806  TSInfo, LParenLoc, None, RParenLoc, /*ListInitialization=*/false);
2807  }
2808 
2809  /// Build a new C++ "new" expression.
2810  ///
2811  /// By default, performs semantic analysis to build the new expression.
2812  /// Subclasses may override this routine to provide different behavior.
2814  bool UseGlobal,
2815  SourceLocation PlacementLParen,
2816  MultiExprArg PlacementArgs,
2817  SourceLocation PlacementRParen,
2818  SourceRange TypeIdParens,
2819  QualType AllocatedType,
2820  TypeSourceInfo *AllocatedTypeInfo,
2821  Optional<Expr *> ArraySize,
2822  SourceRange DirectInitRange,
2823  Expr *Initializer) {
2824  return getSema().BuildCXXNew(StartLoc, UseGlobal,
2825  PlacementLParen,
2826  PlacementArgs,
2827  PlacementRParen,
2828  TypeIdParens,
2829  AllocatedType,
2830  AllocatedTypeInfo,
2831  ArraySize,
2832  DirectInitRange,
2833  Initializer);
2834  }
2835 
2836  /// Build a new C++ "delete" expression.
2837  ///
2838  /// By default, performs semantic analysis to build the new expression.
2839  /// Subclasses may override this routine to provide different behavior.
2841  bool IsGlobalDelete,
2842  bool IsArrayForm,
2843  Expr *Operand) {
2844  return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
2845  Operand);
2846  }
2847 
2848  /// Build a new type trait expression.
2849  ///
2850  /// By default, performs semantic analysis to build the new expression.
2851  /// Subclasses may override this routine to provide different behavior.
2853  SourceLocation StartLoc,
2855  SourceLocation RParenLoc) {
2856  return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
2857  }
2858 
2859  /// Build a new array type trait expression.
2860  ///
2861  /// By default, performs semantic analysis to build the new expression.
2862  /// Subclasses may override this routine to provide different behavior.
2864  SourceLocation StartLoc,
2865  TypeSourceInfo *TSInfo,
2866  Expr *DimExpr,
2867  SourceLocation RParenLoc) {
2868  return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
2869  }
2870 
2871  /// Build a new expression trait expression.
2872  ///
2873  /// By default, performs semantic analysis to build the new expression.
2874  /// Subclasses may override this routine to provide different behavior.
2876  SourceLocation StartLoc,
2877  Expr *Queried,
2878  SourceLocation RParenLoc) {
2879  return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
2880  }
2881 
2882  /// Build a new (previously unresolved) declaration reference
2883  /// expression.
2884  ///
2885  /// By default, performs semantic analysis to build the new expression.
2886  /// Subclasses may override this routine to provide different behavior.
2888  NestedNameSpecifierLoc QualifierLoc,
2889  SourceLocation TemplateKWLoc,
2890  const DeclarationNameInfo &NameInfo,
2891  const TemplateArgumentListInfo *TemplateArgs,
2892  bool IsAddressOfOperand,
2893  TypeSourceInfo **RecoveryTSI) {
2894  CXXScopeSpec SS;
2895  SS.Adopt(QualifierLoc);
2896 
2897  if (TemplateArgs || TemplateKWLoc.isValid())
2898  return getSema().BuildQualifiedTemplateIdExpr(SS, TemplateKWLoc, NameInfo,
2899  TemplateArgs);
2900 
2901  return getSema().BuildQualifiedDeclarationNameExpr(
2902  SS, NameInfo, IsAddressOfOperand, /*S*/nullptr, RecoveryTSI);
2903  }
2904 
2905  /// Build a new template-id expression.
2906  ///
2907  /// By default, performs semantic analysis to build the new expression.
2908  /// Subclasses may override this routine to provide different behavior.
2910  SourceLocation TemplateKWLoc,
2911  LookupResult &R,
2912  bool RequiresADL,
2913  const TemplateArgumentListInfo *TemplateArgs) {
2914  return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
2915  TemplateArgs);
2916  }
2917 
2918  /// Build a new object-construction expression.
2919  ///
2920  /// By default, performs semantic analysis to build the new expression.
2921  /// Subclasses may override this routine to provide different behavior.
2923  SourceLocation Loc,
2924  CXXConstructorDecl *Constructor,
2925  bool IsElidable,
2926  MultiExprArg Args,
2927  bool HadMultipleCandidates,
2928  bool ListInitialization,
2929  bool StdInitListInitialization,
2930  bool RequiresZeroInit,
2931  CXXConstructExpr::ConstructionKind ConstructKind,
2932  SourceRange ParenRange) {
2933  SmallVector<Expr*, 8> ConvertedArgs;
2934  if (getSema().CompleteConstructorCall(Constructor, Args, Loc,
2935  ConvertedArgs))
2936  return ExprError();
2937 
2938  return getSema().BuildCXXConstructExpr(Loc, T, Constructor,
2939  IsElidable,
2940  ConvertedArgs,
2941  HadMultipleCandidates,
2942  ListInitialization,
2943  StdInitListInitialization,
2944  RequiresZeroInit, ConstructKind,
2945  ParenRange);
2946  }
2947 
2948  /// Build a new implicit construction via inherited constructor
2949  /// expression.
2951  CXXConstructorDecl *Constructor,
2952  bool ConstructsVBase,
2953  bool InheritedFromVBase) {
2954  return new (getSema().Context) CXXInheritedCtorInitExpr(
2955  Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
2956  }
2957 
2958  /// Build a new object-construction expression.
2959  ///
2960  /// By default, performs semantic analysis to build the new expression.
2961  /// Subclasses may override this routine to provide different behavior.
2963  SourceLocation LParenOrBraceLoc,
2964  MultiExprArg Args,
2965  SourceLocation RParenOrBraceLoc,
2966  bool ListInitialization) {
2967  return getSema().BuildCXXTypeConstructExpr(
2968  TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
2969  }
2970 
2971  /// Build a new object-construction expression.
2972  ///
2973  /// By default, performs semantic analysis to build the new expression.
2974  /// Subclasses may override this routine to provide different behavior.
2976  SourceLocation LParenLoc,
2977  MultiExprArg Args,
2978  SourceLocation RParenLoc,
2979  bool ListInitialization) {
2980  return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
2981  RParenLoc, ListInitialization);
2982  }
2983 
2984  /// Build a new member reference expression.
2985  ///
2986  /// By default, performs semantic analysis to build the new expression.
2987  /// Subclasses may override this routine to provide different behavior.
2989  QualType BaseType,
2990  bool IsArrow,
2991  SourceLocation OperatorLoc,
2992  NestedNameSpecifierLoc QualifierLoc,
2993  SourceLocation TemplateKWLoc,
2994  NamedDecl *FirstQualifierInScope,
2995  const DeclarationNameInfo &MemberNameInfo,
2996  const TemplateArgumentListInfo *TemplateArgs) {
2997  CXXScopeSpec SS;
2998  SS.Adopt(QualifierLoc);
2999 
3000  return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3001  OperatorLoc, IsArrow,
3002  SS, TemplateKWLoc,
3003  FirstQualifierInScope,
3004  MemberNameInfo,
3005  TemplateArgs, /*S*/nullptr);
3006  }
3007 
3008  /// Build a new member reference expression.
3009  ///
3010  /// By default, performs semantic analysis to build the new expression.
3011  /// Subclasses may override this routine to provide different behavior.
3013  SourceLocation OperatorLoc,
3014  bool IsArrow,
3015  NestedNameSpecifierLoc QualifierLoc,
3016  SourceLocation TemplateKWLoc,
3017  NamedDecl *FirstQualifierInScope,
3018  LookupResult &R,
3019  const TemplateArgumentListInfo *TemplateArgs) {
3020  CXXScopeSpec SS;
3021  SS.Adopt(QualifierLoc);
3022 
3023  return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3024  OperatorLoc, IsArrow,
3025  SS, TemplateKWLoc,
3026  FirstQualifierInScope,
3027  R, TemplateArgs, /*S*/nullptr);
3028  }
3029 
3030  /// Build a new noexcept expression.
3031  ///
3032  /// By default, performs semantic analysis to build the new expression.
3033  /// Subclasses may override this routine to provide different behavior.
3035  return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3036  }
3037 
3038  /// Build a new expression to compute the length of a parameter pack.
3040  NamedDecl *Pack,
3041  SourceLocation PackLoc,
3042  SourceLocation RParenLoc,
3043  Optional<unsigned> Length,
3044  ArrayRef<TemplateArgument> PartialArgs) {
3045  return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3046  RParenLoc, Length, PartialArgs);
3047  }
3048 
3049  /// Build a new expression representing a call to a source location
3050  /// builtin.
3051  ///
3052  /// By default, performs semantic analysis to build the new expression.
3053  /// Subclasses may override this routine to provide different behavior.
3055  SourceLocation BuiltinLoc,
3056  SourceLocation RPLoc,
3057  DeclContext *ParentContext) {
3058  return getSema().BuildSourceLocExpr(Kind, BuiltinLoc, RPLoc, ParentContext);
3059  }
3060 
3061  /// Build a new Objective-C boxed expression.
3062  ///
3063  /// By default, performs semantic analysis to build the new expression.
3064  /// Subclasses may override this routine to provide different behavior.
3066  SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3067  NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3068  TemplateArgumentListInfo *TALI) {
3069  CXXScopeSpec SS;
3070  SS.Adopt(NNS);
3071  ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3072  ConceptNameInfo,
3073  FoundDecl,
3074  NamedConcept, TALI);
3075  if (Result.isInvalid())
3076  return ExprError();
3077  return Result;
3078  }
3079 
3080  /// \brief Build a new requires expression.
3081  ///
3082  /// By default, performs semantic analysis to build the new expression.
3083  /// Subclasses may override this routine to provide different behavior.
3085  RequiresExprBodyDecl *Body,
3086  ArrayRef<ParmVarDecl *> LocalParameters,
3087  ArrayRef<concepts::Requirement *> Requirements,
3088  SourceLocation ClosingBraceLoc) {
3089  return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body,
3090  LocalParameters, Requirements, ClosingBraceLoc);
3091  }
3092 
3096  return SemaRef.BuildTypeRequirement(SubstDiag);
3097  }
3098 
3100  return SemaRef.BuildTypeRequirement(T);
3101  }
3102 
3105  concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3106  SourceLocation NoexceptLoc,
3108  return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3109  std::move(Ret));
3110  }
3111 
3113  RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3115  return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3116  std::move(Ret));
3117  }
3118 
3122  return SemaRef.BuildNestedRequirement(SubstDiag);
3123  }
3124 
3126  return SemaRef.BuildNestedRequirement(Constraint);
3127  }
3128 
3129  /// \brief Build a new Objective-C boxed expression.
3130  ///
3131  /// By default, performs semantic analysis to build the new expression.
3132  /// Subclasses may override this routine to provide different behavior.
3134  return getSema().BuildObjCBoxedExpr(SR, ValueExpr);
3135  }
3136 
3137  /// Build a new Objective-C array literal.
3138  ///
3139  /// By default, performs semantic analysis to build the new expression.
3140  /// Subclasses may override this routine to provide different behavior.
3142  Expr **Elements, unsigned NumElements) {
3143  return getSema().BuildObjCArrayLiteral(Range,
3144  MultiExprArg(Elements, NumElements));
3145  }
3146 
3148  Expr *Base, Expr *Key,
3149  ObjCMethodDecl *getterMethod,
3150  ObjCMethodDecl *setterMethod) {
3151  return getSema().BuildObjCSubscriptExpression(RB, Base, Key,
3152  getterMethod, setterMethod);
3153  }
3154 
3155  /// Build a new Objective-C dictionary literal.
3156  ///
3157  /// By default, performs semantic analysis to build the new expression.
3158  /// Subclasses may override this routine to provide different behavior.
3161  return getSema().BuildObjCDictionaryLiteral(Range, Elements);
3162  }
3163 
3164  /// Build a new Objective-C \@encode expression.
3165  ///
3166  /// By default, performs semantic analysis to build the new expression.
3167  /// Subclasses may override this routine to provide different behavior.
3169  TypeSourceInfo *EncodeTypeInfo,
3170  SourceLocation RParenLoc) {
3171  return SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo, RParenLoc);
3172  }
3173 
3174  /// Build a new Objective-C class message.
3176  Selector Sel,
3177  ArrayRef<SourceLocation> SelectorLocs,
3178  ObjCMethodDecl *Method,
3179  SourceLocation LBracLoc,
3180  MultiExprArg Args,
3181  SourceLocation RBracLoc) {
3182  return SemaRef.BuildClassMessage(ReceiverTypeInfo,
3183  ReceiverTypeInfo->getType(),
3184  /*SuperLoc=*/SourceLocation(),
3185  Sel, Method, LBracLoc, SelectorLocs,
3186  RBracLoc, Args);
3187  }
3188 
3189  /// Build a new Objective-C instance message.
3191  Selector Sel,
3192  ArrayRef<SourceLocation> SelectorLocs,
3193  ObjCMethodDecl *Method,
3194  SourceLocation LBracLoc,
3195  MultiExprArg Args,
3196  SourceLocation RBracLoc) {
3197  return SemaRef.BuildInstanceMessage(Receiver,
3198  Receiver->getType(),
3199  /*SuperLoc=*/SourceLocation(),
3200  Sel, Method, LBracLoc, SelectorLocs,
3201  RBracLoc, Args);
3202  }
3203 
3204  /// Build a new Objective-C instance/class message to 'super'.
3206  Selector Sel,
3207  ArrayRef<SourceLocation> SelectorLocs,
3208  QualType SuperType,
3209  ObjCMethodDecl *Method,
3210  SourceLocation LBracLoc,
3211  MultiExprArg Args,
3212  SourceLocation RBracLoc) {
3213  return Method->isInstanceMethod() ? SemaRef.BuildInstanceMessage(nullptr,
3214  SuperType,
3215  SuperLoc,
3216  Sel, Method, LBracLoc, SelectorLocs,
3217  RBracLoc, Args)
3218  : SemaRef.BuildClassMessage(nullptr,
3219  SuperType,
3220  SuperLoc,
3221  Sel, Method, LBracLoc, SelectorLocs,
3222  RBracLoc, Args);
3223 
3224 
3225  }
3226 
3227  /// Build a new Objective-C ivar reference expression.
3228  ///
3229  /// By default, performs semantic analysis to build the new expression.
3230  /// Subclasses may override this routine to provide different behavior.
3232  SourceLocation IvarLoc,
3233  bool IsArrow, bool IsFreeIvar) {
3234  CXXScopeSpec SS;
3235  DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3236  ExprResult Result = getSema().BuildMemberReferenceExpr(
3237  BaseArg, BaseArg->getType(),
3238  /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3239  /*FirstQualifierInScope=*/nullptr, NameInfo,
3240  /*TemplateArgs=*/nullptr,
3241  /*S=*/nullptr);
3242  if (IsFreeIvar && Result.isUsable())
3243  cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3244  return Result;
3245  }
3246 
3247  /// Build a new Objective-C property reference expression.
3248  ///
3249  /// By default, performs semantic analysis to build the new expression.
3250  /// Subclasses may override this routine to provide different behavior.
3252  ObjCPropertyDecl *Property,
3253  SourceLocation PropertyLoc) {
3254  CXXScopeSpec SS;
3255  DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3256  return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3257  /*FIXME:*/PropertyLoc,
3258  /*IsArrow=*/false,
3259  SS, SourceLocation(),
3260  /*FirstQualifierInScope=*/nullptr,
3261  NameInfo,
3262  /*TemplateArgs=*/nullptr,
3263  /*S=*/nullptr);
3264  }
3265 
3266  /// Build a new Objective-C property reference expression.
3267  ///
3268  /// By default, performs semantic analysis to build the new expression.
3269  /// Subclasses may override this routine to provide different behavior.
3271  ObjCMethodDecl *Getter,
3272  ObjCMethodDecl *Setter,
3273  SourceLocation PropertyLoc) {
3274  // Since these expressions can only be value-dependent, we do not
3275  // need to perform semantic analysis again.
3276  return Owned(
3277  new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3279  PropertyLoc, Base));
3280  }
3281 
3282  /// Build a new Objective-C "isa" expression.
3283  ///
3284  /// By default, performs semantic analysis to build the new expression.
3285  /// Subclasses may override this routine to provide different behavior.
3287  SourceLocation OpLoc, bool IsArrow) {
3288  CXXScopeSpec SS;
3289  DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
3290  return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3291  OpLoc, IsArrow,
3292  SS, SourceLocation(),
3293  /*FirstQualifierInScope=*/nullptr,
3294  NameInfo,
3295  /*TemplateArgs=*/nullptr,
3296  /*S=*/nullptr);
3297  }
3298 
3299  /// Build a new shuffle vector expression.
3300  ///
3301  /// By default, performs semantic analysis to build the new expression.
3302  /// Subclasses may override this routine to provide different behavior.
3304  MultiExprArg SubExprs,
3305  SourceLocation RParenLoc) {
3306  // Find the declaration for __builtin_shufflevector
3307  const IdentifierInfo &Name
3308  = SemaRef.Context.Idents.get("__builtin_shufflevector");
3310  DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
3311  assert(!Lookup.empty() && "No __builtin_shufflevector?");
3312 
3313  // Build a reference to the __builtin_shufflevector builtin
3314  FunctionDecl *Builtin = cast<FunctionDecl>(Lookup.front());
3315  Expr *Callee = new (SemaRef.Context)
3316  DeclRefExpr(SemaRef.Context, Builtin, false,
3317  SemaRef.Context.BuiltinFnTy, VK_RValue, BuiltinLoc);
3318  QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
3319  Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
3320  CK_BuiltinFnToFnPtr).get();
3321 
3322  // Build the CallExpr
3323  ExprResult TheCall = CallExpr::Create(
3324  SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
3325  Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc);
3326 
3327  // Type-check the __builtin_shufflevector expression.
3328  return SemaRef.SemaBuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
3329  }
3330 
3331  /// Build a new convert vector expression.
3333  Expr *SrcExpr, TypeSourceInfo *DstTInfo,
3334  SourceLocation RParenLoc) {
3335  return SemaRef.SemaConvertVectorExpr(SrcExpr, DstTInfo,
3336  BuiltinLoc, RParenLoc);
3337  }
3338 
3339  /// Build a new template argument pack expansion.
3340  ///
3341  /// By default, performs semantic analysis to build a new pack expansion
3342  /// for a template argument. Subclasses may override this routine to provide
3343  /// different behavior.
3345  SourceLocation EllipsisLoc,
3346  Optional<unsigned> NumExpansions) {
3347  switch (Pattern.getArgument().getKind()) {
3348  case TemplateArgument::Expression: {
3349  ExprResult Result
3350  = getSema().CheckPackExpansion(Pattern.getSourceExpression(),
3351  EllipsisLoc, NumExpansions);
3352  if (Result.isInvalid())
3353  return TemplateArgumentLoc();
3354 
3355  return TemplateArgumentLoc(Result.get(), Result.get());
3356  }
3357 
3358  case TemplateArgument::Template:
3360  Pattern.getArgument().getAsTemplate(),
3361  NumExpansions),
3362  Pattern.getTemplateQualifierLoc(),
3363  Pattern.getTemplateNameLoc(),
3364  EllipsisLoc);
3365 
3367  case TemplateArgument::Integral:
3368  case TemplateArgument::Declaration:
3369  case TemplateArgument::Pack:
3370  case TemplateArgument::TemplateExpansion:
3371  case TemplateArgument::NullPtr:
3372  llvm_unreachable("Pack expansion pattern has no parameter packs");
3373 
3375  if (TypeSourceInfo *Expansion
3376  = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
3377  EllipsisLoc,
3378  NumExpansions))
3379  return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
3380  Expansion);
3381  break;
3382  }
3383 
3384  return TemplateArgumentLoc();
3385  }
3386 
3387  /// Build a new expression pack expansion.
3388  ///
3389  /// By default, performs semantic analysis to build a new pack expansion
3390  /// for an expression. Subclasses may override this routine to provide
3391  /// different behavior.
3393  Optional<unsigned> NumExpansions) {
3394  return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
3395  }
3396 
3397  /// Build a new C++1z fold-expression.
3398  ///
3399  /// By default, performs semantic analysis in order to build a new fold
3400  /// expression.
3402  BinaryOperatorKind Operator,
3403  SourceLocation EllipsisLoc, Expr *RHS,
3404  SourceLocation RParenLoc,
3405  Optional<unsigned> NumExpansions) {
3406  return getSema().BuildCXXFoldExpr(LParenLoc, LHS, Operator, EllipsisLoc,
3407  RHS, RParenLoc, NumExpansions);
3408  }
3409 
3410  /// Build an empty C++1z fold-expression with the given operator.
3411  ///
3412  /// By default, produces the fallback value for the fold-expression, or
3413  /// produce an error if there is no fallback value.
3415  BinaryOperatorKind Operator) {
3416  return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
3417  }
3418 
3419  /// Build a new atomic operation expression.
3420  ///
3421  /// By default, performs semantic analysis to build the new expression.
3422  /// Subclasses may override this routine to provide different behavior.
3425  SourceLocation RParenLoc) {
3426  // Use this for all of the locations, since we don't know the difference
3427  // between the call and the expr at this point.
3428  SourceRange Range{BuiltinLoc, RParenLoc};
3429  return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
3430  Sema::AtomicArgumentOrder::AST);
3431  }
3432 
3433 private:
3434  TypeLoc TransformTypeInObjectScope(TypeLoc TL,
3435  QualType ObjectType,
3436  NamedDecl *FirstQualifierInScope,
3437  CXXScopeSpec &SS);
3438 
3439  TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
3440  QualType ObjectType,
3441  NamedDecl *FirstQualifierInScope,
3442  CXXScopeSpec &SS);
3443 
3444  TypeSourceInfo *TransformTSIInObjectScope(TypeLoc TL, QualType ObjectType,
3445  NamedDecl *FirstQualifierInScope,
3446  CXXScopeSpec &SS);
3447 
3448  QualType TransformDependentNameType(TypeLocBuilder &TLB,
3450  bool DeducibleTSTContext);
3451 };
3452 
3453 template <typename Derived>
3455  if (!S)
3456  return S;
3457 
3458  switch (S->getStmtClass()) {
3459  case Stmt::NoStmtClass: break;
3460 
3461  // Transform individual statement nodes
3462  // Pass SDK into statements that can produce a value
3463 #define STMT(Node, Parent) \
3464  case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
3465 #define VALUESTMT(Node, Parent) \
3466  case Stmt::Node##Class: \
3467  return getDerived().Transform##Node(cast<Node>(S), SDK);
3468 #define ABSTRACT_STMT(Node)
3469 #define EXPR(Node, Parent)
3470 #include "clang/AST/StmtNodes.inc"
3471 
3472  // Transform expressions by calling TransformExpr.
3473 #define STMT(Node, Parent)
3474 #define ABSTRACT_STMT(Stmt)
3475 #define EXPR(Node, Parent) case Stmt::Node##Class:
3476 #include "clang/AST/StmtNodes.inc"
3477  {
3478  ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
3479 
3480  if (SDK == SDK_StmtExprResult)
3481  E = getSema().ActOnStmtExprResult(E);
3482  return getSema().ActOnExprStmt(E, SDK == SDK_Discarded);
3483  }
3484  }
3485 
3486  return S;
3487 }
3488 
3489 template<typename Derived>
3491  if (!S)
3492  return S;
3493 
3494  switch (S->getClauseKind()) {
3495  default: break;
3496  // Transform individual clause nodes
3497 #define OPENMP_CLAUSE(Name, Class) \
3498  case OMPC_ ## Name : \
3499  return getDerived().Transform ## Class(cast<Class>(S));
3500 #include "clang/Basic/OpenMPKinds.def"
3501  }
3502 
3503  return S;
3504 }
3505 
3506 
3507 template<typename Derived>
3509  if (!E)
3510  return E;
3511 
3512  switch (E->getStmtClass()) {
3513  case Stmt::NoStmtClass: break;
3514 #define STMT(Node, Parent) case Stmt::Node##Class: break;
3515 #define ABSTRACT_STMT(Stmt)
3516 #define EXPR(Node, Parent) \
3517  case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
3518 #include "clang/AST/StmtNodes.inc"
3519  }
3520 
3521  return E;
3522 }
3523 
3524 template<typename Derived>
3526  bool NotCopyInit) {
3527  // Initializers are instantiated like expressions, except that various outer
3528  // layers are stripped.
3529  if (!Init)
3530  return Init;
3531 
3532  if (auto *FE = dyn_cast<FullExpr>(Init))
3533  Init = FE->getSubExpr();
3534 
3535  if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init))
3536  Init = AIL->getCommonExpr();
3537 
3538  if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
3539  Init = MTE->getSubExpr();
3540 
3541  while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
3542  Init = Binder->getSubExpr();
3543 
3544  if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
3545  Init = ICE->getSubExprAsWritten();
3546 
3547  if (CXXStdInitializerListExpr *ILE =
3548  dyn_cast<CXXStdInitializerListExpr>(Init))
3549  return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
3550 
3551  // If this is copy-initialization, we only need to reconstruct
3552  // InitListExprs. Other forms of copy-initialization will be a no-op if
3553  // the initializer is already the right type.
3554  CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
3555  if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
3556  return getDerived().TransformExpr(Init);
3557 
3558  // Revert value-initialization back to empty parens.
3559  if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
3560  SourceRange Parens = VIE->getSourceRange();
3561  return getDerived().RebuildParenListExpr(Parens.getBegin(), None,
3562  Parens.getEnd());
3563  }
3564 
3565  // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
3566  if (isa<ImplicitValueInitExpr>(Init))
3567  return getDerived().RebuildParenListExpr(SourceLocation(), None,
3568  SourceLocation());
3569 
3570  // Revert initialization by constructor back to a parenthesized or braced list
3571  // of expressions. Any other form of initializer can just be reused directly.
3572  if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
3573  return getDerived().TransformExpr(Init);
3574 
3575  // If the initialization implicitly converted an initializer list to a
3576  // std::initializer_list object, unwrap the std::initializer_list too.
3577  if (Construct && Construct->isStdInitListInitialization())
3578  return TransformInitializer(Construct->getArg(0), NotCopyInit);
3579 
3580  // Enter a list-init context if this was list initialization.
3582  getSema(), EnterExpressionEvaluationContext::InitList,
3583  Construct->isListInitialization());
3584 
3585  SmallVector<Expr*, 8> NewArgs;
3586  bool ArgChanged = false;
3587  if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
3588  /*IsCall*/true, NewArgs, &ArgChanged))
3589  return ExprError();
3590 
3591  // If this was list initialization, revert to syntactic list form.
3592  if (Construct->isListInitialization())
3593  return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
3594  Construct->getEndLoc());
3595 
3596  // Build a ParenListExpr to represent anything else.
3597  SourceRange Parens = Construct->getParenOrBraceRange();
3598  if (Parens.isInvalid()) {
3599  // This was a variable declaration's initialization for which no initializer
3600  // was specified.
3601  assert(NewArgs.empty() &&
3602  "no parens or braces but have direct init with arguments?");
3603  return ExprEmpty();
3604  }
3605  return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
3606  Parens.getEnd());
3607 }
3608 
3609 template<typename Derived>
3611  unsigned NumInputs,
3612  bool IsCall,
3613  SmallVectorImpl<Expr *> &Outputs,
3614  bool *ArgChanged) {
3615  for (unsigned I = 0; I != NumInputs; ++I) {
3616  // If requested, drop call arguments that need to be dropped.
3617  if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
3618  if (ArgChanged)
3619  *ArgChanged = true;
3620 
3621  break;
3622  }
3623 
3624  if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
3625  Expr *Pattern = Expansion->getPattern();
3626 
3628  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
3629  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
3630 
3631  // Determine whether the set of unexpanded parameter packs can and should
3632  // be expanded.
3633  bool Expand = true;
3634  bool RetainExpansion = false;
3635  Optional<unsigned> OrigNumExpansions = Expansion->getNumExpansions();
3636  Optional<unsigned> NumExpansions = OrigNumExpansions;
3637  if (getDerived().TryExpandParameterPacks(Expansion->getEllipsisLoc(),
3638  Pattern->getSourceRange(),
3639  Unexpanded,
3640  Expand, RetainExpansion,
3641  NumExpansions))
3642  return true;
3643 
3644  if (!Expand) {
3645  // The transform has determined that we should perform a simple
3646  // transformation on the pack expansion, producing another pack
3647  // expansion.
3648  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
3649  ExprResult OutPattern = getDerived().TransformExpr(Pattern);
3650  if (OutPattern.isInvalid())
3651  return true;
3652 
3653  ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
3654  Expansion->getEllipsisLoc(),
3655  NumExpansions);
3656  if (Out.isInvalid())
3657  return true;
3658 
3659  if (ArgChanged)
3660  *ArgChanged = true;
3661  Outputs.push_back(Out.get());
3662  continue;
3663  }
3664 
3665  // Record right away that the argument was changed. This needs
3666  // to happen even if the array expands to nothing.
3667  if (ArgChanged) *ArgChanged = true;
3668 
3669  // The transform has determined that we should perform an elementwise
3670  // expansion of the pattern. Do so.
3671  for (unsigned I = 0; I != *NumExpansions; ++I) {
3672  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
3673  ExprResult Out = getDerived().TransformExpr(Pattern);
3674  if (Out.isInvalid())
3675  return true;
3676 
3677  if (Out.get()->containsUnexpandedParameterPack()) {
3678  Out = getDerived().RebuildPackExpansion(
3679  Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
3680  if (Out.isInvalid())
3681  return true;
3682  }
3683 
3684  Outputs.push_back(Out.get());
3685  }
3686 
3687  // If we're supposed to retain a pack expansion, do so by temporarily
3688  // forgetting the partially-substituted parameter pack.
3689  if (RetainExpansion) {
3690  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
3691 
3692  ExprResult Out = getDerived().TransformExpr(Pattern);
3693  if (Out.isInvalid())
3694  return true;
3695 
3696  Out = getDerived().RebuildPackExpansion(
3697  Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
3698  if (Out.isInvalid())
3699  return true;
3700 
3701  Outputs.push_back(Out.get());
3702  }
3703 
3704  continue;
3705  }
3706 
3707  ExprResult Result =
3708  IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
3709  : getDerived().TransformExpr(Inputs[I]);
3710  if (Result.isInvalid())
3711  return true;
3712 
3713  if (Result.get() != Inputs[I] && ArgChanged)
3714  *ArgChanged = true;
3715 
3716  Outputs.push_back(Result.get());
3717  }
3718 
3719  return false;
3720 }
3721 
3722 template <typename Derived>
3725  if (Var) {
3726  VarDecl *ConditionVar = cast_or_null<VarDecl>(
3727  getDerived().TransformDefinition(Var->getLocation(), Var));
3728 
3729  if (!ConditionVar)
3730  return Sema::ConditionError();
3731 
3732  return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
3733  }
3734 
3735  if (Expr) {
3736  ExprResult CondExpr = getDerived().TransformExpr(Expr);
3737 
3738  if (CondExpr.isInvalid())
3739  return Sema::ConditionError();
3740 
3741  return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind);
3742  }
3743 
3744  return Sema::ConditionResult();
3745 }
3746 
3747 template<typename Derived>
3751  QualType ObjectType,
3752  NamedDecl *FirstQualifierInScope) {
3754  for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
3755  Qualifier = Qualifier.getPrefix())
3756  Qualifiers.push_back(Qualifier);
3757 
3758  CXXScopeSpec SS;
3759  while (!Qualifiers.empty()) {
3760  NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
3762 
3763  switch (QNNS->getKind()) {
3766  Q.getLocalBeginLoc(), Q.getLocalEndLoc(), ObjectType);
3767  if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo, false,
3768  SS, FirstQualifierInScope, false))
3769  return NestedNameSpecifierLoc();
3770  }
3771  break;
3772 
3773  case NestedNameSpecifier::Namespace: {
3774  NamespaceDecl *NS
3775  = cast_or_null<NamespaceDecl>(
3776  getDerived().TransformDecl(
3777  Q.getLocalBeginLoc(),
3778  QNNS->getAsNamespace()));
3779  SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
3780  break;
3781  }
3782 
3783  case NestedNameSpecifier::NamespaceAlias: {
3784  NamespaceAliasDecl *Alias
3785  = cast_or_null<NamespaceAliasDecl>(
3786  getDerived().TransformDecl(Q.getLocalBeginLoc(),
3787  QNNS->getAsNamespaceAlias()));
3788  SS.Extend(SemaRef.Context, Alias, Q.getLocalBeginLoc(),
3789  Q.getLocalEndLoc());
3790  break;
3791  }
3792 
3793  case NestedNameSpecifier::Global:
3794  // There is no meaningful transformation that one could perform on the
3795  // global scope.
3796  SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
3797  break;
3798 
3799  case NestedNameSpecifier::Super: {
3800  CXXRecordDecl *RD =
3801  cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
3802  SourceLocation(), QNNS->getAsRecordDecl()));
3803  SS.MakeSuper(SemaRef.Context, RD, Q.getBeginLoc(), Q.getEndLoc());
3804  break;
3805  }
3806 
3807  case NestedNameSpecifier::TypeSpecWithTemplate:
3808  case NestedNameSpecifier::TypeSpec: {
3809  TypeLoc TL = TransformTypeInObjectScope(Q.getTypeLoc(), ObjectType,
3810  FirstQualifierInScope, SS);
3811 
3812  if (!TL)
3813  return NestedNameSpecifierLoc();
3814 
3815  if (TL.getType()->isDependentType() || TL.getType()->isRecordType() ||
3816  (SemaRef.getLangOpts().CPlusPlus11 &&
3817  TL.getType()->isEnumeralType())) {
3818  assert(!TL.getType().hasLocalQualifiers() &&
3819  "Can't get cv-qualifiers here");
3820  if (TL.getType()->isEnumeralType())
3821  SemaRef.Diag(TL.getBeginLoc(),
3822  diag::warn_cxx98_compat_enum_nested_name_spec);
3823  SS.Extend(SemaRef.Context, /*FIXME:*/SourceLocation(), TL,
3824  Q.getLocalEndLoc());
3825  break;
3826  }
3827  // If the nested-name-specifier is an invalid type def, don't emit an
3828  // error because a previous error should have already been emitted.
3829  TypedefTypeLoc TTL = TL.getAs<TypedefTypeLoc>();
3830  if (!TTL || !TTL.getTypedefNameDecl()->isInvalidDecl()) {
3831  SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
3832  << TL.getType() << SS.getRange();
3833  }
3834  return NestedNameSpecifierLoc();
3835  }
3836  }
3837 
3838  // The qualifier-in-scope and object type only apply to the leftmost entity.
3839  FirstQualifierInScope = nullptr;
3840  ObjectType = QualType();
3841  }
3842 
3843  // Don't rebuild the nested-name-specifier if we don't have to.
3844  if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
3845  !getDerived().AlwaysRebuild())
3846  return NNS;
3847 
3848  // If we can re-use the source-location data from the original
3849  // nested-name-specifier, do so.
3850  if (SS.location_size() == NNS.getDataLength() &&
3851  memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
3852  return NestedNameSpecifierLoc(SS.getScopeRep(), NNS.getOpaqueData());
3853 
3854  // Allocate new nested-name-specifier location information.
3855  return SS.getWithLocInContext(SemaRef.Context);
3856 }
3857 
3858 template<typename Derived>
3862  DeclarationName Name = NameInfo.getName();
3863  if (!Name)
3864  return DeclarationNameInfo();
3865 
3866  switch (Name.getNameKind()) {
3868  case DeclarationName::ObjCZeroArgSelector:
3869  case DeclarationName::ObjCOneArgSelector:
3870  case DeclarationName::ObjCMultiArgSelector:
3871  case DeclarationName::CXXOperatorName:
3872  case DeclarationName::CXXLiteralOperatorName:
3873  case DeclarationName::CXXUsingDirective:
3874  return NameInfo;
3875 
3876  case DeclarationName::CXXDeductionGuideName: {
3877  TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
3878  TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
3879  getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
3880  if (!NewTemplate)
3881  return DeclarationNameInfo();
3882 
3883  DeclarationNameInfo NewNameInfo(NameInfo);
3884  NewNameInfo.setName(
3885  SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
3886  return NewNameInfo;
3887  }
3888 
3889  case DeclarationName::CXXConstructorName:
3890  case DeclarationName::CXXDestructorName:
3891  case DeclarationName::CXXConversionFunctionName: {
3892  TypeSourceInfo *NewTInfo;
3893  CanQualType NewCanTy;
3894  if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
3895  NewTInfo = getDerived().TransformType(OldTInfo);
3896  if (!NewTInfo)
3897  return DeclarationNameInfo();
3898  NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
3899  }
3900  else {
3901  NewTInfo = nullptr;
3902  TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
3903  QualType NewT = getDerived().TransformType(Name.getCXXNameType());
3904  if (NewT.isNull())
3905  return DeclarationNameInfo();
3906  NewCanTy = SemaRef.Context.getCanonicalType(NewT);
3907  }
3908 
3909  DeclarationName NewName
3910  = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
3911  NewCanTy);
3912  DeclarationNameInfo NewNameInfo(NameInfo);
3913  NewNameInfo.setName(NewName);
3914  NewNameInfo.setNamedTypeInfo(NewTInfo);
3915  return NewNameInfo;
3916  }
3917  }
3918 
3919  llvm_unreachable("Unknown name kind.");
3920 }
3921 
3922 template<typename Derived>
3925  TemplateName Name,
3926  SourceLocation NameLoc,
3927  QualType ObjectType,
3928  NamedDecl *FirstQualifierInScope,
3929  bool AllowInjectedClassName) {
3931  TemplateDecl *Template = QTN->getTemplateDecl();
3932  assert(Template && "qualified template name must refer to a template");
3933 
3934  TemplateDecl *TransTemplate
3935  = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
3936  Template));
3937  if (!TransTemplate)
3938  return TemplateName();
3939 
3940  if (!getDerived().AlwaysRebuild() &&
3941  SS.getScopeRep() == QTN->getQualifier() &&
3942  TransTemplate == Template)
3943  return Name;
3944 
3945  return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
3946  TransTemplate);
3947  }
3948 
3950  if (SS.getScopeRep()) {
3951  // These apply to the scope specifier, not the template.
3952  ObjectType = QualType();
3953  FirstQualifierInScope = nullptr;
3954  }
3955 
3956  if (!getDerived().AlwaysRebuild() &&
3957  SS.getScopeRep() == DTN->getQualifier() &&
3958  ObjectType.isNull())
3959  return Name;
3960 
3961  // FIXME: Preserve the location of the "template" keyword.
3962  SourceLocation TemplateKWLoc = NameLoc;
3963 
3964  if (DTN->isIdentifier()) {
3965  return getDerived().RebuildTemplateName(SS,
3966  TemplateKWLoc,
3967  *DTN->getIdentifier(),
3968  NameLoc,
3969  ObjectType,
3970  FirstQualifierInScope,
3971  AllowInjectedClassName);
3972  }
3973 
3974  return getDerived().RebuildTemplateName(SS, TemplateKWLoc,
3975  DTN->getOperator(), NameLoc,
3976  ObjectType, AllowInjectedClassName);
3977  }
3978 
3979  if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
3980  TemplateDecl *TransTemplate
3981  = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
3982  Template));
3983  if (!TransTemplate)
3984  return TemplateName();
3985 
3986  if (!getDerived().AlwaysRebuild() &&
3987  TransTemplate == Template)
3988  return Name;
3989 
3990  return TemplateName(TransTemplate);
3991  }
3992 
3995  TemplateTemplateParmDecl *TransParam
3996  = cast_or_null<TemplateTemplateParmDecl>(
3997  getDerived().TransformDecl(NameLoc, SubstPack->getParameterPack()));
3998  if (!TransParam)
3999  return TemplateName();
4000 
4001  if (!getDerived().AlwaysRebuild() &&
4002  TransParam == SubstPack->getParameterPack())
4003  return Name;
4004 
4005  return getDerived().RebuildTemplateName(TransParam,
4006  SubstPack->getArgumentPack());
4007  }
4008 
4009  // These should be getting filtered out before they reach the AST.
4010  llvm_unreachable("overloaded function decl survived to here");
4011 }
4012 
4013 template<typename Derived>
4015  const TemplateArgument &Arg,
4016  TemplateArgumentLoc &Output) {
4017  SourceLocation Loc = getDerived().getBaseLocation();
4018  switch (Arg.getKind()) {
4020  llvm_unreachable("null template argument in TreeTransform");
4021  break;
4022 
4024  Output = TemplateArgumentLoc(Arg,
4025  SemaRef.Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc));
4026 
4027  break;
4028 
4029  case TemplateArgument::Template:
4030  case TemplateArgument::TemplateExpansion: {
4033  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
4034  Builder.MakeTrivial(SemaRef.Context, DTN->getQualifier(), Loc);
4035  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
4036  Builder.MakeTrivial(SemaRef.Context, QTN->getQualifier(), Loc);
4037 
4038  if (Arg.getKind() == TemplateArgument::Template)
4039  Output = TemplateArgumentLoc(Arg,
4040  Builder.getWithLocInContext(SemaRef.Context),
4041  Loc);
4042  else
4043  Output = TemplateArgumentLoc(Arg,
4044  Builder.getWithLocInContext(SemaRef.Context),
4045  Loc, Loc);
4046 
4047  break;
4048  }
4049 
4050  case TemplateArgument::Expression:
4051  Output = TemplateArgumentLoc(Arg, Arg.getAsExpr());
4052  break;
4053 
4054  case TemplateArgument::Declaration:
4055  case TemplateArgument::Integral:
4056  case TemplateArgument::Pack:
4057  case TemplateArgument::NullPtr:
4059  break;
4060  }
4061 }
4062 
4063 template<typename Derived>
4065  const TemplateArgumentLoc &Input,
4066  TemplateArgumentLoc &Output, bool Uneval) {
4067  const TemplateArgument &Arg = Input.getArgument();
4068  switch (Arg.getKind()) {
4070  case TemplateArgument::Integral:
4071  case TemplateArgument::Pack:
4072  case TemplateArgument::Declaration:
4073  case TemplateArgument::NullPtr:
4074  llvm_unreachable("Unexpected TemplateArgument");
4075 
4076  case TemplateArgument::Type: {
4077  TypeSourceInfo *DI = Input.getTypeSourceInfo();
4078  if (!DI)
4079  DI = InventTypeSourceInfo(Input.getArgument().getAsType());
4080 
4081  DI = getDerived().TransformType(DI);
4082  if (!DI) return true;
4083 
4084  Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
4085  return false;
4086  }
4087 
4088  case TemplateArgument::Template: {
4089  NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
4090  if (QualifierLoc) {
4091  QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
4092  if (!QualifierLoc)
4093  return true;
4094  }
4095 
4096  CXXScopeSpec SS;
4097  SS.Adopt(QualifierLoc);
4098  TemplateName Template
4099  = getDerived().TransformTemplateName(SS, Arg.getAsTemplate(),
4100  Input.getTemplateNameLoc());
4101  if (Template.isNull())
4102  return true;
4103 
4104  Output = TemplateArgumentLoc(TemplateArgument(Template), QualifierLoc,
4105  Input.getTemplateNameLoc());
4106  return false;
4107  }
4108 
4109  case TemplateArgument::TemplateExpansion:
4110  llvm_unreachable("Caller should expand pack expansions");
4111 
4112  case TemplateArgument::Expression: {
4113  // Template argument expressions are constant expressions.
4115  getSema(),
4116  Uneval ? Sema::ExpressionEvaluationContext::Unevaluated
4117  : Sema::ExpressionEvaluationContext::ConstantEvaluated,
4118  /*LambdaContextDecl=*/nullptr, /*ExprContext=*/
4119  Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument);
4120 
4121  Expr *InputExpr = Input.getSourceExpression();
4122  if (!InputExpr) InputExpr = Input.getArgument().getAsExpr();
4123 
4124  ExprResult E = getDerived().TransformExpr(InputExpr);
4125  E = SemaRef.ActOnConstantExpression(E);
4126  if (E.isInvalid()) return true;
4127  Output = TemplateArgumentLoc(TemplateArgument(E.get()), E.get());
4128  return false;
4129  }
4130  }
4131 
4132  // Work around bogus GCC warning
4133  return true;
4134 }
4135 
4136 /// Iterator adaptor that invents template argument location information
4137 /// for each of the template arguments in its underlying iterator.
4138 template<typename Derived, typename InputIterator>
4140  TreeTransform<Derived> &Self;
4141  InputIterator Iter;
4142 
4143 public:
4146  typedef typename std::iterator_traits<InputIterator>::difference_type
4148  typedef std::input_iterator_tag iterator_category;
4149 
4150  class pointer {
4151  TemplateArgumentLoc Arg;
4152 
4153  public:
4154  explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
4155 
4156  const TemplateArgumentLoc *operator->() const { return &Arg; }
4157  };
4158 
4160 
4162  InputIterator Iter)
4163  : Self(Self), Iter(Iter) { }
4164 
4166  ++Iter;
4167  return *this;
4168  }
4169 
4172  ++(*this);
4173  return Old;
4174  }
4175 
4176  reference operator*() const {
4177  TemplateArgumentLoc Result;
4178  Self.InventTemplateArgumentLoc(*Iter, Result);
4179  return Result;
4180  }
4181 
4182  pointer operator->() const { return pointer(**this); }
4183 
4186  return X.Iter == Y.Iter;
4187  }
4188 
4191  return X.Iter != Y.Iter;
4192  }
4193 };
4194 
4195 template<typename Derived>
4196 template<typename InputIterator>
4198  InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
4199  bool Uneval) {
4200  for (; First != Last; ++First) {
4201  TemplateArgumentLoc Out;
4202  TemplateArgumentLoc In = *First;
4203 
4204  if (In.getArgument().getKind() == TemplateArgument::Pack) {
4205  // Unpack argument packs, which we translate them into separate
4206  // arguments.
4207  // FIXME: We could do much better if we could guarantee that the
4208  // TemplateArgumentLocInfo for the pack expansion would be usable for
4209  // all of the template arguments in the argument pack.
4210  typedef TemplateArgumentLocInventIterator<Derived,
4212  PackLocIterator;
4213  if (TransformTemplateArguments(PackLocIterator(*this,
4214  In.getArgument().pack_begin()),
4215  PackLocIterator(*this,
4216  In.getArgument().pack_end()),
4217  Outputs, Uneval))
4218  return true;
4219 
4220  continue;
4221  }
4222 
4223  if (In.getArgument().isPackExpansion()) {
4224  // We have a pack expansion, for which we will be substituting into
4225  // the pattern.
4226  SourceLocation Ellipsis;
4227  Optional<unsigned> OrigNumExpansions;
4228  TemplateArgumentLoc Pattern
4229  = getSema().getTemplateArgumentPackExpansionPattern(
4230  In, Ellipsis, OrigNumExpansions);
4231 
4233  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4234  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4235 
4236  // Determine whether the set of unexpanded parameter packs can and should
4237  // be expanded.
4238  bool Expand = true;
4239  bool RetainExpansion = false;
4240  Optional<unsigned> NumExpansions = OrigNumExpansions;
4241  if (getDerived().TryExpandParameterPacks(Ellipsis,
4242  Pattern.getSourceRange(),
4243  Unexpanded,
4244  Expand,
4245  RetainExpansion,
4246  NumExpansions))
4247  return true;
4248 
4249  if (!Expand) {
4250  // The transform has determined that we should perform a simple
4251  // transformation on the pack expansion, producing another pack
4252  // expansion.
4253  TemplateArgumentLoc OutPattern;
4254  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
4255  if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
4256  return true;
4257 
4258  Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis,
4259  NumExpansions);
4260  if (Out.getArgument().isNull())
4261  return true;
4262 
4263  Outputs.addArgument(Out);
4264  continue;
4265  }
4266 
4267  // The transform has determined that we should perform an elementwise
4268  // expansion of the pattern. Do so.
4269  for (unsigned I = 0; I != *NumExpansions; ++I) {
4270  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
4271 
4272  if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4273  return true;
4274 
4276  Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4277  OrigNumExpansions);
4278  if (Out.getArgument().isNull())
4279  return true;
4280  }
4281 
4282  Outputs.addArgument(Out);
4283  }
4284 
4285  // If we're supposed to retain a pack expansion, do so by temporarily
4286  // forgetting the partially-substituted parameter pack.
4287  if (RetainExpansion) {
4288  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4289 
4290  if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4291  return true;
4292 
4293  Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4294  OrigNumExpansions);
4295  if (Out.getArgument().isNull())
4296  return true;
4297 
4298  Outputs.addArgument(Out);
4299  }
4300 
4301  continue;
4302  }
4303 
4304  // The simple case:
4305  if (getDerived().TransformTemplateArgument(In, Out, Uneval))
4306  return true;
4307 
4308  Outputs.addArgument(Out);
4309  }
4310 
4311  return false;
4312 
4313 }
4314 
4315 //===----------------------------------------------------------------------===//
4316 // Type transformation
4317 //===----------------------------------------------------------------------===//
4318 
4319 template<typename Derived>
4321  if (getDerived().AlreadyTransformed(T))
4322  return T;
4323 
4324  // Temporary workaround. All of these transformations should
4325  // eventually turn into transformations on TypeLocs.
4326  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
4327  getDerived().getBaseLocation());
4328 
4329  TypeSourceInfo *NewDI = getDerived().TransformType(DI);
4330 
4331  if (!NewDI)
4332  return QualType();
4333 
4334  return NewDI->getType();
4335 }
4336 
4337 template<typename Derived>
4339  // Refine the base location to the type's location.
4340  TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
4341  getDerived().getBaseEntity());
4342  if (getDerived().AlreadyTransformed(DI->getType()))
4343  return DI;
4344 
4345  TypeLocBuilder TLB;
4346 
4347  TypeLoc TL = DI->getTypeLoc();
4348  TLB.reserve(TL.getFullDataSize());
4349 
4350  QualType Result = getDerived().TransformType(TLB, TL);
4351  if (Result.isNull())
4352  return nullptr;
4353 
4354  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4355 }
4356 
4357 template<typename Derived>
4358 QualType
4360  switch (T.getTypeLocClass()) {
4361 #define ABSTRACT_TYPELOC(CLASS, PARENT)
4362 #define TYPELOC(CLASS, PARENT) \
4363  case TypeLoc::CLASS: \
4364  return getDerived().Transform##CLASS##Type(TLB, \
4365  T.castAs<CLASS##TypeLoc>());
4366 #include "clang/AST/TypeLocNodes.def"
4367  }
4368 
4369  llvm_unreachable("unhandled type loc!");
4370 }
4371 
4372 template<typename Derived>
4374  if (!isa<DependentNameType>(T))
4375  return TransformType(T);
4376 
4377  if (getDerived().AlreadyTransformed(T))
4378  return T;
4379  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
4380  getDerived().getBaseLocation());
4381  TypeSourceInfo *NewDI = getDerived().TransformTypeWithDeducedTST(DI);
4382  return NewDI ? NewDI->getType() : QualType();
4383 }
4384 
4385 template<typename Derived>
4388  if (!isa<DependentNameType>(DI->getType()))
4389  return TransformType(DI);
4390 
4391  // Refine the base location to the type's location.
4392  TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
4393  getDerived().getBaseEntity());
4394  if (getDerived().AlreadyTransformed(DI->getType()))
4395  return DI;
4396 
4397  TypeLocBuilder TLB;
4398 
4399  TypeLoc TL = DI->getTypeLoc();
4400  TLB.reserve(TL.getFullDataSize());
4401 
4402  auto QTL = TL.getAs<QualifiedTypeLoc>();
4403  if (QTL)
4404  TL = QTL.getUnqualifiedLoc();
4405 
4406  auto DNTL = TL.castAs<DependentNameTypeLoc>();
4407 
4408  QualType Result = getDerived().TransformDependentNameType(
4409  TLB, DNTL, /*DeducedTSTContext*/true);
4410  if (Result.isNull())
4411  return nullptr;
4412 
4413  if (QTL) {
4414  Result = getDerived().RebuildQualifiedType(Result, QTL);
4415  if (Result.isNull())
4416  return nullptr;
4417  TLB.TypeWasModifiedSafely(Result);
4418  }
4419 
4420  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4421 }
4422 
4423 template<typename Derived>
4424 QualType
4426  QualifiedTypeLoc T) {
4427  QualType Result = getDerived().TransformType(TLB, T.getUnqualifiedLoc());
4428  if (Result.isNull())
4429  return QualType();
4430 
4431  Result = getDerived().RebuildQualifiedType(Result, T);
4432 
4433  if (Result.isNull())
4434  return QualType();
4435 
4436  // RebuildQualifiedType might have updated the type, but not in a way
4437  // that invalidates the TypeLoc. (There's no location information for
4438  // qualifiers.)
4439  TLB.TypeWasModifiedSafely(Result);
4440 
4441  return Result;
4442 }
4443 
4444 template <typename Derived>
4446  QualifiedTypeLoc TL) {
4447 
4448  SourceLocation Loc = TL.getBeginLoc();
4449  Qualifiers Quals = TL.getType().getLocalQualifiers();
4450 
4451  if (((T.getAddressSpace() != LangAS::Default &&
4452  Quals.getAddressSpace() != LangAS::Default)) &&
4453  T.getAddressSpace() != Quals.getAddressSpace()) {
4454  SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
4455  << TL.getType() << T;
4456  return QualType();
4457  }
4458 
4459  // C++ [dcl.fct]p7:
4460  // [When] adding cv-qualifications on top of the function type [...] the
4461  // cv-qualifiers are ignored.
4462  if (T->isFunctionType()) {
4463  T = SemaRef.getASTContext().getAddrSpaceQualType(T,
4464  Quals.getAddressSpace());
4465  return T;
4466  }
4467 
4468  // C++ [dcl.ref]p1:
4469  // when the cv-qualifiers are introduced through the use of a typedef-name
4470  // or decltype-specifier [...] the cv-qualifiers are ignored.
4471  // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
4472  // applied to a reference type.
4473  if (T->isReferenceType()) {
4474  // The only qualifier that applies to a reference type is restrict.
4475  if (!Quals.hasRestrict())
4476  return T;
4477  Quals = Qualifiers::fromCVRMask(Qualifiers::Restrict);
4478  }
4479 
4480  // Suppress Objective-C lifetime qualifiers if they don't make sense for the
4481  // resulting type.
4482  if (Quals.hasObjCLifetime()) {
4483  if (!T->isObjCLifetimeType() && !T->isDependentType())
4484  Quals.removeObjCLifetime();
4485  else if (T.getObjCLifetime()) {
4486  // Objective-C ARC:
4487  // A lifetime qualifier applied to a substituted template parameter
4488  // overrides the lifetime qualifier from the template argument.
4489  const AutoType *AutoTy;
4490  if (const SubstTemplateTypeParmType *SubstTypeParam
4491  = dyn_cast<SubstTemplateTypeParmType>(T)) {
4492  QualType Replacement = SubstTypeParam->getReplacementType();
4493  Qualifiers Qs = Replacement.getQualifiers();
4494  Qs.removeObjCLifetime();
4495  Replacement = SemaRef.Context.getQualifiedType(
4496  Replacement.getUnqualifiedType(), Qs);
4497  T = SemaRef.Context.getSubstTemplateTypeParmType(
4498  SubstTypeParam->getReplacedParameter(), Replacement);
4499  } else if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
4500  // 'auto' types behave the same way as template parameters.
4501  QualType Deduced = AutoTy->getDeducedType();
4502  Qualifiers Qs = Deduced.getQualifiers();
4503  Qs.removeObjCLifetime();
4504  Deduced =
4505  SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
4506  T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
4507  AutoTy->isDependentType(),
4508  /*isPack=*/false,
4509  AutoTy->getTypeConstraintConcept(),
4510  AutoTy->getTypeConstraintArguments());
4511  } else {
4512  // Otherwise, complain about the addition of a qualifier to an
4513  // already-qualified type.
4514  // FIXME: Why is this check not in Sema::BuildQualifiedType?
4515  SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
4516  Quals.removeObjCLifetime();
4517  }
4518  }
4519  }
4520 
4521  return SemaRef.BuildQualifiedType(T, Loc, Quals);
4522 }
4523 
4524 template<typename Derived>
4525 TypeLoc
4527  QualType ObjectType,
4528  NamedDecl *UnqualLookup,
4529  CXXScopeSpec &SS) {
4530  if (getDerived().AlreadyTransformed(TL.getType()))
4531  return TL;
4532 
4533  TypeSourceInfo *TSI =
4534  TransformTSIInObjectScope(TL, ObjectType, UnqualLookup, SS);
4535  if (TSI)
4536  return TSI->getTypeLoc();
4537  return TypeLoc();
4538 }
4539 
4540 template<typename Derived>
4543  QualType ObjectType,
4544  NamedDecl *UnqualLookup,
4545  CXXScopeSpec &SS) {
4546  if (getDerived().AlreadyTransformed(TSInfo->getType()))
4547  return TSInfo;
4548 
4549  return TransformTSIInObjectScope(TSInfo->getTypeLoc(), ObjectType,
4550  UnqualLookup, SS);
4551 }
4552 
4553 template <typename Derived>
4555  TypeLoc TL, QualType ObjectType, NamedDecl *UnqualLookup,
4556  CXXScopeSpec &SS) {
4557  QualType T = TL.getType();
4558  assert(!getDerived().AlreadyTransformed(T));
4559 
4560  TypeLocBuilder TLB;
4561  QualType Result;
4562 
4563  if (isa<TemplateSpecializationType>(T)) {
4566 
4567  TemplateName Template = getDerived().TransformTemplateName(
4568  SS, SpecTL.getTypePtr()->getTemplateName(), SpecTL.getTemplateNameLoc(),
4569  ObjectType, UnqualLookup, /*AllowInjectedClassName*/true);
4570  if (Template.isNull())
4571  return nullptr;
4572 
4573  Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL,
4574  Template);
4575  } else if (isa<DependentTemplateSpecializationType>(T)) {
4578 
4579  TemplateName Template
4580  = getDerived().RebuildTemplateName(SS,
4581  SpecTL.getTemplateKeywordLoc(),
4582  *SpecTL.getTypePtr()->getIdentifier(),
4583  SpecTL.getTemplateNameLoc(),
4584  ObjectType, UnqualLookup,
4585  /*AllowInjectedClassName*/true);
4586  if (Template.isNull())
4587  return nullptr;
4588 
4589  Result = getDerived().TransformDependentTemplateSpecializationType(TLB,
4590  SpecTL,
4591  Template,
4592  SS);
4593  } else {
4594  // Nothing special needs to be done for these.
4595  Result = getDerived().TransformType(TLB, TL);
4596  }
4597 
4598  if (Result.isNull())
4599  return nullptr;
4600 
4601  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4602 }
4603 
4604 template <class TyLoc> static inline
4606  TyLoc NewT = TLB.push<TyLoc>(T.getType());
4607  NewT.setNameLoc(T.getNameLoc());
4608  return T.getType();
4609 }
4610 
4611 template<typename Derived>
4613  BuiltinTypeLoc T) {
4614  BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
4615  NewT.setBuiltinLoc(T.getBuiltinLoc());
4616  if (T.needsExtraLocalData())
4618  return T.getType();
4619 }
4620 
4621 template<typename Derived>
4623  ComplexTypeLoc T) {
4624  // FIXME: recurse?
4625  return TransformTypeSpecType(TLB, T);
4626 }
4627 
4628 template <typename Derived>
4630  AdjustedTypeLoc TL) {
4631  // Adjustments applied during transformation are handled elsewhere.
4632  return getDerived().TransformType(TLB, TL.getOriginalLoc());
4633 }
4634 
4635 template<typename Derived>
4637  DecayedTypeLoc TL) {
4638  QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
4639  if (OriginalType.isNull())
4640  return QualType();
4641 
4642  QualType Result = TL.getType();
4643  if (getDerived().AlwaysRebuild() ||
4644  OriginalType != TL.getOriginalLoc().getType())
4645  Result = SemaRef.Context.getDecayedType(OriginalType);
4646  TLB.push<DecayedTypeLoc>(Result);
4647  // Nothing to set for DecayedTypeLoc.
4648  return Result;
4649 }
4650 
4651 template<typename Derived>
4653  PointerTypeLoc TL) {
4654  QualType PointeeType
4655  = getDerived().TransformType(TLB, TL.getPointeeLoc());
4656  if (PointeeType.isNull())
4657  return QualType();
4658 
4659  QualType Result = TL.getType();
4660  if (PointeeType->getAs<ObjCObjectType>()) {
4661  // A dependent pointer type 'T *' has is being transformed such
4662  // that an Objective-C class type is being replaced for 'T'. The
4663  // resulting pointer type is an ObjCObjectPointerType, not a
4664  // PointerType.
4665  Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
4666 
4668  NewT.setStarLoc(TL.getStarLoc());
4669  return Result;
4670  }
4671 
4672  if (getDerived().AlwaysRebuild() ||
4673  PointeeType != TL.getPointeeLoc().getType()) {
4674  Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
4675  if (Result.isNull())
4676  return QualType();
4677  }
4678 
4679  // Objective-C ARC can add lifetime qualifiers to the type that we're
4680  // pointing to.
4681  TLB.TypeWasModifiedSafely(Result->getPointeeType());
4682 
4683  PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
4684  NewT.setSigilLoc(TL.getSigilLoc());
4685  return Result;
4686 }
4687 
4688 template<typename Derived>
4689 QualType
4691  BlockPointerTypeLoc TL) {
4692  QualType PointeeType
4693  = getDerived().TransformType(TLB, TL.getPointeeLoc());
4694  if (PointeeType.isNull())
4695  return QualType();
4696 
4697  QualType Result = TL.getType();
4698  if (getDerived().AlwaysRebuild() ||
4699  PointeeType != TL.getPointeeLoc().getType()) {
4700  Result = getDerived().RebuildBlockPointerType(PointeeType,
4701  TL.getSigilLoc());
4702  if (Result.isNull())
4703  return QualType();
4704  }
4705 
4706  BlockPointerTypeLoc NewT = TLB.push<BlockPointerTypeLoc>(Result);
4707  NewT.setSigilLoc(TL.getSigilLoc());
4708  return Result;
4709 }
4710 
4711 /// Transforms a reference type. Note that somewhat paradoxically we
4712 /// don't care whether the type itself is an l-value type or an r-value
4713 /// type; we only care if the type was *written* as an l-value type
4714 /// or an r-value type.
4715 template<typename Derived>
4716 QualType
4718  ReferenceTypeLoc TL) {
4719  const ReferenceType *T = TL.getTypePtr();
4720 
4721  // Note that this works with the pointee-as-written.
4722  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
4723  if (PointeeType.isNull())
4724  return QualType();
4725 
4726  QualType Result = TL.getType();
4727  if (getDerived().AlwaysRebuild() ||
4728  PointeeType != T->getPointeeTypeAsWritten()) {
4729  Result = getDerived().RebuildReferenceType(PointeeType,
4730  T->isSpelledAsLValue(),
4731  TL.getSigilLoc());
4732  if (Result.isNull())
4733  return QualType();
4734  }
4735 
4736  // Objective-C ARC can add lifetime qualifiers to the type that we're
4737  // referring to.
4740 
4741  // r-value references can be rebuilt as l-value references.
4742  ReferenceTypeLoc NewTL;
4743  if (isa<LValueReferenceType>(Result))
4744  NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
4745  else
4746  NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
4747  NewTL.setSigilLoc(TL.getSigilLoc());
4748 
4749  return Result;
4750 }
4751 
4752 template<typename Derived>
4753 QualType
4756  return TransformReferenceType(TLB, TL);
4757 }
4758 
4759 template<typename Derived>
4760 QualType
4763  return TransformReferenceType(TLB, TL);
4764 }
4765 
4766 template<typename Derived>
4767 QualType
4769  MemberPointerTypeLoc TL) {
4770  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
4771  if (PointeeType.isNull())
4772  return QualType();
4773 
4774  TypeSourceInfo* OldClsTInfo = TL.getClassTInfo();
4775  TypeSourceInfo *NewClsTInfo = nullptr;
4776  if (OldClsTInfo) {
4777  NewClsTInfo = getDerived().TransformType(OldClsTInfo);
4778  if (!NewClsTInfo)
4779  return QualType();
4780  }
4781 
4782  const MemberPointerType *T = TL.getTypePtr();
4783  QualType OldClsType = QualType(T->getClass(), 0);
4784  QualType NewClsType;
4785  if (NewClsTInfo)
4786  NewClsType = NewClsTInfo->getType();
4787  else {
4788  NewClsType = getDerived().TransformType(OldClsType);
4789  if (NewClsType.isNull())
4790  return QualType();
4791  }
4792 
4793  QualType Result = TL.getType();
4794  if (getDerived().AlwaysRebuild() ||
4795  PointeeType != T->getPointeeType() ||
4796  NewClsType != OldClsType) {
4797  Result = getDerived().RebuildMemberPointerType(PointeeType, NewClsType,
4798  TL.getStarLoc());
4799  if (Result.isNull())
4800  return QualType();
4801  }
4802 
4803  // If we had to adjust the pointee type when building a member pointer, make
4804  // sure to push TypeLoc info for it.
4805  const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
4806  if (MPT && PointeeType != MPT->getPointeeType()) {
4807  assert(isa<AdjustedType>(MPT->getPointeeType()));
4808  TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
4809  }
4810 
4811  MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(Result);
4812  NewTL.setSigilLoc(TL.getSigilLoc());
4813  NewTL.setClassTInfo(NewClsTInfo);
4814 
4815  return Result;
4816 }
4817 
4818 template<typename Derived>
4819 QualType
4821  ConstantArrayTypeLoc TL) {
4822  const ConstantArrayType *T = TL.getTypePtr();
4823  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4824  if (ElementType.isNull())
4825  return QualType();
4826 
4827  // Prefer the expression from the TypeLoc; the other may have been uniqued.
4828  Expr *OldSize = TL.getSizeExpr();
4829  if (!OldSize)
4830  OldSize = const_cast<Expr*>(T->getSizeExpr());
4831  Expr *NewSize = nullptr;
4832  if (OldSize) {
4834  SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
4835  NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
4836  NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
4837  }
4838 
4839  QualType Result = TL.getType();
4840  if (getDerived().AlwaysRebuild() ||
4841  ElementType != T->getElementType() ||
4842  (T->getSizeExpr() && NewSize != OldSize)) {
4843  Result = getDerived().RebuildConstantArrayType(ElementType,
4844  T->getSizeModifier(),
4845  T->getSize(), NewSize,
4847  TL.getBracketsRange());
4848  if (Result.isNull())
4849  return QualType();
4850  }
4851 
4852  // We might have either a ConstantArrayType or a VariableArrayType now:
4853  // a ConstantArrayType is allowed to have an element type which is a
4854  // VariableArrayType if the type is dependent. Fortunately, all array
4855  // types have the same location layout.
4856  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4857  NewTL.setLBracketLoc(TL.getLBracketLoc());
4858  NewTL.setRBracketLoc(TL.getRBracketLoc());
4859  NewTL.setSizeExpr(NewSize);
4860 
4861  return Result;
4862 }
4863 
4864 template<typename Derived>
4866  TypeLocBuilder &TLB,
4868  const IncompleteArrayType *T = TL.getTypePtr();
4869  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4870  if (ElementType.isNull())
4871  return QualType();
4872 
4873  QualType Result = TL.getType();
4874  if (getDerived().AlwaysRebuild() ||
4875  ElementType != T->getElementType()) {
4876  Result = getDerived().RebuildIncompleteArrayType(ElementType,
4877  T->getSizeModifier(),
4879  TL.getBracketsRange());
4880  if (Result.isNull())
4881  return QualType();
4882  }
4883 
4884  IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(Result);
4885  NewTL.setLBracketLoc(TL.getLBracketLoc());
4886  NewTL.setRBracketLoc(TL.getRBracketLoc());
4887  NewTL.setSizeExpr(nullptr);
4888 
4889  return Result;
4890 }
4891 
4892 template<typename Derived>
4893 QualType
4895  VariableArrayTypeLoc TL) {
4896  const VariableArrayType *T = TL.getTypePtr();
4897  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4898  if (ElementType.isNull())
4899  return QualType();
4900 
4901  ExprResult SizeResult;
4902  {
4904  SemaRef, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
4905  SizeResult = getDerived().TransformExpr(T->getSizeExpr());
4906  }
4907  if (SizeResult.isInvalid())
4908  return QualType();
4909  SizeResult =
4910  SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
4911  if (SizeResult.isInvalid())
4912  return QualType();
4913 
4914  Expr *Size = SizeResult.get();
4915 
4916  QualType Result = TL.getType();
4917  if (getDerived().AlwaysRebuild() ||
4918  ElementType != T->getElementType() ||
4919  Size != T->getSizeExpr()) {
4920  Result = getDerived().RebuildVariableArrayType(ElementType,
4921  T->getSizeModifier(),
4922  Size,
4924  TL.getBracketsRange());
4925  if (Result.isNull())
4926  return QualType();
4927  }
4928 
4929  // We might have constant size array now, but fortunately it has the same
4930  // location layout.
4931  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4932  NewTL.setLBracketLoc(TL.getLBracketLoc());
4933  NewTL.setRBracketLoc(TL.getRBracketLoc());
4934  NewTL.setSizeExpr(Size);
4935 
4936  return Result;
4937 }
4938 
4939 template<typename Derived>
4940 QualType
4943  const DependentSizedArrayType *T = TL.getTypePtr();
4944  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4945  if (ElementType.isNull())
4946  return QualType();
4947 
4948  // Array bounds are constant expressions.
4950  SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
4951 
4952  // Prefer the expression from the TypeLoc; the other may have been uniqued.
4953  Expr *origSize = TL.getSizeExpr();
4954  if (!origSize) origSize = T->getSizeExpr();
4955 
4956  ExprResult sizeResult
4957  = getDerived().TransformExpr(origSize);
4958  sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
4959  if (sizeResult.isInvalid())
4960  return QualType();
4961 
4962  Expr *size = sizeResult.get();
4963 
4964  QualType Result = TL.getType();
4965  if (getDerived().AlwaysRebuild() ||
4966  ElementType != T->getElementType() ||
4967  size != origSize) {
4968  Result = getDerived().RebuildDependentSizedArrayType(ElementType,
4969  T->getSizeModifier(),
4970  size,
4972  TL.getBracketsRange());
4973  if (Result.isNull())
4974  return QualType();
4975  }
4976 
4977  // We might have any sort of array type now, but fortunately they
4978  // all have the same location layout.
4979  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4980  NewTL.setLBracketLoc(TL.getLBracketLoc());
4981  NewTL.setRBracketLoc(TL.getRBracketLoc());
4982  NewTL.setSizeExpr(size);
4983 
4984  return Result;
4985 }
4986 
4987 template <typename Derived>
4990  const DependentVectorType *T = TL.getTypePtr();
4991  QualType ElementType = getDerived().TransformType(T->getElementType());
4992  if (ElementType.isNull())
4993  return QualType();
4994 
4996  SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
4997 
4998  ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
4999  Size = SemaRef.ActOnConstantExpression(Size);
5000  if (Size.isInvalid())
5001  return QualType();
5002 
5003  QualType Result = TL.getType();
5004  if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
5005  Size.get() != T->getSizeExpr()) {
5006  Result = getDerived().RebuildDependentVectorType(
5007  ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
5008  if (Result.isNull())
5009  return QualType();
5010  }
5011 
5012  // Result might be dependent or not.
5013  if (isa<DependentVectorType>(Result)) {
5014  DependentVectorTypeLoc NewTL =
5015  TLB.push<DependentVectorTypeLoc>(Result);
5016  NewTL.setNameLoc(TL.getNameLoc());
5017  } else {
5018  VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
5019  NewTL.setNameLoc(TL.getNameLoc());
5020  }
5021 
5022  return Result;
5023 }
5024 
5025 template<typename Derived>
5027  TypeLocBuilder &TLB,
5029  const DependentSizedExtVectorType *T = TL.getTypePtr();
5030 
5031  // FIXME: ext vector locs should be nested
5032  QualType ElementType = getDerived().TransformType(T->getElementType());
5033  if (ElementType.isNull())
5034  return QualType();
5035 
5036  // Vector sizes are constant expressions.
5038  SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
5039 
5040  ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
5041  Size = SemaRef.ActOnConstantExpression(Size);
5042  if (Size.isInvalid())
5043  return QualType();
5044 
5045  QualType Result = TL.getType();
5046  if (getDerived().AlwaysRebuild() ||
5047  ElementType != T->getElementType() ||
5048  Size.get() != T->getSizeExpr()) {
5049  Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
5050  Size.get(),
5051  T->getAttributeLoc());
5052  if (Result.isNull())
5053  return QualType();
5054  }
5055 
5056  // Result might be dependent or not.
5057  if (isa<DependentSizedExtVectorType>(Result)) {
5059  = TLB.push<DependentSizedExtVectorTypeLoc>(Result);
5060  NewTL.setNameLoc(TL.getNameLoc());
5061  } else {
5062  ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
5063  NewTL.setNameLoc(TL.getNameLoc());
5064  }
5065 
5066  return Result;
5067 }
5068 
5069 template <typename Derived>
5072  const DependentAddressSpaceType *T = TL.getTypePtr();
5073 
5074  QualType pointeeType = getDerived().TransformType(T->getPointeeType());
5075 
5076  if (pointeeType.isNull())
5077  return QualType();
5078 
5079  // Address spaces are constant expressions.
5081  SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
5082 
5083  ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
5084  AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
5085  if (AddrSpace.isInvalid())
5086  return QualType();
5087 
5088  QualType Result = TL.getType();
5089  if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
5090  AddrSpace.get() != T->getAddrSpaceExpr()) {
5091  Result = getDerived().RebuildDependentAddressSpaceType(
5092  pointeeType, AddrSpace.get(), T->getAttributeLoc());
5093  if (Result.isNull())
5094  return QualType();
5095  }
5096 
5097  // Result might be dependent or not.
5098  if (isa<DependentAddressSpaceType>(Result)) {
5100  TLB.push<DependentAddressSpaceTypeLoc>(Result);
5101 
5104  NewTL.setAttrNameLoc(TL.getAttrNameLoc());
5105 
5106  } else {
5107  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(
5108  Result, getDerived().getBaseLocation());
5109  TransformType(TLB, DI->getTypeLoc());
5110  }
5111 
5112  return Result;
5113 }
5114 
5115 template <typename Derived>
5117  VectorTypeLoc TL) {
5118  const VectorType *T = TL.getTypePtr();
5119  QualType ElementType = getDerived().TransformType(T->getElementType());
5120  if (ElementType.isNull())
5121  return QualType();
5122 
5123  QualType Result = TL.getType();
5124  if (getDerived().AlwaysRebuild() ||
5125  ElementType != T->getElementType()) {
5126  Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
5127  T->getVectorKind());
5128  if (Result.isNull())
5129  return QualType();
5130  }
5131 
5132  VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
5133  NewTL.setNameLoc(TL.getNameLoc());
5134 
5135  return Result;
5136 }
5137 
5138 template<typename Derived>
5140  ExtVectorTypeLoc TL) {
5141  const VectorType *T = TL.getTypePtr();
5142  QualType ElementType = getDerived().TransformType(T->getElementType());
5143  if (ElementType.isNull())
5144  return QualType();
5145 
5146  QualType Result = TL.getType();
5147  if (getDerived().AlwaysRebuild() ||
5148  ElementType != T->getElementType()) {
5149  Result = getDerived().RebuildExtVectorType(ElementType,
5150  T->getNumElements(),
5151  /*FIXME*/ SourceLocation());
5152  if (Result.isNull())
5153  return QualType();
5154  }
5155 
5156  ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
5157  NewTL.setNameLoc(TL.getNameLoc());
5158 
5159  return Result;
5160 }
5161 
5162 template <typename Derived>
5164  ParmVarDecl *OldParm, int indexAdjustment, Optional<unsigned> NumExpansions,
5165  bool ExpectParameterPack) {
5166  TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
5167  TypeSourceInfo *NewDI = nullptr;
5168 
5169  if (NumExpansions && isa<PackExpansionType>(OldDI->getType())) {
5170  // If we're substituting into a pack expansion type and we know the
5171  // length we want to expand to, just substitute for the pattern.
5172  TypeLoc OldTL = OldDI->getTypeLoc();
5173  PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
5174 
5175  TypeLocBuilder TLB;
5176  TypeLoc NewTL = OldDI->getTypeLoc();
5177  TLB.reserve(NewTL.getFullDataSize());
5178 
5179  QualType Result = getDerived().TransformType(TLB,
5180  OldExpansionTL.getPatternLoc());
5181  if (Result.isNull())
5182  return nullptr;
5183 
5184  Result = RebuildPackExpansionType(Result,
5185  OldExpansionTL.getPatternLoc().getSourceRange(),
5186  OldExpansionTL.getEllipsisLoc(),
5187  NumExpansions);
5188  if (Result.isNull())
5189  return nullptr;
5190 
5191  PackExpansionTypeLoc NewExpansionTL
5192  = TLB.push<PackExpansionTypeLoc>(Result);
5193  NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
5194  NewDI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
5195  } else
5196  NewDI = getDerived().TransformType(OldDI);
5197  if (!NewDI)
5198  return nullptr;
5199 
5200  if (NewDI == OldDI && indexAdjustment == 0)
5201  return OldParm;
5202 
5203  ParmVarDecl *newParm = ParmVarDecl::Create(SemaRef.Context,
5204  OldParm->getDeclContext(),
5205  OldParm->getInnerLocStart(),
5206  OldParm->getLocation(),
5207  OldParm->getIdentifier(),
5208  NewDI->getType(),
5209  NewDI,
5210  OldParm->getStorageClass(),
5211  /* DefArg */ nullptr);
5212  newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
5213  OldParm->getFunctionScopeIndex() + indexAdjustment);
5214  return newParm;
5215 }
5216 
5217 template <typename Derived>
5220  const QualType *ParamTypes,
5221  const FunctionProtoType::ExtParameterInfo *ParamInfos,
5222  SmallVectorImpl<QualType> &OutParamTypes,
5225  int indexAdjustment = 0;
5226 
5227  unsigned NumParams = Params.size();
5228  for (unsigned i = 0; i != NumParams; ++i) {
5229  if (ParmVarDecl *OldParm = Params[i]) {
5230  assert(OldParm->getFunctionScopeIndex() == i);
5231 
5232  Optional<unsigned> NumExpansions;
5233  ParmVarDecl *NewParm = nullptr;
5234  if (OldParm->isParameterPack()) {
5235  // We have a function parameter pack that may need to be expanded.
5237 
5238  // Find the parameter packs that could be expanded.
5239  TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
5240  PackExpansionTypeLoc ExpansionTL = TL.castAs<PackExpansionTypeLoc>();
5241  TypeLoc Pattern = ExpansionTL.getPatternLoc();
5242  SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
5243 
5244  // Determine whether we should expand the parameter packs.
5245  bool ShouldExpand = false;
5246  bool RetainExpansion = false;
5247  Optional<unsigned> OrigNumExpansions;
5248  if (Unexpanded.size() > 0) {
5249  OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
5250  NumExpansions = OrigNumExpansions;
5251  if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
5252  Pattern.getSourceRange(),
5253  Unexpanded,
5254  ShouldExpand,
5255  RetainExpansion,
5256  NumExpansions)) {
5257  return true;
5258  }
5259  } else {
5260 #ifndef NDEBUG
5261  const AutoType *AT =
5262  Pattern.getType().getTypePtr()->getContainedAutoType();
5263  assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
5264  "Could not find parameter packs or undeduced auto type!");
5265 #endif
5266  }
5267 
5268  if (ShouldExpand) {
5269  // Expand the function parameter pack into multiple, separate
5270  // parameters.
5271  getDerived().ExpandingFunctionParameterPack(OldParm);
5272  for (unsigned I = 0; I != *NumExpansions; ++I) {
5273  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
5274  ParmVarDecl *NewParm
5275  = getDerived().TransformFunctionTypeParam(OldParm,
5276  indexAdjustment++,
5277  OrigNumExpansions,
5278  /*ExpectParameterPack=*/false);
5279  if (!NewParm)
5280  return true;
5281 
5282  if (ParamInfos)
5283  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5284  OutParamTypes.push_back(NewParm->getType());
5285  if (PVars)
5286  PVars->push_back(NewParm);
5287  }
5288 
5289  // If we're supposed to retain a pack expansion, do so by temporarily
5290  // forgetting the partially-substituted parameter pack.
5291  if (RetainExpansion) {
5292  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5293  ParmVarDecl *NewParm
5294  = getDerived().TransformFunctionTypeParam(OldParm,
5295  indexAdjustment++,
5296  OrigNumExpansions,
5297  /*ExpectParameterPack=*/false);
5298  if (!NewParm)
5299  return true;
5300 
5301  if (ParamInfos)
5302  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5303  OutParamTypes.push_back(NewParm->getType());
5304  if (PVars)
5305  PVars->push_back(NewParm);
5306  }
5307 
5308  // The next parameter should have the same adjustment as the
5309  // last thing we pushed, but we post-incremented indexAdjustment
5310  // on every push. Also, if we push nothing, the adjustment should
5311  // go down by one.
5312  indexAdjustment--;
5313 
5314  // We're done with the pack expansion.
5315  continue;
5316  }
5317 
5318  // We'll substitute the parameter now without expanding the pack
5319  // expansion.
5320  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5321  NewParm = getDerived().TransformFunctionTypeParam(OldParm,
5322  indexAdjustment,
5323  NumExpansions,
5324  /*ExpectParameterPack=*/true);
5325  assert(NewParm->isParameterPack() &&
5326  "Parameter pack no longer a parameter pack after "
5327  "transformation.");
5328  } else {
5329  NewParm = getDerived().TransformFunctionTypeParam(
5330  OldParm, indexAdjustment, None, /*ExpectParameterPack=*/ false);
5331  }
5332 
5333  if (!NewParm)
5334  return true;
5335 
5336  if (ParamInfos)
5337  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5338  OutParamTypes.push_back(NewParm->getType());
5339  if (PVars)
5340  PVars->push_back(NewParm);
5341  continue;
5342  }
5343 
5344  // Deal with the possibility that we don't have a parameter
5345  // declaration for this parameter.
5346  QualType OldType = ParamTypes[i];
5347  bool IsPackExpansion = false;
5348  Optional<unsigned> NumExpansions;
5349  QualType NewType;
5350  if (const PackExpansionType *Expansion
5351  = dyn_cast<PackExpansionType>(OldType)) {
5352  // We have a function parameter pack that may need to be expanded.
5353  QualType Pattern = Expansion->getPattern();
5355  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5356 
5357  // Determine whether we should expand the parameter packs.
5358  bool ShouldExpand = false;
5359  bool RetainExpansion = false;
5360  if (getDerived().TryExpandParameterPacks(Loc, SourceRange(),
5361  Unexpanded,
5362  ShouldExpand,
5363  RetainExpansion,
5364  NumExpansions)) {
5365  return true;
5366  }
5367 
5368  if (ShouldExpand) {
5369  // Expand the function parameter pack into multiple, separate
5370  // parameters.
5371  for (unsigned I = 0; I != *NumExpansions; ++I) {
5372  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
5373  QualType NewType = getDerived().TransformType(Pattern);
5374  if (NewType.isNull())
5375  return true;
5376 
5377  if (NewType->containsUnexpandedParameterPack()) {
5378  NewType =
5379  getSema().getASTContext().getPackExpansionType(NewType, None);
5380 
5381  if (NewType.isNull())
5382  return true;
5383  }
5384 
5385  if (ParamInfos)
5386  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5387  OutParamTypes.push_back(NewType);
5388  if (PVars)
5389  PVars->push_back(nullptr);
5390  }
5391 
5392  // We're done with the pack expansion.
5393  continue;
5394  }
5395 
5396  // If we're supposed to retain a pack expansion, do so by temporarily
5397  // forgetting the partially-substituted parameter pack.
5398  if (RetainExpansion) {
5399  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5400  QualType NewType = getDerived().TransformType(Pattern);
5401  if (NewType.isNull())
5402  return true;
5403 
5404  if (ParamInfos)
5405  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5406  OutParamTypes.push_back(NewType);
5407  if (PVars)
5408  PVars->push_back(nullptr);
5409  }
5410 
5411  // We'll substitute the parameter now without expanding the pack
5412  // expansion.
5413  OldType = Expansion->getPattern();
5414  IsPackExpansion = true;
5415  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5416  NewType = getDerived().TransformType(OldType);
5417  } else {
5418  NewType = getDerived().TransformType(OldType);
5419  }
5420 
5421  if (NewType.isNull())
5422  return true;
5423 
5424  if (IsPackExpansion)
5425  NewType = getSema().Context.getPackExpansionType(NewType,
5426  NumExpansions);
5427 
5428  if (ParamInfos)
5429  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5430  OutParamTypes.push_back(NewType);
5431  if (PVars)
5432  PVars->push_back(nullptr);
5433  }
5434 
5435 #ifndef NDEBUG
5436  if (PVars) {
5437  for (unsigned i = 0, e = PVars->size(); i != e; ++i)
5438  if (ParmVarDecl *parm = (*PVars)[i])
5439  assert(parm->getFunctionScopeIndex() == i);
5440  }
5441 #endif
5442 
5443  return false;
5444 }
5445 
5446 template<typename Derived>
5447 QualType
5449  FunctionProtoTypeLoc TL) {
5450  SmallVector<QualType, 4> ExceptionStorage;
5451  TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
5452  return getDerived().TransformFunctionProtoType(
5453  TLB, TL, nullptr, Qualifiers(),
5454  [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
5455  return This->TransformExceptionSpec(TL.getBeginLoc(), ESI,
5456  ExceptionStorage, Changed);
5457  });
5458 }
5459 
5460 template<typename Derived> template<typename Fn>
5462  TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
5463  Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
5464 
5465  // Transform the parameters and return type.
5466  //
5467  // We are required to instantiate the params and return type in source order.
5468  // When the function has a trailing return type, we instantiate the
5469  // parameters before the return type, since the return type can then refer
5470  // to the parameters themselves (via decltype, sizeof, etc.).
5471  //
5472  SmallVector<QualType, 4> ParamTypes;
5473  SmallVector<ParmVarDecl*, 4> ParamDecls;
5474  Sema::ExtParameterInfoBuilder ExtParamInfos;
5475  const FunctionProtoType *T = TL.getTypePtr();
5476 
5477  QualType ResultType;
5478 
5479  if (T->hasTrailingReturn()) {
5480  if (getDerived().TransformFunctionTypeParams(
5481  TL.getBeginLoc(), TL.getParams(),
5482  TL.getTypePtr()->param_type_begin(),
5484  ParamTypes, &ParamDecls, ExtParamInfos))
5485  return QualType();
5486 
5487  {
5488  // C++11 [expr.prim.general]p3:
5489  // If a declaration declares a member function or member function
5490  // template of a class X, the expression this is a prvalue of type
5491  // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
5492  // and the end of the function-definition, member-declarator, or
5493  // declarator.
5494  Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, ThisTypeQuals);
5495 
5496  ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5497  if (ResultType.isNull())
5498  return QualType();
5499  }
5500  }
5501  else {
5502  ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5503  if (ResultType.isNull())
5504  return QualType();
5505 
5506  if (getDerived().TransformFunctionTypeParams(
5507  TL.getBeginLoc(), TL.getParams(),
5508  TL.getTypePtr()->param_type_begin(),
5510  ParamTypes, &ParamDecls, ExtParamInfos))
5511  return QualType();
5512  }
5513 
5515 
5516  bool EPIChanged = false;
5517  if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
5518  return QualType();
5519 
5520  // Handle extended parameter information.
5521  if (auto NewExtParamInfos =
5522  ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
5523  if (!EPI.ExtParameterInfos ||
5524  llvm::makeArrayRef(EPI.ExtParameterInfos, TL.getNumParams())
5525  != llvm::makeArrayRef(NewExtParamInfos, ParamTypes.size())) {
5526  EPIChanged = true;
5527  }
5528  EPI.ExtParameterInfos = NewExtParamInfos;
5529  } else if (EPI.ExtParameterInfos) {
5530  EPIChanged = true;
5531  EPI.ExtParameterInfos = nullptr;
5532  }
5533 
5534  QualType Result = TL.getType();
5535  if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
5536  T->getParamTypes() != llvm::makeArrayRef(ParamTypes) || EPIChanged) {
5537  Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
5538  if (Result.isNull())
5539  return QualType();
5540  }
5541 
5542  FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result);
5544  NewTL.setLParenLoc(TL.getLParenLoc());
5545  NewTL.setRParenLoc(TL.getRParenLoc());
5547  NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
5548  for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
5549  NewTL.setParam(i, ParamDecls[i]);
5550 
5551  return Result;
5552 }
5553 
5554 template<typename Derived>
5557  SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
5558  assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
5559 
5560  // Instantiate a dynamic noexcept expression, if any.
5561  if (isComputedNoexcept(ESI.Type)) {
5563  getSema(), Sema::ExpressionEvaluationContext::ConstantEvaluated);
5564  ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
5565  if (NoexceptExpr.isInvalid())
5566  return true;
5567 
5568  ExceptionSpecificationType EST = ESI.Type;
5569  NoexceptExpr =
5570  getSema().ActOnNoexceptSpec(Loc, NoexceptExpr.get(), EST);
5571  if (NoexceptExpr.isInvalid())
5572  return true;
5573 
5574  if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
5575  Changed = true;
5576  ESI.NoexceptExpr = NoexceptExpr.get();
5577  ESI.Type = EST;
5578  }
5579 
5580  if (ESI.Type != EST_Dynamic)
5581  return false;
5582 
5583  // Instantiate a dynamic exception specification's type.
5584  for (QualType T : ESI.Exceptions) {
5585  if (const PackExpansionType *PackExpansion =
5586  T->getAs<PackExpansionType>()) {
5587  Changed = true;
5588 
5589  // We have a pack expansion. Instantiate it.
5591  SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
5592  Unexpanded);
5593  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5594 
5595  // Determine whether the set of unexpanded parameter packs can and
5596  // should
5597  // be expanded.
5598  bool Expand = false;
5599  bool RetainExpansion = false;
5600  Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
5601  // FIXME: Track the location of the ellipsis (and track source location
5602  // information for the types in the exception specification in general).
5603  if (getDerived().TryExpandParameterPacks(
5604  Loc, SourceRange(), Unexpanded, Expand,
5605  RetainExpansion, NumExpansions))
5606  return true;
5607 
5608  if (!Expand) {
5609  // We can't expand this pack expansion into separate arguments yet;
5610  // just substitute into the pattern and create a new pack expansion
5611  // type.
5612  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5613  QualType U = getDerived().TransformType(PackExpansion->getPattern());
5614  if (U.isNull())
5615  return true;
5616 
5617  U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
5618  Exceptions.push_back(U);
5619  continue;
5620  }
5621 
5622  // Substitute into the pack expansion pattern for each slice of the
5623  // pack.
5624  for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
5625  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
5626 
5627  QualType U = getDerived().TransformType(PackExpansion->getPattern());
5628  if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
5629  return true;
5630 
5631  Exceptions.push_back(U);
5632  }
5633  } else {
5634  QualType U = getDerived().TransformType(T);
5635  if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
5636  return true;
5637  if (T != U)
5638  Changed = true;
5639 
5640  Exceptions.push_back(U);
5641  }
5642  }
5643 
5644  ESI.Exceptions = Exceptions;
5645  if (ESI.Exceptions.empty())
5646  ESI.Type = EST_DynamicNone;
5647  return false;
5648 }
5649 
5650 template<typename Derived>
5652  TypeLocBuilder &TLB,
5654  const FunctionNoProtoType *T = TL.getTypePtr();
5655  QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5656  if (ResultType.isNull())
5657  return QualType();
5658 
5659  QualType Result = TL.getType();
5660  if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
5661  Result = getDerived().RebuildFunctionNoProtoType(ResultType);
5662 
5663  FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result);
5665  NewTL.setLParenLoc(TL.getLParenLoc());
5666  NewTL.setRParenLoc(TL.getRParenLoc());
5667  NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
5668 
5669  return Result;
5670 }
5671 
5672 template<typename Derived> QualType
5675  const UnresolvedUsingType *T = TL.getTypePtr();
5676  Decl *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
5677  if (!D)
5678  return QualType();
5679 
5680  QualType Result = TL.getType();
5681  if (getDerived().AlwaysRebuild() || D != T->getDecl()) {
5682  Result = getDerived().RebuildUnresolvedUsingType(TL.getNameLoc(), D);
5683  if (Result.isNull())
5684  return QualType();
5685  }
5686 
5687  // We might get an arbitrary type spec type back. We should at
5688  // least always get a type spec type, though.
5689  TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(Result);
5690  NewTL.setNameLoc(TL.getNameLoc());
5691 
5692  return Result;
5693 }
5694 
5695 template<typename Derived>
5697  TypedefTypeLoc TL) {
5698  const TypedefType *T = TL.getTypePtr();
5699  TypedefNameDecl *Typedef
5700  = cast_or_null<TypedefNameDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5701  T->getDecl()));
5702  if (!Typedef)
5703  return QualType();
5704 
5705  QualType Result = TL.getType();
5706  if (getDerived().AlwaysRebuild() ||
5707  Typedef != T->getDecl()) {
5708  Result = getDerived().RebuildTypedefType(Typedef);
5709  if (Result.isNull())
5710  return QualType();
5711  }
5712 
5713  TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(Result);
5714  NewTL.setNameLoc(TL.getNameLoc());
5715 
5716  return Result;
5717 }
5718 
5719 template<typename Derived>
5721  TypeOfExprTypeLoc TL) {
5722  // typeof expressions are not potentially evaluated contexts
5724  SemaRef, Sema::ExpressionEvaluationContext::Unevaluated,
5725  Sema::ReuseLambdaContextDecl);
5726 
5727  ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
5728  if (E.isInvalid())
5729  return QualType();
5730 
5731  E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
5732  if (E.isInvalid())
5733  return QualType();
5734 
5735  QualType Result = TL.getType();
5736  if (getDerived().AlwaysRebuild() ||
5737  E.get() != TL.getUnderlyingExpr()) {
5738  Result = getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc());
5739  if (Result.isNull())
5740  return QualType();
5741  }
5742  else E.get();
5743 
5744  TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
5745  NewTL.setTypeofLoc(TL.getTypeofLoc());
5746  NewTL.setLParenLoc(TL.getLParenLoc());
5747  NewTL.setRParenLoc(TL.getRParenLoc());
5748 
5749  return Result;
5750 }
5751 
5752 template<typename Derived>
5754  TypeOfTypeLoc TL) {
5755  TypeSourceInfo* Old_Under_TI = TL.getUnderlyingTInfo();
5756  TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
5757  if (!New_Under_TI)
5758  return QualType();
5759 
5760  QualType Result = TL.getType();
5761  if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
5762  Result = getDerived().RebuildTypeOfType(New_Under_TI->getType());
5763  if (Result.isNull())
5764  return QualType();
5765  }
5766 
5767  TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
5768  NewTL.setTypeofLoc(TL.getTypeofLoc());
5769  NewTL.setLParenLoc(TL.getLParenLoc());
5770  NewTL.setRParenLoc(TL.getRParenLoc());
5771  NewTL.setUnderlyingTInfo(New_Under_TI);
5772 
5773  return Result;
5774 }
5775 
5776 template<typename Derived>
5778  DecltypeTypeLoc TL) {
5779  const DecltypeType *T = TL.getTypePtr();
5780 
5781  // decltype expressions are not potentially evaluated contexts
5783  SemaRef, Sema::ExpressionEvaluationContext::Unevaluated, nullptr,
5784  Sema::ExpressionEvaluationContextRecord::EK_Decltype);
5785 
5786  ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
5787  if (E.isInvalid())
5788  return QualType();
5789 
5790  E = getSema().ActOnDecltypeExpression(E.get());
5791  if (E.isInvalid())
5792  return QualType();
5793 
5794  QualType Result = TL.getType();
5795  if (getDerived().AlwaysRebuild() ||
5796  E.get() != T->getUnderlyingExpr()) {
5797  Result = getDerived().RebuildDecltypeType(E.get(), TL.getNameLoc());
5798  if (Result.isNull())
5799  return QualType();
5800  }
5801  else E.get();
5802 
5803  DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
5804  NewTL.setNameLoc(TL.getNameLoc());
5805 
5806  return Result;
5807 }
5808 
5809 template<typename Derived>
5811  TypeLocBuilder &TLB,
5812  UnaryTransformTypeLoc TL) {
5813  QualType Result = TL.getType();
5814  if (Result->isDependentType()) {
5815  const UnaryTransformType *T = TL.getTypePtr();
5816  QualType NewBase =
5817  getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
5818  Result = getDerived().RebuildUnaryTransformType(NewBase,
5819  T->getUTTKind(),
5820  TL.getKWLoc());
5821  if (Result.isNull())
5822  return QualType();
5823  }
5824 
5825  UnaryTransformTypeLoc NewTL = TLB.push<UnaryTransformTypeLoc>(Result);
5826  NewTL.setKWLoc(TL.getKWLoc());
5827  NewTL.setParensRange(TL.getParensRange());
5829  return Result;
5830 }
5831 
5832 template<typename Derived>
5836 
5837  CXXScopeSpec SS;
5838  TemplateName TemplateName = getDerived().TransformTemplateName(
5839  SS, T->getTemplateName(), TL.getTemplateNameLoc());
5840  if (TemplateName.isNull())
5841  return QualType();
5842 
5843  QualType OldDeduced = T->getDeducedType();
5844  QualType NewDeduced;
5845  if (!OldDeduced.isNull()) {
5846  NewDeduced = getDerived().TransformType(OldDeduced);
5847  if (NewDeduced.isNull())
5848  return QualType();
5849  }
5850 
5851  QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
5852  TemplateName, NewDeduced);
5853  if (Result.isNull())
5854  return QualType();
5855 
5859 
5860  return Result;
5861 }
5862 
5863 template<typename Derived>
5865  RecordTypeLoc TL) {
5866  const RecordType *T = TL.getTypePtr();
5867  RecordDecl *Record
5868  = cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5869  T->getDecl()));
5870  if (!Record)
5871  return QualType();
5872 
5873  QualType Result = TL.getType();
5874  if (getDerived().AlwaysRebuild() ||
5875  Record != T->getDecl()) {
5876  Result = getDerived().RebuildRecordType(Record);
5877  if (Result.isNull())
5878  return QualType();
5879  }
5880 
5881  RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(Result);
5882  NewTL.setNameLoc(TL.getNameLoc());
5883 
5884  return Result;
5885 }
5886 
5887 template<typename Derived>
5889  EnumTypeLoc TL) {
5890  const EnumType *T = TL.getTypePtr();
5891  EnumDecl *Enum
5892  = cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5893  T->getDecl()));
5894  if (!Enum)
5895  return QualType();
5896 
5897  QualType Result = TL.getType();
5898  if (getDerived().AlwaysRebuild() ||
5899  Enum != T->getDecl()) {
5900  Result = getDerived().RebuildEnumType(Enum);
5901  if (Result.isNull())
5902  return QualType();
5903  }
5904 
5905  EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(Result);
5906  NewTL.setNameLoc(TL.getNameLoc());
5907 
5908  return Result;
5909 }
5910 
5911 template<typename Derived>
5913  TypeLocBuilder &TLB,
5915  Decl *D = getDerived().TransformDecl(TL.getNameLoc(),
5916  TL.getTypePtr()->getDecl());
5917  if (!D) return QualType();
5918 
5919  QualType T = SemaRef.Context.getTypeDeclType(cast<TypeDecl>(D));
5920  TLB.pushTypeSpec(T).setNameLoc(TL.getNameLoc());
5921  return T;
5922 }
5923 
5924 template<typename Derived>
5926  TypeLocBuilder &TLB,
5928  return TransformTypeSpecType(TLB, TL);
5929 }
5930 
5931 template<typename Derived>
5933  TypeLocBuilder &TLB,
5935  const SubstTemplateTypeParmType *T = TL.getTypePtr();
5936 
5937  // Substitute into the replacement type, which itself might involve something
5938  // that needs to be transformed. This only tends to occur with default
5939  // template arguments of template template parameters.
5940  TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
5941  QualType Replacement = getDerived().TransformType(T->getReplacementType());
5942  if (Replacement.isNull())
5943  return QualType();
5944 
5945  // Always canonicalize the replacement type.
5946  Replacement = SemaRef.Context.getCanonicalType(Replacement);
5947  QualType Result
5948  = SemaRef.Context.getSubstTemplateTypeParmType(T->getReplacedParameter(),
5949  Replacement);
5950 
5951  // Propagate type-source information.
5953  = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
5954  NewTL.setNameLoc(TL.getNameLoc());
5955  return Result;
5956 
5957 }
5958 
5959 template<typename Derived>
5961  TypeLocBuilder &TLB,
5963  return TransformTypeSpecType(TLB, TL);
5964 }
5965 
5966 template<typename Derived>
5968  TypeLocBuilder &TLB,
5970  const TemplateSpecializationType *T = TL.getTypePtr();
5971 
5972  // The nested-name-specifier never matters in a TemplateSpecializationType,
5973  // because we can't have a dependent nested-name-specifier anyway.
5974  CXXScopeSpec SS;
5975  TemplateName Template
5976  = getDerived().TransformTemplateName(SS, T->getTemplateName(),
5977  TL.getTemplateNameLoc());
5978  if (Template.isNull())
5979  return QualType();
5980 
5981  return getDerived().TransformTemplateSpecializationType(TLB, TL, Template);
5982 }
5983 
5984 template<typename Derived>
5986  AtomicTypeLoc TL) {
5987  QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
5988  if (ValueType.isNull())
5989  return QualType();
5990 
5991  QualType Result = TL.getType();
5992  if (getDerived().AlwaysRebuild() ||
5993  ValueType != TL.getValueLoc().getType()) {
5994  Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
5995  if (Result.isNull())
5996  return QualType();
5997  }
5998 
5999  AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
6000  NewTL.setKWLoc(TL.getKWLoc());
6001  NewTL.setLParenLoc(TL.getLParenLoc());
6002  NewTL.setRParenLoc(TL.getRParenLoc());
6003 
6004  return Result;
6005 }
6006 
6007 template <typename Derived>
6009  PipeTypeLoc TL) {
6010  QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
6011  if (ValueType.isNull())
6012  return QualType();
6013 
6014  QualType Result = TL.getType();
6015  if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
6016  const PipeType *PT = Result->castAs<PipeType>();
6017  bool isReadPipe = PT->isReadOnly();
6018  Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
6019  if (Result.isNull())
6020  return QualType();
6021  }
6022 
6023  PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
6024  NewTL.setKWLoc(TL.getKWLoc());
6025 
6026  return Result;
6027 }
6028 
6029  /// Simple iterator that traverses the template arguments in a
6030  /// container that provides a \c getArgLoc() member function.
6031  ///
6032  /// This iterator is intended to be used with the iterator form of
6033  /// \c TreeTransform<Derived>::TransformTemplateArguments().
6034  template<typename ArgLocContainer>
6036  ArgLocContainer *Container;
6037  unsigned Index;
6038 
6039  public:
6042  typedef int difference_type;
6043  typedef std::input_iterator_tag iterator_category;
6044 
6045  class pointer {
6046  TemplateArgumentLoc Arg;
6047 
6048  public:
6049  explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
6050 
6052  return &Arg;
6053  }
6054  };
6055 
6056 
6058 
6059  TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
6060  unsigned Index)
6061  : Container(&Container), Index(Index) { }
6062 
6064  ++Index;
6065  return *this;
6066  }
6067 
6070  ++(*this);
6071  return Old;
6072  }
6073 
6075  return Container->getArgLoc(Index);
6076  }
6077 
6079  return pointer(Container->getArgLoc(Index));
6080  }
6081 
6084  return X.Container == Y.Container && X.Index == Y.Index;
6085  }
6086 
6089  return !(X == Y);
6090  }
6091  };
6092 
6093 template<typename Derived>
6095  AutoTypeLoc TL) {
6096  const AutoType *T = TL.getTypePtr();
6097  QualType OldDeduced = T->getDeducedType();
6098  QualType NewDeduced;
6099  if (!OldDeduced.isNull()) {
6100  NewDeduced = getDerived().TransformType(OldDeduced);
6101  if (NewDeduced.isNull())
6102  return QualType();
6103  }
6104 
6105  ConceptDecl *NewCD = nullptr;
6106  TemplateArgumentListInfo NewTemplateArgs;
6107  NestedNameSpecifierLoc NewNestedNameSpec;
6108  if (TL.getTypePtr()->isConstrained()) {
6109  NewCD = cast_or_null<ConceptDecl>(
6110  getDerived().TransformDecl(
6111  TL.getConceptNameLoc(),
6113 
6114  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
6115  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
6117  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
6118  ArgIterator(TL,
6119  TL.getNumArgs()),
6120  NewTemplateArgs))
6121  return QualType();
6122 
6123  if (TL.getNestedNameSpecifierLoc()) {
6124  NewNestedNameSpec
6125  = getDerived().TransformNestedNameSpecifierLoc(
6127  if (!NewNestedNameSpec)
6128  return QualType();
6129  }
6130  }
6131 
6132  QualType Result = TL.getType();
6133  if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
6134  T->isDependentType()) {
6136  NewArgList.reserve(NewArgList.size());
6137  for (const auto &ArgLoc : NewTemplateArgs.arguments())
6138  NewArgList.push_back(ArgLoc.getArgument());
6139  Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword(), NewCD,
6140  NewArgList);
6141  if (Result.isNull())
6142  return QualType();
6143  }
6144 
6145  AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
6146  NewTL.setNameLoc(TL.getNameLoc());
6147  NewTL.setNestedNameSpecifierLoc(NewNestedNameSpec);
6148  NewTL.setTemplateKWLoc(TL.getTemplateKWLoc());
6150  NewTL.setFoundDecl(TL.getFoundDecl());
6151  NewTL.setLAngleLoc(TL.getLAngleLoc());
6152  NewTL.setRAngleLoc(TL.getRAngleLoc());
6153  for (unsigned I = 0; I < TL.getNumArgs(); ++I)
6154  NewTL.setArgLocInfo(I, NewTemplateArgs.arguments()[I].getLocInfo());
6155 
6156  return Result;
6157 }
6158 
6159 template <typename Derived>
6161  TypeLocBuilder &TLB,
6163  TemplateName Template) {
6164  TemplateArgumentListInfo NewTemplateArgs;
6165  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
6166  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
6168  ArgIterator;
6169  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
6170  ArgIterator(TL, TL.getNumArgs()),
6171  NewTemplateArgs))
6172  return QualType();
6173 
6174  // FIXME: maybe don't rebuild if all the template arguments are the same.
6175 
6176  QualType Result =
6177  getDerived().RebuildTemplateSpecializationType(Template,
6178  TL.getTemplateNameLoc(),
6179  NewTemplateArgs);
6180 
6181  if (!Result.isNull()) {
6182  // Specializations of template template parameters are represented as
6183  // TemplateSpecializationTypes, and substitution of type alias templates
6184  // within a dependent context can transform them into
6185  // DependentTemplateSpecializationTypes.
6186  if (isa<DependentTemplateSpecializationType>(Result)) {
6193  NewTL.setLAngleLoc(TL.getLAngleLoc());
6194  NewTL.setRAngleLoc(TL.getRAngleLoc());
6195  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
6196  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
6197  return Result;
6198  }
6199 
6201  = TLB.push<TemplateSpecializationTypeLoc>(Result);
6204  NewTL.setLAngleLoc(TL.getLAngleLoc());
6205  NewTL.setRAngleLoc(TL.getRAngleLoc());
6206  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
6207  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
6208  }
6209 
6210  return Result;
6211 }
6212 
6213 template <typename Derived>
6215  TypeLocBuilder &TLB,
6217  TemplateName Template,
6218  CXXScopeSpec &SS) {
6219  TemplateArgumentListInfo NewTemplateArgs;
6220  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
6221  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
6224  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
6225  ArgIterator(TL, TL.getNumArgs()),
6226  NewTemplateArgs))
6227  return QualType();
6228 
6229  // FIXME: maybe don't rebuild if all the template arguments are the same.
6230 
6231  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
6232  QualType Result
6233  = getSema().Context.getDependentTemplateSpecializationType(
6234  TL.getTypePtr()->getKeyword(),
6235  DTN->getQualifier(),
6236  DTN->getIdentifier(),
6237  NewTemplateArgs);
6238 
6242  NewTL.setQualifierLoc(SS.getWithLocInContext(SemaRef.Context));
6245  NewTL.setLAngleLoc(TL.getLAngleLoc());
6246  NewTL.setRAngleLoc(TL.getRAngleLoc());
6247  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
6248  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
6249  return Result;
6250  }
6251 
6252  QualType Result
6253  = getDerived().RebuildTemplateSpecializationType(Template,
6254  TL.getTemplateNameLoc(),
6255  NewTemplateArgs);
6256 
6257  if (!Result.isNull()) {
6258  /// FIXME: Wrap this in an elaborated-type-specifier?
6260  = TLB.push<TemplateSpecializationTypeLoc>(Result);
6263  NewTL.setLAngleLoc(TL.getLAngleLoc());
6264  NewTL.setRAngleLoc(TL.getRAngleLoc());
6265  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
6266  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
6267  }
6268 
6269  return Result;
6270 }
6271 
6272 template<typename Derived>
6273 QualType
6275  ElaboratedTypeLoc TL) {
6276  const ElaboratedType *T = TL.getTypePtr();
6277 
6278  NestedNameSpecifierLoc QualifierLoc;
6279  // NOTE: the qualifier in an ElaboratedType is optional.
6280  if (TL.getQualifierLoc()) {
6281  QualifierLoc
6282  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6283  if (!QualifierLoc)
6284  return QualType();
6285  }
6286 
6287  QualType NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc());
6288  if (NamedT.isNull())
6289  return QualType();
6290 
6291  // C++0x [dcl.type.elab]p2:
6292  // If the identifier resolves to a typedef-name or the simple-template-id
6293  // resolves to an alias template specialization, the
6294  // elaborated-type-specifier is ill-formed.
6295  if (T->getKeyword() != ETK_None && T->getKeyword() != ETK_Typename) {
6296  if (const TemplateSpecializationType *TST =
6297  NamedT->getAs<TemplateSpecializationType>()) {
6298  TemplateName Template = TST->getTemplateName();
6299  if (TypeAliasTemplateDecl *TAT = dyn_cast_or_null<TypeAliasTemplateDecl>(
6300  Template.getAsTemplateDecl())) {
6301  SemaRef.Diag(TL.getNamedTypeLoc().getBeginLoc(),
6302  diag::err_tag_reference_non_tag)
6303  << TAT << Sema::NTK_TypeAliasTemplate
6304  << ElaboratedType::getTagTypeKindForKeyword(T->getKeyword());
6305  SemaRef.Diag(TAT->getLocation(), diag::note_declared_at);
6306  }
6307  }
6308  }
6309 
6310  QualType Result = TL.getType();
6311  if (getDerived().AlwaysRebuild() ||
6312  QualifierLoc != TL.getQualifierLoc() ||
6313  NamedT != T->getNamedType()) {
6314  Result = getDerived().RebuildElaboratedType(TL.getElaboratedKeywordLoc(),
6315  T->getKeyword(),
6316  QualifierLoc, NamedT);
6317  if (Result.isNull())
6318  return QualType();
6319  }
6320 
6321  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6323  NewTL.setQualifierLoc(QualifierLoc);
6324  return Result;
6325 }
6326 
6327 template<typename Derived>
6329  TypeLocBuilder &TLB,
6330  AttributedTypeLoc TL) {
6331  const AttributedType *oldType = TL.getTypePtr();
6332  QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
6333  if (modifiedType.isNull())
6334  return QualType();
6335 
6336  // oldAttr can be null if we started with a QualType rather than a TypeLoc.
6337  const Attr *oldAttr = TL.getAttr();
6338  const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
6339  if (oldAttr && !newAttr)
6340  return QualType();
6341 
6342  QualType result = TL.getType();
6343 
6344  // FIXME: dependent operand expressions?
6345  if (getDerived().AlwaysRebuild() ||
6346  modifiedType != oldType->getModifiedType()) {
6347  // TODO: this is really lame; we should really be rebuilding the
6348  // equivalent type from first principles.
6349  QualType equivalentType
6350  = getDerived().TransformType(oldType->getEquivalentType());
6351  if (equivalentType.isNull())
6352  return QualType();
6353 
6354  // Check whether we can add nullability; it is only represented as
6355  // type sugar, and therefore cannot be diagnosed in any other way.
6356  if (auto nullability = oldType->getImmediateNullability()) {
6357  if (!modifiedType->canHaveNullability()) {
6358  SemaRef.Diag(TL.getAttr()->getLocation(),
6359  diag::err_nullability_nonpointer)
6360  << DiagNullabilityKind(*nullability, false) << modifiedType;
6361  return QualType();
6362  }
6363  }
6364 
6365  result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
6366  modifiedType,
6367  equivalentType);
6368  }
6369 
6370  AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
6371  newTL.setAttr(newAttr);
6372  return result;
6373 }
6374 
6375 template<typename Derived>
6376 QualType
6378  ParenTypeLoc TL) {
6379  QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
6380  if (Inner.isNull())
6381  return QualType();
6382 
6383  QualType Result = TL.getType();
6384  if (getDerived().AlwaysRebuild() ||
6385  Inner != TL.getInnerLoc().getType()) {
6386  Result = getDerived().RebuildParenType(Inner);
6387  if (Result.isNull())
6388  return QualType();
6389  }
6390 
6391  ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
6392  NewTL.setLParenLoc(TL.getLParenLoc());
6393  NewTL.setRParenLoc(TL.getRParenLoc());
6394  return Result;
6395 }
6396 
6397 template <typename Derived>
6398 QualType
6400  MacroQualifiedTypeLoc TL) {
6401  QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
6402  if (Inner.isNull())
6403  return QualType();
6404 
6405  QualType Result = TL.getType();
6406  if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
6407  Result =
6408  getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
6409  if (Result.isNull())
6410  return QualType();
6411  }
6412 
6413  MacroQualifiedTypeLoc NewTL = TLB.push<MacroQualifiedTypeLoc>(Result);
6414  NewTL.setExpansionLoc(TL.getExpansionLoc());
6415  return Result;
6416 }
6417 
6418 template<typename Derived>
6421  return TransformDependentNameType(TLB, TL, false);
6422 }
6423 
6424 template<typename Derived>
6426  TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext) {
6427  const DependentNameType *T = TL.getTypePtr();
6428 
6429  NestedNameSpecifierLoc QualifierLoc
6430  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6431  if (!QualifierLoc)
6432  return QualType();
6433 
6434  QualType Result
6435  = getDerived().RebuildDependentNameType(T->getKeyword(),
6437  QualifierLoc,
6438  T->getIdentifier(),
6439  TL.getNameLoc(),
6440  DeducedTSTContext);
6441  if (Result.isNull())
6442  return QualType();
6443 
6444  if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) {
6445  QualType NamedT = ElabT->getNamedType();
6446  TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc());
6447 
6448  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6450  NewTL.setQualifierLoc(QualifierLoc);
6451  } else {
6452  DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
6454  NewTL.setQualifierLoc(QualifierLoc);
6455  NewTL.setNameLoc(TL.getNameLoc());
6456  }
6457  return Result;
6458 }
6459 
6460 template<typename Derived>
6464  NestedNameSpecifierLoc QualifierLoc;
6465  if (TL.getQualifierLoc()) {
6466  QualifierLoc
6467  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6468  if (!QualifierLoc)
6469  return QualType();
6470  }
6471 
6472  return getDerived()
6473  .TransformDependentTemplateSpecializationType(TLB, TL, QualifierLoc);
6474 }
6475 
6476 template<typename Derived>
6480  NestedNameSpecifierLoc QualifierLoc) {
6482 
6483  TemplateArgumentListInfo NewTemplateArgs;
6484  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
6485  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
6486 
6489  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
6490  ArgIterator(TL, TL.getNumArgs()),
6491  NewTemplateArgs))
6492  return QualType();
6493 
6494  QualType Result = getDerived().RebuildDependentTemplateSpecializationType(
6495  T->getKeyword(), QualifierLoc, TL.getTemplateKeywordLoc(),
6496  T->getIdentifier(), TL.getTemplateNameLoc(), NewTemplateArgs,
6497  /*AllowInjectedClassName*/ false);
6498  if (Result.isNull())
6499  return QualType();
6500 
6501  if (const ElaboratedType *ElabT = dyn_cast<ElaboratedType>(Result)) {
6502  QualType NamedT = ElabT->getNamedType();
6503 
6504  // Copy information relevant to the template specialization.
6506  = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
6508  NamedTL.setTemplateNameLoc(TL.getTemplateNameLoc());
6509  NamedTL.setLAngleLoc(TL.getLAngleLoc());
6510  NamedTL.setRAngleLoc(TL.getRAngleLoc());
6511  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6512  NamedTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6513 
6514  // Copy information relevant to the elaborated type.
6515  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6517  NewTL.setQualifierLoc(QualifierLoc);
6518  } else if (isa<DependentTemplateSpecializationType>(Result)) {
6522  SpecTL.setQualifierLoc(QualifierLoc);
6525  SpecTL.setLAngleLoc(TL.getLAngleLoc());
6526  SpecTL.setRAngleLoc(TL.getRAngleLoc());
6527  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6528  SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6529  } else {
6531  = TLB.push<TemplateSpecializationTypeLoc>(Result);
6534  SpecTL.setLAngleLoc(TL.getLAngleLoc());
6535  SpecTL.setRAngleLoc(TL.getRAngleLoc());
6536  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6537  SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6538  }
6539  return Result;
6540 }
6541 
6542 template<typename Derived>
6544  PackExpansionTypeLoc TL) {
6545  QualType Pattern
6546  = getDerived().TransformType(TLB, TL.getPatternLoc());
6547  if (Pattern.isNull())
6548  return QualType();
6549 
6550  QualType Result = TL.getType();
6551  if (getDerived().AlwaysRebuild() ||
6552  Pattern != TL.getPatternLoc().getType()) {
6553  Result = getDerived().RebuildPackExpansionType(Pattern,
6555  TL.getEllipsisLoc(),
6556  TL.getTypePtr()->getNumExpansions());
6557  if (Result.isNull())
6558  return QualType();
6559  }
6560 
6561  PackExpansionTypeLoc NewT = TLB.push<PackExpansionTypeLoc>(Result);
6562  NewT.setEllipsisLoc(TL.getEllipsisLoc());
6563  return Result;
6564 }
6565 
6566 template<typename Derived>
6567 QualType
6569  ObjCInterfaceTypeLoc TL) {
6570  // ObjCInterfaceType is never dependent.
6571  TLB.pushFullCopy(TL);
6572  return TL.getType();
6573 }
6574 
6575 template<typename Derived>
6576 QualType
6578  ObjCTypeParamTypeLoc TL) {
6579  const ObjCTypeParamType *T = TL.getTypePtr();
6580  ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
6581  getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
6582  if (!OTP)
6583  return QualType();
6584 
6585  QualType Result = TL.getType();
6586  if (getDerived().AlwaysRebuild() ||
6587  OTP != T->getDecl()) {
6588  Result = getDerived().RebuildObjCTypeParamType(OTP,
6589  TL.getProtocolLAngleLoc(),
6590  llvm::makeArrayRef(TL.getTypePtr()->qual_begin(),
6591  TL.getNumProtocols()),
6592  TL.getProtocolLocs(),
6593  TL.getProtocolRAngleLoc());
6594  if (Result.isNull())
6595  return QualType();
6596  }
6597 
6598  ObjCTypeParamTypeLoc NewTL = TLB.push<ObjCTypeParamTypeLoc>(Result);
6599  if (TL.getNumProtocols()) {
6601  for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
6602  NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
6604  }
6605  return Result;
6606 }
6607 
6608 template<typename Derived>
6609 QualType
6611  ObjCObjectTypeLoc TL) {
6612  // Transform base type.
6613  QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
6614  if (BaseType.isNull())
6615  return QualType();
6616 
6617  bool AnyChanged = BaseType != TL.getBaseLoc().getType();
6618 
6619  // Transform type arguments.
6620  SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
6621  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
6622  TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
6623  TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
6624  QualType TypeArg = TypeArgInfo->getType();
6625  if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
6626  AnyChanged = true;
6627 
6628  // We have a pack expansion. Instantiate it.
6629  const auto *PackExpansion = PackExpansionLoc.getType()
6632  SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6633  Unexpanded);
6634  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6635 
6636  // Determine whether the set of unexpanded parameter packs can
6637  // and should be expanded.
6638  TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
6639  bool Expand = false;
6640  bool RetainExpansion = false;
6641  Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
6642  if (getDerived().TryExpandParameterPacks(
6643  PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
6644  Unexpanded, Expand, RetainExpansion, NumExpansions))
6645  return QualType();
6646 
6647  if (!Expand) {
6648  // We can't expand this pack expansion into separate arguments yet;
6649  // just substitute into the pattern and create a new pack expansion
6650  // type.
6651  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6652 
6653  TypeLocBuilder TypeArgBuilder;
6654  TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
6655  QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
6656  PatternLoc);
6657  if (NewPatternType.isNull())
6658  return QualType();
6659 
6660  QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
6661  NewPatternType, NumExpansions);
6662  auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
6663  NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
6664  NewTypeArgInfos.push_back(
6665  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
6666  continue;
6667  }
6668 
6669  // Substitute into the pack expansion pattern for each slice of the
6670  // pack.
6671  for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6672  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
6673 
6674  TypeLocBuilder TypeArgBuilder;
6675  TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
6676 
6677  QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
6678  PatternLoc);
6679  if (NewTypeArg.isNull())
6680  return QualType();
6681 
6682  NewTypeArgInfos.push_back(
6683  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
6684  }
6685 
6686  continue;
6687  }
6688 
6689  TypeLocBuilder TypeArgBuilder;
6690  TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
6691  QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
6692  if (NewTypeArg.isNull())
6693  return QualType();
6694 
6695  // If nothing changed, just keep the old TypeSourceInfo.
6696  if (NewTypeArg == TypeArg) {
6697  NewTypeArgInfos.push_back(TypeArgInfo);
6698  continue;
6699  }
6700 
6701  NewTypeArgInfos.push_back(
6702  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
6703  AnyChanged = true;
6704  }
6705 
6706  QualType Result = TL.getType();
6707  if (getDerived().AlwaysRebuild() || AnyChanged) {
6708  // Rebuild the type.
6709  Result = getDerived().RebuildObjCObjectType(
6710  BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
6712  llvm::makeArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
6714 
6715  if (Result.isNull())
6716  return QualType();
6717  }
6718 
6719  ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
6720  NewT.setHasBaseTypeAsWritten(true);
6722  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
6723  NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
6726  for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
6727  NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
6729  return Result;
6730 }
6731 
6732 template<typename Derived>
6733 QualType
6736  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
6737  if (PointeeType.isNull())
6738  return QualType();
6739 
6740  QualType Result = TL.getType();
6741  if (getDerived().AlwaysRebuild() ||
6742  PointeeType != TL.getPointeeLoc().getType()) {
6743  Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
6744  TL.getStarLoc());
6745  if (Result.isNull())
6746  return QualType();
6747  }
6748 
6750  NewT.setStarLoc(TL.getStarLoc());
6751  return Result;
6752 }
6753 
6754 //===----------------------------------------------------------------------===//
6755 // Statement transformation
6756 //===----------------------------------------------------------------------===//
6757 template<typename Derived>
6758 StmtResult
6760  return S;
6761 }
6762 
6763 template<typename Derived>
6764 StmtResult
6766  return getDerived().TransformCompoundStmt(S, false);
6767 }
6768 
6769 template<typename Derived>
6770 StmtResult
6772  bool IsStmtExpr) {
6773  Sema::CompoundScopeRAII CompoundScope(getSema());
6774 
6775  const Stmt *ExprResult = S->getStmtExprResult();
6776  bool SubStmtInvalid = false;
6777  bool SubStmtChanged = false;
6778  SmallVector<Stmt*, 8> Statements;
6779  for (auto *B : S->body()) {
6780  StmtResult Result = getDerived().TransformStmt(
6781  B, IsStmtExpr && B == ExprResult ? SDK_StmtExprResult : SDK_Discarded);
6782 
6783  if (Result.isInvalid()) {
6784  // Immediately fail if this was a DeclStmt, since it's very
6785  // likely that this will cause problems for future statements.
6786  if (isa<DeclStmt>(B))
6787  return StmtError();
6788 
6789  // Otherwise, just keep processing substatements and fail later.
6790  SubStmtInvalid = true;
6791  continue;
6792  }
6793 
6794  SubStmtChanged = SubStmtChanged || Result.get() != B;
6795  Statements.push_back(Result.getAs<Stmt>());
6796  }
6797 
6798  if (SubStmtInvalid)
6799  return StmtError();
6800 
6801  if (!getDerived().AlwaysRebuild() &&
6802  !SubStmtChanged)
6803  return S;
6804 
6805  return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
6806  Statements,
6807  S->getRBracLoc(),
6808  IsStmtExpr);
6809 }
6810 
6811 template<typename Derived>
6812 StmtResult
6814  ExprResult LHS, RHS;
6815  {
6817  SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
6818 
6819  // Transform the left-hand case value.
6820  LHS = getDerived().TransformExpr(S->getLHS());
6821  LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
6822  if (LHS.isInvalid())
6823  return StmtError();
6824 
6825  // Transform the right-hand case value (for the GNU case-range extension).
6826  RHS = getDerived().TransformExpr(S->getRHS());
6827  RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
6828  if (RHS.isInvalid())
6829  return StmtError();
6830  }
6831 
6832  // Build the case statement.
6833  // Case statements are always rebuilt so that they will attached to their
6834  // transformed switch statement.
6835  StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
6836  LHS.get(),
6837  S->getEllipsisLoc(),
6838  RHS.get(),
6839  S->getColonLoc());
6840  if (Case.isInvalid())
6841  return StmtError();
6842 
6843  // Transform the statement following the case
6844  StmtResult SubStmt =
6845  getDerived().TransformStmt(S->getSubStmt());
6846  if (SubStmt.isInvalid())
6847  return StmtError();
6848 
6849  // Attach the body to the case statement
6850  return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
6851 }
6852 
6853 template <typename Derived>
6855  // Transform the statement following the default case
6856  StmtResult SubStmt =
6857  getDerived().TransformStmt(S->getSubStmt());
6858  if (SubStmt.isInvalid())
6859  return StmtError();
6860 
6861  // Default statements are always rebuilt
6862  return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
6863  SubStmt.get());
6864 }
6865 
6866 template<typename Derived>
6867 StmtResult
6869  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
6870  if (SubStmt.isInvalid())
6871  return StmtError();
6872 
6873  Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
6874  S->getDecl());
6875  if (!LD)
6876  return StmtError();
6877 
6878  // If we're transforming "in-place" (we're not creating new local
6879  // declarations), assume we're replacing the old label statement
6880  // and clear out the reference to it.
6881  if (LD == S->getDecl())
6882  S->getDecl()->setStmt(nullptr);
6883 
6884  // FIXME: Pass the real colon location in.
6885  return getDerived().RebuildLabelStmt(S->getIdentLoc(),
6886  cast<LabelDecl>(LD), SourceLocation(),
6887  SubStmt.get());
6888 }
6889 
6890 template <typename Derived>
6892  if (!R)
6893  return R;
6894 
6895  switch (R->getKind()) {
6896 // Transform attributes with a pragma spelling by calling TransformXXXAttr.
6897 #define ATTR(X)
6898 #define PRAGMA_SPELLING_ATTR(X) \
6899  case attr::X: \
6900  return getDerived().Transform##X##Attr(cast<X##Attr>(R));
6901 #include "clang/Basic/AttrList.inc"
6902  default:
6903  return R;
6904  }
6905 }
6906 
6907 template <typename Derived>
6908 StmtResult
6910  StmtDiscardKind SDK) {
6911  bool AttrsChanged = false;
6913 
6914  // Visit attributes and keep track if any are transformed.
6915  for (const auto *I : S->getAttrs()) {
6916  const Attr *R = getDerived().TransformAttr(I);
6917  AttrsChanged |= (I != R);
6918  Attrs.push_back(R);
6919  }
6920 
6921  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
6922  if (SubStmt.isInvalid())
6923  return StmtError();
6924 
6925  if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
6926  return S;
6927 
6928  return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
6929  SubStmt.get());
6930 }
6931 
6932 template<typename Derived>
6933 StmtResult
6935  // Transform the initialization statement
6936  StmtResult Init = getDerived().TransformStmt(S->getInit());
6937  if (Init.isInvalid())
6938  return StmtError();
6939 
6940  // Transform the condition
6941  Sema::ConditionResult Cond = getDerived().TransformCondition(
6942  S->getIfLoc(), S->getConditionVariable(), S->getCond(),
6943  S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
6944  : Sema::ConditionKind::Boolean);
6945  if (Cond.isInvalid())
6946  return StmtError();
6947 
6948  // If this is a constexpr if, determine which arm we should instantiate.
6949  llvm::Optional<bool> ConstexprConditionValue;
6950  if (S->isConstexpr())
6951  ConstexprConditionValue = Cond.getKnownValue();
6952 
6953  // Transform the "then" branch.
6954  StmtResult Then;
6955  if (!ConstexprConditionValue || *ConstexprConditionValue) {
6956  Then = getDerived().TransformStmt(S->getThen());
6957  if (Then.isInvalid())
6958  return StmtError();
6959  } else {
6960  Then = new (getSema().Context) NullStmt(S->getThen()->getBeginLoc());
6961  }
6962 
6963  // Transform the "else" branch.
6964  StmtResult Else;
6965  if (!ConstexprConditionValue || !*ConstexprConditionValue) {
6966  Else = getDerived().TransformStmt(S->getElse());
6967  if (Else.isInvalid())
6968  return StmtError();
6969  }
6970 
6971  if (!getDerived().AlwaysRebuild() &&
6972  Init.get() == S->getInit() &&
6973  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
6974  Then.get() == S->getThen() &&
6975  Else.get() == S->getElse())
6976  return S;
6977 
6978  return getDerived().RebuildIfStmt(S->getIfLoc(), S->isConstexpr(), Cond,
6979  Init.get(), Then.get(), S->getElseLoc(),
6980  Else.get());
6981 }
6982 
6983 template<typename Derived>
6984 StmtResult
6986  // Transform the initialization statement
6987  StmtResult Init = getDerived().TransformStmt(S->getInit());
6988  if (Init.isInvalid())
6989  return StmtError();
6990 
6991  // Transform the condition.
6992  Sema::ConditionResult Cond = getDerived().TransformCondition(
6993  S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
6994  Sema::ConditionKind::Switch);
6995  if (Cond.isInvalid())
6996  return StmtError();
6997 
6998  // Rebuild the switch statement.
6999  StmtResult Switch
7000  = getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond);
7001  if (Switch.isInvalid())
7002  return StmtError();
7003 
7004  // Transform the body of the switch statement.
7005  StmtResult Body = getDerived().TransformStmt(S->getBody());
7006  if (Body.isInvalid())
7007  return StmtError();
7008 
7009  // Complete the switch statement.
7010  return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
7011  Body.get());
7012 }
7013 
7014 template<typename Derived>
7015 StmtResult
7017  // Transform the condition
7018  Sema::ConditionResult Cond = getDerived().TransformCondition(
7019  S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
7020  Sema::ConditionKind::Boolean);
7021  if (Cond.isInvalid())
7022  return StmtError();
7023 
7024  // Transform the body
7025  StmtResult Body = getDerived().TransformStmt(S->getBody());
7026  if (Body.isInvalid())
7027  return StmtError();
7028 
7029  if (!getDerived().AlwaysRebuild() &&
7030  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
7031  Body.get() == S->getBody())
7032  return Owned(S);
7033 
7034  return getDerived().RebuildWhileStmt(S->getWhileLoc(), Cond, Body.get());
7035 }
7036 
7037 template<typename Derived>
7038 StmtResult
7040  // Transform the body
7041  StmtResult Body = getDerived().TransformStmt(S->getBody());
7042  if (Body.isInvalid())
7043  return StmtError();
7044 
7045  // Transform the condition
7046  ExprResult Cond = getDerived().TransformExpr(S->getCond());
7047  if (Cond.isInvalid())
7048  return StmtError();
7049 
7050  if (!getDerived().AlwaysRebuild() &&
7051  Cond.get() == S->getCond() &&
7052  Body.get() == S->getBody())
7053  return S;
7054 
7055  return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
7056  /*FIXME:*/S->getWhileLoc(), Cond.get(),
7057  S->getRParenLoc());
7058 }
7059 
7060 template<typename Derived>
7061 StmtResult
7063  if (getSema().getLangOpts().OpenMP)
7064  getSema().startOpenMPLoop();
7065 
7066  // Transform the initialization statement
7067  StmtResult Init = getDerived().TransformStmt(S->getInit());
7068  if (Init.isInvalid())
7069  return StmtError();
7070 
7071  // In OpenMP loop region loop control variable must be captured and be
7072  // private. Perform analysis of first part (if any).
7073  if (getSema().getLangOpts().OpenMP && Init.isUsable())
7074  getSema().ActOnOpenMPLoopInitialization(S->getForLoc(), Init.get());
7075 
7076  // Transform the condition
7077  Sema::ConditionResult Cond = getDerived().TransformCondition(
7078  S->getForLoc(), S->getConditionVariable(), S->getCond(),
7079  Sema::ConditionKind::Boolean);
7080  if (Cond.isInvalid())
7081  return StmtError();
7082 
7083  // Transform the increment
7084  ExprResult Inc = getDerived().TransformExpr(S->getInc());
7085  if (Inc.isInvalid())
7086  return StmtError();
7087 
7088  Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
7089  if (S->getInc() && !FullInc.get())
7090  return StmtError();
7091 
7092  // Transform the body
7093  StmtResult Body = getDerived().TransformStmt(S->getBody());
7094  if (Body.isInvalid())
7095  return StmtError();
7096 
7097  if (!getDerived().AlwaysRebuild() &&
7098  Init.get() == S->getInit() &&
7099  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
7100  Inc.get() == S->getInc() &&
7101  Body.get() == S->getBody())
7102  return S;
7103 
7104  return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
7105  Init.get(), Cond, FullInc,
7106  S->getRParenLoc(), Body.get());
7107 }
7108 
7109 template<typename Derived>
7110 StmtResult
7112  Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
7113  S->getLabel());
7114  if (!LD)
7115  return StmtError();
7116 
7117  // Goto statements must always be rebuilt, to resolve the label.
7118  return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
7119  cast<LabelDecl>(LD));
7120 }
7121 
7122 template<typename Derived>
7123 StmtResult
7125  ExprResult Target = getDerived().TransformExpr(S->getTarget());
7126  if (Target.isInvalid())
7127  return StmtError();
7128  Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
7129 
7130  if (!getDerived().AlwaysRebuild() &&
7131  Target.get() == S->getTarget())
7132  return S;
7133 
7134  return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
7135  Target.get());
7136 }
7137 
7138 template<typename Derived>
7139 StmtResult
7141  return S;
7142 }
7143 
7144 template<typename Derived>
7145 StmtResult
7147  return S;
7148 }
7149 
7150 template<typename Derived>
7151 StmtResult
7153  ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
7154  /*NotCopyInit*/false);
7155  if (Result.isInvalid())
7156  return StmtError();
7157 
7158  // FIXME: We always rebuild the return statement because there is no way
7159  // to tell whether the return type of the function has changed.
7160  return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
7161 }
7162 
7163 template<typename Derived>
7164 StmtResult
7166  bool DeclChanged = false;
7167  SmallVector<Decl *, 4> Decls;
7168  for (auto *D : S->decls()) {
7169  Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
7170  if (!Transformed)
7171  return StmtError();
7172 
7173  if (Transformed != D)
7174  DeclChanged = true;
7175 
7176  Decls.push_back(Transformed);
7177  }
7178 
7179  if (!getDerived().AlwaysRebuild() && !DeclChanged)
7180  return S;
7181 
7182  return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
7183 }
7184 
7185 template<typename Derived>
7186 StmtResult
7188 
7189  SmallVector<Expr*, 8> Constraints;
7190  SmallVector<Expr*, 8> Exprs;
7192 
7193  ExprResult AsmString;
7194  SmallVector<Expr*, 8> Clobbers;
7195 
7196  bool ExprsChanged = false;
7197 
7198  // Go through the outputs.
7199  for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
7200  Names.push_back(S->getOutputIdentifier(I));
7201 
7202  // No need to transform the constraint literal.
7203  Constraints.push_back(S->getOutputConstraintLiteral(I));
7204 
7205  // Transform the output expr.
7206  Expr *OutputExpr = S->getOutputExpr(I);
7207  ExprResult Result = getDerived().TransformExpr(OutputExpr);
7208  if (Result.isInvalid())
7209  return StmtError();
7210 
7211  ExprsChanged |= Result.get() != OutputExpr;
7212 
7213  Exprs.push_back(Result.get());
7214  }
7215 
7216  // Go through the inputs.
7217  for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
7218  Names.push_back(S->getInputIdentifier(I));
7219 
7220  // No need to transform the constraint literal.
7221  Constraints.push_back(S->getInputConstraintLiteral(I));
7222 
7223  // Transform the input expr.
7224  Expr *InputExpr = S->getInputExpr(I);
7225  ExprResult Result = getDerived().TransformExpr(InputExpr);
7226  if (Result.isInvalid())
7227  return StmtError();
7228 
7229  ExprsChanged |= Result.get() != InputExpr;
7230 
7231  Exprs.push_back(Result.get());
7232  }
7233 
7234  // Go through the Labels.
7235  for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
7236  Names.push_back(S->getLabelIdentifier(I));
7237 
7238  ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
7239  if (Result.isInvalid())
7240  return StmtError();
7241  ExprsChanged |= Result.get() != S->getLabelExpr(I);
7242  Exprs.push_back(Result.get());
7243  }
7244  if (!getDerived().AlwaysRebuild() && !ExprsChanged)
7245  return S;
7246 
7247  // Go through the clobbers.
7248  for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I)
7249  Clobbers.push_back(S->getClobberStringLiteral(I));
7250 
7251  // No need to transform the asm string literal.
7252  AsmString = S->getAsmString();
7253  return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
7254  S->isVolatile(), S->getNumOutputs(),
7255  S->getNumInputs(), Names.data(),
7256  Constraints, Exprs, AsmString.get(),
7257  Clobbers, S->getNumLabels(),
7258  S->getRParenLoc());
7259 }
7260 
7261 template<typename Derived>
7262 StmtResult
7264  ArrayRef<Token> AsmToks =
7265  llvm::makeArrayRef(S->getAsmToks(), S->getNumAsmToks());
7266 
7267  bool HadError = false, HadChange = false;
7268 
7269  ArrayRef<Expr*> SrcExprs = S->getAllExprs();
7270  SmallVector<Expr*, 8> TransformedExprs;
7271  TransformedExprs.reserve(SrcExprs.size());
7272  for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
7273  ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
7274  if (!Result.isUsable()) {
7275  HadError = true;
7276  } else {
7277  HadChange |= (Result.get() != SrcExprs[i]);
7278  TransformedExprs.push_back(Result.get());
7279  }
7280  }
7281 
7282  if (HadError) return StmtError();
7283  if (!HadChange && !getDerived().AlwaysRebuild())
7284  return Owned(S);
7285 
7286  return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
7287  AsmToks, S->getAsmString(),
7288  S->getNumOutputs(), S->getNumInputs(),
7289  S->getAllConstraints(), S->getClobbers(),
7290  TransformedExprs, S->getEndLoc());
7291 }
7292 
7293 // C++ Coroutines TS
7294 
7295 template<typename Derived>
7296 StmtResult
7298  auto *ScopeInfo = SemaRef.getCurFunction();
7299  auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
7300  assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
7301  ScopeInfo->NeedsCoroutineSuspends &&
7302  ScopeInfo->CoroutineSuspends.first == nullptr &&
7303  ScopeInfo->CoroutineSuspends.second == nullptr &&
7304  "expected clean scope info");
7305 
7306  // Set that we have (possibly-invalid) suspend points before we do anything
7307  // that may fail.
7308  ScopeInfo->setNeedsCoroutineSuspends(false);
7309 
7310  // We re-build the coroutine promise object (and the coroutine parameters its
7311  // type and constructor depend on) based on the types used in our current
7312  // function. We must do so, and set it on the current FunctionScopeInfo,
7313  // before attempting to transform the other parts of the coroutine body
7314  // statement, such as the implicit suspend statements (because those
7315  // statements reference the FunctionScopeInfo::CoroutinePromise).
7316  if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
7317  return StmtError();
7318  auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
7319  if (!Promise)
7320  return StmtError();
7321  getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
7322  ScopeInfo->CoroutinePromise = Promise;
7323 
7324  // Transform the implicit coroutine statements constructed using dependent
7325  // types during the previous parse: initial and final suspensions, the return
7326  // object, and others. We also transform the coroutine function's body.
7327  StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
7328  if (InitSuspend.isInvalid())
7329  return StmtError();
7330  StmtResult FinalSuspend =
7331  getDerived().TransformStmt(S->getFinalSuspendStmt());
7332  if (FinalSuspend.isInvalid())
7333  return StmtError();
7334  ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
7335  assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
7336 
7337  StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
7338  if (BodyRes.isInvalid())
7339  return StmtError();
7340 
7341  CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
7342  if (Builder.isInvalid())
7343  return StmtError();
7344 
7345  Expr *ReturnObject = S->getReturnValueInit();
7346  assert(ReturnObject && "the return object is expected to be valid");
7347  ExprResult Res = getDerived().TransformInitializer(ReturnObject,
7348  /*NoCopyInit*/ false);
7349  if (Res.isInvalid())
7350  return StmtError();
7351  Builder.ReturnValue = Res.get();
7352 
7353  // If during the previous parse the coroutine still had a dependent promise
7354  // statement, we may need to build some implicit coroutine statements
7355  // (such as exception and fallthrough handlers) for the first time.
7356  if (S->hasDependentPromiseType()) {
7357  // We can only build these statements, however, if the current promise type
7358  // is not dependent.
7359  if (!Promise->getType()->isDependentType()) {
7360  assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
7361  !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
7362  "these nodes should not have been built yet");
7363  if (!Builder.buildDependentStatements())
7364  return StmtError();
7365  }
7366  } else {
7367  if (auto *OnFallthrough = S->getFallthroughHandler()) {
7368  StmtResult Res = getDerived().TransformStmt(OnFallthrough);
7369  if (Res.isInvalid())
7370  return StmtError();
7371  Builder.OnFallthrough = Res.get();
7372  }
7373 
7374  if (auto *OnException = S->getExceptionHandler()) {
7375  StmtResult Res = getDerived().TransformStmt(OnException);
7376  if (Res.isInvalid())
7377  return StmtError();
7378  Builder.OnException = Res.get();
7379  }
7380 
7381  if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
7382  StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
7383  if (Res.isInvalid())
7384  return StmtError();
7385  Builder.ReturnStmtOnAllocFailure = Res.get();
7386  }
7387 
7388  // Transform any additional statements we may have already built
7389  assert(S->getAllocate() && S->getDeallocate() &&
7390  "allocation and deallocation calls must already be built");
7391  ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
7392  if (AllocRes.isInvalid())
7393  return StmtError();
7394  Builder.Allocate = AllocRes.get();
7395 
7396  ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
7397  if (DeallocRes.isInvalid())
7398  return StmtError();
7399  Builder.Deallocate = DeallocRes.get();
7400 
7401  assert(S->getResultDecl() && "ResultDecl must already be built");
7402  StmtResult ResultDecl = getDerived().TransformStmt(S->getResultDecl());
7403  if (ResultDecl.isInvalid())
7404  return StmtError();
7405  Builder.ResultDecl = ResultDecl.get();
7406 
7407  if (auto *ReturnStmt = S->getReturnStmt()) {
7408  StmtResult Res = getDerived().TransformStmt(ReturnStmt);
7409  if (Res.isInvalid())
7410  return StmtError();
7411  Builder.ReturnStmt = Res.get();
7412  }
7413  }
7414 
7415  return getDerived().RebuildCoroutineBodyStmt(Builder);
7416 }
7417 
7418 template<typename Derived>
7419 StmtResult
7421  ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
7422  /*NotCopyInit*/false);
7423  if (Result.isInvalid())
7424  return StmtError();
7425 
7426  // Always rebuild; we don't know if this needs to be injected into a new
7427  // context or if the promise type has changed.
7428  return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
7429  S->isImplicit());
7430 }
7431 
7432 template<typename Derived>
7433 ExprResult
7435  ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
7436  /*NotCopyInit*/false);
7437  if (Result.isInvalid())
7438  return ExprError();
7439 
7440  // Always rebuild; we don't know if this needs to be injected into a new
7441  // context or if the promise type has changed.
7442  return getDerived().RebuildCoawaitExpr(E->getKeywordLoc(), Result.get(),
7443  E->isImplicit());
7444 }
7445 
7446 template <typename Derived>
7447 ExprResult
7449  ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
7450  /*NotCopyInit*/ false);
7451  if (OperandResult.isInvalid())
7452  return ExprError();
7453 
7454  ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
7456 
7457  if (LookupResult.isInvalid())
7458  return ExprError();
7459 
7460  // Always rebuild; we don't know if this needs to be injected into a new
7461  // context or if the promise type has changed.
7462  return getDerived().RebuildDependentCoawaitExpr(
7463  E->getKeywordLoc(), OperandResult.get(),
7464  cast<UnresolvedLookupExpr>(LookupResult.get()));
7465 }
7466 
7467 template<typename Derived>
7468 ExprResult
7470  ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
7471  /*NotCopyInit*/false);
7472  if (Result.isInvalid())
7473  return ExprError();
7474 
7475  // Always rebuild; we don't know if this needs to be injected into a new
7476  // context or if the promise type has changed.
7477  return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
7478 }
7479 
7480 // Objective-C Statements.
7481 
7482 template<typename Derived>
7483 StmtResult
7485  // Transform the body of the @try.
7486  StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
7487  if (TryBody.isInvalid())
7488  return StmtError();
7489 
7490  // Transform the @catch statements (if present).
7491  bool AnyCatchChanged = false;
7492  SmallVector<Stmt*, 8> CatchStmts;
7493  for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
7494  StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
7495  if (Catch.isInvalid())
7496  return StmtError();
7497  if (Catch.get() != S->getCatchStmt(I))
7498  AnyCatchChanged = true;
7499  CatchStmts.push_back(Catch.get());
7500  }
7501 
7502  // Transform the @finally statement (if present).
7503  StmtResult Finally;
7504  if (S->getFinallyStmt()) {
7505  Finally = getDerived().TransformStmt(S->getFinallyStmt());
7506  if (Finally.isInvalid())
7507  return StmtError();
7508  }
7509 
7510  // If nothing changed, just retain this statement.
7511  if (!getDerived().AlwaysRebuild() &&
7512  TryBody.get() == S->getTryBody() &&
7513  !AnyCatchChanged &&
7514  Finally.get() == S->getFinallyStmt())
7515  return S;
7516 
7517  // Build a new statement.
7518  return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
7519  CatchStmts, Finally.get());
7520 }
7521 
7522 template<typename Derived>
7523 StmtResult
7525  // Transform the @catch parameter, if there is one.
7526  VarDecl *Var = nullptr;
7527  if (VarDecl *FromVar = S->getCatchParamDecl()) {
7528  TypeSourceInfo *TSInfo = nullptr;
7529  if (FromVar->getTypeSourceInfo()) {
7530  TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
7531  if (!TSInfo)
7532  return StmtError();
7533  }
7534 
7535  QualType T;
7536  if (TSInfo)
7537  T = TSInfo->getType();
7538  else {
7539  T = getDerived().TransformType(FromVar->getType());
7540  if (T.isNull())
7541  return StmtError();
7542  }
7543 
7544  Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
7545  if (!Var)
7546  return StmtError();
7547  }
7548 
7549  StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
7550  if (Body.isInvalid())
7551  return StmtError();
7552 
7553  return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
7554  S->getRParenLoc(),
7555  Var, Body.get());
7556 }
7557 
7558 template<typename Derived>
7559 StmtResult
7561  // Transform the body.
7562  StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
7563  if (Body.isInvalid())
7564  return StmtError();
7565 
7566  // If nothing changed, just retain this statement.
7567  if (!getDerived().AlwaysRebuild() &&
7568  Body.get() == S->getFinallyBody())
7569  return S;
7570 
7571  // Build a new statement.
7572  return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
7573  Body.get());
7574 }
7575 
7576 template<typename Derived>
7577 StmtResult
7579  ExprResult Operand;
7580  if (S->getThrowExpr()) {
7581  Operand = getDerived().TransformExpr(S->getThrowExpr());
7582  if (Operand.isInvalid())
7583  return StmtError();
7584  }
7585 
7586  if (!getDerived().AlwaysRebuild() &&
7587  Operand.get() == S->getThrowExpr())
7588  return S;
7589 
7590  return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
7591 }
7592 
7593 template<typename Derived>
7594 StmtResult
7597  // Transform the object we are locking.
7598  ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
7599  if (Object.isInvalid())
7600  return StmtError();
7601  Object =
7602  getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
7603  Object.get());
7604  if (Object.isInvalid())
7605  return StmtError();
7606 
7607  // Transform the body.
7608  StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
7609  if (Body.isInvalid())
7610  return StmtError();
7611 
7612  // If nothing change, just retain the current statement.
7613  if (!getDerived().AlwaysRebuild() &&
7614  Object.get() == S->getSynchExpr() &&
7615  Body.get() == S->getSynchBody())
7616  return S;
7617 
7618  // Build a new statement.
7619  return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
7620  Object.get(), Body.get());
7621 }
7622 
7623 template<typename Derived>
7624 StmtResult
7627  // Transform the body.
7628  StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
7629  if (Body.isInvalid())
7630  return StmtError();
7631 
7632  // If nothing changed, just retain this statement.
7633  if (!getDerived().AlwaysRebuild() &&
7634  Body.get() == S->getSubStmt())
7635  return S;
7636 
7637  // Build a new statement.
7638  return getDerived().RebuildObjCAutoreleasePoolStmt(
7639  S->getAtLoc(), Body.get());
7640 }
7641 
7642 template<typename Derived>
7643 StmtResult
7645  ObjCForCollectionStmt *S) {
7646  // Transform the element statement.
7647  StmtResult Element =
7648  getDerived().TransformStmt(S->getElement(), SDK_NotDiscarded);
7649  if (Element.isInvalid())
7650  return StmtError();
7651 
7652  // Transform the collection expression.
7653  ExprResult Collection = getDerived().TransformExpr(S->getCollection());
7654  if (Collection.isInvalid())
7655  return StmtError();
7656 
7657  // Transform the body.
7658  StmtResult Body = getDerived().TransformStmt(S->getBody());
7659  if (Body.isInvalid())
7660  return StmtError();
7661 
7662  // If nothing changed, just retain this statement.
7663  if (!getDerived().AlwaysRebuild() &&
7664  Element.get() == S->getElement() &&
7665  Collection.get() == S->getCollection() &&
7666  Body.get() == S->getBody())
7667  return S;
7668 
7669  // Build a new statement.
7670  return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
7671  Element.get(),
7672  Collection.get(),
7673  S->getRParenLoc(),
7674  Body.get());
7675 }
7676 
7677 template <typename Derived>
7679  // Transform the exception declaration, if any.
7680  VarDecl *Var = nullptr;
7681  if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
7682  TypeSourceInfo *T =
7683  getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
7684  if (!T)
7685  return StmtError();
7686 
7687  Var = getDerived().RebuildExceptionDecl(
7688  ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
7689  ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
7690  if (!Var || Var->isInvalidDecl())
7691  return StmtError();
7692  }
7693 
7694  // Transform the actual exception handler.
7695  StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
7696  if (Handler.isInvalid())
7697  return StmtError();
7698 
7699  if (!getDerived().AlwaysRebuild() && !Var &&
7700  Handler.get() == S->getHandlerBlock())
7701  return S;
7702 
7703  return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
7704 }
7705 
7706 template <typename Derived>
7708  // Transform the try block itself.
7709  StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
7710  if (TryBlock.isInvalid())
7711  return StmtError();
7712 
7713  // Transform the handlers.
7714  bool HandlerChanged = false;
7715  SmallVector<Stmt *, 8> Handlers;
7716  for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
7717  StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
7718  if (Handler.isInvalid())
7719  return StmtError();
7720 
7721  HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
7722  Handlers.push_back(Handler.getAs<Stmt>());
7723  }
7724 
7725  if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
7726  !HandlerChanged)
7727  return S;
7728 
7729  return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
7730  Handlers);
7731 }
7732 
7733 template<typename Derived>
7734 StmtResult
7736  StmtResult Init =
7737  S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
7738  if (Init.isInvalid())
7739  return StmtError();
7740 
7741  StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
7742  if (Range.isInvalid())
7743  return StmtError();
7744 
7745  StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
7746  if (Begin.isInvalid())
7747  return StmtError();
7748  StmtResult End = getDerived().TransformStmt(S->getEndStmt());
7749  if (End.isInvalid())
7750  return StmtError();
7751 
7752  ExprResult Cond = getDerived().TransformExpr(S->getCond());
7753  if (Cond.isInvalid())
7754  return StmtError();
7755  if (Cond.get())
7756  Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
7757  if (Cond.isInvalid())
7758  return StmtError();
7759  if (Cond.get())
7760  Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
7761 
7762  ExprResult Inc = getDerived().TransformExpr(S->getInc());
7763  if (Inc.isInvalid())
7764  return StmtError();
7765  if (Inc.get())
7766  Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
7767 
7768  StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
7769  if (LoopVar.isInvalid())
7770  return StmtError();
7771 
7772  StmtResult NewStmt = S;
7773  if (getDerived().AlwaysRebuild() ||
7774  Init.get() != S->getInit() ||
7775  Range.get() != S->getRangeStmt() ||
7776  Begin.get() != S->getBeginStmt() ||
7777  End.get() != S->getEndStmt() ||
7778  Cond.get() != S->getCond() ||
7779  Inc.get() != S->getInc() ||
7780  LoopVar.get() != S->getLoopVarStmt()) {
7781  NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(),
7782  S->getCoawaitLoc(), Init.get(),
7783  S->getColonLoc(), Range.get(),
7784  Begin.get(), End.get(),
7785  Cond.get(),
7786  Inc.get(), LoopVar.get(),
7787  S->getRParenLoc());
7788  if (NewStmt.isInvalid())
7789  return StmtError();
7790  }
7791 
7792  StmtResult Body = getDerived().TransformStmt(S->getBody());
7793  if (Body.isInvalid())
7794  return StmtError();
7795 
7796  // Body has changed but we didn't rebuild the for-range statement. Rebuild
7797  // it now so we have a new statement to attach the body to.
7798  if (Body.get() != S->getBody() && NewStmt.get() == S) {
7799  NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(),
7800  S->getCoawaitLoc(), Init.get(),
7801  S->getColonLoc(), Range.get(),
7802  Begin.get(), End.get(),
7803  Cond.get(),
7804  Inc.get(), LoopVar.get(),
7805  S->getRParenLoc());
7806  if (NewStmt.isInvalid())
7807  return StmtError();
7808  }
7809 
7810  if (NewStmt.get() == S)
7811  return S;
7812 
7813  return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
7814 }
7815 
7816 template<typename Derived>
7817 StmtResult
7819  MSDependentExistsStmt *S) {
7820  // Transform the nested-name-specifier, if any.
7821  NestedNameSpecifierLoc QualifierLoc;
7822  if (S->getQualifierLoc()) {
7823  QualifierLoc
7824  = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
7825  if (!QualifierLoc)
7826  return StmtError();
7827  }
7828 
7829  // Transform the declaration name.
7830  DeclarationNameInfo NameInfo = S->getNameInfo();
7831  if (NameInfo.getName()) {
7832  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
7833  if (!NameInfo.getName())
7834  return StmtError();
7835  }
7836 
7837  // Check whether anything changed.
7838  if (!getDerived().AlwaysRebuild() &&
7839  QualifierLoc == S->getQualifierLoc() &&
7840  NameInfo.getName() == S->getNameInfo().getName())
7841  return S;
7842 
7843  // Determine whether this name exists, if we can.
7844  CXXScopeSpec SS;
7845  SS.Adopt(QualifierLoc);
7846  bool Dependent = false;
7847  switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
7848  case Sema::IER_Exists:
7849  if (S->isIfExists())
7850  break;
7851 
7852  return new (getSema().Context) NullStmt(S->getKeywordLoc());
7853 
7854  case Sema::IER_DoesNotExist:
7855  if (S->isIfNotExists())
7856  break;
7857 
7858  return new (getSema().Context) NullStmt(S->getKeywordLoc());
7859 
7860  case Sema::IER_Dependent:
7861  Dependent = true;
7862  break;
7863 
7864  case Sema::IER_Error:
7865  return StmtError();
7866  }
7867 
7868  // We need to continue with the instantiation, so do so now.
7869  StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
7870  if (SubStmt.isInvalid())
7871  return StmtError();
7872 
7873  // If we have resolved the name, just transform to the substatement.
7874  if (!Dependent)
7875  return SubStmt;
7876 
7877  // The name is still dependent, so build a dependent expression again.
7878  return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
7879  S->isIfExists(),
7880  QualifierLoc,
7881  NameInfo,
7882  SubStmt.get());
7883 }
7884 
7885 template<typename Derived>
7886 ExprResult
7888  NestedNameSpecifierLoc QualifierLoc;
7889  if (E->getQualifierLoc()) {
7890  QualifierLoc
7891  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
7892  if (!QualifierLoc)
7893  return ExprError();
7894  }
7895 
7896  MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
7897  getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
7898  if (!PD)
7899  return ExprError();
7900 
7901  ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
7902  if (Base.isInvalid())
7903  return ExprError();
7904 
7905  return new (SemaRef.getASTContext())
7906  MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
7907  SemaRef.getASTContext().PseudoObjectTy, VK_LValue,
7908  QualifierLoc, E->getMemberLoc());
7909 }
7910 
7911 template <typename Derived>
7914  auto BaseRes = getDerived().TransformExpr(E->getBase());
7915  if (BaseRes.isInvalid())
7916  return ExprError();
7917  auto IdxRes = getDerived().TransformExpr(E->getIdx());
7918  if (IdxRes.isInvalid())
7919  return ExprError();
7920 
7921  if (!getDerived().AlwaysRebuild() &&
7922  BaseRes.get() == E->getBase() &&
7923  IdxRes.get() == E->getIdx())
7924  return E;
7925 
7926  return getDerived().RebuildArraySubscriptExpr(
7927  BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
7928 }
7929 
7930 template <typename Derived>
7932  StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
7933  if (TryBlock.isInvalid())
7934  return StmtError();
7935 
7936  StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
7937  if (Handler.isInvalid())
7938  return StmtError();
7939 
7940  if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
7941  Handler.get() == S->getHandler())
7942  return S;
7943 
7944  return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
7945  TryBlock.get(), Handler.get());
7946 }
7947 
7948 template <typename Derived>
7950  StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
7951  if (Block.isInvalid())
7952  return StmtError();
7953 
7954  return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
7955 }
7956 
7957 template <typename Derived>
7959  ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
7960  if (FilterExpr.isInvalid())
7961  return StmtError();
7962 
7963  StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
7964  if (Block.isInvalid())
7965  return StmtError();
7966 
7967  return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
7968  Block.get());
7969 }
7970 
7971 template <typename Derived>
7973  if (isa<SEHFinallyStmt>(Handler))
7974  return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
7975  else
7976  return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
7977 }
7978 
7979 template<typename Derived>
7980 StmtResult
7982  return S;
7983 }
7984 
7985 //===----------------------------------------------------------------------===//
7986 // OpenMP directive transformation
7987 //===----------------------------------------------------------------------===//
7988 template <typename Derived>
7991 
7992  // Transform the clauses
7994  ArrayRef<OMPClause *> Clauses = D->clauses();
7995  TClauses.reserve(Clauses.size());
7996  for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
7997  I != E; ++I) {
7998  if (*I) {
7999  getDerived().getSema().StartOpenMPClause((*I)->getClauseKind());
8000  OMPClause *Clause = getDerived().TransformOMPClause(*I);
8001  getDerived().getSema().EndOpenMPClause();
8002  if (Clause)
8003  TClauses.push_back(Clause);
8004  } else {
8005  TClauses.push_back(nullptr);
8006  }
8007  }
8008  StmtResult AssociatedStmt;
8009  if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
8010  getDerived().getSema().ActOnOpenMPRegionStart(D->getDirectiveKind(),
8011  /*CurScope=*/nullptr);
8012  StmtResult Body;
8013  {
8014  Sema::CompoundScopeRAII CompoundScope(getSema());
8016  Body = getDerived().TransformStmt(CS);
8017  }
8018  AssociatedStmt =
8019  getDerived().getSema().ActOnOpenMPRegionEnd(Body, TClauses);
8020  if (AssociatedStmt.isInvalid()) {
8021  return StmtError();
8022  }
8023  }
8024  if (TClauses.size() != Clauses.size()) {
8025  return StmtError();
8026  }
8027 
8028  // Transform directive name for 'omp critical' directive.
8029  DeclarationNameInfo DirName;
8030  if (D->getDirectiveKind() == OMPD_critical) {
8031  DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
8032  DirName = getDerived().TransformDeclarationNameInfo(DirName);
8033  }
8034  OpenMPDirectiveKind CancelRegion = OMPD_unknown;
8035  if (D->getDirectiveKind() == OMPD_cancellation_point) {
8036  CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
8037  } else if (D->getDirectiveKind() == OMPD_cancel) {
8038  CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
8039  }
8040 
8041  return getDerived().RebuildOMPExecutableDirective(
8042  D->getDirectiveKind(), DirName, CancelRegion, TClauses,
8043  AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
8044 }
8045 
8046 template <typename Derived>
8047 StmtResult
8049  DeclarationNameInfo DirName;
8050  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel, DirName, nullptr,
8051  D->getBeginLoc());
8052  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8053  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8054  return Res;
8055 }
8056 
8057 template <typename Derived>
8058 StmtResult
8060  DeclarationNameInfo DirName;
8061  getDerived().getSema().StartOpenMPDSABlock(OMPD_simd, DirName, nullptr,
8062  D->getBeginLoc());
8063  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8064  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8065  return Res;
8066 }
8067 
8068 template <typename Derived>
8069 StmtResult
8071  DeclarationNameInfo DirName;
8072  getDerived().getSema().StartOpenMPDSABlock(OMPD_for, DirName, nullptr,
8073  D->getBeginLoc());
8074  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8075  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8076  return Res;
8077 }
8078 
8079 template <typename Derived>
8080 StmtResult
8082  DeclarationNameInfo DirName;
8083  getDerived().getSema().StartOpenMPDSABlock(OMPD_for_simd, DirName, nullptr,
8084  D->getBeginLoc());
8085  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8086  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8087  return Res;
8088 }
8089 
8090 template <typename Derived>
8091 StmtResult
8093  DeclarationNameInfo DirName;
8094  getDerived().getSema().StartOpenMPDSABlock(OMPD_sections, DirName, nullptr,
8095  D->getBeginLoc());
8096  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8097  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8098  return Res;
8099 }
8100 
8101 template <typename Derived>
8102 StmtResult
8104  DeclarationNameInfo DirName;
8105  getDerived().getSema().StartOpenMPDSABlock(OMPD_section, DirName, nullptr,
8106  D->getBeginLoc());
8107  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8108  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8109  return Res;
8110 }
8111 
8112 template <typename Derived>
8113 StmtResult
8115  DeclarationNameInfo DirName;
8116  getDerived().getSema().StartOpenMPDSABlock(OMPD_single, DirName, nullptr,
8117  D->getBeginLoc());
8118  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8119  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8120  return Res;
8121 }
8122 
8123 template <typename Derived>
8124 StmtResult
8126  DeclarationNameInfo DirName;
8127  getDerived().getSema().StartOpenMPDSABlock(OMPD_master, DirName, nullptr,
8128  D->getBeginLoc());
8129  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8130  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8131  return Res;
8132 }
8133 
8134 template <typename Derived>
8135 StmtResult
8137  getDerived().getSema().StartOpenMPDSABlock(
8138  OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
8139  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8140  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8141  return Res;
8142 }
8143 
8144 template <typename Derived>
8147  DeclarationNameInfo DirName;
8148  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_for, DirName,
8149  nullptr, D->getBeginLoc());
8150  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8151  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8152  return Res;
8153 }
8154 
8155 template <typename Derived>
8158  DeclarationNameInfo DirName;
8159  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_for_simd, DirName,
8160  nullptr, D->getBeginLoc());
8161  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8162  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8163  return Res;
8164 }
8165 
8166 template <typename Derived>
8169  DeclarationNameInfo DirName;
8170  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_master, DirName,
8171  nullptr, D->getBeginLoc());
8172  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8173  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8174  return Res;
8175 }
8176 
8177 template <typename Derived>
8180  DeclarationNameInfo DirName;
8181  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_sections, DirName,
8182  nullptr, D->getBeginLoc());
8183  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8184  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8185  return Res;
8186 }
8187 
8188 template <typename Derived>
8189 StmtResult
8191  DeclarationNameInfo DirName;
8192  getDerived().getSema().StartOpenMPDSABlock(OMPD_task, DirName, nullptr,
8193  D->getBeginLoc());
8194  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8195  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8196  return Res;
8197 }
8198 
8199 template <typename Derived>
8201  OMPTaskyieldDirective *D) {
8202  DeclarationNameInfo DirName;
8203  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskyield, DirName, nullptr,
8204  D->getBeginLoc());
8205  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8206  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8207  return Res;
8208 }
8209 
8210 template <typename Derived>
8211 StmtResult
8213  DeclarationNameInfo DirName;
8214  getDerived().getSema().StartOpenMPDSABlock(OMPD_barrier, DirName, nullptr,
8215  D->getBeginLoc());
8216  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8217  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8218  return Res;
8219 }
8220 
8221 template <typename Derived>
8222 StmtResult
8224  DeclarationNameInfo DirName;
8225  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskwait, DirName, nullptr,
8226  D->getBeginLoc());
8227  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8228  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8229  return Res;
8230 }
8231 
8232 template <typename Derived>
8234  OMPTaskgroupDirective *D) {
8235  DeclarationNameInfo DirName;
8236  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskgroup, DirName, nullptr,
8237  D->getBeginLoc());
8238  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8239  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8240  return Res;
8241 }
8242 
8243 template <typename Derived>
8244 StmtResult
8246  DeclarationNameInfo DirName;
8247  getDerived().getSema().StartOpenMPDSABlock(OMPD_flush, DirName, nullptr,
8248  D->getBeginLoc());
8249  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8250  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8251  return Res;
8252 }
8253 
8254 template <typename Derived>
8255 StmtResult
8257  DeclarationNameInfo DirName;
8258  getDerived().getSema().StartOpenMPDSABlock(OMPD_ordered, DirName, nullptr,
8259  D->getBeginLoc());
8260  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8261  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8262  return Res;
8263 }
8264 
8265 template <typename Derived>
8266 StmtResult
8268  DeclarationNameInfo DirName;
8269  getDerived().getSema().StartOpenMPDSABlock(OMPD_atomic, DirName, nullptr,
8270  D->getBeginLoc());
8271  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8272  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8273  return Res;
8274 }
8275 
8276 template <typename Derived>
8277 StmtResult
8279  DeclarationNameInfo DirName;
8280  getDerived().getSema().StartOpenMPDSABlock(OMPD_target, DirName, nullptr,
8281  D->getBeginLoc());
8282  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8283  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8284  return Res;
8285 }
8286 
8287 template <typename Derived>
8290  DeclarationNameInfo DirName;
8291  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_data, DirName, nullptr,
8292  D->getBeginLoc());
8293  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8294  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8295  return Res;
8296 }
8297 
8298 template <typename Derived>
8301  DeclarationNameInfo DirName;
8302  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_enter_data, DirName,
8303  nullptr, D->getBeginLoc());
8304  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8305  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8306  return Res;
8307 }
8308 
8309 template <typename Derived>
8312  DeclarationNameInfo DirName;
8313  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_exit_data, DirName,
8314  nullptr, D->getBeginLoc());
8315  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8316  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8317  return Res;
8318 }
8319 
8320 template <typename Derived>
8323  DeclarationNameInfo DirName;
8324  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel, DirName,
8325  nullptr, D->getBeginLoc());
8326  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8327  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8328  return Res;
8329 }
8330 
8331 template <typename Derived>
8334  DeclarationNameInfo DirName;
8335  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel_for, DirName,
8336  nullptr, D->getBeginLoc());
8337  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8338  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8339  return Res;
8340 }
8341 
8342 template <typename Derived>
8345  DeclarationNameInfo DirName;
8346  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_update, DirName,
8347  nullptr, D->getBeginLoc());
8348  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8349  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8350  return Res;
8351 }
8352 
8353 template <typename Derived>
8354 StmtResult
8356  DeclarationNameInfo DirName;
8357  getDerived().getSema().StartOpenMPDSABlock(OMPD_teams, DirName, nullptr,
8358  D->getBeginLoc());
8359  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8360  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8361  return Res;
8362 }
8363 
8364 template <typename Derived>
8367  DeclarationNameInfo DirName;
8368  getDerived().getSema().StartOpenMPDSABlock(OMPD_cancellation_point, DirName,
8369  nullptr, D->getBeginLoc());
8370  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8371  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8372  return Res;
8373 }
8374 
8375 template <typename Derived>
8376 StmtResult
8378  DeclarationNameInfo DirName;
8379  getDerived().getSema().StartOpenMPDSABlock(OMPD_cancel, DirName, nullptr,
8380  D->getBeginLoc());
8381  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8382  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8383  return Res;
8384 }
8385 
8386 template <typename Derived>
8387 StmtResult
8389  DeclarationNameInfo DirName;
8390  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop, DirName, nullptr,
8391  D->getBeginLoc());
8392  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8393  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8394  return Res;
8395 }
8396 
8397 template <typename Derived>
8400  DeclarationNameInfo DirName;
8401  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop_simd, DirName,
8402  nullptr, D->getBeginLoc());
8403  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8404  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8405  return Res;
8406 }
8407 
8408 template <typename Derived>
8411  DeclarationNameInfo DirName;
8412  getDerived().getSema().StartOpenMPDSABlock(OMPD_master_taskloop, DirName,
8413  nullptr, D->getBeginLoc());
8414  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8415  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8416  return Res;
8417 }
8418 
8419 template <typename Derived>
8422  DeclarationNameInfo DirName;
8423  getDerived().getSema().StartOpenMPDSABlock(OMPD_master_taskloop_simd, DirName,
8424  nullptr, D->getBeginLoc());
8425  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8426  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8427  return Res;
8428 }
8429 
8430 template <typename Derived>
8433  DeclarationNameInfo DirName;
8434  getDerived().getSema().StartOpenMPDSABlock(
8435  OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
8436  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8437  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8438  return Res;
8439 }
8440 
8441 template <typename Derived>
8442 StmtResult
8445  DeclarationNameInfo DirName;
8446  getDerived().getSema().StartOpenMPDSABlock(
8447  OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
8448  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8449  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8450  return Res;
8451 }
8452 
8453 template <typename Derived>
8456  DeclarationNameInfo DirName;
8457  getDerived().getSema().StartOpenMPDSABlock(OMPD_distribute, DirName, nullptr,
8458  D->getBeginLoc());
8459  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8460  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8461  return Res;
8462 }
8463 
8464 template <typename Derived>
8467  DeclarationNameInfo DirName;
8468  getDerived().getSema().StartOpenMPDSABlock(
8469  OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
8470  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8471  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8472  return Res;
8473 }
8474 
8475 template <typename Derived>
8476 StmtResult
8479  DeclarationNameInfo DirName;
8480  getDerived().getSema().StartOpenMPDSABlock(
8481  OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
8482  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8483  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8484  return Res;
8485 }
8486 
8487 template <typename Derived>
8490  DeclarationNameInfo DirName;
8491  getDerived().getSema().StartOpenMPDSABlock(OMPD_distribute_simd, DirName,
8492  nullptr, D->getBeginLoc());
8493  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8494  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8495  return Res;
8496 }
8497 
8498 template <typename Derived>
8501  DeclarationNameInfo DirName;
8502  getDerived().getSema().StartOpenMPDSABlock(
8503  OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
8504  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8505  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8506  return Res;
8507 }
8508 
8509 template <typename Derived>
8512  DeclarationNameInfo DirName;
8513  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_simd, DirName, nullptr,
8514  D->getBeginLoc());
8515  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8516  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8517  return Res;
8518 }
8519 
8520 template <typename Derived>
8523  DeclarationNameInfo DirName;
8524  getDerived().getSema().StartOpenMPDSABlock(OMPD_teams_distribute, DirName,
8525  nullptr, D->getBeginLoc());
8526  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8527  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8528  return Res;
8529 }
8530 
8531 template <typename Derived>
8534  DeclarationNameInfo DirName;
8535  getDerived().getSema().StartOpenMPDSABlock(
8536  OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
8537  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8538  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8539  return Res;
8540 }
8541 
8542 template <typename Derived>
8545  DeclarationNameInfo DirName;
8546  getDerived().getSema().StartOpenMPDSABlock(
8547  OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
8548  D->getBeginLoc());
8549  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8550  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8551  return Res;
8552 }
8553 
8554 template <typename Derived>
8557  DeclarationNameInfo DirName;
8558  getDerived().getSema().StartOpenMPDSABlock(
8559  OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
8560  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8561  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8562  return Res;
8563 }
8564 
8565 template <typename Derived>
8568  DeclarationNameInfo DirName;
8569  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_teams, DirName,
8570  nullptr, D->getBeginLoc());
8571  auto Res = getDerived().TransformOMPExecutableDirective(D);
8572  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8573  return Res;
8574 }
8575 
8576 template <typename Derived>
8579  DeclarationNameInfo DirName;
8580  getDerived().getSema().StartOpenMPDSABlock(
8581  OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
8582  auto Res = getDerived().TransformOMPExecutableDirective(D);
8583  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8584  return Res;
8585 }
8586 
8587 template <typename Derived>
8588 StmtResult
8591  DeclarationNameInfo DirName;
8592  getDerived().getSema().StartOpenMPDSABlock(
8593  OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
8594  D->getBeginLoc());
8595  auto Res = getDerived().TransformOMPExecutableDirective(D);
8596  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8597  return Res;
8598 }
8599 
8600 template <typename Derived>
8604  DeclarationNameInfo DirName;
8605  getDerived().getSema().StartOpenMPDSABlock(
8606  OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
8607  D->getBeginLoc());
8608  auto Res = getDerived().TransformOMPExecutableDirective(D);
8609  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8610  return Res;
8611 }
8612 
8613 template <typename Derived>
8614 StmtResult
8617  DeclarationNameInfo DirName;
8618  getDerived().getSema().StartOpenMPDSABlock(
8619  OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
8620  auto Res = getDerived().TransformOMPExecutableDirective(D);
8621  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8622  return Res;
8623 }
8624 
8625 
8626 //===----------------------------------------------------------------------===//
8627 // OpenMP clause transformation
8628 //===----------------------------------------------------------------------===//
8629 template <typename Derived>
8631  ExprResult Cond = getDerived().TransformExpr(C->getCondition());
8632  if (Cond.isInvalid())
8633  return nullptr;
8634  return getDerived().RebuildOMPIfClause(
8635  C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
8636  C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
8637 }
8638 
8639 template <typename Derived>
8641  ExprResult Cond = getDerived().TransformExpr(C->getCondition());
8642  if (Cond.isInvalid())
8643  return nullptr;
8644  return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
8645  C->getLParenLoc(), C->getEndLoc());
8646 }
8647 
8648 template <typename Derived>
8649 OMPClause *
8651  ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
8652  if (NumThreads.isInvalid())
8653  return nullptr;
8654  return getDerived().RebuildOMPNumThreadsClause(
8655  NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8656 }
8657 
8658 template <typename Derived>
8659 OMPClause *
8661  ExprResult E = getDerived().TransformExpr(C->getSafelen());
8662  if (E.isInvalid())
8663  return nullptr;
8664  return getDerived().RebuildOMPSafelenClause(
8665  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8666 }
8667 
8668 template <typename Derived>
8669 OMPClause *
8671  ExprResult E = getDerived().TransformExpr(C->getAllocator());
8672  if (E.isInvalid())
8673  return nullptr;
8674  return getDerived().RebuildOMPAllocatorClause(
8675  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8676 }
8677 
8678 template <typename Derived>
8679 OMPClause *
8681  ExprResult E = getDerived().TransformExpr(C->getSimdlen());
8682  if (E.isInvalid())
8683  return nullptr;
8684  return getDerived().RebuildOMPSimdlenClause(
8685  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8686 }
8687 
8688 template <typename Derived>
8689 OMPClause *
8691  ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
8692  if (E.isInvalid())
8693  return nullptr;
8694  return getDerived().RebuildOMPCollapseClause(
8695  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8696 }
8697 
8698 template <typename Derived>
8699 OMPClause *
8701  return getDerived().RebuildOMPDefaultClause(
8703  C->getLParenLoc(), C->getEndLoc());
8704 }
8705 
8706 template <typename Derived>
8707 OMPClause *
8709  return getDerived().RebuildOMPProcBindClause(
8711  C->getLParenLoc(), C->getEndLoc());
8712 }
8713 
8714 template <typename Derived>
8715 OMPClause *
8717  ExprResult E = getDerived().TransformExpr(C->getChunkSize());
8718  if (E.isInvalid())
8719  return nullptr;
8720  return getDerived().RebuildOMPScheduleClause(
8722  C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
8724  C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
8725 }
8726 
8727 template <typename Derived>
8728 OMPClause *
8730  ExprResult E;
8731  if (auto *Num = C->getNumForLoops()) {
8732  E = getDerived().TransformExpr(Num);
8733  if (E.isInvalid())
8734  return nullptr;
8735  }
8736  return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
8737  C->getLParenLoc(), E.get());
8738 }
8739 
8740 template <typename Derived>
8741 OMPClause *
8743  // No need to rebuild this clause, no template-dependent parameters.
8744  return C;
8745 }
8746 
8747 template <typename Derived>
8748 OMPClause *
8750  // No need to rebuild this clause, no template-dependent parameters.
8751  return C;
8752 }
8753 
8754 template <typename Derived>
8755 OMPClause *
8757  // No need to rebuild this clause, no template-dependent parameters.
8758  return C;
8759 }
8760 
8761 template <typename Derived>
8763  // No need to rebuild this clause, no template-dependent parameters.
8764  return C;
8765 }
8766 
8767 template <typename Derived>
8769  // No need to rebuild this clause, no template-dependent parameters.
8770  return C;
8771 }
8772 
8773 template <typename Derived>
8774 OMPClause *
8776  // No need to rebuild this clause, no template-dependent parameters.
8777  return C;
8778 }
8779 
8780 template <typename Derived>
8781 OMPClause *
8783  // No need to rebuild this clause, no template-dependent parameters.
8784  return C;
8785 }
8786 
8787 template <typename Derived>
8788 OMPClause *
8790  // No need to rebuild this clause, no template-dependent parameters.
8791  return C;
8792 }
8793 
8794 template <typename Derived>
8795 OMPClause *
8797  // No need to rebuild this clause, no template-dependent parameters.
8798  return C;
8799 }
8800 
8801 template <typename Derived>
8803  // No need to rebuild this clause, no template-dependent parameters.
8804  return C;
8805 }
8806 
8807 template <typename Derived>
8808 OMPClause *
8810  // No need to rebuild this clause, no template-dependent parameters.
8811  return C;
8812 }
8813 
8814 template <typename Derived>
8817  llvm_unreachable("unified_address clause cannot appear in dependent context");
8818 }
8819 
8820 template <typename Derived>
8823  llvm_unreachable(
8824  "unified_shared_memory clause cannot appear in dependent context");
8825 }
8826 
8827 template <typename Derived>
8830  llvm_unreachable("reverse_offload clause cannot appear in dependent context");
8831 }
8832 
8833 template <typename Derived>
8836  llvm_unreachable(
8837  "dynamic_allocators clause cannot appear in dependent context");
8838 }
8839 
8840 template <typename Derived>
8843  llvm_unreachable(
8844  "atomic_default_mem_order clause cannot appear in dependent context");
8845 }
8846 
8847 template <typename Derived>
8848 OMPClause *
8851  Vars.reserve(C->varlist_size());
8852  for (auto *VE : C->varlists()) {
8853  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8854  if (EVar.isInvalid())
8855  return nullptr;
8856  Vars.push_back(EVar.get());
8857  }
8858  return getDerived().RebuildOMPPrivateClause(
8859  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8860 }
8861 
8862 template <typename Derived>
8864  OMPFirstprivateClause *C) {
8866  Vars.reserve(C->varlist_size());
8867  for (auto *VE : C->varlists()) {
8868  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8869  if (EVar.isInvalid())
8870  return nullptr;
8871  Vars.push_back(EVar.get());
8872  }
8873  return getDerived().RebuildOMPFirstprivateClause(
8874  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8875 }
8876 
8877 template <typename Derived>
8878 OMPClause *
8881  Vars.reserve(C->varlist_size());
8882  for (auto *VE : C->varlists()) {
8883  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8884  if (EVar.isInvalid())
8885  return nullptr;
8886  Vars.push_back(EVar.get());
8887  }
8888  return getDerived().RebuildOMPLastprivateClause(
8889  Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
8890  C->getLParenLoc(), C->getEndLoc());
8891 }
8892 
8893 template <typename Derived>
8894 OMPClause *
8897  Vars.reserve(C->varlist_size());
8898  for (auto *VE : C->varlists()) {
8899  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8900  if (EVar.isInvalid())
8901  return nullptr;
8902  Vars.push_back(EVar.get());
8903  }
8904  return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
8905  C->getLParenLoc(), C->getEndLoc());
8906 }
8907 
8908 template <typename Derived>
8909 OMPClause *
8912  Vars.reserve(C->varlist_size());
8913  for (auto *VE : C->varlists()) {
8914  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8915  if (EVar.isInvalid())
8916  return nullptr;
8917  Vars.push_back(EVar.get());
8918  }
8919  CXXScopeSpec ReductionIdScopeSpec;
8920  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8921 
8922  DeclarationNameInfo NameInfo = C->getNameInfo();
8923  if (NameInfo.getName()) {
8924  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8925  if (!NameInfo.getName())
8926  return nullptr;
8927  }
8928  // Build a list of all UDR decls with the same names ranged by the Scopes.
8929  // The Scope boundary is a duplication of the previous decl.
8930  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8931  for (auto *E : C->reduction_ops()) {
8932  // Transform all the decls.
8933  if (E) {
8934  auto *ULE = cast<UnresolvedLookupExpr>(E);
8935  UnresolvedSet<8> Decls;
8936  for (auto *D : ULE->decls()) {
8937  NamedDecl *InstD =
8938  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8939  Decls.addDecl(InstD, InstD->getAccess());
8940  }
8941  UnresolvedReductions.push_back(
8943  SemaRef.Context, /*NamingClass=*/nullptr,
8944  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context),
8945  NameInfo, /*ADL=*/true, ULE->isOverloaded(),
8946  Decls.begin(), Decls.end()));
8947  } else
8948  UnresolvedReductions.push_back(nullptr);
8949  }
8950  return getDerived().RebuildOMPReductionClause(
8951  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
8952  C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8953 }
8954 
8955 template <typename Derived>
8959  Vars.reserve(C->varlist_size());
8960  for (auto *VE : C->varlists()) {
8961  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8962  if (EVar.isInvalid())
8963  return nullptr;
8964  Vars.push_back(EVar.get());
8965  }
8966  CXXScopeSpec ReductionIdScopeSpec;
8967  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8968 
8969  DeclarationNameInfo NameInfo = C->getNameInfo();
8970  if (NameInfo.getName()) {
8971  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8972  if (!NameInfo.getName())
8973  return nullptr;
8974  }
8975  // Build a list of all UDR decls with the same names ranged by the Scopes.
8976  // The Scope boundary is a duplication of the previous decl.
8977  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8978  for (auto *E : C->reduction_ops()) {
8979  // Transform all the decls.
8980  if (E) {
8981  auto *ULE = cast<UnresolvedLookupExpr>(E);
8982  UnresolvedSet<8> Decls;
8983  for (auto *D : ULE->decls()) {
8984  NamedDecl *InstD =
8985  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8986  Decls.addDecl(InstD, InstD->getAccess());
8987  }
8988  UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
8989  SemaRef.Context, /*NamingClass=*/nullptr,
8990  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
8991  /*ADL=*/true, ULE->isOverloaded(), Decls.begin(), Decls.end()));
8992  } else
8993  UnresolvedReductions.push_back(nullptr);
8994  }
8995  return getDerived().RebuildOMPTaskReductionClause(
8996  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
8997  C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8998 }
8999 
9000 template <typename Derived>
9001 OMPClause *
9004  Vars.reserve(C->varlist_size());
9005  for (auto *VE : C->varlists()) {
9006  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9007  if (EVar.isInvalid())
9008  return nullptr;
9009  Vars.push_back(EVar.get());
9010  }
9011  CXXScopeSpec ReductionIdScopeSpec;
9012  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
9013 
9014  DeclarationNameInfo NameInfo = C->getNameInfo();
9015  if (NameInfo.getName()) {
9016  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9017  if (!NameInfo.getName())
9018  return nullptr;
9019  }
9020  // Build a list of all UDR decls with the same names ranged by the Scopes.
9021  // The Scope boundary is a duplication of the previous decl.
9022  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
9023  for (auto *E : C->reduction_ops()) {
9024  // Transform all the decls.
9025  if (E) {
9026  auto *ULE = cast<UnresolvedLookupExpr>(E);
9027  UnresolvedSet<8> Decls;
9028  for (auto *D : ULE->decls()) {
9029  NamedDecl *InstD =
9030  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
9031  Decls.addDecl(InstD, InstD->getAccess());
9032  }
9033  UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
9034  SemaRef.Context, /*NamingClass=*/nullptr,
9035  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
9036  /*ADL=*/true, ULE->isOverloaded(), Decls.begin(), Decls.end()));
9037  } else
9038  UnresolvedReductions.push_back(nullptr);
9039  }
9040  return getDerived().RebuildOMPInReductionClause(
9041  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
9042  C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
9043 }
9044 
9045 template <typename Derived>
9046 OMPClause *
9049  Vars.reserve(C->varlist_size());
9050  for (auto *VE : C->varlists()) {
9051  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9052  if (EVar.isInvalid())
9053  return nullptr;
9054  Vars.push_back(EVar.get());
9055  }
9056  ExprResult Step = getDerived().TransformExpr(C->getStep());
9057  if (Step.isInvalid())
9058  return nullptr;
9059  return getDerived().RebuildOMPLinearClause(
9060  Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
9061  C->getModifierLoc(), C->getColonLoc(), C->getEndLoc());
9062 }
9063 
9064 template <typename Derived>
9065 OMPClause *
9068  Vars.reserve(C->varlist_size());
9069  for (auto *VE : C->varlists()) {
9070  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9071  if (EVar.isInvalid())
9072  return nullptr;
9073  Vars.push_back(EVar.get());
9074  }
9075  ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
9076  if (Alignment.isInvalid())
9077  return nullptr;
9078  return getDerived().RebuildOMPAlignedClause(
9079  Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
9080  C->getColonLoc(), C->getEndLoc());
9081 }
9082 
9083 template <typename Derived>
9084 OMPClause *
9087  Vars.reserve(C->varlist_size());
9088  for (auto *VE : C->varlists()) {
9089  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9090  if (EVar.isInvalid())
9091  return nullptr;
9092  Vars.push_back(EVar.get());
9093  }
9094  return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
9095  C->getLParenLoc(), C->getEndLoc());
9096 }
9097 
9098 template <typename Derived>
9099 OMPClause *
9102  Vars.reserve(C->varlist_size());
9103  for (auto *VE : C->varlists()) {
9104  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9105  if (EVar.isInvalid())
9106  return nullptr;
9107  Vars.push_back(EVar.get());
9108  }
9109  return getDerived().RebuildOMPCopyprivateClause(
9110  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9111 }
9112 
9113 template <typename Derived>
9116  Vars.reserve(C->varlist_size());
9117  for (auto *VE : C->varlists()) {
9118  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9119  if (EVar.isInvalid())
9120  return nullptr;
9121  Vars.push_back(EVar.get());
9122  }
9123  return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
9124  C->getLParenLoc(), C->getEndLoc());
9125 }
9126 
9127 template <typename Derived>
9128 OMPClause *
9131  Vars.reserve(C->varlist_size());
9132  for (auto *VE : C->varlists()) {
9133  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9134  if (EVar.isInvalid())
9135  return nullptr;
9136  Vars.push_back(EVar.get());
9137  }
9138  return getDerived().RebuildOMPDependClause(
9139  C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(), Vars,
9140  C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9141 }
9142 
9143 template <typename Derived>
9144 OMPClause *
9146  ExprResult E = getDerived().TransformExpr(C->getDevice());
9147  if (E.isInvalid())
9148  return nullptr;
9149  return getDerived().RebuildOMPDeviceClause(E.get(), C->getBeginLoc(),
9150  C->getLParenLoc(), C->getEndLoc());
9151 }
9152 
9153 template <typename Derived, class T>
9156  llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
9157  DeclarationNameInfo &MapperIdInfo,
9158  llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
9159  // Transform expressions in the list.
9160  Vars.reserve(C->varlist_size());
9161  for (auto *VE : C->varlists()) {
9162  ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
9163  if (EVar.isInvalid())
9164  return true;
9165  Vars.push_back(EVar.get());
9166  }
9167  // Transform mapper scope specifier and identifier.
9168  NestedNameSpecifierLoc QualifierLoc;
9169  if (C->getMapperQualifierLoc()) {
9170  QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
9171  C->getMapperQualifierLoc());
9172  if (!QualifierLoc)
9173  return true;
9174  }
9175  MapperIdScopeSpec.Adopt(QualifierLoc);
9176  MapperIdInfo = C->getMapperIdInfo();
9177  if (MapperIdInfo.getName()) {
9178  MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
9179  if (!MapperIdInfo.getName())
9180  return true;
9181  }
9182  // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
9183  // the previous user-defined mapper lookup in dependent environment.
9184  for (auto *E : C->mapperlists()) {
9185  // Transform all the decls.
9186  if (E) {
9187  auto *ULE = cast<UnresolvedLookupExpr>(E);
9188  UnresolvedSet<8> Decls;
9189  for (auto *D : ULE->decls()) {
9190  NamedDecl *InstD =
9191  cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
9192  Decls.addDecl(InstD, InstD->getAccess());
9193  }
9194  UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
9195  TT.getSema().Context, /*NamingClass=*/nullptr,
9196  MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
9197  MapperIdInfo, /*ADL=*/true, ULE->isOverloaded(), Decls.begin(),
9198  Decls.end()));
9199  } else {
9200  UnresolvedMappers.push_back(nullptr);
9201  }
9202  }
9203  return false;
9204 }
9205 
9206 template <typename Derived>
9208  OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9210  CXXScopeSpec MapperIdScopeSpec;
9211  DeclarationNameInfo MapperIdInfo;
9212  llvm::SmallVector<Expr *, 16> UnresolvedMappers;
9213  if (transformOMPMappableExprListClause<Derived, OMPMapClause>(
9214  *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
9215  return nullptr;
9216  return getDerived().RebuildOMPMapClause(
9217  C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(), MapperIdScopeSpec,
9218  MapperIdInfo, C->getMapType(), C->isImplicitMapType(), C->getMapLoc(),
9219  C->getColonLoc(), Vars, Locs, UnresolvedMappers);
9220 }
9221 
9222 template <typename Derived>
9223 OMPClause *
9225  Expr *Allocator = C->getAllocator();
9226  if (Allocator) {
9227  ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
9228  if (AllocatorRes.isInvalid())
9229  return nullptr;
9230  Allocator = AllocatorRes.get();
9231  }
9233  Vars.reserve(C->varlist_size());
9234  for (auto *VE : C->varlists()) {
9235  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9236  if (EVar.isInvalid())
9237  return nullptr;
9238  Vars.push_back(EVar.get());
9239  }
9240  return getDerived().RebuildOMPAllocateClause(
9241  Allocator, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
9242  C->getEndLoc());
9243 }
9244 
9245 template <typename Derived>
9246 OMPClause *
9248  ExprResult E = getDerived().TransformExpr(C->getNumTeams());
9249  if (E.isInvalid())
9250  return nullptr;
9251  return getDerived().RebuildOMPNumTeamsClause(
9252  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9253 }
9254 
9255 template <typename Derived>
9256 OMPClause *
9258  ExprResult E = getDerived().TransformExpr(C->getThreadLimit());
9259  if (E.isInvalid())
9260  return nullptr;
9261  return getDerived().RebuildOMPThreadLimitClause(
9262  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9263 }
9264 
9265 template <typename Derived>
9266 OMPClause *
9268  ExprResult E = getDerived().TransformExpr(C->getPriority());
9269  if (E.isInvalid())
9270  return nullptr;
9271  return getDerived().RebuildOMPPriorityClause(
9272  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9273 }
9274 
9275 template <typename Derived>
9276 OMPClause *
9278  ExprResult E = getDerived().TransformExpr(C->getGrainsize());
9279  if (E.isInvalid())
9280  return nullptr;
9281  return getDerived().RebuildOMPGrainsizeClause(
9282  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9283 }
9284 
9285 template <typename Derived>
9286 OMPClause *
9288  ExprResult E = getDerived().TransformExpr(C->getNumTasks());
9289  if (E.isInvalid())
9290  return nullptr;
9291  return getDerived().RebuildOMPNumTasksClause(
9292  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9293 }
9294 
9295 template <typename Derived>
9297  ExprResult E = getDerived().TransformExpr(C->getHint());
9298  if (E.isInvalid())
9299  return nullptr;
9300  return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
9301  C->getLParenLoc(), C->getEndLoc());
9302 }
9303 
9304 template <typename Derived>
9306  OMPDistScheduleClause *C) {
9307  ExprResult E = getDerived().TransformExpr(C->getChunkSize());
9308  if (E.isInvalid())
9309  return nullptr;
9310  return getDerived().RebuildOMPDistScheduleClause(
9311  C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
9312  C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
9313 }
9314 
9315 template <typename Derived>
9316 OMPClause *
9318  // Rebuild Defaultmap Clause since we need to invoke the checking of
9319  // defaultmap(none:variable-category) after template initialization.
9320  return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
9321  C->getDefaultmapKind(),
9322  C->getBeginLoc(),
9323  C->getLParenLoc(),
9325  C->getDefaultmapKindLoc(),
9326  C->getEndLoc());
9327 }
9328 
9329 template <typename Derived>
9331  OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9333  CXXScopeSpec MapperIdScopeSpec;
9334  DeclarationNameInfo MapperIdInfo;
9335  llvm::SmallVector<Expr *, 16> UnresolvedMappers;
9336  if (transformOMPMappableExprListClause<Derived, OMPToClause>(
9337  *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
9338  return nullptr;
9339  return getDerived().RebuildOMPToClause(Vars, MapperIdScopeSpec, MapperIdInfo,
9340  Locs, UnresolvedMappers);
9341 }
9342 
9343 template <typename Derived>
9345  OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9347  CXXScopeSpec MapperIdScopeSpec;
9348  DeclarationNameInfo MapperIdInfo;
9349  llvm::SmallVector<Expr *, 16> UnresolvedMappers;
9350  if (transformOMPMappableExprListClause<Derived, OMPFromClause>(
9351  *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
9352  return nullptr;
9353  return getDerived().RebuildOMPFromClause(
9354  Vars, MapperIdScopeSpec, MapperIdInfo, Locs, UnresolvedMappers);
9355 }
9356 
9357 template <typename Derived>
9359  OMPUseDevicePtrClause *C) {
9361  Vars.reserve(C->varlist_size());
9362  for (auto *VE : C->varlists()) {
9363  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9364  if (EVar.isInvalid())
9365  return nullptr;
9366  Vars.push_back(EVar.get());
9367  }
9368  OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9369  return getDerived().RebuildOMPUseDevicePtrClause(Vars, Locs);
9370 }
9371 
9372 template <typename Derived>
9373 OMPClause *
9376  Vars.reserve(C->varlist_size());
9377  for (auto *VE : C->varlists()) {
9378  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9379  if (EVar.isInvalid())
9380  return nullptr;
9381  Vars.push_back(EVar.get());
9382  }
9383  OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9384  return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
9385 }
9386 
9387 template <typename Derived>
9388 OMPClause *
9391  Vars.reserve(C->varlist_size());
9392  for (auto *VE : C->varlists()) {
9393  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
9394  if (EVar.isInvalid())
9395  return nullptr;
9396  Vars.push_back(EVar.get());
9397  }
9398  return getDerived().RebuildOMPNontemporalClause(
9399  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9400 }
9401 
9402 //===----------------------------------------------------------------------===//
9403 // Expression transformation
9404 //===----------------------------------------------------------------------===//
9405 template<typename Derived>
9406 ExprResult
9408  return TransformExpr(E->getSubExpr());
9409 }
9410 
9411 template<typename Derived>
9412 ExprResult
9414  if (!E->isTypeDependent())
9415  return E;
9416 
9417  return getDerived().RebuildPredefinedExpr(E->getLocation(),
9418  E->getIdentKind());
9419 }
9420 
9421 template<typename Derived>
9422 ExprResult
9424  NestedNameSpecifierLoc QualifierLoc;
9425  if (E->getQualifierLoc()) {
9426  QualifierLoc
9427  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9428  if (!QualifierLoc)
9429  return ExprError();
9430  }
9431 
9432  ValueDecl *ND
9433  = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
9434  E->getDecl()));
9435  if (!ND)
9436  return ExprError();
9437 
9438  NamedDecl *Found = ND;
9439  if (E->getFoundDecl() != E->getDecl()) {
9440  Found = cast_or_null<NamedDecl>(
9441  getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
9442  if (!Found)
9443  return ExprError();
9444  }
9445 
9446  DeclarationNameInfo NameInfo = E->getNameInfo();
9447  if (NameInfo.getName()) {
9448  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9449  if (!NameInfo.getName())
9450  return ExprError();
9451  }
9452 
9453  if (!getDerived().AlwaysRebuild() &&
9454  QualifierLoc == E->getQualifierLoc() &&
9455  ND == E->getDecl() &&
9456  Found == E->getFoundDecl() &&
9457  NameInfo.getName() == E->getDecl()->getDeclName() &&
9458  !E->hasExplicitTemplateArgs()) {
9459 
9460  // Mark it referenced in the new context regardless.
9461  // FIXME: this is a bit instantiation-specific.
9462  SemaRef.MarkDeclRefReferenced(E);
9463 
9464  return E;
9465  }
9466 
9467  TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
9468  if (E->hasExplicitTemplateArgs()) {
9469  TemplateArgs = &TransArgs;
9470  TransArgs.setLAngleLoc(E->getLAngleLoc());
9471  TransArgs.setRAngleLoc(E->getRAngleLoc());
9472  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
9473  E->getNumTemplateArgs(),
9474  TransArgs))
9475  return ExprError();
9476  }
9477 
9478  return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
9479  Found, TemplateArgs);
9480 }
9481 
9482 template<typename Derived>
9483 ExprResult
9485  return E;
9486 }
9487 
9488 template <typename Derived>
9490  FixedPointLiteral *E) {
9491  return E;
9492 }
9493 
9494 template<typename Derived>
9495 ExprResult
9497  return E;
9498 }
9499 
9500 template<typename Derived>
9501 ExprResult
9503  return E;
9504 }
9505 
9506 template<typename Derived>
9507 ExprResult
9509  return E;
9510 }
9511 
9512 template<typename Derived>
9513 ExprResult
9515  return E;
9516 }
9517 
9518 template<typename Derived>
9519 ExprResult
9521  if (FunctionDecl *FD = E->getDirectCallee())
9522  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), FD);
9523  return SemaRef.MaybeBindToTemporary(E);
9524 }
9525 
9526 template<typename Derived>
9527 ExprResult
9529  ExprResult ControllingExpr =
9530  getDerived().TransformExpr(E->getControllingExpr());
9531  if (ControllingExpr.isInvalid())
9532  return ExprError();
9533 
9534  SmallVector<Expr *, 4> AssocExprs;
9536  for (const GenericSelectionExpr::Association Assoc : E->associations()) {
9537  TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
9538  if (TSI) {
9539  TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
9540  if (!AssocType)
9541  return ExprError();
9542  AssocTypes.push_back(AssocType);
9543  } else {
9544  AssocTypes.push_back(nullptr);
9545  }
9546 
9547  ExprResult AssocExpr =
9548  getDerived().TransformExpr(Assoc.getAssociationExpr());
9549  if (AssocExpr.isInvalid())
9550  return ExprError();
9551  AssocExprs.push_back(AssocExpr.get());
9552  }
9553 
9554  return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
9555  E->getDefaultLoc(),
9556  E->getRParenLoc(),
9557  ControllingExpr.get(),
9558  AssocTypes,
9559  AssocExprs);
9560 }
9561 
9562 template<typename Derived>
9563 ExprResult
9565  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
9566  if (SubExpr.isInvalid())
9567  return ExprError();
9568 
9569  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
9570  return E;
9571 
9572  return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
9573  E->getRParen());
9574 }
9575 
9576 /// The operand of a unary address-of operator has special rules: it's
9577 /// allowed to refer to a non-static member of a class even if there's no 'this'
9578 /// object available.
9579 template<typename Derived>
9580 ExprResult
9582  if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
9583  return getDerived().TransformDependentScopeDeclRefExpr(DRE, true, nullptr);
9584  else
9585  return getDerived().TransformExpr(E);
9586 }
9587 
9588 template<typename Derived>
9589 ExprResult
9591  ExprResult SubExpr;
9592  if (E->getOpcode() == UO_AddrOf)
9593  SubExpr = TransformAddressOfOperand(E->getSubExpr());
9594  else
9595  SubExpr = TransformExpr(E->getSubExpr());
9596  if (SubExpr.isInvalid())
9597  return ExprError();
9598 
9599  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
9600  return E;
9601 
9602  return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
9603  E->getOpcode(),
9604  SubExpr.get());
9605 }
9606 
9607 template<typename Derived>
9608 ExprResult
9610  // Transform the type.
9611  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
9612  if (!Type)
9613  return ExprError();
9614 
9615  // Transform all of the components into components similar to what the
9616  // parser uses.
9617  // FIXME: It would be slightly more efficient in the non-dependent case to
9618  // just map FieldDecls, rather than requiring the rebuilder to look for
9619  // the fields again. However, __builtin_offsetof is rare enough in
9620  // template code that we don't care.
9621  bool ExprChanged = false;
9622  typedef Sema::OffsetOfComponent Component;
9623  SmallVector<Component, 4> Components;
9624  for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
9625  const OffsetOfNode &ON = E->getComponent(I);
9626  Component Comp;
9627  Comp.isBrackets = true;
9628  Comp.LocStart = ON.getSourceRange().getBegin();
9629  Comp.LocEnd = ON.getSourceRange().getEnd();
9630  switch (ON.getKind()) {
9631  case OffsetOfNode::Array: {
9632  Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
9633  ExprResult Index = getDerived().TransformExpr(FromIndex);
9634  if (Index.isInvalid())
9635  return ExprError();
9636 
9637  ExprChanged = ExprChanged || Index.get() != FromIndex;
9638  Comp.isBrackets = true;
9639  Comp.U.E = Index.get();
9640  break;
9641  }
9642 
9643  case OffsetOfNode::Field:
9645  Comp.isBrackets = false;
9646  Comp.U.IdentInfo = ON.getFieldName();
9647  if (!Comp.U.IdentInfo)
9648  continue;
9649 
9650  break;
9651 
9652  case OffsetOfNode::Base:
9653  // Will be recomputed during the rebuild.
9654  continue;
9655  }
9656 
9657  Components.push_back(Comp);
9658  }
9659 
9660  // If nothing changed, retain the existing expression.
9661  if (!getDerived().AlwaysRebuild() &&
9662  Type == E->getTypeSourceInfo() &&
9663  !ExprChanged)
9664  return E;
9665 
9666  // Build a new offsetof expression.
9667  return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
9668  Components, E->getRParenLoc());
9669 }
9670 
9671 template<typename Derived>
9672 ExprResult
9674  assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
9675  "opaque value expression requires transformation");
9676  return E;
9677 }
9678 
9679 template<typename Derived>
9680 ExprResult
9682  return E;
9683 }
9684 
9685 template<typename Derived>
9686 ExprResult
9688  // Rebuild the syntactic form. The original syntactic form has
9689  // opaque-value expressions in it, so strip those away and rebuild
9690  // the result. This is a really awful way of doing this, but the
9691  // better solution (rebuilding the semantic expressions and
9692  // rebinding OVEs as necessary) doesn't work; we'd need
9693  // TreeTransform to not strip away implicit conversions.
9694  Expr *newSyntacticForm = SemaRef.recreateSyntacticForm(E);
9695  ExprResult result = getDerived().TransformExpr(newSyntacticForm);
9696  if (result.isInvalid()) return ExprError();
9697 
9698  // If that gives us a pseudo-object result back, the pseudo-object
9699  // expression must have been an lvalue-to-rvalue conversion which we
9700  // should reapply.
9701  if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
9702  result = SemaRef.checkPseudoObjectRValue(result.get());
9703 
9704  return result;
9705 }
9706 
9707 template<typename Derived>
9708 ExprResult
9711  if (E->isArgumentType()) {
9712  TypeSourceInfo *OldT = E->getArgumentTypeInfo();
9713 
9714  TypeSourceInfo *NewT = getDerived().TransformType(OldT);
9715  if (!NewT)
9716  return ExprError();
9717 
9718  if (!getDerived().AlwaysRebuild() && OldT == NewT)
9719  return E;
9720 
9721  return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
9722  E->getKind(),
9723  E->getSourceRange());
9724  }
9725 
9726  // C++0x [expr.sizeof]p1:
9727  // The operand is either an expression, which is an unevaluated operand
9728  // [...]
9730  SemaRef, Sema::ExpressionEvaluationContext::Unevaluated,
9731  Sema::ReuseLambdaContextDecl);
9732 
9733  // Try to recover if we have something like sizeof(T::X) where X is a type.
9734  // Notably, there must be *exactly* one set of parens if X is a type.
9735  TypeSourceInfo *RecoveryTSI = nullptr;
9736  ExprResult SubExpr;
9737  auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
9738  if (auto *DRE =
9739  PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
9740  SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
9741  PE, DRE, false, &RecoveryTSI);
9742  else
9743  SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
9744 
9745  if (RecoveryTSI) {
9746  return getDerived().RebuildUnaryExprOrTypeTrait(
9747  RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
9748  } else if (SubExpr.isInvalid())
9749  return ExprError();
9750 
9751  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
9752  return E;
9753 
9754  return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
9755  E->getOperatorLoc(),
9756  E->getKind(),
9757  E->getSourceRange());
9758 }
9759 
9760 template<typename Derived>
9761 ExprResult
9763  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9764  if (LHS.isInvalid())
9765  return ExprError();
9766 
9767  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9768  if (RHS.isInvalid())
9769  return ExprError();
9770 
9771 
9772  if (!getDerived().AlwaysRebuild() &&
9773  LHS.get() == E->getLHS() &&
9774  RHS.get() == E->getRHS())
9775  return E;
9776 
9777  return getDerived().RebuildArraySubscriptExpr(
9778  LHS.get(),
9779  /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
9780 }
9781 
9782 template <typename Derived>
9783 ExprResult
9785  ExprResult Base = getDerived().TransformExpr(E->getBase());
9786  if (Base.isInvalid())
9787  return ExprError();
9788 
9789  ExprResult LowerBound;
9790  if (E->getLowerBound()) {
9791  LowerBound = getDerived().TransformExpr(E->getLowerBound());
9792  if (LowerBound.isInvalid())
9793  return ExprError();
9794  }
9795 
9796  ExprResult Length;
9797  if (E->getLength()) {
9798  Length = getDerived().TransformExpr(E->getLength());
9799  if (Length.isInvalid())
9800  return ExprError();
9801  }
9802 
9803  if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
9804  LowerBound.get() == E->getLowerBound() && Length.get() == E->getLength())
9805  return E;
9806 
9807  return getDerived().RebuildOMPArraySectionExpr(
9808  Base.get(), E->getBase()->getEndLoc(), LowerBound.get(), E->getColonLoc(),
9809  Length.get(), E->getRBracketLoc());
9810 }
9811 
9812 template<typename Derived>
9813 ExprResult
9815  // Transform the callee.
9816  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
9817  if (Callee.isInvalid())
9818  return ExprError();
9819 
9820  // Transform arguments.
9821  bool ArgChanged = false;
9822  SmallVector<Expr*, 8> Args;
9823  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
9824  &ArgChanged))
9825  return ExprError();
9826 
9827  if (!getDerived().AlwaysRebuild() &&
9828  Callee.get() == E->getCallee() &&
9829  !ArgChanged)
9830  return SemaRef.MaybeBindToTemporary(E);
9831 
9832  // FIXME: Wrong source location information for the '('.
9833  SourceLocation FakeLParenLoc
9834  = ((Expr *)Callee.get())->getSourceRange().getBegin();
9835  return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
9836  Args,
9837  E->getRParenLoc());
9838 }
9839 
9840 template<typename Derived>
9841 ExprResult
9843  ExprResult Base = getDerived().TransformExpr(E->getBase());
9844  if (Base.isInvalid())
9845  return ExprError();
9846 
9847  NestedNameSpecifierLoc QualifierLoc;
9848  if (E->hasQualifier()) {
9849  QualifierLoc
9850  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9851 
9852  if (!QualifierLoc)
9853  return ExprError();
9854  }
9855  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
9856 
9857  ValueDecl *Member
9858  = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
9859  E->getMemberDecl()));
9860  if (!Member)
9861  return ExprError();
9862 
9863  NamedDecl *FoundDecl = E->getFoundDecl();
9864  if (FoundDecl == E->getMemberDecl()) {
9865  FoundDecl = Member;
9866  } else {
9867  FoundDecl = cast_or_null<NamedDecl>(
9868  getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
9869  if (!FoundDecl)
9870  return ExprError();
9871  }
9872 
9873  if (!getDerived().AlwaysRebuild() &&
9874  Base.get() == E->getBase() &&
9875  QualifierLoc == E->getQualifierLoc() &&
9876  Member == E->getMemberDecl() &&
9877  FoundDecl == E->getFoundDecl() &&
9878  !E->hasExplicitTemplateArgs()) {
9879 
9880  // Mark it referenced in the new context regardless.
9881  // FIXME: this is a bit instantiation-specific.
9882  SemaRef.MarkMemberReferenced(E);
9883 
9884  return E;
9885  }
9886 
9887  TemplateArgumentListInfo TransArgs;
9888  if (E->hasExplicitTemplateArgs()) {
9889  TransArgs.setLAngleLoc(E->getLAngleLoc());
9890  TransArgs.setRAngleLoc(E->getRAngleLoc());
9891  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
9892  E->getNumTemplateArgs(),
9893  TransArgs))
9894  return ExprError();
9895  }
9896 
9897  // FIXME: Bogus source location for the operator
9898  SourceLocation FakeOperatorLoc =
9899  SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
9900 
9901  // FIXME: to do this check properly, we will need to preserve the
9902  // first-qualifier-in-scope here, just in case we had a dependent
9903  // base (and therefore couldn't do the check) and a
9904  // nested-name-qualifier (and therefore could do the lookup).
9905  NamedDecl *FirstQualifierInScope = nullptr;
9906  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
9907  if (MemberNameInfo.getName()) {
9908  MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
9909  if (!MemberNameInfo.getName())
9910  return ExprError();
9911  }
9912 
9913  return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
9914  E->isArrow(),
9915  QualifierLoc,
9916  TemplateKWLoc,
9917  MemberNameInfo,
9918  Member,
9919  FoundDecl,
9921  ? &TransArgs : nullptr),
9922  FirstQualifierInScope);
9923 }
9924 
9925 template<typename Derived>
9926 ExprResult
9928  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9929  if (LHS.isInvalid())
9930  return ExprError();
9931 
9932  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9933  if (RHS.isInvalid())
9934  return ExprError();
9935 
9936  if (!getDerived().AlwaysRebuild() &&
9937  LHS.get() == E->getLHS() &&
9938  RHS.get() == E->getRHS())
9939  return E;
9940 
9941  Sema::FPContractStateRAII FPContractState(getSema());
9942  getSema().FPFeatures = E->getFPFeatures();
9943 
9944  return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
9945  LHS.get(), RHS.get());
9946 }
9947 
9948 template <typename Derived>
9952 
9953  ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
9954  if (LHS.isInvalid())
9955  return ExprError();
9956 
9957  ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
9958  if (RHS.isInvalid())
9959  return ExprError();
9960 
9961  if (!getDerived().AlwaysRebuild() &&
9962  LHS.get() == Decomp.LHS &&
9963  RHS.get() == Decomp.RHS)
9964  return E;
9965 
9966  // Extract the already-resolved callee declarations so that we can restrict
9967  // ourselves to using them as the unqualified lookup results when rebuilding.
9968  UnresolvedSet<2> UnqualLookups;
9969  Expr *PossibleBinOps[] = {E->getSemanticForm(),
9970  const_cast<Expr *>(Decomp.InnerBinOp)};
9971  for (Expr *PossibleBinOp : PossibleBinOps) {
9972  auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
9973  if (!Op)
9974  continue;
9975  auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
9976  if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
9977  continue;
9978 
9979  // Transform the callee in case we built a call to a local extern
9980  // declaration.
9981  NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
9982  E->getOperatorLoc(), Callee->getFoundDecl()));
9983  if (!Found)
9984  return ExprError();
9985  UnqualLookups.addDecl(Found);
9986  }
9987 
9988  return getDerived().RebuildCXXRewrittenBinaryOperator(
9989  E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
9990 }
9991 
9992 template<typename Derived>
9993 ExprResult
9996  return getDerived().TransformBinaryOperator(E);
9997 }
9998 
9999 template<typename Derived>
10002  // Just rebuild the common and RHS expressions and see whether we
10003  // get any changes.
10004 
10005  ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
10006  if (commonExpr.isInvalid())
10007  return ExprError();
10008 
10009  ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
10010  if (rhs.isInvalid())
10011  return ExprError();
10012 
10013  if (!getDerived().AlwaysRebuild() &&
10014  commonExpr.get() == e->getCommon() &&
10015  rhs.get() == e->getFalseExpr())
10016  return e;
10017 
10018  return getDerived().RebuildConditionalOperator(commonExpr.get(),
10019  e->getQuestionLoc(),
10020  nullptr,
10021  e->getColonLoc(),
10022  rhs.get());
10023 }
10024 
10025 template<typename Derived>
10026 ExprResult
10028  ExprResult Cond = getDerived().TransformExpr(E->getCond());
10029  if (Cond.isInvalid())
10030  return ExprError();
10031 
10032  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
10033  if (LHS.isInvalid())
10034  return ExprError();
10035 
10036  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
10037  if (RHS.isInvalid())
10038  return ExprError();
10039 
10040  if (!getDerived().AlwaysRebuild() &&
10041  Cond.get() == E->getCond() &&
10042  LHS.get() == E->getLHS() &&
10043  RHS.get() == E->getRHS())
10044  return E;
10045 
10046  return getDerived().RebuildConditionalOperator(Cond.get(),
10047  E->getQuestionLoc(),
10048  LHS.get(),
10049  E->getColonLoc(),
10050  RHS.get());
10051 }
10052 
10053 template<typename Derived>
10054 ExprResult
10056  // Implicit casts are eliminated during transformation, since they
10057  // will be recomputed by semantic analysis after transformation.
10058  return getDerived().TransformExpr(E->getSubExprAsWritten());
10059 }
10060 
10061 template<typename Derived>
10062 ExprResult
10064  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
10065  if (!Type)
10066  return ExprError();
10067 
10068  ExprResult SubExpr
10069  = getDerived().TransformExpr(E->getSubExprAsWritten());
10070  if (SubExpr.isInvalid())
10071  return ExprError();
10072 
10073  if (!getDerived().AlwaysRebuild() &&
10074  Type == E->getTypeInfoAsWritten() &&
10075  SubExpr.get() == E->getSubExpr())
10076  return E;
10077 
10078  return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
10079  Type,
10080  E->getRParenLoc(),
10081  SubExpr.get());
10082 }
10083 
10084 template<typename Derived>
10085 ExprResult
10087  TypeSourceInfo *OldT = E->getTypeSourceInfo();
10088  TypeSourceInfo *NewT = getDerived().TransformType(OldT);
10089  if (!NewT)
10090  return ExprError();
10091 
10092  ExprResult Init = getDerived().TransformExpr(E->getInitializer());
10093  if (Init.isInvalid())
10094  return ExprError();
10095 
10096  if (!getDerived().AlwaysRebuild() &&
10097  OldT == NewT &&
10098  Init.get() == E->getInitializer())
10099  return SemaRef.MaybeBindToTemporary(E);
10100 
10101  // Note: the expression type doesn't necessarily match the
10102  // type-as-written, but that's okay, because it should always be
10103  // derivable from the initializer.
10104 
10105  return getDerived().RebuildCompoundLiteralExpr(
10106  E->getLParenLoc(), NewT,
10107  /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
10108 }
10109 
10110 template<typename Derived>
10111 ExprResult
10113  ExprResult Base = getDerived().TransformExpr(E->getBase());
10114  if (Base.isInvalid())
10115  return ExprError();
10116 
10117  if (!getDerived().AlwaysRebuild() &&
10118  Base.get() == E->getBase())
10119  return E;
10120 
10121  // FIXME: Bad source location
10122  SourceLocation FakeOperatorLoc =
10123  SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
10124  return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc,
10125  E->getAccessorLoc(),
10126  E->getAccessor());
10127 }
10128 
10129 template<typename Derived>
10130 ExprResult
10132  if (InitListExpr *Syntactic = E->getSyntacticForm())
10133  E = Syntactic;
10134 
10135  bool InitChanged = false;
10136 
10138  getSema(), EnterExpressionEvaluationContext::InitList);
10139 
10141  if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
10142  Inits, &InitChanged))
10143  return ExprError();
10144 
10145  if (!getDerived().AlwaysRebuild() && !InitChanged) {
10146  // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
10147  // in some cases. We can't reuse it in general, because the syntactic and
10148  // semantic forms are linked, and we can't know that semantic form will
10149  // match even if the syntactic form does.
10150  }
10151 
10152  return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
10153  E->getRBraceLoc());
10154 }
10155 
10156 template<typename Derived>
10157 ExprResult
10159  Designation Desig;
10160 
10161  // transform the initializer value
10162  ExprResult Init = getDerived().TransformExpr(E->getInit());
10163  if (Init.isInvalid())
10164  return ExprError();
10165 
10166  // transform the designators.
10167  SmallVector<Expr*, 4> ArrayExprs;
10168  bool ExprChanged = false;
10169  for (const DesignatedInitExpr::Designator &D : E->designators()) {
10170  if (D.isFieldDesignator()) {
10171  Desig.AddDesignator(Designator::getField(D.getFieldName(),
10172  D.getDotLoc(),
10173  D.getFieldLoc()));
10174  if (D.getField()) {
10175  FieldDecl *Field = cast_or_null<FieldDecl>(
10176  getDerived().TransformDecl(D.getFieldLoc(), D.getField()));
10177  if (Field != D.getField())
10178  // Rebuild the expression when the transformed FieldDecl is
10179  // different to the already assigned FieldDecl.
10180  ExprChanged = true;
10181  } else {
10182  // Ensure that the designator expression is rebuilt when there isn't
10183  // a resolved FieldDecl in the designator as we don't want to assign
10184  // a FieldDecl to a pattern designator that will be instantiated again.
10185  ExprChanged = true;
10186  }
10187  continue;
10188  }
10189 
10190  if (D.isArrayDesignator()) {
10191  ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
10192  if (Index.isInvalid())
10193  return ExprError();
10194 
10195  Desig.AddDesignator(
10196  Designator::getArray(Index.get(), D.getLBracketLoc()));
10197 
10198  ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D);
10199  ArrayExprs.push_back(Index.get());
10200  continue;
10201  }
10202 
10203  assert(D.isArrayRangeDesignator() && "New kind of designator?");
10204  ExprResult Start
10205  = getDerived().TransformExpr(E->getArrayRangeStart(D));
10206  if (Start.isInvalid())
10207  return ExprError();
10208 
10209  ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
10210  if (End.isInvalid())
10211  return ExprError();
10212 
10213  Desig.AddDesignator(Designator::getArrayRange(Start.get(),
10214  End.get(),
10215  D.getLBracketLoc(),
10216  D.getEllipsisLoc()));
10217 
10218  ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
10219  End.get() != E->getArrayRangeEnd(D);
10220 
10221  ArrayExprs.push_back(Start.get());
10222  ArrayExprs.push_back(End.get());
10223  }
10224 
10225  if (!getDerived().AlwaysRebuild() &&
10226  Init.get() == E->getInit() &&
10227  !ExprChanged)
10228  return E;
10229 
10230  return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
10231  E->getEqualOrColonLoc(),
10232  E->usesGNUSyntax(), Init.get());
10233 }
10234 
10235 // Seems that if TransformInitListExpr() only works on the syntactic form of an
10236 // InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
10237 template<typename Derived>
10238 ExprResult
10241  llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
10242  "initializer");
10243  return ExprError();
10244 }
10245 
10246 template<typename Derived>
10247 ExprResult
10249  NoInitExpr *E) {
10250  llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
10251  return ExprError();
10252 }
10253 
10254 template<typename Derived>
10255 ExprResult
10257  llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
10258  return ExprError();
10259 }
10260 
10261 template<typename Derived>
10262 ExprResult
10264  llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
10265  return ExprError();
10266 }
10267 
10268 template<typename Derived>
10269 ExprResult
10271  ImplicitValueInitExpr *E) {
10272  TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
10273 
10274  // FIXME: Will we ever have proper type location here? Will we actually
10275  // need to transform the type?
10276  QualType T = getDerived().TransformType(E->getType());
10277  if (T.isNull())
10278  return ExprError();
10279 
10280  if (!getDerived().AlwaysRebuild() &&
10281  T == E->getType())
10282  return E;
10283 
10284  return getDerived().RebuildImplicitValueInitExpr(T);
10285 }
10286 
10287 template<typename Derived>
10288 ExprResult
10290  TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
10291  if (!TInfo)
10292  return ExprError();
10293 
10294  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
10295  if (SubExpr.isInvalid())
10296  return ExprError();
10297 
10298  if (!getDerived().AlwaysRebuild() &&
10299  TInfo == E->getWrittenTypeInfo() &&
10300  SubExpr.get() == E->getSubExpr())
10301  return E;
10302 
10303  return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
10304  TInfo, E->getRParenLoc());
10305 }
10306 
10307 template<typename Derived>
10308 ExprResult
10310  bool ArgumentChanged = false;
10312  if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
10313  &ArgumentChanged))
10314  return ExprError();
10315 
10316  return getDerived().RebuildParenListExpr(E->getLParenLoc(),
10317  Inits,
10318  E->getRParenLoc());
10319 }
10320 
10321 /// Transform an address-of-label expression.
10322 ///
10323 /// By default, the transformation of an address-of-label expression always
10324 /// rebuilds the expression, so that the label identifier can be resolved to
10325 /// the corresponding label statement by semantic analysis.
10326 template<typename Derived>
10327 ExprResult
10329  Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
10330  E->getLabel());
10331  if (!LD)
10332  return ExprError();
10333 
10334  return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
10335  cast<LabelDecl>(LD));
10336 }
10337 
10338 template<typename Derived>
10339 ExprResult
10341  SemaRef.ActOnStartStmtExpr();
10342  StmtResult SubStmt
10343  = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
10344  if (SubStmt.isInvalid()) {
10345  SemaRef.ActOnStmtExprError();
10346  return ExprError();
10347  }
10348 
10349  if (!getDerived().AlwaysRebuild() &&
10350  SubStmt.get() == E->getSubStmt()) {
10351  // Calling this an 'error' is unintuitive, but it does the right thing.
10352  SemaRef.ActOnStmtExprError();
10353  return SemaRef.MaybeBindToTemporary(E);
10354  }
10355 
10356  return getDerived().RebuildStmtExpr(E->getLParenLoc(),
10357  SubStmt.get(),
10358  E->getRParenLoc());
10359 }
10360 
10361 template<typename Derived>
10362 ExprResult
10364  ExprResult Cond = getDerived().TransformExpr(E->getCond());
10365  if (Cond.isInvalid())
10366  return ExprError();
10367 
10368  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
10369  if (LHS.isInvalid())
10370  return ExprError();
10371 
10372  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
10373  if (RHS.isInvalid())
10374  return ExprError();
10375 
10376  if (!getDerived().AlwaysRebuild() &&
10377  Cond.get() == E->getCond() &&
10378  LHS.get() == E->getLHS() &&
10379  RHS.get() == E->getRHS())
10380  return E;
10381 
10382  return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
10383  Cond.get(), LHS.get(), RHS.get(),
10384  E->getRParenLoc());
10385 }
10386 
10387 template<typename Derived>
10388 ExprResult
10390  return E;
10391 }
10392 
10393 template<typename Derived>
10394 ExprResult
10396  switch (E->getOperator()) {
10397  case OO_New:
10398  case OO_Delete:
10399  case OO_Array_New:
10400  case OO_Array_Delete:
10401  llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
10402 
10403  case OO_Call: {
10404  // This is a call to an object's operator().
10405  assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
10406 
10407  // Transform the object itself.
10408  ExprResult Object = getDerived().TransformExpr(E->getArg(0));
10409  if (Object.isInvalid())
10410  return ExprError();
10411 
10412  // FIXME: Poor location information
10413  SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(
10414  static_cast<Expr *>(Object.get())->getEndLoc());
10415 
10416  // Transform the call arguments.
10417  SmallVector<Expr*, 8> Args;
10418  if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
10419  Args))
10420  return ExprError();
10421 
10422  return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
10423  E->getEndLoc());
10424  }
10425 
10426 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
10427  case OO_##Name:
10428 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
10429 #include "clang/Basic/OperatorKinds.def"
10430  case OO_Subscript:
10431  // Handled below.
10432  break;
10433 
10434  case OO_Conditional:
10435  llvm_unreachable("conditional operator is not actually overloadable");
10436 
10437  case OO_None:
10439  llvm_unreachable("not an overloaded operator?");
10440  }
10441 
10442  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
10443  if (Callee.isInvalid())
10444  return ExprError();
10445 
10446  ExprResult First;
10447  if (E->getOperator() == OO_Amp)
10448  First = getDerived().TransformAddressOfOperand(E->getArg(0));
10449  else
10450  First = getDerived().TransformExpr(E->getArg(0));
10451  if (First.isInvalid())
10452  return ExprError();
10453 
10454  ExprResult Second;
10455  if (E->getNumArgs() == 2) {
10456  Second = getDerived().TransformExpr(E->getArg(1));
10457  if (Second.isInvalid())
10458  return ExprError();
10459  }
10460 
10461  if (!getDerived().AlwaysRebuild() &&
10462  Callee.get() == E->getCallee() &&
10463  First.get() == E->getArg(0) &&
10464  (E->getNumArgs() != 2 || Second.get() == E->getArg(1)))
10465  return SemaRef.MaybeBindToTemporary(E);
10466 
10467  Sema::FPContractStateRAII FPContractState(getSema());
10468  getSema().FPFeatures = E->getFPFeatures();
10469 
10470  return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(),
10471  E->getOperatorLoc(),
10472  Callee.get(),
10473  First.get(),
10474  Second.get());
10475 }
10476 
10477 template<typename Derived>
10478 ExprResult
10480  return getDerived().TransformCallExpr(E);
10481 }
10482 
10483 template <typename Derived>
10485  bool NeedRebuildFunc = E->getIdentKind() == SourceLocExpr::Function &&
10486  getSema().CurContext != E->getParentContext();
10487 
10488  if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
10489  return E;
10490 
10491  return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getBeginLoc(),
10492  E->getEndLoc(),
10493  getSema().CurContext);
10494 }
10495 
10496 template<typename Derived>
10497 ExprResult
10499  // Transform the callee.
10500  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
10501  if (Callee.isInvalid())
10502  return ExprError();
10503 
10504  // Transform exec config.
10505  ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
10506  if (EC.isInvalid())
10507  return ExprError();
10508 
10509  // Transform arguments.
10510  bool ArgChanged = false;
10511  SmallVector<Expr*, 8> Args;
10512  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
10513  &ArgChanged))
10514  return ExprError();
10515 
10516  if (!getDerived().AlwaysRebuild() &&
10517  Callee.get() == E->getCallee() &&
10518  !ArgChanged)
10519  return SemaRef.MaybeBindToTemporary(E);
10520 
10521  // FIXME: Wrong source location information for the '('.
10522  SourceLocation FakeLParenLoc
10523  = ((Expr *)Callee.get())->getSourceRange().getBegin();
10524  return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
10525  Args,
10526  E->getRParenLoc(), EC.get());
10527 }
10528 
10529 template<typename Derived>
10530 ExprResult
10532  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
10533  if (!Type)
10534  return ExprError();
10535 
10536  ExprResult SubExpr
10537  = getDerived().TransformExpr(E->getSubExprAsWritten());
10538  if (SubExpr.isInvalid())
10539  return ExprError();
10540 
10541  if (!getDerived().AlwaysRebuild() &&
10542  Type == E->getTypeInfoAsWritten() &&
10543  SubExpr.get() == E->getSubExpr())
10544  return E;
10545  return getDerived().RebuildCXXNamedCastExpr(
10547  Type, E->getAngleBrackets().getEnd(),
10548  // FIXME. this should be '(' location
10549  E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
10550 }
10551 
10552 template<typename Derived>
10553 ExprResult
10555  TypeSourceInfo *TSI =
10556  getDerived().TransformType(BCE->getTypeInfoAsWritten());
10557  if (!TSI)
10558  return ExprError();
10559 
10560  ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
10561  if (Sub.isInvalid())
10562  return ExprError();
10563 
10564  return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
10565  Sub.get(), BCE->getEndLoc());
10566 }
10567 
10568 template<typename Derived>
10569 ExprResult
10571  return getDerived().TransformCXXNamedCastExpr(E);
10572 }
10573 
10574 template<typename Derived>
10575 ExprResult
10577  return getDerived().TransformCXXNamedCastExpr(E);
10578 }
10579 
10580 template<typename Derived>
10581 ExprResult
10584  return getDerived().TransformCXXNamedCastExpr(E);
10585 }
10586 
10587 template<typename Derived>
10588 ExprResult
10590  return getDerived().TransformCXXNamedCastExpr(E);
10591 }
10592 
10593 template<typename Derived>
10594 ExprResult
10596  CXXFunctionalCastExpr *E) {
10597  TypeSourceInfo *Type =
10598  getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
10599  if (!Type)
10600  return ExprError();
10601 
10602  ExprResult SubExpr
10603  = getDerived().TransformExpr(E->getSubExprAsWritten());
10604  if (SubExpr.isInvalid())
10605  return ExprError();
10606 
10607  if (!getDerived().AlwaysRebuild() &&
10608  Type == E->getTypeInfoAsWritten() &&
10609  SubExpr.get() == E->getSubExpr())
10610  return E;
10611 
10612  return getDerived().RebuildCXXFunctionalCastExpr(Type,
10613  E->getLParenLoc(),
10614  SubExpr.get(),
10615  E->getRParenLoc(),
10616  E->isListInitialization());
10617 }
10618 
10619 template<typename Derived>
10620 ExprResult
10622  if (E->isTypeOperand()) {
10623  TypeSourceInfo *TInfo
10624  = getDerived().TransformType(E->getTypeOperandSourceInfo());
10625  if (!TInfo)
10626  return ExprError();
10627 
10628  if (!getDerived().AlwaysRebuild() &&
10629  TInfo == E->getTypeOperandSourceInfo())
10630  return E;
10631 
10632  return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
10633  TInfo, E->getEndLoc());
10634  }
10635 
10636  // We don't know whether the subexpression is potentially evaluated until
10637  // after we perform semantic analysis. We speculatively assume it is
10638  // unevaluated; it will get fixed later if the subexpression is in fact
10639  // potentially evaluated.
10641  SemaRef, Sema::ExpressionEvaluationContext::Unevaluated,
10642  Sema::ReuseLambdaContextDecl);
10643 
10644  ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
10645  if (SubExpr.isInvalid())
10646  return ExprError();
10647 
10648  if (!getDerived().AlwaysRebuild() &&
10649  SubExpr.get() == E->getExprOperand())
10650  return E;
10651 
10652  return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
10653  SubExpr.get(), E->getEndLoc());
10654 }
10655 
10656 template<typename Derived>
10657 ExprResult
10659  if (E->isTypeOperand()) {
10660  TypeSourceInfo *TInfo
10661  = getDerived().TransformType(E->getTypeOperandSourceInfo());
10662  if (!TInfo)
10663  return ExprError();
10664 
10665  if (!getDerived().AlwaysRebuild() &&
10666  TInfo == E->getTypeOperandSourceInfo())
10667  return E;
10668 
10669  return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
10670  TInfo, E->getEndLoc());
10671  }
10672 
10674  SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);
10675 
10676  ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
10677  if (SubExpr.isInvalid())
10678  return ExprError();
10679 
10680  if (!getDerived().AlwaysRebuild() &&
10681  SubExpr.get() == E->getExprOperand())
10682  return E;
10683 
10684  return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
10685  SubExpr.get(), E->getEndLoc());
10686 }
10687 
10688 template<typename Derived>
10689 ExprResult
10691  return E;
10692 }
10693 
10694 template<typename Derived>
10695 ExprResult
10697  CXXNullPtrLiteralExpr *E) {
10698  return E;
10699 }
10700 
10701 template<typename Derived>
10702 ExprResult
10704  QualType T = getSema().getCurrentThisType();
10705 
10706  if (!getDerived().AlwaysRebuild() && T == E->getType()) {
10707  // Mark it referenced in the new context regardless.
10708  // FIXME: this is a bit instantiation-specific.
10709  getSema().MarkThisReferenced(E);
10710  return E;
10711  }
10712 
10713  return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
10714 }
10715 
10716 template<typename Derived>
10717 ExprResult
10719  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
10720  if (SubExpr.isInvalid())
10721  return ExprError();
10722 
10723  if (!getDerived().AlwaysRebuild() &&
10724  SubExpr.get() == E->getSubExpr())
10725  return E;
10726 
10727  return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
10729 }
10730 
10731 template<typename Derived>
10732 ExprResult
10734  ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
10735  getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
10736  if (!Param)
10737  return ExprError();
10738 
10739  if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
10740  E->getUsedContext() == SemaRef.CurContext)
10741  return E;
10742 
10743  return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param);
10744 }
10745 
10746 template<typename Derived>
10747 ExprResult
10749  FieldDecl *Field = cast_or_null<FieldDecl>(
10750  getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
10751  if (!Field)
10752  return ExprError();
10753 
10754  if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
10755  E->getUsedContext() == SemaRef.CurContext)
10756  return E;
10757 
10758  return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
10759 }
10760 
10761 template<typename Derived>
10762 ExprResult
10765  TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
10766  if (!T)
10767  return ExprError();
10768 
10769  if (!getDerived().AlwaysRebuild() &&
10770  T == E->getTypeSourceInfo())
10771  return E;
10772 
10773  return getDerived().RebuildCXXScalarValueInitExpr(T,
10774  /*FIXME:*/T->getTypeLoc().getEndLoc(),
10775  E->getRParenLoc());
10776 }
10777 
10778 template<typename Derived>
10779 ExprResult
10781  // Transform the type that we're allocating
10782  TypeSourceInfo *AllocTypeInfo =
10783  getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
10784  if (!AllocTypeInfo)
10785  return ExprError();
10786 
10787  // Transform the size of the array we're allocating (if any).
10788  Optional<Expr *> ArraySize;
10789  if (Optional<Expr *> OldArraySize = E->getArraySize()) {
10790  ExprResult NewArraySize;
10791  if (*OldArraySize) {
10792  NewArraySize = getDerived().TransformExpr(*OldArraySize);
10793  if (NewArraySize.isInvalid())
10794  return ExprError();
10795  }
10796  ArraySize = NewArraySize.get();
10797  }
10798 
10799  // Transform the placement arguments (if any).
10800  bool ArgumentChanged = false;
10801  SmallVector<Expr*, 8> PlacementArgs;
10802  if (getDerived().TransformExprs(E->getPlacementArgs(),
10803  E->getNumPlacementArgs(), true,
10804  PlacementArgs, &ArgumentChanged))
10805  return ExprError();
10806 
10807  // Transform the initializer (if any).
10808  Expr *OldInit = E->getInitializer();
10809  ExprResult NewInit;
10810  if (OldInit)
10811  NewInit = getDerived().TransformInitializer(OldInit, true);
10812  if (NewInit.isInvalid())
10813  return ExprError();
10814 
10815  // Transform new operator and delete operator.
10816  FunctionDecl *OperatorNew = nullptr;
10817  if (E->getOperatorNew()) {
10818  OperatorNew = cast_or_null<FunctionDecl>(
10819  getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
10820  if (!OperatorNew)
10821  return ExprError();
10822  }
10823 
10824  FunctionDecl *OperatorDelete = nullptr;
10825  if (E->getOperatorDelete()) {
10826  OperatorDelete = cast_or_null<FunctionDecl>(
10827  getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
10828  if (!OperatorDelete)
10829  return ExprError();
10830  }
10831 
10832  if (!getDerived().AlwaysRebuild() &&
10833  AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
10834  ArraySize == E->getArraySize() &&
10835  NewInit.get() == OldInit &&
10836  OperatorNew == E->getOperatorNew() &&
10837  OperatorDelete == E->getOperatorDelete() &&
10838  !ArgumentChanged) {
10839  // Mark any declarations we need as referenced.
10840  // FIXME: instantiation-specific.
10841  if (OperatorNew)
10842  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
10843  if (OperatorDelete)
10844  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
10845 
10846  if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
10847  QualType ElementType
10848  = SemaRef.Context.getBaseElementType(E->getAllocatedType());
10849  if (const RecordType *RecordT = ElementType->getAs<RecordType>()) {
10850  CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordT->getDecl());
10851  if (CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(Record)) {
10852  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
10853  }
10854  }
10855  }
10856 
10857  return E;
10858  }
10859 
10860  QualType AllocType = AllocTypeInfo->getType();
10861  if (!ArraySize) {
10862  // If no array size was specified, but the new expression was
10863  // instantiated with an array type (e.g., "new T" where T is
10864  // instantiated with "int[4]"), extract the outer bound from the
10865  // array type as our array size. We do this with constant and
10866  // dependently-sized array types.
10867  const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
10868  if (!ArrayT) {
10869  // Do nothing
10870  } else if (const ConstantArrayType *ConsArrayT
10871  = dyn_cast<ConstantArrayType>(ArrayT)) {
10872  ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
10873  SemaRef.Context.getSizeType(),
10874  /*FIXME:*/ E->getBeginLoc());
10875  AllocType = ConsArrayT->getElementType();
10876  } else if (const DependentSizedArrayType *DepArrayT
10877  = dyn_cast<DependentSizedArrayType>(ArrayT)) {
10878  if (DepArrayT->getSizeExpr()) {
10879  ArraySize = DepArrayT->getSizeExpr();
10880  AllocType = DepArrayT->getElementType();
10881  }
10882  }
10883  }
10884 
10885  return getDerived().RebuildCXXNewExpr(
10886  E->getBeginLoc(), E->isGlobalNew(),
10887  /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
10888  /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
10889  AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
10890 }
10891 
10892 template<typename Derived>
10893 ExprResult
10895  ExprResult Operand = getDerived().TransformExpr(E->getArgument());
10896  if (Operand.isInvalid())
10897  return ExprError();
10898 
10899  // Transform the delete operator, if known.
10900  FunctionDecl *OperatorDelete = nullptr;
10901  if (E->getOperatorDelete()) {
10902  OperatorDelete = cast_or_null<FunctionDecl>(
10903  getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
10904  if (!OperatorDelete)
10905  return ExprError();
10906  }
10907 
10908  if (!getDerived().AlwaysRebuild() &&
10909  Operand.get() == E->getArgument() &&
10910  OperatorDelete == E->getOperatorDelete()) {
10911  // Mark any declarations we need as referenced.
10912  // FIXME: instantiation-specific.
10913  if (OperatorDelete)
10914  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
10915 
10916  if (!E->getArgument()->isTypeDependent()) {
10917  QualType Destroyed = SemaRef.Context.getBaseElementType(
10918  E->getDestroyedType());
10919  if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
10920  CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
10921  SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
10922  SemaRef.LookupDestructor(Record));
10923  }
10924  }
10925 
10926  return E;
10927  }
10928 
10929  return getDerived().RebuildCXXDeleteExpr(
10930  E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
10931 }
10932 
10933 template<typename Derived>
10934 ExprResult
10937  ExprResult Base = getDerived().TransformExpr(E->getBase());
10938  if (Base.isInvalid())
10939  return ExprError();
10940 
10941  ParsedType ObjectTypePtr;
10942  bool MayBePseudoDestructor = false;
10943  Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
10944  E->getOperatorLoc(),
10945  E->isArrow()? tok::arrow : tok::period,
10946  ObjectTypePtr,
10947  MayBePseudoDestructor);
10948  if (Base.isInvalid())
10949  return ExprError();
10950 
10951  QualType ObjectType = ObjectTypePtr.get();
10952  NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
10953  if (QualifierLoc) {
10954  QualifierLoc
10955  = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
10956  if (!QualifierLoc)
10957  return ExprError();
10958  }
10959  CXXScopeSpec SS;
10960  SS.Adopt(QualifierLoc);
10961 
10962  PseudoDestructorTypeStorage Destroyed;
10963  if (E->getDestroyedTypeInfo()) {
10964  TypeSourceInfo *DestroyedTypeInfo
10965  = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(),
10966  ObjectType, nullptr, SS);
10967  if (!DestroyedTypeInfo)
10968  return ExprError();
10969  Destroyed = DestroyedTypeInfo;
10970  } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
10971  // We aren't likely to be able to resolve the identifier down to a type
10972  // now anyway, so just retain the identifier.
10974  E->getDestroyedTypeLoc());
10975  } else {
10976  // Look for a destructor known with the given name.
10977  ParsedType T = SemaRef.getDestructorName(E->getTildeLoc(),
10979  E->getDestroyedTypeLoc(),
10980  /*Scope=*/nullptr,
10981  SS, ObjectTypePtr,
10982  false);
10983  if (!T)
10984  return ExprError();
10985 
10986  Destroyed
10987  = SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.GetTypeFromParser(T),
10988  E->getDestroyedTypeLoc());
10989  }
10990 
10991  TypeSourceInfo *ScopeTypeInfo = nullptr;
10992  if (E->getScopeTypeInfo()) {
10993  CXXScopeSpec EmptySS;
10994  ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
10995  E->getScopeTypeInfo(), ObjectType, nullptr, EmptySS);
10996  if (!ScopeTypeInfo)
10997  return ExprError();
10998  }
10999 
11000  return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
11001  E->getOperatorLoc(),
11002  E->isArrow(),
11003  SS,
11004  ScopeTypeInfo,
11005  E->getColonColonLoc(),
11006  E->getTildeLoc(),
11007  Destroyed);
11008 }
11009 
11010 template <typename Derived>
11012  bool RequiresADL,
11013  LookupResult &R) {
11014  // Transform all the decls.
11015  bool AllEmptyPacks = true;
11016  for (auto *OldD : Old->decls()) {
11017  Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
11018  if (!InstD) {
11019  // Silently ignore these if a UsingShadowDecl instantiated to nothing.
11020  // This can happen because of dependent hiding.
11021  if (isa<UsingShadowDecl>(OldD))
11022  continue;
11023  else {
11024  R.clear();
11025  return true;
11026  }
11027  }
11028 
11029  // Expand using pack declarations.
11030  NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
11031  ArrayRef<NamedDecl*> Decls = SingleDecl;
11032  if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
11033  Decls = UPD->expansions();
11034 
11035  // Expand using declarations.
11036  for (auto *D : Decls) {
11037  if (auto *UD = dyn_cast<UsingDecl>(D)) {
11038  for (auto *SD : UD->shadows())
11039  R.addDecl(SD);
11040  } else {
11041  R.addDecl(D);
11042  }
11043  }
11044 
11045  AllEmptyPacks &= Decls.empty();
11046  };
11047 
11048  // C++ [temp.res]/8.4.2:
11049  // The program is ill-formed, no diagnostic required, if [...] lookup for
11050  // a name in the template definition found a using-declaration, but the
11051  // lookup in the corresponding scope in the instantiation odoes not find
11052  // any declarations because the using-declaration was a pack expansion and
11053  // the corresponding pack is empty
11054  if (AllEmptyPacks && !RequiresADL) {
11055  getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
11056  << isa<UnresolvedMemberExpr>(Old) << Old->getName();
11057  return true;
11058  }
11059 
11060  // Resolve a kind, but don't do any further analysis. If it's
11061  // ambiguous, the callee needs to deal with it.
11062  R.resolveKind();
11063  return false;
11064 }
11065 
11066 template<typename Derived>
11067 ExprResult
11069  UnresolvedLookupExpr *Old) {
11070  LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
11071  Sema::LookupOrdinaryName);
11072 
11073  // Transform the declaration set.
11074  if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
11075  return ExprError();
11076 
11077  // Rebuild the nested-name qualifier, if present.
11078  CXXScopeSpec SS;
11079  if (Old->getQualifierLoc()) {
11080  NestedNameSpecifierLoc QualifierLoc
11081  = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
11082  if (!QualifierLoc)
11083  return ExprError();
11084 
11085  SS.Adopt(QualifierLoc);
11086  }
11087 
11088  if (Old->getNamingClass()) {
11089  CXXRecordDecl *NamingClass
11090  = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
11091  Old->getNameLoc(),
11092  Old->getNamingClass()));
11093  if (!NamingClass) {
11094  R.clear();
11095  return ExprError();
11096  }
11097 
11098  R.setNamingClass(NamingClass);
11099  }
11100 
11101  SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
11102 
11103  // If we have neither explicit template arguments, nor the template keyword,
11104  // it's a normal declaration name or member reference.
11105  if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid()) {
11106  NamedDecl *D = R.getAsSingle<NamedDecl>();
11107  // In a C++11 unevaluated context, an UnresolvedLookupExpr might refer to an
11108  // instance member. In other contexts, BuildPossibleImplicitMemberExpr will
11109  // give a good diagnostic.
11110  if (D && D->isCXXInstanceMember()) {
11111  return SemaRef.BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, R,
11112  /*TemplateArgs=*/nullptr,
11113  /*Scope=*/nullptr);
11114  }
11115 
11116  return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
11117  }
11118 
11119  // If we have template arguments, rebuild them, then rebuild the
11120  // templateid expression.
11121  TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
11122  if (Old->hasExplicitTemplateArgs() &&
11123  getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
11124  Old->getNumTemplateArgs(),
11125  TransArgs)) {
11126  R.clear();
11127  return ExprError();
11128  }
11129 
11130  return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
11131  Old->requiresADL(), &TransArgs);
11132 }
11133 
11134 template<typename Derived>
11135 ExprResult
11137  bool ArgChanged = false;
11139  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
11140  TypeSourceInfo *From = E->getArg(I);
11141  TypeLoc FromTL = From->getTypeLoc();
11142  if (!FromTL.getAs<PackExpansionTypeLoc>()) {
11143  TypeLocBuilder TLB;
11144  TLB.reserve(FromTL.getFullDataSize());
11145  QualType To = getDerived().TransformType(TLB, FromTL);
11146  if (To.isNull())
11147  return ExprError();
11148 
11149  if (To == From->getType())
11150  Args.push_back(From);
11151  else {
11152  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
11153  ArgChanged = true;
11154  }
11155  continue;
11156  }
11157 
11158  ArgChanged = true;
11159 
11160  // We have a pack expansion. Instantiate it.
11161  PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
11162  TypeLoc PatternTL = ExpansionTL.getPatternLoc();
11164  SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
11165 
11166  // Determine whether the set of unexpanded parameter packs can and should
11167  // be expanded.
11168  bool Expand = true;
11169  bool RetainExpansion = false;
11170  Optional<unsigned> OrigNumExpansions =
11171  ExpansionTL.getTypePtr()->getNumExpansions();
11172  Optional<unsigned> NumExpansions = OrigNumExpansions;
11173  if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
11174  PatternTL.getSourceRange(),
11175  Unexpanded,
11176  Expand, RetainExpansion,
11177  NumExpansions))
11178  return ExprError();
11179 
11180  if (!Expand) {
11181  // The transform has determined that we should perform a simple
11182  // transformation on the pack expansion, producing another pack
11183  // expansion.
11184  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
11185 
11186  TypeLocBuilder TLB;
11187  TLB.reserve(From->getTypeLoc().getFullDataSize());
11188 
11189  QualType To = getDerived().TransformType(TLB, PatternTL);
11190  if (To.isNull())
11191  return ExprError();
11192 
11193  To = getDerived().RebuildPackExpansionType(To,
11194  PatternTL.getSourceRange(),
11195  ExpansionTL.getEllipsisLoc(),
11196  NumExpansions);
11197  if (To.isNull())
11198  return ExprError();
11199 
11200  PackExpansionTypeLoc ToExpansionTL
11201  = TLB.push<PackExpansionTypeLoc>(To);
11202  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
11203  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
11204  continue;
11205  }
11206 
11207  // Expand the pack expansion by substituting for each argument in the
11208  // pack(s).
11209  for (unsigned I = 0; I != *NumExpansions; ++I) {
11210  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I);
11211  TypeLocBuilder TLB;
11212  TLB.reserve(PatternTL.getFullDataSize());
11213  QualType To = getDerived().TransformType(TLB, PatternTL);
11214  if (To.isNull())
11215  return ExprError();
11216 
11217  if (To->containsUnexpandedParameterPack()) {
11218  To = getDerived().RebuildPackExpansionType(To,
11219  PatternTL.getSourceRange(),
11220  ExpansionTL.getEllipsisLoc(),
11221  NumExpansions);
11222  if (To.isNull())
11223  return ExprError();
11224 
11225  PackExpansionTypeLoc ToExpansionTL
11226  = TLB.push<PackExpansionTypeLoc>(To);
11227  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
11228  }
11229 
11230  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
11231  }
11232 
11233  if (!RetainExpansion)
11234  continue;
11235 
11236  // If we're supposed to retain a pack expansion, do so by temporarily
11237  // forgetting the partially-substituted parameter pack.
11238  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
11239 
11240  TypeLocBuilder TLB;
11241  TLB.reserve(From->getTypeLoc().getFullDataSize());
11242 
11243  QualType To = getDerived().TransformType(TLB, PatternTL);
11244  if (To.isNull())
11245  return ExprError();
11246 
11247  To = getDerived().RebuildPackExpansionType(To,
11248  PatternTL.getSourceRange(),
11249  ExpansionTL.getEllipsisLoc(),
11250  NumExpansions);
11251  if (To.isNull())
11252  return ExprError();
11253 
11254  PackExpansionTypeLoc ToExpansionTL
11255  = TLB.push<PackExpansionTypeLoc>(To);
11256  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
11257  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
11258  }
11259 
11260  if (!getDerived().AlwaysRebuild() && !ArgChanged)
11261  return E;
11262 
11263  return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
11264  E->getEndLoc());
11265 }
11266 
11267 template<typename Derived>
11268 ExprResult
11272  TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
11273  if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
11274  Old->NumTemplateArgs, TransArgs))
11275  return ExprError();
11276 
11277  return getDerived().RebuildConceptSpecializationExpr(
11280  &TransArgs);
11281 }
11282 
11283 template<typename Derived>
11284 ExprResult
11286  SmallVector<ParmVarDecl*, 4> TransParams;
11287  SmallVector<QualType, 4> TransParamTypes;
11288  Sema::ExtParameterInfoBuilder ExtParamInfos;
11289 
11290  // C++2a [expr.prim.req]p2
11291  // Expressions appearing within a requirement-body are unevaluated operands.
11293  SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);
11294 
11296  getSema().Context, E->getBody()->getDeclContext(),
11297  E->getBody()->getBeginLoc());
11298 
11299  Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
11300 
11301  if (getDerived().TransformFunctionTypeParams(E->getRequiresKWLoc(),
11302  E->getLocalParameters(),
11303  /*ParamTypes=*/nullptr,
11304  /*ParamInfos=*/nullptr,
11305  TransParamTypes, &TransParams,
11306  ExtParamInfos))
11307  return ExprError();
11308 
11309  for (ParmVarDecl *Param : TransParams)
11310  Param->setDeclContext(Body);
11311 
11313  if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
11314  TransReqs))
11315  return ExprError();
11316 
11317  for (concepts::Requirement *Req : TransReqs) {
11318  if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
11319  if (ER->getReturnTypeRequirement().isTypeConstraint()) {
11320  ER->getReturnTypeRequirement()
11321  .getTypeConstraintTemplateParameterList()->getParam(0)
11322  ->setDeclContext(Body);
11323  }
11324  }
11325  }
11326 
11327  return getDerived().RebuildRequiresExpr(E->getRequiresKWLoc(), Body,
11328  TransParams, TransReqs,
11329  E->getRBraceLoc());
11330 }
11331 
11332 template<typename Derived>
11336  for (concepts::Requirement *Req : Reqs) {
11337  concepts::Requirement *TransReq = nullptr;
11338  if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
11339  TransReq = getDerived().TransformTypeRequirement(TypeReq);
11340  else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
11341  TransReq = getDerived().TransformExprRequirement(ExprReq);
11342  else
11343  TransReq = getDerived().TransformNestedRequirement(
11344  cast<concepts::NestedRequirement>(Req));
11345  if (!TransReq)
11346  return true;
11347  Transformed.push_back(TransReq);
11348  }
11349  return false;
11350 }
11351 
11352 template<typename Derived>
11356  if (Req->isSubstitutionFailure()) {
11357  if (getDerived().AlwaysRebuild())
11358  return getDerived().RebuildTypeRequirement(
11359  Req->getSubstitutionDiagnostic());
11360  return Req;
11361  }
11362  TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
11363  if (!TransType)
11364  return nullptr;
11365  return getDerived().RebuildTypeRequirement(TransType);
11366 }
11367 
11368 template<typename Derived>
11371  llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
11372  if (Req->isExprSubstitutionFailure())
11373  TransExpr = Req->getExprSubstitutionDiagnostic();
11374  else {
11375  ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
11376  if (TransExprRes.isInvalid())
11377  return nullptr;
11378  TransExpr = TransExprRes.get();
11379  }
11380 
11382  const auto &RetReq = Req->getReturnTypeRequirement();
11383  if (RetReq.isEmpty())
11384  TransRetReq.emplace();
11385  else if (RetReq.isSubstitutionFailure())
11386  TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
11387  else if (RetReq.isTypeConstraint()) {
11388  TemplateParameterList *OrigTPL =
11389  RetReq.getTypeConstraintTemplateParameterList();
11390  TemplateParameterList *TPL =
11391  getDerived().TransformTemplateParameterList(OrigTPL);
11392  if (!TPL)
11393  return nullptr;
11394  TransRetReq.emplace(TPL);
11395  }
11396  assert(TransRetReq.hasValue() &&
11397  "All code paths leading here must set TransRetReq");
11398  if (Expr *E = TransExpr.dyn_cast<Expr *>())
11399  return getDerived().RebuildExprRequirement(E, Req->isSimple(),
11400  Req->getNoexceptLoc(),
11401  std::move(*TransRetReq));
11402  return getDerived().RebuildExprRequirement(
11404  Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
11405 }
11406 
11407 template<typename Derived>
11411  if (Req->isSubstitutionFailure()) {
11412  if (getDerived().AlwaysRebuild())
11413  return getDerived().RebuildNestedRequirement(
11414  Req->getSubstitutionDiagnostic());
11415  return Req;
11416  }
11417  ExprResult TransConstraint =
11418  getDerived().TransformExpr(Req->getConstraintExpr());
11419  if (TransConstraint.isInvalid())
11420  return nullptr;
11421  return getDerived().RebuildNestedRequirement(TransConstraint.get());
11422 }
11423 
11424 template<typename Derived>
11425 ExprResult
11427  TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
11428  if (!T)
11429  return ExprError();
11430 
11431  if (!getDerived().AlwaysRebuild() &&
11432  T == E->getQueriedTypeSourceInfo())
11433  return E;
11434 
11435  ExprResult SubExpr;
11436  {
11438  SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);
11439  SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
11440  if (SubExpr.isInvalid())
11441  return ExprError();
11442 
11443  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getDimensionExpression())
11444  return E;
11445  }
11446 
11447  return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
11448  SubExpr.get(), E->getEndLoc());
11449 }
11450 
11451 template<typename Derived>
11452 ExprResult
11454  ExprResult SubExpr;
11455  {
11457  SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);
11458  SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
11459  if (SubExpr.isInvalid())
11460  return ExprError();
11461 
11462  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
11463  return E;
11464  }
11465 
11466  return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
11467  SubExpr.get(), E->getEndLoc());
11468 }
11469 
11470 template <typename Derived>
11472  ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
11473  TypeSourceInfo **RecoveryTSI) {
11474  ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
11475  DRE, AddrTaken, RecoveryTSI);
11476 
11477  // Propagate both errors and recovered types, which return ExprEmpty.
11478  if (!NewDRE.isUsable())
11479  return NewDRE;
11480 
11481  // We got an expr, wrap it up in parens.
11482  if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
11483  return PE;
11484  return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
11485  PE->getRParen());
11486 }
11487 
11488 template <typename Derived>
11491  return TransformDependentScopeDeclRefExpr(E, /*IsAddressOfOperand=*/false,
11492  nullptr);
11493 }
11494 
11495 template<typename Derived>
11496 ExprResult
11499  bool IsAddressOfOperand,
11500  TypeSourceInfo **RecoveryTSI) {
11501  assert(E->getQualifierLoc());
11502  NestedNameSpecifierLoc QualifierLoc
11503  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
11504  if (!QualifierLoc)
11505  return ExprError();
11506  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
11507 
11508  // TODO: If this is a conversion-function-id, verify that the
11509  // destination type name (if present) resolves the same way after
11510  // instantiation as it did in the local scope.
11511 
11512  DeclarationNameInfo NameInfo
11513  = getDerived().TransformDeclarationNameInfo(E->getNameInfo());
11514  if (!NameInfo.getName())
11515  return ExprError();
11516 
11517  if (!E->hasExplicitTemplateArgs()) {
11518  if (!getDerived().AlwaysRebuild() &&
11519  QualifierLoc == E->getQualifierLoc() &&
11520  // Note: it is sufficient to compare the Name component of NameInfo:
11521  // if name has not changed, DNLoc has not changed either.
11522  NameInfo.getName() == E->getDeclName())
11523  return E;
11524 
11525  return getDerived().RebuildDependentScopeDeclRefExpr(
11526  QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
11527  IsAddressOfOperand, RecoveryTSI);
11528  }
11529 
11530  TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
11531  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
11532  E->getNumTemplateArgs(),
11533  TransArgs))
11534  return ExprError();
11535 
11536  return getDerived().RebuildDependentScopeDeclRefExpr(
11537  QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
11538  RecoveryTSI);
11539 }
11540 
11541 template<typename Derived>
11542 ExprResult
11544  // CXXConstructExprs other than for list-initialization and
11545  // CXXTemporaryObjectExpr are always implicit, so when we have
11546  // a 1-argument construction we just transform that argument.
11547  if ((E->getNumArgs() == 1 ||
11548  (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
11549  (!getDerived().DropCallArgument(E->getArg(0))) &&
11550  !E->isListInitialization())
11551  return getDerived().TransformExpr(E->getArg(0));
11552 
11553  TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
11554 
11555  QualType T = getDerived().TransformType(E->getType());
11556  if (T.isNull())
11557  return ExprError();
11558 
11559  CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
11560  getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
11561  if (!Constructor)
11562  return ExprError();
11563 
11564  bool ArgumentChanged = false;
11565  SmallVector<Expr*, 8> Args;
11566  {
11568  getSema(), EnterExpressionEvaluationContext::InitList,
11569  E->isListInitialization());
11570  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
11571  &ArgumentChanged))
11572  return ExprError();
11573  }
11574 
11575  if (!getDerived().AlwaysRebuild() &&
11576  T == E->getType() &&
11577  Constructor == E->getConstructor() &&
11578  !ArgumentChanged) {
11579  // Mark the constructor as referenced.
11580  // FIXME: Instantiation-specific
11581  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
11582  return E;
11583  }
11584 
11585  return getDerived().RebuildCXXConstructExpr(
11586  T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
11590 }
11591 
11592 template<typename Derived>
11595  QualType T = getDerived().TransformType(E->getType());
11596  if (T.isNull())
11597  return ExprError();
11598 
11599  CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
11600  getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
11601  if (!Constructor)
11602  return ExprError();
11603 
11604  if (!getDerived().AlwaysRebuild() &&
11605  T == E->getType() &&
11606  Constructor == E->getConstructor()) {
11607  // Mark the constructor as referenced.
11608  // FIXME: Instantiation-specific
11609  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
11610  return E;
11611  }
11612 
11613  return getDerived().RebuildCXXInheritedCtorInitExpr(
11614  T, E->getLocation(), Constructor,
11615  E->constructsVBase(), E->inheritedFromVBase());
11616 }
11617 
11618 /// Transform a C++ temporary-binding expression.
11619 ///
11620 /// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
11621 /// transform the subexpression and return that.
11622 template<typename Derived>
11623 ExprResult
11625  return getDerived().TransformExpr(E->getSubExpr());
11626 }
11627 
11628 /// Transform a C++ expression that contains cleanups that should
11629 /// be run after the expression is evaluated.
11630 ///
11631 /// Since ExprWithCleanups nodes are implicitly generated, we
11632 /// just transform the subexpression and return that.
11633 template<typename Derived>
11634 ExprResult
11636  return getDerived().TransformExpr(E->getSubExpr());
11637 }
11638 
11639 template<typename Derived>
11640 ExprResult
11643  TypeSourceInfo *T =
11644  getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
11645  if (!T)
11646  return ExprError();
11647 
11648  CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
11649  getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
11650  if (!Constructor)
11651  return ExprError();
11652 
11653  bool ArgumentChanged = false;
11654  SmallVector<Expr*, 8> Args;
11655  Args.reserve(E->getNumArgs());
11656  {
11658  getSema(), EnterExpressionEvaluationContext::InitList,
11659  E->isListInitialization());
11660  if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
11661  &ArgumentChanged))
11662  return ExprError();
11663  }
11664 
11665  if (!getDerived().AlwaysRebuild() &&
11666  T == E->getTypeSourceInfo() &&
11667  Constructor == E->getConstructor() &&
11668  !ArgumentChanged) {
11669  // FIXME: Instantiation-specific
11670  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
11671  return SemaRef.MaybeBindToTemporary(E);
11672  }
11673 
11674  // FIXME: We should just pass E->isListInitialization(), but we're not
11675  // prepared to handle list-initialization without a child InitListExpr.
11676  SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
11677  return getDerived().RebuildCXXTemporaryObjectExpr(
11678  T, LParenLoc, Args, E->getEndLoc(),
11679  /*ListInitialization=*/LParenLoc.isInvalid());
11680 }
11681 
11682 template<typename Derived>
11683 ExprResult
11685  // Transform any init-capture expressions before entering the scope of the
11686  // lambda body, because they are not semantically within that scope.
11687  typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
11688  struct TransformedInitCapture {
11689  // The location of the ... if the result is retaining a pack expansion.
11690  SourceLocation EllipsisLoc;
11691  // Zero or more expansions of the init-capture.
11693  };
11695  InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
11697  CEnd = E->capture_end();
11698  C != CEnd; ++C) {
11699  if (!E->isInitCapture(C))
11700  continue;
11701 
11702  TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
11703  VarDecl *OldVD = C->getCapturedVar();
11704 
11705  auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
11706  Optional<unsigned> NumExpansions) {
11707  ExprResult NewExprInitResult = getDerived().TransformInitializer(
11708  OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
11709 
11710  if (NewExprInitResult.isInvalid()) {
11711  Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
11712  return;
11713  }
11714  Expr *NewExprInit = NewExprInitResult.get();
11715 
11716  QualType NewInitCaptureType =
11717  getSema().buildLambdaInitCaptureInitialization(
11718  C->getLocation(), OldVD->getType()->isReferenceType(),
11719  EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
11720  C->getCapturedVar()->getInitStyle() != VarDecl::CInit,
11721  NewExprInit);
11722  Result.Expansions.push_back(
11723  InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
11724  };
11725 
11726  // If this is an init-capture pack, consider expanding the pack now.
11727  if (OldVD->isParameterPack()) {
11728  PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
11729  ->getTypeLoc()
11732  SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
11733 
11734  // Determine whether the set of unexpanded parameter packs can and should
11735  // be expanded.
11736  bool Expand = true;
11737  bool RetainExpansion = false;
11738  Optional<unsigned> OrigNumExpansions =
11739  ExpansionTL.getTypePtr()->getNumExpansions();
11740  Optional<unsigned> NumExpansions = OrigNumExpansions;
11741  if (getDerived().TryExpandParameterPacks(
11742  ExpansionTL.getEllipsisLoc(),
11743  OldVD->getInit()->getSourceRange(), Unexpanded, Expand,
11744  RetainExpansion, NumExpansions))
11745  return ExprError();
11746  if (Expand) {
11747  for (unsigned I = 0; I != *NumExpansions; ++I) {
11748  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
11749  SubstInitCapture(SourceLocation(), None);
11750  }
11751  }
11752  if (!Expand || RetainExpansion) {
11753  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
11754  SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
11755  Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
11756  }
11757  } else {
11758  SubstInitCapture(SourceLocation(), None);
11759  }
11760  }
11761 
11762  LambdaScopeInfo *LSI = getSema().PushLambdaScope();
11763  Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
11764 
11765  // Transform the template parameters, and add them to the current
11766  // instantiation scope. The null case is handled correctly.
11767  auto TPL = getDerived().TransformTemplateParameterList(
11769  LSI->GLTemplateParameterList = TPL;
11770 
11771  // Transform the type of the original lambda's call operator.
11772  // The transformation MUST be done in the CurrentInstantiationScope since
11773  // it introduces a mapping of the original to the newly created
11774  // transformed parameters.
11775  TypeSourceInfo *NewCallOpTSI = nullptr;
11776  {
11777  TypeSourceInfo *OldCallOpTSI = E->getCallOperator()->getTypeSourceInfo();
11778  FunctionProtoTypeLoc OldCallOpFPTL =
11779  OldCallOpTSI->getTypeLoc().getAs<FunctionProtoTypeLoc>();
11780 
11781  TypeLocBuilder NewCallOpTLBuilder;
11782  SmallVector<QualType, 4> ExceptionStorage;
11783  TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
11784  QualType NewCallOpType = TransformFunctionProtoType(
11785  NewCallOpTLBuilder, OldCallOpFPTL, nullptr, Qualifiers(),
11786  [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
11787  return This->TransformExceptionSpec(OldCallOpFPTL.getBeginLoc(), ESI,
11788  ExceptionStorage, Changed);
11789  });
11790  if (NewCallOpType.isNull())
11791  return ExprError();
11792  NewCallOpTSI = NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context,
11793  NewCallOpType);
11794  }
11795 
11796  // Transform the trailing requires clause
11797  ExprResult NewTrailingRequiresClause;
11798  if (Expr *TRC = E->getCallOperator()->getTrailingRequiresClause())
11799  // FIXME: Concepts: Substitution into requires clause should only happen
11800  // when checking satisfaction.
11801  NewTrailingRequiresClause = getDerived().TransformExpr(TRC);
11802 
11803  // Create the local class that will describe the lambda.
11804  CXXRecordDecl *OldClass = E->getLambdaClass();
11805  CXXRecordDecl *Class
11806  = getSema().createLambdaClosureType(E->getIntroducerRange(),
11807  NewCallOpTSI,
11808  /*KnownDependent=*/false,
11809  E->getCaptureDefault());
11810  getDerived().transformedLocalDecl(OldClass, {Class});
11811 
11813  if (getDerived().ReplacingOriginal())
11814  Mangling = std::make_tuple(OldClass->getLambdaManglingNumber(),
11815  OldClass->hasKnownLambdaInternalLinkage(),
11816  OldClass->getLambdaContextDecl());
11817 
11818  // Build the call operator.
11819  CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition(
11820  Class, E->getIntroducerRange(), NewCallOpTSI,
11821  E->getCallOperator()->getEndLoc(),
11822  NewCallOpTSI->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams(),
11824  NewTrailingRequiresClause.get());
11825 
11826  LSI->CallOperator = NewCallOperator;
11827 
11828  for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
11829  I != NumParams; ++I) {
11830  auto *P = NewCallOperator->getParamDecl(I);
11831  if (P->hasUninstantiatedDefaultArg()) {
11833  getSema(),
11834  Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed, P);
11835  ExprResult R = getDerived().TransformExpr(
11837  P->setDefaultArg(R.get());
11838  }
11839  }
11840 
11841  getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
11842  getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
11843 
11844  // Number the lambda for linkage purposes if necessary.
11845  getSema().handleLambdaNumbering(Class, NewCallOperator, Mangling);
11846 
11847  // Introduce the context of the call operator.
11848  Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
11849  /*NewThisContext*/false);
11850 
11851  // Enter the scope of the lambda.
11852  getSema().buildLambdaScope(LSI, NewCallOperator,
11853  E->getIntroducerRange(),
11854  E->getCaptureDefault(),
11855  E->getCaptureDefaultLoc(),
11856  E->hasExplicitParameters(),
11857  E->hasExplicitResultType(),
11858  E->isMutable());
11859 
11860  bool Invalid = false;
11861 
11862  // Transform captures.
11864  CEnd = E->capture_end();
11865  C != CEnd; ++C) {
11866  // When we hit the first implicit capture, tell Sema that we've finished
11867  // the list of explicit captures.
11868  if (C->isImplicit())
11869  break;
11870 
11871  // Capturing 'this' is trivial.
11872  if (C->capturesThis()) {
11873  getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
11874  /*BuildAndDiagnose*/ true, nullptr,
11875  C->getCaptureKind() == LCK_StarThis);
11876  continue;
11877  }
11878  // Captured expression will be recaptured during captured variables
11879  // rebuilding.
11880  if (C->capturesVLAType())
11881  continue;
11882 
11883  // Rebuild init-captures, including the implied field declaration.
11884  if (E->isInitCapture(C)) {
11885  TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
11886 
11887  VarDecl *OldVD = C->getCapturedVar();
11889 
11890  for (InitCaptureInfoTy &Info : NewC.Expansions) {
11891  ExprResult Init = Info.first;
11892  QualType InitQualType = Info.second;
11893  if (Init.isInvalid() || InitQualType.isNull()) {
11894  Invalid = true;
11895  break;
11896  }
11897  VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
11898  OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
11899  OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get());
11900  if (!NewVD) {
11901  Invalid = true;
11902  break;
11903  }
11904  NewVDs.push_back(NewVD);
11905  getSema().addInitCapture(LSI, NewVD);
11906  }
11907 
11908  if (Invalid)
11909  break;
11910 
11911  getDerived().transformedLocalDecl(OldVD, NewVDs);
11912  continue;
11913  }
11914 
11915  assert(C->capturesVariable() && "unexpected kind of lambda capture");
11916 
11917  // Determine the capture kind for Sema.
11919  = C->isImplicit()? Sema::TryCapture_Implicit
11920  : C->getCaptureKind() == LCK_ByCopy
11921  ? Sema::TryCapture_ExplicitByVal
11922  : Sema::TryCapture_ExplicitByRef;
11923  SourceLocation EllipsisLoc;
11924  if (C->isPackExpansion()) {
11925  UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
11926  bool ShouldExpand = false;
11927  bool RetainExpansion = false;
11928  Optional<unsigned> NumExpansions;
11929  if (getDerived().TryExpandParameterPacks(C->getEllipsisLoc(),
11930  C->getLocation(),
11931  Unexpanded,
11932  ShouldExpand, RetainExpansion,
11933  NumExpansions)) {
11934  Invalid = true;
11935  continue;
11936  }
11937 
11938  if (ShouldExpand) {
11939  // The transform has determined that we should perform an expansion;
11940  // transform and capture each of the arguments.
11941  // expansion of the pattern. Do so.
11942  VarDecl *Pack = C->getCapturedVar();
11943  for (unsigned I = 0; I != *NumExpansions; ++I) {
11944  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
11945  VarDecl *CapturedVar
11946  = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(),
11947  Pack));
11948  if (!CapturedVar) {
11949  Invalid = true;
11950  continue;
11951  }
11952 
11953  // Capture the transformed variable.
11954  getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
11955  }
11956 
11957  // FIXME: Retain a pack expansion if RetainExpansion is true.
11958 
11959  continue;
11960  }
11961 
11962  EllipsisLoc = C->getEllipsisLoc();
11963  }
11964 
11965  // Transform the captured variable.
11966  VarDecl *CapturedVar
11967  = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(),
11968  C->getCapturedVar()));
11969  if (!CapturedVar || CapturedVar->isInvalidDecl()) {
11970  Invalid = true;
11971  continue;
11972  }
11973 
11974  // Capture the transformed variable.
11975  getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
11976  EllipsisLoc);
11977  }
11978  getSema().finishLambdaExplicitCaptures(LSI);
11979 
11980  // FIXME: Sema's lambda-building mechanism expects us to push an expression
11981  // evaluation context even if we're not transforming the function body.
11982  getSema().PushExpressionEvaluationContext(
11983  Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
11984 
11985  // Instantiate the body of the lambda expression.
11986  StmtResult Body =
11987  Invalid ? StmtError() : getDerived().TransformLambdaBody(E, E->getBody());
11988 
11989  // ActOnLambda* will pop the function scope for us.
11990  FuncScopeCleanup.disable();
11991 
11992  if (Body.isInvalid()) {
11993  SavedContext.pop();
11994  getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
11995  /*IsInstantiation=*/true);
11996  return ExprError();
11997  }
11998 
11999  // Copy the LSI before ActOnFinishFunctionBody removes it.
12000  // FIXME: This is dumb. Store the lambda information somewhere that outlives
12001  // the call operator.
12002  auto LSICopy = *LSI;
12003  getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
12004  /*IsInstantiation*/ true);
12005  SavedContext.pop();
12006 
12007  return getSema().BuildLambdaExpr(E->getBeginLoc(), Body.get()->getEndLoc(),
12008  &LSICopy);
12009 }
12010 
12011 template<typename Derived>
12012 StmtResult
12014  return TransformStmt(S);
12015 }
12016 
12017 template<typename Derived>
12018 StmtResult
12020  // Transform captures.
12022  CEnd = E->capture_end();
12023  C != CEnd; ++C) {
12024  // When we hit the first implicit capture, tell Sema that we've finished
12025  // the list of explicit captures.
12026  if (!C->isImplicit())
12027  continue;
12028 
12029  // Capturing 'this' is trivial.
12030  if (C->capturesThis()) {
12031  getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
12032  /*BuildAndDiagnose*/ true, nullptr,
12033  C->getCaptureKind() == LCK_StarThis);
12034  continue;
12035  }
12036  // Captured expression will be recaptured during captured variables
12037  // rebuilding.
12038  if (C->capturesVLAType())
12039  continue;
12040 
12041  assert(C->capturesVariable() && "unexpected kind of lambda capture");
12042  assert(!E->isInitCapture(C) && "implicit init-capture?");
12043 
12044  // Transform the captured variable.
12045  VarDecl *CapturedVar = cast_or_null<VarDecl>(
12046  getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
12047  if (!CapturedVar || CapturedVar->isInvalidDecl())
12048  return StmtError();
12049 
12050  // Capture the transformed variable.
12051  getSema().tryCaptureVariable(CapturedVar, C->getLocation());
12052  }
12053 
12054  return S;
12055 }
12056 
12057 template<typename Derived>
12058 ExprResult
12061  TypeSourceInfo *T =
12062  getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
12063  if (!T)
12064  return ExprError();
12065 
12066  bool ArgumentChanged = false;
12067  SmallVector<Expr*, 8> Args;
12068  Args.reserve(E->arg_size());
12069  {
12071  getSema(), EnterExpressionEvaluationContext::InitList,
12072  E->isListInitialization());
12073  if (getDerived().TransformExprs(E->arg_begin(), E->arg_size(), true, Args,
12074  &ArgumentChanged))
12075  return ExprError();
12076  }
12077 
12078  if (!getDerived().AlwaysRebuild() &&
12079  T == E->getTypeSourceInfo() &&
12080  !ArgumentChanged)
12081  return E;
12082 
12083  // FIXME: we're faking the locations of the commas
12084  return getDerived().RebuildCXXUnresolvedConstructExpr(
12085  T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
12086 }
12087 
12088 template<typename Derived>
12089 ExprResult
12092  // Transform the base of the expression.
12093  ExprResult Base((Expr*) nullptr);
12094  Expr *OldBase;
12095  QualType BaseType;
12096  QualType ObjectType;
12097  if (!E->isImplicitAccess()) {
12098  OldBase = E->getBase();
12099  Base = getDerived().TransformExpr(OldBase);
12100  if (Base.isInvalid())
12101  return ExprError();
12102 
12103  // Start the member reference and compute the object's type.
12104  ParsedType ObjectTy;
12105  bool MayBePseudoDestructor = false;
12106  Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
12107  E->getOperatorLoc(),
12108  E->isArrow()? tok::arrow : tok::period,
12109  ObjectTy,
12110  MayBePseudoDestructor);
12111  if (Base.isInvalid())
12112  return ExprError();
12113 
12114  ObjectType = ObjectTy.get();
12115  BaseType = ((Expr*) Base.get())->getType();
12116  } else {
12117  OldBase = nullptr;
12118  BaseType = getDerived().TransformType(E->getBaseType());
12119  ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
12120  }
12121 
12122  // Transform the first part of the nested-name-specifier that qualifies
12123  // the member name.
12124  NamedDecl *FirstQualifierInScope
12125  = getDerived().TransformFirstQualifierInScope(
12127  E->getQualifierLoc().getBeginLoc());
12128 
12129  NestedNameSpecifierLoc QualifierLoc;
12130  if (E->getQualifier()) {
12131  QualifierLoc
12132  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
12133  ObjectType,
12134  FirstQualifierInScope);
12135  if (!QualifierLoc)
12136  return ExprError();
12137  }
12138 
12139  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
12140 
12141  // TODO: If this is a conversion-function-id, verify that the
12142  // destination type name (if present) resolves the same way after
12143  // instantiation as it did in the local scope.
12144 
12145  DeclarationNameInfo NameInfo
12146  = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
12147  if (!NameInfo.getName())
12148  return ExprError();
12149 
12150  if (!E->hasExplicitTemplateArgs()) {
12151  // This is a reference to a member without an explicitly-specified
12152  // template argument list. Optimize for this common case.
12153  if (!getDerived().AlwaysRebuild() &&
12154  Base.get() == OldBase &&
12155  BaseType == E->getBaseType() &&
12156  QualifierLoc == E->getQualifierLoc() &&
12157  NameInfo.getName() == E->getMember() &&
12158  FirstQualifierInScope == E->getFirstQualifierFoundInScope())
12159  return E;
12160 
12161  return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
12162  BaseType,
12163  E->isArrow(),
12164  E->getOperatorLoc(),
12165  QualifierLoc,
12166  TemplateKWLoc,
12167  FirstQualifierInScope,
12168  NameInfo,
12169  /*TemplateArgs*/nullptr);
12170  }
12171 
12172  TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
12173  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
12174  E->getNumTemplateArgs(),
12175  TransArgs))
12176  return ExprError();
12177 
12178  return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
12179  BaseType,
12180  E->isArrow(),
12181  E->getOperatorLoc(),
12182  QualifierLoc,
12183  TemplateKWLoc,
12184  FirstQualifierInScope,
12185  NameInfo,
12186  &TransArgs);
12187 }
12188 
12189 template<typename Derived>
12190 ExprResult
12192  // Transform the base of the expression.
12193  ExprResult Base((Expr*) nullptr);
12194  QualType BaseType;
12195  if (!Old->isImplicitAccess()) {
12196  Base = getDerived().TransformExpr(Old->getBase());
12197  if (Base.isInvalid())
12198  return ExprError();
12199  Base = getSema().PerformMemberExprBaseConversion(Base.get(),
12200  Old->isArrow());
12201  if (Base.isInvalid())
12202  return ExprError();
12203  BaseType = Base.get()->getType();
12204  } else {
12205  BaseType = getDerived().TransformType(Old->getBaseType());
12206  }
12207 
12208  NestedNameSpecifierLoc QualifierLoc;
12209  if (Old->getQualifierLoc()) {
12210  QualifierLoc
12211  = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
12212  if (!QualifierLoc)
12213  return ExprError();
12214  }
12215 
12216  SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
12217 
12218  LookupResult R(SemaRef, Old->getMemberNameInfo(),
12219  Sema::LookupOrdinaryName);
12220 
12221  // Transform the declaration set.
12222  if (TransformOverloadExprDecls(Old, /*RequiresADL*/false, R))
12223  return ExprError();
12224 
12225  // Determine the naming class.
12226  if (Old->getNamingClass()) {
12227  CXXRecordDecl *NamingClass
12228  = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
12229  Old->getMemberLoc(),
12230  Old->getNamingClass()));
12231  if (!NamingClass)
12232  return ExprError();
12233 
12234  R.setNamingClass(NamingClass);
12235  }
12236 
12237  TemplateArgumentListInfo TransArgs;
12238  if (Old->hasExplicitTemplateArgs()) {
12239  TransArgs.setLAngleLoc(Old->getLAngleLoc());
12240  TransArgs.setRAngleLoc(Old->getRAngleLoc());
12241  if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
12242  Old->getNumTemplateArgs(),
12243  TransArgs))
12244  return ExprError();
12245  }
12246 
12247  // FIXME: to do this check properly, we will need to preserve the
12248  // first-qualifier-in-scope here, just in case we had a dependent
12249  // base (and therefore couldn't do the check) and a
12250  // nested-name-qualifier (and therefore could do the lookup).
12251  NamedDecl *FirstQualifierInScope = nullptr;
12252 
12253  return getDerived().RebuildUnresolvedMemberExpr(Base.get(),
12254  BaseType,
12255  Old->getOperatorLoc(),
12256  Old->isArrow(),
12257  QualifierLoc,
12258  TemplateKWLoc,
12259  FirstQualifierInScope,
12260  R,
12261  (Old->hasExplicitTemplateArgs()
12262  ? &TransArgs : nullptr));
12263 }
12264 
12265 template<typename Derived>
12266 ExprResult
12269  SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);
12270  ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
12271  if (SubExpr.isInvalid())
12272  return ExprError();
12273 
12274  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
12275  return E;
12276 
12277  return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
12278 }
12279 
12280 template<typename Derived>
12281 ExprResult
12283  ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
12284  if (Pattern.isInvalid())
12285  return ExprError();
12286 
12287  if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
12288  return E;
12289 
12290  return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
12291  E->getNumExpansions());
12292 }
12293 
12294 template<typename Derived>
12295 ExprResult
12297  // If E is not value-dependent, then nothing will change when we transform it.
12298  // Note: This is an instantiation-centric view.
12299  if (!E->isValueDependent())
12300  return E;
12301 
12303  getSema(), Sema::ExpressionEvaluationContext::Unevaluated);
12304 
12305  ArrayRef<TemplateArgument> PackArgs;
12306  TemplateArgument ArgStorage;
12307 
12308  // Find the argument list to transform.
12309  if (E->isPartiallySubstituted()) {
12310  PackArgs = E->getPartialArguments();
12311  } else if (E->isValueDependent()) {
12312  UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
12313  bool ShouldExpand = false;
12314  bool RetainExpansion = false;
12315  Optional<unsigned> NumExpansions;
12316  if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(),
12317  Unexpanded,
12318  ShouldExpand, RetainExpansion,
12319  NumExpansions))
12320  return ExprError();
12321 
12322  // If we need to expand the pack, build a template argument from it and
12323  // expand that.
12324  if (ShouldExpand) {
12325  auto *Pack = E->getPack();
12326  if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
12327  ArgStorage = getSema().Context.getPackExpansionType(
12328  getSema().Context.getTypeDeclType(TTPD), None);
12329  } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
12330  ArgStorage = TemplateArgument(TemplateName(TTPD), None);
12331  } else {
12332  auto *VD = cast<ValueDecl>(Pack);
12333  ExprResult DRE = getSema().BuildDeclRefExpr(
12334  VD, VD->getType().getNonLValueExprType(getSema().Context),
12335  VD->getType()->isReferenceType() ? VK_LValue : VK_RValue,
12336  E->getPackLoc());
12337  if (DRE.isInvalid())
12338  return ExprError();
12339  ArgStorage = new (getSema().Context) PackExpansionExpr(
12340  getSema().Context.DependentTy, DRE.get(), E->getPackLoc(), None);
12341  }
12342  PackArgs = ArgStorage;
12343  }
12344  }
12345 
12346  // If we're not expanding the pack, just transform the decl.
12347  if (!PackArgs.size()) {
12348  auto *Pack = cast_or_null<NamedDecl>(
12349  getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
12350  if (!Pack)
12351  return ExprError();
12352  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), Pack,
12353  E->getPackLoc(),
12354  E->getRParenLoc(), None, None);
12355  }
12356 
12357  // Try to compute the result without performing a partial substitution.
12358  Optional<unsigned> Result = 0;
12359  for (const TemplateArgument &Arg : PackArgs) {
12360  if (!Arg.isPackExpansion()) {
12361  Result = *Result + 1;
12362  continue;
12363  }
12364 
12365  TemplateArgumentLoc ArgLoc;
12366  InventTemplateArgumentLoc(Arg, ArgLoc);
12367 
12368  // Find the pattern of the pack expansion.
12369  SourceLocation Ellipsis;
12370  Optional<unsigned> OrigNumExpansions;
12371  TemplateArgumentLoc Pattern =
12372  getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
12373  OrigNumExpansions);
12374 
12375  // Substitute under the pack expansion. Do not expand the pack (yet).
12376  TemplateArgumentLoc OutPattern;
12377  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
12378  if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
12379  /*Uneval*/ true))
12380  return true;
12381 
12382  // See if we can determine the number of arguments from the result.
12383  Optional<unsigned> NumExpansions =
12384  getSema().getFullyPackExpandedSize(OutPattern.getArgument());
12385  if (!NumExpansions) {
12386  // No: we must be in an alias template expansion, and we're going to need
12387  // to actually expand the packs.
12388  Result = None;
12389  break;
12390  }
12391 
12392  Result = *Result + *NumExpansions;
12393  }
12394 
12395  // Common case: we could determine the number of expansions without
12396  // substituting.
12397  if (Result)
12398  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
12399  E->getPackLoc(),
12400  E->getRParenLoc(), *Result, None);
12401 
12402  TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
12403  E->getPackLoc());
12404  {
12405  TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
12407  Derived, const TemplateArgument*> PackLocIterator;
12408  if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
12409  PackLocIterator(*this, PackArgs.end()),
12410  TransformedPackArgs, /*Uneval*/true))
12411  return ExprError();
12412  }
12413 
12414  // Check whether we managed to fully-expand the pack.
12415  // FIXME: Is it possible for us to do so and not hit the early exit path?
12417  bool PartialSubstitution = false;
12418  for (auto &Loc : TransformedPackArgs.arguments()) {
12419  Args.push_back(Loc.getArgument());
12420  if (Loc.getArgument().isPackExpansion())
12421  PartialSubstitution = true;
12422  }
12423 
12424  if (PartialSubstitution)
12425  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
12426  E->getPackLoc(),
12427  E->getRParenLoc(), None, Args);
12428 
12429  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
12430  E->getPackLoc(), E->getRParenLoc(),
12431  Args.size(), None);
12432 }
12433 
12434 template<typename Derived>
12435 ExprResult
12438  // Default behavior is to do nothing with this transformation.
12439  return E;
12440 }
12441 
12442 template<typename Derived>
12443 ExprResult
12446  // Default behavior is to do nothing with this transformation.
12447  return E;
12448 }
12449 
12450 template<typename Derived>
12451 ExprResult
12453  // Default behavior is to do nothing with this transformation.
12454  return E;
12455 }
12456 
12457 template<typename Derived>
12458 ExprResult
12461  return getDerived().TransformExpr(E->getSubExpr());
12462 }
12463 
12464 template<typename Derived>
12465 ExprResult
12467  Expr *Pattern = E->getPattern();
12468 
12470  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
12471  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
12472 
12473  // Determine whether the set of unexpanded parameter packs can and should
12474  // be expanded.
12475  bool Expand = true;
12476  bool RetainExpansion = false;
12477  Optional<unsigned> OrigNumExpansions = E->getNumExpansions(),
12478  NumExpansions = OrigNumExpansions;
12479  if (getDerived().TryExpandParameterPacks(E->getEllipsisLoc(),
12480  Pattern->getSourceRange(),
12481  Unexpanded,
12482  Expand, RetainExpansion,
12483  NumExpansions))
12484  return true;
12485 
12486  if (!Expand) {
12487  // Do not expand any packs here, just transform and rebuild a fold
12488  // expression.
12489  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
12490 
12491  ExprResult LHS =
12492  E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
12493  if (LHS.isInvalid())
12494  return true;
12495 
12496  ExprResult RHS =
12497  E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
12498  if (RHS.isInvalid())
12499  return true;
12500 
12501  if (!getDerived().AlwaysRebuild() &&
12502  LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
12503  return E;
12504 
12505  return getDerived().RebuildCXXFoldExpr(
12506  E->getBeginLoc(), LHS.get(), E->getOperator(), E->getEllipsisLoc(),
12507  RHS.get(), E->getEndLoc(), NumExpansions);
12508  }
12509 
12510  // The transform has determined that we should perform an elementwise
12511  // expansion of the pattern. Do so.
12512  ExprResult Result = getDerived().TransformExpr(E->getInit());
12513  if (Result.isInvalid())
12514  return true;
12515  bool LeftFold = E->isLeftFold();
12516 
12517  // If we're retaining an expansion for a right fold, it is the innermost
12518  // component and takes the init (if any).
12519  if (!LeftFold && RetainExpansion) {
12520  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
12521 
12522  ExprResult Out = getDerived().TransformExpr(Pattern);
12523  if (Out.isInvalid())
12524  return true;
12525 
12526  Result = getDerived().RebuildCXXFoldExpr(
12527  E->getBeginLoc(), Out.get(), E->getOperator(), E->getEllipsisLoc(),
12528  Result.get(), E->getEndLoc(), OrigNumExpansions);
12529  if (Result.isInvalid())
12530  return true;
12531  }
12532 
12533  for (unsigned I = 0; I != *NumExpansions; ++I) {
12535  getSema(), LeftFold ? I : *NumExpansions - I - 1);
12536  ExprResult Out = getDerived().TransformExpr(Pattern);
12537  if (Out.isInvalid())
12538  return true;
12539 
12540  if (Out.get()->containsUnexpandedParameterPack()) {
12541  // We still have a pack; retain a pack expansion for this slice.
12542  Result = getDerived().RebuildCXXFoldExpr(
12543  E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
12544  E->getOperator(), E->getEllipsisLoc(),
12545  LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
12546  OrigNumExpansions);
12547  } else if (Result.isUsable()) {
12548  // We've got down to a single element; build a binary operator.
12549  Result = getDerived().RebuildBinaryOperator(
12550  E->getEllipsisLoc(), E->getOperator(),
12551  LeftFold ? Result.get() : Out.get(),
12552  LeftFold ? Out.get() : Result.get());
12553  } else
12554  Result = Out;
12555 
12556  if (Result.isInvalid())
12557  return true;
12558  }
12559 
12560  // If we're retaining an expansion for a left fold, it is the outermost
12561  // component and takes the complete expansion so far as its init (if any).
12562  if (LeftFold && RetainExpansion) {
12563  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
12564 
12565  ExprResult Out = getDerived().TransformExpr(Pattern);
12566  if (Out.isInvalid())
12567  return true;
12568 
12569  Result = getDerived().RebuildCXXFoldExpr(
12570  E->getBeginLoc(), Result.get(), E->getOperator(), E->getEllipsisLoc(),
12571  Out.get(), E->getEndLoc(), OrigNumExpansions);
12572  if (Result.isInvalid())
12573  return true;
12574  }
12575 
12576  // If we had no init and an empty pack, and we're not retaining an expansion,
12577  // then produce a fallback value or error.
12578  if (Result.isUnset())
12579  return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
12580  E->getOperator());
12581 
12582  return Result;
12583 }
12584 
12585 template<typename Derived>
12586 ExprResult
12589  return getDerived().TransformExpr(E->getSubExpr());
12590 }
12591 
12592 template<typename Derived>
12593 ExprResult
12595  return SemaRef.MaybeBindToTemporary(E);
12596 }
12597 
12598 template<typename Derived>
12599 ExprResult
12601  return E;
12602 }
12603 
12604 template<typename Derived>
12605 ExprResult
12607  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
12608  if (SubExpr.isInvalid())
12609  return ExprError();
12610 
12611  if (!getDerived().AlwaysRebuild() &&
12612  SubExpr.get() == E->getSubExpr())
12613  return E;
12614 
12615  return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
12616 }
12617 
12618 template<typename Derived>
12619 ExprResult
12621  // Transform each of the elements.
12622  SmallVector<Expr *, 8> Elements;
12623  bool ArgChanged = false;
12624  if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
12625  /*IsCall=*/false, Elements, &ArgChanged))
12626  return ExprError();
12627 
12628  if (!getDerived().AlwaysRebuild() && !ArgChanged)
12629  return SemaRef.MaybeBindToTemporary(E);
12630 
12631  return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
12632  Elements.data(),
12633  Elements.size());
12634 }
12635 
12636 template<typename Derived>
12637 ExprResult
12639  ObjCDictionaryLiteral *E) {
12640  // Transform each of the elements.
12642  bool ArgChanged = false;
12643  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
12644  ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
12645 
12646  if (OrigElement.isPackExpansion()) {
12647  // This key/value element is a pack expansion.
12649  getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
12650  getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
12651  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
12652 
12653  // Determine whether the set of unexpanded parameter packs can
12654  // and should be expanded.
12655  bool Expand = true;
12656  bool RetainExpansion = false;
12657  Optional<unsigned> OrigNumExpansions = OrigElement.NumExpansions;
12658  Optional<unsigned> NumExpansions = OrigNumExpansions;
12659  SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
12660  OrigElement.Value->getEndLoc());
12661  if (getDerived().TryExpandParameterPacks(OrigElement.EllipsisLoc,
12662  PatternRange, Unexpanded, Expand,
12663  RetainExpansion, NumExpansions))
12664  return ExprError();
12665 
12666  if (!Expand) {
12667  // The transform has determined that we should perform a simple
12668  // transformation on the pack expansion, producing another pack
12669  // expansion.
12670  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
12671  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
12672  if (Key.isInvalid())
12673  return ExprError();
12674 
12675  if (Key.get() != OrigElement.Key)
12676  ArgChanged = true;
12677 
12678  ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
12679  if (Value.isInvalid())
12680  return ExprError();
12681 
12682  if (Value.get() != OrigElement.Value)
12683  ArgChanged = true;
12684 
12685  ObjCDictionaryElement Expansion = {
12686  Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
12687  };
12688  Elements.push_back(Expansion);
12689  continue;
12690  }
12691 
12692  // Record right away that the argument was changed. This needs
12693  // to happen even if the array expands to nothing.
12694  ArgChanged = true;
12695 
12696  // The transform has determined that we should perform an elementwise
12697  // expansion of the pattern. Do so.
12698  for (unsigned I = 0; I != *NumExpansions; ++I) {
12699  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
12700  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
12701  if (Key.isInvalid())
12702  return ExprError();
12703 
12704  ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
12705  if (Value.isInvalid())
12706  return ExprError();
12707 
12708  ObjCDictionaryElement Element = {
12709  Key.get(), Value.get(), SourceLocation(), NumExpansions
12710  };
12711 
12712  // If any unexpanded parameter packs remain, we still have a
12713  // pack expansion.
12714  // FIXME: Can this really happen?
12715  if (Key.get()->containsUnexpandedParameterPack() ||
12716  Value.get()->containsUnexpandedParameterPack())
12717  Element.EllipsisLoc = OrigElement.EllipsisLoc;
12718 
12719  Elements.push_back(Element);
12720  }
12721 
12722  // FIXME: Retain a pack expansion if RetainExpansion is true.
12723 
12724  // We've finished with this pack expansion.
12725  continue;
12726  }
12727 
12728  // Transform and check key.
12729  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
12730  if (Key.isInvalid())
12731  return ExprError();
12732 
12733  if (Key.get() != OrigElement.Key)
12734  ArgChanged = true;
12735 
12736  // Transform and check value.
12738  = getDerived().TransformExpr(OrigElement.Value);
12739  if (Value.isInvalid())
12740  return ExprError();
12741 
12742  if (Value.get() != OrigElement.Value)
12743  ArgChanged = true;
12744 
12745  ObjCDictionaryElement Element = {
12746  Key.get(), Value.get(), SourceLocation(), None
12747  };
12748  Elements.push_back(Element);
12749  }
12750 
12751  if (!getDerived().AlwaysRebuild() && !ArgChanged)
12752  return SemaRef.MaybeBindToTemporary(E);
12753 
12754  return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
12755  Elements);
12756 }
12757 
12758 template<typename Derived>
12759 ExprResult
12761  TypeSourceInfo *EncodedTypeInfo
12762  = getDerived().TransformType(E->getEncodedTypeSourceInfo());
12763  if (!EncodedTypeInfo)
12764  return ExprError();
12765 
12766  if (!getDerived().AlwaysRebuild() &&
12767  EncodedTypeInfo == E->getEncodedTypeSourceInfo())
12768  return E;
12769 
12770  return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
12771  EncodedTypeInfo,
12772  E->getRParenLoc());
12773 }
12774 
12775 template<typename Derived>
12778  // This is a kind of implicit conversion, and it needs to get dropped
12779  // and recomputed for the same general reasons that ImplicitCastExprs
12780  // do, as well a more specific one: this expression is only valid when
12781  // it appears *immediately* as an argument expression.
12782  return getDerived().TransformExpr(E->getSubExpr());
12783 }
12784 
12785 template<typename Derived>
12788  TypeSourceInfo *TSInfo
12789  = getDerived().TransformType(E->getTypeInfoAsWritten());
12790  if (!TSInfo)
12791  return ExprError();
12792 
12793  ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
12794  if (Result.isInvalid())
12795  return ExprError();
12796 
12797  if (!getDerived().AlwaysRebuild() &&
12798  TSInfo == E->getTypeInfoAsWritten() &&
12799  Result.get() == E->getSubExpr())
12800  return E;
12801 
12802  return SemaRef.BuildObjCBridgedCast(E->getLParenLoc(), E->getBridgeKind(),
12803  E->getBridgeKeywordLoc(), TSInfo,
12804  Result.get());
12805 }
12806 
12807 template <typename Derived>
12810  return E;
12811 }
12812 
12813 template<typename Derived>
12814 ExprResult
12816  // Transform arguments.
12817  bool ArgChanged = false;
12818  SmallVector<Expr*, 8> Args;
12819  Args.reserve(E->getNumArgs());
12820  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
12821  &ArgChanged))
12822  return ExprError();
12823 
12824  if (E->getReceiverKind() == ObjCMessageExpr::Class) {
12825  // Class message: transform the receiver type.
12826  TypeSourceInfo *ReceiverTypeInfo
12827  = getDerived().TransformType(E->getClassReceiverTypeInfo());
12828  if (!ReceiverTypeInfo)
12829  return ExprError();
12830 
12831  // If nothing changed, just retain the existing message send.
12832  if (!getDerived().AlwaysRebuild() &&
12833  ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
12834  return SemaRef.MaybeBindToTemporary(E);
12835 
12836  // Build a new class message send.
12838  E->getSelectorLocs(SelLocs);
12839  return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
12840  E->getSelector(),
12841  SelLocs,
12842  E->getMethodDecl(),
12843  E->getLeftLoc(),
12844  Args,
12845  E->getRightLoc());
12846  }
12847  else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
12848  E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
12849  if (!E->getMethodDecl())
12850  return ExprError();
12851 
12852  // Build a new class message send to 'super'.
12854  E->getSelectorLocs(SelLocs);
12855  return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
12856  E->getSelector(),
12857  SelLocs,
12858  E->getReceiverType(),
12859  E->getMethodDecl(),
12860  E->getLeftLoc(),
12861  Args,
12862  E->getRightLoc());
12863  }
12864 
12865  // Instance message: transform the receiver
12866  assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
12867  "Only class and instance messages may be instantiated");
12868  ExprResult Receiver
12869  = getDerived().TransformExpr(E->getInstanceReceiver());
12870  if (Receiver.isInvalid())
12871  return ExprError();
12872 
12873  // If nothing changed, just retain the existing message send.
12874  if (!getDerived().AlwaysRebuild() &&
12875  Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
12876  return SemaRef.MaybeBindToTemporary(E);
12877 
12878  // Build a new instance message send.
12880  E->getSelectorLocs(SelLocs);
12881  return getDerived().RebuildObjCMessageExpr(Receiver.get(),
12882  E->getSelector(),
12883  SelLocs,
12884  E->getMethodDecl(),
12885  E->getLeftLoc(),
12886  Args,
12887  E->getRightLoc());
12888 }
12889 
12890 template<typename Derived>
12891 ExprResult
12893  return E;
12894 }
12895 
12896 template<typename Derived>
12897 ExprResult
12899  return E;
12900 }
12901 
12902 template<typename Derived>
12903 ExprResult
12905  // Transform the base expression.
12906  ExprResult Base = getDerived().TransformExpr(E->getBase());
12907  if (Base.isInvalid())
12908  return ExprError();
12909 
12910  // We don't need to transform the ivar; it will never change.
12911 
12912  // If nothing changed, just retain the existing expression.
12913  if (!getDerived().AlwaysRebuild() &&
12914  Base.get() == E->getBase())
12915  return E;
12916 
12917  return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
12918  E->getLocation(),
12919  E->isArrow(), E->isFreeIvar());
12920 }
12921 
12922 template<typename Derived>
12923 ExprResult
12925  // 'super' and types never change. Property never changes. Just
12926  // retain the existing expression.
12927  if (!E->isObjectReceiver())
12928  return E;
12929 
12930  // Transform the base expression.
12931  ExprResult Base = getDerived().TransformExpr(E->getBase());
12932  if (Base.isInvalid())
12933  return ExprError();
12934 
12935  // We don't need to transform the property; it will never change.
12936 
12937  // If nothing changed, just retain the existing expression.
12938  if (!getDerived().AlwaysRebuild() &&
12939  Base.get() == E->getBase())
12940  return E;
12941 
12942  if (E->isExplicitProperty())
12943  return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
12944  E->getExplicitProperty(),
12945  E->getLocation());
12946 
12947  return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
12948  SemaRef.Context.PseudoObjectTy,
12951  E->getLocation());
12952 }
12953 
12954 template<typename Derived>
12955 ExprResult
12957  // Transform the base expression.
12958  ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
12959  if (Base.isInvalid())
12960  return ExprError();
12961 
12962  // Transform the key expression.
12963  ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
12964  if (Key.isInvalid())
12965  return ExprError();
12966 
12967  // If nothing changed, just retain the existing expression.
12968  if (!getDerived().AlwaysRebuild() &&
12969  Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
12970  return E;
12971 
12972  return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
12973  Base.get(), Key.get(),
12974  E->getAtIndexMethodDecl(),
12975  E->setAtIndexMethodDecl());
12976 }
12977 
12978 template<typename Derived>
12979 ExprResult
12981  // Transform the base expression.
12982  ExprResult Base = getDerived().TransformExpr(E->getBase());
12983  if (Base.isInvalid())
12984  return ExprError();
12985 
12986  // If nothing changed, just retain the existing expression.
12987  if (!getDerived().AlwaysRebuild() &&
12988  Base.get() == E->getBase())
12989  return E;
12990 
12991  return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
12992  E->getOpLoc(),
12993  E->isArrow());
12994 }
12995 
12996 template<typename Derived>
12997 ExprResult
12999  bool ArgumentChanged = false;
13000  SmallVector<Expr*, 8> SubExprs;
13001  SubExprs.reserve(E->getNumSubExprs());
13002  if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
13003  SubExprs, &ArgumentChanged))
13004  return ExprError();
13005 
13006  if (!getDerived().AlwaysRebuild() &&
13007  !ArgumentChanged)
13008  return E;
13009 
13010  return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
13011  SubExprs,
13012  E->getRParenLoc());
13013 }
13014 
13015 template<typename Derived>
13016 ExprResult
13018  ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
13019  if (SrcExpr.isInvalid())
13020  return ExprError();
13021 
13022  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
13023  if (!Type)
13024  return ExprError();
13025 
13026  if (!getDerived().AlwaysRebuild() &&
13027  Type == E->getTypeSourceInfo() &&
13028  SrcExpr.get() == E->getSrcExpr())
13029  return E;
13030 
13031  return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
13032  SrcExpr.get(), Type,
13033  E->getRParenLoc());
13034 }
13035 
13036 template<typename Derived>
13037 ExprResult
13039  BlockDecl *oldBlock = E->getBlockDecl();
13040 
13041  SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
13042  BlockScopeInfo *blockScope = SemaRef.getCurBlock();
13043 
13044  blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
13045  blockScope->TheDecl->setBlockMissingReturnType(
13046  oldBlock->blockMissingReturnType());
13047 
13049  SmallVector<QualType, 4> paramTypes;
13050 
13051  const FunctionProtoType *exprFunctionType = E->getFunctionType();
13052 
13053  // Parameter substitution.
13054  Sema::ExtParameterInfoBuilder extParamInfos;
13055  if (getDerived().TransformFunctionTypeParams(
13056  E->getCaretLocation(), oldBlock->parameters(), nullptr,
13057  exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
13058  extParamInfos)) {
13059  getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
13060  return ExprError();
13061  }
13062 
13063  QualType exprResultType =
13064  getDerived().TransformType(exprFunctionType->getReturnType());
13065 
13066  auto epi = exprFunctionType->getExtProtoInfo();
13067  epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
13068 
13070  getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
13071  blockScope->FunctionType = functionType;
13072 
13073  // Set the parameters on the block decl.
13074  if (!params.empty())
13075  blockScope->TheDecl->setParams(params);
13076 
13077  if (!oldBlock->blockMissingReturnType()) {
13078  blockScope->HasImplicitReturnType = false;
13079  blockScope->ReturnType = exprResultType;
13080  }
13081 
13082  // Transform the body
13083  StmtResult body = getDerived().TransformStmt(E->getBody());
13084  if (body.isInvalid()) {
13085  getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
13086  return ExprError();
13087  }
13088 
13089 #ifndef NDEBUG
13090  // In builds with assertions, make sure that we captured everything we
13091  // captured before.
13092  if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
13093  for (const auto &I : oldBlock->captures()) {
13094  VarDecl *oldCapture = I.getVariable();
13095 
13096  // Ignore parameter packs.
13097  if (oldCapture->isParameterPack())
13098  continue;
13099 
13100  VarDecl *newCapture =
13101  cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
13102  oldCapture));
13103  assert(blockScope->CaptureMap.count(newCapture));
13104  }
13105  assert(oldBlock->capturesCXXThis() == blockScope->isCXXThisCaptured());
13106  }
13107 #endif
13108 
13109  return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
13110  /*Scope=*/nullptr);
13111 }
13112 
13113 template<typename Derived>
13114 ExprResult
13116  llvm_unreachable("Cannot transform asType expressions yet");
13117 }
13118 
13119 template<typename Derived>
13120 ExprResult
13122  bool ArgumentChanged = false;
13123  SmallVector<Expr*, 8> SubExprs;
13124  SubExprs.reserve(E->getNumSubExprs());
13125  if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
13126  SubExprs, &ArgumentChanged))
13127  return ExprError();
13128 
13129  if (!getDerived().AlwaysRebuild() &&
13130  !ArgumentChanged)
13131  return E;
13132 
13133  return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
13134  E->getOp(), E->getRParenLoc());
13135 }
13136 
13137 //===----------------------------------------------------------------------===//
13138 // Type reconstruction
13139 //===----------------------------------------------------------------------===//
13140 
13141 template<typename Derived>
13143  SourceLocation Star) {
13144  return SemaRef.BuildPointerType(PointeeType, Star,
13145  getDerived().getBaseEntity());
13146 }
13147 
13148 template<typename Derived>
13150  SourceLocation Star) {
13151  return SemaRef.BuildBlockPointerType(PointeeType, Star,
13152  getDerived().getBaseEntity());
13153 }
13154 
13155 template<typename Derived>
13156 QualType
13158  bool WrittenAsLValue,
13159  SourceLocation Sigil) {
13160  return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
13161  Sigil, getDerived().getBaseEntity());
13162 }
13163 
13164 template<typename Derived>
13165 QualType
13167  QualType ClassType,
13168  SourceLocation Sigil) {
13169  return SemaRef.BuildMemberPointerType(PointeeType, ClassType, Sigil,
13170  getDerived().getBaseEntity());
13171 }
13172 
13173 template<typename Derived>
13175  const ObjCTypeParamDecl *Decl,
13176  SourceLocation ProtocolLAngleLoc,
13177  ArrayRef<ObjCProtocolDecl *> Protocols,
13178  ArrayRef<SourceLocation> ProtocolLocs,
13179  SourceLocation ProtocolRAngleLoc) {
13180  return SemaRef.BuildObjCTypeParamType(Decl,
13181  ProtocolLAngleLoc, Protocols,
13182  ProtocolLocs, ProtocolRAngleLoc,
13183  /*FailOnError=*/true);
13184 }
13185 
13186 template<typename Derived>
13188  QualType BaseType,
13189  SourceLocation Loc,
13190  SourceLocation TypeArgsLAngleLoc,
13191  ArrayRef<TypeSourceInfo *> TypeArgs,
13192  SourceLocation TypeArgsRAngleLoc,
13193  SourceLocation ProtocolLAngleLoc,
13194  ArrayRef<ObjCProtocolDecl *> Protocols,
13195  ArrayRef<SourceLocation> ProtocolLocs,
13196  SourceLocation ProtocolRAngleLoc) {
13197  return SemaRef.BuildObjCObjectType(BaseType, Loc, TypeArgsLAngleLoc,
13198  TypeArgs, TypeArgsRAngleLoc,
13199  ProtocolLAngleLoc, Protocols, ProtocolLocs,
13200  ProtocolRAngleLoc,
13201  /*FailOnError=*/true);
13202 }
13203 
13204 template<typename Derived>
13206  QualType PointeeType,
13207  SourceLocation Star) {
13208  return SemaRef.Context.getObjCObjectPointerType(PointeeType);
13209 }
13210 
13211 template<typename Derived>
13212 QualType
13215  const llvm::APInt *Size,
13216  Expr *SizeExpr,
13217  unsigned IndexTypeQuals,
13218  SourceRange BracketsRange) {
13219  if (SizeExpr || !Size)
13220  return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
13221  IndexTypeQuals, BracketsRange,
13222  getDerived().getBaseEntity());
13223 
13224  QualType Types[] = {
13225  SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
13226  SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
13227  SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
13228  };
13229  const unsigned NumTypes = llvm::array_lengthof(Types);
13230  QualType SizeType;
13231  for (unsigned I = 0; I != NumTypes; ++I)
13232  if (Size->getBitWidth() == SemaRef.Context.getIntWidth(Types[I])) {
13233  SizeType = Types[I];
13234  break;
13235  }
13236 
13237  // Note that we can return a VariableArrayType here in the case where
13238  // the element type was a dependent VariableArrayType.
13239  IntegerLiteral *ArraySize
13240  = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
13241  /*FIXME*/BracketsRange.getBegin());
13242  return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
13243  IndexTypeQuals, BracketsRange,
13244  getDerived().getBaseEntity());
13245 }
13246 
13247 template<typename Derived>
13248 QualType
13251  const llvm::APInt &Size,
13252  Expr *SizeExpr,
13253  unsigned IndexTypeQuals,
13254  SourceRange BracketsRange) {
13255  return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
13256  IndexTypeQuals, BracketsRange);
13257 }
13258 
13259 template<typename Derived>
13260 QualType
13263  unsigned IndexTypeQuals,
13264  SourceRange BracketsRange) {
13265  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
13266  IndexTypeQuals, BracketsRange);
13267 }
13268 
13269 template<typename Derived>
13270 QualType
13273  Expr *SizeExpr,
13274  unsigned IndexTypeQuals,
13275  SourceRange BracketsRange) {
13276  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
13277  SizeExpr,
13278  IndexTypeQuals, BracketsRange);
13279 }
13280 
13281 template<typename Derived>
13282 QualType
13285  Expr *SizeExpr,
13286  unsigned IndexTypeQuals,
13287  SourceRange BracketsRange) {
13288  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
13289  SizeExpr,
13290  IndexTypeQuals, BracketsRange);
13291 }
13292 
13293 template <typename Derived>
13295  QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
13296  return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
13297  AttributeLoc);
13298 }
13299 
13300 template <typename Derived>
13301 QualType
13303  unsigned NumElements,
13304  VectorType::VectorKind VecKind) {
13305  // FIXME: semantic checking!
13306  return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
13307 }
13308 
13309 template <typename Derived>
13311  QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
13312  VectorType::VectorKind VecKind) {
13313  return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
13314 }
13315 
13316 template<typename Derived>
13318  unsigned NumElements,
13319  SourceLocation AttributeLoc) {
13320  llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
13321  NumElements, true);
13322  IntegerLiteral *VectorSize
13323  = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
13324  AttributeLoc);
13325  return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
13326 }
13327 
13328 template<typename Derived>
13329 QualType
13331  Expr *SizeExpr,
13332  SourceLocation AttributeLoc) {
13333  return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
13334 }
13335 
13336 template<typename Derived>
13338  QualType T,
13339  MutableArrayRef<QualType> ParamTypes,
13340  const FunctionProtoType::ExtProtoInfo &EPI) {
13341  return SemaRef.BuildFunctionType(T, ParamTypes,
13342  getDerived().getBaseLocation(),
13343  getDerived().getBaseEntity(),
13344  EPI);
13345 }
13346 
13347 template<typename Derived>
13349  return SemaRef.Context.getFunctionNoProtoType(T);
13350 }
13351 
13352 template<typename Derived>
13354  Decl *D) {
13355  assert(D && "no decl found");
13356  if (D->isInvalidDecl()) return QualType();
13357 
13358  // FIXME: Doesn't account for ObjCInterfaceDecl!
13359  TypeDecl *Ty;
13360  if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
13361  // A valid resolved using typename pack expansion decl can have multiple
13362  // UsingDecls, but they must each have exactly one type, and it must be
13363  // the same type in every case. But we must have at least one expansion!
13364  if (UPD->expansions().empty()) {
13365  getSema().Diag(Loc, diag::err_using_pack_expansion_empty)
13366  << UPD->isCXXClassMember() << UPD;
13367  return QualType();
13368  }
13369 
13370  // We might still have some unresolved types. Try to pick a resolved type
13371  // if we can. The final instantiation will check that the remaining
13372  // unresolved types instantiate to the type we pick.
13373  QualType FallbackT;
13374  QualType T;
13375  for (auto *E : UPD->expansions()) {
13376  QualType ThisT = RebuildUnresolvedUsingType(Loc, E);
13377  if (ThisT.isNull())
13378  continue;
13379  else if (ThisT->getAs<UnresolvedUsingType>())
13380  FallbackT = ThisT;
13381  else if (T.isNull())
13382  T = ThisT;
13383  else
13384  assert(getSema().Context.hasSameType(ThisT, T) &&
13385  "mismatched resolved types in using pack expansion");
13386  }
13387  return T.isNull() ? FallbackT : T;
13388  } else if (auto *Using = dyn_cast<UsingDecl>(D)) {
13389  assert(Using->hasTypename() &&
13390  "UnresolvedUsingTypenameDecl transformed to non-typename using");
13391 
13392  // A valid resolved using typename decl points to exactly one type decl.
13393  assert(++Using->shadow_begin() == Using->shadow_end());
13394  Ty = cast<TypeDecl>((*Using->shadow_begin())->getTargetDecl());
13395  } else {
13396  assert(isa<UnresolvedUsingTypenameDecl>(D) &&
13397  "UnresolvedUsingTypenameDecl transformed to non-using decl");
13398  Ty = cast<UnresolvedUsingTypenameDecl>(D);
13399  }
13400 
13401  return SemaRef.Context.getTypeDeclType(Ty);
13402 }
13403 
13404 template<typename Derived>
13406  SourceLocation Loc) {
13407  return SemaRef.BuildTypeofExprType(E, Loc);
13408 }
13409 
13410 template<typename Derived>
13412  return SemaRef.Context.getTypeOfType(Underlying);
13413 }
13414 
13415 template<typename Derived>
13417  SourceLocation Loc) {
13418  return SemaRef.BuildDecltypeType(E, Loc);
13419 }
13420 
13421 template<typename Derived>
13424  SourceLocation Loc) {
13425  return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
13426 }
13427 
13428 template<typename Derived>
13430  TemplateName Template,
13431  SourceLocation TemplateNameLoc,
13432  TemplateArgumentListInfo &TemplateArgs) {
13433  return SemaRef.CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
13434 }
13435 
13436 template<typename Derived>
13438  SourceLocation KWLoc) {
13439  return SemaRef.BuildAtomicType(ValueType, KWLoc);
13440 }
13441 
13442 template<typename Derived>
13444  SourceLocation KWLoc,
13445  bool isReadPipe) {
13446  return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
13447  : SemaRef.BuildWritePipeType(ValueType, KWLoc);
13448 }
13449 
13450 template<typename Derived>
13453  bool TemplateKW,
13454  TemplateDecl *Template) {
13455  return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
13456  Template);
13457 }
13458 
13459 template<typename Derived>
13462  SourceLocation TemplateKWLoc,
13463  const IdentifierInfo &Name,
13464  SourceLocation NameLoc,
13465  QualType ObjectType,
13466  NamedDecl *FirstQualifierInScope,
13467  bool AllowInjectedClassName) {
13469  TemplateName.setIdentifier(&Name, NameLoc);
13470  Sema::TemplateTy Template;
13471  getSema().ActOnDependentTemplateName(/*Scope=*/nullptr,
13472  SS, TemplateKWLoc, TemplateName,
13473  ParsedType::make(ObjectType),
13474  /*EnteringContext=*/false,
13475  Template, AllowInjectedClassName);
13476  return Template.get();
13477 }
13478 
13479 template<typename Derived>
13482  SourceLocation TemplateKWLoc,
13483  OverloadedOperatorKind Operator,
13484  SourceLocation NameLoc,
13485  QualType ObjectType,
13486  bool AllowInjectedClassName) {
13487  UnqualifiedId Name;
13488  // FIXME: Bogus location information.
13489  SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
13490  Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
13491  Sema::TemplateTy Template;
13492  getSema().ActOnDependentTemplateName(/*Scope=*/nullptr,
13493  SS, TemplateKWLoc, Name,
13494  ParsedType::make(ObjectType),
13495  /*EnteringContext=*/false,
13496  Template, AllowInjectedClassName);
13497  return Template.get();
13498 }
13499 
13500 template<typename Derived>
13501 ExprResult
13503  SourceLocation OpLoc,
13504  Expr *OrigCallee,
13505  Expr *First,
13506  Expr *Second) {
13507  Expr *Callee = OrigCallee->IgnoreParenCasts();
13508  bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
13509 
13510  if (First->getObjectKind() == OK_ObjCProperty) {
13511  BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
13512  if (BinaryOperator::isAssignmentOp(Opc))
13513  return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc, Opc,
13514  First, Second);
13515  ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
13516  if (Result.isInvalid())
13517  return ExprError();
13518  First = Result.get();
13519  }
13520 
13521  if (Second && Second->getObjectKind() == OK_ObjCProperty) {
13522  ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
13523  if (Result.isInvalid())
13524  return ExprError();
13525  Second = Result.get();
13526  }
13527 
13528  // Determine whether this should be a builtin operation.
13529  if (Op == OO_Subscript) {
13530  if (!First->getType()->isOverloadableType() &&
13531  !Second->getType()->isOverloadableType())
13532  return getSema().CreateBuiltinArraySubscriptExpr(
13533  First, Callee->getBeginLoc(), Second, OpLoc);
13534  } else if (Op == OO_Arrow) {
13535  // -> is never a builtin operation.
13536  return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
13537  } else if (Second == nullptr || isPostIncDec) {
13538  if (!First->getType()->isOverloadableType() ||
13539  (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
13540  // The argument is not of overloadable type, or this is an expression
13541  // of the form &Class::member, so try to create a built-in unary
13542  // operation.
13543  UnaryOperatorKind Opc
13544  = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
13545 
13546  return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
13547  }
13548  } else {
13549  if (!First->getType()->isOverloadableType() &&
13550  !Second->getType()->isOverloadableType()) {
13551  // Neither of the arguments is an overloadable type, so try to
13552  // create a built-in binary operation.
13553  BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
13554  ExprResult Result
13555  = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
13556  if (Result.isInvalid())
13557  return ExprError();
13558 
13559  return Result;
13560  }
13561  }
13562 
13563  // Compute the transformed set of functions (and function templates) to be
13564  // used during overload resolution.
13565  UnresolvedSet<16> Functions;
13566  bool RequiresADL;
13567 
13568  if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
13569  Functions.append(ULE->decls_begin(), ULE->decls_end());
13570  // If the overload could not be resolved in the template definition
13571  // (because we had a dependent argument), ADL is performed as part of
13572  // template instantiation.
13573  RequiresADL = ULE->requiresADL();
13574  } else {
13575  // If we've resolved this to a particular non-member function, just call
13576  // that function. If we resolved it to a member function,
13577  // CreateOverloaded* will find that function for us.
13578  NamedDecl *ND = cast<DeclRefExpr>(Callee)->getDecl();
13579  if (!isa<CXXMethodDecl>(ND))
13580  Functions.addDecl(ND);
13581  RequiresADL = false;
13582  }
13583 
13584  // Add any functions found via argument-dependent lookup.
13585  Expr *Args[2] = { First, Second };
13586  unsigned NumArgs = 1 + (Second != nullptr);
13587 
13588  // Create the overloaded operator invocation for unary operators.
13589  if (NumArgs == 1 || isPostIncDec) {
13590  UnaryOperatorKind Opc
13591  = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
13592  return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
13593  RequiresADL);
13594  }
13595 
13596  if (Op == OO_Subscript) {
13597  SourceLocation LBrace;
13598  SourceLocation RBrace;
13599 
13600  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Callee)) {
13601  DeclarationNameLoc NameLoc = DRE->getNameInfo().getInfo();
13602  LBrace = SourceLocation::getFromRawEncoding(
13604  RBrace = SourceLocation::getFromRawEncoding(
13605  NameLoc.CXXOperatorName.EndOpNameLoc);
13606  } else {
13607  LBrace = Callee->getBeginLoc();
13608  RBrace = OpLoc;
13609  }
13610 
13611  return SemaRef.CreateOverloadedArraySubscriptExpr(LBrace, RBrace,
13612  First, Second);
13613  }
13614 
13615  // Create the overloaded operator invocation for binary operators.
13616  BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
13617  ExprResult Result = SemaRef.CreateOverloadedBinOp(
13618  OpLoc, Opc, Functions, Args[0], Args[1], RequiresADL);
13619  if (Result.isInvalid())
13620  return ExprError();
13621 
13622  return Result;
13623 }
13624 
13625 template<typename Derived>
13626 ExprResult
13628  SourceLocation OperatorLoc,
13629  bool isArrow,
13630  CXXScopeSpec &SS,
13631  TypeSourceInfo *ScopeType,
13632  SourceLocation CCLoc,
13633  SourceLocation TildeLoc,
13634  PseudoDestructorTypeStorage Destroyed) {
13635  QualType BaseType = Base->getType();
13636  if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
13637  (!isArrow && !BaseType->getAs<RecordType>()) ||
13638  (isArrow && BaseType->getAs<PointerType>() &&
13639  !BaseType->castAs<PointerType>()->getPointeeType()
13640  ->template getAs<RecordType>())){
13641  // This pseudo-destructor expression is still a pseudo-destructor.
13642  return SemaRef.BuildPseudoDestructorExpr(
13643  Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
13644  CCLoc, TildeLoc, Destroyed);
13645  }
13646 
13647  TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
13648  DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
13649  SemaRef.Context.getCanonicalType(DestroyedType->getType())));
13650  DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
13651  NameInfo.setNamedTypeInfo(DestroyedType);
13652 
13653  // The scope type is now known to be a valid nested name specifier
13654  // component. Tack it on to the end of the nested name specifier.
13655  if (ScopeType) {
13656  if (!ScopeType->getType()->getAs<TagType>()) {
13657  getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
13658  diag::err_expected_class_or_namespace)
13659  << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
13660  return ExprError();
13661  }
13662  SS.Extend(SemaRef.Context, SourceLocation(), ScopeType->getTypeLoc(),
13663  CCLoc);
13664  }
13665 
13666  SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
13667  return getSema().BuildMemberReferenceExpr(Base, BaseType,
13668  OperatorLoc, isArrow,
13669  SS, TemplateKWLoc,
13670  /*FIXME: FirstQualifier*/ nullptr,
13671  NameInfo,
13672  /*TemplateArgs*/ nullptr,
13673  /*S*/nullptr);
13674 }
13675 
13676 template<typename Derived>
13677 StmtResult
13679  SourceLocation Loc = S->getBeginLoc();
13680  CapturedDecl *CD = S->getCapturedDecl();
13681  unsigned NumParams = CD->getNumParams();
13682  unsigned ContextParamPos = CD->getContextParamPosition();
13684  for (unsigned I = 0; I < NumParams; ++I) {
13685  if (I != ContextParamPos) {
13686  Params.push_back(
13687  std::make_pair(
13688  CD->getParam(I)->getName(),
13689  getDerived().TransformType(CD->getParam(I)->getType())));
13690  } else {
13691  Params.push_back(std::make_pair(StringRef(), QualType()));
13692  }
13693  }
13694  getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
13695  S->getCapturedRegionKind(), Params);
13696  StmtResult Body;
13697  {
13698  Sema::CompoundScopeRAII CompoundScope(getSema());
13699  Body = getDerived().TransformStmt(S->getCapturedStmt());
13700  }
13701 
13702  if (Body.isInvalid()) {
13703  getSema().ActOnCapturedRegionError();
13704  return StmtError();
13705  }
13706 
13707  return getSema().ActOnCapturedRegionEnd(Body.get());
13708 }
13709 
13710 } // end namespace clang
13711 
13712 #endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
SourceLocation getRParenLoc() const
Definition: Stmt.h:2387
Expr * getInc()
Definition: Stmt.h:2443
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:614
const Expr * getSubExpr() const
Definition: Expr.h:963
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1577
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:78
TemporaryBase(TreeTransform &Self, SourceLocation Location, DeclarationName Entity)
Represents a single C99 designator.
Definition: Expr.h:4714
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: Expr.h:1348
SourceLocation getRBracLoc() const
Definition: Stmt.h:1440
const BlockDecl * getBlockDecl() const
Definition: Expr.h:5593
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3757
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it&#39;s either not been deduced or was deduce...
Definition: Type.h:4859
IdentifierInfo * getInputIdentifier(unsigned i) const
Definition: Stmt.h:2994
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1591
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:5285
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1628
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2361
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:1036
SourceLocation getRParenLoc() const
Definition: Stmt.h:2901
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:683
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:2977
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:1115
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:1261
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1986
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:2878
Represents a function declaration or definition.
Definition: Decl.h:1783
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4735
Expr * getArrayIndex(const Designator &D) const
Definition: Expr.cpp:4413
SourceLocation getForLoc() const
Definition: StmtCXX.h:201
SourceRange getExceptionSpecRange() const
Definition: TypeLoc.h:1406
Optional< unsigned > getNumExpansions() const
Definition: ExprCXX.h:4577
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
Definition: Expr.h:1284
helper_expr_const_range reduction_ops() const
This represents &#39;thread_limit&#39; clause in the &#39;#pragma omp ...&#39; directive.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:235
OMPClause * RebuildOMPSharedClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;shared&#39; clause.
Expr ** getArgs()
Retrieve the call arguments.
Definition: Expr.h:2692
Expr * getLHS() const
Definition: Expr.h:3780
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:2995
StringRef Identifier
Definition: Format.cpp:1833
IdentifierInfo * getLabelIdentifier(unsigned i) const
Definition: Stmt.h:3031
unsigned getNumInputs() const
Definition: Stmt.h:2790
SourceLocation getOpLoc() const
Definition: ExprObjC.h:1528
SourceLocation getRParenLoc() const
Definition: Expr.h:2789
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:360
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: Expr.h:1340
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
Definition: Expr.cpp:2375
CompoundStmt * getBlock() const
Definition: Stmt.h:3269
friend bool operator==(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
Smart pointer class that efficiently represents Objective-C method names.
ExprResult RebuildObjCArrayLiteral(SourceRange Range, Expr **Elements, unsigned NumElements)
Build a new Objective-C array literal.
SourceLocation getForLoc() const
Definition: Stmt.h:2456
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; directives.
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:502
PtrTy get() const
Definition: Ownership.h:80
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2614
StmtResult RebuildCaseStmt(SourceLocation CaseLoc, Expr *LHS, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation ColonLoc)
Build a new case statement.
QualType getPointeeType() const
Definition: Type.h:2627
ExprResult RebuildObjCDictionaryLiteral(SourceRange Range, MutableArrayRef< ObjCDictionaryElement > Elements)
Build a new Objective-C dictionary literal.
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into &#39;__super&#39; nested-name-specifier.
Definition: DeclSpec.cpp:106
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
Definition: ExprCXX.h:1248
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
Definition: Type.h:4210
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2428
A (possibly-)qualified type.
Definition: Type.h:654
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:5895
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:1323
ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(type) expression.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:2919
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1302
Derived & getDerived()
Retrieves a reference to the derived class.
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:325
Expr * getCond() const
Definition: Expr.h:4175
llvm::omp::ProcBindKind getProcBindKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:990
QualType TransformType(QualType T)
Transforms the given type into another type.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2702
ObjCMethodDecl * getAtIndexMethodDecl() const
Definition: ExprObjC.h:896
Selector getSelector() const
Definition: ExprObjC.cpp:337
SourceRange getSourceRange() const
Definition: ExprCXX.h:3982
SourceLocation getEllipsisLoc() const
Get the location of the ... in a case statement of the form LHS ... RHS.
Definition: Stmt.h:1575
SourceLocation getLParen() const
Get the location of the left parentheses &#39;(&#39;.
Definition: Expr.h:2018
const Expr * getSubExpr() const
Definition: ExprCXX.h:1162
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition: ExprCXX.cpp:1249
SourceLocation getCommaLoc()
Get location of &#39;,&#39;.
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:409
A requires-expression requirement which queries the validity and properties of an expression (&#39;simple...
Definition: ExprConcepts.h:253
Expr * getCond()
Definition: Stmt.h:2275
TemplateParameterList * GLTemplateParameterList
If this is a generic lambda, and the template parameter list has been created (from the TemplateParam...
Definition: ScopeInfo.h:834
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
ExprResult RebuildRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, ArrayRef< ParmVarDecl *> LocalParameters, ArrayRef< concepts::Requirement *> Requirements, SourceLocation ClosingBraceLoc)
Build a new requires expression.
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
Definition: Expr.h:4033
ExprResult RebuildObjCMessageExpr(TypeSourceInfo *ReceiverTypeInfo, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C class message.
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2627
ArrayRef< ParmVarDecl * > getLocalParameters() const
Definition: ExprConcepts.h:507
unsigned getNumArgs() const
Definition: TypeLoc.h:2014
CompoundStmt * getSubStmt()
Definition: Expr.h:3970
OpenMPDefaultmapClauseKind
OpenMP attributes for &#39;defaultmap&#39; clause.
Definition: OpenMPKinds.h:158
This represents &#39;atomic_default_mem_order&#39; clause in the &#39;#pragma omp requires&#39; directive.
BinaryOperatorKind Opcode
The original opcode, prior to rewriting.
Definition: ExprCXX.h:298
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:3444
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value...
Definition: Expr.h:4335
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2424
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:531
StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt *> Handlers)
Build a new C++ try statement.
StmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Attach the body to the switch statement.
unsigned getNumAsmToks()
Definition: Stmt.h:3131
ExprResult RebuildCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, Optional< unsigned > NumExpansions)
Build a new C++1z fold-expression.
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
Definition: Expr.h:5417
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
Definition: Type.h:4904
Expr * getUnderlyingExpr() const
Definition: Type.h:4380
ExprResult RebuildObjCIsaExpr(Expr *BaseArg, SourceLocation IsaLoc, SourceLocation OpLoc, bool IsArrow)
Build a new Objective-C "isa" expression.
StmtResult RebuildDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation LParenLoc, Expr *Cond, SourceLocation RParenLoc)
Build a new do-while statement.
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2425
const TemplateArgumentLoc * operator->() const
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1398
SourceLocation getRParenLoc() const
Definition: StmtObjC.h:107
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
Definition: ExprCXX.h:2028
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
Attach body to a C++0x range-based for statement.
bool isThrownVariableInScope() const
Determines whether the variable thrown by this expression (if any!) is within the innermost try block...
Definition: ExprCXX.h:1172
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition: Type.h:1413
bool isLeftFold() const
Does this produce a left-associated sequence of operators?
Definition: ExprCXX.h:4566
Represents a &#39;co_return&#39; statement in the C++ Coroutines TS.
Definition: StmtCXX.h:456
Stmt - This represents one statement.
Definition: Stmt.h:66
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: Expr.h:2689
This represents clause &#39;in_reduction&#39; in the &#39;#pragma omp task&#39; directives.
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2762
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
Definition: StmtObjC.h:235
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1592
void setExceptionSpecRange(SourceRange R)
Definition: TypeLoc.h:1412
ExprResult RebuildExpressionTrait(ExpressionTrait Trait, SourceLocation StartLoc, Expr *Queried, SourceLocation RParenLoc)
Build a new expression trait expression.
CXXCatchStmt * getHandler(unsigned i)
Definition: StmtCXX.h:107
ExprResult RebuildArraySubscriptExpr(Expr *LHS, SourceLocation LBracketLoc, Expr *RHS, SourceLocation RBracketLoc)
Build a new array subscript expression.
IfStmt - This represents an if/then/else.
Definition: Stmt.h:1834
ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc, TypeSourceInfo *Type, ArrayRef< Sema::OffsetOfComponent > Components, SourceLocation RParenLoc)
Build a new builtin offsetof expression.
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3225
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition: Expr.h:2302
SourceLocation getRParenLoc() const
Definition: Expr.h:4020
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:557
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3253
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2420
void setConceptNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1976
ObjCMethodDecl * setAtIndexMethodDecl() const
Definition: ExprObjC.h:900
ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc, TypeSourceInfo *EncodeTypeInfo, SourceLocation RParenLoc)
Build a new Objective-C @encode expression.
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
Definition: ScopeInfo.h:659
QualType RebuildEnumType(EnumDecl *Enum)
Build a new Enum type.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1029
unsigned getNumOutputs() const
Definition: Stmt.h:2768
StmtResult RebuildForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *Init, Sema::ConditionResult Cond, Sema::FullExprArg Inc, SourceLocation RParenLoc, Stmt *Body)
Build a new for statement.
ExprResult RebuildObjCSubscriptRefExpr(SourceLocation RB, Expr *Base, Expr *Key, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Represents a qualified type name for which the type name is dependent.
Definition: Type.h:5368
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:832
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1337
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:766
Expr * getAllocator() const
Returns allocator.
Definition: OpenMPClause.h:301
bool isRecordType() const
Definition: Type.h:6594
Expr * getBase() const
Definition: Expr.h:2913
const StringLiteral * getAsmString() const
Definition: Stmt.h:2906
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:3113
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition: Sema.h:1411
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
This represents &#39;grainsize&#39; clause in the &#39;#pragma omp ...&#39; directive.
TemplateParameterList * TransformTemplateParameterList(TemplateParameterList *TPL)
This represents &#39;#pragma omp teams distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:4171
Stmt * getHandlerBlock() const
Definition: StmtCXX.h:51
SourceLocation getBeginLoc() const
Returns starting location of directive kind.
Definition: StmtOpenMP.h:225
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclBase.h:421
ObjCMethodDecl * getImplicitPropertySetter() const
Definition: ExprObjC.h:717
Decl * TransformDefinition(SourceLocation Loc, Decl *D)
Transform the definition of the given declaration.
TreeTransform(Sema &SemaRef)
Initializes a new tree transformer.
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:5082
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:2218
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition: TypeLoc.h:575
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3037
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 &#39;in_reduction&#39; clause.
This represents &#39;if&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:425
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
const Expr * getSubExpr() const
Definition: Expr.h:4262
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we&#39;re testing for, along with location information.
Definition: StmtCXX.h:288
Defines the C++ template declaration subclasses.
Opcode getOpcode() const
Definition: Expr.h:3469
StringRef P
This represents &#39;#pragma omp parallel master&#39; directive.
Definition: StmtOpenMP.h:1863
CapturedStmt * getInnermostCapturedStmt()
Get innermost captured statement for the construct.
Definition: StmtOpenMP.h:283
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:4874
SourceLocation getIdentLoc() const
Definition: Stmt.h:1746
Represents an attribute applied to a statement.
Definition: Stmt.h:1776
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1994
const AstTypeMatcher< FunctionType > functionType
Matches FunctionType nodes.
ExprResult RebuildCXXRewrittenBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opcode, const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS)
Build a new rewritten operator expression.
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
Definition: Expr.h:2933
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
Definition: StmtCXX.h:284
Expr * getLowerBound()
Get lower bound of array section.
Definition: ExprOpenMP.h:90
This represents &#39;priority&#39; clause in the &#39;#pragma omp ...&#39; directive.
The base class of the type hierarchy.
Definition: Type.h:1450
This represents &#39;#pragma omp target teams distribute&#39; combined directive.
Definition: StmtOpenMP.h:4310
Represents Objective-C&#39;s @throw statement.
Definition: StmtObjC.h:332
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called...
Definition: ExprCXX.h:1533
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
Definition: Decl.cpp:4546
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
Definition: Expr.h:1328
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2002
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2244
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2889
Represent a C++ namespace.
Definition: Decl.h:497
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:4766
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1422
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:1251
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:845
Wrapper for source info for typedefs.
Definition: TypeLoc.h:670
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to...
Definition: Expr.h:3355
FPOptions getFPFeatures() const
Definition: Expr.h:3611
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2715
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1162
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:425
bool getIsCXXTry() const
Definition: Stmt.h:3311
SourceLocation getLParenLoc() const
Definition: Expr.h:3397
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:567
std::input_iterator_tag iterator_category
A container of type source information.
Definition: Type.h:6227
This represents &#39;update&#39; clause in the &#39;#pragma omp atomic&#39; directive.
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4583
const Expr * RHS
The original right-hand side.
Definition: ExprCXX.h:302
Wrapper for void* pointer.
Definition: Ownership.h:50
constexpr XRayInstrMask Function
Definition: XRayInstr.h:38
ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ const_cast expression.
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:493
SourceLocation getAttributeLoc() const
Definition: Type.h:3327
This represents &#39;#pragma omp parallel for&#39; directive.
Definition: StmtOpenMP.h:1715
MS property subscript expression.
Definition: ExprCXX.h:937
IdentKind getIdentKind() const
Definition: Expr.h:1951
OMPClause * RebuildOMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;priority&#39; clause.
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2690
SourceLocation getGotoLoc() const
Definition: Stmt.h:2536
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition: DeclSpec.h:221
SourceLocation getOperatorLoc() const
Determine the location of the &#39;sizeof&#39; keyword.
Definition: ExprCXX.h:4153
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:2077
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:4379
Wrapper for source info for pointers decayed from arrays and functions.
Definition: TypeLoc.h:1187
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
OMPClause * RebuildOMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;safelen&#39; clause.
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2383
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
Definition: Lookup.h:554
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4419
OpenMPDefaultmapClauseModifier
OpenMP modifiers for &#39;defaultmap&#39; clause.
Definition: OpenMPKinds.h:166
SourceLocation getAccessorLoc() const
Definition: Expr.h:5543
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:233
Expr * getAlignment()
Returns alignment.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Expr * getNumForLoops() const
Return the number of associated for-loops.
SourceLocation getRParenLoc() const
getRParenLoc - Return the location of final right parenthesis.
Definition: Expr.h:4105
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:228
SourceLocation getSecondScheduleModifierLoc() const
Get the second modifier location.
QualType getElementType() const
Definition: Type.h:2910
concepts::TypeRequirement * RebuildTypeRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag)
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
Definition: Type.h:4958
SourceLocation getCoawaitLoc() const
Definition: StmtCXX.h:202
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:2330
Stmt * getExceptionHandler() const
Definition: StmtCXX.h:396
SourceLocation getEndLoc() const
Returns ending location of directive.
Definition: StmtOpenMP.h:227
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1816
Expr * getDeallocate() const
Definition: StmtCXX.h:406
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2690
Stmt * getSubStmt()
Definition: Stmt.h:1667
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: DeclSpec.cpp:124
SourceLocation getDependencyLoc() const
Get dependency type location.
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
Definition: ExprConcepts.h:381
void setRAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:574
This represents &#39;read&#39; clause in the &#39;#pragma omp atomic&#39; directive.
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2751
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:587
RAII object that enters a new expression evaluation context.
Definition: Sema.h:12029
SourceLocation getExpansionLoc() const
Definition: TypeLoc.h:1093
OMPClause * RebuildOMPDeviceClause(Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;device&#39; clause.
Represents a variable declaration or definition.
Definition: Decl.h:820
ActionResult< Stmt * > StmtResult
Definition: Ownership.h:264
const Derived & getDerived() const
Retrieves a reference to the derived class.
This represents clause &#39;private&#39; in the &#39;#pragma omp ...&#39; directives.
SourceLocation getLParenLoc() const
Definition: Stmt.h:2458
StmtResult RebuildOMPExecutableDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP executable directive.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC &#39;id&#39; type.
Definition: ExprObjC.h:1492
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1792
OMPClause * RebuildOMPToClause(ArrayRef< Expr *> VarList, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, const OMPVarListLocTy &Locs, ArrayRef< Expr *> UnresolvedMappers)
Build a new OpenMP &#39;to&#39; clause.
void removeObjCLifetime()
Definition: Type.h:339
ExprResult RebuildConditionalOperator(Expr *Cond, SourceLocation QuestionLoc, Expr *LHS, SourceLocation ColonLoc, Expr *RHS)
Build a new conditional operator expression.
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3077
This represents &#39;num_threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:594
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1256
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. ...
bool isEnumeralType() const
Definition: Type.h:6598
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;.&#39; or &#39;->&#39; operator.
Definition: ExprCXX.h:2545
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Definition: TypeLoc.h:277
IdentifierInfo * getIdentifier() const
Definition: ExprCXX.h:2448
UnresolvedLookupExpr * getOperatorCoawaitLookup() const
Definition: ExprCXX.h:4762
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:7002
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition: Type.h:6907
varlist_range varlists()
Definition: OpenMPClause.h:232
bool This(InterpState &S, CodePtr OpPC)
Definition: Interp.h:827
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:5131
Records and restores the FP_CONTRACT state on entry/exit of compound statements.
Definition: Sema.h:1300
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
Definition: ExprCXX.h:2676
Extra information about a function prototype.
Definition: Type.h:3837
This represents &#39;defaultmap&#39; clause in the &#39;#pragma omp ...&#39; directive.
DecomposedForm getDecomposedForm() const LLVM_READONLY
Decompose this operator into its syntactic form.
Definition: ExprCXX.cpp:63
Stmt * getResultDecl() const
Definition: StmtCXX.h:412
ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1229
This represents clauses with a list of expressions that are mappable.
Represents a C++17 deduced template specialization type.
Definition: Type.h:4940
TypeSourceInfo * InventTypeSourceInfo(QualType T)
Fakes up a TypeSourceInfo for a type.
SourceLocation getColonLoc() const
Definition: Expr.h:3722
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
ExprResult RebuildObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *object)
Rebuild the operand to an Objective-C @synchronized statement.
OMPClause * RebuildOMPAlignedClause(ArrayRef< Expr *> VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;aligned&#39; clause.
bool isArrow() const
Definition: ExprObjC.h:1520
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:138
SourceLocation getLeftLoc() const
Definition: ExprObjC.h:1416
OMPClause * RebuildOMPThreadLimitClause(Expr *ThreadLimit, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;thread_limit&#39; clause.
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:990
RAII object used to temporarily allow the C++ &#39;this&#39; expression to be used, with the given qualifiers...
Definition: Sema.h:5616
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:603
SourceLocation getColonLoc() const
Return the location of &#39;:&#39;.
Definition: OpenMPClause.h:490
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:2953
reference front() const
Definition: DeclBase.h:1242
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:715
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2125
bool isInvalidDecl() const
Definition: DeclBase.h:553
Stmt * getThen()
Definition: Stmt.h:1921
SourceLocation getIfLoc() const
Definition: Stmt.h:1993
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1714
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:784
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
unsigned getContextParamPosition() const
Definition: Decl.h:4300
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:2236
TypeSourceInfo * getArgumentTypeInfo() const
Definition: Expr.h:2412
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition: ExprCXX.h:3105
This represents implicit clause &#39;flush&#39; for the &#39;#pragma omp flush&#39; directive.
Defines the Objective-C statement AST node classes.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range that covers this offsetof node.
Definition: Expr.h:2248
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
Definition: ExprCXX.h:1648
CharSourceRange getSourceRange(const SourceRange &Range)
Returns the token CharSourceRange corresponding to Range.
Definition: FixIt.h:32
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1140
Expr * getExprOperand() const
Definition: ExprCXX.h:821
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3306
This represents &#39;reverse_offload&#39; clause in the &#39;#pragma omp requires&#39; directive. ...
bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, unsigned NumInputs, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
TypeSourceInfo * getArg(unsigned I) const
Retrieve the Ith argument.
Definition: ExprCXX.h:2679
ExprResult RebuildParenListExpr(SourceLocation LParenLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new expression list in parentheses.
Expr * getAttrExprOperand() const
The attribute&#39;s expression operand, if it has one.
Definition: TypeLoc.h:1700
Represents a parameter to a function.
Definition: Decl.h:1595
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:160
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4728
TemplateArgumentLocContainerIterator operator++(int)
SourceLocation getRParenLoc() const
Definition: Expr.h:5487
Defines the clang::Expr interface and subclasses for C++ expressions.
bool isUnset() const
Definition: Ownership.h:168
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2105
ExprResult RebuildDesignatedInitExpr(Designation &Desig, MultiExprArg ArrayExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Build a new designated initializer expression.
Expr * getGrainsize() const
Return safe iteration space distance.
This represents &#39;nogroup&#39; clause in the &#39;#pragma omp ...&#39; directive.
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
Definition: TypeLoc.h:513
The collection of all-type qualifiers we support.
Definition: Type.h:143
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1665
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1283
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition: TypeLoc.h:949
This represents &#39;allocator&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:266
SourceLocation getBuiltinLoc() const
Definition: Expr.h:4182
This represents &#39;safelen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:670
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:707
PipeType - OpenCL20.
Definition: Type.h:6159
bool needsExtraLocalData() const
Definition: TypeLoc.h:582
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:409
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:987
ExprResult RebuildCXXNoexceptExpr(SourceRange Range, Expr *Arg)
Build a new noexcept expression.
Expr * getExprOperand() const
Definition: ExprCXX.h:1046
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i.e., if it is any kind of pointer type.
Definition: Type.cpp:3841
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1060
const Stmt * getSubStmt() const
Definition: StmtObjC.h:379
SourceLocation getAttributeLoc() const
Definition: Type.h:3212
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:244
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition: ExprCXX.h:386
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:1732
Represents a struct/union/class.
Definition: Decl.h:3748
A semantic tree transformation that allows one to transform one abstract syntax tree into another...
Definition: TreeTransform.h:99
Represents a C99 designated initializer expression.
Definition: Expr.h:4639
unsigned varlist_size() const
Definition: OpenMPClause.h:229
NamedDecl * getFoundDecl() const
Definition: ASTConcept.h:150
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.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:272
TypeSourceInfo * getEncodedTypeSourceInfo() const
Definition: ExprObjC.h:430
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
Definition: ExprCXX.h:293
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2556
SourceLocation getKeywordLoc() const
Definition: StmtCXX.h:476
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
One of these records is kept for each identifier that is lexed.
Stmt * getBody()
Definition: Stmt.h:2379
void setLocalRangeEnd(SourceLocation L)
Definition: TypeLoc.h:1382
SourceLocation getTildeLoc() const
Retrieve the location of the &#39;~&#39;.
Definition: ExprCXX.h:2563
SourceLocation getRParenLoc() const
Definition: Expr.h:5940
Step
Definition: OpenMPClause.h:151
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(), or __builtin_FILE().
Definition: Expr.h:4295
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:261
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:470
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:357
SourceLocation getBegin() const
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3999
SourceLocation getColonLoc() const
Gets location of &#39;:&#39; symbol in clause.
ExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *SubExpr)
Build a new C-style cast expression.
Represents a class type in Objective C.
Definition: Type.h:5694
SourceLocation getRParen() const
Get the location of the right parentheses &#39;)&#39;.
Definition: Expr.h:2022
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:329
A C++ nested-name-specifier augmented with source location information.
Expr * getInit() const
Retrieve the initializer value.
Definition: Expr.h:4877
StmtResult RebuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Operand)
Build a new Objective-C @throw statement.
Decl * TransformDecl(SourceLocation Loc, Decl *D)
Transform the given declaration, which is referenced from a type or expression.
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:446
ExprResult ExprEmpty()
Definition: Ownership.h:285
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3971
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1195
This represents &#39;simd&#39; clause in the &#39;#pragma omp ...&#39; directive.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
Definition: Type.cpp:4080
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:506
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1142
ConstexprSpecKind getConstexprKind() const
Definition: Decl.h:2206
QualType BuildParenType(QualType T)
Build a paren type including T.
Definition: SemaType.cpp:1892
void setBuiltinLoc(SourceLocation Loc)
Definition: TypeLoc.h:559
void transformAttrs(Decl *Old, Decl *New)
Transform the attributes associated with the given declaration and place them on the new declaration...
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:1608
ExprResult RebuildInitList(SourceLocation LBraceLoc, MultiExprArg Inits, SourceLocation RBraceLoc)
Build a new initializer list expression.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:1865
bool isExplicitProperty() const
Definition: ExprObjC.h:705
bool isSpelledAsLValue() const
Definition: Type.h:2766
SourceLocation getAmpAmpLoc() const
Definition: Expr.h:3924
void setRBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1501
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:275
NameKind getNameKind() const
Determine what kind of name this is.
OpenMPLinearClauseKind
OpenMP attributes for &#39;linear&#39; clause.
Definition: OpenMPKinds.h:110
SourceLocation getEndLoc() const
Definition: Stmt.h:1248
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
Definition: SemaDecl.cpp:14655
Represents a member of a struct/union/class.
Definition: Decl.h:2729
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:5059
This represents clause &#39;lastprivate&#39; in the &#39;#pragma omp ...&#39; directives.
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 RebuildObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @finally statement.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3848
This represents clause &#39;allocate&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:328
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4937
QualType RebuildAutoType(QualType Deduced, AutoTypeKeyword Keyword, ConceptDecl *TypeConstraintConcept, ArrayRef< TemplateArgument > TypeConstraintArgs)
Build a new C++11 auto type.
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:622
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1064
VarDecl * getPromiseDecl() const
Definition: StmtCXX.h:385
ArrayRef< Expr * > getAllExprs() const
Definition: Stmt.h:3177
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1652
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:832
Stmt * getStmtExprResult()
Definition: Stmt.h:1424
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:96
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1307
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:954
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:3126
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition: Expr.h:2221
SourceLocation getLabelLoc() const
Definition: Expr.h:3926
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2159
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition: Expr.h:2980
void StartOpenMPDSABlock(OpenMPDirectiveKind K, const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc)
Called on start of new data sharing attribute block.
Expr * getChunkSize()
Get chunk size.
SourceLocation getRBraceLoc() const
Definition: Expr.h:4552
SourceLocation getOperatorLoc() const
Definition: Expr.h:2439
QualType RebuildParenType(QualType InnerType)
Build a new parenthesized type.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:4210
bool isReferenceType() const
Definition: Type.h:6516
This represents clause &#39;map&#39; in the &#39;#pragma omp ...&#39; directives.
StmtResult RebuildAttributedStmt(SourceLocation AttrLoc, ArrayRef< const Attr *> Attrs, Stmt *SubStmt)
Build a new label statement.
SourceLocation getRParenLoc() const
Definition: Expr.h:3400
SourceLocation getDefaultKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:912
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2155
This represents clause &#39;to&#39; in the &#39;#pragma omp ...&#39; directives.
ExprResult TransformExpr(Expr *E)
Transform the given expression.
SourceLocation getProtocolRAngleLoc() const
Definition: TypeLoc.h:962
This represents &#39;#pragma omp target simd&#39; directive.
Definition: StmtOpenMP.h:3895
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1133
bool isInvalid() const
Definition: Sema.h:11013
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3771
Wrapper for source info for unresolved typename using decls.
Definition: TypeLoc.h:692
qual_iterator qual_begin() const
Definition: Type.h:5595
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1394
ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub, bool IsThrownVariableInScope)
Build a new C++ throw expression.
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:11014
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:5518
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:807
LookupResultKind getResultKind() const
Definition: Lookup.h:321
OpenMPDirectiveKind getDirectiveKind() const
Definition: StmtOpenMP.h:301
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:704
OMPClause * RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;collapse&#39; clause.
Expr * getSubExpr()
Definition: Expr.h:3202
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:1909
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:2101
SourceLocation getQuestionLoc() const
Definition: Expr.h:3721
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:188
void ExpandingFunctionParameterPack(ParmVarDecl *Pack)
Note to the derived class when a function parameter pack is being expanded.
SourceRange getSourceRange() const LLVM_READONLY
Expr * getNumTeams()
Return NumTeams number.
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:4269
ExprResult RebuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
Build a new Objective-C boxed expression.
This represents &#39;#pragma omp critical&#39; directive.
Definition: StmtOpenMP.h:1640
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
Definition: ExprCXX.h:1889
bool hasKnownLambdaInternalLinkage() const
The lambda is known to has internal linkage no matter whether it has name mangling number...
Definition: DeclCXX.h:1712
StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *Object, Stmt *Body)
Build a new Objective-C @synchronized statement.
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition: ExprCXX.h:3243
StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @autoreleasepool statement.
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1808
IdentifierTable & Idents
Definition: ASTContext.h:580
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition: Type.h:6275
SourceLocation getCatchLoc() const
Definition: StmtCXX.h:48
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:125
OMPClause * RebuildOMPFlushClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;flush&#39; pseudo clause.
bool TryExpandParameterPacks(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, bool &ShouldExpand, bool &RetainExpansion, Optional< unsigned > &NumExpansions)
Determine whether we should expand a pack expansion with the given set of parameter packs into separa...
StmtResult ActOnAttributedStmt(SourceLocation AttrLoc, ArrayRef< const Attr *> Attrs, Stmt *SubStmt)
Definition: SemaStmt.cpp:540
Represents Objective-C&#39;s @catch statement.
Definition: StmtObjC.h:77
Expr * getLHS() const
Definition: ExprCXX.h:4557
DeclClass * getAsSingle() const
Definition: Lookup.h:507
This represents clause &#39;copyprivate&#39; in the &#39;#pragma omp ...&#39; directives.
OpenMPDistScheduleClauseKind
OpenMP attributes for &#39;dist_schedule&#39; clause.
Definition: OpenMPKinds.h:151
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:2520
Describes an C or C++ initializer list.
Definition: Expr.h:4403
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:1588
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:764
ArrayRef< SourceLocation > getMapTypeModifiersLoc() const LLVM_READONLY
Fetches ArrayRef of location of map-type-modifiers.
This represents &#39;#pragma omp distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3606
VarDecl * RebuildExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *Declarator, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Build a new C++ exception declaration.
bool isArrow() const
Definition: ExprObjC.h:584
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:797
Expr * getKeyExpr() const
Definition: ExprObjC.h:893
This represents &#39;#pragma omp teams distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:4100
BinaryOperatorKind
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:960
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:4221
Optional< Expr * > getArraySize()
Definition: ExprCXX.h:2225
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2381
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:2410
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Definition: SemaLookup.cpp:475
void setAttr(const Attr *A)
Definition: TypeLoc.h:876
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:527
Represents the results of name lookup.
Definition: Lookup.h:46
PtrTy get() const
Definition: Ownership.h:170
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
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.
ExprResult RebuildUnaryExprOrTypeTrait(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec_step expression with a type argument.
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2377
OMPClause * RebuildOMPDefaultClause(OpenMPDefaultClauseKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;default&#39; clause.
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2399
void setExpansionLoc(SourceLocation Loc)
Definition: TypeLoc.h:1097
friend bool operator!=(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
Expr * getBaseExpr() const
Definition: ExprObjC.h:890
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 &#39;schedule&#39; clause.
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1500
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2268
Expr * getOperand() const
Definition: ExprCXX.h:3978
const Expr * getThrowExpr() const
Definition: StmtObjC.h:344
Wrapper for source info for injected class names of class templates.
Definition: TypeLoc.h:681
< Capturing the *this object by copy
Definition: Lambda.h:36
SourceLocation getDefaultmapKindLoc()
Get kind location.
bool isGlobalNew() const
Definition: ExprCXX.h:2259
unsigned getNumProtocols() const
Definition: TypeLoc.h:788
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:974
SourceLocation getSigilLoc() const
Definition: TypeLoc.h:1200
A convenient class for passing around template argument information.
Definition: TemplateBase.h:554
SourceLocation getRequiresKWLoc() const
Definition: ExprConcepts.h:525
SourceLocation getLocation() const
Definition: ExprCXX.h:2452
OMPClause * RebuildOMPPrivateClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;private&#39; clause.
LabelDecl * getDecl() const
Definition: Stmt.h:1749
ExprResult RebuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Sub, SourceLocation RParenLoc)
Build a new C++ __builtin_bit_cast expression.
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4585
SourceLocation getLBracLoc() const
Definition: Stmt.h:1439
QualType RebuildRecordType(RecordDecl *Record)
Build a new class/struct/union type.
SourceLocation getRParenLoc() const
Definition: StmtCXX.h:204
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:2275
QualType RebuildArrayType(QualType ElementType, ArrayType::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)...
SourceLocation getIsaMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of &#39;F&#39;...
Definition: ExprObjC.h:1525
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:2969
Stmt * getBody()
Definition: Stmt.h:2444
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2151
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
ExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, ParmVarDecl *Param)
Build a new C++ default-argument expression.
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:840
bool isConstrained() const
Definition: Type.h:4912
concepts::NestedRequirement * BuildNestedRequirement(Expr *E)
StmtResult StmtError()
Definition: Ownership.h:280
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:1896
QualType FunctionType
BlockType - The function type of the block, if one was given.
Definition: ScopeInfo.h:726
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: ExprCXX.h:3713
Represents a declaration of a type.
Definition: Decl.h:3029
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3434
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:833
SourceLocation RAngleLoc
The source location of the right angle bracket (&#39;>&#39;).
Definition: TemplateBase.h:617
SourceLocation getColonLoc() const
Gets location of &#39;:&#39; symbol in clause.
bool constructsVBase() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1652
LangAS getAddressSpace() const
Definition: Type.h:359
Stmt * getInit()
Definition: Stmt.h:2423
A set of unresolved declarations.
Definition: UnresolvedSet.h:61
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:440
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1386
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1820
ExprResult RebuildAtomicExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, AtomicExpr::AtomicOp Op, SourceLocation RParenLoc)
Build a new atomic operation expression.
SourceLocation getThrowLoc() const
Definition: ExprCXX.h:1165
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:3007
TemplateArgumentLocContainerIterator & operator++()
const Type * getClass() const
Definition: Type.h:2867
CXXForRangeStmt - This represents C++0x [stmt.ranged]&#39;s ranged for statement, represented as &#39;for (ra...
Definition: StmtCXX.h:134
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3386
OMPClause * RebuildOMPNumTasksClause(Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;num_tasks&#39; clause.
bool isArrow() const
Definition: Expr.h:3020
ConceptDecl * getNamedConcept() const
Definition: ASTConcept.h:154
QualType RebuildPackExpansionType(QualType Pattern, SourceRange PatternRange, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Build a new pack expansion type.
This represents &#39;#pragma omp cancellation point&#39; directive.
Definition: StmtOpenMP.h:2946
void setBase(SourceLocation Loc, DeclarationName Entity)
Sets the "base" location and entity when that information is known based on another transformation...
This represents &#39;default&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:862
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
Definition: Expr.cpp:3000
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:50
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the &#39;=&#39; that precedes the initializer value itself, if present.
Definition: Expr.h:4864
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:2240
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3681
Expr * getRHS() const
Definition: ExprCXX.h:4558
Expr * getSizeExpr() const
Definition: Type.h:3058
const CallExpr * getConfig() const
Definition: ExprCXX.h:247
bool isArrow() const
Definition: ExprCXX.h:921
Wrapper for source info for ObjC interfaces.
Definition: TypeLoc.h:1040
FPOptions getFPFeatures() const
Definition: ExprCXX.h:152
StmtResult RebuildDeclStmt(MutableArrayRef< Decl *> Decls, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new declaration statement.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
param_type_iterator param_type_begin() const
Definition: Type.h:4123
CaseStmt - Represent a case statement.
Definition: Stmt.h:1500
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:2516
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5978
This represents &#39;final&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:525
This represents &#39;mergeable&#39; clause in the &#39;#pragma omp ...&#39; directive.
SourceLocation getCaretLocation() const
Definition: Expr.cpp:2381
Expr * getCond()
Definition: Stmt.h:2442
IdentKind getIdentKind() const
Definition: Expr.h:4316
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:436
This represents &#39;#pragma omp teams&#39; directive.
Definition: StmtOpenMP.h:2888
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
void append(iterator I, iterator E)
SourceLocation getEndLoc() const
Definition: Expr.h:4340
StmtResult RebuildSEHFinallyStmt(SourceLocation Loc, Stmt *Block)
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:63
This represents clause &#39;reduction&#39; in the &#39;#pragma omp ...&#39; directives.
FieldDecl * getField()
Get the field whose initializer will be used.
Definition: ExprCXX.h:1303
Helper class for OffsetOfExpr.
Definition: Expr.h:2163
Expr * getOperand() const
Definition: ExprCXX.h:4760
This represents &#39;#pragma omp teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:4029
AssociationTy< false > Association
Definition: Expr.h:5393
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1373
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:3087
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:90
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:263
concepts::ExprRequirement * RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
SourceLocation getBuiltinLoc() const
Definition: Expr.h:4273
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:979
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1818
SourceLocation getDefaultmapModifierLoc() const
Get the modifier location.
CXXRecordDecl * getNamingClass()
Gets the &#39;naming class&#39; (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition: ExprCXX.h:3113
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
Definition: Expr.h:1266
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
Definition: Expr.h:176
SourceLocation getBeginLoc() const
Default argument expressions have no representation in the source, so they have an empty source range...
Definition: ExprCXX.h:1252
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3198
SourceLocation getTryLoc() const
Definition: Stmt.h:3308
ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, bool ListInitialization)
Build a new object-construction expression.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3511
This represents clause &#39;is_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1374
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4226
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
Definition: Stmt.cpp:931
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)
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition: Expr.h:2080
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition: Lookup.h:426
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:1240
StmtClass
Definition: Stmt.h:68
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:62
const Stmt * getBody() const
Definition: Expr.cpp:2384
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2073
SourceLocation getProtocolRAngleLoc() const
Definition: TypeLoc.h:778
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Definition: DeclSpec.cpp:142
Stmt * getBody()
Definition: Stmt.h:2115
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2208
Expr * getSizeExpr() const
Definition: Type.h:3115
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1202
Stmt * getInit()
Definition: Stmt.h:1977
void setStmt(LabelStmt *T)
Definition: Decl.h:476
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1693
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2769
bool isTypeOperand() const
Definition: ExprCXX.h:1029
Expr * getSizeExpr() const
Definition: Type.h:3325
Stmt * getReturnStmt() const
Definition: StmtCXX.h:413
QualType getElementType() const
Definition: Type.h:3211
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:1897
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
Definition: ExprCXX.h:3887
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:8206
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3195
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
Definition: ExprCXX.h:3645
This represents clause &#39;from&#39; in the &#39;#pragma omp ...&#39; directives.
ExprResult RebuildObjCPropertyRefExpr(Expr *BaseArg, ObjCPropertyDecl *Property, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
Represents the this expression in C++.
Definition: ExprCXX.h:1097
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2034
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:576
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:248
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (&#39;)&#39;) that follows the argument list.
Definition: ExprCXX.h:3438
A helper class for building up ExtParameterInfos.
Definition: Sema.h:8617
TypeSourceInfo * getAllocatedTypeSourceInfo() const
Definition: ExprCXX.h:2197
ExprResult RebuildExtVectorElementExpr(Expr *Base, SourceLocation OpLoc, SourceLocation AccessorLoc, IdentifierInfo &Accessor)
Build a new extended vector element access expression.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1612
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: Expr.h:2938
Class that aids in the construction of nested-name-specifiers along with source-location information ...
ExprResult RebuildSourceLocExpr(SourceLocExpr::IdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
Build a new expression representing a call to a source location builtin.
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:20
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition: ExprCXX.h:2758
ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, SourceLocation LParenOrBraceLoc, MultiExprArg Args, SourceLocation RParenOrBraceLoc, bool ListInitialization)
Build a new object-construction expression.
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:1580
bool isArrayForm() const
Definition: ExprCXX.h:2386
const Expr * InnerBinOp
The inner == or <=> operator expression.
Definition: ExprCXX.h:304
Expr ** getSubExprs()
Retrieve the array of expressions.
Definition: Expr.h:4036
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
Definition: StmtObjC.h:217
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3717
Expr * getAddrSpaceExpr() const
Definition: Type.h:3166
helper_expr_const_range reduction_ops() const
This represents &#39;#pragma omp target parallel for simd&#39; directive.
Definition: StmtOpenMP.h:3825
llvm::Optional< bool > getKnownValue() const
Definition: Sema.h:11018
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:44
This represents &#39;dynamic_allocators&#39; clause in the &#39;#pragma omp requires&#39; directive.
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
Definition: DeclCXX.h:1705
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3732
SourceLocation getBuiltinLoc() const
Definition: TypeLoc.h:555
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1779
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:336
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1524
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2479
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1059
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1332
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:909
A requires-expression requirement which queries the existence of a type name or type template special...
Definition: ExprConcepts.h:198
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3754
SourceLocation getRBracket() const
Definition: ExprObjC.h:881
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:1921
NamedDecl * TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc)
Transform the given declaration, which was the first part of a nested-name-specifier in a member acce...
This represents &#39;threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
NestedNameSpecifierLoc getMapperQualifierLoc() const
Gets the nested name specifier for associated user-defined mapper.
ExprResult RebuildCXXConstructExpr(QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor, bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool RequiresZeroInit, CXXConstructExpr::ConstructionKind ConstructKind, SourceRange ParenRange)
Build a new object-construction expression.
Expr ** getSubExprs()
Definition: Expr.h:5916
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
Definition: StmtCXX.h:292
This represents &#39;#pragma omp taskgroup&#39; directive.
Definition: StmtOpenMP.h:2193
Expr * getSimdlen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:769
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Definition: ExprCXX.h:1494
void TypeWasModifiedSafely(QualType T)
Tell the TypeLocBuilder that the type it is storing has been modified in some safe way that doesn&#39;t a...
A RAII object to enter scope of a compound statement.
Definition: Sema.h:4114
SourceLocation getEndLoc() const
Definition: ExprCXX.h:140
OMPClause * RebuildOMPDependClause(OpenMPDependClauseKind DepKind, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;depend&#39; pseudo clause.
TemplateArgument ForgetPartiallySubstitutedPack()
"Forget" about the partially-substituted pack template argument, when performing an instantiation tha...
This represents clause &#39;aligned&#39; in the &#39;#pragma omp ...&#39; directives.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: ExprCXX.h:3704
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Definition: OpenMPClause.h:79
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:216
SourceLocation getNameLoc() const
Definition: TypeLoc.h:2171
StmtResult RebuildDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new default statement.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2372
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:2895
SourceLocation getTryLoc() const
Definition: StmtCXX.h:94
bool isConstexpr() const
Definition: Stmt.h:2007
ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait, SourceLocation StartLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParenLoc)
Build a new array type trait expression.
OMPClause * RebuildOMPLastprivateClause(ArrayRef< Expr *> VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;lastprivate&#39; clause.
SourceLocation getRBracketLoc() const
Definition: ExprCXX.h:975
This represents clause &#39;task_reduction&#39; in the &#39;#pragma omp taskgroup&#39; directives.
SourceLocation getLocation() const
Definition: Expr.h:1255
void setSizeExpr(Expr *Size)
Definition: TypeLoc.h:1513
SourceRange getRange() const
Definition: DeclSpec.h:68
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:978
ObjCTypeParamDecl * getDecl() const
Definition: Type.h:5663
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:4244
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2276
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
SourceLocation getLabelLoc() const
Definition: Stmt.h:2499
OMPClause * RebuildOMPNumThreadsClause(Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;num_threads&#39; clause.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Definition: ExprCXX.h:3601
SourceLocation getThrowLoc() const LLVM_READONLY
Definition: StmtObjC.h:348
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
Definition: Expr.cpp:4640
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2252
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:3480
This represents implicit clause &#39;depend&#39; for the &#39;#pragma omp task&#39; directive.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
Definition: Specifiers.h:151
ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, SourceLocation RParenLoc)
Build a new C++ zero-initialization expression.
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:3093
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
Definition: ExprCXX.h:2587
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:191
SourceLocation getFinallyLoc() const
Definition: Stmt.h:3266
OpenMPLastprivateModifier
OpenMP &#39;lastprivate&#39; clause modifier.
Definition: OpenMPKinds.h:191
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:1905
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2248
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:2053
Retains information about a block that is currently being parsed.
Definition: ScopeInfo.h:716
ExprResult RebuildTypeTrait(TypeTrait Trait, SourceLocation StartLoc, ArrayRef< TypeSourceInfo *> Args, SourceLocation RParenLoc)
Build a new type trait expression.
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;->&#39; or &#39;.&#39; operator.
Definition: ExprCXX.h:3870
const Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
Definition: StmtOpenMP.h:253
CXXMethodDecl * CallOperator
The lambda&#39;s compiler-generated operator().
Definition: ScopeInfo.h:800
Expr * getCond() const
Definition: Expr.h:3769
OpenMPLastprivateModifier getKind() const
Lastprivate kind.
Type source information for an attributed type.
Definition: TypeLoc.h:851
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1060
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4037
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1642
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2224
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:4842
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
This represents &#39;proc_bind&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:942
This represents &#39;capture&#39; clause in the &#39;#pragma omp atomic&#39; directive.
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
Definition: Expr.h:2923
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:619
ExprResult RebuildCoyieldExpr(SourceLocation CoyieldLoc, Expr *Result)
Build a new co_yield expression.
This represents one expression.
Definition: Expr.h:108
OMPClause * RebuildOMPAllocateClause(Expr *Allocate, ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;allocate&#39; clause.
SourceLocation getLocalRangeEnd() const
Definition: TypeLoc.h:1378
SourceLocation getElseLoc() const
Definition: Stmt.h:1996
DeclStmt * getEndStmt()
Definition: StmtCXX.h:165
SourceLocation End
ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool RequiresADL)
Build a new expression that references a declaration.
QualType RebuildMacroQualifiedType(QualType T, const IdentifierInfo *MacroII)
Build a new MacroDefined type.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition: Type.h:5224
Represents the body of a requires-expression.
Definition: DeclCXX.h:1909
SourceLocation getCaptureDefaultLoc() const
Retrieve the location of this lambda&#39;s capture-default, if any.
Definition: ExprCXX.h:1894
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:2997
ArrayRef< StringRef > getClobbers() const
Definition: Stmt.h:3173
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 &#39;super&#39;.
std::string Label
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
Definition: Expr.cpp:1596
SourceLocation getMapLoc() const LLVM_READONLY
Fetches location of clause mapping kind.
OMPClause * RebuildOMPNontemporalClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;nontemporal&#39; clause.
ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocatedType, TypeSourceInfo *AllocatedTypeInfo, Optional< Expr *> ArraySize, SourceRange DirectInitRange, Expr *Initializer)
Build a new C++ "new" expression.
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3867
int Id
Definition: ASTDiff.cpp:190
This represents &#39;simdlen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:735
Expr * getNumTasks() const
Return safe iteration space distance.
SourceLocation getDefaultLoc() const
Definition: Stmt.h:1671
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr)
SourceLocation getScheduleKindLoc()
Get kind location.
TemplateArgumentLocInventIterator(TreeTransform< Derived > &Self, InputIterator Iter)
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
Definition: ExprCXX.cpp:1531
SourceLocation getWhileLoc() const
Definition: Stmt.h:2327
This represents &#39;#pragma omp master taskloop&#39; directive.
Definition: StmtOpenMP.h:3204
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:620
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition: TypeLoc.h:326
SourceRange getBracketsRange() const
Definition: TypeLoc.h:1505
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:1998
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7067
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1750
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:5206
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc, bool IsGlobalDelete, bool IsArrayForm, Expr *Operand)
Build a new C++ "delete" expression.
Inits[]
Definition: OpenMPClause.h:150
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:527
unsigned getNumParams() const
Definition: Decl.h:4271
void setFoundDecl(NamedDecl *D)
Definition: TypeLoc.h:1984
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5579
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:88
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2649
concepts::NestedRequirement * RebuildNestedRequirement(Expr *Constraint)
VarDecl * getExceptionDecl() const
Definition: StmtCXX.h:49
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Definition: ExprCXX.h:2579
Expr * getCallee()
Definition: Expr.h:2663
unsigned getNumInits() const
Definition: Expr.h:4433
TemplateArgumentLocInventIterator & operator++()
OMPClause * RebuildOMPIsDevicePtrClause(ArrayRef< Expr *> VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP &#39;is_device_ptr&#39; clause.
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:4463
bool isIfNotExists() const
Determine whether this is an __if_exists statement.
Definition: StmtCXX.h:280
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:298
RAII object that temporarily sets the base location and entity used for reporting diagnostics in type...
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an &#39;->&#39; (otherwise, it used a &#39;.
Definition: ExprCXX.h:2542
Stmt * getBody()
Definition: Stmt.h:2287
Expr * getAllocator() const
Returns the allocator expression or nullptr, if no allocator is specified.
Definition: OpenMPClause.h:385
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.
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3003
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:304
OMPClause * RebuildOMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;num_teams&#39; clause.
const CompoundStmt * getSynchBody() const
Definition: StmtObjC.h:297
DeclContext * getDeclContext()
Definition: DeclBase.h:438
SourceLocation getLParenLoc() const
Definition: Expr.h:5188
Expr * getRHS()
Definition: Stmt.h:1601
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Definition: Type.h:5394
Represents Objective-C&#39;s @synchronized statement.
Definition: StmtObjC.h:277
ExprResult RebuildOMPArraySectionExpr(Expr *Base, SourceLocation LBracketLoc, Expr *LowerBound, SourceLocation ColonLoc, Expr *Length, SourceLocation RBracketLoc)
Build a new array section expression.
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:454
Expr ** getArgs()
Retrieve the arguments to this message, not including the receiver.
Definition: ExprObjC.h:1386
SourceLocation Begin
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2329
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, Optional< unsigned > Length, ArrayRef< TemplateArgument > PartialArgs)
Build a new expression to compute the length of a parameter pack.
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:2309
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4091
SourceLocation getRBracketLoc() const
Definition: ExprOpenMP.h:111
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:68
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:5642
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
SourceLocation getAtTryLoc() const
Retrieve the location of the @ in the @try.
Definition: StmtObjC.h:204
TemplateName RebuildTemplateName(TemplateTemplateParmDecl *Param, const TemplateArgument &ArgPack)
Build a new template name given a template template parameter pack and the.
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2389
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
Definition: Expr.h:2681
void setTemplateKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:1968
IdentifierInfo & getAccessor() const
Definition: Expr.h:5540
Represents a C++ template name within the type system.
Definition: TemplateName.h:191
Represents the type decltype(expr) (C++11).
Definition: Type.h:4370
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:4536
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2754
ExprResult RebuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Build an empty C++1z fold-expression with the given operator.
This represents &#39;ordered&#39; clause in the &#39;#pragma omp ...&#39; directive.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
Definition: Type.h:2251
SourceRange getAngleBrackets() const LLVM_READONLY
Definition: ExprCXX.h:390
StmtResult RebuildGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new goto statement.
OMPClause * RebuildOMPProcBindClause(ProcBindKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;proc_bind&#39; clause.
Kind getKind() const
Determine what kind of offsetof node this is.
Definition: Expr.h:2217
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1812
llvm::DenseMap< Decl *, Decl * > TransformedLocalDecls
The set of local declarations that have been transformed, for cases where we are forced to build new ...
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: Expr.h:2961
SourceLocation getOperatorLoc() const LLVM_READONLY
Definition: ExprCXX.h:317
bool isInvalid() const
QualType getType() const
Definition: Expr.h:137
SourceLocation getColonLoc() const
Get colon location.
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:4129
TypeSourceInfo * getType() const
Definition: ExprConcepts.h:240
SourceLocation getLocalRangeBegin() const
Definition: TypeLoc.h:1370
SourceLocation getKeywordLoc() const
Retrieve the location of the __if_exists or __if_not_exists keyword.
Definition: StmtCXX.h:274
Wrapper for source info for enum types.
Definition: TypeLoc.h:726
StmtResult RebuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init, SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc)
Build a new C++0x range-based for statement.
This represents &#39;#pragma omp for&#39; directive.
Definition: StmtOpenMP.h:1259
A unary type transform, which is a type constructed from another.
Definition: Type.h:4413
const DeclarationNameInfo & getConceptNameInfo() const
Definition: ASTConcept.h:142
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
OMPClause * RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;allocator&#39; clause.
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:768
Expr * getPattern() const
Get the pattern, that is, the operand that contains an unexpanded pack.
Definition: ExprCXX.h:4569
Optional< unsigned > NumExpansions
The number of elements this pack expansion will expand to, if this is a pack expansion and is known...
Definition: ExprObjC.h:273
SourceLocation getSwitchLoc() const
Definition: Stmt.h:2176
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2333
bool AlreadyTransformed(QualType T)
Determine whether the given type T has already been transformed.
Declaration of an alias template.
LabelDecl * getLabel() const
Definition: Stmt.h:2494
const Stmt * getTryBody() const
Retrieve the @try body.
Definition: StmtObjC.h:208
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4529
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition: TypeLoc.h:748
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:2636
void setNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Definition: TypeLoc.h:1960
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:4251
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition: TypeLoc.h:998
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> Types, ArrayRef< Expr *> Exprs)
Build a new generic selection expression.
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:950
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:3101
SourceLocation getDoLoc() const
Definition: Stmt.h:2383
SourceLocation getAtLoc() const
Definition: StmtObjC.h:388
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:712
bool isInvalid() const
Definition: Ownership.h:166
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition: Expr.cpp:1921
SourceLocation getRBracketLoc() const
Definition: Expr.h:2516
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression&#39;s (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:2046
bool isInstanceMethod() const
Definition: DeclObjC.h:423
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of &#39;F&#39;...
Definition: Expr.h:3025
Represents a GCC generic vector type.
Definition: Type.h:3235
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1234
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2912
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
Definition: Expr.h:4873
struct CXXOpName CXXOperatorName
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2820
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:14163
AtomicOp getOp() const
Definition: Expr.h:5913
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:863
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
UTTKind getUTTKind() const
Definition: Type.h:4441
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4209
const OffsetOfNode & getComponent(unsigned Idx) const
Definition: Expr.h:2316
Expr * getDevice()
Return device number.
const FunctionProtoType::ExtParameterInfo * getPointerOrNull(unsigned numParams)
Return a pointer (suitable for setting in an ExtProtoInfo) to the ExtParameterInfo array we&#39;ve built ...
Definition: Sema.h:8636
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:3005
This represents &#39;collapse&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:800
This represents clause &#39;firstprivate&#39; in the &#39;#pragma omp ...&#39; directives.
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1087
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
SourceLocation getCommaLoc()
Get location of &#39;,&#39;.
Expr * getCond()
Definition: Stmt.h:1909
ValueDecl * getDecl()
Definition: Expr.h:1247
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
Definition: TypeLoc.h:1956
SourceLocation getKWLoc() const
Definition: TypeLoc.h:1896
SourceLocation getLocation() const
Definition: Expr.h:1955
bool isUsable() const
Definition: Ownership.h:167
SourceLocation getRParenLoc() const
Definition: Expr.h:4276
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Definition: ASTContext.h:1417
ExprResult RebuildObjCMessageExpr(Expr *Receiver, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C instance message.
SourceLocation getForLoc() const
Definition: StmtObjC.h:52
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:301
const Expr * getSubExpr() const
Definition: Expr.h:2010
ObjCBridgeCastKind getBridgeKind() const
Determine which kind of bridge is being performed via this cast.
Definition: ExprObjC.h:1665
const Expr * getSubExpr() const
Definition: ExprCXX.h:1396
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2164
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
Definition: Expr.h:3371
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition: ExprCXX.h:4156
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1287
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:719
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1309
const DeclContext * getUsedContext() const
Definition: ExprCXX.h:1244
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2497
concepts::ExprRequirement * BuildExprRequirement(Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement)
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Definition: ASTConcept.h:158
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1435
OMPClause * RebuildOMPReductionClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr *> UnresolvedReductions)
Build a new OpenMP &#39;reduction&#39; clause.
This file defines OpenMP AST classes for clauses.
DeclarationName getBaseEntity()
Returns the name of the entity being transformed, if that information was not available elsewhere in ...
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
Definition: Expr.h:1662
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:6338
ExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ dynamic_cast expression.
This represents &#39;#pragma omp flush&#39; directive.
Definition: StmtOpenMP.h:2267
ArrayRef< concepts::Requirement * > getRequirements() const
Definition: ExprConcepts.h:513
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:288
This represents &#39;#pragma omp parallel for simd&#39; directive.
Definition: StmtOpenMP.h:1796
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition: Expr.h:421
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:2354
This represents &#39;seq_cst&#39; clause in the &#39;#pragma omp atomic&#39; directive.
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;->&#39; or &#39;.&#39; operator.
Definition: ExprCXX.h:3621
This represents &#39;untied&#39; clause in the &#39;#pragma omp ...&#39; directive.
TemplateArgumentLocInventIterator operator++(int)
OMPClause * RebuildOMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;final&#39; clause.
mapperlist_range mapperlists()
OMPClause * RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;simdlen&#39; clause.
ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, SourceLocation RParen)
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses (&#39;(&#39;) that precedes the argument list.
Definition: ExprCXX.h:3433
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Definition: Type.h:4102
RecordDecl * getDecl() const
Definition: Type.h:4505
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3626
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Definition: ExprCXX.h:129
void setIsVariadic(bool value)
Definition: Decl.h:4113
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:76
This represents &#39;#pragma omp parallel master taskloop&#39; directive.
Definition: StmtOpenMP.h:3340
void setTypeofLoc(SourceLocation Loc)
Definition: TypeLoc.h:1804
This represents &#39;unified_address&#39; clause in the &#39;#pragma omp requires&#39; directive. ...
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3195
Expr * getArgument()
Definition: ExprCXX.h:2401
This represents &#39;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2631
Simple iterator that traverses the template arguments in a container that provides a getArgLoc() memb...
SourceLocation getLParenLoc()
Get location of &#39;(&#39;.
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Definition: Decl.h:747
char * location_data() const
Retrieve the data associated with the source-location information.
Definition: DeclSpec.h:217
StmtResult RebuildObjCForCollectionStmt(SourceLocation ForLoc, Stmt *Element, Expr *Collection, SourceLocation RParenLoc, Stmt *Body)
Build a new Objective-C fast enumeration statement.
friend bool operator==(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
concepts::ExprRequirement * RebuildExprRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
Wrapper for source info for arrays.
Definition: TypeLoc.h:1484
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
SourceLocation getColonLoc() const
Returns the location of &#39;:&#39;.
This represents &#39;#pragma omp master taskloop simd&#39; directive.
Definition: StmtOpenMP.h:3272
StmtResult RebuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Build a new C++0x range-based for statement.
StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc, VarDecl *ExceptionDecl, Stmt *Handler)
Build a new C++ catch statement.
This represents &#39;num_teams&#39; clause in the &#39;#pragma omp ...&#39; directive.
void InventTemplateArgumentLoc(const TemplateArgument &Arg, TemplateArgumentLoc &ArgLoc)
Fakes up a TemplateArgumentLoc for a given TemplateArgument.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:445
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:1075
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2071
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4067
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
Definition: ExprObjC.h:1382
VarDecl * RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TInfo, QualType T)
Rebuild an Objective-C exception declaration.
CanQualType BuiltinFnTy
Definition: ASTContext.h:1046
SourceLocation getLParenLoc() const
Definition: Expr.h:3110
Kind
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2345
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2844
This captures a statement into a function.
Definition: Stmt.h:3376
Expr * getInit() const
Get the operand that doesn&#39;t contain a pack, for a binary fold.
Definition: ExprCXX.h:4572
QualType getCanonicalType() const
Definition: Type.h:6295
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1613
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2822
Token * getAsmToks()
Definition: Stmt.h:3132
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:153
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3813
Expr ** getPlacementArgs()
Definition: ExprCXX.h:2240
SourceLocation getLParenLoc()
Get location of &#39;(&#39;.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5715
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2260
ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar, SourceLocation IvarLoc, bool IsArrow, bool IsFreeIvar)
Build a new Objective-C ivar reference expression.
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: Expr.h:1316
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:5246
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:3975
const Attr * getAttr() const
The type attribute.
Definition: TypeLoc.h:873
friend bool operator!=(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
void RememberPartiallySubstitutedPack(TemplateArgument Arg)
"Remember" the partially-substituted pack template argument after performing an instantiation that mu...
SourceLocation getNameLoc() const
Gets the location of the name.
Definition: ExprCXX.h:2956
const ExtParameterInfo * ExtParameterInfos
Definition: Type.h:3844
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Definition: ExprCXX.h:1662
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: Expr.h:2969
unsigned getNumExprs() const
Return the number of expressions in this paren list.
Definition: Expr.h:5169
This represents &#39;#pragma omp single&#39; directive.
Definition: StmtOpenMP.h:1535
Encodes a location in the source.
const Expr * LHS
The original left-hand side.
Definition: ExprCXX.h:300
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1298
body_range body()
Definition: Stmt.h:1365
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2752
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:1257
QualType getReturnType() const
Definition: Type.h:3680
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
This represents &#39;hint&#39; clause in the &#39;#pragma omp ...&#39; directive.
Expr * getRetValue()
Definition: Stmt.h:2669
OpenMPDependClauseKind
OpenMP attributes for &#39;depend&#39; clause.
Definition: OpenMPKinds.h:102
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4521
SourceLocation getOperatorLoc() const
Definition: Expr.h:3466
StmtDiscardKind
The reason why the value of a statement is not discarded, if any.
StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new label statement.
const Stmt * getCatchBody() const
Definition: StmtObjC.h:93
LangAS getAddressSpace() const
Return the address space of this type.
Definition: Type.h:6377
unsigned getNumHandlers() const
Definition: StmtCXX.h:106
Expr * getSubExpr() const
Definition: Expr.h:2076
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3692
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3233
StmtResult RebuildSEHTryStmt(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: Expr.h:1308
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
Definition: Diagnostic.h:1295
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information...
Definition: ExprCXX.h:2531
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:33
static bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
Definition: Interp.cpp:34
A structure for storing an already-substituted template template parameter pack.
Definition: TemplateName.h:134
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition: ExprCXX.h:383
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:2100
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:2339
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:358
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:774
Expr * getLHS()
Definition: Stmt.h:1589
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:517
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Definition: ExprCXX.h:564
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3219
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition: ExprCXX.h:4812
MutableArrayRef< Expr * > MultiExprArg
Definition: Ownership.h:273
This represents &#39;schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:4051
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:171
NamedDecl * getFoundDecl() const
Definition: TypeLoc.h:1980
SourceLocation getExceptLoc() const
Definition: Stmt.h:3225
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:380
Stmt * getElse()
Definition: Stmt.h:1930
QualType getElementType() const
Definition: Type.h:3270
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:1225
bool transformOMPMappableExprListClause(TreeTransform< Derived > &TT, OMPMappableExprListClause< T > *C, llvm::SmallVectorImpl< Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperIdInfo, llvm::SmallVectorImpl< Expr *> &UnresolvedMappers)
Represents the declaration of a label.
Definition: Decl.h:451
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
This represents clause &#39;shared&#39; in the &#39;#pragma omp ...&#39; directives.
Represents a vector type where either the type or size is dependent.
Definition: Type.h:3312
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:966
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2691
SourceLocation getProcBindKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:993
ExprResult RebuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentKind IK)
Build a new predefined expression.
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Definition: StmtOpenMP.h:1699
SourceLocation getLBraceLoc() const
Definition: Stmt.h:3124
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1931
ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new address-of-label expression.
Expr * getCond()
Definition: Stmt.h:2103
Expr * getPriority()
Return Priority number.
ExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ reinterpret_cast expression.
ExprResult SemaBuiltinShuffleVector(CallExpr *TheCall)
SemaBuiltinShuffleVector - Handle __builtin_shufflevector.
SourceLocation getColonLoc() const
Definition: ExprOpenMP.h:108
SourceLocation getRParenLoc() const
Definition: Expr.h:3979
OpenMPLinearClauseKind Modifier
Modifier of &#39;linear&#39; clause.
Definition: OpenMPClause.h:101
ExprResult RebuildUnaryExprOrTypeTrait(Expr *SubExpr, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec step expression with an expression argument.
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:425
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
SourceLocation getSuperLoc() const
Retrieve the location of the &#39;super&#39; keyword for a class or instance message to &#39;super&#39;, otherwise an invalid source location.
Definition: ExprObjC.h:1301
SourceLocation getAtLoc() const
Definition: ExprObjC.h:423
This represents &#39;#pragma omp taskwait&#39; directive.
Definition: StmtOpenMP.h:2147
QualType getAllocatedType() const
Definition: ExprCXX.h:2193
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, ValueDecl *VD, const DeclarationNameInfo &NameInfo, NamedDecl *Found, TemplateArgumentListInfo *TemplateArgs)
Build a new expression that references a declaration.
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1121
const ParmVarDecl * getParamDecl(unsigned i) const
Definition: Decl.h:2422
SourceLocation getLocation() const
Definition: Attr.h:92
SourceLocation getNoexceptLoc() const
Definition: ExprConcepts.h:363
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
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.
SourceLocation getKindLoc() const
Returns the location of the lastprivate kind.
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:51
QualType getEquivalentType() const
Definition: Type.h:4576
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
Definition: Expr.h:5849
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2403
SourceLocation getColonLoc() const
Returns the location of the &#39;:&#39; delimiter.
Definition: OpenMPClause.h:388
bool isArray() const
Definition: ExprCXX.h:2223
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:2006
bool AlwaysRebuild()
Whether the transformation should always rebuild AST nodes, even if none of the children have changed...
void addDecl(NamedDecl *D)
Definition: UnresolvedSet.h:91
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:503
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1260
bool hasRestrict() const
Definition: Type.h:270
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Definition: Expr.h:158
QualType getReceiverType() const
Retrieve the receiver type to which this message is being directed.
Definition: ExprObjC.cpp:344
SourceLocation getLParenLoc() const
Definition: Expr.h:3977
SourceLocation getGotoLoc() const
Definition: Stmt.h:2497
SourceLocation getAtFinallyLoc() const
Definition: StmtObjC.h:148
bool isObjCObjectPointerType() const
Definition: Type.h:6618
SourceLocation getRBraceLoc() const
Definition: ExprConcepts.h:529
SourceLocation getNameModifierLoc() const
Return the location of directive name modifier.
Definition: OpenMPClause.h:499
llvm::APInt APInt
Definition: Integral.h:27
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:2979
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:741
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2212
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3274
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition: Stmt.h:3477
SourceLocation getAtCatchLoc() const
Definition: StmtObjC.h:105
Expr ** getInits()
Retrieve the set of initializers.
Definition: Expr.h:4436
This represents &#39;#pragma omp target&#39; directive.
Definition: StmtOpenMP.h:2514
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:451
ExprResult RebuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Build a new C++11 default-initialization expression.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(type) expression.
ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C class message expression.
SourceLocation getColonLoc() const
Returns the location of the &#39;:&#39; symbol, if any.
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:835
void setLBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1493
AutoTypeKeyword getKeyword() const
Definition: Type.h:4920
SourceLocation getEndLoc() const
Definition: Stmt.h:3126
Expr * getArrayRangeStart(const Designator &D) const
Definition: Expr.cpp:4418
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:1596
Expr * getSubExpr()
Definition: ExprObjC.h:142
An expression trait intrinsic.
Definition: ExprCXX.h:2785
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:831
EnumDecl * getDecl() const
Definition: Type.h:4528
Expr ** getExprs()
Definition: Expr.h:5180
const ObjCMethodDecl * getMethodDecl() const
Definition: ExprObjC.h:1356
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:145
VarDecl * getConditionVariable()
Retrieve the variable declared in this "switch" statement, if any.
Definition: Stmt.cpp:994
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2323
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3954
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:8624
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1417
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:3547
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:124
bool isArgumentType() const
Definition: Expr.h:2408
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition: TypeLoc.h:163
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
Definition: ExprCXX.cpp:1569
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:5536
OMPClause * RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;hint&#39; clause.
SourceLocation getStarLoc() const
Definition: Stmt.h:2538
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:635
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:573
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:594
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2220
This represents &#39;#pragma omp parallel master taskloop simd&#39; directive.
Definition: StmtOpenMP.h:3411
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2819
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3217
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
Definition: StmtCXX.h:252
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:224
SourceLocation getBaseLocation()
Returns the location of the entity being transformed, if that information was not available elsewhere...
ExprResult RebuildParenExpr(Expr *SubExpr, SourceLocation LParen, SourceLocation RParen)
Build a new expression in parentheses.
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3155
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1517
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:266
const Expr * getInitializer() const
Definition: Expr.h:3103
QualType getPointeeType() const
Definition: Type.h:3167
Represents a pack expansion of types.
Definition: Type.h:5511
Expr * getLHS() const
Definition: Expr.h:3474
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3654
SourceLocation getLocation() const LLVM_READONLY
Definition: ExprCXX.h:1664
Expr ** getElements()
Retrieve elements of array of literals.
Definition: ExprObjC.h:219
ExprResult RebuildUnaryOperator(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *SubExpr)
Build a new unary operator expression.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1390
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1584
Represents a C11 generic selection.
Definition: Expr.h:5234
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition: ExprCXX.h:4184
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
Definition: TemplateBase.h:626
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:928
const Expr * getBase() const
Definition: Expr.h:5536
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1260
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3910
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1638
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3071
SourceLocation getTypeofLoc() const
Definition: TypeLoc.h:1800
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4337
Represents a template argument.
Definition: TemplateBase.h:50
ArrayRef< OpenMPMapModifierKind > getMapTypeModifiers() const LLVM_READONLY
Fetches ArrayRef of map-type-modifiers.
bool isDeduced() const
Definition: Type.h:4862
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:922
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
Definition: ExprCXX.h:2572
TypeSourceInfo * getClassTInfo() const
Definition: TypeLoc.h:1272
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
Definition: SemaDecl.cpp:14626
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Definition: Expr.h:3867
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:390
Optional< types::ID > Type
TagTypeKind
The kind of a tag type.
Definition: Type.h:5187
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:1297
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1318
OpenMPScheduleClauseModifier
OpenMP modifiers for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:93
bool isTypeOperand() const
Definition: ExprCXX.h:804
bool isNull() const
Determine whether this template name is NULL.
Dataflow Directional Tag Classes.
StmtResult RebuildIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *Target)
Build a new indirect goto statement.
SourceLocation getColonLoc() const
Get colon location.
This represents &#39;device&#39; clause in the &#39;#pragma omp ...&#39; directive.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isVolatile() const
Definition: Stmt.h:2755
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:8200
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E)
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: Expr.h:2992
Stmt * getReturnStmtOnAllocFailure() const
Definition: StmtCXX.h:414
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
Definition: Stmt.cpp:1050
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:498
not evaluated yet, for special member function
Expr * getAllocate() const
Definition: StmtCXX.h:403
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1903
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition: Expr.h:3013
UnaryOperatorKind
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1271
SourceLocation getLocation() const
Definition: ExprObjC.h:763
RequiresExprBodyDecl * getBody() const
Definition: ExprConcepts.h:511
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2359
ArrayRef< Capture > captures() const
Definition: Decl.h:4164
IdentifierInfo * getOutputIdentifier(unsigned i) const
Definition: Stmt.h:2968
ExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *Init)
Build a new compound literal expression.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:402
bool isSimple() const
Definition: Stmt.h:2752
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Definition: ExprCXX.h:107
SourceLocation ModifierLoc
Location of linear modifier if any.
Definition: OpenMPClause.h:104
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
bool isVariadic() const
Definition: Decl.h:4112
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type &#39;Type&#39;, insert an implicit cast.
Definition: Sema.cpp:529
MSPropertyDecl * getPropertyDecl() const
Definition: ExprCXX.h:920
const Stmt * getFinallyBody() const
Definition: StmtObjC.h:139
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:132
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:1812
bool isImplicit() const
Definition: ExprCXX.h:1118
OMPClause * RebuildOMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;dist_schedule&#39; clause.
bool hasDependentPromiseType() const
Definition: StmtCXX.h:372
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1472
QualType RebuildElaboratedType(SourceLocation KeywordLoc, ElaboratedTypeKeyword Keyword, NestedNameSpecifierLoc QualifierLoc, QualType Named)
Build a new qualified name type.
This represents &#39;#pragma omp teams distribute&#39; directive.
Definition: StmtOpenMP.h:3961
Expr * getReturnValueInit() const
Definition: StmtCXX.h:409
ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, SourceLocation LParenLoc, Expr *Sub, SourceLocation RParenLoc, bool ListInitialization)
Build a new C++ functional-style cast expression.
Expr * getSourceExpression() const
Definition: TemplateBase.h:511
Interesting information about a specific parameter that can&#39;t simply be reflected in parameter&#39;s type...
Definition: Type.h:3448
SourceLocation EllipsisLoc
The location of the ellipsis, if this is a pack expansion.
Definition: ExprObjC.h:269
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition: ExprCXX.h:3429
const Expr * getInit() const
Definition: Decl.h:1229
AccessSpecifier getAccess() const
Definition: DeclBase.h:473
static ExprResult Owned(Expr *E)
A runtime availability query.
Definition: ExprObjC.h:1699
TemplateArgumentLocContainerIterator(ArgLocContainer &Container, unsigned Index)
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
Definition: Type.h:756
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:487
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:1194
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2444
Stmt * getHandler() const
Definition: Stmt.h:3317
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4786
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3657
SourceLocation getLBraceLoc() const
Definition: Expr.h:4550
The name of a declaration.
StmtClass getStmtClass() const
Definition: Stmt.h:1109
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:571
VectorKind getVectorKind() const
Definition: Type.h:3280
Expr * getDefaultArg()
Definition: Decl.cpp:2710
SourceRange getIntroducerRange() const
Retrieve the source range covering the lambda introducer, which contains the explicit capture list su...
Definition: ExprCXX.h:1988
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Definition: Decl.h:328
Expr * getOperand() const
Retrieve the operand of the &#39;co_return&#39; statement.
Definition: StmtCXX.h:480
SourceLocation getLParenLoc()
Get location of &#39;(&#39;.
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4015
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1513
OMPClause * RebuildOMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Num)
Build a new OpenMP &#39;ordered&#39; clause.
bool isImplicit() const
Definition: ExprCXX.h:4725
This represents &#39;unified_shared_memory&#39; clause in the &#39;#pragma omp requires&#39; directive.
This represents clause &#39;linear&#39; in the &#39;#pragma omp ...&#39; directives.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
Definition: ASTConcept.h:138
Represents an enum.
Definition: Decl.h:3481
SourceLocation LAngleLoc
The source location of the left angle bracket (&#39;<&#39;).
Definition: TemplateBase.h:614
const Expr * getSynchExpr() const
Definition: StmtObjC.h:305
OMPClause * RebuildOMPLinearClause(ArrayRef< Expr *> VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;linear&#39; clause.
Stmt * getInitSuspendStmt() const
Definition: StmtCXX.h:389
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2833
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack...
Definition: Decl.cpp:2464
bool hasObjCLifetime() const
Definition: Type.h:332
void setSigilLoc(SourceLocation Loc)
Definition: TypeLoc.h:1204
bool isIfExists() const
Determine whether this is an __if_exists statement.
Definition: StmtCXX.h:277
Expr * get() const
Definition: Sema.h:4072
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition: TypeLoc.h:868
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:3568
SourceLocation getBeginLoc() const
Definition: Expr.h:4339
NestedNameSpecifierLoc getQualifierLoc() const
Definition: ExprCXX.h:923
StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body)
Attach the body to a new case statement.
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:582
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
Definition: ExprCXX.h:3880
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
OpenMPDefaultmapClauseModifier getDefaultmapModifier() const
Get the modifier of the clause.
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it...
Definition: ExprCXX.cpp:1297
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2379
SourceLocation getBeginLoc() const
Returns the starting location of the clause.
Definition: OpenMPClause.h:67
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
Definition: TemplateBase.h:339
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4743
bool isNull() const
Determine whether this template argument has no value.
Definition: TemplateBase.h:237
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
SourceLocation getLParenLoc() const
Definition: ExprObjC.h:1662
ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
SemaConvertVectorExpr - Handle __builtin_convertvector.
bool isImplicitMapType() const LLVM_READONLY
Is this an implicit map type? We have to capture &#39;IsMapTypeImplicit&#39; from the parser for more informa...
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:811
ExprResult RebuildConceptSpecializationExpr(NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, TemplateArgumentListInfo *TALI)
Build a new Objective-C boxed expression.
Expr * getArrayRangeEnd(const Designator &D) const
Definition: Expr.cpp:4424
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2100
Represents a __leave statement.
Definition: Stmt.h:3337
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2092
QualType getModifiedType() const
Definition: Type.h:4575
unsigned getNumParams() const
Definition: TypeLoc.h:1426
LabelDecl * getLabel() const
Definition: Expr.h:3932
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2175
ExprResult BuildInstanceMessage(Expr *Receiver, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C instance message expression.
SourceLocation getRBracketLoc() const
Definition: TypeLoc.h:1497
SourceLocation getEndLoc() const
Returns the ending location of the clause.
Definition: OpenMPClause.h:70
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3958
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:152
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:2043
SourceLocation getColonColonLoc() const
Retrieve the location of the &#39;::&#39; in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2560
ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
Build a new template-id expression.
OMPClause * RebuildOMPFromClause(ArrayRef< Expr *> VarList, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, const OMPVarListLocTy &Locs, ArrayRef< Expr *> UnresolvedMappers)
Build a new OpenMP &#39;from&#39; clause.
OMPClause * RebuildOMPCopyprivateClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;copyprivate&#39; clause.
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:2410
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1208
Not an overloaded operator.
Definition: OperatorKinds.h:22
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition: ExprCXX.h:3207
SourceLocation getRParenLoc() const
Definition: StmtObjC.h:54
DeclarationNameInfo getNameInfo() const
Definition: Expr.h:1251
Represents the body of a coroutine.
Definition: StmtCXX.h:317
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4495
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, TypeSourceInfo *EncodedTypeInfo, SourceLocation RParenLoc)
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:449
unsigned getIndexTypeCVRQualifiers() const
Definition: Type.h:2920
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, Expr *SubExpr, TypeSourceInfo *TInfo, SourceLocation RParenLoc)
Build a new va_arg expression.
Expr * getBase() const
Definition: ExprObjC.h:1518
ExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build a new binary operator expression.
SourceLocation getBuiltinLoc() const
Definition: Expr.h:4017
ExprResult RebuildChooseExpr(SourceLocation BuiltinLoc, Expr *Cond, Expr *LHS, Expr *RHS, SourceLocation RParenLoc)
Build a new __builtin_choose_expr expression.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2462
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
Definition: TypeLoc.h:944
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:906
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
Definition: OpenMPClause.h:496
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
Definition: ExprObjC.h:227
OMPClause * RebuildOMPMapClause(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 &#39;map&#39; clause.
This file defines OpenMP AST classes for executable directives and clauses.
Represents Objective-C&#39;s collection statement.
Definition: StmtObjC.h:23
TypedefNameDecl * getTypedefNameDecl() const
Definition: TypeLoc.h:674
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1620
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:407
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition: ExprCXX.h:4159
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2369
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2385
OMPClause * RebuildOMPGrainsizeClause(Expr *Grainsize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;grainsize&#39; clause.
SourceLocation getLocation() const
Definition: ExprObjC.h:589
const llvm::APInt & getSize() const
Definition: Type.h:2958
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2075
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:224
bool isFunctionType() const
Definition: Type.h:6500
SourceLocation getRParenLoc() const
Definition: Expr.h:4185
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4699
StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc, Stmt *Init, Sema::ConditionResult Cond)
Start building a new switch statement.
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:564
std::iterator_traits< InputIterator >::difference_type difference_type
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:700
Stmt * getInit()
Definition: Stmt.h:2124
SourceLocation getColonLoc() const
Gets location of &#39;:&#39; symbol in clause.
AddrLabelExpr * getLabelExpr(unsigned i) const
Definition: Stmt.cpp:459
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
Definition: DeclSpec.cpp:1377
SourceRange getDirectInitRange() const
Definition: ExprCXX.h:2342
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information...
Definition: ExprCXX.h:3632
OpenMPScheduleClauseKind
OpenMP attributes for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:85
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:792
Expr * getSizeExpr() const
Definition: TypeLoc.h:1509
Opcode getOpcode() const
Definition: Expr.h:2071
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1573
OMPClause * RebuildOMPCopyinClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;copyin&#39; clause.
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2750
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
decl_range decls()
Definition: Stmt.h:1273
const Expr * getSizeExpr() const
Definition: Type.h:2959
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:4273
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:115
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:936
Wrapper for source info for record types.
Definition: TypeLoc.h:718
SourceLocation getLBracketLoc() const
Definition: TypeLoc.h:1489
Represents Objective-C&#39;s @finally statement.
Definition: StmtObjC.h:127
SourceLocation getDefaultLoc() const
Definition: Expr.h:5486
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1294
Holds information about the various types of exception specification.
Definition: Type.h:3811
StringRef getAsmString() const
Definition: Stmt.h:3135
OpenMPDefaultClauseKind
OpenMP attributes for &#39;default&#39; clause.
Definition: OpenMPKinds.h:77
ArrayRef< StringRef > getAllConstraints() const
Definition: Stmt.h:3169
SourceLocation getDistScheduleKindLoc()
Get kind location.
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
Definition: StmtOpenMP.h:250
ExprResult RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, UnresolvedLookupExpr *Lookup)
Build a new co_await expression.
const Expr * getBase() const
Definition: ExprObjC.h:580
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
Definition: ScopeInfo.h:644
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3618
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: Expr.h:3001
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
SourceLocation getColonLoc() const
Definition: Stmt.h:1481
This represents &#39;write&#39; clause in the &#39;#pragma omp atomic&#39; directive.
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1117
ExprResult RebuildCXXStaticCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ static_cast expression.
StmtResult RebuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs Args)
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
unsigned getNumClobbers() const
Definition: Stmt.h:2800
bool isImplicit() const
Definition: StmtCXX.h:489
SourceLocation getRParenLoc() const
Definition: Stmt.h:2460
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:546
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:3816
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof...
Definition: ExprCXX.h:4179
ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, bool IsImplicit)
Build a new co_await expression.
DeclStmt * getRangeStmt()
Definition: StmtCXX.h:161
unsigned arg_size() const
Retrieve the number of arguments.
Definition: ExprCXX.h:3447
bool capturesCXXThis() const
Definition: Decl.h:4169
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
TypeLoc getBaseLoc() const
Definition: TypeLoc.h:1002
UnqualTypeLoc getUnqualifiedLoc() const
Definition: TypeLoc.h:281
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2010
Expr * getRHS() const
Definition: Expr.h:4179
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:2942
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3390
SourceLocation getAsmLoc() const
Definition: Stmt.h:2749
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2481
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1279
Expr * getTarget()
Definition: Stmt.h:2540
VectorType::VectorKind getVectorKind() const
Definition: Type.h:3328
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:244
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:1725
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:4091
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3673
TypedefNameDecl * getDecl() const
Definition: Type.h:4256
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:14781
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getTypeArgsLAngleLoc() const
Definition: TypeLoc.h:924
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
Definition: TemplateBase.h:346
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:3819
void AddDesignator(Designator D)
AddDesignator - Add a designator to the end of this list.
Definition: Designator.h:186
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition: Stmt.cpp:1298
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:234
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4550
bool isFreeIvar() const
Definition: ExprObjC.h:585
Expr * getCond()
Definition: Stmt.h:2372
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2373
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Represents a type parameter type in Objective C.
Definition: Type.h:5620
StmtResult RebuildWhileStmt(SourceLocation WhileLoc, Sema::ConditionResult Cond, Stmt *Body)
Build a new while statement.
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form &#39;type...
Definition: DeclSpec.cpp:46
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
Definition: Stmt.cpp:887
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1009
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2836
SourceLocation getWhileLoc() const
Definition: Stmt.h:2385
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 &#39;task_reduction&#39; clause.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
bool DropCallArgument(Expr *E)
Determine whether the given call argument should be dropped, e.g., because it is a default argument...
ActionResult< Expr * > ExprResult
Definition: Ownership.h:263
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:6336
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2748
This represents &#39;nowait&#39; clause in the &#39;#pragma omp ...&#39; directive.
Defines Expressions and AST nodes for C++2a concepts.
Represents a C++ struct/union/class.
Definition: DeclCXX.h:253
TemplateArgumentLoc RebuildPackExpansion(TemplateArgumentLoc Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Build a new template argument pack expansion.
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:5420
ContinueStmt - This represents a continue.
Definition: Stmt.h:2569
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:978
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
bool ReplacingOriginal()
Whether the transformation is forming an expression or statement that replaces the original...
Represents a loop initializing the elements of an array.
Definition: Expr.h:5027
const TemplateArgumentLoc * operator->() const
This represents &#39;num_tasks&#39; clause in the &#39;#pragma omp ...&#39; directive.
Stmt * getFallthroughHandler() const
Definition: StmtCXX.h:399
SourceLocation getColonLoc() const
Definition: StmtCXX.h:203
Represents a C array with an unspecified size.
Definition: Type.h:2995
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2018
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
Definition: ExprConcepts.h:402
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:4130
OMPClause * RebuildOMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;if&#39; clause.
Expr * getFilterExpr() const
Definition: Stmt.h:3228
SourceLocation getAttrLoc() const
Definition: Stmt.h:1811
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3808
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:28
OMPClause * RebuildOMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;defaultmap&#39; clause.
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1688
SourceLocation getRParenLoc() const
Definition: Expr.h:5189
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:276
int Priority
Definition: Format.cpp:1829
OpenMPMapClauseKind
OpenMP mapping kind for &#39;map&#39; clause.
Definition: OpenMPKinds.h:118
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:6283
OMPClause * RebuildOMPFirstprivateClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;firstprivate&#39; clause.
Expr * getRHS() const
Definition: Expr.h:3781
Expr * getOperand() const
Definition: ExprCXX.h:4720
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1959
void setParam(unsigned i, ParmVarDecl *VD)
Definition: TypeLoc.h:1433
StmtResult RebuildSEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:5325
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:2226
SourceLocation getFirstScheduleModifierLoc() const
Get the first modifier location.
Represents the specialization of a concept - evaluates to a prvalue of type bool. ...
Definition: ExprConcepts.h:40
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1590
TryCaptureKind
Definition: Sema.h:4479
unsigned getNumProtocols() const
Definition: TypeLoc.h:970
helper_expr_const_range reduction_ops() const
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1125
QualType RebuildDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const IdentifierInfo *Name, SourceLocation NameLoc, TemplateArgumentListInfo &Args, bool AllowInjectedClassName)
Build a new typename type that refers to a template-id.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Definition: Type.h:4749
Location information for a TemplateArgument.
Definition: TemplateBase.h:392
SourceRange getParensRange() const
Definition: TypeLoc.h:1917
bool isCXXThisCaptured() const
Determine whether the C++ &#39;this&#39; is captured.
Definition: ScopeInfo.h:679
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1719
SourceLocation getAtSynchronizedLoc() const
Definition: StmtObjC.h:294
Expr * getThreadLimit()
Return ThreadLimit number.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
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 RebuildReturnStmt(SourceLocation ReturnLoc, Expr *Result)
Build a new return statement.
Optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated...
Definition: ExprCXX.h:4055
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier &#39;::&#39;.
Definition: DeclSpec.cpp:96
const DeclContext * getUsedContext() const
Definition: ExprCXX.h:1316
CompoundStmt * getTryBlock()
Definition: StmtCXX.h:99
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
Definition: DeclCXX.cpp:1496
SourceLocation getCaseLoc() const
Definition: Stmt.h:1571
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
SourceLocation getEllipsisLoc() const
Definition: ExprCXX.h:4574
const IdentifierInfo * getMacroIdentifier() const
Definition: TypeLoc.h:1089
Represents Objective-C&#39;s @try ... @catch ... @finally statement.
Definition: StmtObjC.h:165
SourceLocation getTemplateKWLoc() const
Definition: ASTConcept.h:148
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:263
bool isGlobalDelete() const
Definition: ExprCXX.h:2385
ExprResult RebuildPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Build a new expression pack expansion.
This represents &#39;#pragma omp taskloop simd&#39; directive.
Definition: StmtOpenMP.h:3137
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_convertvector token.
Definition: Expr.h:4102
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
Definition: StmtObjC.h:214
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3609
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1711
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
Definition: ExprCXX.h:2025
ExprResult RebuildShuffleVectorExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new shuffle vector expression.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2546
SourceLocation getNameLoc() const
Definition: TypeLoc.h:523
SourceRange getTypeIdParens() const
Definition: ExprCXX.h:2254
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4044
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1600
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:250
ExprResult ExprError()
Definition: Ownership.h:279
This represents &#39;dist_schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition: TypeLoc.h:1711
bool blockMissingReturnType() const
Definition: Decl.h:4172
bool TransformExceptionSpec(SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, SmallVectorImpl< QualType > &Exceptions, bool &Changed)
Expr * getLHS() const
Definition: Expr.h:4177
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition: ExprCXX.cpp:1245
Stmt * getBody() const
Retrieve the body of the coroutine as written.
Definition: StmtCXX.h:378
unsigned getNumTypeArgs() const
Definition: TypeLoc.h:940
ExprResult RebuildImplicitValueInitExpr(QualType T)
Build a new value-initialized expression.
SourceLocation getTemplateKWLoc() const
Definition: TypeLoc.h:1964
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:353
unsigned getNumElements() const
Definition: Type.h:3271
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:2985
StmtResult RebuildObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParenLoc, VarDecl *Var, Stmt *Body)
Build a new Objective-C @catch statement.
This represents &#39;#pragma omp sections&#39; directive.
Definition: StmtOpenMP.h:1403
Designation - Represent a full designation, which is a sequence of designators.
Definition: Designator.h:180
Expr * getHint() const
Returns number of threads.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:85
bool isObjectReceiver() const
Definition: ExprObjC.h:775
The top declaration context.
Definition: Decl.h:82
unsigned getNumComponents() const
Definition: Expr.h:2326
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2573
bool isReadOnly() const
Definition: Type.h:6192
ExprResult RebuildStmtExpr(SourceLocation LParenLoc, Stmt *SubStmt, SourceLocation RParenLoc)
Build a new GNU statement expression.
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1237
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2150
ExprResult RebuildConvertVectorExpr(SourceLocation BuiltinLoc, Expr *SrcExpr, TypeSourceInfo *DstTInfo, SourceLocation RParenLoc)
Build a new convert vector expression.
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:256
A rewritten comparison expression that was originally written using operator syntax.
Definition: ExprCXX.h:273
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1171
Represents an extended address space qualifier where the input address space value is dependent...
Definition: Type.h:3153
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4996
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:4123
Expr * getRHS() const
Definition: Expr.h:3476
ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc, QualType ThisType, bool isImplicit)
Build a new C++ "this" expression.
ExprResult RebuildObjCPropertyRefExpr(Expr *Base, QualType T, ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
concepts::TypeRequirement * RebuildTypeRequirement(TypeSourceInfo *T)
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition: ExprCXX.h:2965
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
bool isPointerType() const
Definition: Type.h:6504
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:958
Iterator adaptor that invents template argument location information for each of the template argumen...
BreakStmt - This represents a break.
Definition: Stmt.h:2599
Expr * getChunkSize()
Get chunk size.
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:97
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:538
unsigned getNumLabels() const
Definition: Stmt.h:3027
Expr * getOperand() const
Definition: ExprCXX.h:4799
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:1690
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: ExprCXX.h:3665
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition: Expr.cpp:3056
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:638
Stmt * getSubStmt()
Definition: Stmt.h:1753
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
bool Null(InterpState &S, CodePtr OpPC)
Definition: Interp.h:818
attr::Kind getAttrKind() const
Definition: TypeLoc.h:856
This structure contains most locations needed for by an OMPVarListClause.
Definition: OpenMPClause.h:172
SourceLocation getBridgeKeywordLoc() const
The location of the bridge keyword.
Definition: ExprObjC.h:1673
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1...
Definition: ExprCXX.h:1505
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3940
DeclStmt * getLoopVarStmt()
Definition: StmtCXX.h:168
QualType getType() const
Definition: Decl.h:630
Wrapper for source info for builtin types.
Definition: TypeLoc.h:550
ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(expr) expression.
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:129
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1129
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition: ExprCXX.h:1570
Wrapper for template type parameters.
Definition: TypeLoc.h:734
const Expr * getBase() const
Definition: ExprObjC.h:756
A trivial tuple used to represent a source range.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(expr) expression.
ASTContext & Context
Definition: Sema.h:385
This represents &#39;#pragma omp taskyield&#39; directive.
Definition: StmtOpenMP.h:2055
This represents a decl that may have a name.
Definition: Decl.h:223
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
Definition: DeclSpec.h:1049
This represents &#39;#pragma omp distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3688
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:645
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: Expr.h:2953
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:701
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4830
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2267
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
Definition: TypeLoc.h:77
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:3039
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2824
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1914
Represents a C++ namespace alias.
Definition: DeclCXX.h:2967
StmtResult RebuildCoreturnStmt(SourceLocation CoreturnLoc, Expr *Result, bool IsImplicit)
Build a new co_return statement.
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1624
Sema & getSema() const
Retrieves a reference to the semantic analysis object used for this tree transform.
SourceLocation getBuiltinLoc() const
Definition: Expr.h:5939
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2216
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:1000
No keyword precedes the qualified type name.
Definition: Type.h:5227
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1721
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, MultiStmtArg Statements, SourceLocation RBraceLoc, bool IsStmtExpr)
Build a new compound statement.
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:1848
SourceLocation getAttributeLoc() const
Definition: Type.h:3168
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:280
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition: Expr.h:3848
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3260
TypeSourceInfo * getWrittenTypeInfo() const
Definition: Expr.h:4270
DeclStmt * getBeginStmt()
Definition: StmtCXX.h:162
QualType getElementType() const
Definition: Type.h:3326
void setBlockMissingReturnType(bool val=true)
Definition: Decl.h:4176
const ExtParameterInfo * getExtParameterInfosOrNull() const
Return a pointer to the beginning of the array of extra parameter information, if present...
Definition: Type.h:4161
SourceLocation getRightLoc() const
Definition: ExprObjC.h:1417
ConceptDecl * getTypeConstraintConcept() const
Definition: Type.h:4908
attr::Kind getKind() const
Definition: Attr.h:85
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.
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:487
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition: Lookup.h:524
SourceLocation getGenericLoc() const
Definition: Expr.h:5483
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
Definition: ExprObjC.cpp:289
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
Definition: TemplateBase.h:287
concepts::NestedRequirement * RebuildNestedRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag)
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
Wrapper for source info for pointers.
Definition: TypeLoc.h:1226
const DeclarationNameInfo & getMapperIdInfo() const
Gets the name info for associated user-defined mapper.
SourceLocation getBegin() const
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
Definition: Expr.h:4094
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:4436
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4575
SourceLocation ColonLoc
Location of &#39;:&#39;.
Definition: OpenMPClause.h:107
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
Definition: Expr.h:2306
This represents clause &#39;nontemporal&#39; in the &#39;#pragma omp ...&#39; directives.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition: Decl.h:714
void transformedLocalDecl(Decl *Old, ArrayRef< Decl *> New)
Note that a local declaration has been transformed by this transformer.
ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
Build a new call expression.
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:4162
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1239
OMPClause * RebuildOMPUseDevicePtrClause(ArrayRef< Expr *> VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP &#39;use_device_ptr&#39; clause.
Represents Objective-C&#39;s @autoreleasepool Statement.
Definition: StmtObjC.h:368
llvm::Optional< NullabilityKind > getImmediateNullability() const
Definition: Type.cpp:3958
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:4657
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2935
CompoundStmt * getTryBlock() const
Definition: Stmt.h:3313
Stmt * getSubStmt()
Definition: Stmt.h:1816
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:3843
QualType getBaseType() const
Definition: ExprCXX.h:3857
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4562
QualType RebuildDeducedTemplateSpecializationType(TemplateName Template, QualType Deduced)
By default, builds a new DeducedTemplateSpecializationType with the given deduced type...
Expr * getBaseExpr() const
Definition: ExprCXX.h:919
QualType RebuildTypedefType(TypedefNameDecl *Typedef)
Build a new typedef type.
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5117
CompoundStmt * getBlock() const
Definition: Stmt.h:3232
SourceLocation getConceptNameLoc() const
Definition: TypeLoc.h:1972
static StmtResult Owned(Stmt *S)
SourceLocation getReturnLoc() const
Definition: Stmt.h:2692
bool Sub(InterpState &S, CodePtr OpPC)
Definition: Interp.h:140
Stmt * getFinalSuspendStmt() const
Definition: StmtCXX.h:392
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2096
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition: Stmt.cpp:1313
This represents &#39;#pragma omp target parallel for&#39; directive.
Definition: StmtOpenMP.h:2808
ExprResult RebuildCXXInheritedCtorInitExpr(QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor, bool ConstructsVBase, bool InheritedFromVBase)
Build a new implicit construction via inherited constructor expression.
Attr - This represents one attribute.
Definition: Attr.h:45
SourceLocation getLocation() const
Definition: DeclBase.h:429
This represents clause &#39;use_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
SourceLocation getTypeArgsRAngleLoc() const
Definition: TypeLoc.h:932
QualType getPointeeType() const
Definition: Type.h:2853
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6238
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2666
association_range associations()
Definition: Expr.h:5463
Expr * getLength()
Get length of array section.
Definition: ExprOpenMP.h:98
StmtResult RebuildIfStmt(SourceLocation IfLoc, bool IsConstexpr, Sema::ConditionResult Cond, Stmt *Init, Stmt *Then, SourceLocation ElseLoc, Stmt *Else)
Build a new "if" statement.
void setUnderlyingTInfo(TypeSourceInfo *TI) const
Definition: TypeLoc.h:1869
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3652
const IdentifierInfo * getIdentifier() const
Definition: Type.h:5447
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
Definition: Decl.cpp:1790
ConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1542
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4831
TypeSourceInfo * getClassReceiverTypeInfo() const
Returns a type-source information of a class message send, or nullptr if the message is not a class m...
Definition: ExprObjC.h:1288
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
Definition: ExprOpenMP.h:81
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
Definition: Type.h:1080
A RAII object to temporarily push a declaration context.
Definition: Sema.h:797
Stmt * getSubStmt()
Definition: Stmt.h:1619
StmtResult RebuildObjCAtTryStmt(SourceLocation AtLoc, Stmt *TryBody, MultiStmtArg CatchStmts, Stmt *Finally)
Build a new Objective-C @try statement.
const ReturnTypeRequirement & getReturnTypeRequirement() const
Definition: ExprConcepts.h:371
This represents &#39;#pragma omp taskloop&#39; directive.
Definition: StmtOpenMP.h:3071