clang  8.0.0
TreeTransform.h
Go to the documentation of this file.
1 //===------- TreeTransform.h - Semantic Tree Transformation -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements a semantic tree transformation that takes a given
10 // AST and rebuilds it, possibly transforming some nodes in the process.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
15 #define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
16 
17 #include "CoroutineStmtBuilder.h"
18 #include "TypeLocBuilder.h"
19 #include "clang/AST/Decl.h"
20 #include "clang/AST/DeclObjC.h"
21 #include "clang/AST/DeclTemplate.h"
22 #include "clang/AST/Expr.h"
23 #include "clang/AST/ExprCXX.h"
24 #include "clang/AST/ExprObjC.h"
25 #include "clang/AST/ExprOpenMP.h"
26 #include "clang/AST/Stmt.h"
27 #include "clang/AST/StmtCXX.h"
28 #include "clang/AST/StmtObjC.h"
29 #include "clang/AST/StmtOpenMP.h"
30 #include "clang/Sema/Designator.h"
31 #include "clang/Sema/Lookup.h"
32 #include "clang/Sema/Ownership.h"
34 #include "clang/Sema/ScopeInfo.h"
37 #include "llvm/ADT/ArrayRef.h"
38 #include "llvm/Support/ErrorHandling.h"
39 #include <algorithm>
40 
41 namespace clang {
42 using namespace sema;
43 
44 /// A semantic tree transformation that allows one to transform one
45 /// abstract syntax tree into another.
46 ///
47 /// A new tree transformation is defined by creating a new subclass \c X of
48 /// \c TreeTransform<X> and then overriding certain operations to provide
49 /// behavior specific to that transformation. For example, template
50 /// instantiation is implemented as a tree transformation where the
51 /// transformation of TemplateTypeParmType nodes involves substituting the
52 /// template arguments for their corresponding template parameters; a similar
53 /// transformation is performed for non-type template parameters and
54 /// template template parameters.
55 ///
56 /// This tree-transformation template uses static polymorphism to allow
57 /// subclasses to customize any of its operations. Thus, a subclass can
58 /// override any of the transformation or rebuild operators by providing an
59 /// operation with the same signature as the default implementation. The
60 /// overriding function should not be virtual.
61 ///
62 /// Semantic tree transformations are split into two stages, either of which
63 /// can be replaced by a subclass. The "transform" step transforms an AST node
64 /// or the parts of an AST node using the various transformation functions,
65 /// then passes the pieces on to the "rebuild" step, which constructs a new AST
66 /// node of the appropriate kind from the pieces. The default transformation
67 /// routines recursively transform the operands to composite AST nodes (e.g.,
68 /// the pointee type of a PointerType node) and, if any of those operand nodes
69 /// were changed by the transformation, invokes the rebuild operation to create
70 /// a new AST node.
71 ///
72 /// Subclasses can customize the transformation at various levels. The
73 /// most coarse-grained transformations involve replacing TransformType(),
74 /// TransformExpr(), TransformDecl(), TransformNestedNameSpecifierLoc(),
75 /// TransformTemplateName(), or TransformTemplateArgument() with entirely
76 /// new implementations.
77 ///
78 /// For more fine-grained transformations, subclasses can replace any of the
79 /// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
80 /// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
81 /// replacing TransformTemplateTypeParmType() allows template instantiation
82 /// to substitute template arguments for their corresponding template
83 /// parameters. Additionally, subclasses can override the \c RebuildXXX
84 /// functions to control how AST nodes are rebuilt when their operands change.
85 /// By default, \c TreeTransform will invoke semantic analysis to rebuild
86 /// AST nodes. However, certain other tree transformations (e.g, cloning) may
87 /// be able to use more efficient rebuild steps.
88 ///
89 /// There are a handful of other functions that can be overridden, allowing one
90 /// to avoid traversing nodes that don't need any transformation
91 /// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
92 /// operands have not changed (\c AlwaysRebuild()), and customize the
93 /// default locations and entity names used for type-checking
94 /// (\c getBaseLocation(), \c getBaseEntity()).
95 template<typename Derived>
97  /// Private RAII object that helps us forget and then re-remember
98  /// the template argument corresponding to a partially-substituted parameter
99  /// pack.
100  class ForgetPartiallySubstitutedPackRAII {
101  Derived &Self;
102  TemplateArgument Old;
103 
104  public:
105  ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) {
106  Old = Self.ForgetPartiallySubstitutedPack();
107  }
108 
109  ~ForgetPartiallySubstitutedPackRAII() {
110  Self.RememberPartiallySubstitutedPack(Old);
111  }
112  };
113 
114 protected:
116 
117  /// The set of local declarations that have been transformed, for
118  /// cases where we are forced to build new declarations within the transformer
119  /// rather than in the subclass (e.g., lambda closure types).
120  llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls;
121 
122 public:
123  /// Initializes a new tree transformer.
124  TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { }
125 
126  /// Retrieves a reference to the derived class.
127  Derived &getDerived() { return static_cast<Derived&>(*this); }
128 
129  /// Retrieves a reference to the derived class.
130  const Derived &getDerived() const {
131  return static_cast<const Derived&>(*this);
132  }
133 
134  static inline ExprResult Owned(Expr *E) { return E; }
135  static inline StmtResult Owned(Stmt *S) { return S; }
136 
137  /// Retrieves a reference to the semantic analysis object used for
138  /// this tree transform.
139  Sema &getSema() const { return SemaRef; }
140 
141  /// Whether the transformation should always rebuild AST nodes, even
142  /// if none of the children have changed.
143  ///
144  /// Subclasses may override this function to specify when the transformation
145  /// should rebuild all AST nodes.
146  ///
147  /// We must always rebuild all AST nodes when performing variadic template
148  /// pack expansion, in order to avoid violating the AST invariant that each
149  /// statement node appears at most once in its containing declaration.
150  bool AlwaysRebuild() { return SemaRef.ArgumentPackSubstitutionIndex != -1; }
151 
152  /// Returns the location of the entity being transformed, if that
153  /// information was not available elsewhere in the AST.
154  ///
155  /// By default, returns no source-location information. Subclasses can
156  /// provide an alternative implementation that provides better location
157  /// information.
159 
160  /// Returns the name of the entity being transformed, if that
161  /// information was not available elsewhere in the AST.
162  ///
163  /// By default, returns an empty name. Subclasses can provide an alternative
164  /// implementation with a more precise name.
166 
167  /// Sets the "base" location and entity when that
168  /// information is known based on another transformation.
169  ///
170  /// By default, the source location and entity are ignored. Subclasses can
171  /// override this function to provide a customized implementation.
172  void setBase(SourceLocation Loc, DeclarationName Entity) { }
173 
174  /// RAII object that temporarily sets the base location and entity
175  /// used for reporting diagnostics in types.
177  TreeTransform &Self;
178  SourceLocation OldLocation;
179  DeclarationName OldEntity;
180 
181  public:
183  DeclarationName Entity) : Self(Self) {
184  OldLocation = Self.getDerived().getBaseLocation();
185  OldEntity = Self.getDerived().getBaseEntity();
186 
187  if (Location.isValid())
188  Self.getDerived().setBase(Location, Entity);
189  }
190 
192  Self.getDerived().setBase(OldLocation, OldEntity);
193  }
194  };
195 
196  /// Determine whether the given type \p T has already been
197  /// transformed.
198  ///
199  /// Subclasses can provide an alternative implementation of this routine
200  /// to short-circuit evaluation when it is known that a given type will
201  /// not change. For example, template instantiation need not traverse
202  /// non-dependent types.
204  return T.isNull();
205  }
206 
207  /// Determine whether the given call argument should be dropped, e.g.,
208  /// because it is a default argument.
209  ///
210  /// Subclasses can provide an alternative implementation of this routine to
211  /// determine which kinds of call arguments get dropped. By default,
212  /// CXXDefaultArgument nodes are dropped (prior to transformation).
214  return E->isDefaultArgument();
215  }
216 
217  /// Determine whether we should expand a pack expansion with the
218  /// given set of parameter packs into separate arguments by repeatedly
219  /// transforming the pattern.
220  ///
221  /// By default, the transformer never tries to expand pack expansions.
222  /// Subclasses can override this routine to provide different behavior.
223  ///
224  /// \param EllipsisLoc The location of the ellipsis that identifies the
225  /// pack expansion.
226  ///
227  /// \param PatternRange The source range that covers the entire pattern of
228  /// the pack expansion.
229  ///
230  /// \param Unexpanded The set of unexpanded parameter packs within the
231  /// pattern.
232  ///
233  /// \param ShouldExpand Will be set to \c true if the transformer should
234  /// expand the corresponding pack expansions into separate arguments. When
235  /// set, \c NumExpansions must also be set.
236  ///
237  /// \param RetainExpansion Whether the caller should add an unexpanded
238  /// pack expansion after all of the expanded arguments. This is used
239  /// when extending explicitly-specified template argument packs per
240  /// C++0x [temp.arg.explicit]p9.
241  ///
242  /// \param NumExpansions The number of separate arguments that will be in
243  /// the expanded form of the corresponding pack expansion. This is both an
244  /// input and an output parameter, which can be set by the caller if the
245  /// number of expansions is known a priori (e.g., due to a prior substitution)
246  /// and will be set by the callee when the number of expansions is known.
247  /// The callee must set this value when \c ShouldExpand is \c true; it may
248  /// set this value in other cases.
249  ///
250  /// \returns true if an error occurred (e.g., because the parameter packs
251  /// are to be instantiated with arguments of different lengths), false
252  /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
253  /// must be set.
255  SourceRange PatternRange,
257  bool &ShouldExpand,
258  bool &RetainExpansion,
259  Optional<unsigned> &NumExpansions) {
260  ShouldExpand = false;
261  return false;
262  }
263 
264  /// "Forget" about the partially-substituted pack template argument,
265  /// when performing an instantiation that must preserve the parameter pack
266  /// use.
267  ///
268  /// This routine is meant to be overridden by the template instantiator.
270  return TemplateArgument();
271  }
272 
273  /// "Remember" the partially-substituted pack template argument
274  /// after performing an instantiation that must preserve the parameter pack
275  /// use.
276  ///
277  /// This routine is meant to be overridden by the template instantiator.
279 
280  /// Note to the derived class when a function parameter pack is
281  /// being expanded.
283 
284  /// Transforms the given type into another type.
285  ///
286  /// By default, this routine transforms a type by creating a
287  /// TypeSourceInfo for it and delegating to the appropriate
288  /// function. This is expensive, but we don't mind, because
289  /// this method is deprecated anyway; all users should be
290  /// switched to storing TypeSourceInfos.
291  ///
292  /// \returns the transformed type.
293  QualType TransformType(QualType T);
294 
295  /// Transforms the given type-with-location into a new
296  /// type-with-location.
297  ///
298  /// By default, this routine transforms a type by delegating to the
299  /// appropriate TransformXXXType to build a new type. Subclasses
300  /// may override this function (to take over all type
301  /// transformations) or some set of the TransformXXXType functions
302  /// to alter the transformation.
303  TypeSourceInfo *TransformType(TypeSourceInfo *DI);
304 
305  /// Transform the given type-with-location into a new
306  /// type, collecting location information in the given builder
307  /// as necessary.
308  ///
309  QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL);
310 
311  /// Transform a type that is permitted to produce a
312  /// DeducedTemplateSpecializationType.
313  ///
314  /// This is used in the (relatively rare) contexts where it is acceptable
315  /// for transformation to produce a class template type with deduced
316  /// template arguments.
317  /// @{
318  QualType TransformTypeWithDeducedTST(QualType T);
319  TypeSourceInfo *TransformTypeWithDeducedTST(TypeSourceInfo *DI);
320  /// @}
321 
322  /// Transform the given statement.
323  ///
324  /// By default, this routine transforms a statement by delegating to the
325  /// appropriate TransformXXXStmt function to transform a specific kind of
326  /// statement or the TransformExpr() function to transform an expression.
327  /// Subclasses may override this function to transform statements using some
328  /// other mechanism.
329  ///
330  /// \returns the transformed statement.
331  StmtResult TransformStmt(Stmt *S, bool DiscardedValue = false);
332 
333  /// Transform the given statement.
334  ///
335  /// By default, this routine transforms a statement by delegating to the
336  /// appropriate TransformOMPXXXClause function to transform a specific kind
337  /// of clause. Subclasses may override this function to transform statements
338  /// using some other mechanism.
339  ///
340  /// \returns the transformed OpenMP clause.
341  OMPClause *TransformOMPClause(OMPClause *S);
342 
343  /// Transform the given attribute.
344  ///
345  /// By default, this routine transforms a statement by delegating to the
346  /// appropriate TransformXXXAttr function to transform a specific kind
347  /// of attribute. Subclasses may override this function to transform
348  /// attributed statements using some other mechanism.
349  ///
350  /// \returns the transformed attribute
351  const Attr *TransformAttr(const Attr *S);
352 
353 /// Transform the specified attribute.
354 ///
355 /// Subclasses should override the transformation of attributes with a pragma
356 /// spelling to transform expressions stored within the attribute.
357 ///
358 /// \returns the transformed attribute.
359 #define ATTR(X)
360 #define PRAGMA_SPELLING_ATTR(X) \
361  const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; }
362 #include "clang/Basic/AttrList.inc"
363 
364  /// Transform the given expression.
365  ///
366  /// By default, this routine transforms an expression by delegating to the
367  /// appropriate TransformXXXExpr function to build a new expression.
368  /// Subclasses may override this function to transform expressions using some
369  /// other mechanism.
370  ///
371  /// \returns the transformed expression.
372  ExprResult TransformExpr(Expr *E);
373 
374  /// Transform the given initializer.
375  ///
376  /// By default, this routine transforms an initializer by stripping off the
377  /// semantic nodes added by initialization, then passing the result to
378  /// TransformExpr or TransformExprs.
379  ///
380  /// \returns the transformed initializer.
381  ExprResult TransformInitializer(Expr *Init, bool NotCopyInit);
382 
383  /// Transform the given list of expressions.
384  ///
385  /// This routine transforms a list of expressions by invoking
386  /// \c TransformExpr() for each subexpression. However, it also provides
387  /// support for variadic templates by expanding any pack expansions (if the
388  /// derived class permits such expansion) along the way. When pack expansions
389  /// are present, the number of outputs may not equal the number of inputs.
390  ///
391  /// \param Inputs The set of expressions to be transformed.
392  ///
393  /// \param NumInputs The number of expressions in \c Inputs.
394  ///
395  /// \param IsCall If \c true, then this transform is being performed on
396  /// function-call arguments, and any arguments that should be dropped, will
397  /// be.
398  ///
399  /// \param Outputs The transformed input expressions will be added to this
400  /// vector.
401  ///
402  /// \param ArgChanged If non-NULL, will be set \c true if any argument changed
403  /// due to transformation.
404  ///
405  /// \returns true if an error occurred, false otherwise.
406  bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall,
407  SmallVectorImpl<Expr *> &Outputs,
408  bool *ArgChanged = nullptr);
409 
410  /// Transform the given declaration, which is referenced from a type
411  /// or expression.
412  ///
413  /// By default, acts as the identity function on declarations, unless the
414  /// transformer has had to transform the declaration itself. Subclasses
415  /// may override this function to provide alternate behavior.
417  llvm::DenseMap<Decl *, Decl *>::iterator Known
418  = TransformedLocalDecls.find(D);
419  if (Known != TransformedLocalDecls.end())
420  return Known->second;
421 
422  return D;
423  }
424 
425  /// Transform the specified condition.
426  ///
427  /// By default, this transforms the variable and expression and rebuilds
428  /// the condition.
429  Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var,
430  Expr *Expr,
432 
433  /// Transform the attributes associated with the given declaration and
434  /// place them on the new declaration.
435  ///
436  /// By default, this operation does nothing. Subclasses may override this
437  /// behavior to transform attributes.
438  void transformAttrs(Decl *Old, Decl *New) { }
439 
440  /// Note that a local declaration has been transformed by this
441  /// transformer.
442  ///
443  /// Local declarations are typically transformed via a call to
444  /// TransformDefinition. However, in some cases (e.g., lambda expressions),
445  /// the transformer itself has to transform the declarations. This routine
446  /// can be overridden by a subclass that keeps track of such mappings.
447  void transformedLocalDecl(Decl *Old, Decl *New) {
448  TransformedLocalDecls[Old] = New;
449  }
450 
451  /// Transform the definition of the given declaration.
452  ///
453  /// By default, invokes TransformDecl() to transform the declaration.
454  /// Subclasses may override this function to provide alternate behavior.
456  return getDerived().TransformDecl(Loc, D);
457  }
458 
459  /// Transform the given declaration, which was the first part of a
460  /// nested-name-specifier in a member access expression.
461  ///
462  /// This specific declaration transformation only applies to the first
463  /// identifier in a nested-name-specifier of a member access expression, e.g.,
464  /// the \c T in \c x->T::member
465  ///
466  /// By default, invokes TransformDecl() to transform the declaration.
467  /// Subclasses may override this function to provide alternate behavior.
469  return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D));
470  }
471 
472  /// Transform the set of declarations in an OverloadExpr.
473  bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL,
474  LookupResult &R);
475 
476  /// Transform the given nested-name-specifier with source-location
477  /// information.
478  ///
479  /// By default, transforms all of the types and declarations within the
480  /// nested-name-specifier. Subclasses may override this function to provide
481  /// alternate behavior.
483  TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
484  QualType ObjectType = QualType(),
485  NamedDecl *FirstQualifierInScope = nullptr);
486 
487  /// Transform the given declaration name.
488  ///
489  /// By default, transforms the types of conversion function, constructor,
490  /// and destructor names and then (if needed) rebuilds the declaration name.
491  /// Identifiers and selectors are returned unmodified. Sublcasses may
492  /// override this function to provide alternate behavior.
494  TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo);
495 
496  /// Transform the given template name.
497  ///
498  /// \param SS The nested-name-specifier that qualifies the template
499  /// name. This nested-name-specifier must already have been transformed.
500  ///
501  /// \param Name The template name to transform.
502  ///
503  /// \param NameLoc The source location of the template name.
504  ///
505  /// \param ObjectType If we're translating a template name within a member
506  /// access expression, this is the type of the object whose member template
507  /// is being referenced.
508  ///
509  /// \param FirstQualifierInScope If the first part of a nested-name-specifier
510  /// also refers to a name within the current (lexical) scope, this is the
511  /// declaration it refers to.
512  ///
513  /// By default, transforms the template name by transforming the declarations
514  /// and nested-name-specifiers that occur within the template name.
515  /// Subclasses may override this function to provide alternate behavior.
517  TransformTemplateName(CXXScopeSpec &SS, TemplateName Name,
518  SourceLocation NameLoc,
519  QualType ObjectType = QualType(),
520  NamedDecl *FirstQualifierInScope = nullptr,
521  bool AllowInjectedClassName = false);
522 
523  /// Transform the given template argument.
524  ///
525  /// By default, this operation transforms the type, expression, or
526  /// declaration stored within the template argument and constructs a
527  /// new template argument from the transformed result. Subclasses may
528  /// override this function to provide alternate behavior.
529  ///
530  /// Returns true if there was an error.
531  bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
532  TemplateArgumentLoc &Output,
533  bool Uneval = false);
534 
535  /// Transform the given set of template arguments.
536  ///
537  /// By default, this operation transforms all of the template arguments
538  /// in the input set using \c TransformTemplateArgument(), and appends
539  /// the transformed arguments to the output list.
540  ///
541  /// Note that this overload of \c TransformTemplateArguments() is merely
542  /// a convenience function. Subclasses that wish to override this behavior
543  /// should override the iterator-based member template version.
544  ///
545  /// \param Inputs The set of template arguments to be transformed.
546  ///
547  /// \param NumInputs The number of template arguments in \p Inputs.
548  ///
549  /// \param Outputs The set of transformed template arguments output by this
550  /// routine.
551  ///
552  /// Returns true if an error occurred.
554  unsigned NumInputs,
555  TemplateArgumentListInfo &Outputs,
556  bool Uneval = false) {
557  return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs,
558  Uneval);
559  }
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  /// \param First An iterator to the first template argument.
568  ///
569  /// \param Last An iterator one step past the last template argument.
570  ///
571  /// \param Outputs The set of transformed template arguments output by this
572  /// routine.
573  ///
574  /// Returns true if an error occurred.
575  template<typename InputIterator>
576  bool TransformTemplateArguments(InputIterator First,
577  InputIterator Last,
578  TemplateArgumentListInfo &Outputs,
579  bool Uneval = false);
580 
581  /// Fakes up a TemplateArgumentLoc for a given TemplateArgument.
582  void InventTemplateArgumentLoc(const TemplateArgument &Arg,
583  TemplateArgumentLoc &ArgLoc);
584 
585  /// Fakes up a TypeSourceInfo for a type.
587  return SemaRef.Context.getTrivialTypeSourceInfo(T,
588  getDerived().getBaseLocation());
589  }
590 
591 #define ABSTRACT_TYPELOC(CLASS, PARENT)
592 #define TYPELOC(CLASS, PARENT) \
593  QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
594 #include "clang/AST/TypeLocNodes.def"
595 
596  template<typename Fn>
597  QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
598  FunctionProtoTypeLoc TL,
599  CXXRecordDecl *ThisContext,
600  Qualifiers ThisTypeQuals,
601  Fn TransformExceptionSpec);
602 
603  bool TransformExceptionSpec(SourceLocation Loc,
604  FunctionProtoType::ExceptionSpecInfo &ESI,
605  SmallVectorImpl<QualType> &Exceptions,
606  bool &Changed);
607 
608  StmtResult TransformSEHHandler(Stmt *Handler);
609 
610  QualType
611  TransformTemplateSpecializationType(TypeLocBuilder &TLB,
612  TemplateSpecializationTypeLoc TL,
613  TemplateName Template);
614 
615  QualType
616  TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB,
617  DependentTemplateSpecializationTypeLoc TL,
618  TemplateName Template,
619  CXXScopeSpec &SS);
620 
621  QualType TransformDependentTemplateSpecializationType(
622  TypeLocBuilder &TLB, DependentTemplateSpecializationTypeLoc TL,
623  NestedNameSpecifierLoc QualifierLoc);
624 
625  /// Transforms the parameters of a function type into the
626  /// given vectors.
627  ///
628  /// The result vectors should be kept in sync; null entries in the
629  /// variables vector are acceptable.
630  ///
631  /// Return true on error.
632  bool TransformFunctionTypeParams(
633  SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
634  const QualType *ParamTypes,
635  const FunctionProtoType::ExtParameterInfo *ParamInfos,
636  SmallVectorImpl<QualType> &PTypes, SmallVectorImpl<ParmVarDecl *> *PVars,
637  Sema::ExtParameterInfoBuilder &PInfos);
638 
639  /// Transforms a single function-type parameter. Return null
640  /// on error.
641  ///
642  /// \param indexAdjustment - A number to add to the parameter's
643  /// scope index; can be negative
644  ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
645  int indexAdjustment,
646  Optional<unsigned> NumExpansions,
647  bool ExpectParameterPack);
648 
649  QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL);
650 
651  StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr);
652  ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E);
653 
655  TemplateParameterList *TPL) {
656  return TPL;
657  }
658 
659  ExprResult TransformAddressOfOperand(Expr *E);
660 
661  ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E,
662  bool IsAddressOfOperand,
663  TypeSourceInfo **RecoveryTSI);
664 
665  ExprResult TransformParenDependentScopeDeclRefExpr(
666  ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
667  TypeSourceInfo **RecoveryTSI);
668 
669  StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S);
670 
671 // FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
672 // amount of stack usage with clang.
673 #define STMT(Node, Parent) \
674  LLVM_ATTRIBUTE_NOINLINE \
675  StmtResult Transform##Node(Node *S);
676 #define EXPR(Node, Parent) \
677  LLVM_ATTRIBUTE_NOINLINE \
678  ExprResult Transform##Node(Node *E);
679 #define ABSTRACT_STMT(Stmt)
680 #include "clang/AST/StmtNodes.inc"
681 
682 #define OPENMP_CLAUSE(Name, Class) \
683  LLVM_ATTRIBUTE_NOINLINE \
684  OMPClause *Transform ## Class(Class *S);
685 #include "clang/Basic/OpenMPKinds.def"
686 
687  /// Build a new qualified type given its unqualified type and type location.
688  ///
689  /// By default, this routine adds type qualifiers only to types that can
690  /// have qualifiers, and silently suppresses those qualifiers that are not
691  /// permitted. Subclasses may override this routine to provide different
692  /// behavior.
693  QualType RebuildQualifiedType(QualType T, QualifiedTypeLoc TL);
694 
695  /// Build a new pointer type given its pointee type.
696  ///
697  /// By default, performs semantic analysis when building the pointer type.
698  /// Subclasses may override this routine to provide different behavior.
699  QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil);
700 
701  /// Build a new block pointer type given its pointee type.
702  ///
703  /// By default, performs semantic analysis when building the block pointer
704  /// type. Subclasses may override this routine to provide different behavior.
705  QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil);
706 
707  /// Build a new reference type given the type it references.
708  ///
709  /// By default, performs semantic analysis when building the
710  /// reference type. Subclasses may override this routine to provide
711  /// different behavior.
712  ///
713  /// \param LValue whether the type was written with an lvalue sigil
714  /// or an rvalue sigil.
715  QualType RebuildReferenceType(QualType ReferentType,
716  bool LValue,
717  SourceLocation Sigil);
718 
719  /// Build a new member pointer type given the pointee type and the
720  /// class type it refers into.
721  ///
722  /// By default, performs semantic analysis when building the member pointer
723  /// type. Subclasses may override this routine to provide different behavior.
724  QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType,
725  SourceLocation Sigil);
726 
727  QualType RebuildObjCTypeParamType(const ObjCTypeParamDecl *Decl,
728  SourceLocation ProtocolLAngleLoc,
729  ArrayRef<ObjCProtocolDecl *> Protocols,
730  ArrayRef<SourceLocation> ProtocolLocs,
731  SourceLocation ProtocolRAngleLoc);
732 
733  /// Build an Objective-C object type.
734  ///
735  /// By default, performs semantic analysis when building the object type.
736  /// Subclasses may override this routine to provide different behavior.
737  QualType RebuildObjCObjectType(QualType BaseType,
738  SourceLocation Loc,
739  SourceLocation TypeArgsLAngleLoc,
740  ArrayRef<TypeSourceInfo *> TypeArgs,
741  SourceLocation TypeArgsRAngleLoc,
742  SourceLocation ProtocolLAngleLoc,
743  ArrayRef<ObjCProtocolDecl *> Protocols,
744  ArrayRef<SourceLocation> ProtocolLocs,
745  SourceLocation ProtocolRAngleLoc);
746 
747  /// Build a new Objective-C object pointer type given the pointee type.
748  ///
749  /// By default, directly builds the pointer type, with no additional semantic
750  /// analysis.
751  QualType RebuildObjCObjectPointerType(QualType PointeeType,
752  SourceLocation Star);
753 
754  /// Build a new array type given the element type, size
755  /// modifier, size of the array (if known), size expression, and index type
756  /// qualifiers.
757  ///
758  /// By default, performs semantic analysis when building the array type.
759  /// Subclasses may override this routine to provide different behavior.
760  /// Also by default, all of the other Rebuild*Array
761  QualType RebuildArrayType(QualType ElementType,
763  const llvm::APInt *Size,
764  Expr *SizeExpr,
765  unsigned IndexTypeQuals,
766  SourceRange BracketsRange);
767 
768  /// Build a new constant array type given the element type, size
769  /// modifier, (known) size of the array, and index type qualifiers.
770  ///
771  /// By default, performs semantic analysis when building the array type.
772  /// Subclasses may override this routine to provide different behavior.
773  QualType RebuildConstantArrayType(QualType ElementType,
775  const llvm::APInt &Size,
776  unsigned IndexTypeQuals,
777  SourceRange BracketsRange);
778 
779  /// Build a new incomplete array type given the element type, size
780  /// modifier, and index type qualifiers.
781  ///
782  /// By default, performs semantic analysis when building the array type.
783  /// Subclasses may override this routine to provide different behavior.
784  QualType RebuildIncompleteArrayType(QualType ElementType,
786  unsigned IndexTypeQuals,
787  SourceRange BracketsRange);
788 
789  /// Build a new variable-length array type given the element type,
790  /// size modifier, size expression, and index type qualifiers.
791  ///
792  /// By default, performs semantic analysis when building the array type.
793  /// Subclasses may override this routine to provide different behavior.
794  QualType RebuildVariableArrayType(QualType ElementType,
796  Expr *SizeExpr,
797  unsigned IndexTypeQuals,
798  SourceRange BracketsRange);
799 
800  /// Build a new dependent-sized array type given the element type,
801  /// size modifier, size expression, and index type qualifiers.
802  ///
803  /// By default, performs semantic analysis when building the array type.
804  /// Subclasses may override this routine to provide different behavior.
805  QualType RebuildDependentSizedArrayType(QualType ElementType,
807  Expr *SizeExpr,
808  unsigned IndexTypeQuals,
809  SourceRange BracketsRange);
810 
811  /// Build a new vector type given the element type and
812  /// number of elements.
813  ///
814  /// By default, performs semantic analysis when building the vector type.
815  /// Subclasses may override this routine to provide different behavior.
816  QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
817  VectorType::VectorKind VecKind);
818 
819  /// Build a new potentially dependently-sized extended vector type
820  /// given the element type and number of elements.
821  ///
822  /// By default, performs semantic analysis when building the vector type.
823  /// Subclasses may override this routine to provide different behavior.
824  QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr,
825  SourceLocation AttributeLoc,
827 
828  /// Build a new extended vector type given the element type and
829  /// number of elements.
830  ///
831  /// By default, performs semantic analysis when building the vector type.
832  /// Subclasses may override this routine to provide different behavior.
833  QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
834  SourceLocation AttributeLoc);
835 
836  /// Build a new potentially dependently-sized extended vector type
837  /// given the element type and number of elements.
838  ///
839  /// By default, performs semantic analysis when building the vector type.
840  /// Subclasses may override this routine to provide different behavior.
841  QualType RebuildDependentSizedExtVectorType(QualType ElementType,
842  Expr *SizeExpr,
843  SourceLocation AttributeLoc);
844 
845  /// Build a new DependentAddressSpaceType or return the pointee
846  /// type variable with the correct address space (retrieved from
847  /// AddrSpaceExpr) applied to it. The former will be returned in cases
848  /// where the address space remains dependent.
849  ///
850  /// By default, performs semantic analysis when building the type with address
851  /// space applied. Subclasses may override this routine to provide different
852  /// behavior.
853  QualType RebuildDependentAddressSpaceType(QualType PointeeType,
854  Expr *AddrSpaceExpr,
855  SourceLocation AttributeLoc);
856 
857  /// Build a new function type.
858  ///
859  /// By default, performs semantic analysis when building the function type.
860  /// Subclasses may override this routine to provide different behavior.
861  QualType RebuildFunctionProtoType(QualType T,
862  MutableArrayRef<QualType> ParamTypes,
863  const FunctionProtoType::ExtProtoInfo &EPI);
864 
865  /// Build a new unprototyped function type.
866  QualType RebuildFunctionNoProtoType(QualType ResultType);
867 
868  /// Rebuild an unresolved typename type, given the decl that
869  /// the UnresolvedUsingTypenameDecl was transformed to.
870  QualType RebuildUnresolvedUsingType(SourceLocation NameLoc, Decl *D);
871 
872  /// Build a new typedef type.
874  return SemaRef.Context.getTypeDeclType(Typedef);
875  }
876 
877  /// Build a new class/struct/union type.
879  return SemaRef.Context.getTypeDeclType(Record);
880  }
881 
882  /// Build a new Enum type.
884  return SemaRef.Context.getTypeDeclType(Enum);
885  }
886 
887  /// Build a new typeof(expr) type.
888  ///
889  /// By default, performs semantic analysis when building the typeof type.
890  /// Subclasses may override this routine to provide different behavior.
891  QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc);
892 
893  /// Build a new typeof(type) type.
894  ///
895  /// By default, builds a new TypeOfType with the given underlying type.
896  QualType RebuildTypeOfType(QualType Underlying);
897 
898  /// Build a new unary transform type.
899  QualType RebuildUnaryTransformType(QualType BaseType,
901  SourceLocation Loc);
902 
903  /// Build a new C++11 decltype type.
904  ///
905  /// By default, performs semantic analysis when building the decltype type.
906  /// Subclasses may override this routine to provide different behavior.
907  QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc);
908 
909  /// Build a new C++11 auto type.
910  ///
911  /// By default, builds a new AutoType with the given deduced type.
913  // Note, IsDependent is always false here: we implicitly convert an 'auto'
914  // which has been deduced to a dependent type into an undeduced 'auto', so
915  // that we'll retry deduction after the transformation.
916  return SemaRef.Context.getAutoType(Deduced, Keyword,
917  /*IsDependent*/ false);
918  }
919 
920  /// By default, builds a new DeducedTemplateSpecializationType with the given
921  /// deduced type.
923  QualType Deduced) {
925  Template, Deduced, /*IsDependent*/ false);
926  }
927 
928  /// Build a new template specialization type.
929  ///
930  /// By default, performs semantic analysis when building the template
931  /// specialization type. Subclasses may override this routine to provide
932  /// different behavior.
933  QualType RebuildTemplateSpecializationType(TemplateName Template,
934  SourceLocation TemplateLoc,
936 
937  /// Build a new parenthesized type.
938  ///
939  /// By default, builds a new ParenType type from the inner type.
940  /// Subclasses may override this routine to provide different behavior.
942  return SemaRef.BuildParenType(InnerType);
943  }
944 
945  /// Build a new qualified name type.
946  ///
947  /// By default, builds a new ElaboratedType type from the keyword,
948  /// the nested-name-specifier and the named type.
949  /// Subclasses may override this routine to provide different behavior.
951  ElaboratedTypeKeyword Keyword,
952  NestedNameSpecifierLoc QualifierLoc,
953  QualType Named) {
954  return SemaRef.Context.getElaboratedType(Keyword,
955  QualifierLoc.getNestedNameSpecifier(),
956  Named);
957  }
958 
959  /// Build a new typename type that refers to a template-id.
960  ///
961  /// By default, builds a new DependentNameType type from the
962  /// nested-name-specifier and the given type. Subclasses may override
963  /// this routine to provide different behavior.
965  ElaboratedTypeKeyword Keyword,
966  NestedNameSpecifierLoc QualifierLoc,
967  SourceLocation TemplateKWLoc,
968  const IdentifierInfo *Name,
969  SourceLocation NameLoc,
971  bool AllowInjectedClassName) {
972  // Rebuild the template name.
973  // TODO: avoid TemplateName abstraction
974  CXXScopeSpec SS;
975  SS.Adopt(QualifierLoc);
976  TemplateName InstName = getDerived().RebuildTemplateName(
977  SS, TemplateKWLoc, *Name, NameLoc, QualType(), nullptr,
978  AllowInjectedClassName);
979 
980  if (InstName.isNull())
981  return QualType();
982 
983  // If it's still dependent, make a dependent specialization.
984  if (InstName.getAsDependentTemplateName())
985  return SemaRef.Context.getDependentTemplateSpecializationType(Keyword,
986  QualifierLoc.getNestedNameSpecifier(),
987  Name,
988  Args);
989 
990  // Otherwise, make an elaborated type wrapping a non-dependent
991  // specialization.
992  QualType T =
993  getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args);
994  if (T.isNull()) return QualType();
995 
996  if (Keyword == ETK_None && QualifierLoc.getNestedNameSpecifier() == nullptr)
997  return T;
998 
999  return SemaRef.Context.getElaboratedType(Keyword,
1000  QualifierLoc.getNestedNameSpecifier(),
1001  T);
1002  }
1003 
1004  /// Build a new typename type that refers to an identifier.
1005  ///
1006  /// By default, performs semantic analysis when building the typename type
1007  /// (or elaborated type). Subclasses may override this routine to provide
1008  /// different behavior.
1010  SourceLocation KeywordLoc,
1011  NestedNameSpecifierLoc QualifierLoc,
1012  const IdentifierInfo *Id,
1013  SourceLocation IdLoc,
1014  bool DeducedTSTContext) {
1015  CXXScopeSpec SS;
1016  SS.Adopt(QualifierLoc);
1017 
1018  if (QualifierLoc.getNestedNameSpecifier()->isDependent()) {
1019  // If the name is still dependent, just build a new dependent name type.
1020  if (!SemaRef.computeDeclContext(SS))
1021  return SemaRef.Context.getDependentNameType(Keyword,
1022  QualifierLoc.getNestedNameSpecifier(),
1023  Id);
1024  }
1025 
1026  if (Keyword == ETK_None || Keyword == ETK_Typename) {
1027  QualType T = SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1028  *Id, IdLoc);
1029  // If a dependent name resolves to a deduced template specialization type,
1030  // check that we're in one of the syntactic contexts permitting it.
1031  if (!DeducedTSTContext) {
1032  if (auto *Deduced = dyn_cast_or_null<DeducedTemplateSpecializationType>(
1033  T.isNull() ? nullptr : T->getContainedDeducedType())) {
1034  SemaRef.Diag(IdLoc, diag::err_dependent_deduced_tst)
1035  << (int)SemaRef.getTemplateNameKindForDiagnostics(
1036  Deduced->getTemplateName())
1037  << QualType(QualifierLoc.getNestedNameSpecifier()->getAsType(), 0);
1038  if (auto *TD = Deduced->getTemplateName().getAsTemplateDecl())
1039  SemaRef.Diag(TD->getLocation(), diag::note_template_decl_here);
1040  return QualType();
1041  }
1042  }
1043  return T;
1044  }
1045 
1047 
1048  // We had a dependent elaborated-type-specifier that has been transformed
1049  // into a non-dependent elaborated-type-specifier. Find the tag we're
1050  // referring to.
1051  LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
1052  DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1053  if (!DC)
1054  return QualType();
1055 
1056  if (SemaRef.RequireCompleteDeclContext(SS, DC))
1057  return QualType();
1058 
1059  TagDecl *Tag = nullptr;
1060  SemaRef.LookupQualifiedName(Result, DC);
1061  switch (Result.getResultKind()) {
1064  break;
1065 
1066  case LookupResult::Found:
1067  Tag = Result.getAsSingle<TagDecl>();
1068  break;
1069 
1072  llvm_unreachable("Tag lookup cannot find non-tags");
1073 
1075  // Let the LookupResult structure handle ambiguities.
1076  return QualType();
1077  }
1078 
1079  if (!Tag) {
1080  // Check where the name exists but isn't a tag type and use that to emit
1081  // better diagnostics.
1082  LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
1083  SemaRef.LookupQualifiedName(Result, DC);
1084  switch (Result.getResultKind()) {
1085  case LookupResult::Found:
1088  NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1089  Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1090  SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << SomeDecl
1091  << NTK << Kind;
1092  SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1093  break;
1094  }
1095  default:
1096  SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1097  << Kind << Id << DC << QualifierLoc.getSourceRange();
1098  break;
1099  }
1100  return QualType();
1101  }
1102 
1103  if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1104  IdLoc, Id)) {
1105  SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1106  SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1107  return QualType();
1108  }
1109 
1110  // Build the elaborated-type-specifier type.
1111  QualType T = SemaRef.Context.getTypeDeclType(Tag);
1112  return SemaRef.Context.getElaboratedType(Keyword,
1113  QualifierLoc.getNestedNameSpecifier(),
1114  T);
1115  }
1116 
1117  /// Build a new pack expansion type.
1118  ///
1119  /// By default, builds a new PackExpansionType type from the given pattern.
1120  /// Subclasses may override this routine to provide different behavior.
1122  SourceRange PatternRange,
1123  SourceLocation EllipsisLoc,
1124  Optional<unsigned> NumExpansions) {
1125  return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1126  NumExpansions);
1127  }
1128 
1129  /// Build a new atomic type given its value type.
1130  ///
1131  /// By default, performs semantic analysis when building the atomic type.
1132  /// Subclasses may override this routine to provide different behavior.
1133  QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc);
1134 
1135  /// Build a new pipe type given its value type.
1136  QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc,
1137  bool isReadPipe);
1138 
1139  /// Build a new template name given a nested name specifier, a flag
1140  /// indicating whether the "template" keyword was provided, and the template
1141  /// that the template name refers to.
1142  ///
1143  /// By default, builds the new template name directly. Subclasses may override
1144  /// this routine to provide different behavior.
1145  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1146  bool TemplateKW,
1147  TemplateDecl *Template);
1148 
1149  /// Build a new template name given a nested name specifier and the
1150  /// name that is referred to as a template.
1151  ///
1152  /// By default, performs semantic analysis to determine whether the name can
1153  /// be resolved to a specific template, then builds the appropriate kind of
1154  /// template name. Subclasses may override this routine to provide different
1155  /// behavior.
1156  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1157  SourceLocation TemplateKWLoc,
1158  const IdentifierInfo &Name,
1159  SourceLocation NameLoc, QualType ObjectType,
1160  NamedDecl *FirstQualifierInScope,
1161  bool AllowInjectedClassName);
1162 
1163  /// Build a new template name given a nested name specifier and the
1164  /// overloaded operator name that is referred to as a template.
1165  ///
1166  /// By default, performs semantic analysis to determine whether the name can
1167  /// be resolved to a specific template, then builds the appropriate kind of
1168  /// template name. Subclasses may override this routine to provide different
1169  /// behavior.
1170  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1171  SourceLocation TemplateKWLoc,
1172  OverloadedOperatorKind Operator,
1173  SourceLocation NameLoc, QualType ObjectType,
1174  bool AllowInjectedClassName);
1175 
1176  /// Build a new template name given a template template parameter pack
1177  /// and the
1178  ///
1179  /// By default, performs semantic analysis to determine whether the name can
1180  /// be resolved to a specific template, then builds the appropriate kind of
1181  /// template name. Subclasses may override this routine to provide different
1182  /// behavior.
1184  const TemplateArgument &ArgPack) {
1185  return getSema().Context.getSubstTemplateTemplateParmPack(Param, ArgPack);
1186  }
1187 
1188  /// Build a new compound statement.
1189  ///
1190  /// By default, performs semantic analysis to build the new statement.
1191  /// Subclasses may override this routine to provide different behavior.
1193  MultiStmtArg Statements,
1194  SourceLocation RBraceLoc,
1195  bool IsStmtExpr) {
1196  return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1197  IsStmtExpr);
1198  }
1199 
1200  /// Build a new case statement.
1201  ///
1202  /// By default, performs semantic analysis to build the new statement.
1203  /// Subclasses may override this routine to provide different behavior.
1205  Expr *LHS,
1206  SourceLocation EllipsisLoc,
1207  Expr *RHS,
1209  return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1210  ColonLoc);
1211  }
1212 
1213  /// Attach the body to a new case statement.
1214  ///
1215  /// By default, performs semantic analysis to build the new statement.
1216  /// Subclasses may override this routine to provide different behavior.
1218  getSema().ActOnCaseStmtBody(S, Body);
1219  return S;
1220  }
1221 
1222  /// Build a new default statement.
1223  ///
1224  /// By default, performs semantic analysis to build the new statement.
1225  /// Subclasses may override this routine to provide different behavior.
1228  Stmt *SubStmt) {
1229  return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1230  /*CurScope=*/nullptr);
1231  }
1232 
1233  /// Build a new label statement.
1234  ///
1235  /// By default, performs semantic analysis to build the new statement.
1236  /// Subclasses may override this routine to provide different behavior.
1238  SourceLocation ColonLoc, Stmt *SubStmt) {
1239  return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1240  }
1241 
1242  /// Build a new label statement.
1243  ///
1244  /// By default, performs semantic analysis to build the new statement.
1245  /// Subclasses may override this routine to provide different behavior.
1247  ArrayRef<const Attr*> Attrs,
1248  Stmt *SubStmt) {
1249  return SemaRef.ActOnAttributedStmt(AttrLoc, Attrs, SubStmt);
1250  }
1251 
1252  /// Build a new "if" statement.
1253  ///
1254  /// By default, performs semantic analysis to build the new statement.
1255  /// Subclasses may override this routine to provide different behavior.
1256  StmtResult RebuildIfStmt(SourceLocation IfLoc, bool IsConstexpr,
1257  Sema::ConditionResult Cond, Stmt *Init, Stmt *Then,
1258  SourceLocation ElseLoc, Stmt *Else) {
1259  return getSema().ActOnIfStmt(IfLoc, IsConstexpr, Init, Cond, Then,
1260  ElseLoc, Else);
1261  }
1262 
1263  /// Start building a new switch statement.
1264  ///
1265  /// By default, performs semantic analysis to build the new statement.
1266  /// Subclasses may override this routine to provide different behavior.
1268  Sema::ConditionResult Cond) {
1269  return getSema().ActOnStartOfSwitchStmt(SwitchLoc, Init, Cond);
1270  }
1271 
1272  /// Attach the body to the switch statement.
1273  ///
1274  /// By default, performs semantic analysis to build the new statement.
1275  /// Subclasses may override this routine to provide different behavior.
1277  Stmt *Switch, Stmt *Body) {
1278  return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1279  }
1280 
1281  /// Build a new while statement.
1282  ///
1283  /// By default, performs semantic analysis to build the new statement.
1284  /// Subclasses may override this routine to provide different behavior.
1286  Sema::ConditionResult Cond, Stmt *Body) {
1287  return getSema().ActOnWhileStmt(WhileLoc, Cond, Body);
1288  }
1289 
1290  /// Build a new do-while statement.
1291  ///
1292  /// By default, performs semantic analysis to build the new statement.
1293  /// Subclasses may override this routine to provide different behavior.
1295  SourceLocation WhileLoc, SourceLocation LParenLoc,
1296  Expr *Cond, SourceLocation RParenLoc) {
1297  return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1298  Cond, RParenLoc);
1299  }
1300 
1301  /// Build a new for statement.
1302  ///
1303  /// By default, performs semantic analysis to build the new statement.
1304  /// Subclasses may override this routine to provide different behavior.
1306  Stmt *Init, Sema::ConditionResult Cond,
1307  Sema::FullExprArg Inc, SourceLocation RParenLoc,
1308  Stmt *Body) {
1309  return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1310  Inc, RParenLoc, Body);
1311  }
1312 
1313  /// Build a new goto statement.
1314  ///
1315  /// By default, performs semantic analysis to build the new statement.
1316  /// Subclasses may override this routine to provide different behavior.
1318  LabelDecl *Label) {
1319  return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1320  }
1321 
1322  /// Build a new indirect goto statement.
1323  ///
1324  /// By default, performs semantic analysis to build the new statement.
1325  /// Subclasses may override this routine to provide different behavior.
1327  SourceLocation StarLoc,
1328  Expr *Target) {
1329  return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1330  }
1331 
1332  /// Build a new return statement.
1333  ///
1334  /// By default, performs semantic analysis to build the new statement.
1335  /// Subclasses may override this routine to provide different behavior.
1337  return getSema().BuildReturnStmt(ReturnLoc, Result);
1338  }
1339 
1340  /// Build a new declaration statement.
1341  ///
1342  /// By default, performs semantic analysis to build the new statement.
1343  /// Subclasses may override this routine to provide different behavior.
1345  SourceLocation StartLoc, SourceLocation EndLoc) {
1346  Sema::DeclGroupPtrTy DG = getSema().BuildDeclaratorGroup(Decls);
1347  return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1348  }
1349 
1350  /// Build a new inline asm statement.
1351  ///
1352  /// By default, performs semantic analysis to build the new statement.
1353  /// Subclasses may override this routine to provide different behavior.
1355  bool IsVolatile, unsigned NumOutputs,
1356  unsigned NumInputs, IdentifierInfo **Names,
1357  MultiExprArg Constraints, MultiExprArg Exprs,
1358  Expr *AsmString, MultiExprArg Clobbers,
1359  SourceLocation RParenLoc) {
1360  return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1361  NumInputs, Names, Constraints, Exprs,
1362  AsmString, Clobbers, RParenLoc);
1363  }
1364 
1365  /// Build a new MS style inline asm statement.
1366  ///
1367  /// By default, performs semantic analysis to build the new statement.
1368  /// Subclasses may override this routine to provide different behavior.
1370  ArrayRef<Token> AsmToks,
1371  StringRef AsmString,
1372  unsigned NumOutputs, unsigned NumInputs,
1373  ArrayRef<StringRef> Constraints,
1374  ArrayRef<StringRef> Clobbers,
1375  ArrayRef<Expr*> Exprs,
1376  SourceLocation EndLoc) {
1377  return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1378  NumOutputs, NumInputs,
1379  Constraints, Clobbers, Exprs, EndLoc);
1380  }
1381 
1382  /// Build a new co_return statement.
1383  ///
1384  /// By default, performs semantic analysis to build the new statement.
1385  /// Subclasses may override this routine to provide different behavior.
1387  bool IsImplicit) {
1388  return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1389  }
1390 
1391  /// Build a new co_await expression.
1392  ///
1393  /// By default, performs semantic analysis to build the new expression.
1394  /// Subclasses may override this routine to provide different behavior.
1396  bool IsImplicit) {
1397  return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Result, IsImplicit);
1398  }
1399 
1400  /// Build a new co_await expression.
1401  ///
1402  /// By default, performs semantic analysis to build the new expression.
1403  /// Subclasses may override this routine to provide different behavior.
1405  Expr *Result,
1406  UnresolvedLookupExpr *Lookup) {
1407  return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1408  }
1409 
1410  /// Build a new co_yield expression.
1411  ///
1412  /// By default, performs semantic analysis to build the new expression.
1413  /// Subclasses may override this routine to provide different behavior.
1415  return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1416  }
1417 
1419  return getSema().BuildCoroutineBodyStmt(Args);
1420  }
1421 
1422  /// Build a new Objective-C \@try statement.
1423  ///
1424  /// By default, performs semantic analysis to build the new statement.
1425  /// Subclasses may override this routine to provide different behavior.
1427  Stmt *TryBody,
1428  MultiStmtArg CatchStmts,
1429  Stmt *Finally) {
1430  return getSema().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1431  Finally);
1432  }
1433 
1434  /// Rebuild an Objective-C exception declaration.
1435  ///
1436  /// By default, performs semantic analysis to build the new declaration.
1437  /// Subclasses may override this routine to provide different behavior.
1439  TypeSourceInfo *TInfo, QualType T) {
1440  return getSema().BuildObjCExceptionDecl(TInfo, T,
1441  ExceptionDecl->getInnerLocStart(),
1442  ExceptionDecl->getLocation(),
1443  ExceptionDecl->getIdentifier());
1444  }
1445 
1446  /// Build a new Objective-C \@catch statement.
1447  ///
1448  /// By default, performs semantic analysis to build the new statement.
1449  /// Subclasses may override this routine to provide different behavior.
1451  SourceLocation RParenLoc,
1452  VarDecl *Var,
1453  Stmt *Body) {
1454  return getSema().ActOnObjCAtCatchStmt(AtLoc, RParenLoc,
1455  Var, Body);
1456  }
1457 
1458  /// Build a new Objective-C \@finally statement.
1459  ///
1460  /// By default, performs semantic analysis to build the new statement.
1461  /// Subclasses may override this routine to provide different behavior.
1463  Stmt *Body) {
1464  return getSema().ActOnObjCAtFinallyStmt(AtLoc, Body);
1465  }
1466 
1467  /// Build a new Objective-C \@throw statement.
1468  ///
1469  /// By default, performs semantic analysis to build the new statement.
1470  /// Subclasses may override this routine to provide different behavior.
1472  Expr *Operand) {
1473  return getSema().BuildObjCAtThrowStmt(AtLoc, Operand);
1474  }
1475 
1476  /// Build a new OpenMP executable directive.
1477  ///
1478  /// By default, performs semantic analysis to build the new statement.
1479  /// Subclasses may override this routine to provide different behavior.
1481  DeclarationNameInfo DirName,
1482  OpenMPDirectiveKind CancelRegion,
1483  ArrayRef<OMPClause *> Clauses,
1484  Stmt *AStmt, SourceLocation StartLoc,
1485  SourceLocation EndLoc) {
1486  return getSema().ActOnOpenMPExecutableDirective(
1487  Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1488  }
1489 
1490  /// Build a new OpenMP 'if' clause.
1491  ///
1492  /// By default, performs semantic analysis to build the new OpenMP clause.
1493  /// Subclasses may override this routine to provide different behavior.
1495  Expr *Condition, SourceLocation StartLoc,
1496  SourceLocation LParenLoc,
1497  SourceLocation NameModifierLoc,
1499  SourceLocation EndLoc) {
1500  return getSema().ActOnOpenMPIfClause(NameModifier, Condition, StartLoc,
1501  LParenLoc, NameModifierLoc, ColonLoc,
1502  EndLoc);
1503  }
1504 
1505  /// Build a new OpenMP 'final' clause.
1506  ///
1507  /// By default, performs semantic analysis to build the new OpenMP clause.
1508  /// Subclasses may override this routine to provide different behavior.
1510  SourceLocation LParenLoc,
1511  SourceLocation EndLoc) {
1512  return getSema().ActOnOpenMPFinalClause(Condition, StartLoc, LParenLoc,
1513  EndLoc);
1514  }
1515 
1516  /// Build a new OpenMP 'num_threads' clause.
1517  ///
1518  /// By default, performs semantic analysis to build the new OpenMP clause.
1519  /// Subclasses may override this routine to provide different behavior.
1521  SourceLocation StartLoc,
1522  SourceLocation LParenLoc,
1523  SourceLocation EndLoc) {
1524  return getSema().ActOnOpenMPNumThreadsClause(NumThreads, StartLoc,
1525  LParenLoc, EndLoc);
1526  }
1527 
1528  /// Build a new OpenMP 'safelen' clause.
1529  ///
1530  /// By default, performs semantic analysis to build the new OpenMP clause.
1531  /// Subclasses may override this routine to provide different behavior.
1533  SourceLocation LParenLoc,
1534  SourceLocation EndLoc) {
1535  return getSema().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc, EndLoc);
1536  }
1537 
1538  /// Build a new OpenMP 'simdlen' clause.
1539  ///
1540  /// By default, performs semantic analysis to build the new OpenMP clause.
1541  /// Subclasses may override this routine to provide different behavior.
1543  SourceLocation LParenLoc,
1544  SourceLocation EndLoc) {
1545  return getSema().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc, EndLoc);
1546  }
1547 
1548  /// Build a new OpenMP 'collapse' 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 LParenLoc,
1554  SourceLocation EndLoc) {
1555  return getSema().ActOnOpenMPCollapseClause(Num, StartLoc, LParenLoc,
1556  EndLoc);
1557  }
1558 
1559  /// Build a new OpenMP 'default' clause.
1560  ///
1561  /// By default, performs semantic analysis to build the new OpenMP clause.
1562  /// Subclasses may override this routine to provide different behavior.
1564  SourceLocation KindKwLoc,
1565  SourceLocation StartLoc,
1566  SourceLocation LParenLoc,
1567  SourceLocation EndLoc) {
1568  return getSema().ActOnOpenMPDefaultClause(Kind, KindKwLoc,
1569  StartLoc, LParenLoc, EndLoc);
1570  }
1571 
1572  /// Build a new OpenMP 'proc_bind' clause.
1573  ///
1574  /// By default, performs semantic analysis to build the new OpenMP clause.
1575  /// Subclasses may override this routine to provide different behavior.
1577  SourceLocation KindKwLoc,
1578  SourceLocation StartLoc,
1579  SourceLocation LParenLoc,
1580  SourceLocation EndLoc) {
1581  return getSema().ActOnOpenMPProcBindClause(Kind, KindKwLoc,
1582  StartLoc, LParenLoc, EndLoc);
1583  }
1584 
1585  /// Build a new OpenMP 'schedule' clause.
1586  ///
1587  /// By default, performs semantic analysis to build the new OpenMP clause.
1588  /// Subclasses may override this routine to provide different behavior.
1591  OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1592  SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1593  SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1594  return getSema().ActOnOpenMPScheduleClause(
1595  M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1596  CommaLoc, EndLoc);
1597  }
1598 
1599  /// Build a new OpenMP 'ordered' clause.
1600  ///
1601  /// By default, performs semantic analysis to build the new OpenMP clause.
1602  /// Subclasses may override this routine to provide different behavior.
1604  SourceLocation EndLoc,
1605  SourceLocation LParenLoc, Expr *Num) {
1606  return getSema().ActOnOpenMPOrderedClause(StartLoc, EndLoc, LParenLoc, Num);
1607  }
1608 
1609  /// Build a new OpenMP 'private' clause.
1610  ///
1611  /// By default, performs semantic analysis to build the new OpenMP clause.
1612  /// Subclasses may override this routine to provide different behavior.
1614  SourceLocation StartLoc,
1615  SourceLocation LParenLoc,
1616  SourceLocation EndLoc) {
1617  return getSema().ActOnOpenMPPrivateClause(VarList, StartLoc, LParenLoc,
1618  EndLoc);
1619  }
1620 
1621  /// Build a new OpenMP 'firstprivate' clause.
1622  ///
1623  /// By default, performs semantic analysis to build the new OpenMP clause.
1624  /// Subclasses may override this routine to provide different behavior.
1626  SourceLocation StartLoc,
1627  SourceLocation LParenLoc,
1628  SourceLocation EndLoc) {
1629  return getSema().ActOnOpenMPFirstprivateClause(VarList, StartLoc, LParenLoc,
1630  EndLoc);
1631  }
1632 
1633  /// Build a new OpenMP 'lastprivate' clause.
1634  ///
1635  /// By default, performs semantic analysis to build the new OpenMP clause.
1636  /// Subclasses may override this routine to provide different behavior.
1638  SourceLocation StartLoc,
1639  SourceLocation LParenLoc,
1640  SourceLocation EndLoc) {
1641  return getSema().ActOnOpenMPLastprivateClause(VarList, StartLoc, LParenLoc,
1642  EndLoc);
1643  }
1644 
1645  /// Build a new OpenMP 'shared' clause.
1646  ///
1647  /// By default, performs semantic analysis to build the new OpenMP clause.
1648  /// Subclasses may override this routine to provide different behavior.
1650  SourceLocation StartLoc,
1651  SourceLocation LParenLoc,
1652  SourceLocation EndLoc) {
1653  return getSema().ActOnOpenMPSharedClause(VarList, StartLoc, LParenLoc,
1654  EndLoc);
1655  }
1656 
1657  /// Build a new OpenMP 'reduction' clause.
1658  ///
1659  /// By default, performs semantic analysis to build the new statement.
1660  /// Subclasses may override this routine to provide different behavior.
1662  SourceLocation StartLoc,
1663  SourceLocation LParenLoc,
1665  SourceLocation EndLoc,
1666  CXXScopeSpec &ReductionIdScopeSpec,
1667  const DeclarationNameInfo &ReductionId,
1668  ArrayRef<Expr *> UnresolvedReductions) {
1669  return getSema().ActOnOpenMPReductionClause(
1670  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1671  ReductionId, UnresolvedReductions);
1672  }
1673 
1674  /// Build a new OpenMP 'task_reduction' clause.
1675  ///
1676  /// By default, performs semantic analysis to build the new statement.
1677  /// Subclasses may override this routine to provide different behavior.
1679  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1681  CXXScopeSpec &ReductionIdScopeSpec,
1682  const DeclarationNameInfo &ReductionId,
1683  ArrayRef<Expr *> UnresolvedReductions) {
1684  return getSema().ActOnOpenMPTaskReductionClause(
1685  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1686  ReductionId, UnresolvedReductions);
1687  }
1688 
1689  /// Build a new OpenMP 'in_reduction' clause.
1690  ///
1691  /// By default, performs semantic analysis to build the new statement.
1692  /// Subclasses may override this routine to provide different behavior.
1693  OMPClause *
1696  SourceLocation EndLoc,
1697  CXXScopeSpec &ReductionIdScopeSpec,
1698  const DeclarationNameInfo &ReductionId,
1699  ArrayRef<Expr *> UnresolvedReductions) {
1700  return getSema().ActOnOpenMPInReductionClause(
1701  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1702  ReductionId, UnresolvedReductions);
1703  }
1704 
1705  /// Build a new OpenMP 'linear' clause.
1706  ///
1707  /// By default, performs semantic analysis to build the new OpenMP clause.
1708  /// Subclasses may override this routine to provide different behavior.
1710  SourceLocation StartLoc,
1711  SourceLocation LParenLoc,
1715  SourceLocation EndLoc) {
1716  return getSema().ActOnOpenMPLinearClause(VarList, Step, StartLoc, LParenLoc,
1717  Modifier, ModifierLoc, ColonLoc,
1718  EndLoc);
1719  }
1720 
1721  /// Build a new OpenMP 'aligned' clause.
1722  ///
1723  /// By default, performs semantic analysis to build the new OpenMP clause.
1724  /// Subclasses may override this routine to provide different behavior.
1726  SourceLocation StartLoc,
1727  SourceLocation LParenLoc,
1729  SourceLocation EndLoc) {
1730  return getSema().ActOnOpenMPAlignedClause(VarList, Alignment, StartLoc,
1731  LParenLoc, ColonLoc, EndLoc);
1732  }
1733 
1734  /// Build a new OpenMP 'copyin' clause.
1735  ///
1736  /// By default, performs semantic analysis to build the new OpenMP clause.
1737  /// Subclasses may override this routine to provide different behavior.
1739  SourceLocation StartLoc,
1740  SourceLocation LParenLoc,
1741  SourceLocation EndLoc) {
1742  return getSema().ActOnOpenMPCopyinClause(VarList, StartLoc, LParenLoc,
1743  EndLoc);
1744  }
1745 
1746  /// Build a new OpenMP 'copyprivate' clause.
1747  ///
1748  /// By default, performs semantic analysis to build the new OpenMP clause.
1749  /// Subclasses may override this routine to provide different behavior.
1751  SourceLocation StartLoc,
1752  SourceLocation LParenLoc,
1753  SourceLocation EndLoc) {
1754  return getSema().ActOnOpenMPCopyprivateClause(VarList, StartLoc, LParenLoc,
1755  EndLoc);
1756  }
1757 
1758  /// Build a new OpenMP 'flush' pseudo clause.
1759  ///
1760  /// By default, performs semantic analysis to build the new OpenMP clause.
1761  /// Subclasses may override this routine to provide different behavior.
1763  SourceLocation StartLoc,
1764  SourceLocation LParenLoc,
1765  SourceLocation EndLoc) {
1766  return getSema().ActOnOpenMPFlushClause(VarList, StartLoc, LParenLoc,
1767  EndLoc);
1768  }
1769 
1770  /// Build a new OpenMP 'depend' pseudo clause.
1771  ///
1772  /// By default, performs semantic analysis to build the new OpenMP clause.
1773  /// Subclasses may override this routine to provide different behavior.
1774  OMPClause *
1777  SourceLocation StartLoc, SourceLocation LParenLoc,
1778  SourceLocation EndLoc) {
1779  return getSema().ActOnOpenMPDependClause(DepKind, DepLoc, ColonLoc, VarList,
1780  StartLoc, LParenLoc, EndLoc);
1781  }
1782 
1783  /// Build a new OpenMP 'device' clause.
1784  ///
1785  /// By default, performs semantic analysis to build the new statement.
1786  /// Subclasses may override this routine to provide different behavior.
1788  SourceLocation LParenLoc,
1789  SourceLocation EndLoc) {
1790  return getSema().ActOnOpenMPDeviceClause(Device, StartLoc, LParenLoc,
1791  EndLoc);
1792  }
1793 
1794  /// Build a new OpenMP 'map' clause.
1795  ///
1796  /// By default, performs semantic analysis to build the new OpenMP clause.
1797  /// Subclasses may override this routine to provide different behavior.
1798  OMPClause *
1800  ArrayRef<SourceLocation> MapTypeModifiersLoc,
1801  OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
1803  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1804  SourceLocation LParenLoc, SourceLocation EndLoc) {
1805  return getSema().ActOnOpenMPMapClause(MapTypeModifiers, MapTypeModifiersLoc,
1806  MapType, IsMapTypeImplicit, MapLoc,
1807  ColonLoc, VarList, StartLoc,
1808  LParenLoc, EndLoc);
1809  }
1810 
1811  /// Build a new OpenMP 'num_teams' clause.
1812  ///
1813  /// By default, performs semantic analysis to build the new statement.
1814  /// Subclasses may override this routine to provide different behavior.
1816  SourceLocation LParenLoc,
1817  SourceLocation EndLoc) {
1818  return getSema().ActOnOpenMPNumTeamsClause(NumTeams, StartLoc, LParenLoc,
1819  EndLoc);
1820  }
1821 
1822  /// Build a new OpenMP 'thread_limit' clause.
1823  ///
1824  /// By default, performs semantic analysis to build the new statement.
1825  /// Subclasses may override this routine to provide different behavior.
1827  SourceLocation StartLoc,
1828  SourceLocation LParenLoc,
1829  SourceLocation EndLoc) {
1830  return getSema().ActOnOpenMPThreadLimitClause(ThreadLimit, StartLoc,
1831  LParenLoc, EndLoc);
1832  }
1833 
1834  /// Build a new OpenMP 'priority' clause.
1835  ///
1836  /// By default, performs semantic analysis to build the new statement.
1837  /// Subclasses may override this routine to provide different behavior.
1839  SourceLocation LParenLoc,
1840  SourceLocation EndLoc) {
1841  return getSema().ActOnOpenMPPriorityClause(Priority, StartLoc, LParenLoc,
1842  EndLoc);
1843  }
1844 
1845  /// Build a new OpenMP 'grainsize' clause.
1846  ///
1847  /// By default, performs semantic analysis to build the new statement.
1848  /// Subclasses may override this routine to provide different behavior.
1850  SourceLocation LParenLoc,
1851  SourceLocation EndLoc) {
1852  return getSema().ActOnOpenMPGrainsizeClause(Grainsize, StartLoc, LParenLoc,
1853  EndLoc);
1854  }
1855 
1856  /// Build a new OpenMP 'num_tasks' clause.
1857  ///
1858  /// By default, performs semantic analysis to build the new statement.
1859  /// Subclasses may override this routine to provide different behavior.
1861  SourceLocation LParenLoc,
1862  SourceLocation EndLoc) {
1863  return getSema().ActOnOpenMPNumTasksClause(NumTasks, StartLoc, LParenLoc,
1864  EndLoc);
1865  }
1866 
1867  /// Build a new OpenMP 'hint' clause.
1868  ///
1869  /// By default, performs semantic analysis to build the new statement.
1870  /// Subclasses may override this routine to provide different behavior.
1872  SourceLocation LParenLoc,
1873  SourceLocation EndLoc) {
1874  return getSema().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc, EndLoc);
1875  }
1876 
1877  /// Build a new OpenMP 'dist_schedule' clause.
1878  ///
1879  /// By default, performs semantic analysis to build the new OpenMP clause.
1880  /// Subclasses may override this routine to provide different behavior.
1881  OMPClause *
1883  Expr *ChunkSize, SourceLocation StartLoc,
1884  SourceLocation LParenLoc, SourceLocation KindLoc,
1885  SourceLocation CommaLoc, SourceLocation EndLoc) {
1886  return getSema().ActOnOpenMPDistScheduleClause(
1887  Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
1888  }
1889 
1890  /// Build a new OpenMP 'to' clause.
1891  ///
1892  /// By default, performs semantic analysis to build the new statement.
1893  /// Subclasses may override this routine to provide different behavior.
1895  SourceLocation StartLoc,
1896  SourceLocation LParenLoc,
1897  SourceLocation EndLoc) {
1898  return getSema().ActOnOpenMPToClause(VarList, StartLoc, LParenLoc, EndLoc);
1899  }
1900 
1901  /// Build a new OpenMP 'from' clause.
1902  ///
1903  /// By default, performs semantic analysis to build the new statement.
1904  /// Subclasses may override this routine to provide different behavior.
1906  SourceLocation StartLoc,
1907  SourceLocation LParenLoc,
1908  SourceLocation EndLoc) {
1909  return getSema().ActOnOpenMPFromClause(VarList, StartLoc, LParenLoc,
1910  EndLoc);
1911  }
1912 
1913  /// Build a new OpenMP 'use_device_ptr' clause.
1914  ///
1915  /// By default, performs semantic analysis to build the new OpenMP clause.
1916  /// Subclasses may override this routine to provide different behavior.
1918  SourceLocation StartLoc,
1919  SourceLocation LParenLoc,
1920  SourceLocation EndLoc) {
1921  return getSema().ActOnOpenMPUseDevicePtrClause(VarList, StartLoc, LParenLoc,
1922  EndLoc);
1923  }
1924 
1925  /// Build a new OpenMP 'is_device_ptr' clause.
1926  ///
1927  /// By default, performs semantic analysis to build the new OpenMP clause.
1928  /// Subclasses may override this routine to provide different behavior.
1930  SourceLocation StartLoc,
1931  SourceLocation LParenLoc,
1932  SourceLocation EndLoc) {
1933  return getSema().ActOnOpenMPIsDevicePtrClause(VarList, StartLoc, LParenLoc,
1934  EndLoc);
1935  }
1936 
1937  /// Rebuild the operand to an Objective-C \@synchronized statement.
1938  ///
1939  /// By default, performs semantic analysis to build the new statement.
1940  /// Subclasses may override this routine to provide different behavior.
1942  Expr *object) {
1943  return getSema().ActOnObjCAtSynchronizedOperand(atLoc, object);
1944  }
1945 
1946  /// Build a new Objective-C \@synchronized statement.
1947  ///
1948  /// By default, performs semantic analysis to build the new statement.
1949  /// Subclasses may override this routine to provide different behavior.
1951  Expr *Object, Stmt *Body) {
1952  return getSema().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
1953  }
1954 
1955  /// Build a new Objective-C \@autoreleasepool statement.
1956  ///
1957  /// By default, performs semantic analysis to build the new statement.
1958  /// Subclasses may override this routine to provide different behavior.
1960  Stmt *Body) {
1961  return getSema().ActOnObjCAutoreleasePoolStmt(AtLoc, Body);
1962  }
1963 
1964  /// Build a new Objective-C fast enumeration statement.
1965  ///
1966  /// By default, performs semantic analysis to build the new statement.
1967  /// Subclasses may override this routine to provide different behavior.
1969  Stmt *Element,
1970  Expr *Collection,
1971  SourceLocation RParenLoc,
1972  Stmt *Body) {
1973  StmtResult ForEachStmt = getSema().ActOnObjCForCollectionStmt(ForLoc,
1974  Element,
1975  Collection,
1976  RParenLoc);
1977  if (ForEachStmt.isInvalid())
1978  return StmtError();
1979 
1980  return getSema().FinishObjCForCollectionStmt(ForEachStmt.get(), Body);
1981  }
1982 
1983  /// Build a new C++ exception declaration.
1984  ///
1985  /// By default, performs semantic analysis to build the new decaration.
1986  /// Subclasses may override this routine to provide different behavior.
1989  SourceLocation StartLoc,
1990  SourceLocation IdLoc,
1991  IdentifierInfo *Id) {
1992  VarDecl *Var = getSema().BuildExceptionDeclaration(nullptr, Declarator,
1993  StartLoc, IdLoc, Id);
1994  if (Var)
1995  getSema().CurContext->addDecl(Var);
1996  return Var;
1997  }
1998 
1999  /// Build a new C++ catch statement.
2000  ///
2001  /// By default, performs semantic analysis to build the new statement.
2002  /// Subclasses may override this routine to provide different behavior.
2004  VarDecl *ExceptionDecl,
2005  Stmt *Handler) {
2006  return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2007  Handler));
2008  }
2009 
2010  /// Build a new C++ try statement.
2011  ///
2012  /// By default, performs semantic analysis to build the new statement.
2013  /// Subclasses may override this routine to provide different behavior.
2015  ArrayRef<Stmt *> Handlers) {
2016  return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2017  }
2018 
2019  /// Build a new C++0x range-based for statement.
2020  ///
2021  /// By default, performs semantic analysis to build the new statement.
2022  /// Subclasses may override this routine to provide different behavior.
2024  SourceLocation CoawaitLoc, Stmt *Init,
2025  SourceLocation ColonLoc, Stmt *Range,
2026  Stmt *Begin, Stmt *End, Expr *Cond,
2027  Expr *Inc, Stmt *LoopVar,
2028  SourceLocation RParenLoc) {
2029  // If we've just learned that the range is actually an Objective-C
2030  // collection, treat this as an Objective-C fast enumeration loop.
2031  if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2032  if (RangeStmt->isSingleDecl()) {
2033  if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2034  if (RangeVar->isInvalidDecl())
2035  return StmtError();
2036 
2037  Expr *RangeExpr = RangeVar->getInit();
2038  if (!RangeExpr->isTypeDependent() &&
2039  RangeExpr->getType()->isObjCObjectPointerType()) {
2040  // FIXME: Support init-statements in Objective-C++20 ranged for
2041  // statement.
2042  if (Init) {
2043  return SemaRef.Diag(Init->getBeginLoc(),
2044  diag::err_objc_for_range_init_stmt)
2045  << Init->getSourceRange();
2046  }
2047  return getSema().ActOnObjCForCollectionStmt(ForLoc, LoopVar,
2048  RangeExpr, RParenLoc);
2049  }
2050  }
2051  }
2052  }
2053 
2054  return getSema().BuildCXXForRangeStmt(ForLoc, CoawaitLoc, Init, ColonLoc,
2055  Range, Begin, End, Cond, Inc, LoopVar,
2056  RParenLoc, Sema::BFRK_Rebuild);
2057  }
2058 
2059  /// Build a new C++0x range-based for statement.
2060  ///
2061  /// By default, performs semantic analysis to build the new statement.
2062  /// Subclasses may override this routine to provide different behavior.
2064  bool IsIfExists,
2065  NestedNameSpecifierLoc QualifierLoc,
2066  DeclarationNameInfo NameInfo,
2067  Stmt *Nested) {
2068  return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2069  QualifierLoc, NameInfo, Nested);
2070  }
2071 
2072  /// Attach body to a C++0x range-based for statement.
2073  ///
2074  /// By default, performs semantic analysis to finish the new statement.
2075  /// Subclasses may override this routine to provide different behavior.
2077  return getSema().FinishCXXForRangeStmt(ForRange, Body);
2078  }
2079 
2081  Stmt *TryBlock, Stmt *Handler) {
2082  return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2083  }
2084 
2086  Stmt *Block) {
2087  return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2088  }
2089 
2091  return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2092  }
2093 
2094  /// Build a new predefined expression.
2095  ///
2096  /// By default, performs semantic analysis to build the new expression.
2097  /// Subclasses may override this routine to provide different behavior.
2100  return getSema().BuildPredefinedExpr(Loc, IK);
2101  }
2102 
2103  /// Build a new expression that references a declaration.
2104  ///
2105  /// By default, performs semantic analysis to build the new expression.
2106  /// Subclasses may override this routine to provide different behavior.
2108  LookupResult &R,
2109  bool RequiresADL) {
2110  return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2111  }
2112 
2113 
2114  /// Build a new expression that references a declaration.
2115  ///
2116  /// By default, performs semantic analysis to build the new expression.
2117  /// Subclasses may override this routine to provide different behavior.
2119  ValueDecl *VD,
2120  const DeclarationNameInfo &NameInfo,
2121  TemplateArgumentListInfo *TemplateArgs) {
2122  CXXScopeSpec SS;
2123  SS.Adopt(QualifierLoc);
2124 
2125  // FIXME: loses template args.
2126 
2127  return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD);
2128  }
2129 
2130  /// Build a new expression in parentheses.
2131  ///
2132  /// By default, performs semantic analysis to build the new expression.
2133  /// Subclasses may override this routine to provide different behavior.
2135  SourceLocation RParen) {
2136  return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2137  }
2138 
2139  /// Build a new pseudo-destructor expression.
2140  ///
2141  /// By default, performs semantic analysis to build the new expression.
2142  /// Subclasses may override this routine to provide different behavior.
2143  ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base,
2144  SourceLocation OperatorLoc,
2145  bool isArrow,
2146  CXXScopeSpec &SS,
2147  TypeSourceInfo *ScopeType,
2148  SourceLocation CCLoc,
2149  SourceLocation TildeLoc,
2150  PseudoDestructorTypeStorage Destroyed);
2151 
2152  /// Build a new unary operator expression.
2153  ///
2154  /// By default, performs semantic analysis to build the new expression.
2155  /// Subclasses may override this routine to provide different behavior.
2157  UnaryOperatorKind Opc,
2158  Expr *SubExpr) {
2159  return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2160  }
2161 
2162  /// Build a new builtin offsetof expression.
2163  ///
2164  /// By default, performs semantic analysis to build the new expression.
2165  /// Subclasses may override this routine to provide different behavior.
2169  SourceLocation RParenLoc) {
2170  return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2171  RParenLoc);
2172  }
2173 
2174  /// Build a new sizeof, alignof or vec_step expression with a
2175  /// type argument.
2176  ///
2177  /// By default, performs semantic analysis to build the new expression.
2178  /// Subclasses may override this routine to provide different behavior.
2180  SourceLocation OpLoc,
2181  UnaryExprOrTypeTrait ExprKind,
2182  SourceRange R) {
2183  return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2184  }
2185 
2186  /// Build a new sizeof, alignof or vec step expression with an
2187  /// expression argument.
2188  ///
2189  /// By default, performs semantic analysis to build the new expression.
2190  /// Subclasses may override this routine to provide different behavior.
2192  UnaryExprOrTypeTrait ExprKind,
2193  SourceRange R) {
2194  ExprResult Result
2195  = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2196  if (Result.isInvalid())
2197  return ExprError();
2198 
2199  return Result;
2200  }
2201 
2202  /// Build a new array subscript expression.
2203  ///
2204  /// By default, performs semantic analysis to build the new expression.
2205  /// Subclasses may override this routine to provide different behavior.
2207  SourceLocation LBracketLoc,
2208  Expr *RHS,
2209  SourceLocation RBracketLoc) {
2210  return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2211  LBracketLoc, RHS,
2212  RBracketLoc);
2213  }
2214 
2215  /// Build a new array section expression.
2216  ///
2217  /// By default, performs semantic analysis to build the new expression.
2218  /// Subclasses may override this routine to provide different behavior.
2220  Expr *LowerBound,
2221  SourceLocation ColonLoc, Expr *Length,
2222  SourceLocation RBracketLoc) {
2223  return getSema().ActOnOMPArraySectionExpr(Base, LBracketLoc, LowerBound,
2224  ColonLoc, Length, RBracketLoc);
2225  }
2226 
2227  /// Build a new call expression.
2228  ///
2229  /// By default, performs semantic analysis to build the new expression.
2230  /// Subclasses may override this routine to provide different behavior.
2232  MultiExprArg Args,
2233  SourceLocation RParenLoc,
2234  Expr *ExecConfig = nullptr) {
2235  return getSema().ActOnCallExpr(/*Scope=*/nullptr, Callee, LParenLoc,
2236  Args, RParenLoc, ExecConfig);
2237  }
2238 
2239  /// Build a new member access expression.
2240  ///
2241  /// By default, performs semantic analysis to build the new expression.
2242  /// Subclasses may override this routine to provide different behavior.
2244  bool isArrow,
2245  NestedNameSpecifierLoc QualifierLoc,
2246  SourceLocation TemplateKWLoc,
2247  const DeclarationNameInfo &MemberNameInfo,
2248  ValueDecl *Member,
2249  NamedDecl *FoundDecl,
2250  const TemplateArgumentListInfo *ExplicitTemplateArgs,
2251  NamedDecl *FirstQualifierInScope) {
2252  ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base,
2253  isArrow);
2254  if (!Member->getDeclName()) {
2255  // We have a reference to an unnamed field. This is always the
2256  // base of an anonymous struct/union member access, i.e. the
2257  // field is always of record type.
2258  assert(Member->getType()->isRecordType() &&
2259  "unnamed member not of record type?");
2260 
2261  BaseResult =
2262  getSema().PerformObjectMemberConversion(BaseResult.get(),
2263  QualifierLoc.getNestedNameSpecifier(),
2264  FoundDecl, Member);
2265  if (BaseResult.isInvalid())
2266  return ExprError();
2267  Base = BaseResult.get();
2268 
2269  CXXScopeSpec EmptySS;
2270  return getSema().BuildFieldReferenceExpr(
2271  Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
2272  DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()), MemberNameInfo);
2273  }
2274 
2275  CXXScopeSpec SS;
2276  SS.Adopt(QualifierLoc);
2277 
2278  Base = BaseResult.get();
2279  QualType BaseType = Base->getType();
2280 
2281  if (isArrow && !BaseType->isPointerType())
2282  return ExprError();
2283 
2284  // FIXME: this involves duplicating earlier analysis in a lot of
2285  // cases; we should avoid this when possible.
2286  LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
2287  R.addDecl(FoundDecl);
2288  R.resolveKind();
2289 
2290  return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
2291  SS, TemplateKWLoc,
2292  FirstQualifierInScope,
2293  R, ExplicitTemplateArgs,
2294  /*S*/nullptr);
2295  }
2296 
2297  /// Build a new binary operator expression.
2298  ///
2299  /// By default, performs semantic analysis to build the new expression.
2300  /// Subclasses may override this routine to provide different behavior.
2302  BinaryOperatorKind Opc,
2303  Expr *LHS, Expr *RHS) {
2304  return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS);
2305  }
2306 
2307  /// Build a new conditional operator expression.
2308  ///
2309  /// By default, performs semantic analysis to build the new expression.
2310  /// Subclasses may override this routine to provide different behavior.
2312  SourceLocation QuestionLoc,
2313  Expr *LHS,
2315  Expr *RHS) {
2316  return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
2317  LHS, RHS);
2318  }
2319 
2320  /// Build a new C-style cast expression.
2321  ///
2322  /// By default, performs semantic analysis to build the new expression.
2323  /// Subclasses may override this routine to provide different behavior.
2325  TypeSourceInfo *TInfo,
2326  SourceLocation RParenLoc,
2327  Expr *SubExpr) {
2328  return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
2329  SubExpr);
2330  }
2331 
2332  /// Build a new compound literal expression.
2333  ///
2334  /// By default, performs semantic analysis to build the new expression.
2335  /// Subclasses may override this routine to provide different behavior.
2337  TypeSourceInfo *TInfo,
2338  SourceLocation RParenLoc,
2339  Expr *Init) {
2340  return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
2341  Init);
2342  }
2343 
2344  /// Build a new extended vector element access expression.
2345  ///
2346  /// By default, performs semantic analysis to build the new expression.
2347  /// Subclasses may override this routine to provide different behavior.
2349  SourceLocation OpLoc,
2350  SourceLocation AccessorLoc,
2351  IdentifierInfo &Accessor) {
2352 
2353  CXXScopeSpec SS;
2354  DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
2355  return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
2356  OpLoc, /*IsArrow*/ false,
2357  SS, SourceLocation(),
2358  /*FirstQualifierInScope*/ nullptr,
2359  NameInfo,
2360  /* TemplateArgs */ nullptr,
2361  /*S*/ nullptr);
2362  }
2363 
2364  /// Build a new initializer list expression.
2365  ///
2366  /// By default, performs semantic analysis to build the new expression.
2367  /// Subclasses may override this routine to provide different behavior.
2370  SourceLocation RBraceLoc) {
2371  return SemaRef.ActOnInitList(LBraceLoc, Inits, RBraceLoc);
2372  }
2373 
2374  /// Build a new designated initializer expression.
2375  ///
2376  /// By default, performs semantic analysis to build the new expression.
2377  /// Subclasses may override this routine to provide different behavior.
2379  MultiExprArg ArrayExprs,
2380  SourceLocation EqualOrColonLoc,
2381  bool GNUSyntax,
2382  Expr *Init) {
2383  ExprResult Result
2384  = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
2385  Init);
2386  if (Result.isInvalid())
2387  return ExprError();
2388 
2389  return Result;
2390  }
2391 
2392  /// Build a new value-initialized expression.
2393  ///
2394  /// By default, builds the implicit value initialization without performing
2395  /// any semantic analysis. Subclasses may override this routine to provide
2396  /// different behavior.
2398  return new (SemaRef.Context) ImplicitValueInitExpr(T);
2399  }
2400 
2401  /// Build a new \c va_arg expression.
2402  ///
2403  /// By default, performs semantic analysis to build the new expression.
2404  /// Subclasses may override this routine to provide different behavior.
2406  Expr *SubExpr, TypeSourceInfo *TInfo,
2407  SourceLocation RParenLoc) {
2408  return getSema().BuildVAArgExpr(BuiltinLoc,
2409  SubExpr, TInfo,
2410  RParenLoc);
2411  }
2412 
2413  /// Build a new expression list in parentheses.
2414  ///
2415  /// By default, performs semantic analysis to build the new expression.
2416  /// Subclasses may override this routine to provide different behavior.
2418  MultiExprArg SubExprs,
2419  SourceLocation RParenLoc) {
2420  return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
2421  }
2422 
2423  /// Build a new address-of-label expression.
2424  ///
2425  /// By default, performs semantic analysis, using the name of the label
2426  /// rather than attempting to map the label statement itself.
2427  /// Subclasses may override this routine to provide different behavior.
2429  SourceLocation LabelLoc, LabelDecl *Label) {
2430  return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
2431  }
2432 
2433  /// Build a new GNU statement expression.
2434  ///
2435  /// By default, performs semantic analysis to build the new expression.
2436  /// Subclasses may override this routine to provide different behavior.
2438  Stmt *SubStmt,
2439  SourceLocation RParenLoc) {
2440  return getSema().ActOnStmtExpr(LParenLoc, SubStmt, RParenLoc);
2441  }
2442 
2443  /// Build a new __builtin_choose_expr expression.
2444  ///
2445  /// By default, performs semantic analysis to build the new expression.
2446  /// Subclasses may override this routine to provide different behavior.
2448  Expr *Cond, Expr *LHS, Expr *RHS,
2449  SourceLocation RParenLoc) {
2450  return SemaRef.ActOnChooseExpr(BuiltinLoc,
2451  Cond, LHS, RHS,
2452  RParenLoc);
2453  }
2454 
2455  /// Build a new generic selection expression.
2456  ///
2457  /// By default, performs semantic analysis to build the new expression.
2458  /// Subclasses may override this routine to provide different behavior.
2460  SourceLocation DefaultLoc,
2461  SourceLocation RParenLoc,
2462  Expr *ControllingExpr,
2464  ArrayRef<Expr *> Exprs) {
2465  return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
2466  ControllingExpr, Types, Exprs);
2467  }
2468 
2469  /// Build a new overloaded operator call expression.
2470  ///
2471  /// By default, performs semantic analysis to build the new expression.
2472  /// The semantic analysis provides the behavior of template instantiation,
2473  /// copying with transformations that turn what looks like an overloaded
2474  /// operator call into a use of a builtin operator, performing
2475  /// argument-dependent lookup, etc. Subclasses may override this routine to
2476  /// provide different behavior.
2477  ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
2478  SourceLocation OpLoc,
2479  Expr *Callee,
2480  Expr *First,
2481  Expr *Second);
2482 
2483  /// Build a new C++ "named" cast expression, such as static_cast or
2484  /// reinterpret_cast.
2485  ///
2486  /// By default, this routine dispatches to one of the more-specific routines
2487  /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
2488  /// Subclasses may override this routine to provide different behavior.
2490  Stmt::StmtClass Class,
2491  SourceLocation LAngleLoc,
2492  TypeSourceInfo *TInfo,
2493  SourceLocation RAngleLoc,
2494  SourceLocation LParenLoc,
2495  Expr *SubExpr,
2496  SourceLocation RParenLoc) {
2497  switch (Class) {
2498  case Stmt::CXXStaticCastExprClass:
2499  return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
2500  RAngleLoc, LParenLoc,
2501  SubExpr, RParenLoc);
2502 
2503  case Stmt::CXXDynamicCastExprClass:
2504  return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
2505  RAngleLoc, LParenLoc,
2506  SubExpr, RParenLoc);
2507 
2508  case Stmt::CXXReinterpretCastExprClass:
2509  return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
2510  RAngleLoc, LParenLoc,
2511  SubExpr,
2512  RParenLoc);
2513 
2514  case Stmt::CXXConstCastExprClass:
2515  return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
2516  RAngleLoc, LParenLoc,
2517  SubExpr, RParenLoc);
2518 
2519  default:
2520  llvm_unreachable("Invalid C++ named cast");
2521  }
2522  }
2523 
2524  /// Build a new C++ static_cast expression.
2525  ///
2526  /// By default, performs semantic analysis to build the new expression.
2527  /// Subclasses may override this routine to provide different behavior.
2529  SourceLocation LAngleLoc,
2530  TypeSourceInfo *TInfo,
2531  SourceLocation RAngleLoc,
2532  SourceLocation LParenLoc,
2533  Expr *SubExpr,
2534  SourceLocation RParenLoc) {
2535  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
2536  TInfo, SubExpr,
2537  SourceRange(LAngleLoc, RAngleLoc),
2538  SourceRange(LParenLoc, RParenLoc));
2539  }
2540 
2541  /// Build a new C++ dynamic_cast expression.
2542  ///
2543  /// By default, performs semantic analysis to build the new expression.
2544  /// Subclasses may override this routine to provide different behavior.
2546  SourceLocation LAngleLoc,
2547  TypeSourceInfo *TInfo,
2548  SourceLocation RAngleLoc,
2549  SourceLocation LParenLoc,
2550  Expr *SubExpr,
2551  SourceLocation RParenLoc) {
2552  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
2553  TInfo, SubExpr,
2554  SourceRange(LAngleLoc, RAngleLoc),
2555  SourceRange(LParenLoc, RParenLoc));
2556  }
2557 
2558  /// Build a new C++ reinterpret_cast expression.
2559  ///
2560  /// By default, performs semantic analysis to build the new expression.
2561  /// Subclasses may override this routine to provide different behavior.
2563  SourceLocation LAngleLoc,
2564  TypeSourceInfo *TInfo,
2565  SourceLocation RAngleLoc,
2566  SourceLocation LParenLoc,
2567  Expr *SubExpr,
2568  SourceLocation RParenLoc) {
2569  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
2570  TInfo, SubExpr,
2571  SourceRange(LAngleLoc, RAngleLoc),
2572  SourceRange(LParenLoc, RParenLoc));
2573  }
2574 
2575  /// Build a new C++ const_cast expression.
2576  ///
2577  /// By default, performs semantic analysis to build the new expression.
2578  /// Subclasses may override this routine to provide different behavior.
2580  SourceLocation LAngleLoc,
2581  TypeSourceInfo *TInfo,
2582  SourceLocation RAngleLoc,
2583  SourceLocation LParenLoc,
2584  Expr *SubExpr,
2585  SourceLocation RParenLoc) {
2586  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
2587  TInfo, SubExpr,
2588  SourceRange(LAngleLoc, RAngleLoc),
2589  SourceRange(LParenLoc, RParenLoc));
2590  }
2591 
2592  /// Build a new C++ functional-style cast expression.
2593  ///
2594  /// By default, performs semantic analysis to build the new expression.
2595  /// Subclasses may override this routine to provide different behavior.
2597  SourceLocation LParenLoc,
2598  Expr *Sub,
2599  SourceLocation RParenLoc,
2600  bool ListInitialization) {
2601  return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
2602  MultiExprArg(&Sub, 1), RParenLoc,
2603  ListInitialization);
2604  }
2605 
2606  /// Build a new C++ typeid(type) expression.
2607  ///
2608  /// By default, performs semantic analysis to build the new expression.
2609  /// Subclasses may override this routine to provide different behavior.
2611  SourceLocation TypeidLoc,
2612  TypeSourceInfo *Operand,
2613  SourceLocation RParenLoc) {
2614  return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
2615  RParenLoc);
2616  }
2617 
2618 
2619  /// Build a new C++ typeid(expr) expression.
2620  ///
2621  /// By default, performs semantic analysis to build the new expression.
2622  /// Subclasses may override this routine to provide different behavior.
2624  SourceLocation TypeidLoc,
2625  Expr *Operand,
2626  SourceLocation RParenLoc) {
2627  return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
2628  RParenLoc);
2629  }
2630 
2631  /// Build a new C++ __uuidof(type) expression.
2632  ///
2633  /// By default, performs semantic analysis to build the new expression.
2634  /// Subclasses may override this routine to provide different behavior.
2636  SourceLocation TypeidLoc,
2637  TypeSourceInfo *Operand,
2638  SourceLocation RParenLoc) {
2639  return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand,
2640  RParenLoc);
2641  }
2642 
2643  /// Build a new C++ __uuidof(expr) expression.
2644  ///
2645  /// By default, performs semantic analysis to build the new expression.
2646  /// Subclasses may override this routine to provide different behavior.
2648  SourceLocation TypeidLoc,
2649  Expr *Operand,
2650  SourceLocation RParenLoc) {
2651  return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand,
2652  RParenLoc);
2653  }
2654 
2655  /// Build a new C++ "this" expression.
2656  ///
2657  /// By default, builds a new "this" expression without performing any
2658  /// semantic analysis. Subclasses may override this routine to provide
2659  /// different behavior.
2661  QualType ThisType,
2662  bool isImplicit) {
2663  getSema().CheckCXXThisCapture(ThisLoc);
2664  return new (getSema().Context) CXXThisExpr(ThisLoc, ThisType, isImplicit);
2665  }
2666 
2667  /// Build a new C++ throw expression.
2668  ///
2669  /// By default, performs semantic analysis to build the new expression.
2670  /// Subclasses may override this routine to provide different behavior.
2672  bool IsThrownVariableInScope) {
2673  return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
2674  }
2675 
2676  /// Build a new C++ default-argument expression.
2677  ///
2678  /// By default, builds a new default-argument expression, which does not
2679  /// require any semantic analysis. Subclasses may override this routine to
2680  /// provide different behavior.
2682  ParmVarDecl *Param) {
2683  return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param);
2684  }
2685 
2686  /// Build a new C++11 default-initialization expression.
2687  ///
2688  /// By default, builds a new default field initialization expression, which
2689  /// does not require any semantic analysis. Subclasses may override this
2690  /// routine to provide different behavior.
2692  FieldDecl *Field) {
2693  return CXXDefaultInitExpr::Create(getSema().Context, Loc, Field);
2694  }
2695 
2696  /// Build a new C++ zero-initialization expression.
2697  ///
2698  /// By default, performs semantic analysis to build the new expression.
2699  /// Subclasses may override this routine to provide different behavior.
2701  SourceLocation LParenLoc,
2702  SourceLocation RParenLoc) {
2703  return getSema().BuildCXXTypeConstructExpr(
2704  TSInfo, LParenLoc, None, RParenLoc, /*ListInitialization=*/false);
2705  }
2706 
2707  /// Build a new C++ "new" expression.
2708  ///
2709  /// By default, performs semantic analysis to build the new expression.
2710  /// Subclasses may override this routine to provide different behavior.
2712  bool UseGlobal,
2713  SourceLocation PlacementLParen,
2714  MultiExprArg PlacementArgs,
2715  SourceLocation PlacementRParen,
2716  SourceRange TypeIdParens,
2717  QualType AllocatedType,
2718  TypeSourceInfo *AllocatedTypeInfo,
2719  Expr *ArraySize,
2720  SourceRange DirectInitRange,
2721  Expr *Initializer) {
2722  return getSema().BuildCXXNew(StartLoc, UseGlobal,
2723  PlacementLParen,
2724  PlacementArgs,
2725  PlacementRParen,
2726  TypeIdParens,
2727  AllocatedType,
2728  AllocatedTypeInfo,
2729  ArraySize,
2730  DirectInitRange,
2731  Initializer);
2732  }
2733 
2734  /// Build a new C++ "delete" expression.
2735  ///
2736  /// By default, performs semantic analysis to build the new expression.
2737  /// Subclasses may override this routine to provide different behavior.
2739  bool IsGlobalDelete,
2740  bool IsArrayForm,
2741  Expr *Operand) {
2742  return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
2743  Operand);
2744  }
2745 
2746  /// Build a new type trait expression.
2747  ///
2748  /// By default, performs semantic analysis to build the new expression.
2749  /// Subclasses may override this routine to provide different behavior.
2751  SourceLocation StartLoc,
2753  SourceLocation RParenLoc) {
2754  return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
2755  }
2756 
2757  /// Build a new array type trait expression.
2758  ///
2759  /// By default, performs semantic analysis to build the new expression.
2760  /// Subclasses may override this routine to provide different behavior.
2762  SourceLocation StartLoc,
2763  TypeSourceInfo *TSInfo,
2764  Expr *DimExpr,
2765  SourceLocation RParenLoc) {
2766  return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
2767  }
2768 
2769  /// Build a new expression trait expression.
2770  ///
2771  /// By default, performs semantic analysis to build the new expression.
2772  /// Subclasses may override this routine to provide different behavior.
2774  SourceLocation StartLoc,
2775  Expr *Queried,
2776  SourceLocation RParenLoc) {
2777  return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
2778  }
2779 
2780  /// Build a new (previously unresolved) declaration reference
2781  /// expression.
2782  ///
2783  /// By default, performs semantic analysis to build the new expression.
2784  /// Subclasses may override this routine to provide different behavior.
2786  NestedNameSpecifierLoc QualifierLoc,
2787  SourceLocation TemplateKWLoc,
2788  const DeclarationNameInfo &NameInfo,
2789  const TemplateArgumentListInfo *TemplateArgs,
2790  bool IsAddressOfOperand,
2791  TypeSourceInfo **RecoveryTSI) {
2792  CXXScopeSpec SS;
2793  SS.Adopt(QualifierLoc);
2794 
2795  if (TemplateArgs || TemplateKWLoc.isValid())
2796  return getSema().BuildQualifiedTemplateIdExpr(SS, TemplateKWLoc, NameInfo,
2797  TemplateArgs);
2798 
2799  return getSema().BuildQualifiedDeclarationNameExpr(
2800  SS, NameInfo, IsAddressOfOperand, /*S*/nullptr, RecoveryTSI);
2801  }
2802 
2803  /// Build a new template-id expression.
2804  ///
2805  /// By default, performs semantic analysis to build the new expression.
2806  /// Subclasses may override this routine to provide different behavior.
2808  SourceLocation TemplateKWLoc,
2809  LookupResult &R,
2810  bool RequiresADL,
2811  const TemplateArgumentListInfo *TemplateArgs) {
2812  return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
2813  TemplateArgs);
2814  }
2815 
2816  /// Build a new object-construction expression.
2817  ///
2818  /// By default, performs semantic analysis to build the new expression.
2819  /// Subclasses may override this routine to provide different behavior.
2821  SourceLocation Loc,
2822  CXXConstructorDecl *Constructor,
2823  bool IsElidable,
2824  MultiExprArg Args,
2825  bool HadMultipleCandidates,
2826  bool ListInitialization,
2827  bool StdInitListInitialization,
2828  bool RequiresZeroInit,
2829  CXXConstructExpr::ConstructionKind ConstructKind,
2830  SourceRange ParenRange) {
2831  SmallVector<Expr*, 8> ConvertedArgs;
2832  if (getSema().CompleteConstructorCall(Constructor, Args, Loc,
2833  ConvertedArgs))
2834  return ExprError();
2835 
2836  return getSema().BuildCXXConstructExpr(Loc, T, Constructor,
2837  IsElidable,
2838  ConvertedArgs,
2839  HadMultipleCandidates,
2840  ListInitialization,
2841  StdInitListInitialization,
2842  RequiresZeroInit, ConstructKind,
2843  ParenRange);
2844  }
2845 
2846  /// Build a new implicit construction via inherited constructor
2847  /// expression.
2849  CXXConstructorDecl *Constructor,
2850  bool ConstructsVBase,
2851  bool InheritedFromVBase) {
2852  return new (getSema().Context) CXXInheritedCtorInitExpr(
2853  Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
2854  }
2855 
2856  /// Build a new object-construction expression.
2857  ///
2858  /// By default, performs semantic analysis to build the new expression.
2859  /// Subclasses may override this routine to provide different behavior.
2861  SourceLocation LParenOrBraceLoc,
2862  MultiExprArg Args,
2863  SourceLocation RParenOrBraceLoc,
2864  bool ListInitialization) {
2865  return getSema().BuildCXXTypeConstructExpr(
2866  TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
2867  }
2868 
2869  /// Build a new object-construction expression.
2870  ///
2871  /// By default, performs semantic analysis to build the new expression.
2872  /// Subclasses may override this routine to provide different behavior.
2874  SourceLocation LParenLoc,
2875  MultiExprArg Args,
2876  SourceLocation RParenLoc,
2877  bool ListInitialization) {
2878  return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
2879  RParenLoc, ListInitialization);
2880  }
2881 
2882  /// Build a new member reference expression.
2883  ///
2884  /// By default, performs semantic analysis to build the new expression.
2885  /// Subclasses may override this routine to provide different behavior.
2887  QualType BaseType,
2888  bool IsArrow,
2889  SourceLocation OperatorLoc,
2890  NestedNameSpecifierLoc QualifierLoc,
2891  SourceLocation TemplateKWLoc,
2892  NamedDecl *FirstQualifierInScope,
2893  const DeclarationNameInfo &MemberNameInfo,
2894  const TemplateArgumentListInfo *TemplateArgs) {
2895  CXXScopeSpec SS;
2896  SS.Adopt(QualifierLoc);
2897 
2898  return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
2899  OperatorLoc, IsArrow,
2900  SS, TemplateKWLoc,
2901  FirstQualifierInScope,
2902  MemberNameInfo,
2903  TemplateArgs, /*S*/nullptr);
2904  }
2905 
2906  /// Build a new member reference expression.
2907  ///
2908  /// By default, performs semantic analysis to build the new expression.
2909  /// Subclasses may override this routine to provide different behavior.
2911  SourceLocation OperatorLoc,
2912  bool IsArrow,
2913  NestedNameSpecifierLoc QualifierLoc,
2914  SourceLocation TemplateKWLoc,
2915  NamedDecl *FirstQualifierInScope,
2916  LookupResult &R,
2917  const TemplateArgumentListInfo *TemplateArgs) {
2918  CXXScopeSpec SS;
2919  SS.Adopt(QualifierLoc);
2920 
2921  return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
2922  OperatorLoc, IsArrow,
2923  SS, TemplateKWLoc,
2924  FirstQualifierInScope,
2925  R, TemplateArgs, /*S*/nullptr);
2926  }
2927 
2928  /// Build a new noexcept expression.
2929  ///
2930  /// By default, performs semantic analysis to build the new expression.
2931  /// Subclasses may override this routine to provide different behavior.
2933  return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
2934  }
2935 
2936  /// Build a new expression to compute the length of a parameter pack.
2938  NamedDecl *Pack,
2939  SourceLocation PackLoc,
2940  SourceLocation RParenLoc,
2941  Optional<unsigned> Length,
2942  ArrayRef<TemplateArgument> PartialArgs) {
2943  return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
2944  RParenLoc, Length, PartialArgs);
2945  }
2946 
2947  /// Build a new Objective-C boxed expression.
2948  ///
2949  /// By default, performs semantic analysis to build the new expression.
2950  /// Subclasses may override this routine to provide different behavior.
2952  return getSema().BuildObjCBoxedExpr(SR, ValueExpr);
2953  }
2954 
2955  /// Build a new Objective-C array literal.
2956  ///
2957  /// By default, performs semantic analysis to build the new expression.
2958  /// Subclasses may override this routine to provide different behavior.
2960  Expr **Elements, unsigned NumElements) {
2961  return getSema().BuildObjCArrayLiteral(Range,
2962  MultiExprArg(Elements, NumElements));
2963  }
2964 
2966  Expr *Base, Expr *Key,
2967  ObjCMethodDecl *getterMethod,
2968  ObjCMethodDecl *setterMethod) {
2969  return getSema().BuildObjCSubscriptExpression(RB, Base, Key,
2970  getterMethod, setterMethod);
2971  }
2972 
2973  /// Build a new Objective-C dictionary literal.
2974  ///
2975  /// By default, performs semantic analysis to build the new expression.
2976  /// Subclasses may override this routine to provide different behavior.
2979  return getSema().BuildObjCDictionaryLiteral(Range, Elements);
2980  }
2981 
2982  /// Build a new Objective-C \@encode expression.
2983  ///
2984  /// By default, performs semantic analysis to build the new expression.
2985  /// Subclasses may override this routine to provide different behavior.
2987  TypeSourceInfo *EncodeTypeInfo,
2988  SourceLocation RParenLoc) {
2989  return SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo, RParenLoc);
2990  }
2991 
2992  /// Build a new Objective-C class message.
2994  Selector Sel,
2995  ArrayRef<SourceLocation> SelectorLocs,
2996  ObjCMethodDecl *Method,
2997  SourceLocation LBracLoc,
2998  MultiExprArg Args,
2999  SourceLocation RBracLoc) {
3000  return SemaRef.BuildClassMessage(ReceiverTypeInfo,
3001  ReceiverTypeInfo->getType(),
3002  /*SuperLoc=*/SourceLocation(),
3003  Sel, Method, LBracLoc, SelectorLocs,
3004  RBracLoc, Args);
3005  }
3006 
3007  /// Build a new Objective-C instance message.
3009  Selector Sel,
3010  ArrayRef<SourceLocation> SelectorLocs,
3011  ObjCMethodDecl *Method,
3012  SourceLocation LBracLoc,
3013  MultiExprArg Args,
3014  SourceLocation RBracLoc) {
3015  return SemaRef.BuildInstanceMessage(Receiver,
3016  Receiver->getType(),
3017  /*SuperLoc=*/SourceLocation(),
3018  Sel, Method, LBracLoc, SelectorLocs,
3019  RBracLoc, Args);
3020  }
3021 
3022  /// Build a new Objective-C instance/class message to 'super'.
3024  Selector Sel,
3025  ArrayRef<SourceLocation> SelectorLocs,
3026  QualType SuperType,
3027  ObjCMethodDecl *Method,
3028  SourceLocation LBracLoc,
3029  MultiExprArg Args,
3030  SourceLocation RBracLoc) {
3031  return Method->isInstanceMethod() ? SemaRef.BuildInstanceMessage(nullptr,
3032  SuperType,
3033  SuperLoc,
3034  Sel, Method, LBracLoc, SelectorLocs,
3035  RBracLoc, Args)
3036  : SemaRef.BuildClassMessage(nullptr,
3037  SuperType,
3038  SuperLoc,
3039  Sel, Method, LBracLoc, SelectorLocs,
3040  RBracLoc, Args);
3041 
3042 
3043  }
3044 
3045  /// Build a new Objective-C ivar reference expression.
3046  ///
3047  /// By default, performs semantic analysis to build the new expression.
3048  /// Subclasses may override this routine to provide different behavior.
3050  SourceLocation IvarLoc,
3051  bool IsArrow, bool IsFreeIvar) {
3052  CXXScopeSpec SS;
3053  DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3054  ExprResult Result = getSema().BuildMemberReferenceExpr(
3055  BaseArg, BaseArg->getType(),
3056  /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3057  /*FirstQualifierInScope=*/nullptr, NameInfo,
3058  /*TemplateArgs=*/nullptr,
3059  /*S=*/nullptr);
3060  if (IsFreeIvar && Result.isUsable())
3061  cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3062  return Result;
3063  }
3064 
3065  /// Build a new Objective-C property reference expression.
3066  ///
3067  /// By default, performs semantic analysis to build the new expression.
3068  /// Subclasses may override this routine to provide different behavior.
3070  ObjCPropertyDecl *Property,
3071  SourceLocation PropertyLoc) {
3072  CXXScopeSpec SS;
3073  DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3074  return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3075  /*FIXME:*/PropertyLoc,
3076  /*IsArrow=*/false,
3077  SS, SourceLocation(),
3078  /*FirstQualifierInScope=*/nullptr,
3079  NameInfo,
3080  /*TemplateArgs=*/nullptr,
3081  /*S=*/nullptr);
3082  }
3083 
3084  /// Build a new Objective-C property reference expression.
3085  ///
3086  /// By default, performs semantic analysis to build the new expression.
3087  /// Subclasses may override this routine to provide different behavior.
3089  ObjCMethodDecl *Getter,
3090  ObjCMethodDecl *Setter,
3091  SourceLocation PropertyLoc) {
3092  // Since these expressions can only be value-dependent, we do not
3093  // need to perform semantic analysis again.
3094  return Owned(
3095  new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3097  PropertyLoc, Base));
3098  }
3099 
3100  /// Build a new Objective-C "isa" expression.
3101  ///
3102  /// By default, performs semantic analysis to build the new expression.
3103  /// Subclasses may override this routine to provide different behavior.
3105  SourceLocation OpLoc, bool IsArrow) {
3106  CXXScopeSpec SS;
3107  DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
3108  return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3109  OpLoc, IsArrow,
3110  SS, SourceLocation(),
3111  /*FirstQualifierInScope=*/nullptr,
3112  NameInfo,
3113  /*TemplateArgs=*/nullptr,
3114  /*S=*/nullptr);
3115  }
3116 
3117  /// Build a new shuffle vector expression.
3118  ///
3119  /// By default, performs semantic analysis to build the new expression.
3120  /// Subclasses may override this routine to provide different behavior.
3122  MultiExprArg SubExprs,
3123  SourceLocation RParenLoc) {
3124  // Find the declaration for __builtin_shufflevector
3125  const IdentifierInfo &Name
3126  = SemaRef.Context.Idents.get("__builtin_shufflevector");
3128  DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
3129  assert(!Lookup.empty() && "No __builtin_shufflevector?");
3130 
3131  // Build a reference to the __builtin_shufflevector builtin
3132  FunctionDecl *Builtin = cast<FunctionDecl>(Lookup.front());
3133  Expr *Callee = new (SemaRef.Context)
3134  DeclRefExpr(SemaRef.Context, Builtin, false,
3135  SemaRef.Context.BuiltinFnTy, VK_RValue, BuiltinLoc);
3136  QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
3137  Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
3138  CK_BuiltinFnToFnPtr).get();
3139 
3140  // Build the CallExpr
3141  ExprResult TheCall = CallExpr::Create(
3142  SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
3143  Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc);
3144 
3145  // Type-check the __builtin_shufflevector expression.
3146  return SemaRef.SemaBuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
3147  }
3148 
3149  /// Build a new convert vector expression.
3151  Expr *SrcExpr, TypeSourceInfo *DstTInfo,
3152  SourceLocation RParenLoc) {
3153  return SemaRef.SemaConvertVectorExpr(SrcExpr, DstTInfo,
3154  BuiltinLoc, RParenLoc);
3155  }
3156 
3157  /// Build a new template argument pack expansion.
3158  ///
3159  /// By default, performs semantic analysis to build a new pack expansion
3160  /// for a template argument. Subclasses may override this routine to provide
3161  /// different behavior.
3163  SourceLocation EllipsisLoc,
3164  Optional<unsigned> NumExpansions) {
3165  switch (Pattern.getArgument().getKind()) {
3167  ExprResult Result
3168  = getSema().CheckPackExpansion(Pattern.getSourceExpression(),
3169  EllipsisLoc, NumExpansions);
3170  if (Result.isInvalid())
3171  return TemplateArgumentLoc();
3172 
3173  return TemplateArgumentLoc(Result.get(), Result.get());
3174  }
3175 
3178  Pattern.getArgument().getAsTemplate(),
3179  NumExpansions),
3180  Pattern.getTemplateQualifierLoc(),
3181  Pattern.getTemplateNameLoc(),
3182  EllipsisLoc);
3183 
3190  llvm_unreachable("Pack expansion pattern has no parameter packs");
3191 
3193  if (TypeSourceInfo *Expansion
3194  = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
3195  EllipsisLoc,
3196  NumExpansions))
3197  return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
3198  Expansion);
3199  break;
3200  }
3201 
3202  return TemplateArgumentLoc();
3203  }
3204 
3205  /// Build a new expression pack expansion.
3206  ///
3207  /// By default, performs semantic analysis to build a new pack expansion
3208  /// for an expression. Subclasses may override this routine to provide
3209  /// different behavior.
3211  Optional<unsigned> NumExpansions) {
3212  return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
3213  }
3214 
3215  /// Build a new C++1z fold-expression.
3216  ///
3217  /// By default, performs semantic analysis in order to build a new fold
3218  /// expression.
3220  BinaryOperatorKind Operator,
3221  SourceLocation EllipsisLoc, Expr *RHS,
3222  SourceLocation RParenLoc) {
3223  return getSema().BuildCXXFoldExpr(LParenLoc, LHS, Operator, EllipsisLoc,
3224  RHS, RParenLoc);
3225  }
3226 
3227  /// Build an empty C++1z fold-expression with the given operator.
3228  ///
3229  /// By default, produces the fallback value for the fold-expression, or
3230  /// produce an error if there is no fallback value.
3232  BinaryOperatorKind Operator) {
3233  return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
3234  }
3235 
3236  /// Build a new atomic operation expression.
3237  ///
3238  /// By default, performs semantic analysis to build the new expression.
3239  /// Subclasses may override this routine to provide different behavior.
3241  MultiExprArg SubExprs,
3242  QualType RetTy,
3244  SourceLocation RParenLoc) {
3245  // Just create the expression; there is not any interesting semantic
3246  // analysis here because we can't actually build an AtomicExpr until
3247  // we are sure it is semantically sound.
3248  return new (SemaRef.Context) AtomicExpr(BuiltinLoc, SubExprs, RetTy, Op,
3249  RParenLoc);
3250  }
3251 
3252 private:
3253  TypeLoc TransformTypeInObjectScope(TypeLoc TL,
3254  QualType ObjectType,
3255  NamedDecl *FirstQualifierInScope,
3256  CXXScopeSpec &SS);
3257 
3258  TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
3259  QualType ObjectType,
3260  NamedDecl *FirstQualifierInScope,
3261  CXXScopeSpec &SS);
3262 
3263  TypeSourceInfo *TransformTSIInObjectScope(TypeLoc TL, QualType ObjectType,
3264  NamedDecl *FirstQualifierInScope,
3265  CXXScopeSpec &SS);
3266 
3267  QualType TransformDependentNameType(TypeLocBuilder &TLB,
3269  bool DeducibleTSTContext);
3270 };
3271 
3272 template <typename Derived>
3274  if (!S)
3275  return S;
3276 
3277  switch (S->getStmtClass()) {
3278  case Stmt::NoStmtClass: break;
3279 
3280  // Transform individual statement nodes
3281 #define STMT(Node, Parent) \
3282  case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
3283 #define ABSTRACT_STMT(Node)
3284 #define EXPR(Node, Parent)
3285 #include "clang/AST/StmtNodes.inc"
3286 
3287  // Transform expressions by calling TransformExpr.
3288 #define STMT(Node, Parent)
3289 #define ABSTRACT_STMT(Stmt)
3290 #define EXPR(Node, Parent) case Stmt::Node##Class:
3291 #include "clang/AST/StmtNodes.inc"
3292  {
3293  ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
3294  if (E.isInvalid())
3295  return StmtError();
3296 
3297  return getSema().ActOnExprStmt(E, DiscardedValue);
3298  }
3299  }
3300 
3301  return S;
3302 }
3303 
3304 template<typename Derived>
3306  if (!S)
3307  return S;
3308 
3309  switch (S->getClauseKind()) {
3310  default: break;
3311  // Transform individual clause nodes
3312 #define OPENMP_CLAUSE(Name, Class) \
3313  case OMPC_ ## Name : \
3314  return getDerived().Transform ## Class(cast<Class>(S));
3315 #include "clang/Basic/OpenMPKinds.def"
3316  }
3317 
3318  return S;
3319 }
3320 
3321 
3322 template<typename Derived>
3324  if (!E)
3325  return E;
3326 
3327  switch (E->getStmtClass()) {
3328  case Stmt::NoStmtClass: break;
3329 #define STMT(Node, Parent) case Stmt::Node##Class: break;
3330 #define ABSTRACT_STMT(Stmt)
3331 #define EXPR(Node, Parent) \
3332  case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
3333 #include "clang/AST/StmtNodes.inc"
3334  }
3335 
3336  return E;
3337 }
3338 
3339 template<typename Derived>
3341  bool NotCopyInit) {
3342  // Initializers are instantiated like expressions, except that various outer
3343  // layers are stripped.
3344  if (!Init)
3345  return Init;
3346 
3347  if (auto *FE = dyn_cast<FullExpr>(Init))
3348  Init = FE->getSubExpr();
3349 
3350  if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init))
3351  Init = AIL->getCommonExpr();
3352 
3353  if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
3354  Init = MTE->GetTemporaryExpr();
3355 
3356  while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
3357  Init = Binder->getSubExpr();
3358 
3359  if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
3360  Init = ICE->getSubExprAsWritten();
3361 
3362  if (CXXStdInitializerListExpr *ILE =
3363  dyn_cast<CXXStdInitializerListExpr>(Init))
3364  return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
3365 
3366  // If this is copy-initialization, we only need to reconstruct
3367  // InitListExprs. Other forms of copy-initialization will be a no-op if
3368  // the initializer is already the right type.
3369  CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
3370  if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
3371  return getDerived().TransformExpr(Init);
3372 
3373  // Revert value-initialization back to empty parens.
3374  if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
3375  SourceRange Parens = VIE->getSourceRange();
3376  return getDerived().RebuildParenListExpr(Parens.getBegin(), None,
3377  Parens.getEnd());
3378  }
3379 
3380  // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
3381  if (isa<ImplicitValueInitExpr>(Init))
3382  return getDerived().RebuildParenListExpr(SourceLocation(), None,
3383  SourceLocation());
3384 
3385  // Revert initialization by constructor back to a parenthesized or braced list
3386  // of expressions. Any other form of initializer can just be reused directly.
3387  if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
3388  return getDerived().TransformExpr(Init);
3389 
3390  // If the initialization implicitly converted an initializer list to a
3391  // std::initializer_list object, unwrap the std::initializer_list too.
3392  if (Construct && Construct->isStdInitListInitialization())
3393  return TransformInitializer(Construct->getArg(0), NotCopyInit);
3394 
3395  // Enter a list-init context if this was list initialization.
3398  Construct->isListInitialization());
3399 
3400  SmallVector<Expr*, 8> NewArgs;
3401  bool ArgChanged = false;
3402  if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
3403  /*IsCall*/true, NewArgs, &ArgChanged))
3404  return ExprError();
3405 
3406  // If this was list initialization, revert to syntactic list form.
3407  if (Construct->isListInitialization())
3408  return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
3409  Construct->getEndLoc());
3410 
3411  // Build a ParenListExpr to represent anything else.
3412  SourceRange Parens = Construct->getParenOrBraceRange();
3413  if (Parens.isInvalid()) {
3414  // This was a variable declaration's initialization for which no initializer
3415  // was specified.
3416  assert(NewArgs.empty() &&
3417  "no parens or braces but have direct init with arguments?");
3418  return ExprEmpty();
3419  }
3420  return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
3421  Parens.getEnd());
3422 }
3423 
3424 template<typename Derived>
3426  unsigned NumInputs,
3427  bool IsCall,
3428  SmallVectorImpl<Expr *> &Outputs,
3429  bool *ArgChanged) {
3430  for (unsigned I = 0; I != NumInputs; ++I) {
3431  // If requested, drop call arguments that need to be dropped.
3432  if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
3433  if (ArgChanged)
3434  *ArgChanged = true;
3435 
3436  break;
3437  }
3438 
3439  if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
3440  Expr *Pattern = Expansion->getPattern();
3441 
3443  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
3444  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
3445 
3446  // Determine whether the set of unexpanded parameter packs can and should
3447  // be expanded.
3448  bool Expand = true;
3449  bool RetainExpansion = false;
3450  Optional<unsigned> OrigNumExpansions = Expansion->getNumExpansions();
3451  Optional<unsigned> NumExpansions = OrigNumExpansions;
3452  if (getDerived().TryExpandParameterPacks(Expansion->getEllipsisLoc(),
3453  Pattern->getSourceRange(),
3454  Unexpanded,
3455  Expand, RetainExpansion,
3456  NumExpansions))
3457  return true;
3458 
3459  if (!Expand) {
3460  // The transform has determined that we should perform a simple
3461  // transformation on the pack expansion, producing another pack
3462  // expansion.
3463  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
3464  ExprResult OutPattern = getDerived().TransformExpr(Pattern);
3465  if (OutPattern.isInvalid())
3466  return true;
3467 
3468  ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
3469  Expansion->getEllipsisLoc(),
3470  NumExpansions);
3471  if (Out.isInvalid())
3472  return true;
3473 
3474  if (ArgChanged)
3475  *ArgChanged = true;
3476  Outputs.push_back(Out.get());
3477  continue;
3478  }
3479 
3480  // Record right away that the argument was changed. This needs
3481  // to happen even if the array expands to nothing.
3482  if (ArgChanged) *ArgChanged = true;
3483 
3484  // The transform has determined that we should perform an elementwise
3485  // expansion of the pattern. Do so.
3486  for (unsigned I = 0; I != *NumExpansions; ++I) {
3487  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
3488  ExprResult Out = getDerived().TransformExpr(Pattern);
3489  if (Out.isInvalid())
3490  return true;
3491 
3492  if (Out.get()->containsUnexpandedParameterPack()) {
3493  Out = getDerived().RebuildPackExpansion(
3494  Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
3495  if (Out.isInvalid())
3496  return true;
3497  }
3498 
3499  Outputs.push_back(Out.get());
3500  }
3501 
3502  // If we're supposed to retain a pack expansion, do so by temporarily
3503  // forgetting the partially-substituted parameter pack.
3504  if (RetainExpansion) {
3505  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
3506 
3507  ExprResult Out = getDerived().TransformExpr(Pattern);
3508  if (Out.isInvalid())
3509  return true;
3510 
3511  Out = getDerived().RebuildPackExpansion(
3512  Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
3513  if (Out.isInvalid())
3514  return true;
3515 
3516  Outputs.push_back(Out.get());
3517  }
3518 
3519  continue;
3520  }
3521 
3522  ExprResult Result =
3523  IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
3524  : getDerived().TransformExpr(Inputs[I]);
3525  if (Result.isInvalid())
3526  return true;
3527 
3528  if (Result.get() != Inputs[I] && ArgChanged)
3529  *ArgChanged = true;
3530 
3531  Outputs.push_back(Result.get());
3532  }
3533 
3534  return false;
3535 }
3536 
3537 template <typename Derived>
3540  if (Var) {
3541  VarDecl *ConditionVar = cast_or_null<VarDecl>(
3542  getDerived().TransformDefinition(Var->getLocation(), Var));
3543 
3544  if (!ConditionVar)
3545  return Sema::ConditionError();
3546 
3547  return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
3548  }
3549 
3550  if (Expr) {
3551  ExprResult CondExpr = getDerived().TransformExpr(Expr);
3552 
3553  if (CondExpr.isInvalid())
3554  return Sema::ConditionError();
3555 
3556  return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind);
3557  }
3558 
3559  return Sema::ConditionResult();
3560 }
3561 
3562 template<typename Derived>
3566  QualType ObjectType,
3567  NamedDecl *FirstQualifierInScope) {
3569  for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
3570  Qualifier = Qualifier.getPrefix())
3571  Qualifiers.push_back(Qualifier);
3572 
3573  CXXScopeSpec SS;
3574  while (!Qualifiers.empty()) {
3575  NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
3577 
3578  switch (QNNS->getKind()) {
3581  Q.getLocalBeginLoc(), Q.getLocalEndLoc(), ObjectType);
3582  if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo, false,
3583  SS, FirstQualifierInScope, false))
3584  return NestedNameSpecifierLoc();
3585  }
3586  break;
3587 
3589  NamespaceDecl *NS
3590  = cast_or_null<NamespaceDecl>(
3591  getDerived().TransformDecl(
3592  Q.getLocalBeginLoc(),
3593  QNNS->getAsNamespace()));
3594  SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
3595  break;
3596  }
3597 
3599  NamespaceAliasDecl *Alias
3600  = cast_or_null<NamespaceAliasDecl>(
3601  getDerived().TransformDecl(Q.getLocalBeginLoc(),
3602  QNNS->getAsNamespaceAlias()));
3603  SS.Extend(SemaRef.Context, Alias, Q.getLocalBeginLoc(),
3604  Q.getLocalEndLoc());
3605  break;
3606  }
3607 
3609  // There is no meaningful transformation that one could perform on the
3610  // global scope.
3611  SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
3612  break;
3613 
3615  CXXRecordDecl *RD =
3616  cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
3617  SourceLocation(), QNNS->getAsRecordDecl()));
3618  SS.MakeSuper(SemaRef.Context, RD, Q.getBeginLoc(), Q.getEndLoc());
3619  break;
3620  }
3621 
3624  TypeLoc TL = TransformTypeInObjectScope(Q.getTypeLoc(), ObjectType,
3625  FirstQualifierInScope, SS);
3626 
3627  if (!TL)
3628  return NestedNameSpecifierLoc();
3629 
3630  if (TL.getType()->isDependentType() || TL.getType()->isRecordType() ||
3631  (SemaRef.getLangOpts().CPlusPlus11 &&
3632  TL.getType()->isEnumeralType())) {
3633  assert(!TL.getType().hasLocalQualifiers() &&
3634  "Can't get cv-qualifiers here");
3635  if (TL.getType()->isEnumeralType())
3636  SemaRef.Diag(TL.getBeginLoc(),
3637  diag::warn_cxx98_compat_enum_nested_name_spec);
3638  SS.Extend(SemaRef.Context, /*FIXME:*/SourceLocation(), TL,
3639  Q.getLocalEndLoc());
3640  break;
3641  }
3642  // If the nested-name-specifier is an invalid type def, don't emit an
3643  // error because a previous error should have already been emitted.
3644  TypedefTypeLoc TTL = TL.getAs<TypedefTypeLoc>();
3645  if (!TTL || !TTL.getTypedefNameDecl()->isInvalidDecl()) {
3646  SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
3647  << TL.getType() << SS.getRange();
3648  }
3649  return NestedNameSpecifierLoc();
3650  }
3651  }
3652 
3653  // The qualifier-in-scope and object type only apply to the leftmost entity.
3654  FirstQualifierInScope = nullptr;
3655  ObjectType = QualType();
3656  }
3657 
3658  // Don't rebuild the nested-name-specifier if we don't have to.
3659  if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
3660  !getDerived().AlwaysRebuild())
3661  return NNS;
3662 
3663  // If we can re-use the source-location data from the original
3664  // nested-name-specifier, do so.
3665  if (SS.location_size() == NNS.getDataLength() &&
3666  memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
3667  return NestedNameSpecifierLoc(SS.getScopeRep(), NNS.getOpaqueData());
3668 
3669  // Allocate new nested-name-specifier location information.
3670  return SS.getWithLocInContext(SemaRef.Context);
3671 }
3672 
3673 template<typename Derived>
3677  DeclarationName Name = NameInfo.getName();
3678  if (!Name)
3679  return DeclarationNameInfo();
3680 
3681  switch (Name.getNameKind()) {
3689  return NameInfo;
3690 
3692  TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
3693  TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
3694  getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
3695  if (!NewTemplate)
3696  return DeclarationNameInfo();
3697 
3698  DeclarationNameInfo NewNameInfo(NameInfo);
3699  NewNameInfo.setName(
3700  SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
3701  return NewNameInfo;
3702  }
3703 
3707  TypeSourceInfo *NewTInfo;
3708  CanQualType NewCanTy;
3709  if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
3710  NewTInfo = getDerived().TransformType(OldTInfo);
3711  if (!NewTInfo)
3712  return DeclarationNameInfo();
3713  NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
3714  }
3715  else {
3716  NewTInfo = nullptr;
3717  TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
3718  QualType NewT = getDerived().TransformType(Name.getCXXNameType());
3719  if (NewT.isNull())
3720  return DeclarationNameInfo();
3721  NewCanTy = SemaRef.Context.getCanonicalType(NewT);
3722  }
3723 
3724  DeclarationName NewName
3725  = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
3726  NewCanTy);
3727  DeclarationNameInfo NewNameInfo(NameInfo);
3728  NewNameInfo.setName(NewName);
3729  NewNameInfo.setNamedTypeInfo(NewTInfo);
3730  return NewNameInfo;
3731  }
3732  }
3733 
3734  llvm_unreachable("Unknown name kind.");
3735 }
3736 
3737 template<typename Derived>
3740  TemplateName Name,
3741  SourceLocation NameLoc,
3742  QualType ObjectType,
3743  NamedDecl *FirstQualifierInScope,
3744  bool AllowInjectedClassName) {
3746  TemplateDecl *Template = QTN->getTemplateDecl();
3747  assert(Template && "qualified template name must refer to a template");
3748 
3749  TemplateDecl *TransTemplate
3750  = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
3751  Template));
3752  if (!TransTemplate)
3753  return TemplateName();
3754 
3755  if (!getDerived().AlwaysRebuild() &&
3756  SS.getScopeRep() == QTN->getQualifier() &&
3757  TransTemplate == Template)
3758  return Name;
3759 
3760  return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
3761  TransTemplate);
3762  }
3763 
3765  if (SS.getScopeRep()) {
3766  // These apply to the scope specifier, not the template.
3767  ObjectType = QualType();
3768  FirstQualifierInScope = nullptr;
3769  }
3770 
3771  if (!getDerived().AlwaysRebuild() &&
3772  SS.getScopeRep() == DTN->getQualifier() &&
3773  ObjectType.isNull())
3774  return Name;
3775 
3776  // FIXME: Preserve the location of the "template" keyword.
3777  SourceLocation TemplateKWLoc = NameLoc;
3778 
3779  if (DTN->isIdentifier()) {
3780  return getDerived().RebuildTemplateName(SS,
3781  TemplateKWLoc,
3782  *DTN->getIdentifier(),
3783  NameLoc,
3784  ObjectType,
3785  FirstQualifierInScope,
3786  AllowInjectedClassName);
3787  }
3788 
3789  return getDerived().RebuildTemplateName(SS, TemplateKWLoc,
3790  DTN->getOperator(), NameLoc,
3791  ObjectType, AllowInjectedClassName);
3792  }
3793 
3794  if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
3795  TemplateDecl *TransTemplate
3796  = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
3797  Template));
3798  if (!TransTemplate)
3799  return TemplateName();
3800 
3801  if (!getDerived().AlwaysRebuild() &&
3802  TransTemplate == Template)
3803  return Name;
3804 
3805  return TemplateName(TransTemplate);
3806  }
3807 
3810  TemplateTemplateParmDecl *TransParam
3811  = cast_or_null<TemplateTemplateParmDecl>(
3812  getDerived().TransformDecl(NameLoc, SubstPack->getParameterPack()));
3813  if (!TransParam)
3814  return TemplateName();
3815 
3816  if (!getDerived().AlwaysRebuild() &&
3817  TransParam == SubstPack->getParameterPack())
3818  return Name;
3819 
3820  return getDerived().RebuildTemplateName(TransParam,
3821  SubstPack->getArgumentPack());
3822  }
3823 
3824  // These should be getting filtered out before they reach the AST.
3825  llvm_unreachable("overloaded function decl survived to here");
3826 }
3827 
3828 template<typename Derived>
3830  const TemplateArgument &Arg,
3831  TemplateArgumentLoc &Output) {
3832  SourceLocation Loc = getDerived().getBaseLocation();
3833  switch (Arg.getKind()) {
3835  llvm_unreachable("null template argument in TreeTransform");
3836  break;
3837 
3839  Output = TemplateArgumentLoc(Arg,
3840  SemaRef.Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc));
3841 
3842  break;
3843 
3848  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
3849  Builder.MakeTrivial(SemaRef.Context, DTN->getQualifier(), Loc);
3850  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
3851  Builder.MakeTrivial(SemaRef.Context, QTN->getQualifier(), Loc);
3852 
3853  if (Arg.getKind() == TemplateArgument::Template)
3854  Output = TemplateArgumentLoc(Arg,
3855  Builder.getWithLocInContext(SemaRef.Context),
3856  Loc);
3857  else
3858  Output = TemplateArgumentLoc(Arg,
3859  Builder.getWithLocInContext(SemaRef.Context),
3860  Loc, Loc);
3861 
3862  break;
3863  }
3864 
3866  Output = TemplateArgumentLoc(Arg, Arg.getAsExpr());
3867  break;
3868 
3874  break;
3875  }
3876 }
3877 
3878 template<typename Derived>
3880  const TemplateArgumentLoc &Input,
3881  TemplateArgumentLoc &Output, bool Uneval) {
3884  /*LambdaContextDecl=*/nullptr, /*ExprContext=*/
3886  const TemplateArgument &Arg = Input.getArgument();
3887  switch (Arg.getKind()) {
3893  llvm_unreachable("Unexpected TemplateArgument");
3894 
3895  case TemplateArgument::Type: {
3896  TypeSourceInfo *DI = Input.getTypeSourceInfo();
3897  if (!DI)
3898  DI = InventTypeSourceInfo(Input.getArgument().getAsType());
3899 
3900  DI = getDerived().TransformType(DI);
3901  if (!DI) return true;
3902 
3903  Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
3904  return false;
3905  }
3906 
3908  NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
3909  if (QualifierLoc) {
3910  QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
3911  if (!QualifierLoc)
3912  return true;
3913  }
3914 
3915  CXXScopeSpec SS;
3916  SS.Adopt(QualifierLoc);
3917  TemplateName Template
3918  = getDerived().TransformTemplateName(SS, Arg.getAsTemplate(),
3919  Input.getTemplateNameLoc());
3920  if (Template.isNull())
3921  return true;
3922 
3923  Output = TemplateArgumentLoc(TemplateArgument(Template), QualifierLoc,
3924  Input.getTemplateNameLoc());
3925  return false;
3926  }
3927 
3929  llvm_unreachable("Caller should expand pack expansions");
3930 
3932  // Template argument expressions are constant expressions.
3934  getSema(), Uneval
3937 
3938  Expr *InputExpr = Input.getSourceExpression();
3939  if (!InputExpr) InputExpr = Input.getArgument().getAsExpr();
3940 
3941  ExprResult E = getDerived().TransformExpr(InputExpr);
3942  E = SemaRef.ActOnConstantExpression(E);
3943  if (E.isInvalid()) return true;
3944  Output = TemplateArgumentLoc(TemplateArgument(E.get()), E.get());
3945  return false;
3946  }
3947  }
3948 
3949  // Work around bogus GCC warning
3950  return true;
3951 }
3952 
3953 /// Iterator adaptor that invents template argument location information
3954 /// for each of the template arguments in its underlying iterator.
3955 template<typename Derived, typename InputIterator>
3957  TreeTransform<Derived> &Self;
3958  InputIterator Iter;
3959 
3960 public:
3963  typedef typename std::iterator_traits<InputIterator>::difference_type
3965  typedef std::input_iterator_tag iterator_category;
3966 
3967  class pointer {
3968  TemplateArgumentLoc Arg;
3969 
3970  public:
3971  explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
3972 
3973  const TemplateArgumentLoc *operator->() const { return &Arg; }
3974  };
3975 
3977 
3979  InputIterator Iter)
3980  : Self(Self), Iter(Iter) { }
3981 
3983  ++Iter;
3984  return *this;
3985  }
3986 
3989  ++(*this);
3990  return Old;
3991  }
3992 
3993  reference operator*() const {
3994  TemplateArgumentLoc Result;
3995  Self.InventTemplateArgumentLoc(*Iter, Result);
3996  return Result;
3997  }
3998 
3999  pointer operator->() const { return pointer(**this); }
4000 
4003  return X.Iter == Y.Iter;
4004  }
4005 
4008  return X.Iter != Y.Iter;
4009  }
4010 };
4011 
4012 template<typename Derived>
4013 template<typename InputIterator>
4015  InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
4016  bool Uneval) {
4017  for (; First != Last; ++First) {
4018  TemplateArgumentLoc Out;
4019  TemplateArgumentLoc In = *First;
4020 
4021  if (In.getArgument().getKind() == TemplateArgument::Pack) {
4022  // Unpack argument packs, which we translate them into separate
4023  // arguments.
4024  // FIXME: We could do much better if we could guarantee that the
4025  // TemplateArgumentLocInfo for the pack expansion would be usable for
4026  // all of the template arguments in the argument pack.
4027  typedef TemplateArgumentLocInventIterator<Derived,
4029  PackLocIterator;
4030  if (TransformTemplateArguments(PackLocIterator(*this,
4031  In.getArgument().pack_begin()),
4032  PackLocIterator(*this,
4033  In.getArgument().pack_end()),
4034  Outputs, Uneval))
4035  return true;
4036 
4037  continue;
4038  }
4039 
4040  if (In.getArgument().isPackExpansion()) {
4041  // We have a pack expansion, for which we will be substituting into
4042  // the pattern.
4043  SourceLocation Ellipsis;
4044  Optional<unsigned> OrigNumExpansions;
4045  TemplateArgumentLoc Pattern
4046  = getSema().getTemplateArgumentPackExpansionPattern(
4047  In, Ellipsis, OrigNumExpansions);
4048 
4050  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4051  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4052 
4053  // Determine whether the set of unexpanded parameter packs can and should
4054  // be expanded.
4055  bool Expand = true;
4056  bool RetainExpansion = false;
4057  Optional<unsigned> NumExpansions = OrigNumExpansions;
4058  if (getDerived().TryExpandParameterPacks(Ellipsis,
4059  Pattern.getSourceRange(),
4060  Unexpanded,
4061  Expand,
4062  RetainExpansion,
4063  NumExpansions))
4064  return true;
4065 
4066  if (!Expand) {
4067  // The transform has determined that we should perform a simple
4068  // transformation on the pack expansion, producing another pack
4069  // expansion.
4070  TemplateArgumentLoc OutPattern;
4071  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
4072  if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
4073  return true;
4074 
4075  Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis,
4076  NumExpansions);
4077  if (Out.getArgument().isNull())
4078  return true;
4079 
4080  Outputs.addArgument(Out);
4081  continue;
4082  }
4083 
4084  // The transform has determined that we should perform an elementwise
4085  // expansion of the pattern. Do so.
4086  for (unsigned I = 0; I != *NumExpansions; ++I) {
4087  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
4088 
4089  if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4090  return true;
4091 
4093  Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4094  OrigNumExpansions);
4095  if (Out.getArgument().isNull())
4096  return true;
4097  }
4098 
4099  Outputs.addArgument(Out);
4100  }
4101 
4102  // If we're supposed to retain a pack expansion, do so by temporarily
4103  // forgetting the partially-substituted parameter pack.
4104  if (RetainExpansion) {
4105  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4106 
4107  if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4108  return true;
4109 
4110  Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4111  OrigNumExpansions);
4112  if (Out.getArgument().isNull())
4113  return true;
4114 
4115  Outputs.addArgument(Out);
4116  }
4117 
4118  continue;
4119  }
4120 
4121  // The simple case:
4122  if (getDerived().TransformTemplateArgument(In, Out, Uneval))
4123  return true;
4124 
4125  Outputs.addArgument(Out);
4126  }
4127 
4128  return false;
4129 
4130 }
4131 
4132 //===----------------------------------------------------------------------===//
4133 // Type transformation
4134 //===----------------------------------------------------------------------===//
4135 
4136 template<typename Derived>
4138  if (getDerived().AlreadyTransformed(T))
4139  return T;
4140 
4141  // Temporary workaround. All of these transformations should
4142  // eventually turn into transformations on TypeLocs.
4143  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
4144  getDerived().getBaseLocation());
4145 
4146  TypeSourceInfo *NewDI = getDerived().TransformType(DI);
4147 
4148  if (!NewDI)
4149  return QualType();
4150 
4151  return NewDI->getType();
4152 }
4153 
4154 template<typename Derived>
4156  // Refine the base location to the type's location.
4157  TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
4158  getDerived().getBaseEntity());
4159  if (getDerived().AlreadyTransformed(DI->getType()))
4160  return DI;
4161 
4162  TypeLocBuilder TLB;
4163 
4164  TypeLoc TL = DI->getTypeLoc();
4165  TLB.reserve(TL.getFullDataSize());
4166 
4167  QualType Result = getDerived().TransformType(TLB, TL);
4168  if (Result.isNull())
4169  return nullptr;
4170 
4171  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4172 }
4173 
4174 template<typename Derived>
4175 QualType
4177  switch (T.getTypeLocClass()) {
4178 #define ABSTRACT_TYPELOC(CLASS, PARENT)
4179 #define TYPELOC(CLASS, PARENT) \
4180  case TypeLoc::CLASS: \
4181  return getDerived().Transform##CLASS##Type(TLB, \
4182  T.castAs<CLASS##TypeLoc>());
4183 #include "clang/AST/TypeLocNodes.def"
4184  }
4185 
4186  llvm_unreachable("unhandled type loc!");
4187 }
4188 
4189 template<typename Derived>
4191  if (!isa<DependentNameType>(T))
4192  return TransformType(T);
4193 
4194  if (getDerived().AlreadyTransformed(T))
4195  return T;
4196  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
4197  getDerived().getBaseLocation());
4198  TypeSourceInfo *NewDI = getDerived().TransformTypeWithDeducedTST(DI);
4199  return NewDI ? NewDI->getType() : QualType();
4200 }
4201 
4202 template<typename Derived>
4205  if (!isa<DependentNameType>(DI->getType()))
4206  return TransformType(DI);
4207 
4208  // Refine the base location to the type's location.
4209  TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
4210  getDerived().getBaseEntity());
4211  if (getDerived().AlreadyTransformed(DI->getType()))
4212  return DI;
4213 
4214  TypeLocBuilder TLB;
4215 
4216  TypeLoc TL = DI->getTypeLoc();
4217  TLB.reserve(TL.getFullDataSize());
4218 
4219  auto QTL = TL.getAs<QualifiedTypeLoc>();
4220  if (QTL)
4221  TL = QTL.getUnqualifiedLoc();
4222 
4223  auto DNTL = TL.castAs<DependentNameTypeLoc>();
4224 
4225  QualType Result = getDerived().TransformDependentNameType(
4226  TLB, DNTL, /*DeducedTSTContext*/true);
4227  if (Result.isNull())
4228  return nullptr;
4229 
4230  if (QTL) {
4231  Result = getDerived().RebuildQualifiedType(Result, QTL);
4232  if (Result.isNull())
4233  return nullptr;
4234  TLB.TypeWasModifiedSafely(Result);
4235  }
4236 
4237  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4238 }
4239 
4240 template<typename Derived>
4241 QualType
4243  QualifiedTypeLoc T) {
4244  QualType Result = getDerived().TransformType(TLB, T.getUnqualifiedLoc());
4245  if (Result.isNull())
4246  return QualType();
4247 
4248  Result = getDerived().RebuildQualifiedType(Result, T);
4249 
4250  if (Result.isNull())
4251  return QualType();
4252 
4253  // RebuildQualifiedType might have updated the type, but not in a way
4254  // that invalidates the TypeLoc. (There's no location information for
4255  // qualifiers.)
4256  TLB.TypeWasModifiedSafely(Result);
4257 
4258  return Result;
4259 }
4260 
4261 template <typename Derived>
4263  QualifiedTypeLoc TL) {
4264 
4265  SourceLocation Loc = TL.getBeginLoc();
4266  Qualifiers Quals = TL.getType().getLocalQualifiers();
4267 
4268  if (((T.getAddressSpace() != LangAS::Default &&
4269  Quals.getAddressSpace() != LangAS::Default)) &&
4270  T.getAddressSpace() != Quals.getAddressSpace()) {
4271  SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
4272  << TL.getType() << T;
4273  return QualType();
4274  }
4275 
4276  // C++ [dcl.fct]p7:
4277  // [When] adding cv-qualifications on top of the function type [...] the
4278  // cv-qualifiers are ignored.
4279  if (T->isFunctionType()) {
4280  T = SemaRef.getASTContext().getAddrSpaceQualType(T,
4281  Quals.getAddressSpace());
4282  return T;
4283  }
4284 
4285  // C++ [dcl.ref]p1:
4286  // when the cv-qualifiers are introduced through the use of a typedef-name
4287  // or decltype-specifier [...] the cv-qualifiers are ignored.
4288  // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
4289  // applied to a reference type.
4290  if (T->isReferenceType()) {
4291  // The only qualifier that applies to a reference type is restrict.
4292  if (!Quals.hasRestrict())
4293  return T;
4295  }
4296 
4297  // Suppress Objective-C lifetime qualifiers if they don't make sense for the
4298  // resulting type.
4299  if (Quals.hasObjCLifetime()) {
4300  if (!T->isObjCLifetimeType() && !T->isDependentType())
4301  Quals.removeObjCLifetime();
4302  else if (T.getObjCLifetime()) {
4303  // Objective-C ARC:
4304  // A lifetime qualifier applied to a substituted template parameter
4305  // overrides the lifetime qualifier from the template argument.
4306  const AutoType *AutoTy;
4307  if (const SubstTemplateTypeParmType *SubstTypeParam
4308  = dyn_cast<SubstTemplateTypeParmType>(T)) {
4309  QualType Replacement = SubstTypeParam->getReplacementType();
4310  Qualifiers Qs = Replacement.getQualifiers();
4311  Qs.removeObjCLifetime();
4312  Replacement = SemaRef.Context.getQualifiedType(
4313  Replacement.getUnqualifiedType(), Qs);
4314  T = SemaRef.Context.getSubstTemplateTypeParmType(
4315  SubstTypeParam->getReplacedParameter(), Replacement);
4316  } else if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
4317  // 'auto' types behave the same way as template parameters.
4318  QualType Deduced = AutoTy->getDeducedType();
4319  Qualifiers Qs = Deduced.getQualifiers();
4320  Qs.removeObjCLifetime();
4321  Deduced =
4322  SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
4323  T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
4324  AutoTy->isDependentType());
4325  } else {
4326  // Otherwise, complain about the addition of a qualifier to an
4327  // already-qualified type.
4328  // FIXME: Why is this check not in Sema::BuildQualifiedType?
4329  SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
4330  Quals.removeObjCLifetime();
4331  }
4332  }
4333  }
4334 
4335  return SemaRef.BuildQualifiedType(T, Loc, Quals);
4336 }
4337 
4338 template<typename Derived>
4339 TypeLoc
4341  QualType ObjectType,
4342  NamedDecl *UnqualLookup,
4343  CXXScopeSpec &SS) {
4344  if (getDerived().AlreadyTransformed(TL.getType()))
4345  return TL;
4346 
4347  TypeSourceInfo *TSI =
4348  TransformTSIInObjectScope(TL, ObjectType, UnqualLookup, SS);
4349  if (TSI)
4350  return TSI->getTypeLoc();
4351  return TypeLoc();
4352 }
4353 
4354 template<typename Derived>
4357  QualType ObjectType,
4358  NamedDecl *UnqualLookup,
4359  CXXScopeSpec &SS) {
4360  if (getDerived().AlreadyTransformed(TSInfo->getType()))
4361  return TSInfo;
4362 
4363  return TransformTSIInObjectScope(TSInfo->getTypeLoc(), ObjectType,
4364  UnqualLookup, SS);
4365 }
4366 
4367 template <typename Derived>
4369  TypeLoc TL, QualType ObjectType, NamedDecl *UnqualLookup,
4370  CXXScopeSpec &SS) {
4371  QualType T = TL.getType();
4372  assert(!getDerived().AlreadyTransformed(T));
4373 
4374  TypeLocBuilder TLB;
4375  QualType Result;
4376 
4377  if (isa<TemplateSpecializationType>(T)) {
4380 
4381  TemplateName Template = getDerived().TransformTemplateName(
4382  SS, SpecTL.getTypePtr()->getTemplateName(), SpecTL.getTemplateNameLoc(),
4383  ObjectType, UnqualLookup, /*AllowInjectedClassName*/true);
4384  if (Template.isNull())
4385  return nullptr;
4386 
4387  Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL,
4388  Template);
4389  } else if (isa<DependentTemplateSpecializationType>(T)) {
4392 
4393  TemplateName Template
4394  = getDerived().RebuildTemplateName(SS,
4395  SpecTL.getTemplateKeywordLoc(),
4396  *SpecTL.getTypePtr()->getIdentifier(),
4397  SpecTL.getTemplateNameLoc(),
4398  ObjectType, UnqualLookup,
4399  /*AllowInjectedClassName*/true);
4400  if (Template.isNull())
4401  return nullptr;
4402 
4403  Result = getDerived().TransformDependentTemplateSpecializationType(TLB,
4404  SpecTL,
4405  Template,
4406  SS);
4407  } else {
4408  // Nothing special needs to be done for these.
4409  Result = getDerived().TransformType(TLB, TL);
4410  }
4411 
4412  if (Result.isNull())
4413  return nullptr;
4414 
4415  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4416 }
4417 
4418 template <class TyLoc> static inline
4420  TyLoc NewT = TLB.push<TyLoc>(T.getType());
4421  NewT.setNameLoc(T.getNameLoc());
4422  return T.getType();
4423 }
4424 
4425 template<typename Derived>
4427  BuiltinTypeLoc T) {
4428  BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
4429  NewT.setBuiltinLoc(T.getBuiltinLoc());
4430  if (T.needsExtraLocalData())
4432  return T.getType();
4433 }
4434 
4435 template<typename Derived>
4437  ComplexTypeLoc T) {
4438  // FIXME: recurse?
4439  return TransformTypeSpecType(TLB, T);
4440 }
4441 
4442 template <typename Derived>
4444  AdjustedTypeLoc TL) {
4445  // Adjustments applied during transformation are handled elsewhere.
4446  return getDerived().TransformType(TLB, TL.getOriginalLoc());
4447 }
4448 
4449 template<typename Derived>
4451  DecayedTypeLoc TL) {
4452  QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
4453  if (OriginalType.isNull())
4454  return QualType();
4455 
4456  QualType Result = TL.getType();
4457  if (getDerived().AlwaysRebuild() ||
4458  OriginalType != TL.getOriginalLoc().getType())
4459  Result = SemaRef.Context.getDecayedType(OriginalType);
4460  TLB.push<DecayedTypeLoc>(Result);
4461  // Nothing to set for DecayedTypeLoc.
4462  return Result;
4463 }
4464 
4465 template<typename Derived>
4467  PointerTypeLoc TL) {
4468  QualType PointeeType
4469  = getDerived().TransformType(TLB, TL.getPointeeLoc());
4470  if (PointeeType.isNull())
4471  return QualType();
4472 
4473  QualType Result = TL.getType();
4474  if (PointeeType->getAs<ObjCObjectType>()) {
4475  // A dependent pointer type 'T *' has is being transformed such
4476  // that an Objective-C class type is being replaced for 'T'. The
4477  // resulting pointer type is an ObjCObjectPointerType, not a
4478  // PointerType.
4479  Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
4480 
4482  NewT.setStarLoc(TL.getStarLoc());
4483  return Result;
4484  }
4485 
4486  if (getDerived().AlwaysRebuild() ||
4487  PointeeType != TL.getPointeeLoc().getType()) {
4488  Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
4489  if (Result.isNull())
4490  return QualType();
4491  }
4492 
4493  // Objective-C ARC can add lifetime qualifiers to the type that we're
4494  // pointing to.
4495  TLB.TypeWasModifiedSafely(Result->getPointeeType());
4496 
4497  PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
4498  NewT.setSigilLoc(TL.getSigilLoc());
4499  return Result;
4500 }
4501 
4502 template<typename Derived>
4503 QualType
4505  BlockPointerTypeLoc TL) {
4506  QualType PointeeType
4507  = getDerived().TransformType(TLB, TL.getPointeeLoc());
4508  if (PointeeType.isNull())
4509  return QualType();
4510 
4511  QualType Result = TL.getType();
4512  if (getDerived().AlwaysRebuild() ||
4513  PointeeType != TL.getPointeeLoc().getType()) {
4514  Result = getDerived().RebuildBlockPointerType(PointeeType,
4515  TL.getSigilLoc());
4516  if (Result.isNull())
4517  return QualType();
4518  }
4519 
4520  BlockPointerTypeLoc NewT = TLB.push<BlockPointerTypeLoc>(Result);
4521  NewT.setSigilLoc(TL.getSigilLoc());
4522  return Result;
4523 }
4524 
4525 /// Transforms a reference type. Note that somewhat paradoxically we
4526 /// don't care whether the type itself is an l-value type or an r-value
4527 /// type; we only care if the type was *written* as an l-value type
4528 /// or an r-value type.
4529 template<typename Derived>
4530 QualType
4532  ReferenceTypeLoc TL) {
4533  const ReferenceType *T = TL.getTypePtr();
4534 
4535  // Note that this works with the pointee-as-written.
4536  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
4537  if (PointeeType.isNull())
4538  return QualType();
4539 
4540  QualType Result = TL.getType();
4541  if (getDerived().AlwaysRebuild() ||
4542  PointeeType != T->getPointeeTypeAsWritten()) {
4543  Result = getDerived().RebuildReferenceType(PointeeType,
4544  T->isSpelledAsLValue(),
4545  TL.getSigilLoc());
4546  if (Result.isNull())
4547  return QualType();
4548  }
4549 
4550  // Objective-C ARC can add lifetime qualifiers to the type that we're
4551  // referring to.
4554 
4555  // r-value references can be rebuilt as l-value references.
4556  ReferenceTypeLoc NewTL;
4557  if (isa<LValueReferenceType>(Result))
4558  NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
4559  else
4560  NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
4561  NewTL.setSigilLoc(TL.getSigilLoc());
4562 
4563  return Result;
4564 }
4565 
4566 template<typename Derived>
4567 QualType
4570  return TransformReferenceType(TLB, TL);
4571 }
4572 
4573 template<typename Derived>
4574 QualType
4577  return TransformReferenceType(TLB, TL);
4578 }
4579 
4580 template<typename Derived>
4581 QualType
4583  MemberPointerTypeLoc TL) {
4584  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
4585  if (PointeeType.isNull())
4586  return QualType();
4587 
4588  TypeSourceInfo* OldClsTInfo = TL.getClassTInfo();
4589  TypeSourceInfo *NewClsTInfo = nullptr;
4590  if (OldClsTInfo) {
4591  NewClsTInfo = getDerived().TransformType(OldClsTInfo);
4592  if (!NewClsTInfo)
4593  return QualType();
4594  }
4595 
4596  const MemberPointerType *T = TL.getTypePtr();
4597  QualType OldClsType = QualType(T->getClass(), 0);
4598  QualType NewClsType;
4599  if (NewClsTInfo)
4600  NewClsType = NewClsTInfo->getType();
4601  else {
4602  NewClsType = getDerived().TransformType(OldClsType);
4603  if (NewClsType.isNull())
4604  return QualType();
4605  }
4606 
4607  QualType Result = TL.getType();
4608  if (getDerived().AlwaysRebuild() ||
4609  PointeeType != T->getPointeeType() ||
4610  NewClsType != OldClsType) {
4611  Result = getDerived().RebuildMemberPointerType(PointeeType, NewClsType,
4612  TL.getStarLoc());
4613  if (Result.isNull())
4614  return QualType();
4615  }
4616 
4617  // If we had to adjust the pointee type when building a member pointer, make
4618  // sure to push TypeLoc info for it.
4619  const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
4620  if (MPT && PointeeType != MPT->getPointeeType()) {
4621  assert(isa<AdjustedType>(MPT->getPointeeType()));
4622  TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
4623  }
4624 
4625  MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(Result);
4626  NewTL.setSigilLoc(TL.getSigilLoc());
4627  NewTL.setClassTInfo(NewClsTInfo);
4628 
4629  return Result;
4630 }
4631 
4632 template<typename Derived>
4633 QualType
4635  ConstantArrayTypeLoc TL) {
4636  const ConstantArrayType *T = TL.getTypePtr();
4637  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4638  if (ElementType.isNull())
4639  return QualType();
4640 
4641  QualType Result = TL.getType();
4642  if (getDerived().AlwaysRebuild() ||
4643  ElementType != T->getElementType()) {
4644  Result = getDerived().RebuildConstantArrayType(ElementType,
4645  T->getSizeModifier(),
4646  T->getSize(),
4648  TL.getBracketsRange());
4649  if (Result.isNull())
4650  return QualType();
4651  }
4652 
4653  // We might have either a ConstantArrayType or a VariableArrayType now:
4654  // a ConstantArrayType is allowed to have an element type which is a
4655  // VariableArrayType if the type is dependent. Fortunately, all array
4656  // types have the same location layout.
4657  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4658  NewTL.setLBracketLoc(TL.getLBracketLoc());
4659  NewTL.setRBracketLoc(TL.getRBracketLoc());
4660 
4661  Expr *Size = TL.getSizeExpr();
4662  if (Size) {
4665  Size = getDerived().TransformExpr(Size).template getAs<Expr>();
4666  Size = SemaRef.ActOnConstantExpression(Size).get();
4667  }
4668  NewTL.setSizeExpr(Size);
4669 
4670  return Result;
4671 }
4672 
4673 template<typename Derived>
4675  TypeLocBuilder &TLB,
4677  const IncompleteArrayType *T = TL.getTypePtr();
4678  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4679  if (ElementType.isNull())
4680  return QualType();
4681 
4682  QualType Result = TL.getType();
4683  if (getDerived().AlwaysRebuild() ||
4684  ElementType != T->getElementType()) {
4685  Result = getDerived().RebuildIncompleteArrayType(ElementType,
4686  T->getSizeModifier(),
4688  TL.getBracketsRange());
4689  if (Result.isNull())
4690  return QualType();
4691  }
4692 
4693  IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(Result);
4694  NewTL.setLBracketLoc(TL.getLBracketLoc());
4695  NewTL.setRBracketLoc(TL.getRBracketLoc());
4696  NewTL.setSizeExpr(nullptr);
4697 
4698  return Result;
4699 }
4700 
4701 template<typename Derived>
4702 QualType
4704  VariableArrayTypeLoc TL) {
4705  const VariableArrayType *T = TL.getTypePtr();
4706  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4707  if (ElementType.isNull())
4708  return QualType();
4709 
4710  ExprResult SizeResult;
4711  {
4714  SizeResult = getDerived().TransformExpr(T->getSizeExpr());
4715  }
4716  if (SizeResult.isInvalid())
4717  return QualType();
4718  SizeResult =
4719  SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
4720  if (SizeResult.isInvalid())
4721  return QualType();
4722 
4723  Expr *Size = SizeResult.get();
4724 
4725  QualType Result = TL.getType();
4726  if (getDerived().AlwaysRebuild() ||
4727  ElementType != T->getElementType() ||
4728  Size != T->getSizeExpr()) {
4729  Result = getDerived().RebuildVariableArrayType(ElementType,
4730  T->getSizeModifier(),
4731  Size,
4733  TL.getBracketsRange());
4734  if (Result.isNull())
4735  return QualType();
4736  }
4737 
4738  // We might have constant size array now, but fortunately it has the same
4739  // location layout.
4740  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4741  NewTL.setLBracketLoc(TL.getLBracketLoc());
4742  NewTL.setRBracketLoc(TL.getRBracketLoc());
4743  NewTL.setSizeExpr(Size);
4744 
4745  return Result;
4746 }
4747 
4748 template<typename Derived>
4749 QualType
4752  const DependentSizedArrayType *T = TL.getTypePtr();
4753  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4754  if (ElementType.isNull())
4755  return QualType();
4756 
4757  // Array bounds are constant expressions.
4760 
4761  // Prefer the expression from the TypeLoc; the other may have been uniqued.
4762  Expr *origSize = TL.getSizeExpr();
4763  if (!origSize) origSize = T->getSizeExpr();
4764 
4765  ExprResult sizeResult
4766  = getDerived().TransformExpr(origSize);
4767  sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
4768  if (sizeResult.isInvalid())
4769  return QualType();
4770 
4771  Expr *size = sizeResult.get();
4772 
4773  QualType Result = TL.getType();
4774  if (getDerived().AlwaysRebuild() ||
4775  ElementType != T->getElementType() ||
4776  size != origSize) {
4777  Result = getDerived().RebuildDependentSizedArrayType(ElementType,
4778  T->getSizeModifier(),
4779  size,
4781  TL.getBracketsRange());
4782  if (Result.isNull())
4783  return QualType();
4784  }
4785 
4786  // We might have any sort of array type now, but fortunately they
4787  // all have the same location layout.
4788  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4789  NewTL.setLBracketLoc(TL.getLBracketLoc());
4790  NewTL.setRBracketLoc(TL.getRBracketLoc());
4791  NewTL.setSizeExpr(size);
4792 
4793  return Result;
4794 }
4795 
4796 template <typename Derived>
4799  const DependentVectorType *T = TL.getTypePtr();
4800  QualType ElementType = getDerived().TransformType(T->getElementType());
4801  if (ElementType.isNull())
4802  return QualType();
4803 
4806 
4807  ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
4808  Size = SemaRef.ActOnConstantExpression(Size);
4809  if (Size.isInvalid())
4810  return QualType();
4811 
4812  QualType Result = TL.getType();
4813  if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
4814  Size.get() != T->getSizeExpr()) {
4815  Result = getDerived().RebuildDependentVectorType(
4816  ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
4817  if (Result.isNull())
4818  return QualType();
4819  }
4820 
4821  // Result might be dependent or not.
4822  if (isa<DependentVectorType>(Result)) {
4823  DependentVectorTypeLoc NewTL =
4824  TLB.push<DependentVectorTypeLoc>(Result);
4825  NewTL.setNameLoc(TL.getNameLoc());
4826  } else {
4827  VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
4828  NewTL.setNameLoc(TL.getNameLoc());
4829  }
4830 
4831  return Result;
4832 }
4833 
4834 template<typename Derived>
4836  TypeLocBuilder &TLB,
4838  const DependentSizedExtVectorType *T = TL.getTypePtr();
4839 
4840  // FIXME: ext vector locs should be nested
4841  QualType ElementType = getDerived().TransformType(T->getElementType());
4842  if (ElementType.isNull())
4843  return QualType();
4844 
4845  // Vector sizes are constant expressions.
4848 
4849  ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
4850  Size = SemaRef.ActOnConstantExpression(Size);
4851  if (Size.isInvalid())
4852  return QualType();
4853 
4854  QualType Result = TL.getType();
4855  if (getDerived().AlwaysRebuild() ||
4856  ElementType != T->getElementType() ||
4857  Size.get() != T->getSizeExpr()) {
4858  Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
4859  Size.get(),
4860  T->getAttributeLoc());
4861  if (Result.isNull())
4862  return QualType();
4863  }
4864 
4865  // Result might be dependent or not.
4866  if (isa<DependentSizedExtVectorType>(Result)) {
4868  = TLB.push<DependentSizedExtVectorTypeLoc>(Result);
4869  NewTL.setNameLoc(TL.getNameLoc());
4870  } else {
4871  ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
4872  NewTL.setNameLoc(TL.getNameLoc());
4873  }
4874 
4875  return Result;
4876 }
4877 
4878 template <typename Derived>
4881  const DependentAddressSpaceType *T = TL.getTypePtr();
4882 
4883  QualType pointeeType = getDerived().TransformType(T->getPointeeType());
4884 
4885  if (pointeeType.isNull())
4886  return QualType();
4887 
4888  // Address spaces are constant expressions.
4891 
4892  ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
4893  AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
4894  if (AddrSpace.isInvalid())
4895  return QualType();
4896 
4897  QualType Result = TL.getType();
4898  if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
4899  AddrSpace.get() != T->getAddrSpaceExpr()) {
4900  Result = getDerived().RebuildDependentAddressSpaceType(
4901  pointeeType, AddrSpace.get(), T->getAttributeLoc());
4902  if (Result.isNull())
4903  return QualType();
4904  }
4905 
4906  // Result might be dependent or not.
4907  if (isa<DependentAddressSpaceType>(Result)) {
4909  TLB.push<DependentAddressSpaceTypeLoc>(Result);
4910 
4913  NewTL.setAttrNameLoc(TL.getAttrNameLoc());
4914 
4915  } else {
4916  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(
4917  Result, getDerived().getBaseLocation());
4918  TransformType(TLB, DI->getTypeLoc());
4919  }
4920 
4921  return Result;
4922 }
4923 
4924 template <typename Derived>
4926  VectorTypeLoc TL) {
4927  const VectorType *T = TL.getTypePtr();
4928  QualType ElementType = getDerived().TransformType(T->getElementType());
4929  if (ElementType.isNull())
4930  return QualType();
4931 
4932  QualType Result = TL.getType();
4933  if (getDerived().AlwaysRebuild() ||
4934  ElementType != T->getElementType()) {
4935  Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
4936  T->getVectorKind());
4937  if (Result.isNull())
4938  return QualType();
4939  }
4940 
4941  VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
4942  NewTL.setNameLoc(TL.getNameLoc());
4943 
4944  return Result;
4945 }
4946 
4947 template<typename Derived>
4949  ExtVectorTypeLoc TL) {
4950  const VectorType *T = TL.getTypePtr();
4951  QualType ElementType = getDerived().TransformType(T->getElementType());
4952  if (ElementType.isNull())
4953  return QualType();
4954 
4955  QualType Result = TL.getType();
4956  if (getDerived().AlwaysRebuild() ||
4957  ElementType != T->getElementType()) {
4958  Result = getDerived().RebuildExtVectorType(ElementType,
4959  T->getNumElements(),
4960  /*FIXME*/ SourceLocation());
4961  if (Result.isNull())
4962  return QualType();
4963  }
4964 
4965  ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
4966  NewTL.setNameLoc(TL.getNameLoc());
4967 
4968  return Result;
4969 }
4970 
4971 template <typename Derived>
4973  ParmVarDecl *OldParm, int indexAdjustment, Optional<unsigned> NumExpansions,
4974  bool ExpectParameterPack) {
4975  TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
4976  TypeSourceInfo *NewDI = nullptr;
4977 
4978  if (NumExpansions && isa<PackExpansionType>(OldDI->getType())) {
4979  // If we're substituting into a pack expansion type and we know the
4980  // length we want to expand to, just substitute for the pattern.
4981  TypeLoc OldTL = OldDI->getTypeLoc();
4982  PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
4983 
4984  TypeLocBuilder TLB;
4985  TypeLoc NewTL = OldDI->getTypeLoc();
4986  TLB.reserve(NewTL.getFullDataSize());
4987 
4988  QualType Result = getDerived().TransformType(TLB,
4989  OldExpansionTL.getPatternLoc());
4990  if (Result.isNull())
4991  return nullptr;
4992 
4993  Result = RebuildPackExpansionType(Result,
4994  OldExpansionTL.getPatternLoc().getSourceRange(),
4995  OldExpansionTL.getEllipsisLoc(),
4996  NumExpansions);
4997  if (Result.isNull())
4998  return nullptr;
4999 
5000  PackExpansionTypeLoc NewExpansionTL
5001  = TLB.push<PackExpansionTypeLoc>(Result);
5002  NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
5003  NewDI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
5004  } else
5005  NewDI = getDerived().TransformType(OldDI);
5006  if (!NewDI)
5007  return nullptr;
5008 
5009  if (NewDI == OldDI && indexAdjustment == 0)
5010  return OldParm;
5011 
5012  ParmVarDecl *newParm = ParmVarDecl::Create(SemaRef.Context,
5013  OldParm->getDeclContext(),
5014  OldParm->getInnerLocStart(),
5015  OldParm->getLocation(),
5016  OldParm->getIdentifier(),
5017  NewDI->getType(),
5018  NewDI,
5019  OldParm->getStorageClass(),
5020  /* DefArg */ nullptr);
5021  newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
5022  OldParm->getFunctionScopeIndex() + indexAdjustment);
5023  return newParm;
5024 }
5025 
5026 template <typename Derived>
5029  const QualType *ParamTypes,
5030  const FunctionProtoType::ExtParameterInfo *ParamInfos,
5031  SmallVectorImpl<QualType> &OutParamTypes,
5034  int indexAdjustment = 0;
5035 
5036  unsigned NumParams = Params.size();
5037  for (unsigned i = 0; i != NumParams; ++i) {
5038  if (ParmVarDecl *OldParm = Params[i]) {
5039  assert(OldParm->getFunctionScopeIndex() == i);
5040 
5041  Optional<unsigned> NumExpansions;
5042  ParmVarDecl *NewParm = nullptr;
5043  if (OldParm->isParameterPack()) {
5044  // We have a function parameter pack that may need to be expanded.
5046 
5047  // Find the parameter packs that could be expanded.
5048  TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
5049  PackExpansionTypeLoc ExpansionTL = TL.castAs<PackExpansionTypeLoc>();
5050  TypeLoc Pattern = ExpansionTL.getPatternLoc();
5051  SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
5052  assert(Unexpanded.size() > 0 && "Could not find parameter packs!");
5053 
5054  // Determine whether we should expand the parameter packs.
5055  bool ShouldExpand = false;
5056  bool RetainExpansion = false;
5057  Optional<unsigned> OrigNumExpansions =
5058  ExpansionTL.getTypePtr()->getNumExpansions();
5059  NumExpansions = OrigNumExpansions;
5060  if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
5061  Pattern.getSourceRange(),
5062  Unexpanded,
5063  ShouldExpand,
5064  RetainExpansion,
5065  NumExpansions)) {
5066  return true;
5067  }
5068 
5069  if (ShouldExpand) {
5070  // Expand the function parameter pack into multiple, separate
5071  // parameters.
5072  getDerived().ExpandingFunctionParameterPack(OldParm);
5073  for (unsigned I = 0; I != *NumExpansions; ++I) {
5074  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
5075  ParmVarDecl *NewParm
5076  = getDerived().TransformFunctionTypeParam(OldParm,
5077  indexAdjustment++,
5078  OrigNumExpansions,
5079  /*ExpectParameterPack=*/false);
5080  if (!NewParm)
5081  return true;
5082 
5083  if (ParamInfos)
5084  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5085  OutParamTypes.push_back(NewParm->getType());
5086  if (PVars)
5087  PVars->push_back(NewParm);
5088  }
5089 
5090  // If we're supposed to retain a pack expansion, do so by temporarily
5091  // forgetting the partially-substituted parameter pack.
5092  if (RetainExpansion) {
5093  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5094  ParmVarDecl *NewParm
5095  = getDerived().TransformFunctionTypeParam(OldParm,
5096  indexAdjustment++,
5097  OrigNumExpansions,
5098  /*ExpectParameterPack=*/false);
5099  if (!NewParm)
5100  return true;
5101 
5102  if (ParamInfos)
5103  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5104  OutParamTypes.push_back(NewParm->getType());
5105  if (PVars)
5106  PVars->push_back(NewParm);
5107  }
5108 
5109  // The next parameter should have the same adjustment as the
5110  // last thing we pushed, but we post-incremented indexAdjustment
5111  // on every push. Also, if we push nothing, the adjustment should
5112  // go down by one.
5113  indexAdjustment--;
5114 
5115  // We're done with the pack expansion.
5116  continue;
5117  }
5118 
5119  // We'll substitute the parameter now without expanding the pack
5120  // expansion.
5121  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5122  NewParm = getDerived().TransformFunctionTypeParam(OldParm,
5123  indexAdjustment,
5124  NumExpansions,
5125  /*ExpectParameterPack=*/true);
5126  } else {
5127  NewParm = getDerived().TransformFunctionTypeParam(
5128  OldParm, indexAdjustment, None, /*ExpectParameterPack=*/ false);
5129  }
5130 
5131  if (!NewParm)
5132  return true;
5133 
5134  if (ParamInfos)
5135  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5136  OutParamTypes.push_back(NewParm->getType());
5137  if (PVars)
5138  PVars->push_back(NewParm);
5139  continue;
5140  }
5141 
5142  // Deal with the possibility that we don't have a parameter
5143  // declaration for this parameter.
5144  QualType OldType = ParamTypes[i];
5145  bool IsPackExpansion = false;
5146  Optional<unsigned> NumExpansions;
5147  QualType NewType;
5148  if (const PackExpansionType *Expansion
5149  = dyn_cast<PackExpansionType>(OldType)) {
5150  // We have a function parameter pack that may need to be expanded.
5151  QualType Pattern = Expansion->getPattern();
5153  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5154 
5155  // Determine whether we should expand the parameter packs.
5156  bool ShouldExpand = false;
5157  bool RetainExpansion = false;
5158  if (getDerived().TryExpandParameterPacks(Loc, SourceRange(),
5159  Unexpanded,
5160  ShouldExpand,
5161  RetainExpansion,
5162  NumExpansions)) {
5163  return true;
5164  }
5165 
5166  if (ShouldExpand) {
5167  // Expand the function parameter pack into multiple, separate
5168  // parameters.
5169  for (unsigned I = 0; I != *NumExpansions; ++I) {
5170  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
5171  QualType NewType = getDerived().TransformType(Pattern);
5172  if (NewType.isNull())
5173  return true;
5174 
5175  if (NewType->containsUnexpandedParameterPack()) {
5176  NewType =
5177  getSema().getASTContext().getPackExpansionType(NewType, None);
5178 
5179  if (NewType.isNull())
5180  return true;
5181  }
5182 
5183  if (ParamInfos)
5184  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5185  OutParamTypes.push_back(NewType);
5186  if (PVars)
5187  PVars->push_back(nullptr);
5188  }
5189 
5190  // We're done with the pack expansion.
5191  continue;
5192  }
5193 
5194  // If we're supposed to retain a pack expansion, do so by temporarily
5195  // forgetting the partially-substituted parameter pack.
5196  if (RetainExpansion) {
5197  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5198  QualType NewType = getDerived().TransformType(Pattern);
5199  if (NewType.isNull())
5200  return true;
5201 
5202  if (ParamInfos)
5203  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5204  OutParamTypes.push_back(NewType);
5205  if (PVars)
5206  PVars->push_back(nullptr);
5207  }
5208 
5209  // We'll substitute the parameter now without expanding the pack
5210  // expansion.
5211  OldType = Expansion->getPattern();
5212  IsPackExpansion = true;
5213  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5214  NewType = getDerived().TransformType(OldType);
5215  } else {
5216  NewType = getDerived().TransformType(OldType);
5217  }
5218 
5219  if (NewType.isNull())
5220  return true;
5221 
5222  if (IsPackExpansion)
5223  NewType = getSema().Context.getPackExpansionType(NewType,
5224  NumExpansions);
5225 
5226  if (ParamInfos)
5227  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5228  OutParamTypes.push_back(NewType);
5229  if (PVars)
5230  PVars->push_back(nullptr);
5231  }
5232 
5233 #ifndef NDEBUG
5234  if (PVars) {
5235  for (unsigned i = 0, e = PVars->size(); i != e; ++i)
5236  if (ParmVarDecl *parm = (*PVars)[i])
5237  assert(parm->getFunctionScopeIndex() == i);
5238  }
5239 #endif
5240 
5241  return false;
5242 }
5243 
5244 template<typename Derived>
5245 QualType
5247  FunctionProtoTypeLoc TL) {
5248  SmallVector<QualType, 4> ExceptionStorage;
5249  TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
5250  return getDerived().TransformFunctionProtoType(
5251  TLB, TL, nullptr, Qualifiers(),
5252  [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
5253  return This->TransformExceptionSpec(TL.getBeginLoc(), ESI,
5254  ExceptionStorage, Changed);
5255  });
5256 }
5257 
5258 template<typename Derived> template<typename Fn>
5260  TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
5261  Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
5262 
5263  // Transform the parameters and return type.
5264  //
5265  // We are required to instantiate the params and return type in source order.
5266  // When the function has a trailing return type, we instantiate the
5267  // parameters before the return type, since the return type can then refer
5268  // to the parameters themselves (via decltype, sizeof, etc.).
5269  //
5270  SmallVector<QualType, 4> ParamTypes;
5271  SmallVector<ParmVarDecl*, 4> ParamDecls;
5272  Sema::ExtParameterInfoBuilder ExtParamInfos;
5273  const FunctionProtoType *T = TL.getTypePtr();
5274 
5275  QualType ResultType;
5276 
5277  if (T->hasTrailingReturn()) {
5278  if (getDerived().TransformFunctionTypeParams(
5279  TL.getBeginLoc(), TL.getParams(),
5280  TL.getTypePtr()->param_type_begin(),
5282  ParamTypes, &ParamDecls, ExtParamInfos))
5283  return QualType();
5284 
5285  {
5286  // C++11 [expr.prim.general]p3:
5287  // If a declaration declares a member function or member function
5288  // template of a class X, the expression this is a prvalue of type
5289  // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
5290  // and the end of the function-definition, member-declarator, or
5291  // declarator.
5292  Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, ThisTypeQuals);
5293 
5294  ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5295  if (ResultType.isNull())
5296  return QualType();
5297  }
5298  }
5299  else {
5300  ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5301  if (ResultType.isNull())
5302  return QualType();
5303 
5304  // Return type can not be qualified with an address space.
5305  if (ResultType.getAddressSpace() != LangAS::Default) {
5306  SemaRef.Diag(TL.getReturnLoc().getBeginLoc(),
5307  diag::err_attribute_address_function_type);
5308  return QualType();
5309  }
5310 
5311  if (getDerived().TransformFunctionTypeParams(
5312  TL.getBeginLoc(), TL.getParams(),
5313  TL.getTypePtr()->param_type_begin(),
5315  ParamTypes, &ParamDecls, ExtParamInfos))
5316  return QualType();
5317  }
5318 
5320 
5321  bool EPIChanged = false;
5322  if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
5323  return QualType();
5324 
5325  // Handle extended parameter information.
5326  if (auto NewExtParamInfos =
5327  ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
5328  if (!EPI.ExtParameterInfos ||
5329  llvm::makeArrayRef(EPI.ExtParameterInfos, TL.getNumParams())
5330  != llvm::makeArrayRef(NewExtParamInfos, ParamTypes.size())) {
5331  EPIChanged = true;
5332  }
5333  EPI.ExtParameterInfos = NewExtParamInfos;
5334  } else if (EPI.ExtParameterInfos) {
5335  EPIChanged = true;
5336  EPI.ExtParameterInfos = nullptr;
5337  }
5338 
5339  QualType Result = TL.getType();
5340  if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
5341  T->getParamTypes() != llvm::makeArrayRef(ParamTypes) || EPIChanged) {
5342  Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
5343  if (Result.isNull())
5344  return QualType();
5345  }
5346 
5347  FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result);
5349  NewTL.setLParenLoc(TL.getLParenLoc());
5350  NewTL.setRParenLoc(TL.getRParenLoc());
5352  NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
5353  for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
5354  NewTL.setParam(i, ParamDecls[i]);
5355 
5356  return Result;
5357 }
5358 
5359 template<typename Derived>
5362  SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
5363  assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
5364 
5365  // Instantiate a dynamic noexcept expression, if any.
5366  if (isComputedNoexcept(ESI.Type)) {
5369  ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
5370  if (NoexceptExpr.isInvalid())
5371  return true;
5372 
5373  ExceptionSpecificationType EST = ESI.Type;
5374  NoexceptExpr =
5375  getSema().ActOnNoexceptSpec(Loc, NoexceptExpr.get(), EST);
5376  if (NoexceptExpr.isInvalid())
5377  return true;
5378 
5379  if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
5380  Changed = true;
5381  ESI.NoexceptExpr = NoexceptExpr.get();
5382  ESI.Type = EST;
5383  }
5384 
5385  if (ESI.Type != EST_Dynamic)
5386  return false;
5387 
5388  // Instantiate a dynamic exception specification's type.
5389  for (QualType T : ESI.Exceptions) {
5390  if (const PackExpansionType *PackExpansion =
5391  T->getAs<PackExpansionType>()) {
5392  Changed = true;
5393 
5394  // We have a pack expansion. Instantiate it.
5396  SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
5397  Unexpanded);
5398  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5399 
5400  // Determine whether the set of unexpanded parameter packs can and
5401  // should
5402  // be expanded.
5403  bool Expand = false;
5404  bool RetainExpansion = false;
5405  Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
5406  // FIXME: Track the location of the ellipsis (and track source location
5407  // information for the types in the exception specification in general).
5408  if (getDerived().TryExpandParameterPacks(
5409  Loc, SourceRange(), Unexpanded, Expand,
5410  RetainExpansion, NumExpansions))
5411  return true;
5412 
5413  if (!Expand) {
5414  // We can't expand this pack expansion into separate arguments yet;
5415  // just substitute into the pattern and create a new pack expansion
5416  // type.
5417  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5418  QualType U = getDerived().TransformType(PackExpansion->getPattern());
5419  if (U.isNull())
5420  return true;
5421 
5422  U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
5423  Exceptions.push_back(U);
5424  continue;
5425  }
5426 
5427  // Substitute into the pack expansion pattern for each slice of the
5428  // pack.
5429  for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
5430  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
5431 
5432  QualType U = getDerived().TransformType(PackExpansion->getPattern());
5433  if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
5434  return true;
5435 
5436  Exceptions.push_back(U);
5437  }
5438  } else {
5439  QualType U = getDerived().TransformType(T);
5440  if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
5441  return true;
5442  if (T != U)
5443  Changed = true;
5444 
5445  Exceptions.push_back(U);
5446  }
5447  }
5448 
5449  ESI.Exceptions = Exceptions;
5450  if (ESI.Exceptions.empty())
5451  ESI.Type = EST_DynamicNone;
5452  return false;
5453 }
5454 
5455 template<typename Derived>
5457  TypeLocBuilder &TLB,
5459  const FunctionNoProtoType *T = TL.getTypePtr();
5460  QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5461  if (ResultType.isNull())
5462  return QualType();
5463 
5464  QualType Result = TL.getType();
5465  if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
5466  Result = getDerived().RebuildFunctionNoProtoType(ResultType);
5467 
5468  FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result);
5470  NewTL.setLParenLoc(TL.getLParenLoc());
5471  NewTL.setRParenLoc(TL.getRParenLoc());
5472  NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
5473 
5474  return Result;
5475 }
5476 
5477 template<typename Derived> QualType
5480  const UnresolvedUsingType *T = TL.getTypePtr();
5481  Decl *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
5482  if (!D)
5483  return QualType();
5484 
5485  QualType Result = TL.getType();
5486  if (getDerived().AlwaysRebuild() || D != T->getDecl()) {
5487  Result = getDerived().RebuildUnresolvedUsingType(TL.getNameLoc(), D);
5488  if (Result.isNull())
5489  return QualType();
5490  }
5491 
5492  // We might get an arbitrary type spec type back. We should at
5493  // least always get a type spec type, though.
5494  TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(Result);
5495  NewTL.setNameLoc(TL.getNameLoc());
5496 
5497  return Result;
5498 }
5499 
5500 template<typename Derived>
5502  TypedefTypeLoc TL) {
5503  const TypedefType *T = TL.getTypePtr();
5504  TypedefNameDecl *Typedef
5505  = cast_or_null<TypedefNameDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5506  T->getDecl()));
5507  if (!Typedef)
5508  return QualType();
5509 
5510  QualType Result = TL.getType();
5511  if (getDerived().AlwaysRebuild() ||
5512  Typedef != T->getDecl()) {
5513  Result = getDerived().RebuildTypedefType(Typedef);
5514  if (Result.isNull())
5515  return QualType();
5516  }
5517 
5518  TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(Result);
5519  NewTL.setNameLoc(TL.getNameLoc());
5520 
5521  return Result;
5522 }
5523 
5524 template<typename Derived>
5526  TypeOfExprTypeLoc TL) {
5527  // typeof expressions are not potentially evaluated contexts
5531 
5532  ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
5533  if (E.isInvalid())
5534  return QualType();
5535 
5536  E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
5537  if (E.isInvalid())
5538  return QualType();
5539 
5540  QualType Result = TL.getType();
5541  if (getDerived().AlwaysRebuild() ||
5542  E.get() != TL.getUnderlyingExpr()) {
5543  Result = getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc());
5544  if (Result.isNull())
5545  return QualType();
5546  }
5547  else E.get();
5548 
5549  TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
5550  NewTL.setTypeofLoc(TL.getTypeofLoc());
5551  NewTL.setLParenLoc(TL.getLParenLoc());
5552  NewTL.setRParenLoc(TL.getRParenLoc());
5553 
5554  return Result;
5555 }
5556 
5557 template<typename Derived>
5559  TypeOfTypeLoc TL) {
5560  TypeSourceInfo* Old_Under_TI = TL.getUnderlyingTInfo();
5561  TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
5562  if (!New_Under_TI)
5563  return QualType();
5564 
5565  QualType Result = TL.getType();
5566  if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
5567  Result = getDerived().RebuildTypeOfType(New_Under_TI->getType());
5568  if (Result.isNull())
5569  return QualType();
5570  }
5571 
5572  TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
5573  NewTL.setTypeofLoc(TL.getTypeofLoc());
5574  NewTL.setLParenLoc(TL.getLParenLoc());
5575  NewTL.setRParenLoc(TL.getRParenLoc());
5576  NewTL.setUnderlyingTInfo(New_Under_TI);
5577 
5578  return Result;
5579 }
5580 
5581 template<typename Derived>
5583  DecltypeTypeLoc TL) {
5584  const DecltypeType *T = TL.getTypePtr();
5585 
5586  // decltype expressions are not potentially evaluated contexts
5590 
5591  ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
5592  if (E.isInvalid())
5593  return QualType();
5594 
5595  E = getSema().ActOnDecltypeExpression(E.get());
5596  if (E.isInvalid())
5597  return QualType();
5598 
5599  QualType Result = TL.getType();
5600  if (getDerived().AlwaysRebuild() ||
5601  E.get() != T->getUnderlyingExpr()) {
5602  Result = getDerived().RebuildDecltypeType(E.get(), TL.getNameLoc());
5603  if (Result.isNull())
5604  return QualType();
5605  }
5606  else E.get();
5607 
5608  DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
5609  NewTL.setNameLoc(TL.getNameLoc());
5610 
5611  return Result;
5612 }
5613 
5614 template<typename Derived>
5616  TypeLocBuilder &TLB,
5617  UnaryTransformTypeLoc TL) {
5618  QualType Result = TL.getType();
5619  if (Result->isDependentType()) {
5620  const UnaryTransformType *T = TL.getTypePtr();
5621  QualType NewBase =
5622  getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
5623  Result = getDerived().RebuildUnaryTransformType(NewBase,
5624  T->getUTTKind(),
5625  TL.getKWLoc());
5626  if (Result.isNull())
5627  return QualType();
5628  }
5629 
5630  UnaryTransformTypeLoc NewTL = TLB.push<UnaryTransformTypeLoc>(Result);
5631  NewTL.setKWLoc(TL.getKWLoc());
5632  NewTL.setParensRange(TL.getParensRange());
5634  return Result;
5635 }
5636 
5637 template<typename Derived>
5639  AutoTypeLoc TL) {
5640  const AutoType *T = TL.getTypePtr();
5641  QualType OldDeduced = T->getDeducedType();
5642  QualType NewDeduced;
5643  if (!OldDeduced.isNull()) {
5644  NewDeduced = getDerived().TransformType(OldDeduced);
5645  if (NewDeduced.isNull())
5646  return QualType();
5647  }
5648 
5649  QualType Result = TL.getType();
5650  if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
5651  T->isDependentType()) {
5652  Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword());
5653  if (Result.isNull())
5654  return QualType();
5655  }
5656 
5657  AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
5658  NewTL.setNameLoc(TL.getNameLoc());
5659 
5660  return Result;
5661 }
5662 
5663 template<typename Derived>
5667 
5668  CXXScopeSpec SS;
5669  TemplateName TemplateName = getDerived().TransformTemplateName(
5670  SS, T->getTemplateName(), TL.getTemplateNameLoc());
5671  if (TemplateName.isNull())
5672  return QualType();
5673 
5674  QualType OldDeduced = T->getDeducedType();
5675  QualType NewDeduced;
5676  if (!OldDeduced.isNull()) {
5677  NewDeduced = getDerived().TransformType(OldDeduced);
5678  if (NewDeduced.isNull())
5679  return QualType();
5680  }
5681 
5682  QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
5683  TemplateName, NewDeduced);
5684  if (Result.isNull())
5685  return QualType();
5686 
5690 
5691  return Result;
5692 }
5693 
5694 template<typename Derived>
5696  RecordTypeLoc TL) {
5697  const RecordType *T = TL.getTypePtr();
5698  RecordDecl *Record
5699  = cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5700  T->getDecl()));
5701  if (!Record)
5702  return QualType();
5703 
5704  QualType Result = TL.getType();
5705  if (getDerived().AlwaysRebuild() ||
5706  Record != T->getDecl()) {
5707  Result = getDerived().RebuildRecordType(Record);
5708  if (Result.isNull())
5709  return QualType();
5710  }
5711 
5712  RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(Result);
5713  NewTL.setNameLoc(TL.getNameLoc());
5714 
5715  return Result;
5716 }
5717 
5718 template<typename Derived>
5720  EnumTypeLoc TL) {
5721  const EnumType *T = TL.getTypePtr();
5722  EnumDecl *Enum
5723  = cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5724  T->getDecl()));
5725  if (!Enum)
5726  return QualType();
5727 
5728  QualType Result = TL.getType();
5729  if (getDerived().AlwaysRebuild() ||
5730  Enum != T->getDecl()) {
5731  Result = getDerived().RebuildEnumType(Enum);
5732  if (Result.isNull())
5733  return QualType();
5734  }
5735 
5736  EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(Result);
5737  NewTL.setNameLoc(TL.getNameLoc());
5738 
5739  return Result;
5740 }
5741 
5742 template<typename Derived>
5744  TypeLocBuilder &TLB,
5746  Decl *D = getDerived().TransformDecl(TL.getNameLoc(),
5747  TL.getTypePtr()->getDecl());
5748  if (!D) return QualType();
5749 
5750  QualType T = SemaRef.Context.getTypeDeclType(cast<TypeDecl>(D));
5751  TLB.pushTypeSpec(T).setNameLoc(TL.getNameLoc());
5752  return T;
5753 }
5754 
5755 template<typename Derived>
5757  TypeLocBuilder &TLB,
5759  return TransformTypeSpecType(TLB, TL);
5760 }
5761 
5762 template<typename Derived>
5764  TypeLocBuilder &TLB,
5766  const SubstTemplateTypeParmType *T = TL.getTypePtr();
5767 
5768  // Substitute into the replacement type, which itself might involve something
5769  // that needs to be transformed. This only tends to occur with default
5770  // template arguments of template template parameters.
5771  TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
5772  QualType Replacement = getDerived().TransformType(T->getReplacementType());
5773  if (Replacement.isNull())
5774  return QualType();
5775 
5776  // Always canonicalize the replacement type.
5777  Replacement = SemaRef.Context.getCanonicalType(Replacement);
5778  QualType Result
5779  = SemaRef.Context.getSubstTemplateTypeParmType(T->getReplacedParameter(),
5780  Replacement);
5781 
5782  // Propagate type-source information.
5784  = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
5785  NewTL.setNameLoc(TL.getNameLoc());
5786  return Result;
5787 
5788 }
5789 
5790 template<typename Derived>
5792  TypeLocBuilder &TLB,
5794  return TransformTypeSpecType(TLB, TL);
5795 }
5796 
5797 template<typename Derived>
5799  TypeLocBuilder &TLB,
5801  const TemplateSpecializationType *T = TL.getTypePtr();
5802 
5803  // The nested-name-specifier never matters in a TemplateSpecializationType,
5804  // because we can't have a dependent nested-name-specifier anyway.
5805  CXXScopeSpec SS;
5806  TemplateName Template
5807  = getDerived().TransformTemplateName(SS, T->getTemplateName(),
5808  TL.getTemplateNameLoc());
5809  if (Template.isNull())
5810  return QualType();
5811 
5812  return getDerived().TransformTemplateSpecializationType(TLB, TL, Template);
5813 }
5814 
5815 template<typename Derived>
5817  AtomicTypeLoc TL) {
5818  QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
5819  if (ValueType.isNull())
5820  return QualType();
5821 
5822  QualType Result = TL.getType();
5823  if (getDerived().AlwaysRebuild() ||
5824  ValueType != TL.getValueLoc().getType()) {
5825  Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
5826  if (Result.isNull())
5827  return QualType();
5828  }
5829 
5830  AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
5831  NewTL.setKWLoc(TL.getKWLoc());
5832  NewTL.setLParenLoc(TL.getLParenLoc());
5833  NewTL.setRParenLoc(TL.getRParenLoc());
5834 
5835  return Result;
5836 }
5837 
5838 template <typename Derived>
5840  PipeTypeLoc TL) {
5841  QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
5842  if (ValueType.isNull())
5843  return QualType();
5844 
5845  QualType Result = TL.getType();
5846  if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
5847  const PipeType *PT = Result->getAs<PipeType>();
5848  bool isReadPipe = PT->isReadOnly();
5849  Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
5850  if (Result.isNull())
5851  return QualType();
5852  }
5853 
5854  PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
5855  NewTL.setKWLoc(TL.getKWLoc());
5856 
5857  return Result;
5858 }
5859 
5860  /// Simple iterator that traverses the template arguments in a
5861  /// container that provides a \c getArgLoc() member function.
5862  ///
5863  /// This iterator is intended to be used with the iterator form of
5864  /// \c TreeTransform<Derived>::TransformTemplateArguments().
5865  template<typename ArgLocContainer>
5867  ArgLocContainer *Container;
5868  unsigned Index;
5869 
5870  public:
5873  typedef int difference_type;
5874  typedef std::input_iterator_tag iterator_category;
5875 
5876  class pointer {
5877  TemplateArgumentLoc Arg;
5878 
5879  public:
5880  explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5881 
5883  return &Arg;
5884  }
5885  };
5886 
5887 
5889 
5890  TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
5891  unsigned Index)
5892  : Container(&Container), Index(Index) { }
5893 
5895  ++Index;
5896  return *this;
5897  }
5898 
5901  ++(*this);
5902  return Old;
5903  }
5904 
5906  return Container->getArgLoc(Index);
5907  }
5908 
5910  return pointer(Container->getArgLoc(Index));
5911  }
5912 
5915  return X.Container == Y.Container && X.Index == Y.Index;
5916  }
5917 
5920  return !(X == Y);
5921  }
5922  };
5923 
5924 
5925 template <typename Derived>
5927  TypeLocBuilder &TLB,
5929  TemplateName Template) {
5930  TemplateArgumentListInfo NewTemplateArgs;
5931  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
5932  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
5934  ArgIterator;
5935  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
5936  ArgIterator(TL, TL.getNumArgs()),
5937  NewTemplateArgs))
5938  return QualType();
5939 
5940  // FIXME: maybe don't rebuild if all the template arguments are the same.
5941 
5942  QualType Result =
5943  getDerived().RebuildTemplateSpecializationType(Template,
5944  TL.getTemplateNameLoc(),
5945  NewTemplateArgs);
5946 
5947  if (!Result.isNull()) {
5948  // Specializations of template template parameters are represented as
5949  // TemplateSpecializationTypes, and substitution of type alias templates
5950  // within a dependent context can transform them into
5951  // DependentTemplateSpecializationTypes.
5952  if (isa<DependentTemplateSpecializationType>(Result)) {
5959  NewTL.setLAngleLoc(TL.getLAngleLoc());
5960  NewTL.setRAngleLoc(TL.getRAngleLoc());
5961  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
5962  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
5963  return Result;
5964  }
5965 
5967  = TLB.push<TemplateSpecializationTypeLoc>(Result);
5970  NewTL.setLAngleLoc(TL.getLAngleLoc());
5971  NewTL.setRAngleLoc(TL.getRAngleLoc());
5972  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
5973  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
5974  }
5975 
5976  return Result;
5977 }
5978 
5979 template <typename Derived>
5981  TypeLocBuilder &TLB,
5983  TemplateName Template,
5984  CXXScopeSpec &SS) {
5985  TemplateArgumentListInfo NewTemplateArgs;
5986  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
5987  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
5990  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
5991  ArgIterator(TL, TL.getNumArgs()),
5992  NewTemplateArgs))
5993  return QualType();
5994 
5995  // FIXME: maybe don't rebuild if all the template arguments are the same.
5996 
5997  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
5998  QualType Result
5999  = getSema().Context.getDependentTemplateSpecializationType(
6000  TL.getTypePtr()->getKeyword(),
6001  DTN->getQualifier(),
6002  DTN->getIdentifier(),
6003  NewTemplateArgs);
6004 
6008  NewTL.setQualifierLoc(SS.getWithLocInContext(SemaRef.Context));
6011  NewTL.setLAngleLoc(TL.getLAngleLoc());
6012  NewTL.setRAngleLoc(TL.getRAngleLoc());
6013  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
6014  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
6015  return Result;
6016  }
6017 
6018  QualType Result
6019  = getDerived().RebuildTemplateSpecializationType(Template,
6020  TL.getTemplateNameLoc(),
6021  NewTemplateArgs);
6022 
6023  if (!Result.isNull()) {
6024  /// FIXME: Wrap this in an elaborated-type-specifier?
6026  = TLB.push<TemplateSpecializationTypeLoc>(Result);
6029  NewTL.setLAngleLoc(TL.getLAngleLoc());
6030  NewTL.setRAngleLoc(TL.getRAngleLoc());
6031  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
6032  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
6033  }
6034 
6035  return Result;
6036 }
6037 
6038 template<typename Derived>
6039 QualType
6041  ElaboratedTypeLoc TL) {
6042  const ElaboratedType *T = TL.getTypePtr();
6043 
6044  NestedNameSpecifierLoc QualifierLoc;
6045  // NOTE: the qualifier in an ElaboratedType is optional.
6046  if (TL.getQualifierLoc()) {
6047  QualifierLoc
6048  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6049  if (!QualifierLoc)
6050  return QualType();
6051  }
6052 
6053  QualType NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc());
6054  if (NamedT.isNull())
6055  return QualType();
6056 
6057  // C++0x [dcl.type.elab]p2:
6058  // If the identifier resolves to a typedef-name or the simple-template-id
6059  // resolves to an alias template specialization, the
6060  // elaborated-type-specifier is ill-formed.
6061  if (T->getKeyword() != ETK_None && T->getKeyword() != ETK_Typename) {
6062  if (const TemplateSpecializationType *TST =
6063  NamedT->getAs<TemplateSpecializationType>()) {
6064  TemplateName Template = TST->getTemplateName();
6065  if (TypeAliasTemplateDecl *TAT = dyn_cast_or_null<TypeAliasTemplateDecl>(
6066  Template.getAsTemplateDecl())) {
6067  SemaRef.Diag(TL.getNamedTypeLoc().getBeginLoc(),
6068  diag::err_tag_reference_non_tag)
6069  << TAT << Sema::NTK_TypeAliasTemplate
6071  SemaRef.Diag(TAT->getLocation(), diag::note_declared_at);
6072  }
6073  }
6074  }
6075 
6076  QualType Result = TL.getType();
6077  if (getDerived().AlwaysRebuild() ||
6078  QualifierLoc != TL.getQualifierLoc() ||
6079  NamedT != T->getNamedType()) {
6080  Result = getDerived().RebuildElaboratedType(TL.getElaboratedKeywordLoc(),
6081  T->getKeyword(),
6082  QualifierLoc, NamedT);
6083  if (Result.isNull())
6084  return QualType();
6085  }
6086 
6087  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6089  NewTL.setQualifierLoc(QualifierLoc);
6090  return Result;
6091 }
6092 
6093 template<typename Derived>
6095  TypeLocBuilder &TLB,
6096  AttributedTypeLoc TL) {
6097  const AttributedType *oldType = TL.getTypePtr();
6098  QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
6099  if (modifiedType.isNull())
6100  return QualType();
6101 
6102  // oldAttr can be null if we started with a QualType rather than a TypeLoc.
6103  const Attr *oldAttr = TL.getAttr();
6104  const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
6105  if (oldAttr && !newAttr)
6106  return QualType();
6107 
6108  QualType result = TL.getType();
6109 
6110  // FIXME: dependent operand expressions?
6111  if (getDerived().AlwaysRebuild() ||
6112  modifiedType != oldType->getModifiedType()) {
6113  // TODO: this is really lame; we should really be rebuilding the
6114  // equivalent type from first principles.
6115  QualType equivalentType
6116  = getDerived().TransformType(oldType->getEquivalentType());
6117  if (equivalentType.isNull())
6118  return QualType();
6119 
6120  // Check whether we can add nullability; it is only represented as
6121  // type sugar, and therefore cannot be diagnosed in any other way.
6122  if (auto nullability = oldType->getImmediateNullability()) {
6123  if (!modifiedType->canHaveNullability()) {
6124  SemaRef.Diag(TL.getAttr()->getLocation(),
6125  diag::err_nullability_nonpointer)
6126  << DiagNullabilityKind(*nullability, false) << modifiedType;
6127  return QualType();
6128  }
6129  }
6130 
6131  result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
6132  modifiedType,
6133  equivalentType);
6134  }
6135 
6136  AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
6137  newTL.setAttr(newAttr);
6138  return result;
6139 }
6140 
6141 template<typename Derived>
6142 QualType
6144  ParenTypeLoc TL) {
6145  QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
6146  if (Inner.isNull())
6147  return QualType();
6148 
6149  QualType Result = TL.getType();
6150  if (getDerived().AlwaysRebuild() ||
6151  Inner != TL.getInnerLoc().getType()) {
6152  Result = getDerived().RebuildParenType(Inner);
6153  if (Result.isNull())
6154  return QualType();
6155  }
6156 
6157  ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
6158  NewTL.setLParenLoc(TL.getLParenLoc());
6159  NewTL.setRParenLoc(TL.getRParenLoc());
6160  return Result;
6161 }
6162 
6163 template<typename Derived>
6166  return TransformDependentNameType(TLB, TL, false);
6167 }
6168 
6169 template<typename Derived>
6171  TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext) {
6172  const DependentNameType *T = TL.getTypePtr();
6173 
6174  NestedNameSpecifierLoc QualifierLoc
6175  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6176  if (!QualifierLoc)
6177  return QualType();
6178 
6179  QualType Result
6180  = getDerived().RebuildDependentNameType(T->getKeyword(),
6182  QualifierLoc,
6183  T->getIdentifier(),
6184  TL.getNameLoc(),
6185  DeducedTSTContext);
6186  if (Result.isNull())
6187  return QualType();
6188 
6189  if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) {
6190  QualType NamedT = ElabT->getNamedType();
6191  TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc());
6192 
6193  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6195  NewTL.setQualifierLoc(QualifierLoc);
6196  } else {
6197  DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
6199  NewTL.setQualifierLoc(QualifierLoc);
6200  NewTL.setNameLoc(TL.getNameLoc());
6201  }
6202  return Result;
6203 }
6204 
6205 template<typename Derived>
6209  NestedNameSpecifierLoc QualifierLoc;
6210  if (TL.getQualifierLoc()) {
6211  QualifierLoc
6212  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6213  if (!QualifierLoc)
6214  return QualType();
6215  }
6216 
6217  return getDerived()
6218  .TransformDependentTemplateSpecializationType(TLB, TL, QualifierLoc);
6219 }
6220 
6221 template<typename Derived>
6225  NestedNameSpecifierLoc QualifierLoc) {
6227 
6228  TemplateArgumentListInfo NewTemplateArgs;
6229  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
6230  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
6231 
6234  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
6235  ArgIterator(TL, TL.getNumArgs()),
6236  NewTemplateArgs))
6237  return QualType();
6238 
6239  QualType Result = getDerived().RebuildDependentTemplateSpecializationType(
6240  T->getKeyword(), QualifierLoc, TL.getTemplateKeywordLoc(),
6241  T->getIdentifier(), TL.getTemplateNameLoc(), NewTemplateArgs,
6242  /*AllowInjectedClassName*/ false);
6243  if (Result.isNull())
6244  return QualType();
6245 
6246  if (const ElaboratedType *ElabT = dyn_cast<ElaboratedType>(Result)) {
6247  QualType NamedT = ElabT->getNamedType();
6248 
6249  // Copy information relevant to the template specialization.
6251  = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
6253  NamedTL.setTemplateNameLoc(TL.getTemplateNameLoc());
6254  NamedTL.setLAngleLoc(TL.getLAngleLoc());
6255  NamedTL.setRAngleLoc(TL.getRAngleLoc());
6256  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6257  NamedTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6258 
6259  // Copy information relevant to the elaborated type.
6260  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6262  NewTL.setQualifierLoc(QualifierLoc);
6263  } else if (isa<DependentTemplateSpecializationType>(Result)) {
6267  SpecTL.setQualifierLoc(QualifierLoc);
6270  SpecTL.setLAngleLoc(TL.getLAngleLoc());
6271  SpecTL.setRAngleLoc(TL.getRAngleLoc());
6272  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6273  SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6274  } else {
6276  = TLB.push<TemplateSpecializationTypeLoc>(Result);
6279  SpecTL.setLAngleLoc(TL.getLAngleLoc());
6280  SpecTL.setRAngleLoc(TL.getRAngleLoc());
6281  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6282  SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6283  }
6284  return Result;
6285 }
6286 
6287 template<typename Derived>
6289  PackExpansionTypeLoc TL) {
6290  QualType Pattern
6291  = getDerived().TransformType(TLB, TL.getPatternLoc());
6292  if (Pattern.isNull())
6293  return QualType();
6294 
6295  QualType Result = TL.getType();
6296  if (getDerived().AlwaysRebuild() ||
6297  Pattern != TL.getPatternLoc().getType()) {
6298  Result = getDerived().RebuildPackExpansionType(Pattern,
6300  TL.getEllipsisLoc(),
6301  TL.getTypePtr()->getNumExpansions());
6302  if (Result.isNull())
6303  return QualType();
6304  }
6305 
6306  PackExpansionTypeLoc NewT = TLB.push<PackExpansionTypeLoc>(Result);
6307  NewT.setEllipsisLoc(TL.getEllipsisLoc());
6308  return Result;
6309 }
6310 
6311 template<typename Derived>
6312 QualType
6314  ObjCInterfaceTypeLoc TL) {
6315  // ObjCInterfaceType is never dependent.
6316  TLB.pushFullCopy(TL);
6317  return TL.getType();
6318 }
6319 
6320 template<typename Derived>
6321 QualType
6323  ObjCTypeParamTypeLoc TL) {
6324  const ObjCTypeParamType *T = TL.getTypePtr();
6325  ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
6326  getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
6327  if (!OTP)
6328  return QualType();
6329 
6330  QualType Result = TL.getType();
6331  if (getDerived().AlwaysRebuild() ||
6332  OTP != T->getDecl()) {
6333  Result = getDerived().RebuildObjCTypeParamType(OTP,
6334  TL.getProtocolLAngleLoc(),
6335  llvm::makeArrayRef(TL.getTypePtr()->qual_begin(),
6336  TL.getNumProtocols()),
6337  TL.getProtocolLocs(),
6338  TL.getProtocolRAngleLoc());
6339  if (Result.isNull())
6340  return QualType();
6341  }
6342 
6343  ObjCTypeParamTypeLoc NewTL = TLB.push<ObjCTypeParamTypeLoc>(Result);
6344  if (TL.getNumProtocols()) {
6346  for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
6347  NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
6349  }
6350  return Result;
6351 }
6352 
6353 template<typename Derived>
6354 QualType
6356  ObjCObjectTypeLoc TL) {
6357  // Transform base type.
6358  QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
6359  if (BaseType.isNull())
6360  return QualType();
6361 
6362  bool AnyChanged = BaseType != TL.getBaseLoc().getType();
6363 
6364  // Transform type arguments.
6365  SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
6366  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
6367  TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
6368  TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
6369  QualType TypeArg = TypeArgInfo->getType();
6370  if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
6371  AnyChanged = true;
6372 
6373  // We have a pack expansion. Instantiate it.
6374  const auto *PackExpansion = PackExpansionLoc.getType()
6377  SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6378  Unexpanded);
6379  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6380 
6381  // Determine whether the set of unexpanded parameter packs can
6382  // and should be expanded.
6383  TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
6384  bool Expand = false;
6385  bool RetainExpansion = false;
6386  Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
6387  if (getDerived().TryExpandParameterPacks(
6388  PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
6389  Unexpanded, Expand, RetainExpansion, NumExpansions))
6390  return QualType();
6391 
6392  if (!Expand) {
6393  // We can't expand this pack expansion into separate arguments yet;
6394  // just substitute into the pattern and create a new pack expansion
6395  // type.
6396  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6397 
6398  TypeLocBuilder TypeArgBuilder;
6399  TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
6400  QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
6401  PatternLoc);
6402  if (NewPatternType.isNull())
6403  return QualType();
6404 
6405  QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
6406  NewPatternType, NumExpansions);
6407  auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
6408  NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
6409  NewTypeArgInfos.push_back(
6410  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
6411  continue;
6412  }
6413 
6414  // Substitute into the pack expansion pattern for each slice of the
6415  // pack.
6416  for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6417  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
6418 
6419  TypeLocBuilder TypeArgBuilder;
6420  TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
6421 
6422  QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
6423  PatternLoc);
6424  if (NewTypeArg.isNull())
6425  return QualType();
6426 
6427  NewTypeArgInfos.push_back(
6428  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
6429  }
6430 
6431  continue;
6432  }
6433 
6434  TypeLocBuilder TypeArgBuilder;
6435  TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
6436  QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
6437  if (NewTypeArg.isNull())
6438  return QualType();
6439 
6440  // If nothing changed, just keep the old TypeSourceInfo.
6441  if (NewTypeArg == TypeArg) {
6442  NewTypeArgInfos.push_back(TypeArgInfo);
6443  continue;
6444  }
6445 
6446  NewTypeArgInfos.push_back(
6447  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
6448  AnyChanged = true;
6449  }
6450 
6451  QualType Result = TL.getType();
6452  if (getDerived().AlwaysRebuild() || AnyChanged) {
6453  // Rebuild the type.
6454  Result = getDerived().RebuildObjCObjectType(
6455  BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
6457  llvm::makeArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
6459 
6460  if (Result.isNull())
6461  return QualType();
6462  }
6463 
6464  ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
6465  NewT.setHasBaseTypeAsWritten(true);
6467  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
6468  NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
6471  for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
6472  NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
6474  return Result;
6475 }
6476 
6477 template<typename Derived>
6478 QualType
6481  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
6482  if (PointeeType.isNull())
6483  return QualType();
6484 
6485  QualType Result = TL.getType();
6486  if (getDerived().AlwaysRebuild() ||
6487  PointeeType != TL.getPointeeLoc().getType()) {
6488  Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
6489  TL.getStarLoc());
6490  if (Result.isNull())
6491  return QualType();
6492  }
6493 
6495  NewT.setStarLoc(TL.getStarLoc());
6496  return Result;
6497 }
6498 
6499 //===----------------------------------------------------------------------===//
6500 // Statement transformation
6501 //===----------------------------------------------------------------------===//
6502 template<typename Derived>
6503 StmtResult
6505  return S;
6506 }
6507 
6508 template<typename Derived>
6509 StmtResult
6511  return getDerived().TransformCompoundStmt(S, false);
6512 }
6513 
6514 template<typename Derived>
6515 StmtResult
6517  bool IsStmtExpr) {
6518  Sema::CompoundScopeRAII CompoundScope(getSema());
6519 
6520  bool SubStmtInvalid = false;
6521  bool SubStmtChanged = false;
6522  SmallVector<Stmt*, 8> Statements;
6523  for (auto *B : S->body()) {
6524  StmtResult Result =
6525  getDerived().TransformStmt(B, !IsStmtExpr || B != S->body_back());
6526 
6527  if (Result.isInvalid()) {
6528  // Immediately fail if this was a DeclStmt, since it's very
6529  // likely that this will cause problems for future statements.
6530  if (isa<DeclStmt>(B))
6531  return StmtError();
6532 
6533  // Otherwise, just keep processing substatements and fail later.
6534  SubStmtInvalid = true;
6535  continue;
6536  }
6537 
6538  SubStmtChanged = SubStmtChanged || Result.get() != B;
6539  Statements.push_back(Result.getAs<Stmt>());
6540  }
6541 
6542  if (SubStmtInvalid)
6543  return StmtError();
6544 
6545  if (!getDerived().AlwaysRebuild() &&
6546  !SubStmtChanged)
6547  return S;
6548 
6549  return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
6550  Statements,
6551  S->getRBracLoc(),
6552  IsStmtExpr);
6553 }
6554 
6555 template<typename Derived>
6556 StmtResult
6558  ExprResult LHS, RHS;
6559  {
6562 
6563  // Transform the left-hand case value.
6564  LHS = getDerived().TransformExpr(S->getLHS());
6565  LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
6566  if (LHS.isInvalid())
6567  return StmtError();
6568 
6569  // Transform the right-hand case value (for the GNU case-range extension).
6570  RHS = getDerived().TransformExpr(S->getRHS());
6571  RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
6572  if (RHS.isInvalid())
6573  return StmtError();
6574  }
6575 
6576  // Build the case statement.
6577  // Case statements are always rebuilt so that they will attached to their
6578  // transformed switch statement.
6579  StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
6580  LHS.get(),
6581  S->getEllipsisLoc(),
6582  RHS.get(),
6583  S->getColonLoc());
6584  if (Case.isInvalid())
6585  return StmtError();
6586 
6587  // Transform the statement following the case
6588  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6589  if (SubStmt.isInvalid())
6590  return StmtError();
6591 
6592  // Attach the body to the case statement
6593  return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
6594 }
6595 
6596 template<typename Derived>
6597 StmtResult
6599  // Transform the statement following the default case
6600  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6601  if (SubStmt.isInvalid())
6602  return StmtError();
6603 
6604  // Default statements are always rebuilt
6605  return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
6606  SubStmt.get());
6607 }
6608 
6609 template<typename Derived>
6610 StmtResult
6612  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6613  if (SubStmt.isInvalid())
6614  return StmtError();
6615 
6616  Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
6617  S->getDecl());
6618  if (!LD)
6619  return StmtError();
6620 
6621 
6622  // FIXME: Pass the real colon location in.
6623  return getDerived().RebuildLabelStmt(S->getIdentLoc(),
6624  cast<LabelDecl>(LD), SourceLocation(),
6625  SubStmt.get());
6626 }
6627 
6628 template <typename Derived>
6630  if (!R)
6631  return R;
6632 
6633  switch (R->getKind()) {
6634 // Transform attributes with a pragma spelling by calling TransformXXXAttr.
6635 #define ATTR(X)
6636 #define PRAGMA_SPELLING_ATTR(X) \
6637  case attr::X: \
6638  return getDerived().Transform##X##Attr(cast<X##Attr>(R));
6639 #include "clang/Basic/AttrList.inc"
6640  default:
6641  return R;
6642  }
6643 }
6644 
6645 template <typename Derived>
6647  bool AttrsChanged = false;
6649 
6650  // Visit attributes and keep track if any are transformed.
6651  for (const auto *I : S->getAttrs()) {
6652  const Attr *R = getDerived().TransformAttr(I);
6653  AttrsChanged |= (I != R);
6654  Attrs.push_back(R);
6655  }
6656 
6657  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6658  if (SubStmt.isInvalid())
6659  return StmtError();
6660 
6661  if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
6662  return S;
6663 
6664  return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
6665  SubStmt.get());
6666 }
6667 
6668 template<typename Derived>
6669 StmtResult
6671  // Transform the initialization statement
6672  StmtResult Init = getDerived().TransformStmt(S->getInit());
6673  if (Init.isInvalid())
6674  return StmtError();
6675 
6676  // Transform the condition
6677  Sema::ConditionResult Cond = getDerived().TransformCondition(
6678  S->getIfLoc(), S->getConditionVariable(), S->getCond(),
6681  if (Cond.isInvalid())
6682  return StmtError();
6683 
6684  // If this is a constexpr if, determine which arm we should instantiate.
6685  llvm::Optional<bool> ConstexprConditionValue;
6686  if (S->isConstexpr())
6687  ConstexprConditionValue = Cond.getKnownValue();
6688 
6689  // Transform the "then" branch.
6690  StmtResult Then;
6691  if (!ConstexprConditionValue || *ConstexprConditionValue) {
6692  Then = getDerived().TransformStmt(S->getThen());
6693  if (Then.isInvalid())
6694  return StmtError();
6695  } else {
6696  Then = new (getSema().Context) NullStmt(S->getThen()->getBeginLoc());
6697  }
6698 
6699  // Transform the "else" branch.
6700  StmtResult Else;
6701  if (!ConstexprConditionValue || !*ConstexprConditionValue) {
6702  Else = getDerived().TransformStmt(S->getElse());
6703  if (Else.isInvalid())
6704  return StmtError();
6705  }
6706 
6707  if (!getDerived().AlwaysRebuild() &&
6708  Init.get() == S->getInit() &&
6709  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
6710  Then.get() == S->getThen() &&
6711  Else.get() == S->getElse())
6712  return S;
6713 
6714  return getDerived().RebuildIfStmt(S->getIfLoc(), S->isConstexpr(), Cond,
6715  Init.get(), Then.get(), S->getElseLoc(),
6716  Else.get());
6717 }
6718 
6719 template<typename Derived>
6720 StmtResult
6722  // Transform the initialization statement
6723  StmtResult Init = getDerived().TransformStmt(S->getInit());
6724  if (Init.isInvalid())
6725  return StmtError();
6726 
6727  // Transform the condition.
6728  Sema::ConditionResult Cond = getDerived().TransformCondition(
6729  S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
6731  if (Cond.isInvalid())
6732  return StmtError();
6733 
6734  // Rebuild the switch statement.
6735  StmtResult Switch
6736  = getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond);
6737  if (Switch.isInvalid())
6738  return StmtError();
6739 
6740  // Transform the body of the switch statement.
6741  StmtResult Body = getDerived().TransformStmt(S->getBody());
6742  if (Body.isInvalid())
6743  return StmtError();
6744 
6745  // Complete the switch statement.
6746  return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
6747  Body.get());
6748 }
6749 
6750 template<typename Derived>
6751 StmtResult
6753  // Transform the condition
6754  Sema::ConditionResult Cond = getDerived().TransformCondition(
6755  S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
6757  if (Cond.isInvalid())
6758  return StmtError();
6759 
6760  // Transform the body
6761  StmtResult Body = getDerived().TransformStmt(S->getBody());
6762  if (Body.isInvalid())
6763  return StmtError();
6764 
6765  if (!getDerived().AlwaysRebuild() &&
6766  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
6767  Body.get() == S->getBody())
6768  return Owned(S);
6769 
6770  return getDerived().RebuildWhileStmt(S->getWhileLoc(), Cond, Body.get());
6771 }
6772 
6773 template<typename Derived>
6774 StmtResult
6776  // Transform the body
6777  StmtResult Body = getDerived().TransformStmt(S->getBody());
6778  if (Body.isInvalid())
6779  return StmtError();
6780 
6781  // Transform the condition
6782  ExprResult Cond = getDerived().TransformExpr(S->getCond());
6783  if (Cond.isInvalid())
6784  return StmtError();
6785 
6786  if (!getDerived().AlwaysRebuild() &&
6787  Cond.get() == S->getCond() &&
6788  Body.get() == S->getBody())
6789  return S;
6790 
6791  return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
6792  /*FIXME:*/S->getWhileLoc(), Cond.get(),
6793  S->getRParenLoc());
6794 }
6795 
6796 template<typename Derived>
6797 StmtResult
6799  if (getSema().getLangOpts().OpenMP)
6800  getSema().startOpenMPLoop();
6801 
6802  // Transform the initialization statement
6803  StmtResult Init = getDerived().TransformStmt(S->getInit());
6804  if (Init.isInvalid())
6805  return StmtError();
6806 
6807  // In OpenMP loop region loop control variable must be captured and be
6808  // private. Perform analysis of first part (if any).
6809  if (getSema().getLangOpts().OpenMP && Init.isUsable())
6810  getSema().ActOnOpenMPLoopInitialization(S->getForLoc(), Init.get());
6811 
6812  // Transform the condition
6813  Sema::ConditionResult Cond = getDerived().TransformCondition(
6814  S->getForLoc(), S->getConditionVariable(), S->getCond(),
6816  if (Cond.isInvalid())
6817  return StmtError();
6818 
6819  // Transform the increment
6820  ExprResult Inc = getDerived().TransformExpr(S->getInc());
6821  if (Inc.isInvalid())
6822  return StmtError();
6823 
6824  Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
6825  if (S->getInc() && !FullInc.get())
6826  return StmtError();
6827 
6828  // Transform the body
6829  StmtResult Body = getDerived().TransformStmt(S->getBody());
6830  if (Body.isInvalid())
6831  return StmtError();
6832 
6833  if (!getDerived().AlwaysRebuild() &&
6834  Init.get() == S->getInit() &&
6835  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
6836  Inc.get() == S->getInc() &&
6837  Body.get() == S->getBody())
6838  return S;
6839 
6840  return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
6841  Init.get(), Cond, FullInc,
6842  S->getRParenLoc(), Body.get());
6843 }
6844 
6845 template<typename Derived>
6846 StmtResult
6848  Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
6849  S->getLabel());
6850  if (!LD)
6851  return StmtError();
6852 
6853  // Goto statements must always be rebuilt, to resolve the label.
6854  return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
6855  cast<LabelDecl>(LD));
6856 }
6857 
6858 template<typename Derived>
6859 StmtResult
6861  ExprResult Target = getDerived().TransformExpr(S->getTarget());
6862  if (Target.isInvalid())
6863  return StmtError();
6864  Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
6865 
6866  if (!getDerived().AlwaysRebuild() &&
6867  Target.get() == S->getTarget())
6868  return S;
6869 
6870  return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
6871  Target.get());
6872 }
6873 
6874 template<typename Derived>
6875 StmtResult
6877  return S;
6878 }
6879 
6880 template<typename Derived>
6881 StmtResult
6883  return S;
6884 }
6885 
6886 template<typename Derived>
6887 StmtResult
6889  ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
6890  /*NotCopyInit*/false);
6891  if (Result.isInvalid())
6892  return StmtError();
6893 
6894  // FIXME: We always rebuild the return statement because there is no way
6895  // to tell whether the return type of the function has changed.
6896  return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
6897 }
6898 
6899 template<typename Derived>
6900 StmtResult
6902  bool DeclChanged = false;
6903  SmallVector<Decl *, 4> Decls;
6904  for (auto *D : S->decls()) {
6905  Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
6906  if (!Transformed)
6907  return StmtError();
6908 
6909  if (Transformed != D)
6910  DeclChanged = true;
6911 
6912  Decls.push_back(Transformed);
6913  }
6914 
6915  if (!getDerived().AlwaysRebuild() && !DeclChanged)
6916  return S;
6917 
6918  return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
6919 }
6920 
6921 template<typename Derived>
6922 StmtResult
6924 
6925  SmallVector<Expr*, 8> Constraints;
6926  SmallVector<Expr*, 8> Exprs;
6928 
6929  ExprResult AsmString;
6930  SmallVector<Expr*, 8> Clobbers;
6931 
6932  bool ExprsChanged = false;
6933 
6934  // Go through the outputs.
6935  for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
6936  Names.push_back(S->getOutputIdentifier(I));
6937 
6938  // No need to transform the constraint literal.
6939  Constraints.push_back(S->getOutputConstraintLiteral(I));
6940 
6941  // Transform the output expr.
6942  Expr *OutputExpr = S->getOutputExpr(I);
6943  ExprResult Result = getDerived().TransformExpr(OutputExpr);
6944  if (Result.isInvalid())
6945  return StmtError();
6946 
6947  ExprsChanged |= Result.get() != OutputExpr;
6948 
6949  Exprs.push_back(Result.get());
6950  }
6951 
6952  // Go through the inputs.
6953  for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
6954  Names.push_back(S->getInputIdentifier(I));
6955 
6956  // No need to transform the constraint literal.
6957  Constraints.push_back(S->getInputConstraintLiteral(I));
6958 
6959  // Transform the input expr.
6960  Expr *InputExpr = S->getInputExpr(I);
6961  ExprResult Result = getDerived().TransformExpr(InputExpr);
6962  if (Result.isInvalid())
6963  return StmtError();
6964 
6965  ExprsChanged |= Result.get() != InputExpr;
6966 
6967  Exprs.push_back(Result.get());
6968  }
6969 
6970  if (!getDerived().AlwaysRebuild() && !ExprsChanged)
6971  return S;
6972 
6973  // Go through the clobbers.
6974  for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I)
6975  Clobbers.push_back(S->getClobberStringLiteral(I));
6976 
6977  // No need to transform the asm string literal.
6978  AsmString = S->getAsmString();
6979  return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
6980  S->isVolatile(), S->getNumOutputs(),
6981  S->getNumInputs(), Names.data(),
6982  Constraints, Exprs, AsmString.get(),
6983  Clobbers, S->getRParenLoc());
6984 }
6985 
6986 template<typename Derived>
6987 StmtResult
6989  ArrayRef<Token> AsmToks =
6990  llvm::makeArrayRef(S->getAsmToks(), S->getNumAsmToks());
6991 
6992  bool HadError = false, HadChange = false;
6993 
6994  ArrayRef<Expr*> SrcExprs = S->getAllExprs();
6995  SmallVector<Expr*, 8> TransformedExprs;
6996  TransformedExprs.reserve(SrcExprs.size());
6997  for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
6998  ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
6999  if (!Result.isUsable()) {
7000  HadError = true;
7001  } else {
7002  HadChange |= (Result.get() != SrcExprs[i]);
7003  TransformedExprs.push_back(Result.get());
7004  }
7005  }
7006 
7007  if (HadError) return StmtError();
7008  if (!HadChange && !getDerived().AlwaysRebuild())
7009  return Owned(S);
7010 
7011  return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
7012  AsmToks, S->getAsmString(),
7013  S->getNumOutputs(), S->getNumInputs(),
7014  S->getAllConstraints(), S->getClobbers(),
7015  TransformedExprs, S->getEndLoc());
7016 }
7017 
7018 // C++ Coroutines TS
7019 
7020 template<typename Derived>
7021 StmtResult
7023  auto *ScopeInfo = SemaRef.getCurFunction();
7024  auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
7025  assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
7026  ScopeInfo->NeedsCoroutineSuspends &&
7027  ScopeInfo->CoroutineSuspends.first == nullptr &&
7028  ScopeInfo->CoroutineSuspends.second == nullptr &&
7029  "expected clean scope info");
7030 
7031  // Set that we have (possibly-invalid) suspend points before we do anything
7032  // that may fail.
7033  ScopeInfo->setNeedsCoroutineSuspends(false);
7034 
7035  // The new CoroutinePromise object needs to be built and put into the current
7036  // FunctionScopeInfo before any transformations or rebuilding occurs.
7037  if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
7038  return StmtError();
7039  auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
7040  if (!Promise)
7041  return StmtError();
7042  getDerived().transformedLocalDecl(S->getPromiseDecl(), Promise);
7043  ScopeInfo->CoroutinePromise = Promise;
7044 
7045  // Transform the implicit coroutine statements we built during the initial
7046  // parse.
7047  StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
7048  if (InitSuspend.isInvalid())
7049  return StmtError();
7050  StmtResult FinalSuspend =
7051  getDerived().TransformStmt(S->getFinalSuspendStmt());
7052  if (FinalSuspend.isInvalid())
7053  return StmtError();
7054  ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
7055  assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
7056 
7057  StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
7058  if (BodyRes.isInvalid())
7059  return StmtError();
7060 
7061  CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
7062  if (Builder.isInvalid())
7063  return StmtError();
7064 
7065  Expr *ReturnObject = S->getReturnValueInit();
7066  assert(ReturnObject && "the return object is expected to be valid");
7067  ExprResult Res = getDerived().TransformInitializer(ReturnObject,
7068  /*NoCopyInit*/ false);
7069  if (Res.isInvalid())
7070  return StmtError();
7071  Builder.ReturnValue = Res.get();
7072 
7073  if (S->hasDependentPromiseType()) {
7074  assert(!Promise->getType()->isDependentType() &&
7075  "the promise type must no longer be dependent");
7076  assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
7077  !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
7078  "these nodes should not have been built yet");
7079  if (!Builder.buildDependentStatements())
7080  return StmtError();
7081  } else {
7082  if (auto *OnFallthrough = S->getFallthroughHandler()) {
7083  StmtResult Res = getDerived().TransformStmt(OnFallthrough);
7084  if (Res.isInvalid())
7085  return StmtError();
7086  Builder.OnFallthrough = Res.get();
7087  }
7088 
7089  if (auto *OnException = S->getExceptionHandler()) {
7090  StmtResult Res = getDerived().TransformStmt(OnException);
7091  if (Res.isInvalid())
7092  return StmtError();
7093  Builder.OnException = Res.get();
7094  }
7095 
7096  if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
7097  StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
7098  if (Res.isInvalid())
7099  return StmtError();
7100  Builder.ReturnStmtOnAllocFailure = Res.get();
7101  }
7102 
7103  // Transform any additional statements we may have already built
7104  assert(S->getAllocate() && S->getDeallocate() &&
7105  "allocation and deallocation calls must already be built");
7106  ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
7107  if (AllocRes.isInvalid())
7108  return StmtError();
7109  Builder.Allocate = AllocRes.get();
7110 
7111  ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
7112  if (DeallocRes.isInvalid())
7113  return StmtError();
7114  Builder.Deallocate = DeallocRes.get();
7115 
7116  assert(S->getResultDecl() && "ResultDecl must already be built");
7117  StmtResult ResultDecl = getDerived().TransformStmt(S->getResultDecl());
7118  if (ResultDecl.isInvalid())
7119  return StmtError();
7120  Builder.ResultDecl = ResultDecl.get();
7121 
7122  if (auto *ReturnStmt = S->getReturnStmt()) {
7123  StmtResult Res = getDerived().TransformStmt(ReturnStmt);
7124  if (Res.isInvalid())
7125  return StmtError();
7126  Builder.ReturnStmt = Res.get();
7127  }
7128  }
7129 
7130  return getDerived().RebuildCoroutineBodyStmt(Builder);
7131 }
7132 
7133 template<typename Derived>
7134 StmtResult
7136  ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
7137  /*NotCopyInit*/false);
7138  if (Result.isInvalid())
7139  return StmtError();
7140 
7141  // Always rebuild; we don't know if this needs to be injected into a new
7142  // context or if the promise type has changed.
7143  return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
7144  S->isImplicit());
7145 }
7146 
7147 template<typename Derived>
7148 ExprResult
7150  ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
7151  /*NotCopyInit*/false);
7152  if (Result.isInvalid())
7153  return ExprError();
7154 
7155  // Always rebuild; we don't know if this needs to be injected into a new
7156  // context or if the promise type has changed.
7157  return getDerived().RebuildCoawaitExpr(E->getKeywordLoc(), Result.get(),
7158  E->isImplicit());
7159 }
7160 
7161 template <typename Derived>
7162 ExprResult
7164  ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
7165  /*NotCopyInit*/ false);
7166  if (OperandResult.isInvalid())
7167  return ExprError();
7168 
7169  ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
7171 
7172  if (LookupResult.isInvalid())
7173  return ExprError();
7174 
7175  // Always rebuild; we don't know if this needs to be injected into a new
7176  // context or if the promise type has changed.
7177  return getDerived().RebuildDependentCoawaitExpr(
7178  E->getKeywordLoc(), OperandResult.get(),
7179  cast<UnresolvedLookupExpr>(LookupResult.get()));
7180 }
7181 
7182 template<typename Derived>
7183 ExprResult
7185  ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
7186  /*NotCopyInit*/false);
7187  if (Result.isInvalid())
7188  return ExprError();
7189 
7190  // Always rebuild; we don't know if this needs to be injected into a new
7191  // context or if the promise type has changed.
7192  return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
7193 }
7194 
7195 // Objective-C Statements.
7196 
7197 template<typename Derived>
7198 StmtResult
7200  // Transform the body of the @try.
7201  StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
7202  if (TryBody.isInvalid())
7203  return StmtError();
7204 
7205  // Transform the @catch statements (if present).
7206  bool AnyCatchChanged = false;
7207  SmallVector<Stmt*, 8> CatchStmts;
7208  for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
7209  StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
7210  if (Catch.isInvalid())
7211  return StmtError();
7212  if (Catch.get() != S->getCatchStmt(I))
7213  AnyCatchChanged = true;
7214  CatchStmts.push_back(Catch.get());
7215  }
7216 
7217  // Transform the @finally statement (if present).
7218  StmtResult Finally;
7219  if (S->getFinallyStmt()) {
7220  Finally = getDerived().TransformStmt(S->getFinallyStmt());
7221  if (Finally.isInvalid())
7222  return StmtError();
7223  }
7224 
7225  // If nothing changed, just retain this statement.
7226  if (!getDerived().AlwaysRebuild() &&
7227  TryBody.get() == S->getTryBody() &&
7228  !AnyCatchChanged &&
7229  Finally.get() == S->getFinallyStmt())
7230  return S;
7231 
7232  // Build a new statement.
7233  return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
7234  CatchStmts, Finally.get());
7235 }
7236 
7237 template<typename Derived>
7238 StmtResult
7240  // Transform the @catch parameter, if there is one.
7241  VarDecl *Var = nullptr;
7242  if (VarDecl *FromVar = S->getCatchParamDecl()) {
7243  TypeSourceInfo *TSInfo = nullptr;
7244  if (FromVar->getTypeSourceInfo()) {
7245  TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
7246  if (!TSInfo)
7247  return StmtError();
7248  }
7249 
7250  QualType T;
7251  if (TSInfo)
7252  T = TSInfo->getType();
7253  else {
7254  T = getDerived().TransformType(FromVar->getType());
7255  if (T.isNull())
7256  return StmtError();
7257  }
7258 
7259  Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
7260  if (!Var)
7261  return StmtError();
7262  }
7263 
7264  StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
7265  if (Body.isInvalid())
7266  return StmtError();
7267 
7268  return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
7269  S->getRParenLoc(),
7270  Var, Body.get());
7271 }
7272 
7273 template<typename Derived>
7274 StmtResult
7276  // Transform the body.
7277  StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
7278  if (Body.isInvalid())
7279  return StmtError();
7280 
7281  // If nothing changed, just retain this statement.
7282  if (!getDerived().AlwaysRebuild() &&
7283  Body.get() == S->getFinallyBody())
7284  return S;
7285 
7286  // Build a new statement.
7287  return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
7288  Body.get());
7289 }
7290 
7291 template<typename Derived>
7292 StmtResult
7294  ExprResult Operand;
7295  if (S->getThrowExpr()) {
7296  Operand = getDerived().TransformExpr(S->getThrowExpr());
7297  if (Operand.isInvalid())
7298  return StmtError();
7299  }
7300 
7301  if (!getDerived().AlwaysRebuild() &&
7302  Operand.get() == S->getThrowExpr())
7303  return S;
7304 
7305  return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
7306 }
7307 
7308 template<typename Derived>
7309 StmtResult
7312  // Transform the object we are locking.
7313  ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
7314  if (Object.isInvalid())
7315  return StmtError();
7316  Object =
7317  getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
7318  Object.get());
7319  if (Object.isInvalid())
7320  return StmtError();
7321 
7322  // Transform the body.
7323  StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
7324  if (Body.isInvalid())
7325  return StmtError();
7326 
7327  // If nothing change, just retain the current statement.
7328  if (!getDerived().AlwaysRebuild() &&
7329  Object.get() == S->getSynchExpr() &&
7330  Body.get() == S->getSynchBody())
7331  return S;
7332 
7333  // Build a new statement.
7334  return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
7335  Object.get(), Body.get());
7336 }
7337 
7338 template<typename Derived>
7339 StmtResult
7342  // Transform the body.
7343  StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
7344  if (Body.isInvalid())
7345  return StmtError();
7346 
7347  // If nothing changed, just retain this statement.
7348  if (!getDerived().AlwaysRebuild() &&
7349  Body.get() == S->getSubStmt())
7350  return S;
7351 
7352  // Build a new statement.
7353  return getDerived().RebuildObjCAutoreleasePoolStmt(
7354  S->getAtLoc(), Body.get());
7355 }
7356 
7357 template<typename Derived>
7358 StmtResult
7360  ObjCForCollectionStmt *S) {
7361  // Transform the element statement.
7362  StmtResult Element = getDerived().TransformStmt(S->getElement());
7363  if (Element.isInvalid())
7364  return StmtError();
7365 
7366  // Transform the collection expression.
7367  ExprResult Collection = getDerived().TransformExpr(S->getCollection());
7368  if (Collection.isInvalid())
7369  return StmtError();
7370 
7371  // Transform the body.
7372  StmtResult Body = getDerived().TransformStmt(S->getBody());
7373  if (Body.isInvalid())
7374  return StmtError();
7375 
7376  // If nothing changed, just retain this statement.
7377  if (!getDerived().AlwaysRebuild() &&
7378  Element.get() == S->getElement() &&
7379  Collection.get() == S->getCollection() &&
7380  Body.get() == S->getBody())
7381  return S;
7382 
7383  // Build a new statement.
7384  return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
7385  Element.get(),
7386  Collection.get(),
7387  S->getRParenLoc(),
7388  Body.get());
7389 }
7390 
7391 template <typename Derived>
7393  // Transform the exception declaration, if any.
7394  VarDecl *Var = nullptr;
7395  if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
7396  TypeSourceInfo *T =
7397  getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
7398  if (!T)
7399  return StmtError();
7400 
7401  Var = getDerived().RebuildExceptionDecl(
7402  ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
7403  ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
7404  if (!Var || Var->isInvalidDecl())
7405  return StmtError();
7406  }
7407 
7408  // Transform the actual exception handler.
7409  StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
7410  if (Handler.isInvalid())
7411  return StmtError();
7412 
7413  if (!getDerived().AlwaysRebuild() && !Var &&
7414  Handler.get() == S->getHandlerBlock())
7415  return S;
7416 
7417  return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
7418 }
7419 
7420 template <typename Derived>
7422  // Transform the try block itself.
7423  StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
7424  if (TryBlock.isInvalid())
7425  return StmtError();
7426 
7427  // Transform the handlers.
7428  bool HandlerChanged = false;
7429  SmallVector<Stmt *, 8> Handlers;
7430  for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
7431  StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
7432  if (Handler.isInvalid())
7433  return StmtError();
7434 
7435  HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
7436  Handlers.push_back(Handler.getAs<Stmt>());
7437  }
7438 
7439  if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
7440  !HandlerChanged)
7441  return S;
7442 
7443  return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
7444  Handlers);
7445 }
7446 
7447 template<typename Derived>
7448 StmtResult
7450  StmtResult Init =
7451  S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
7452  if (Init.isInvalid())
7453  return StmtError();
7454 
7455  StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
7456  if (Range.isInvalid())
7457  return StmtError();
7458 
7459  StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
7460  if (Begin.isInvalid())
7461  return StmtError();
7462  StmtResult End = getDerived().TransformStmt(S->getEndStmt());
7463  if (End.isInvalid())
7464  return StmtError();
7465 
7466  ExprResult Cond = getDerived().TransformExpr(S->getCond());
7467  if (Cond.isInvalid())
7468  return StmtError();
7469  if (Cond.get())
7470  Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
7471  if (Cond.isInvalid())
7472  return StmtError();
7473  if (Cond.get())
7474  Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
7475 
7476  ExprResult Inc = getDerived().TransformExpr(S->getInc());
7477  if (Inc.isInvalid())
7478  return StmtError();
7479  if (Inc.get())
7480  Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
7481 
7482  StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
7483  if (LoopVar.isInvalid())
7484  return StmtError();
7485 
7486  StmtResult NewStmt = S;
7487  if (getDerived().AlwaysRebuild() ||
7488  Init.get() != S->getInit() ||
7489  Range.get() != S->getRangeStmt() ||
7490  Begin.get() != S->getBeginStmt() ||
7491  End.get() != S->getEndStmt() ||
7492  Cond.get() != S->getCond() ||
7493  Inc.get() != S->getInc() ||
7494  LoopVar.get() != S->getLoopVarStmt()) {
7495  NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(),
7496  S->getCoawaitLoc(), Init.get(),
7497  S->getColonLoc(), Range.get(),
7498  Begin.get(), End.get(),
7499  Cond.get(),
7500  Inc.get(), LoopVar.get(),
7501  S->getRParenLoc());
7502  if (NewStmt.isInvalid())
7503  return StmtError();
7504  }
7505 
7506  StmtResult Body = getDerived().TransformStmt(S->getBody());
7507  if (Body.isInvalid())
7508  return StmtError();
7509 
7510  // Body has changed but we didn't rebuild the for-range statement. Rebuild
7511  // it now so we have a new statement to attach the body to.
7512  if (Body.get() != S->getBody() && NewStmt.get() == S) {
7513  NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(),
7514  S->getCoawaitLoc(), Init.get(),
7515  S->getColonLoc(), Range.get(),
7516  Begin.get(), End.get(),
7517  Cond.get(),
7518  Inc.get(), LoopVar.get(),
7519  S->getRParenLoc());
7520  if (NewStmt.isInvalid())
7521  return StmtError();
7522  }
7523 
7524  if (NewStmt.get() == S)
7525  return S;
7526 
7527  return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
7528 }
7529 
7530 template<typename Derived>
7531 StmtResult
7533  MSDependentExistsStmt *S) {
7534  // Transform the nested-name-specifier, if any.
7535  NestedNameSpecifierLoc QualifierLoc;
7536  if (S->getQualifierLoc()) {
7537  QualifierLoc
7538  = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
7539  if (!QualifierLoc)
7540  return StmtError();
7541  }
7542 
7543  // Transform the declaration name.
7544  DeclarationNameInfo NameInfo = S->getNameInfo();
7545  if (NameInfo.getName()) {
7546  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
7547  if (!NameInfo.getName())
7548  return StmtError();
7549  }
7550 
7551  // Check whether anything changed.
7552  if (!getDerived().AlwaysRebuild() &&
7553  QualifierLoc == S->getQualifierLoc() &&
7554  NameInfo.getName() == S->getNameInfo().getName())
7555  return S;
7556 
7557  // Determine whether this name exists, if we can.
7558  CXXScopeSpec SS;
7559  SS.Adopt(QualifierLoc);
7560  bool Dependent = false;
7561  switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
7562  case Sema::IER_Exists:
7563  if (S->isIfExists())
7564  break;
7565 
7566  return new (getSema().Context) NullStmt(S->getKeywordLoc());
7567 
7569  if (S->isIfNotExists())
7570  break;
7571 
7572  return new (getSema().Context) NullStmt(S->getKeywordLoc());
7573 
7574  case Sema::IER_Dependent:
7575  Dependent = true;
7576  break;
7577 
7578  case Sema::IER_Error:
7579  return StmtError();
7580  }
7581 
7582  // We need to continue with the instantiation, so do so now.
7583  StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
7584  if (SubStmt.isInvalid())
7585  return StmtError();
7586 
7587  // If we have resolved the name, just transform to the substatement.
7588  if (!Dependent)
7589  return SubStmt;
7590 
7591  // The name is still dependent, so build a dependent expression again.
7592  return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
7593  S->isIfExists(),
7594  QualifierLoc,
7595  NameInfo,
7596  SubStmt.get());
7597 }
7598 
7599 template<typename Derived>
7600 ExprResult
7602  NestedNameSpecifierLoc QualifierLoc;
7603  if (E->getQualifierLoc()) {
7604  QualifierLoc
7605  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
7606  if (!QualifierLoc)
7607  return ExprError();
7608  }
7609 
7610  MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
7611  getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
7612  if (!PD)
7613  return ExprError();
7614 
7615  ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
7616  if (Base.isInvalid())
7617  return ExprError();
7618 
7619  return new (SemaRef.getASTContext())
7620  MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
7621  SemaRef.getASTContext().PseudoObjectTy, VK_LValue,
7622  QualifierLoc, E->getMemberLoc());
7623 }
7624 
7625 template <typename Derived>
7628  auto BaseRes = getDerived().TransformExpr(E->getBase());
7629  if (BaseRes.isInvalid())
7630  return ExprError();
7631  auto IdxRes = getDerived().TransformExpr(E->getIdx());
7632  if (IdxRes.isInvalid())
7633  return ExprError();
7634 
7635  if (!getDerived().AlwaysRebuild() &&
7636  BaseRes.get() == E->getBase() &&
7637  IdxRes.get() == E->getIdx())
7638  return E;
7639 
7640  return getDerived().RebuildArraySubscriptExpr(
7641  BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
7642 }
7643 
7644 template <typename Derived>
7646  StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
7647  if (TryBlock.isInvalid())
7648  return StmtError();
7649 
7650  StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
7651  if (Handler.isInvalid())
7652  return StmtError();
7653 
7654  if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
7655  Handler.get() == S->getHandler())
7656  return S;
7657 
7658  return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
7659  TryBlock.get(), Handler.get());
7660 }
7661 
7662 template <typename Derived>
7664  StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
7665  if (Block.isInvalid())
7666  return StmtError();
7667 
7668  return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
7669 }
7670 
7671 template <typename Derived>
7673  ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
7674  if (FilterExpr.isInvalid())
7675  return StmtError();
7676 
7677  StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
7678  if (Block.isInvalid())
7679  return StmtError();
7680 
7681  return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
7682  Block.get());
7683 }
7684 
7685 template <typename Derived>
7687  if (isa<SEHFinallyStmt>(Handler))
7688  return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
7689  else
7690  return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
7691 }
7692 
7693 template<typename Derived>
7694 StmtResult
7696  return S;
7697 }
7698 
7699 //===----------------------------------------------------------------------===//
7700 // OpenMP directive transformation
7701 //===----------------------------------------------------------------------===//
7702 template <typename Derived>
7705 
7706  // Transform the clauses
7708  ArrayRef<OMPClause *> Clauses = D->clauses();
7709  TClauses.reserve(Clauses.size());
7710  for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
7711  I != E; ++I) {
7712  if (*I) {
7713  getDerived().getSema().StartOpenMPClause((*I)->getClauseKind());
7714  OMPClause *Clause = getDerived().TransformOMPClause(*I);
7715  getDerived().getSema().EndOpenMPClause();
7716  if (Clause)
7717  TClauses.push_back(Clause);
7718  } else {
7719  TClauses.push_back(nullptr);
7720  }
7721  }
7722  StmtResult AssociatedStmt;
7723  if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
7724  getDerived().getSema().ActOnOpenMPRegionStart(D->getDirectiveKind(),
7725  /*CurScope=*/nullptr);
7726  StmtResult Body;
7727  {
7728  Sema::CompoundScopeRAII CompoundScope(getSema());
7730  Body = getDerived().TransformStmt(CS);
7731  }
7732  AssociatedStmt =
7733  getDerived().getSema().ActOnOpenMPRegionEnd(Body, TClauses);
7734  if (AssociatedStmt.isInvalid()) {
7735  return StmtError();
7736  }
7737  }
7738  if (TClauses.size() != Clauses.size()) {
7739  return StmtError();
7740  }
7741 
7742  // Transform directive name for 'omp critical' directive.
7743  DeclarationNameInfo DirName;
7744  if (D->getDirectiveKind() == OMPD_critical) {
7745  DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
7746  DirName = getDerived().TransformDeclarationNameInfo(DirName);
7747  }
7748  OpenMPDirectiveKind CancelRegion = OMPD_unknown;
7749  if (D->getDirectiveKind() == OMPD_cancellation_point) {
7750  CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
7751  } else if (D->getDirectiveKind() == OMPD_cancel) {
7752  CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
7753  }
7754 
7755  return getDerived().RebuildOMPExecutableDirective(
7756  D->getDirectiveKind(), DirName, CancelRegion, TClauses,
7757  AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
7758 }
7759 
7760 template <typename Derived>
7761 StmtResult
7763  DeclarationNameInfo DirName;
7764  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel, DirName, nullptr,
7765  D->getBeginLoc());
7766  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7767  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7768  return Res;
7769 }
7770 
7771 template <typename Derived>
7772 StmtResult
7774  DeclarationNameInfo DirName;
7775  getDerived().getSema().StartOpenMPDSABlock(OMPD_simd, DirName, nullptr,
7776  D->getBeginLoc());
7777  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7778  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7779  return Res;
7780 }
7781 
7782 template <typename Derived>
7783 StmtResult
7785  DeclarationNameInfo DirName;
7786  getDerived().getSema().StartOpenMPDSABlock(OMPD_for, DirName, nullptr,
7787  D->getBeginLoc());
7788  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7789  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7790  return Res;
7791 }
7792 
7793 template <typename Derived>
7794 StmtResult
7796  DeclarationNameInfo DirName;
7797  getDerived().getSema().StartOpenMPDSABlock(OMPD_for_simd, DirName, nullptr,
7798  D->getBeginLoc());
7799  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7800  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7801  return Res;
7802 }
7803 
7804 template <typename Derived>
7805 StmtResult
7807  DeclarationNameInfo DirName;
7808  getDerived().getSema().StartOpenMPDSABlock(OMPD_sections, DirName, nullptr,
7809  D->getBeginLoc());
7810  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7811  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7812  return Res;
7813 }
7814 
7815 template <typename Derived>
7816 StmtResult
7818  DeclarationNameInfo DirName;
7819  getDerived().getSema().StartOpenMPDSABlock(OMPD_section, DirName, nullptr,
7820  D->getBeginLoc());
7821  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7822  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7823  return Res;
7824 }
7825 
7826 template <typename Derived>
7827 StmtResult
7829  DeclarationNameInfo DirName;
7830  getDerived().getSema().StartOpenMPDSABlock(OMPD_single, DirName, nullptr,
7831  D->getBeginLoc());
7832  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7833  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7834  return Res;
7835 }
7836 
7837 template <typename Derived>
7838 StmtResult
7840  DeclarationNameInfo DirName;
7841  getDerived().getSema().StartOpenMPDSABlock(OMPD_master, DirName, nullptr,
7842  D->getBeginLoc());
7843  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7844  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7845  return Res;
7846 }
7847 
7848 template <typename Derived>
7849 StmtResult
7851  getDerived().getSema().StartOpenMPDSABlock(
7852  OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
7853  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7854  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7855  return Res;
7856 }
7857 
7858 template <typename Derived>
7861  DeclarationNameInfo DirName;
7862  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_for, DirName,
7863  nullptr, D->getBeginLoc());
7864  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7865  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7866  return Res;
7867 }
7868 
7869 template <typename Derived>
7872  DeclarationNameInfo DirName;
7873  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_for_simd, DirName,
7874  nullptr, D->getBeginLoc());
7875  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7876  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7877  return Res;
7878 }
7879 
7880 template <typename Derived>
7883  DeclarationNameInfo DirName;
7884  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_sections, DirName,
7885  nullptr, D->getBeginLoc());
7886  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7887  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7888  return Res;
7889 }
7890 
7891 template <typename Derived>
7892 StmtResult
7894  DeclarationNameInfo DirName;
7895  getDerived().getSema().StartOpenMPDSABlock(OMPD_task, DirName, nullptr,
7896  D->getBeginLoc());
7897  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7898  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7899  return Res;
7900 }
7901 
7902 template <typename Derived>
7904  OMPTaskyieldDirective *D) {
7905  DeclarationNameInfo DirName;
7906  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskyield, DirName, nullptr,
7907  D->getBeginLoc());
7908  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7909  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7910  return Res;
7911 }
7912 
7913 template <typename Derived>
7914 StmtResult
7916  DeclarationNameInfo DirName;
7917  getDerived().getSema().StartOpenMPDSABlock(OMPD_barrier, DirName, nullptr,
7918  D->getBeginLoc());
7919  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7920  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7921  return Res;
7922 }
7923 
7924 template <typename Derived>
7925 StmtResult
7927  DeclarationNameInfo DirName;
7928  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskwait, DirName, nullptr,
7929  D->getBeginLoc());
7930  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7931  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7932  return Res;
7933 }
7934 
7935 template <typename Derived>
7937  OMPTaskgroupDirective *D) {
7938  DeclarationNameInfo DirName;
7939  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskgroup, DirName, nullptr,
7940  D->getBeginLoc());
7941  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7942  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7943  return Res;
7944 }
7945 
7946 template <typename Derived>
7947 StmtResult
7949  DeclarationNameInfo DirName;
7950  getDerived().getSema().StartOpenMPDSABlock(OMPD_flush, DirName, nullptr,
7951  D->getBeginLoc());
7952  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7953  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7954  return Res;
7955 }
7956 
7957 template <typename Derived>
7958 StmtResult
7960  DeclarationNameInfo DirName;
7961  getDerived().getSema().StartOpenMPDSABlock(OMPD_ordered, DirName, nullptr,
7962  D->getBeginLoc());
7963  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7964  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7965  return Res;
7966 }
7967 
7968 template <typename Derived>
7969 StmtResult
7971  DeclarationNameInfo DirName;
7972  getDerived().getSema().StartOpenMPDSABlock(OMPD_atomic, DirName, nullptr,
7973  D->getBeginLoc());
7974  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7975  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7976  return Res;
7977 }
7978 
7979 template <typename Derived>
7980 StmtResult
7982  DeclarationNameInfo DirName;
7983  getDerived().getSema().StartOpenMPDSABlock(OMPD_target, DirName, nullptr,
7984  D->getBeginLoc());
7985  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7986  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7987  return Res;
7988 }
7989 
7990 template <typename Derived>
7993  DeclarationNameInfo DirName;
7994  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_data, DirName, nullptr,
7995  D->getBeginLoc());
7996  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7997  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7998  return Res;
7999 }
8000 
8001 template <typename Derived>
8004  DeclarationNameInfo DirName;
8005  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_enter_data, DirName,
8006  nullptr, D->getBeginLoc());
8007  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8008  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8009  return Res;
8010 }
8011 
8012 template <typename Derived>
8015  DeclarationNameInfo DirName;
8016  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_exit_data, DirName,
8017  nullptr, D->getBeginLoc());
8018  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8019  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8020  return Res;
8021 }
8022 
8023 template <typename Derived>
8026  DeclarationNameInfo DirName;
8027  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel, DirName,
8028  nullptr, D->getBeginLoc());
8029  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8030  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8031  return Res;
8032 }
8033 
8034 template <typename Derived>
8037  DeclarationNameInfo DirName;
8038  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel_for, DirName,
8039  nullptr, D->getBeginLoc());
8040  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8041  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8042  return Res;
8043 }
8044 
8045 template <typename Derived>
8048  DeclarationNameInfo DirName;
8049  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_update, DirName,
8050  nullptr, D->getBeginLoc());
8051  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8052  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8053  return Res;
8054 }
8055 
8056 template <typename Derived>
8057 StmtResult
8059  DeclarationNameInfo DirName;
8060  getDerived().getSema().StartOpenMPDSABlock(OMPD_teams, DirName, nullptr,
8061  D->getBeginLoc());
8062  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8063  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8064  return Res;
8065 }
8066 
8067 template <typename Derived>
8070  DeclarationNameInfo DirName;
8071  getDerived().getSema().StartOpenMPDSABlock(OMPD_cancellation_point, DirName,
8072  nullptr, D->getBeginLoc());
8073  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8074  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8075  return Res;
8076 }
8077 
8078 template <typename Derived>
8079 StmtResult
8081  DeclarationNameInfo DirName;
8082  getDerived().getSema().StartOpenMPDSABlock(OMPD_cancel, DirName, nullptr,
8083  D->getBeginLoc());
8084  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8085  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8086  return Res;
8087 }
8088 
8089 template <typename Derived>
8090 StmtResult
8092  DeclarationNameInfo DirName;
8093  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop, DirName, nullptr,
8094  D->getBeginLoc());
8095  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8096  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8097  return Res;
8098 }
8099 
8100 template <typename Derived>
8103  DeclarationNameInfo DirName;
8104  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop_simd, DirName,
8105  nullptr, D->getBeginLoc());
8106  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8107  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8108  return Res;
8109 }
8110 
8111 template <typename Derived>
8114  DeclarationNameInfo DirName;
8115  getDerived().getSema().StartOpenMPDSABlock(OMPD_distribute, DirName, nullptr,
8116  D->getBeginLoc());
8117  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8118  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8119  return Res;
8120 }
8121 
8122 template <typename Derived>
8125  DeclarationNameInfo DirName;
8126  getDerived().getSema().StartOpenMPDSABlock(
8127  OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
8128  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8129  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8130  return Res;
8131 }
8132 
8133 template <typename Derived>
8134 StmtResult
8137  DeclarationNameInfo DirName;
8138  getDerived().getSema().StartOpenMPDSABlock(
8139  OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
8140  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8141  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8142  return Res;
8143 }
8144 
8145 template <typename Derived>
8148  DeclarationNameInfo DirName;
8149  getDerived().getSema().StartOpenMPDSABlock(OMPD_distribute_simd, DirName,
8150  nullptr, D->getBeginLoc());
8151  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8152  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8153  return Res;
8154 }
8155 
8156 template <typename Derived>
8159  DeclarationNameInfo DirName;
8160  getDerived().getSema().StartOpenMPDSABlock(
8161  OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
8162  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8163  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8164  return Res;
8165 }
8166 
8167 template <typename Derived>
8170  DeclarationNameInfo DirName;
8171  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_simd, DirName, nullptr,
8172  D->getBeginLoc());
8173  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8174  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8175  return Res;
8176 }
8177 
8178 template <typename Derived>
8181  DeclarationNameInfo DirName;
8182  getDerived().getSema().StartOpenMPDSABlock(OMPD_teams_distribute, DirName,
8183  nullptr, D->getBeginLoc());
8184  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8185  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8186  return Res;
8187 }
8188 
8189 template <typename Derived>
8192  DeclarationNameInfo DirName;
8193  getDerived().getSema().StartOpenMPDSABlock(
8194  OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
8195  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8196  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8197  return Res;
8198 }
8199 
8200 template <typename Derived>
8203  DeclarationNameInfo DirName;
8204  getDerived().getSema().StartOpenMPDSABlock(
8205  OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
8206  D->getBeginLoc());
8207  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8208  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8209  return Res;
8210 }
8211 
8212 template <typename Derived>
8215  DeclarationNameInfo DirName;
8216  getDerived().getSema().StartOpenMPDSABlock(
8217  OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
8218  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8219  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8220  return Res;
8221 }
8222 
8223 template <typename Derived>
8226  DeclarationNameInfo DirName;
8227  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_teams, DirName,
8228  nullptr, D->getBeginLoc());
8229  auto Res = getDerived().TransformOMPExecutableDirective(D);
8230  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8231  return Res;
8232 }
8233 
8234 template <typename Derived>
8237  DeclarationNameInfo DirName;
8238  getDerived().getSema().StartOpenMPDSABlock(
8239  OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
8240  auto Res = getDerived().TransformOMPExecutableDirective(D);
8241  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8242  return Res;
8243 }
8244 
8245 template <typename Derived>
8246 StmtResult
8249  DeclarationNameInfo DirName;
8250  getDerived().getSema().StartOpenMPDSABlock(
8251  OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
8252  D->getBeginLoc());
8253  auto Res = getDerived().TransformOMPExecutableDirective(D);
8254  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8255  return Res;
8256 }
8257 
8258 template <typename Derived>
8262  DeclarationNameInfo DirName;
8263  getDerived().getSema().StartOpenMPDSABlock(
8264  OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
8265  D->getBeginLoc());
8266  auto Res = getDerived().TransformOMPExecutableDirective(D);
8267  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8268  return Res;
8269 }
8270 
8271 template <typename Derived>
8272 StmtResult
8275  DeclarationNameInfo DirName;
8276  getDerived().getSema().StartOpenMPDSABlock(
8277  OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
8278  auto Res = getDerived().TransformOMPExecutableDirective(D);
8279  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8280  return Res;
8281 }
8282 
8283 
8284 //===----------------------------------------------------------------------===//
8285 // OpenMP clause transformation
8286 //===----------------------------------------------------------------------===//
8287 template <typename Derived>
8289  ExprResult Cond = getDerived().TransformExpr(C->getCondition());
8290  if (Cond.isInvalid())
8291  return nullptr;
8292  return getDerived().RebuildOMPIfClause(
8293  C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
8294  C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
8295 }
8296 
8297 template <typename Derived>
8299  ExprResult Cond = getDerived().TransformExpr(C->getCondition());
8300  if (Cond.isInvalid())
8301  return nullptr;
8302  return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
8303  C->getLParenLoc(), C->getEndLoc());
8304 }
8305 
8306 template <typename Derived>
8307 OMPClause *
8309  ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
8310  if (NumThreads.isInvalid())
8311  return nullptr;
8312  return getDerived().RebuildOMPNumThreadsClause(
8313  NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8314 }
8315 
8316 template <typename Derived>
8317 OMPClause *
8319  ExprResult E = getDerived().TransformExpr(C->getSafelen());
8320  if (E.isInvalid())
8321  return nullptr;
8322  return getDerived().RebuildOMPSafelenClause(
8323  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8324 }
8325 
8326 template <typename Derived>
8327 OMPClause *
8329  ExprResult E = getDerived().TransformExpr(C->getSimdlen());
8330  if (E.isInvalid())
8331  return nullptr;
8332  return getDerived().RebuildOMPSimdlenClause(
8333  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8334 }
8335 
8336 template <typename Derived>
8337 OMPClause *
8339  ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
8340  if (E.isInvalid())
8341  return nullptr;
8342  return getDerived().RebuildOMPCollapseClause(
8343  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8344 }
8345 
8346 template <typename Derived>
8347 OMPClause *
8349  return getDerived().RebuildOMPDefaultClause(
8351  C->getLParenLoc(), C->getEndLoc());
8352 }
8353 
8354 template <typename Derived>
8355 OMPClause *
8357  return getDerived().RebuildOMPProcBindClause(
8359  C->getLParenLoc(), C->getEndLoc());
8360 }
8361 
8362 template <typename Derived>
8363 OMPClause *
8365  ExprResult E = getDerived().TransformExpr(C->getChunkSize());
8366  if (E.isInvalid())
8367  return nullptr;
8368  return getDerived().RebuildOMPScheduleClause(
8370  C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
8372  C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
8373 }
8374 
8375 template <typename Derived>
8376 OMPClause *
8378  ExprResult E;
8379  if (auto *Num = C->getNumForLoops()) {
8380  E = getDerived().TransformExpr(Num);
8381  if (E.isInvalid())
8382  return nullptr;
8383  }
8384  return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
8385  C->getLParenLoc(), E.get());
8386 }
8387 
8388 template <typename Derived>
8389 OMPClause *
8391  // No need to rebuild this clause, no template-dependent parameters.
8392  return C;
8393 }
8394 
8395 template <typename Derived>
8396 OMPClause *
8398  // No need to rebuild this clause, no template-dependent parameters.
8399  return C;
8400 }
8401 
8402 template <typename Derived>
8403 OMPClause *
8405  // No need to rebuild this clause, no template-dependent parameters.
8406  return C;
8407 }
8408 
8409 template <typename Derived>
8411  // No need to rebuild this clause, no template-dependent parameters.
8412  return C;
8413 }
8414 
8415 template <typename Derived>
8417  // No need to rebuild this clause, no template-dependent parameters.
8418  return C;
8419 }
8420 
8421 template <typename Derived>
8422 OMPClause *
8424  // No need to rebuild this clause, no template-dependent parameters.
8425  return C;
8426 }
8427 
8428 template <typename Derived>
8429 OMPClause *
8431  // No need to rebuild this clause, no template-dependent parameters.
8432  return C;
8433 }
8434 
8435 template <typename Derived>
8436 OMPClause *
8438  // No need to rebuild this clause, no template-dependent parameters.
8439  return C;
8440 }
8441 
8442 template <typename Derived>
8443 OMPClause *
8445  // No need to rebuild this clause, no template-dependent parameters.
8446  return C;
8447 }
8448 
8449 template <typename Derived>
8451  // No need to rebuild this clause, no template-dependent parameters.
8452  return C;
8453 }
8454 
8455 template <typename Derived>
8456 OMPClause *
8458  // No need to rebuild this clause, no template-dependent parameters.
8459  return C;
8460 }
8461 
8462 template <typename Derived>
8465  llvm_unreachable("unified_address clause cannot appear in dependent context");
8466 }
8467 
8468 template <typename Derived>
8471  llvm_unreachable(
8472  "unified_shared_memory clause cannot appear in dependent context");
8473 }
8474 
8475 template <typename Derived>
8478  llvm_unreachable("reverse_offload clause cannot appear in dependent context");
8479 }
8480 
8481 template <typename Derived>
8484  llvm_unreachable(
8485  "dynamic_allocators clause cannot appear in dependent context");
8486 }
8487 
8488 template <typename Derived>
8491  llvm_unreachable(
8492  "atomic_default_mem_order clause cannot appear in dependent context");
8493 }
8494 
8495 template <typename Derived>
8496 OMPClause *
8499  Vars.reserve(C->varlist_size());
8500  for (auto *VE : C->varlists()) {
8501  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8502  if (EVar.isInvalid())
8503  return nullptr;
8504  Vars.push_back(EVar.get());
8505  }
8506  return getDerived().RebuildOMPPrivateClause(
8507  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8508 }
8509 
8510 template <typename Derived>
8512  OMPFirstprivateClause *C) {
8514  Vars.reserve(C->varlist_size());
8515  for (auto *VE : C->varlists()) {
8516  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8517  if (EVar.isInvalid())
8518  return nullptr;
8519  Vars.push_back(EVar.get());
8520  }
8521  return getDerived().RebuildOMPFirstprivateClause(
8522  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8523 }
8524 
8525 template <typename Derived>
8526 OMPClause *
8529  Vars.reserve(C->varlist_size());
8530  for (auto *VE : C->varlists()) {
8531  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8532  if (EVar.isInvalid())
8533  return nullptr;
8534  Vars.push_back(EVar.get());
8535  }
8536  return getDerived().RebuildOMPLastprivateClause(
8537  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8538 }
8539 
8540 template <typename Derived>
8541 OMPClause *
8544  Vars.reserve(C->varlist_size());
8545  for (auto *VE : C->varlists()) {
8546  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8547  if (EVar.isInvalid())
8548  return nullptr;
8549  Vars.push_back(EVar.get());
8550  }
8551  return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
8552  C->getLParenLoc(), C->getEndLoc());
8553 }
8554 
8555 template <typename Derived>
8556 OMPClause *
8559  Vars.reserve(C->varlist_size());
8560  for (auto *VE : C->varlists()) {
8561  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8562  if (EVar.isInvalid())
8563  return nullptr;
8564  Vars.push_back(EVar.get());
8565  }
8566  CXXScopeSpec ReductionIdScopeSpec;
8567  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8568 
8569  DeclarationNameInfo NameInfo = C->getNameInfo();
8570  if (NameInfo.getName()) {
8571  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8572  if (!NameInfo.getName())
8573  return nullptr;
8574  }
8575  // Build a list of all UDR decls with the same names ranged by the Scopes.
8576  // The Scope boundary is a duplication of the previous decl.
8577  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8578  for (auto *E : C->reduction_ops()) {
8579  // Transform all the decls.
8580  if (E) {
8581  auto *ULE = cast<UnresolvedLookupExpr>(E);
8582  UnresolvedSet<8> Decls;
8583  for (auto *D : ULE->decls()) {
8584  NamedDecl *InstD =
8585  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8586  Decls.addDecl(InstD, InstD->getAccess());
8587  }
8588  UnresolvedReductions.push_back(
8590  SemaRef.Context, /*NamingClass=*/nullptr,
8591  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context),
8592  NameInfo, /*ADL=*/true, ULE->isOverloaded(),
8593  Decls.begin(), Decls.end()));
8594  } else
8595  UnresolvedReductions.push_back(nullptr);
8596  }
8597  return getDerived().RebuildOMPReductionClause(
8598  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
8599  C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8600 }
8601 
8602 template <typename Derived>
8606  Vars.reserve(C->varlist_size());
8607  for (auto *VE : C->varlists()) {
8608  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8609  if (EVar.isInvalid())
8610  return nullptr;
8611  Vars.push_back(EVar.get());
8612  }
8613  CXXScopeSpec ReductionIdScopeSpec;
8614  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8615 
8616  DeclarationNameInfo NameInfo = C->getNameInfo();
8617  if (NameInfo.getName()) {
8618  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8619  if (!NameInfo.getName())
8620  return nullptr;
8621  }
8622  // Build a list of all UDR decls with the same names ranged by the Scopes.
8623  // The Scope boundary is a duplication of the previous decl.
8624  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8625  for (auto *E : C->reduction_ops()) {
8626  // Transform all the decls.
8627  if (E) {
8628  auto *ULE = cast<UnresolvedLookupExpr>(E);
8629  UnresolvedSet<8> Decls;
8630  for (auto *D : ULE->decls()) {
8631  NamedDecl *InstD =
8632  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8633  Decls.addDecl(InstD, InstD->getAccess());
8634  }
8635  UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
8636  SemaRef.Context, /*NamingClass=*/nullptr,
8637  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
8638  /*ADL=*/true, ULE->isOverloaded(), Decls.begin(), Decls.end()));
8639  } else
8640  UnresolvedReductions.push_back(nullptr);
8641  }
8642  return getDerived().RebuildOMPTaskReductionClause(
8643  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
8644  C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8645 }
8646 
8647 template <typename Derived>
8648 OMPClause *
8651  Vars.reserve(C->varlist_size());
8652  for (auto *VE : C->varlists()) {
8653  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8654  if (EVar.isInvalid())
8655  return nullptr;
8656  Vars.push_back(EVar.get());
8657  }
8658  CXXScopeSpec ReductionIdScopeSpec;
8659  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8660 
8661  DeclarationNameInfo NameInfo = C->getNameInfo();
8662  if (NameInfo.getName()) {
8663  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8664  if (!NameInfo.getName())
8665  return nullptr;
8666  }
8667  // Build a list of all UDR decls with the same names ranged by the Scopes.
8668  // The Scope boundary is a duplication of the previous decl.
8669  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8670  for (auto *E : C->reduction_ops()) {
8671  // Transform all the decls.
8672  if (E) {
8673  auto *ULE = cast<UnresolvedLookupExpr>(E);
8674  UnresolvedSet<8> Decls;
8675  for (auto *D : ULE->decls()) {
8676  NamedDecl *InstD =
8677  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8678  Decls.addDecl(InstD, InstD->getAccess());
8679  }
8680  UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
8681  SemaRef.Context, /*NamingClass=*/nullptr,
8682  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
8683  /*ADL=*/true, ULE->isOverloaded(), Decls.begin(), Decls.end()));
8684  } else
8685  UnresolvedReductions.push_back(nullptr);
8686  }
8687  return getDerived().RebuildOMPInReductionClause(
8688  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
8689  C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8690 }
8691 
8692 template <typename Derived>
8693 OMPClause *
8696  Vars.reserve(C->varlist_size());
8697  for (auto *VE : C->varlists()) {
8698  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8699  if (EVar.isInvalid())
8700  return nullptr;
8701  Vars.push_back(EVar.get());
8702  }
8703  ExprResult Step = getDerived().TransformExpr(C->getStep());
8704  if (Step.isInvalid())
8705  return nullptr;
8706  return getDerived().RebuildOMPLinearClause(
8707  Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
8708  C->getModifierLoc(), C->getColonLoc(), C->getEndLoc());
8709 }
8710 
8711 template <typename Derived>
8712 OMPClause *
8715  Vars.reserve(C->varlist_size());
8716  for (auto *VE : C->varlists()) {
8717  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8718  if (EVar.isInvalid())
8719  return nullptr;
8720  Vars.push_back(EVar.get());
8721  }
8722  ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
8723  if (Alignment.isInvalid())
8724  return nullptr;
8725  return getDerived().RebuildOMPAlignedClause(
8726  Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
8727  C->getColonLoc(), C->getEndLoc());
8728 }
8729 
8730 template <typename Derived>
8731 OMPClause *
8734  Vars.reserve(C->varlist_size());
8735  for (auto *VE : C->varlists()) {
8736  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8737  if (EVar.isInvalid())
8738  return nullptr;
8739  Vars.push_back(EVar.get());
8740  }
8741  return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
8742  C->getLParenLoc(), C->getEndLoc());
8743 }
8744 
8745 template <typename Derived>
8746 OMPClause *
8749  Vars.reserve(C->varlist_size());
8750  for (auto *VE : C->varlists()) {
8751  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8752  if (EVar.isInvalid())
8753  return nullptr;
8754  Vars.push_back(EVar.get());
8755  }
8756  return getDerived().RebuildOMPCopyprivateClause(
8757  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8758 }
8759 
8760 template <typename Derived>
8763  Vars.reserve(C->varlist_size());
8764  for (auto *VE : C->varlists()) {
8765  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8766  if (EVar.isInvalid())
8767  return nullptr;
8768  Vars.push_back(EVar.get());
8769  }
8770  return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
8771  C->getLParenLoc(), C->getEndLoc());
8772 }
8773 
8774 template <typename Derived>
8775 OMPClause *
8778  Vars.reserve(C->varlist_size());
8779  for (auto *VE : C->varlists()) {
8780  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8781  if (EVar.isInvalid())
8782  return nullptr;
8783  Vars.push_back(EVar.get());
8784  }
8785  return getDerived().RebuildOMPDependClause(
8786  C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(), Vars,
8787  C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8788 }
8789 
8790 template <typename Derived>
8791 OMPClause *
8793  ExprResult E = getDerived().TransformExpr(C->getDevice());
8794  if (E.isInvalid())
8795  return nullptr;
8796  return getDerived().RebuildOMPDeviceClause(E.get(), C->getBeginLoc(),
8797  C->getLParenLoc(), C->getEndLoc());
8798 }
8799 
8800 template <typename Derived>
8803  Vars.reserve(C->varlist_size());
8804  for (auto *VE : C->varlists()) {
8805  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8806  if (EVar.isInvalid())
8807  return nullptr;
8808  Vars.push_back(EVar.get());
8809  }
8810  return getDerived().RebuildOMPMapClause(
8812  C->isImplicitMapType(), C->getMapLoc(), C->getColonLoc(), Vars,
8813  C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8814 }
8815 
8816 template <typename Derived>
8817 OMPClause *
8819  ExprResult E = getDerived().TransformExpr(C->getNumTeams());
8820  if (E.isInvalid())
8821  return nullptr;
8822  return getDerived().RebuildOMPNumTeamsClause(
8823  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8824 }
8825 
8826 template <typename Derived>
8827 OMPClause *
8829  ExprResult E = getDerived().TransformExpr(C->getThreadLimit());
8830  if (E.isInvalid())
8831  return nullptr;
8832  return getDerived().RebuildOMPThreadLimitClause(
8833  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8834 }
8835 
8836 template <typename Derived>
8837 OMPClause *
8839  ExprResult E = getDerived().TransformExpr(C->getPriority());
8840  if (E.isInvalid())
8841  return nullptr;
8842  return getDerived().RebuildOMPPriorityClause(
8843  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8844 }
8845 
8846 template <typename Derived>
8847 OMPClause *
8849  ExprResult E = getDerived().TransformExpr(C->getGrainsize());
8850  if (E.isInvalid())
8851  return nullptr;
8852  return getDerived().RebuildOMPGrainsizeClause(
8853  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8854 }
8855 
8856 template <typename Derived>
8857 OMPClause *
8859  ExprResult E = getDerived().TransformExpr(C->getNumTasks());
8860  if (E.isInvalid())
8861  return nullptr;
8862  return getDerived().RebuildOMPNumTasksClause(
8863  E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8864 }
8865 
8866 template <typename Derived>
8868  ExprResult E = getDerived().TransformExpr(C->getHint());
8869  if (E.isInvalid())
8870  return nullptr;
8871  return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
8872  C->getLParenLoc(), C->getEndLoc());
8873 }
8874 
8875 template <typename Derived>
8877  OMPDistScheduleClause *C) {
8878  ExprResult E = getDerived().TransformExpr(C->getChunkSize());
8879  if (E.isInvalid())
8880  return nullptr;
8881  return getDerived().RebuildOMPDistScheduleClause(
8882  C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
8883  C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
8884 }
8885 
8886 template <typename Derived>
8887 OMPClause *
8889  return C;
8890 }
8891 
8892 template <typename Derived>
8895  Vars.reserve(C->varlist_size());
8896  for (auto *VE : C->varlists()) {
8897  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8898  if (EVar.isInvalid())
8899  return 0;
8900  Vars.push_back(EVar.get());
8901  }
8902  return getDerived().RebuildOMPToClause(Vars, C->getBeginLoc(),
8903  C->getLParenLoc(), C->getEndLoc());
8904 }
8905 
8906 template <typename Derived>
8909  Vars.reserve(C->varlist_size());
8910  for (auto *VE : C->varlists()) {
8911  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8912  if (EVar.isInvalid())
8913  return 0;
8914  Vars.push_back(EVar.get());
8915  }
8916  return getDerived().RebuildOMPFromClause(Vars, C->getBeginLoc(),
8917  C->getLParenLoc(), C->getEndLoc());
8918 }
8919 
8920 template <typename Derived>
8922  OMPUseDevicePtrClause *C) {
8924  Vars.reserve(C->varlist_size());
8925  for (auto *VE : C->varlists()) {
8926  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8927  if (EVar.isInvalid())
8928  return nullptr;
8929  Vars.push_back(EVar.get());
8930  }
8931  return getDerived().RebuildOMPUseDevicePtrClause(
8932  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8933 }
8934 
8935 template <typename Derived>
8936 OMPClause *
8939  Vars.reserve(C->varlist_size());
8940  for (auto *VE : C->varlists()) {
8941  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8942  if (EVar.isInvalid())
8943  return nullptr;
8944  Vars.push_back(EVar.get());
8945  }
8946  return getDerived().RebuildOMPIsDevicePtrClause(
8947  Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
8948 }
8949 
8950 //===----------------------------------------------------------------------===//
8951 // Expression transformation
8952 //===----------------------------------------------------------------------===//
8953 template<typename Derived>
8954 ExprResult
8956  return TransformExpr(E->getSubExpr());
8957 }
8958 
8959 template<typename Derived>
8960 ExprResult
8962  if (!E->isTypeDependent())
8963  return E;
8964 
8965  return getDerived().RebuildPredefinedExpr(E->getLocation(),
8966  E->getIdentKind());
8967 }
8968 
8969 template<typename Derived>
8970 ExprResult
8972  NestedNameSpecifierLoc QualifierLoc;
8973  if (E->getQualifierLoc()) {
8974  QualifierLoc
8975  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
8976  if (!QualifierLoc)
8977  return ExprError();
8978  }
8979 
8980  ValueDecl *ND
8981  = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
8982  E->getDecl()));
8983  if (!ND)
8984  return ExprError();
8985 
8986  DeclarationNameInfo NameInfo = E->getNameInfo();
8987  if (NameInfo.getName()) {
8988  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8989  if (!NameInfo.getName())
8990  return ExprError();
8991  }
8992 
8993  if (!getDerived().AlwaysRebuild() &&
8994  QualifierLoc == E->getQualifierLoc() &&
8995  ND == E->getDecl() &&
8996  NameInfo.getName() == E->getDecl()->getDeclName() &&
8997  !E->hasExplicitTemplateArgs()) {
8998 
8999  // Mark it referenced in the new context regardless.
9000  // FIXME: this is a bit instantiation-specific.
9001  SemaRef.MarkDeclRefReferenced(E);
9002 
9003  return E;
9004  }
9005 
9006  TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
9007  if (E->hasExplicitTemplateArgs()) {
9008  TemplateArgs = &TransArgs;
9009  TransArgs.setLAngleLoc(E->getLAngleLoc());
9010  TransArgs.setRAngleLoc(E->getRAngleLoc());
9011  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
9012  E->getNumTemplateArgs(),
9013  TransArgs))
9014  return ExprError();
9015  }
9016 
9017  return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
9018  TemplateArgs);
9019 }
9020 
9021 template<typename Derived>
9022 ExprResult
9024  return E;
9025 }
9026 
9027 template <typename Derived>
9029  FixedPointLiteral *E) {
9030  return E;
9031 }
9032 
9033 template<typename Derived>
9034 ExprResult
9036  return E;
9037 }
9038 
9039 template<typename Derived>
9040 ExprResult
9042  return E;
9043 }
9044 
9045 template<typename Derived>
9046 ExprResult
9048  return E;
9049 }
9050 
9051 template<typename Derived>
9052 ExprResult
9054  return E;
9055 }
9056 
9057 template<typename Derived>
9058 ExprResult
9060  if (FunctionDecl *FD = E->getDirectCallee())
9061  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), FD);
9062  return SemaRef.MaybeBindToTemporary(E);
9063 }
9064 
9065 template<typename Derived>
9066 ExprResult
9068  ExprResult ControllingExpr =
9069  getDerived().TransformExpr(E->getControllingExpr());
9070  if (ControllingExpr.isInvalid())
9071  return ExprError();
9072 
9073  SmallVector<Expr *, 4> AssocExprs;
9075  for (unsigned i = 0; i != E->getNumAssocs(); ++i) {
9077  if (TS) {
9078  TypeSourceInfo *AssocType = getDerived().TransformType(TS);
9079  if (!AssocType)
9080  return ExprError();
9081  AssocTypes.push_back(AssocType);
9082  } else {
9083  AssocTypes.push_back(nullptr);
9084  }
9085 
9086  ExprResult AssocExpr = getDerived().TransformExpr(E->getAssocExpr(i));
9087  if (AssocExpr.isInvalid())
9088  return ExprError();
9089  AssocExprs.push_back(AssocExpr.get());
9090  }
9091 
9092  return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
9093  E->getDefaultLoc(),
9094  E->getRParenLoc(),
9095  ControllingExpr.get(),
9096  AssocTypes,
9097  AssocExprs);
9098 }
9099 
9100 template<typename Derived>
9101 ExprResult
9103  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
9104  if (SubExpr.isInvalid())
9105  return ExprError();
9106 
9107  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
9108  return E;
9109 
9110  return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
9111  E->getRParen());
9112 }
9113 
9114 /// The operand of a unary address-of operator has special rules: it's
9115 /// allowed to refer to a non-static member of a class even if there's no 'this'
9116 /// object available.
9117 template<typename Derived>
9118 ExprResult
9120  if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
9121  return getDerived().TransformDependentScopeDeclRefExpr(DRE, true, nullptr);
9122  else
9123  return getDerived().TransformExpr(E);
9124 }
9125 
9126 template<typename Derived>
9127 ExprResult
9129  ExprResult SubExpr;
9130  if (E->getOpcode() == UO_AddrOf)
9131  SubExpr = TransformAddressOfOperand(E->getSubExpr());
9132  else
9133  SubExpr = TransformExpr(E->getSubExpr());
9134  if (SubExpr.isInvalid())
9135  return ExprError();
9136 
9137  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
9138  return E;
9139 
9140  return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
9141  E->getOpcode(),
9142  SubExpr.get());
9143 }
9144 
9145 template<typename Derived>
9146 ExprResult
9148  // Transform the type.
9149  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
9150  if (!Type)
9151  return ExprError();
9152 
9153  // Transform all of the components into components similar to what the
9154  // parser uses.
9155  // FIXME: It would be slightly more efficient in the non-dependent case to
9156  // just map FieldDecls, rather than requiring the rebuilder to look for
9157  // the fields again. However, __builtin_offsetof is rare enough in
9158  // template code that we don't care.
9159  bool ExprChanged = false;
9160  typedef Sema::OffsetOfComponent Component;
9161  SmallVector<Component, 4> Components;
9162  for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
9163  const OffsetOfNode &ON = E->getComponent(I);
9164  Component Comp;
9165  Comp.isBrackets = true;
9166  Comp.LocStart = ON.getSourceRange().getBegin();
9167  Comp.LocEnd = ON.getSourceRange().getEnd();
9168  switch (ON.getKind()) {
9169  case OffsetOfNode::Array: {
9170  Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
9171  ExprResult Index = getDerived().TransformExpr(FromIndex);
9172  if (Index.isInvalid())
9173  return ExprError();
9174 
9175  ExprChanged = ExprChanged || Index.get() != FromIndex;
9176  Comp.isBrackets = true;
9177  Comp.U.E = Index.get();
9178  break;
9179  }
9180 
9181  case OffsetOfNode::Field:
9183  Comp.isBrackets = false;
9184  Comp.U.IdentInfo = ON.getFieldName();
9185  if (!Comp.U.IdentInfo)
9186  continue;
9187 
9188  break;
9189 
9190  case OffsetOfNode::Base:
9191  // Will be recomputed during the rebuild.
9192  continue;
9193  }
9194 
9195  Components.push_back(Comp);
9196  }
9197 
9198  // If nothing changed, retain the existing expression.
9199  if (!getDerived().AlwaysRebuild() &&
9200  Type == E->getTypeSourceInfo() &&
9201  !ExprChanged)
9202  return E;
9203 
9204  // Build a new offsetof expression.
9205  return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
9206  Components, E->getRParenLoc());
9207 }
9208 
9209 template<typename Derived>
9210 ExprResult
9212  assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
9213  "opaque value expression requires transformation");
9214  return E;
9215 }
9216 
9217 template<typename Derived>
9218 ExprResult
9220  return E;
9221 }
9222 
9223 template<typename Derived>
9224 ExprResult
9226  // Rebuild the syntactic form. The original syntactic form has
9227  // opaque-value expressions in it, so strip those away and rebuild
9228  // the result. This is a really awful way of doing this, but the
9229  // better solution (rebuilding the semantic expressions and
9230  // rebinding OVEs as necessary) doesn't work; we'd need
9231  // TreeTransform to not strip away implicit conversions.
9232  Expr *newSyntacticForm = SemaRef.recreateSyntacticForm(E);
9233  ExprResult result = getDerived().TransformExpr(newSyntacticForm);
9234  if (result.isInvalid()) return ExprError();
9235 
9236  // If that gives us a pseudo-object result back, the pseudo-object
9237  // expression must have been an lvalue-to-rvalue conversion which we
9238  // should reapply.
9239  if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
9240  result = SemaRef.checkPseudoObjectRValue(result.get());
9241 
9242  return result;
9243 }
9244 
9245 template<typename Derived>
9246 ExprResult
9249  if (E->isArgumentType()) {
9250  TypeSourceInfo *OldT = E->getArgumentTypeInfo();
9251 
9252  TypeSourceInfo *NewT = getDerived().TransformType(OldT);
9253  if (!NewT)
9254  return ExprError();
9255 
9256  if (!getDerived().AlwaysRebuild() && OldT == NewT)
9257  return E;
9258 
9259  return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
9260  E->getKind(),
9261  E->getSourceRange());
9262  }
9263 
9264  // C++0x [expr.sizeof]p1:
9265  // The operand is either an expression, which is an unevaluated operand
9266  // [...]
9270 
9271  // Try to recover if we have something like sizeof(T::X) where X is a type.
9272  // Notably, there must be *exactly* one set of parens if X is a type.
9273  TypeSourceInfo *RecoveryTSI = nullptr;
9274  ExprResult SubExpr;
9275  auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
9276  if (auto *DRE =
9277  PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
9278  SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
9279  PE, DRE, false, &RecoveryTSI);
9280  else
9281  SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
9282 
9283  if (RecoveryTSI) {
9284  return getDerived().RebuildUnaryExprOrTypeTrait(
9285  RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
9286  } else if (SubExpr.isInvalid())
9287  return ExprError();
9288 
9289  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
9290  return E;
9291 
9292  return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
9293  E->getOperatorLoc(),
9294  E->getKind(),
9295  E->getSourceRange());
9296 }
9297 
9298 template<typename Derived>
9299 ExprResult
9301  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9302  if (LHS.isInvalid())
9303  return ExprError();
9304 
9305  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9306  if (RHS.isInvalid())
9307  return ExprError();
9308 
9309 
9310  if (!getDerived().AlwaysRebuild() &&
9311  LHS.get() == E->getLHS() &&
9312  RHS.get() == E->getRHS())
9313  return E;
9314 
9315  return getDerived().RebuildArraySubscriptExpr(
9316  LHS.get(),
9317  /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
9318 }
9319 
9320 template <typename Derived>
9321 ExprResult
9323  ExprResult Base = getDerived().TransformExpr(E->getBase());
9324  if (Base.isInvalid())
9325  return ExprError();
9326 
9327  ExprResult LowerBound;
9328  if (E->getLowerBound()) {
9329  LowerBound = getDerived().TransformExpr(E->getLowerBound());
9330  if (LowerBound.isInvalid())
9331  return ExprError();
9332  }
9333 
9334  ExprResult Length;
9335  if (E->getLength()) {
9336  Length = getDerived().TransformExpr(E->getLength());
9337  if (Length.isInvalid())
9338  return ExprError();
9339  }
9340 
9341  if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
9342  LowerBound.get() == E->getLowerBound() && Length.get() == E->getLength())
9343  return E;
9344 
9345  return getDerived().RebuildOMPArraySectionExpr(
9346  Base.get(), E->getBase()->getEndLoc(), LowerBound.get(), E->getColonLoc(),
9347  Length.get(), E->getRBracketLoc());
9348 }
9349 
9350 template<typename Derived>
9351 ExprResult
9353  // Transform the callee.
9354  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
9355  if (Callee.isInvalid())
9356  return ExprError();
9357 
9358  // Transform arguments.
9359  bool ArgChanged = false;
9360  SmallVector<Expr*, 8> Args;
9361  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
9362  &ArgChanged))
9363  return ExprError();
9364 
9365  if (!getDerived().AlwaysRebuild() &&
9366  Callee.get() == E->getCallee() &&
9367  !ArgChanged)
9368  return SemaRef.MaybeBindToTemporary(E);
9369 
9370  // FIXME: Wrong source location information for the '('.
9371  SourceLocation FakeLParenLoc
9372  = ((Expr *)Callee.get())->getSourceRange().getBegin();
9373  return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
9374  Args,
9375  E->getRParenLoc());
9376 }
9377 
9378 template<typename Derived>
9379 ExprResult
9381  ExprResult Base = getDerived().TransformExpr(E->getBase());
9382  if (Base.isInvalid())
9383  return ExprError();
9384 
9385  NestedNameSpecifierLoc QualifierLoc;
9386  if (E->hasQualifier()) {
9387  QualifierLoc
9388  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9389 
9390  if (!QualifierLoc)
9391  return ExprError();
9392  }
9393  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
9394 
9395  ValueDecl *Member
9396  = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
9397  E->getMemberDecl()));
9398  if (!Member)
9399  return ExprError();
9400 
9401  NamedDecl *FoundDecl = E->getFoundDecl();
9402  if (FoundDecl == E->getMemberDecl()) {
9403  FoundDecl = Member;
9404  } else {
9405  FoundDecl = cast_or_null<NamedDecl>(
9406  getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
9407  if (!FoundDecl)
9408  return ExprError();
9409  }
9410 
9411  if (!getDerived().AlwaysRebuild() &&
9412  Base.get() == E->getBase() &&
9413  QualifierLoc == E->getQualifierLoc() &&
9414  Member == E->getMemberDecl() &&
9415  FoundDecl == E->getFoundDecl() &&
9416  !E->hasExplicitTemplateArgs()) {
9417 
9418  // Mark it referenced in the new context regardless.
9419  // FIXME: this is a bit instantiation-specific.
9420  SemaRef.MarkMemberReferenced(E);
9421 
9422  return E;
9423  }
9424 
9425  TemplateArgumentListInfo TransArgs;
9426  if (E->hasExplicitTemplateArgs()) {
9427  TransArgs.setLAngleLoc(E->getLAngleLoc());
9428  TransArgs.setRAngleLoc(E->getRAngleLoc());
9429  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
9430  E->getNumTemplateArgs(),
9431  TransArgs))
9432  return ExprError();
9433  }
9434 
9435  // FIXME: Bogus source location for the operator
9436  SourceLocation FakeOperatorLoc =
9437  SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
9438 
9439  // FIXME: to do this check properly, we will need to preserve the
9440  // first-qualifier-in-scope here, just in case we had a dependent
9441  // base (and therefore couldn't do the check) and a
9442  // nested-name-qualifier (and therefore could do the lookup).
9443  NamedDecl *FirstQualifierInScope = nullptr;
9444  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
9445  if (MemberNameInfo.getName()) {
9446  MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
9447  if (!MemberNameInfo.getName())
9448  return ExprError();
9449  }
9450 
9451  return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
9452  E->isArrow(),
9453  QualifierLoc,
9454  TemplateKWLoc,
9455  MemberNameInfo,
9456  Member,
9457  FoundDecl,
9459  ? &TransArgs : nullptr),
9460  FirstQualifierInScope);
9461 }
9462 
9463 template<typename Derived>
9464 ExprResult
9466  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9467  if (LHS.isInvalid())
9468  return ExprError();
9469 
9470  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9471  if (RHS.isInvalid())
9472  return ExprError();
9473 
9474  if (!getDerived().AlwaysRebuild() &&
9475  LHS.get() == E->getLHS() &&
9476  RHS.get() == E->getRHS())
9477  return E;
9478 
9479  Sema::FPContractStateRAII FPContractState(getSema());
9480  getSema().FPFeatures = E->getFPFeatures();
9481 
9482  return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
9483  LHS.get(), RHS.get());
9484 }
9485 
9486 template<typename Derived>
9487 ExprResult
9490  return getDerived().TransformBinaryOperator(E);
9491 }
9492 
9493 template<typename Derived>
9496  // Just rebuild the common and RHS expressions and see whether we
9497  // get any changes.
9498 
9499  ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
9500  if (commonExpr.isInvalid())
9501  return ExprError();
9502 
9503  ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
9504  if (rhs.isInvalid())
9505  return ExprError();
9506 
9507  if (!getDerived().AlwaysRebuild() &&
9508  commonExpr.get() == e->getCommon() &&
9509  rhs.get() == e->getFalseExpr())
9510  return e;
9511 
9512  return getDerived().RebuildConditionalOperator(commonExpr.get(),
9513  e->getQuestionLoc(),
9514  nullptr,
9515  e->getColonLoc(),
9516  rhs.get());
9517 }
9518 
9519 template<typename Derived>
9520 ExprResult
9522  ExprResult Cond = getDerived().TransformExpr(E->getCond());
9523  if (Cond.isInvalid())
9524  return ExprError();
9525 
9526  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9527  if (LHS.isInvalid())
9528  return ExprError();
9529 
9530  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9531  if (RHS.isInvalid())
9532  return ExprError();
9533 
9534  if (!getDerived().AlwaysRebuild() &&
9535  Cond.get() == E->getCond() &&
9536  LHS.get() == E->getLHS() &&
9537  RHS.get() == E->getRHS())
9538  return E;
9539 
9540  return getDerived().RebuildConditionalOperator(Cond.get(),
9541  E->getQuestionLoc(),
9542  LHS.get(),
9543  E->getColonLoc(),
9544  RHS.get());
9545 }
9546 
9547 template<typename Derived>
9548 ExprResult
9550  // Implicit casts are eliminated during transformation, since they
9551  // will be recomputed by semantic analysis after transformation.
9552  return getDerived().TransformExpr(E->getSubExprAsWritten());
9553 }
9554 
9555 template<typename Derived>
9556 ExprResult
9558  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
9559  if (!Type)
9560  return ExprError();
9561 
9562  ExprResult SubExpr
9563  = getDerived().TransformExpr(E->getSubExprAsWritten());
9564  if (SubExpr.isInvalid())
9565  return ExprError();
9566 
9567  if (!getDerived().AlwaysRebuild() &&
9568  Type == E->getTypeInfoAsWritten() &&
9569  SubExpr.get() == E->getSubExpr())
9570  return E;
9571 
9572  return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
9573  Type,
9574  E->getRParenLoc(),
9575  SubExpr.get());
9576 }
9577 
9578 template<typename Derived>
9579 ExprResult
9581  TypeSourceInfo *OldT = E->getTypeSourceInfo();
9582  TypeSourceInfo *NewT = getDerived().TransformType(OldT);
9583  if (!NewT)
9584  return ExprError();
9585 
9586  ExprResult Init = getDerived().TransformExpr(E->getInitializer());
9587  if (Init.isInvalid())
9588  return ExprError();
9589 
9590  if (!getDerived().AlwaysRebuild() &&
9591  OldT == NewT &&
9592  Init.get() == E->getInitializer())
9593  return SemaRef.MaybeBindToTemporary(E);
9594 
9595  // Note: the expression type doesn't necessarily match the
9596  // type-as-written, but that's okay, because it should always be
9597  // derivable from the initializer.
9598 
9599  return getDerived().RebuildCompoundLiteralExpr(
9600  E->getLParenLoc(), NewT,
9601  /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
9602 }
9603 
9604 template<typename Derived>
9605 ExprResult
9607  ExprResult Base = getDerived().TransformExpr(E->getBase());
9608  if (Base.isInvalid())
9609  return ExprError();
9610 
9611  if (!getDerived().AlwaysRebuild() &&
9612  Base.get() == E->getBase())
9613  return E;
9614 
9615  // FIXME: Bad source location
9616  SourceLocation FakeOperatorLoc =
9617  SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
9618  return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc,
9619  E->getAccessorLoc(),
9620  E->getAccessor());
9621 }
9622 
9623 template<typename Derived>
9624 ExprResult
9626  if (InitListExpr *Syntactic = E->getSyntacticForm())
9627  E = Syntactic;
9628 
9629  bool InitChanged = false;
9630 
9633 
9635  if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
9636  Inits, &InitChanged))
9637  return ExprError();
9638 
9639  if (!getDerived().AlwaysRebuild() && !InitChanged) {
9640  // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
9641  // in some cases. We can't reuse it in general, because the syntactic and
9642  // semantic forms are linked, and we can't know that semantic form will
9643  // match even if the syntactic form does.
9644  }
9645 
9646  return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
9647  E->getRBraceLoc());
9648 }
9649 
9650 template<typename Derived>
9651 ExprResult
9653  Designation Desig;
9654 
9655  // transform the initializer value
9656  ExprResult Init = getDerived().TransformExpr(E->getInit());
9657  if (Init.isInvalid())
9658  return ExprError();
9659 
9660  // transform the designators.
9661  SmallVector<Expr*, 4> ArrayExprs;
9662  bool ExprChanged = false;
9663  for (const DesignatedInitExpr::Designator &D : E->designators()) {
9664  if (D.isFieldDesignator()) {
9665  Desig.AddDesignator(Designator::getField(D.getFieldName(),
9666  D.getDotLoc(),
9667  D.getFieldLoc()));
9668  if (D.getField()) {
9669  FieldDecl *Field = cast_or_null<FieldDecl>(
9670  getDerived().TransformDecl(D.getFieldLoc(), D.getField()));
9671  if (Field != D.getField())
9672  // Rebuild the expression when the transformed FieldDecl is
9673  // different to the already assigned FieldDecl.
9674  ExprChanged = true;
9675  } else {
9676  // Ensure that the designator expression is rebuilt when there isn't
9677  // a resolved FieldDecl in the designator as we don't want to assign
9678  // a FieldDecl to a pattern designator that will be instantiated again.
9679  ExprChanged = true;
9680  }
9681  continue;
9682  }
9683 
9684  if (D.isArrayDesignator()) {
9685  ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
9686  if (Index.isInvalid())
9687  return ExprError();
9688 
9689  Desig.AddDesignator(
9690  Designator::getArray(Index.get(), D.getLBracketLoc()));
9691 
9692  ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D);
9693  ArrayExprs.push_back(Index.get());
9694  continue;
9695  }
9696 
9697  assert(D.isArrayRangeDesignator() && "New kind of designator?");
9698  ExprResult Start
9699  = getDerived().TransformExpr(E->getArrayRangeStart(D));
9700  if (Start.isInvalid())
9701  return ExprError();
9702 
9703  ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
9704  if (End.isInvalid())
9705  return ExprError();
9706 
9707  Desig.AddDesignator(Designator::getArrayRange(Start.get(),
9708  End.get(),
9709  D.getLBracketLoc(),
9710  D.getEllipsisLoc()));
9711 
9712  ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
9713  End.get() != E->getArrayRangeEnd(D);
9714 
9715  ArrayExprs.push_back(Start.get());
9716  ArrayExprs.push_back(End.get());
9717  }
9718 
9719  if (!getDerived().AlwaysRebuild() &&
9720  Init.get() == E->getInit() &&
9721  !ExprChanged)
9722  return E;
9723 
9724  return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
9725  E->getEqualOrColonLoc(),
9726  E->usesGNUSyntax(), Init.get());
9727 }
9728 
9729 // Seems that if TransformInitListExpr() only works on the syntactic form of an
9730 // InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
9731 template<typename Derived>
9732 ExprResult
9735  llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
9736  "initializer");
9737  return ExprError();
9738 }
9739 
9740 template<typename Derived>
9741 ExprResult
9743  NoInitExpr *E) {
9744  llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
9745  return ExprError();
9746 }
9747 
9748 template<typename Derived>
9749 ExprResult
9751  llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
9752  return ExprError();
9753 }
9754 
9755 template<typename Derived>
9756 ExprResult
9758  llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
9759  return ExprError();
9760 }
9761 
9762 template<typename Derived>
9763 ExprResult
9765  ImplicitValueInitExpr *E) {
9766  TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
9767 
9768  // FIXME: Will we ever have proper type location here? Will we actually
9769  // need to transform the type?
9770  QualType T = getDerived().TransformType(E->getType());
9771  if (T.isNull())
9772  return ExprError();
9773 
9774  if (!getDerived().AlwaysRebuild() &&
9775  T == E->getType())
9776  return E;
9777 
9778  return getDerived().RebuildImplicitValueInitExpr(T);
9779 }
9780 
9781 template<typename Derived>
9782 ExprResult
9784  TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
9785  if (!TInfo)
9786  return ExprError();
9787 
9788  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
9789  if (SubExpr.isInvalid())
9790  return ExprError();
9791 
9792  if (!getDerived().AlwaysRebuild() &&
9793  TInfo == E->getWrittenTypeInfo() &&
9794  SubExpr.get() == E->getSubExpr())
9795  return E;
9796 
9797  return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
9798  TInfo, E->getRParenLoc());
9799 }
9800 
9801 template<typename Derived>
9802 ExprResult
9804  bool ArgumentChanged = false;
9806  if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
9807  &ArgumentChanged))
9808  return ExprError();
9809 
9810  return getDerived().RebuildParenListExpr(E->getLParenLoc(),
9811  Inits,
9812  E->getRParenLoc());
9813 }
9814 
9815 /// Transform an address-of-label expression.
9816 ///
9817 /// By default, the transformation of an address-of-label expression always
9818 /// rebuilds the expression, so that the label identifier can be resolved to
9819 /// the corresponding label statement by semantic analysis.
9820 template<typename Derived>
9821 ExprResult
9823  Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
9824  E->getLabel());
9825  if (!LD)
9826  return ExprError();
9827 
9828  return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
9829  cast<LabelDecl>(LD));
9830 }
9831 
9832 template<typename Derived>
9833 ExprResult
9835  SemaRef.ActOnStartStmtExpr();
9836  StmtResult SubStmt
9837  = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
9838  if (SubStmt.isInvalid()) {
9839  SemaRef.ActOnStmtExprError();
9840  return ExprError();
9841  }
9842 
9843  if (!getDerived().AlwaysRebuild() &&
9844  SubStmt.get() == E->getSubStmt()) {
9845  // Calling this an 'error' is unintuitive, but it does the right thing.
9846  SemaRef.ActOnStmtExprError();
9847  return SemaRef.MaybeBindToTemporary(E);
9848  }
9849 
9850  return getDerived().RebuildStmtExpr(E->getLParenLoc(),
9851  SubStmt.get(),
9852  E->getRParenLoc());
9853 }
9854 
9855 template<typename Derived>
9856 ExprResult
9858  ExprResult Cond = getDerived().TransformExpr(E->getCond());
9859  if (Cond.isInvalid())
9860  return ExprError();
9861 
9862  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9863  if (LHS.isInvalid())
9864  return ExprError();
9865 
9866  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9867  if (RHS.isInvalid())
9868  return ExprError();
9869 
9870  if (!getDerived().AlwaysRebuild() &&
9871  Cond.get() == E->getCond() &&
9872  LHS.get() == E->getLHS() &&
9873  RHS.get() == E->getRHS())
9874  return E;
9875 
9876  return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
9877  Cond.get(), LHS.get(), RHS.get(),
9878  E->getRParenLoc());
9879 }
9880 
9881 template<typename Derived>
9882 ExprResult
9884  return E;
9885 }
9886 
9887 template<typename Derived>
9888 ExprResult
9890  switch (E->getOperator()) {
9891  case OO_New:
9892  case OO_Delete:
9893  case OO_Array_New:
9894  case OO_Array_Delete:
9895  llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
9896 
9897  case OO_Call: {
9898  // This is a call to an object's operator().
9899  assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
9900 
9901  // Transform the object itself.
9902  ExprResult Object = getDerived().TransformExpr(E->getArg(0));
9903  if (Object.isInvalid())
9904  return ExprError();
9905 
9906  // FIXME: Poor location information
9907  SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(
9908  static_cast<Expr *>(Object.get())->getEndLoc());
9909 
9910  // Transform the call arguments.
9911  SmallVector<Expr*, 8> Args;
9912  if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
9913  Args))
9914  return ExprError();
9915 
9916  return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
9917  E->getEndLoc());
9918  }
9919 
9920 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
9921  case OO_##Name:
9922 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
9923 #include "clang/Basic/OperatorKinds.def"
9924  case OO_Subscript:
9925  // Handled below.
9926  break;
9927 
9928  case OO_Conditional:
9929  llvm_unreachable("conditional operator is not actually overloadable");
9930 
9931  case OO_None:
9933  llvm_unreachable("not an overloaded operator?");
9934  }
9935 
9936  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
9937  if (Callee.isInvalid())
9938  return ExprError();
9939 
9940  ExprResult First;
9941  if (E->getOperator() == OO_Amp)
9942  First = getDerived().TransformAddressOfOperand(E->getArg(0));
9943  else
9944  First = getDerived().TransformExpr(E->getArg(0));
9945  if (First.isInvalid())
9946  return ExprError();
9947 
9948  ExprResult Second;
9949  if (E->getNumArgs() == 2) {
9950  Second = getDerived().TransformExpr(E->getArg(1));
9951  if (Second.isInvalid())
9952  return ExprError();
9953  }
9954 
9955  if (!getDerived().AlwaysRebuild() &&
9956  Callee.get() == E->getCallee() &&
9957  First.get() == E->getArg(0) &&
9958  (E->getNumArgs() != 2 || Second.get() == E->getArg(1)))
9959  return SemaRef.MaybeBindToTemporary(E);
9960 
9961  Sema::FPContractStateRAII FPContractState(getSema());
9962  getSema().FPFeatures = E->getFPFeatures();
9963 
9964  return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(),
9965  E->getOperatorLoc(),
9966  Callee.get(),
9967  First.get(),
9968  Second.get());
9969 }
9970 
9971 template<typename Derived>
9972 ExprResult
9974  return getDerived().TransformCallExpr(E);
9975 }
9976 
9977 template<typename Derived>
9978 ExprResult
9980  // Transform the callee.
9981  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
9982  if (Callee.isInvalid())
9983  return ExprError();
9984 
9985  // Transform exec config.
9986  ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
9987  if (EC.isInvalid())
9988  return ExprError();
9989 
9990  // Transform arguments.
9991  bool ArgChanged = false;
9992  SmallVector<Expr*, 8> Args;
9993  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
9994  &ArgChanged))
9995  return ExprError();
9996 
9997  if (!getDerived().AlwaysRebuild() &&
9998  Callee.get() == E->getCallee() &&
9999  !ArgChanged)
10000  return SemaRef.MaybeBindToTemporary(E);
10001 
10002  // FIXME: Wrong source location information for the '('.
10003  SourceLocation FakeLParenLoc
10004  = ((Expr *)Callee.get())->getSourceRange().getBegin();
10005  return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
10006  Args,
10007  E->getRParenLoc(), EC.get());
10008 }
10009 
10010 template<typename Derived>
10011 ExprResult
10013  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
10014  if (!Type)
10015  return ExprError();
10016 
10017  ExprResult SubExpr
10018  = getDerived().TransformExpr(E->getSubExprAsWritten());
10019  if (SubExpr.isInvalid())
10020  return ExprError();
10021 
10022  if (!getDerived().AlwaysRebuild() &&
10023  Type == E->getTypeInfoAsWritten() &&
10024  SubExpr.get() == E->getSubExpr())
10025  return E;
10026  return getDerived().RebuildCXXNamedCastExpr(
10028  Type, E->getAngleBrackets().getEnd(),
10029  // FIXME. this should be '(' location
10030  E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
10031 }
10032 
10033 template<typename Derived>
10034 ExprResult
10036  return getDerived().TransformCXXNamedCastExpr(E);
10037 }
10038 
10039 template<typename Derived>
10040 ExprResult
10042  return getDerived().TransformCXXNamedCastExpr(E);
10043 }
10044 
10045 template<typename Derived>
10046 ExprResult
10049  return getDerived().TransformCXXNamedCastExpr(E);
10050 }
10051 
10052 template<typename Derived>
10053 ExprResult
10055  return getDerived().TransformCXXNamedCastExpr(E);
10056 }
10057 
10058 template<typename Derived>
10059 ExprResult
10061  CXXFunctionalCastExpr *E) {
10062  TypeSourceInfo *Type =
10063  getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
10064  if (!Type)
10065  return ExprError();
10066 
10067  ExprResult SubExpr
10068  = getDerived().TransformExpr(E->getSubExprAsWritten());
10069  if (SubExpr.isInvalid())
10070  return ExprError();
10071 
10072  if (!getDerived().AlwaysRebuild() &&
10073  Type == E->getTypeInfoAsWritten() &&
10074  SubExpr.get() == E->getSubExpr())
10075  return E;
10076 
10077  return getDerived().RebuildCXXFunctionalCastExpr(Type,
10078  E->getLParenLoc(),
10079  SubExpr.get(),
10080  E->getRParenLoc(),
10081  E->isListInitialization());
10082 }
10083 
10084 template<typename Derived>
10085 ExprResult
10087  if (E->isTypeOperand()) {
10088  TypeSourceInfo *TInfo
10089  = getDerived().TransformType(E->getTypeOperandSourceInfo());
10090  if (!TInfo)
10091  return ExprError();
10092 
10093  if (!getDerived().AlwaysRebuild() &&
10094  TInfo == E->getTypeOperandSourceInfo())
10095  return E;
10096 
10097  return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
10098  TInfo, E->getEndLoc());
10099  }
10100 
10101  // We don't know whether the subexpression is potentially evaluated until
10102  // after we perform semantic analysis. We speculatively assume it is
10103  // unevaluated; it will get fixed later if the subexpression is in fact
10104  // potentially evaluated.
10108 
10109  ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
10110  if (SubExpr.isInvalid())
10111  return ExprError();
10112 
10113  if (!getDerived().AlwaysRebuild() &&
10114  SubExpr.get() == E->getExprOperand())
10115  return E;
10116 
10117  return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
10118  SubExpr.get(), E->getEndLoc());
10119 }
10120 
10121 template<typename Derived>
10122 ExprResult
10124  if (E->isTypeOperand()) {
10125  TypeSourceInfo *TInfo
10126  = getDerived().TransformType(E->getTypeOperandSourceInfo());
10127  if (!TInfo)
10128  return ExprError();
10129 
10130  if (!getDerived().AlwaysRebuild() &&
10131  TInfo == E->getTypeOperandSourceInfo())
10132  return E;
10133 
10134  return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
10135  TInfo, E->getEndLoc());
10136  }
10137 
10140 
10141  ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
10142  if (SubExpr.isInvalid())
10143  return ExprError();
10144 
10145  if (!getDerived().AlwaysRebuild() &&
10146  SubExpr.get() == E->getExprOperand())
10147  return E;
10148 
10149  return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
10150  SubExpr.get(), E->getEndLoc());
10151 }
10152 
10153 template<typename Derived>
10154 ExprResult
10156  return E;
10157 }
10158 
10159 template<typename Derived>
10160 ExprResult
10162  CXXNullPtrLiteralExpr *E) {
10163  return E;
10164 }
10165 
10166 template<typename Derived>
10167 ExprResult
10169  QualType T = getSema().getCurrentThisType();
10170 
10171  if (!getDerived().AlwaysRebuild() && T == E->getType()) {
10172  // Make sure that we capture 'this'.
10173  getSema().CheckCXXThisCapture(E->getBeginLoc());
10174  return E;
10175  }
10176 
10177  return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
10178 }
10179 
10180 template<typename Derived>
10181 ExprResult
10183  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
10184  if (SubExpr.isInvalid())
10185  return ExprError();
10186 
10187  if (!getDerived().AlwaysRebuild() &&
10188  SubExpr.get() == E->getSubExpr())
10189  return E;
10190 
10191  return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
10193 }
10194 
10195 template<typename Derived>
10196 ExprResult
10198  ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
10199  getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
10200  if (!Param)
10201  return ExprError();
10202 
10203  if (!getDerived().AlwaysRebuild() &&
10204  Param == E->getParam())
10205  return E;
10206 
10207  return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param);
10208 }
10209 
10210 template<typename Derived>
10211 ExprResult
10213  FieldDecl *Field = cast_or_null<FieldDecl>(
10214  getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
10215  if (!Field)
10216  return ExprError();
10217 
10218  if (!getDerived().AlwaysRebuild() && Field == E->getField())
10219  return E;
10220 
10221  return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
10222 }
10223 
10224 template<typename Derived>
10225 ExprResult
10228  TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
10229  if (!T)
10230  return ExprError();
10231 
10232  if (!getDerived().AlwaysRebuild() &&
10233  T == E->getTypeSourceInfo())
10234  return E;
10235 
10236  return getDerived().RebuildCXXScalarValueInitExpr(T,
10237  /*FIXME:*/T->getTypeLoc().getEndLoc(),
10238  E->getRParenLoc());
10239 }
10240 
10241 template<typename Derived>
10242 ExprResult
10244  // Transform the type that we're allocating
10245  TypeSourceInfo *AllocTypeInfo =
10246  getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
10247  if (!AllocTypeInfo)
10248  return ExprError();
10249 
10250  // Transform the size of the array we're allocating (if any).
10251  ExprResult ArraySize = getDerived().TransformExpr(E->getArraySize());
10252  if (ArraySize.isInvalid())
10253  return ExprError();
10254 
10255  // Transform the placement arguments (if any).
10256  bool ArgumentChanged = false;
10257  SmallVector<Expr*, 8> PlacementArgs;
10258  if (getDerived().TransformExprs(E->getPlacementArgs(),
10259  E->getNumPlacementArgs(), true,
10260  PlacementArgs, &ArgumentChanged))
10261  return ExprError();
10262 
10263  // Transform the initializer (if any).
10264  Expr *OldInit = E->getInitializer();
10265  ExprResult NewInit;
10266  if (OldInit)
10267  NewInit = getDerived().TransformInitializer(OldInit, true);
10268  if (NewInit.isInvalid())
10269  return ExprError();
10270 
10271  // Transform new operator and delete operator.
10272  FunctionDecl *OperatorNew = nullptr;
10273  if (E->getOperatorNew()) {
10274  OperatorNew = cast_or_null<FunctionDecl>(
10275  getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
10276  if (!OperatorNew)
10277  return ExprError();
10278  }
10279 
10280  FunctionDecl *OperatorDelete = nullptr;
10281  if (E->getOperatorDelete()) {
10282  OperatorDelete = cast_or_null<FunctionDecl>(
10283  getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
10284  if (!OperatorDelete)
10285  return ExprError();
10286  }
10287 
10288  if (!getDerived().AlwaysRebuild() &&
10289  AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
10290  ArraySize.get() == E->getArraySize() &&
10291  NewInit.get() == OldInit &&
10292  OperatorNew == E->getOperatorNew() &&
10293  OperatorDelete == E->getOperatorDelete() &&
10294  !ArgumentChanged) {
10295  // Mark any declarations we need as referenced.
10296  // FIXME: instantiation-specific.
10297  if (OperatorNew)
10298  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
10299  if (OperatorDelete)
10300  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
10301 
10302  if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
10303  QualType ElementType
10304  = SemaRef.Context.getBaseElementType(E->getAllocatedType());
10305  if (const RecordType *RecordT = ElementType->getAs<RecordType>()) {
10306  CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordT->getDecl());
10307  if (CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(Record)) {
10308  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
10309  }
10310  }
10311  }
10312 
10313  return E;
10314  }
10315 
10316  QualType AllocType = AllocTypeInfo->getType();
10317  if (!ArraySize.get()) {
10318  // If no array size was specified, but the new expression was
10319  // instantiated with an array type (e.g., "new T" where T is
10320  // instantiated with "int[4]"), extract the outer bound from the
10321  // array type as our array size. We do this with constant and
10322  // dependently-sized array types.
10323  const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
10324  if (!ArrayT) {
10325  // Do nothing
10326  } else if (const ConstantArrayType *ConsArrayT
10327  = dyn_cast<ConstantArrayType>(ArrayT)) {
10328  ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
10329  SemaRef.Context.getSizeType(),
10330  /*FIXME:*/ E->getBeginLoc());
10331  AllocType = ConsArrayT->getElementType();
10332  } else if (const DependentSizedArrayType *DepArrayT
10333  = dyn_cast<DependentSizedArrayType>(ArrayT)) {
10334  if (DepArrayT->getSizeExpr()) {
10335  ArraySize = DepArrayT->getSizeExpr();
10336  AllocType = DepArrayT->getElementType();
10337  }
10338  }
10339  }
10340 
10341  return getDerived().RebuildCXXNewExpr(
10342  E->getBeginLoc(), E->isGlobalNew(),
10343  /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
10344  /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
10345  AllocTypeInfo, ArraySize.get(), E->getDirectInitRange(), NewInit.get());
10346 }
10347 
10348 template<typename Derived>
10349 ExprResult
10351  ExprResult Operand = getDerived().TransformExpr(E->getArgument());
10352  if (Operand.isInvalid())
10353  return ExprError();
10354 
10355  // Transform the delete operator, if known.
10356  FunctionDecl *OperatorDelete = nullptr;
10357  if (E->getOperatorDelete()) {
10358  OperatorDelete = cast_or_null<FunctionDecl>(
10359  getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
10360  if (!OperatorDelete)
10361  return ExprError();
10362  }
10363 
10364  if (!getDerived().AlwaysRebuild() &&
10365  Operand.get() == E->getArgument() &&
10366  OperatorDelete == E->getOperatorDelete()) {
10367  // Mark any declarations we need as referenced.
10368  // FIXME: instantiation-specific.
10369  if (OperatorDelete)
10370  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
10371 
10372  if (!E->getArgument()->isTypeDependent()) {
10373  QualType Destroyed = SemaRef.Context.getBaseElementType(
10374  E->getDestroyedType());
10375  if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
10376  CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
10377  SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
10378  SemaRef.LookupDestructor(Record));
10379  }
10380  }
10381 
10382  return E;
10383  }
10384 
10385  return getDerived().RebuildCXXDeleteExpr(
10386  E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
10387 }
10388 
10389 template<typename Derived>
10390 ExprResult
10393  ExprResult Base = getDerived().TransformExpr(E->getBase());
10394  if (Base.isInvalid())
10395  return ExprError();
10396 
10397  ParsedType ObjectTypePtr;
10398  bool MayBePseudoDestructor = false;
10399  Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
10400  E->getOperatorLoc(),
10401  E->isArrow()? tok::arrow : tok::period,
10402  ObjectTypePtr,
10403  MayBePseudoDestructor);
10404  if (Base.isInvalid())
10405  return ExprError();
10406 
10407  QualType ObjectType = ObjectTypePtr.get();
10408  NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
10409  if (QualifierLoc) {
10410  QualifierLoc
10411  = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
10412  if (!QualifierLoc)
10413  return ExprError();
10414  }
10415  CXXScopeSpec SS;
10416  SS.Adopt(QualifierLoc);
10417 
10418  PseudoDestructorTypeStorage Destroyed;
10419  if (E->getDestroyedTypeInfo()) {
10420  TypeSourceInfo *DestroyedTypeInfo
10421  = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(),
10422  ObjectType, nullptr, SS);
10423  if (!DestroyedTypeInfo)
10424  return ExprError();
10425  Destroyed = DestroyedTypeInfo;
10426  } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
10427  // We aren't likely to be able to resolve the identifier down to a type
10428  // now anyway, so just retain the identifier.
10430  E->getDestroyedTypeLoc());
10431  } else {
10432  // Look for a destructor known with the given name.
10433  ParsedType T = SemaRef.getDestructorName(E->getTildeLoc(),
10435  E->getDestroyedTypeLoc(),
10436  /*Scope=*/nullptr,
10437  SS, ObjectTypePtr,
10438  false);
10439  if (!T)
10440  return ExprError();
10441 
10442  Destroyed
10443  = SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.GetTypeFromParser(T),
10444  E->getDestroyedTypeLoc());
10445  }
10446 
10447  TypeSourceInfo *ScopeTypeInfo = nullptr;
10448  if (E->getScopeTypeInfo()) {
10449  CXXScopeSpec EmptySS;
10450  ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
10451  E->getScopeTypeInfo(), ObjectType, nullptr, EmptySS);
10452  if (!ScopeTypeInfo)
10453  return ExprError();
10454  }
10455 
10456  return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
10457  E->getOperatorLoc(),
10458  E->isArrow(),
10459  SS,
10460  ScopeTypeInfo,
10461  E->getColonColonLoc(),
10462  E->getTildeLoc(),
10463  Destroyed);
10464 }
10465 
10466 template <typename Derived>
10468  bool RequiresADL,
10469  LookupResult &R) {
10470  // Transform all the decls.
10471  bool AllEmptyPacks = true;
10472  for (auto *OldD : Old->decls()) {
10473  Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
10474  if (!InstD) {
10475  // Silently ignore these if a UsingShadowDecl instantiated to nothing.
10476  // This can happen because of dependent hiding.
10477  if (isa<UsingShadowDecl>(OldD))
10478  continue;
10479  else {
10480  R.clear();
10481  return true;
10482  }
10483  }
10484 
10485  // Expand using pack declarations.
10486  NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
10487  ArrayRef<NamedDecl*> Decls = SingleDecl;
10488  if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
10489  Decls = UPD->expansions();
10490 
10491  // Expand using declarations.
10492  for (auto *D : Decls) {
10493  if (auto *UD = dyn_cast<UsingDecl>(D)) {
10494  for (auto *SD : UD->shadows())
10495  R.addDecl(SD);
10496  } else {
10497  R.addDecl(D);
10498  }
10499  }
10500 
10501  AllEmptyPacks &= Decls.empty();
10502  };
10503 
10504  // C++ [temp.res]/8.4.2:
10505  // The program is ill-formed, no diagnostic required, if [...] lookup for
10506  // a name in the template definition found a using-declaration, but the
10507  // lookup in the corresponding scope in the instantiation odoes not find
10508  // any declarations because the using-declaration was a pack expansion and
10509  // the corresponding pack is empty
10510  if (AllEmptyPacks && !RequiresADL) {
10511  getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
10512  << isa<UnresolvedMemberExpr>(Old) << Old->getName();
10513  return true;
10514  }
10515 
10516  // Resolve a kind, but don't do any further analysis. If it's
10517  // ambiguous, the callee needs to deal with it.
10518  R.resolveKind();
10519  return false;
10520 }
10521 
10522 template<typename Derived>
10523 ExprResult
10525  UnresolvedLookupExpr *Old) {
10526  LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
10528 
10529  // Transform the declaration set.
10530  if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
10531  return ExprError();
10532 
10533  // Rebuild the nested-name qualifier, if present.
10534  CXXScopeSpec SS;
10535  if (Old->getQualifierLoc()) {
10536  NestedNameSpecifierLoc QualifierLoc
10537  = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
10538  if (!QualifierLoc)
10539  return ExprError();
10540 
10541  SS.Adopt(QualifierLoc);
10542  }
10543 
10544  if (Old->getNamingClass()) {
10545  CXXRecordDecl *NamingClass
10546  = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
10547  Old->getNameLoc(),
10548  Old->getNamingClass()));
10549  if (!NamingClass) {
10550  R.clear();
10551  return ExprError();
10552  }
10553 
10554  R.setNamingClass(NamingClass);
10555  }
10556 
10557  SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
10558 
10559  // If we have neither explicit template arguments, nor the template keyword,
10560  // it's a normal declaration name or member reference.
10561  if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid()) {
10562  NamedDecl *D = R.getAsSingle<NamedDecl>();
10563  // In a C++11 unevaluated context, an UnresolvedLookupExpr might refer to an
10564  // instance member. In other contexts, BuildPossibleImplicitMemberExpr will
10565  // give a good diagnostic.
10566  if (D && D->isCXXInstanceMember()) {
10567  return SemaRef.BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, R,
10568  /*TemplateArgs=*/nullptr,
10569  /*Scope=*/nullptr);
10570  }
10571 
10572  return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
10573  }
10574 
10575  // If we have template arguments, rebuild them, then rebuild the
10576  // templateid expression.
10577  TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
10578  if (Old->hasExplicitTemplateArgs() &&
10579  getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
10580  Old->getNumTemplateArgs(),
10581  TransArgs)) {
10582  R.clear();
10583  return ExprError();
10584  }
10585 
10586  return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
10587  Old->requiresADL(), &TransArgs);
10588 }
10589 
10590 template<typename Derived>
10591 ExprResult
10593  bool ArgChanged = false;
10595  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
10596  TypeSourceInfo *From = E->getArg(I);
10597  TypeLoc FromTL = From->getTypeLoc();
10598  if (!FromTL.getAs<PackExpansionTypeLoc>()) {
10599  TypeLocBuilder TLB;
10600  TLB.reserve(FromTL.getFullDataSize());
10601  QualType To = getDerived().TransformType(TLB, FromTL);
10602  if (To.isNull())
10603  return ExprError();
10604 
10605  if (To == From->getType())
10606  Args.push_back(From);
10607  else {
10608  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10609  ArgChanged = true;
10610  }
10611  continue;
10612  }
10613 
10614  ArgChanged = true;
10615 
10616  // We have a pack expansion. Instantiate it.
10617  PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
10618  TypeLoc PatternTL = ExpansionTL.getPatternLoc();
10620  SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
10621 
10622  // Determine whether the set of unexpanded parameter packs can and should
10623  // be expanded.
10624  bool Expand = true;
10625  bool RetainExpansion = false;
10626  Optional<unsigned> OrigNumExpansions =
10627  ExpansionTL.getTypePtr()->getNumExpansions();
10628  Optional<unsigned> NumExpansions = OrigNumExpansions;
10629  if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
10630  PatternTL.getSourceRange(),
10631  Unexpanded,
10632  Expand, RetainExpansion,
10633  NumExpansions))
10634  return ExprError();
10635 
10636  if (!Expand) {
10637  // The transform has determined that we should perform a simple
10638  // transformation on the pack expansion, producing another pack
10639  // expansion.
10640  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
10641 
10642  TypeLocBuilder TLB;
10643  TLB.reserve(From->getTypeLoc().getFullDataSize());
10644 
10645  QualType To = getDerived().TransformType(TLB, PatternTL);
10646  if (To.isNull())
10647  return ExprError();
10648 
10649  To = getDerived().RebuildPackExpansionType(To,
10650  PatternTL.getSourceRange(),
10651  ExpansionTL.getEllipsisLoc(),
10652  NumExpansions);
10653  if (To.isNull())
10654  return ExprError();
10655 
10656  PackExpansionTypeLoc ToExpansionTL
10657  = TLB.push<PackExpansionTypeLoc>(To);
10658  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
10659  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10660  continue;
10661  }
10662 
10663  // Expand the pack expansion by substituting for each argument in the
10664  // pack(s).
10665  for (unsigned I = 0; I != *NumExpansions; ++I) {
10666  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I);
10667  TypeLocBuilder TLB;
10668  TLB.reserve(PatternTL.getFullDataSize());
10669  QualType To = getDerived().TransformType(TLB, PatternTL);
10670  if (To.isNull())
10671  return ExprError();
10672 
10673  if (To->containsUnexpandedParameterPack()) {
10674  To = getDerived().RebuildPackExpansionType(To,
10675  PatternTL.getSourceRange(),
10676  ExpansionTL.getEllipsisLoc(),
10677  NumExpansions);
10678  if (To.isNull())
10679  return ExprError();
10680 
10681  PackExpansionTypeLoc ToExpansionTL
10682  = TLB.push<PackExpansionTypeLoc>(To);
10683  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
10684  }
10685 
10686  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10687  }
10688 
10689  if (!RetainExpansion)
10690  continue;
10691 
10692  // If we're supposed to retain a pack expansion, do so by temporarily
10693  // forgetting the partially-substituted parameter pack.
10694  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
10695 
10696  TypeLocBuilder TLB;
10697  TLB.reserve(From->getTypeLoc().getFullDataSize());
10698 
10699  QualType To = getDerived().TransformType(TLB, PatternTL);
10700  if (To.isNull())
10701  return ExprError();
10702 
10703  To = getDerived().RebuildPackExpansionType(To,
10704  PatternTL.getSourceRange(),
10705  ExpansionTL.getEllipsisLoc(),
10706  NumExpansions);
10707  if (To.isNull())
10708  return ExprError();
10709 
10710  PackExpansionTypeLoc ToExpansionTL
10711  = TLB.push<PackExpansionTypeLoc>(To);
10712  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
10713  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10714  }
10715 
10716  if (!getDerived().AlwaysRebuild() && !ArgChanged)
10717  return E;
10718 
10719  return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
10720  E->getEndLoc());
10721 }
10722 
10723 template<typename Derived>
10724 ExprResult
10726  TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
10727  if (!T)
10728  return ExprError();
10729 
10730  if (!getDerived().AlwaysRebuild() &&
10731  T == E->getQueriedTypeSourceInfo())
10732  return E;
10733 
10734  ExprResult SubExpr;
10735  {
10738  SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
10739  if (SubExpr.isInvalid())
10740  return ExprError();
10741 
10742  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getDimensionExpression())
10743  return E;
10744  }
10745 
10746  return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
10747  SubExpr.get(), E->getEndLoc());
10748 }
10749 
10750 template<typename Derived>
10751 ExprResult
10753  ExprResult SubExpr;
10754  {
10757  SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
10758  if (SubExpr.isInvalid())
10759  return ExprError();
10760 
10761  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
10762  return E;
10763  }
10764 
10765  return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
10766  SubExpr.get(), E->getEndLoc());
10767 }
10768 
10769 template <typename Derived>
10771  ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
10772  TypeSourceInfo **RecoveryTSI) {
10773  ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
10774  DRE, AddrTaken, RecoveryTSI);
10775 
10776  // Propagate both errors and recovered types, which return ExprEmpty.
10777  if (!NewDRE.isUsable())
10778  return NewDRE;
10779 
10780  // We got an expr, wrap it up in parens.
10781  if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
10782  return PE;
10783  return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
10784  PE->getRParen());
10785 }
10786 
10787 template <typename Derived>
10790  return TransformDependentScopeDeclRefExpr(E, /*IsAddressOfOperand=*/false,
10791  nullptr);
10792 }
10793 
10794 template<typename Derived>
10795 ExprResult
10798  bool IsAddressOfOperand,
10799  TypeSourceInfo **RecoveryTSI) {
10800  assert(E->getQualifierLoc());
10801  NestedNameSpecifierLoc QualifierLoc
10802  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
10803  if (!QualifierLoc)
10804  return ExprError();
10805  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
10806 
10807  // TODO: If this is a conversion-function-id, verify that the
10808  // destination type name (if present) resolves the same way after
10809  // instantiation as it did in the local scope.
10810 
10811  DeclarationNameInfo NameInfo
10812  = getDerived().TransformDeclarationNameInfo(E->getNameInfo());
10813  if (!NameInfo.getName())
10814  return ExprError();
10815 
10816  if (!E->hasExplicitTemplateArgs()) {
10817  if (!getDerived().AlwaysRebuild() &&
10818  QualifierLoc == E->getQualifierLoc() &&
10819  // Note: it is sufficient to compare the Name component of NameInfo:
10820  // if name has not changed, DNLoc has not changed either.
10821  NameInfo.getName() == E->getDeclName())
10822  return E;
10823 
10824  return getDerived().RebuildDependentScopeDeclRefExpr(
10825  QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
10826  IsAddressOfOperand, RecoveryTSI);
10827  }
10828 
10829  TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
10830  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
10831  E->getNumTemplateArgs(),
10832  TransArgs))
10833  return ExprError();
10834 
10835  return getDerived().RebuildDependentScopeDeclRefExpr(
10836  QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
10837  RecoveryTSI);
10838 }
10839 
10840 template<typename Derived>
10841 ExprResult
10843  // CXXConstructExprs other than for list-initialization and
10844  // CXXTemporaryObjectExpr are always implicit, so when we have
10845  // a 1-argument construction we just transform that argument.
10846  if ((E->getNumArgs() == 1 ||
10847  (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
10848  (!getDerived().DropCallArgument(E->getArg(0))) &&
10849  !E->isListInitialization())
10850  return getDerived().TransformExpr(E->getArg(0));
10851 
10852  TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
10853 
10854  QualType T = getDerived().TransformType(E->getType());
10855  if (T.isNull())
10856  return ExprError();
10857 
10858  CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
10859  getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
10860  if (!Constructor)
10861  return ExprError();
10862 
10863  bool ArgumentChanged = false;
10864  SmallVector<Expr*, 8> Args;
10865  {
10868  E->isListInitialization());
10869  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
10870  &ArgumentChanged))
10871  return ExprError();
10872  }
10873 
10874  if (!getDerived().AlwaysRebuild() &&
10875  T == E->getType() &&
10876  Constructor == E->getConstructor() &&
10877  !ArgumentChanged) {
10878  // Mark the constructor as referenced.
10879  // FIXME: Instantiation-specific
10880  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
10881  return E;
10882  }
10883 
10884  return getDerived().RebuildCXXConstructExpr(
10885  T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
10889 }
10890 
10891 template<typename Derived>
10894  QualType T = getDerived().TransformType(E->getType());
10895  if (T.isNull())
10896  return ExprError();
10897 
10898  CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
10899  getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
10900  if (!Constructor)
10901  return ExprError();
10902 
10903  if (!getDerived().AlwaysRebuild() &&
10904  T == E->getType() &&
10905  Constructor == E->getConstructor()) {
10906  // Mark the constructor as referenced.
10907  // FIXME: Instantiation-specific
10908  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
10909  return E;
10910  }
10911 
10912  return getDerived().RebuildCXXInheritedCtorInitExpr(
10913  T, E->getLocation(), Constructor,
10914  E->constructsVBase(), E->inheritedFromVBase());
10915 }
10916 
10917 /// Transform a C++ temporary-binding expression.
10918 ///
10919 /// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
10920 /// transform the subexpression and return that.
10921 template<typename Derived>
10922 ExprResult
10924  return getDerived().TransformExpr(E->getSubExpr());
10925 }
10926 
10927 /// Transform a C++ expression that contains cleanups that should
10928 /// be run after the expression is evaluated.
10929 ///
10930 /// Since ExprWithCleanups nodes are implicitly generated, we
10931 /// just transform the subexpression and return that.
10932 template<typename Derived>
10933 ExprResult
10935  return getDerived().TransformExpr(E->getSubExpr());
10936 }
10937 
10938 template<typename Derived>
10939 ExprResult
10942  TypeSourceInfo *T =
10943  getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
10944  if (!T)
10945  return ExprError();
10946 
10947  CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
10948  getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
10949  if (!Constructor)
10950  return ExprError();
10951 
10952  bool ArgumentChanged = false;
10953  SmallVector<Expr*, 8> Args;
10954  Args.reserve(E->getNumArgs());
10955  {
10958  E->isListInitialization());
10959  if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
10960  &ArgumentChanged))
10961  return ExprError();
10962  }
10963 
10964  if (!getDerived().AlwaysRebuild() &&
10965  T == E->getTypeSourceInfo() &&
10966  Constructor == E->getConstructor() &&
10967  !ArgumentChanged) {
10968  // FIXME: Instantiation-specific
10969  SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
10970  return SemaRef.MaybeBindToTemporary(E);
10971  }
10972 
10973  // FIXME: We should just pass E->isListInitialization(), but we're not
10974  // prepared to handle list-initialization without a child InitListExpr.
10975  SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
10976  return getDerived().RebuildCXXTemporaryObjectExpr(
10977  T, LParenLoc, Args, E->getEndLoc(),
10978  /*ListInitialization=*/LParenLoc.isInvalid());
10979 }
10980 
10981 template<typename Derived>
10982 ExprResult
10984  // Transform any init-capture expressions before entering the scope of the
10985  // lambda body, because they are not semantically within that scope.
10986  typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
10987  SmallVector<InitCaptureInfoTy, 8> InitCaptureExprsAndTypes;
10988  InitCaptureExprsAndTypes.resize(E->explicit_capture_end() -
10989  E->explicit_capture_begin());
10991  CEnd = E->capture_end();
10992  C != CEnd; ++C) {
10993  if (!E->isInitCapture(C))
10994  continue;
10997  ExprResult NewExprInitResult = getDerived().TransformInitializer(
10998  C->getCapturedVar()->getInit(),
10999  C->getCapturedVar()->getInitStyle() == VarDecl::CallInit);
11000 
11001  if (NewExprInitResult.isInvalid())
11002  return ExprError();
11003  Expr *NewExprInit = NewExprInitResult.get();
11004 
11005  VarDecl *OldVD = C->getCapturedVar();
11006  QualType NewInitCaptureType =
11007  getSema().buildLambdaInitCaptureInitialization(
11008  C->getLocation(), OldVD->getType()->isReferenceType(),
11009  OldVD->getIdentifier(),
11010  C->getCapturedVar()->getInitStyle() != VarDecl::CInit, NewExprInit);
11011  NewExprInitResult = NewExprInit;
11012  InitCaptureExprsAndTypes[C - E->capture_begin()] =
11013  std::make_pair(NewExprInitResult, NewInitCaptureType);
11014  }
11015 
11016  // Transform the template parameters, and add them to the current
11017  // instantiation scope. The null case is handled correctly.
11018  auto TPL = getDerived().TransformTemplateParameterList(
11020 
11021  // Transform the type of the original lambda's call operator.
11022  // The transformation MUST be done in the CurrentInstantiationScope since
11023  // it introduces a mapping of the original to the newly created
11024  // transformed parameters.
11025  TypeSourceInfo *NewCallOpTSI = nullptr;
11026  {
11027  TypeSourceInfo *OldCallOpTSI = E->getCallOperator()->getTypeSourceInfo();
11028  FunctionProtoTypeLoc OldCallOpFPTL =
11029  OldCallOpTSI->getTypeLoc().getAs<FunctionProtoTypeLoc>();
11030 
11031  TypeLocBuilder NewCallOpTLBuilder;
11032  SmallVector<QualType, 4> ExceptionStorage;
11033  TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
11034  QualType NewCallOpType = TransformFunctionProtoType(
11035  NewCallOpTLBuilder, OldCallOpFPTL, nullptr, Qualifiers(),
11036  [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
11037  return This->TransformExceptionSpec(OldCallOpFPTL.getBeginLoc(), ESI,
11038  ExceptionStorage, Changed);
11039  });
11040  if (NewCallOpType.isNull())
11041  return ExprError();
11042  NewCallOpTSI = NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context,
11043  NewCallOpType);
11044  }
11045 
11046  LambdaScopeInfo *LSI = getSema().PushLambdaScope();
11047  Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
11048  LSI->GLTemplateParameterList = TPL;
11049 
11050  // Create the local class that will describe the lambda.
11051  CXXRecordDecl *Class
11052  = getSema().createLambdaClosureType(E->getIntroducerRange(),
11053  NewCallOpTSI,
11054  /*KnownDependent=*/false,
11055  E->getCaptureDefault());
11056  getDerived().transformedLocalDecl(E->getLambdaClass(), Class);
11057 
11058  // Build the call operator.
11059  CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition(
11060  Class, E->getIntroducerRange(), NewCallOpTSI,
11061  E->getCallOperator()->getEndLoc(),
11062  NewCallOpTSI->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams(),
11063  E->getCallOperator()->isConstexpr());
11064 
11065  LSI->CallOperator = NewCallOperator;
11066 
11067  for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
11068  I != NumParams; ++I) {
11069  auto *P = NewCallOperator->getParamDecl(I);
11070  if (P->hasUninstantiatedDefaultArg()) {
11072  getSema(),
11074  ExprResult R = getDerived().TransformExpr(
11076  P->setDefaultArg(R.get());
11077  }
11078  }
11079 
11080  getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
11081  getDerived().transformedLocalDecl(E->getCallOperator(), NewCallOperator);
11082 
11083  // Introduce the context of the call operator.
11084  Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
11085  /*NewThisContext*/false);
11086 
11087  // Enter the scope of the lambda.
11088  getSema().buildLambdaScope(LSI, NewCallOperator,
11089  E->getIntroducerRange(),
11090  E->getCaptureDefault(),
11091  E->getCaptureDefaultLoc(),
11092  E->hasExplicitParameters(),
11093  E->hasExplicitResultType(),
11094  E->isMutable());
11095 
11096  bool Invalid = false;
11097 
11098  // Transform captures.
11099  bool FinishedExplicitCaptures = false;
11101  CEnd = E->capture_end();
11102  C != CEnd; ++C) {
11103  // When we hit the first implicit capture, tell Sema that we've finished
11104  // the list of explicit captures.
11105  if (!FinishedExplicitCaptures && C->isImplicit()) {
11106  getSema().finishLambdaExplicitCaptures(LSI);
11107  FinishedExplicitCaptures = true;
11108  }
11109 
11110  // Capturing 'this' is trivial.
11111  if (C->capturesThis()) {
11112  getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
11113  /*BuildAndDiagnose*/ true, nullptr,
11114  C->getCaptureKind() == LCK_StarThis);
11115  continue;
11116  }
11117  // Captured expression will be recaptured during captured variables
11118  // rebuilding.
11119  if (C->capturesVLAType())
11120  continue;
11121 
11122  // Rebuild init-captures, including the implied field declaration.
11123  if (E->isInitCapture(C)) {
11124  InitCaptureInfoTy InitExprTypePair =
11125  InitCaptureExprsAndTypes[C - E->capture_begin()];
11126  ExprResult Init = InitExprTypePair.first;
11127  QualType InitQualType = InitExprTypePair.second;
11128  if (Init.isInvalid() || InitQualType.isNull()) {
11129  Invalid = true;
11130  continue;
11131  }
11132  VarDecl *OldVD = C->getCapturedVar();
11133  VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
11134  OldVD->getLocation(), InitExprTypePair.second, OldVD->getIdentifier(),
11135  OldVD->getInitStyle(), Init.get());
11136  if (!NewVD)
11137  Invalid = true;
11138  else {
11139  getDerived().transformedLocalDecl(OldVD, NewVD);
11140  }
11141  getSema().buildInitCaptureField(LSI, NewVD);
11142  continue;
11143  }
11144 
11145  assert(C->capturesVariable() && "unexpected kind of lambda capture");
11146 
11147  // Determine the capture kind for Sema.
11149  = C->isImplicit()? Sema::TryCapture_Implicit
11150  : C->getCaptureKind() == LCK_ByCopy
11153  SourceLocation EllipsisLoc;
11154  if (C->isPackExpansion()) {
11155  UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
11156  bool ShouldExpand = false;
11157  bool RetainExpansion = false;
11158  Optional<unsigned> NumExpansions;
11159  if (getDerived().TryExpandParameterPacks(C->getEllipsisLoc(),
11160  C->getLocation(),
11161  Unexpanded,
11162  ShouldExpand, RetainExpansion,
11163  NumExpansions)) {
11164  Invalid = true;
11165  continue;
11166  }
11167 
11168  if (ShouldExpand) {
11169  // The transform has determined that we should perform an expansion;
11170  // transform and capture each of the arguments.
11171  // expansion of the pattern. Do so.
11172  VarDecl *Pack = C->getCapturedVar();
11173  for (unsigned I = 0; I != *NumExpansions; ++I) {
11174  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
11175  VarDecl *CapturedVar
11176  = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(),
11177  Pack));
11178  if (!CapturedVar) {
11179  Invalid = true;
11180  continue;
11181  }
11182 
11183  // Capture the transformed variable.
11184  getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
11185  }
11186 
11187  // FIXME: Retain a pack expansion if RetainExpansion is true.
11188 
11189  continue;
11190  }
11191 
11192  EllipsisLoc = C->getEllipsisLoc();
11193  }
11194 
11195  // Transform the captured variable.
11196  VarDecl *CapturedVar
11197  = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(),
11198  C->getCapturedVar()));
11199  if (!CapturedVar || CapturedVar->isInvalidDecl()) {
11200  Invalid = true;
11201  continue;
11202  }
11203 
11204  // Capture the transformed variable.
11205  getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
11206  EllipsisLoc);
11207  }
11208  if (!FinishedExplicitCaptures)
11209  getSema().finishLambdaExplicitCaptures(LSI);
11210 
11211  // Enter a new evaluation context to insulate the lambda from any
11212  // cleanups from the enclosing full-expression.
11213  getSema().PushExpressionEvaluationContext(
11215 
11216  // Instantiate the body of the lambda expression.
11217  StmtResult Body =
11218  Invalid ? StmtError() : getDerived().TransformStmt(E->getBody());
11219 
11220  // ActOnLambda* will pop the function scope for us.
11221  FuncScopeCleanup.disable();
11222 
11223  if (Body.isInvalid()) {
11224  SavedContext.pop();
11225  getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
11226  /*IsInstantiation=*/true);
11227  return ExprError();
11228  }
11229 
11230  // Copy the LSI before ActOnFinishFunctionBody removes it.
11231  // FIXME: This is dumb. Store the lambda information somewhere that outlives
11232  // the call operator.
11233  auto LSICopy = *LSI;
11234  getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
11235  /*IsInstantiation*/ true);
11236  SavedContext.pop();
11237 
11238  return getSema().BuildLambdaExpr(E->getBeginLoc(), Body.get()->getEndLoc(),
11239  &LSICopy);
11240 }
11241 
11242 template<typename Derived>
11243 ExprResult
11246  TypeSourceInfo *T =
11247  getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
11248  if (!T)
11249  return ExprError();
11250 
11251  bool ArgumentChanged = false;
11252  SmallVector<Expr*, 8> Args;
11253  Args.reserve(E->arg_size());
11254  {
11257  E->isListInitialization());
11258  if (getDerived().TransformExprs(E->arg_begin(), E->arg_size(), true, Args,
11259  &ArgumentChanged))
11260  return ExprError();
11261  }
11262 
11263  if (!getDerived().AlwaysRebuild() &&
11264  T == E->getTypeSourceInfo() &&
11265  !ArgumentChanged)
11266  return E;
11267 
11268  // FIXME: we're faking the locations of the commas
11269  return getDerived().RebuildCXXUnresolvedConstructExpr(
11270  T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
11271 }
11272 
11273 template<typename Derived>
11274 ExprResult
11277  // Transform the base of the expression.
11278  ExprResult Base((Expr*) nullptr);
11279  Expr *OldBase;
11280  QualType BaseType;
11281  QualType ObjectType;
11282  if (!E->isImplicitAccess()) {
11283  OldBase = E->getBase();
11284  Base = getDerived().TransformExpr(OldBase);
11285  if (Base.isInvalid())
11286  return ExprError();
11287 
11288  // Start the member reference and compute the object's type.
11289  ParsedType ObjectTy;
11290  bool MayBePseudoDestructor = false;
11291  Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
11292  E->getOperatorLoc(),
11293  E->isArrow()? tok::arrow : tok::period,
11294  ObjectTy,
11295  MayBePseudoDestructor);
11296  if (Base.isInvalid())
11297  return ExprError();
11298 
11299  ObjectType = ObjectTy.get();
11300  BaseType = ((Expr*) Base.get())->getType();
11301  } else {
11302  OldBase = nullptr;
11303  BaseType = getDerived().TransformType(E->getBaseType());
11304  ObjectType = BaseType->getAs<PointerType>()->getPointeeType();
11305  }
11306 
11307  // Transform the first part of the nested-name-specifier that qualifies
11308  // the member name.
11309  NamedDecl *FirstQualifierInScope
11310  = getDerived().TransformFirstQualifierInScope(
11312  E->getQualifierLoc().getBeginLoc());
11313 
11314  NestedNameSpecifierLoc QualifierLoc;
11315  if (E->getQualifier()) {
11316  QualifierLoc
11317  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
11318  ObjectType,
11319  FirstQualifierInScope);
11320  if (!QualifierLoc)
11321  return ExprError();
11322  }
11323 
11324  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
11325 
11326  // TODO: If this is a conversion-function-id, verify that the
11327  // destination type name (if present) resolves the same way after
11328  // instantiation as it did in the local scope.
11329 
11330  DeclarationNameInfo NameInfo
11331  = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
11332  if (!NameInfo.getName())
11333  return ExprError();
11334 
11335  if (!E->hasExplicitTemplateArgs()) {
11336  // This is a reference to a member without an explicitly-specified
11337  // template argument list. Optimize for this common case.
11338  if (!getDerived().AlwaysRebuild() &&
11339  Base.get() == OldBase &&
11340  BaseType == E->getBaseType() &&
11341  QualifierLoc == E->getQualifierLoc() &&
11342  NameInfo.getName() == E->getMember() &&
11343  FirstQualifierInScope == E->getFirstQualifierFoundInScope())
11344  return E;
11345 
11346  return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
11347  BaseType,
11348  E->isArrow(),
11349  E->getOperatorLoc(),
11350  QualifierLoc,
11351  TemplateKWLoc,
11352  FirstQualifierInScope,
11353  NameInfo,
11354  /*TemplateArgs*/nullptr);
11355  }
11356 
11357  TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
11358  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
11359  E->getNumTemplateArgs(),
11360  TransArgs))
11361  return ExprError();
11362 
11363  return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
11364  BaseType,
11365  E->isArrow(),
11366  E->getOperatorLoc(),
11367  QualifierLoc,
11368  TemplateKWLoc,
11369  FirstQualifierInScope,
11370  NameInfo,
11371  &TransArgs);
11372 }
11373 
11374 template<typename Derived>
11375 ExprResult
11377  // Transform the base of the expression.
11378  ExprResult Base((Expr*) nullptr);
11379  QualType BaseType;
11380  if (!Old->isImplicitAccess()) {
11381  Base = getDerived().TransformExpr(Old->getBase());
11382  if (Base.isInvalid())
11383  return ExprError();
11384  Base = getSema().PerformMemberExprBaseConversion(Base.get(),
11385  Old->isArrow());
11386  if (Base.isInvalid())
11387  return ExprError();
11388  BaseType = Base.get()->getType();
11389  } else {
11390  BaseType = getDerived().TransformType(Old->getBaseType());
11391  }
11392 
11393  NestedNameSpecifierLoc QualifierLoc;
11394  if (Old->getQualifierLoc()) {
11395  QualifierLoc
11396  = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
11397  if (!QualifierLoc)
11398  return ExprError();
11399  }
11400 
11401  SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
11402 
11403  LookupResult R(SemaRef, Old->getMemberNameInfo(),
11405 
11406  // Transform the declaration set.
11407  if (TransformOverloadExprDecls(Old, /*RequiresADL*/false, R))
11408  return ExprError();
11409 
11410  // Determine the naming class.
11411  if (Old->getNamingClass()) {
11412  CXXRecordDecl *NamingClass
11413  = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
11414  Old->getMemberLoc(),
11415  Old->getNamingClass()));
11416  if (!NamingClass)
11417  return ExprError();
11418 
11419  R.setNamingClass(NamingClass);
11420  }
11421 
11422  TemplateArgumentListInfo TransArgs;
11423  if (Old->hasExplicitTemplateArgs()) {
11424  TransArgs.setLAngleLoc(Old->getLAngleLoc());
11425  TransArgs.setRAngleLoc(Old->getRAngleLoc());
11426  if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
11427  Old->getNumTemplateArgs(),
11428  TransArgs))
11429  return ExprError();
11430  }
11431 
11432  // FIXME: to do this check properly, we will need to preserve the
11433  // first-qualifier-in-scope here, just in case we had a dependent
11434  // base (and therefore couldn't do the check) and a
11435  // nested-name-qualifier (and therefore could do the lookup).
11436  NamedDecl *FirstQualifierInScope = nullptr;
11437 
11438  return getDerived().RebuildUnresolvedMemberExpr(Base.get(),
11439  BaseType,
11440  Old->getOperatorLoc(),
11441  Old->isArrow(),
11442  QualifierLoc,
11443  TemplateKWLoc,
11444  FirstQualifierInScope,
11445  R,
11446  (Old->hasExplicitTemplateArgs()
11447  ? &TransArgs : nullptr));
11448 }
11449 
11450 template<typename Derived>
11451 ExprResult
11455  ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
11456  if (SubExpr.isInvalid())
11457  return ExprError();
11458 
11459  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
11460  return E;
11461 
11462  return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
11463 }
11464 
11465 template<typename Derived>
11466 ExprResult
11468  ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
11469  if (Pattern.isInvalid())
11470  return ExprError();
11471 
11472  if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
11473  return E;
11474 
11475  return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
11476  E->getNumExpansions());
11477 }
11478 
11479 template<typename Derived>
11480 ExprResult
11482  // If E is not value-dependent, then nothing will change when we transform it.
11483  // Note: This is an instantiation-centric view.
11484  if (!E->isValueDependent())
11485  return E;
11486 
11489 
11490  ArrayRef<TemplateArgument> PackArgs;
11491  TemplateArgument ArgStorage;
11492 
11493  // Find the argument list to transform.
11494  if (E->isPartiallySubstituted()) {
11495  PackArgs = E->getPartialArguments();
11496  } else if (E->isValueDependent()) {
11497  UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
11498  bool ShouldExpand = false;
11499  bool RetainExpansion = false;
11500  Optional<unsigned> NumExpansions;
11501  if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(),
11502  Unexpanded,
11503  ShouldExpand, RetainExpansion,
11504  NumExpansions))
11505  return ExprError();
11506 
11507  // If we need to expand the pack, build a template argument from it and
11508  // expand that.
11509  if (ShouldExpand) {
11510  auto *Pack = E->getPack();
11511  if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
11512  ArgStorage = getSema().Context.getPackExpansionType(
11513  getSema().Context.getTypeDeclType(TTPD), None);
11514  } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
11515  ArgStorage = TemplateArgument(TemplateName(TTPD), None);
11516  } else {
11517  auto *VD = cast<ValueDecl>(Pack);
11518  ExprResult DRE = getSema().BuildDeclRefExpr(
11519  VD, VD->getType().getNonLValueExprType(getSema().Context),
11520  VD->getType()->isReferenceType() ? VK_LValue : VK_RValue,
11521  E->getPackLoc());
11522  if (DRE.isInvalid())
11523  return ExprError();
11524  ArgStorage = new (getSema().Context) PackExpansionExpr(
11525  getSema().Context.DependentTy, DRE.get(), E->getPackLoc(), None);
11526  }
11527  PackArgs = ArgStorage;
11528  }
11529  }
11530 
11531  // If we're not expanding the pack, just transform the decl.
11532  if (!PackArgs.size()) {
11533  auto *Pack = cast_or_null<NamedDecl>(
11534  getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
11535  if (!Pack)
11536  return ExprError();
11537  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), Pack,
11538  E->getPackLoc(),
11539  E->getRParenLoc(), None, None);
11540  }
11541 
11542  // Try to compute the result without performing a partial substitution.
11543  Optional<unsigned> Result = 0;
11544  for (const TemplateArgument &Arg : PackArgs) {
11545  if (!Arg.isPackExpansion()) {
11546  Result = *Result + 1;
11547  continue;
11548  }
11549 
11550  TemplateArgumentLoc ArgLoc;
11551  InventTemplateArgumentLoc(Arg, ArgLoc);
11552 
11553  // Find the pattern of the pack expansion.
11554  SourceLocation Ellipsis;
11555  Optional<unsigned> OrigNumExpansions;
11556  TemplateArgumentLoc Pattern =
11557  getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
11558  OrigNumExpansions);
11559 
11560  // Substitute under the pack expansion. Do not expand the pack (yet).
11561  TemplateArgumentLoc OutPattern;
11562  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
11563  if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
11564  /*Uneval*/ true))
11565  return true;
11566 
11567  // See if we can determine the number of arguments from the result.
11568  Optional<unsigned> NumExpansions =
11569  getSema().getFullyPackExpandedSize(OutPattern.getArgument());
11570  if (!NumExpansions) {
11571  // No: we must be in an alias template expansion, and we're going to need
11572  // to actually expand the packs.
11573  Result = None;
11574  break;
11575  }
11576 
11577  Result = *Result + *NumExpansions;
11578  }
11579 
11580  // Common case: we could determine the number of expansions without
11581  // substituting.
11582  if (Result)
11583  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
11584  E->getPackLoc(),
11585  E->getRParenLoc(), *Result, None);
11586 
11587  TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
11588  E->getPackLoc());
11589  {
11590  TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
11592  Derived, const TemplateArgument*> PackLocIterator;
11593  if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
11594  PackLocIterator(*this, PackArgs.end()),
11595  TransformedPackArgs, /*Uneval*/true))
11596  return ExprError();
11597  }
11598 
11599  // Check whether we managed to fully-expand the pack.
11600  // FIXME: Is it possible for us to do so and not hit the early exit path?
11602  bool PartialSubstitution = false;
11603  for (auto &Loc : TransformedPackArgs.arguments()) {
11604  Args.push_back(Loc.getArgument());
11605  if (Loc.getArgument().isPackExpansion())
11606  PartialSubstitution = true;
11607  }
11608 
11609  if (PartialSubstitution)
11610  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
11611  E->getPackLoc(),
11612  E->getRParenLoc(), None, Args);
11613 
11614  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
11615  E->getPackLoc(), E->getRParenLoc(),
11616  Args.size(), None);
11617 }
11618 
11619 template<typename Derived>
11620 ExprResult
11623  // Default behavior is to do nothing with this transformation.
11624  return E;
11625 }
11626 
11627 template<typename Derived>
11628 ExprResult
11631  // Default behavior is to do nothing with this transformation.
11632  return E;
11633 }
11634 
11635 template<typename Derived>
11636 ExprResult
11638  // Default behavior is to do nothing with this transformation.
11639  return E;
11640 }
11641 
11642 template<typename Derived>
11643 ExprResult
11646  return getDerived().TransformExpr(E->GetTemporaryExpr());
11647 }
11648 
11649 template<typename Derived>
11650 ExprResult
11652  Expr *Pattern = E->getPattern();
11653 
11655  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
11656  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
11657 
11658  // Determine whether the set of unexpanded parameter packs can and should
11659  // be expanded.
11660  bool Expand = true;
11661  bool RetainExpansion = false;
11662  Optional<unsigned> NumExpansions;
11663  if (getDerived().TryExpandParameterPacks(E->getEllipsisLoc(),
11664  Pattern->getSourceRange(),
11665  Unexpanded,
11666  Expand, RetainExpansion,
11667  NumExpansions))
11668  return true;
11669 
11670  if (!Expand) {
11671  // Do not expand any packs here, just transform and rebuild a fold
11672  // expression.
11673  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
11674 
11675  ExprResult LHS =
11676  E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
11677  if (LHS.isInvalid())
11678  return true;
11679 
11680  ExprResult RHS =
11681  E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
11682  if (RHS.isInvalid())
11683  return true;
11684 
11685  if (!getDerived().AlwaysRebuild() &&
11686  LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
11687  return E;
11688 
11689  return getDerived().RebuildCXXFoldExpr(
11690  E->getBeginLoc(), LHS.get(), E->getOperator(), E->getEllipsisLoc(),
11691  RHS.get(), E->getEndLoc());
11692  }
11693 
11694  // The transform has determined that we should perform an elementwise
11695  // expansion of the pattern. Do so.
11696  ExprResult Result = getDerived().TransformExpr(E->getInit());
11697  if (Result.isInvalid())
11698  return true;
11699  bool LeftFold = E->isLeftFold();
11700 
11701  // If we're retaining an expansion for a right fold, it is the innermost
11702  // component and takes the init (if any).
11703  if (!LeftFold && RetainExpansion) {
11704  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
11705 
11706  ExprResult Out = getDerived().TransformExpr(Pattern);
11707  if (Out.isInvalid())
11708  return true;
11709 
11710  Result = getDerived().RebuildCXXFoldExpr(
11711  E->getBeginLoc(), Out.get(), E->getOperator(), E->getEllipsisLoc(),
11712  Result.get(), E->getEndLoc());
11713  if (Result.isInvalid())
11714  return true;
11715  }
11716 
11717  for (unsigned I = 0; I != *NumExpansions; ++I) {
11719  getSema(), LeftFold ? I : *NumExpansions - I - 1);
11720  ExprResult Out = getDerived().TransformExpr(Pattern);
11721  if (Out.isInvalid())
11722  return true;
11723 
11724  if (Out.get()->containsUnexpandedParameterPack()) {
11725  // We still have a pack; retain a pack expansion for this slice.
11726  Result = getDerived().RebuildCXXFoldExpr(
11727  E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
11728  E->getOperator(), E->getEllipsisLoc(),
11729  LeftFold ? Out.get() : Result.get(), E->getEndLoc());
11730  } else if (Result.isUsable()) {
11731  // We've got down to a single element; build a binary operator.
11732  Result = getDerived().RebuildBinaryOperator(
11733  E->getEllipsisLoc(), E->getOperator(),
11734  LeftFold ? Result.get() : Out.get(),
11735  LeftFold ? Out.get() : Result.get());
11736  } else
11737  Result = Out;
11738 
11739  if (Result.isInvalid())
11740  return true;
11741  }
11742 
11743  // If we're retaining an expansion for a left fold, it is the outermost
11744  // component and takes the complete expansion so far as its init (if any).
11745  if (LeftFold && RetainExpansion) {
11746  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
11747 
11748  ExprResult Out = getDerived().TransformExpr(Pattern);
11749  if (Out.isInvalid())
11750  return true;
11751 
11752  Result = getDerived().RebuildCXXFoldExpr(
11753  E->getBeginLoc(), Result.get(), E->getOperator(), E->getEllipsisLoc(),
11754  Out.get(), E->getEndLoc());
11755  if (Result.isInvalid())
11756  return true;
11757  }
11758 
11759  // If we had no init and an empty pack, and we're not retaining an expansion,
11760  // then produce a fallback value or error.
11761  if (Result.isUnset())
11762  return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
11763  E->getOperator());
11764 
11765  return Result;
11766 }
11767 
11768 template<typename Derived>
11769 ExprResult
11772  return getDerived().TransformExpr(E->getSubExpr());
11773 }
11774 
11775 template<typename Derived>
11776 ExprResult
11778  return SemaRef.MaybeBindToTemporary(E);
11779 }
11780 
11781 template<typename Derived>
11782 ExprResult
11784  return E;
11785 }
11786 
11787 template<typename Derived>
11788 ExprResult
11790  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
11791  if (SubExpr.isInvalid())
11792  return ExprError();
11793 
11794  if (!getDerived().AlwaysRebuild() &&
11795  SubExpr.get() == E->getSubExpr())
11796  return E;
11797 
11798  return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
11799 }
11800 
11801 template<typename Derived>
11802 ExprResult
11804  // Transform each of the elements.
11805  SmallVector<Expr *, 8> Elements;
11806  bool ArgChanged = false;
11807  if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
11808  /*IsCall=*/false, Elements, &ArgChanged))
11809  return ExprError();
11810 
11811  if (!getDerived().AlwaysRebuild() && !ArgChanged)
11812  return SemaRef.MaybeBindToTemporary(E);
11813 
11814  return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
11815  Elements.data(),
11816  Elements.size());
11817 }
11818 
11819 template<typename Derived>
11820 ExprResult
11822  ObjCDictionaryLiteral *E) {
11823  // Transform each of the elements.
11825  bool ArgChanged = false;
11826  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
11827  ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
11828 
11829  if (OrigElement.isPackExpansion()) {
11830  // This key/value element is a pack expansion.
11832  getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
11833  getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
11834  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
11835 
11836  // Determine whether the set of unexpanded parameter packs can
11837  // and should be expanded.
11838  bool Expand = true;
11839  bool RetainExpansion = false;
11840  Optional<unsigned> OrigNumExpansions = OrigElement.NumExpansions;
11841  Optional<unsigned> NumExpansions = OrigNumExpansions;
11842  SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
11843  OrigElement.Value->getEndLoc());
11844  if (getDerived().TryExpandParameterPacks(OrigElement.EllipsisLoc,
11845  PatternRange, Unexpanded, Expand,
11846  RetainExpansion, NumExpansions))
11847  return ExprError();
11848 
11849  if (!Expand) {
11850  // The transform has determined that we should perform a simple
11851  // transformation on the pack expansion, producing another pack
11852  // expansion.
11853  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
11854  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
11855  if (Key.isInvalid())
11856  return ExprError();
11857 
11858  if (Key.get() != OrigElement.Key)
11859  ArgChanged = true;
11860 
11861  ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
11862  if (Value.isInvalid())
11863  return ExprError();
11864 
11865  if (Value.get() != OrigElement.Value)
11866  ArgChanged = true;
11867 
11868  ObjCDictionaryElement Expansion = {
11869  Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
11870  };
11871  Elements.push_back(Expansion);
11872  continue;
11873  }
11874 
11875  // Record right away that the argument was changed. This needs
11876  // to happen even if the array expands to nothing.
11877  ArgChanged = true;
11878 
11879  // The transform has determined that we should perform an elementwise
11880  // expansion of the pattern. Do so.
11881  for (unsigned I = 0; I != *NumExpansions; ++I) {
11882  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
11883  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
11884  if (Key.isInvalid())
11885  return ExprError();
11886 
11887  ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
11888  if (Value.isInvalid())
11889  return ExprError();
11890 
11891  ObjCDictionaryElement Element = {
11892  Key.get(), Value.get(), SourceLocation(), NumExpansions
11893  };
11894 
11895  // If any unexpanded parameter packs remain, we still have a
11896  // pack expansion.
11897  // FIXME: Can this really happen?
11898  if (Key.get()->containsUnexpandedParameterPack() ||
11899  Value.get()->containsUnexpandedParameterPack())
11900  Element.EllipsisLoc = OrigElement.EllipsisLoc;
11901 
11902  Elements.push_back(Element);
11903  }
11904 
11905  // FIXME: Retain a pack expansion if RetainExpansion is true.
11906 
11907  // We've finished with this pack expansion.
11908  continue;
11909  }
11910 
11911  // Transform and check key.
11912  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
11913  if (Key.isInvalid())
11914  return ExprError();
11915 
11916  if (Key.get() != OrigElement.Key)
11917  ArgChanged = true;
11918 
11919  // Transform and check value.
11921  = getDerived().TransformExpr(OrigElement.Value);
11922  if (Value.isInvalid())
11923  return ExprError();
11924 
11925  if (Value.get() != OrigElement.Value)
11926  ArgChanged = true;
11927 
11928  ObjCDictionaryElement Element = {
11929  Key.get(), Value.get(), SourceLocation(), None
11930  };
11931  Elements.push_back(Element);
11932  }
11933 
11934  if (!getDerived().AlwaysRebuild() && !ArgChanged)
11935  return SemaRef.MaybeBindToTemporary(E);
11936 
11937  return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
11938  Elements);
11939 }
11940 
11941 template<typename Derived>
11942 ExprResult
11944  TypeSourceInfo *EncodedTypeInfo
11945  = getDerived().TransformType(E->getEncodedTypeSourceInfo());
11946  if (!EncodedTypeInfo)
11947  return ExprError();
11948 
11949  if (!getDerived().AlwaysRebuild() &&
11950  EncodedTypeInfo == E->getEncodedTypeSourceInfo())
11951  return E;
11952 
11953  return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
11954  EncodedTypeInfo,
11955  E->getRParenLoc());
11956 }
11957 
11958 template<typename Derived>
11961  // This is a kind of implicit conversion, and it needs to get dropped
11962  // and recomputed for the same general reasons that ImplicitCastExprs
11963  // do, as well a more specific one: this expression is only valid when
11964  // it appears *immediately* as an argument expression.
11965  return getDerived().TransformExpr(E->getSubExpr());
11966 }
11967 
11968 template<typename Derived>
11971  TypeSourceInfo *TSInfo
11972  = getDerived().TransformType(E->getTypeInfoAsWritten());
11973  if (!TSInfo)
11974  return ExprError();
11975 
11976  ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
11977  if (Result.isInvalid())
11978  return ExprError();
11979 
11980  if (!getDerived().AlwaysRebuild() &&
11981  TSInfo == E->getTypeInfoAsWritten() &&
11982  Result.get() == E->getSubExpr())
11983  return E;
11984 
11985  return SemaRef.BuildObjCBridgedCast(E->getLParenLoc(), E->getBridgeKind(),
11986  E->getBridgeKeywordLoc(), TSInfo,
11987  Result.get());
11988 }
11989 
11990 template <typename Derived>
11993  return E;
11994 }
11995 
11996 template<typename Derived>
11997 ExprResult
11999  // Transform arguments.
12000  bool ArgChanged = false;
12001  SmallVector<Expr*, 8> Args;
12002  Args.reserve(E->getNumArgs());
12003  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
12004  &ArgChanged))
12005  return ExprError();
12006 
12008  // Class message: transform the receiver type.
12009  TypeSourceInfo *ReceiverTypeInfo
12010  = getDerived().TransformType(E->getClassReceiverTypeInfo());
12011  if (!ReceiverTypeInfo)
12012  return ExprError();
12013 
12014  // If nothing changed, just retain the existing message send.
12015  if (!getDerived().AlwaysRebuild() &&
12016  ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
12017  return SemaRef.MaybeBindToTemporary(E);
12018 
12019  // Build a new class message send.
12021  E->getSelectorLocs(SelLocs);
12022  return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
12023  E->getSelector(),
12024  SelLocs,
12025  E->getMethodDecl(),
12026  E->getLeftLoc(),
12027  Args,
12028  E->getRightLoc());
12029  }
12030  else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
12032  if (!E->getMethodDecl())
12033  return ExprError();
12034 
12035  // Build a new class message send to 'super'.
12037  E->getSelectorLocs(SelLocs);
12038  return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
12039  E->getSelector(),
12040  SelLocs,
12041  E->getReceiverType(),
12042  E->getMethodDecl(),
12043  E->getLeftLoc(),
12044  Args,
12045  E->getRightLoc());
12046  }
12047 
12048  // Instance message: transform the receiver
12049  assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
12050  "Only class and instance messages may be instantiated");
12051  ExprResult Receiver
12052  = getDerived().TransformExpr(E->getInstanceReceiver());
12053  if (Receiver.isInvalid())
12054  return ExprError();
12055 
12056  // If nothing changed, just retain the existing message send.
12057  if (!getDerived().AlwaysRebuild() &&
12058  Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
12059  return SemaRef.MaybeBindToTemporary(E);
12060 
12061  // Build a new instance message send.
12063  E->getSelectorLocs(SelLocs);
12064  return getDerived().RebuildObjCMessageExpr(Receiver.get(),
12065  E->getSelector(),
12066  SelLocs,
12067  E->getMethodDecl(),
12068  E->getLeftLoc(),
12069  Args,
12070  E->getRightLoc());
12071 }
12072 
12073 template<typename Derived>
12074 ExprResult
12076  return E;
12077 }
12078 
12079 template<typename Derived>
12080 ExprResult
12082  return E;
12083 }
12084 
12085 template<typename Derived>
12086 ExprResult
12088  // Transform the base expression.
12089  ExprResult Base = getDerived().TransformExpr(E->getBase());
12090  if (Base.isInvalid())
12091  return ExprError();
12092 
12093  // We don't need to transform the ivar; it will never change.
12094 
12095  // If nothing changed, just retain the existing expression.
12096  if (!getDerived().AlwaysRebuild() &&
12097  Base.get() == E->getBase())
12098  return E;
12099 
12100  return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
12101  E->getLocation(),
12102  E->isArrow(), E->isFreeIvar());
12103 }
12104 
12105 template<typename Derived>
12106 ExprResult
12108  // 'super' and types never change. Property never changes. Just
12109  // retain the existing expression.
12110  if (!E->isObjectReceiver())
12111  return E;
12112 
12113  // Transform the base expression.
12114  ExprResult Base = getDerived().TransformExpr(E->getBase());
12115  if (Base.isInvalid())
12116  return ExprError();
12117 
12118  // We don't need to transform the property; it will never change.
12119 
12120  // If nothing changed, just retain the existing expression.
12121  if (!getDerived().AlwaysRebuild() &&
12122  Base.get() == E->getBase())
12123  return E;
12124 
12125  if (E->isExplicitProperty())
12126  return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
12127  E->getExplicitProperty(),
12128  E->getLocation());
12129 
12130  return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
12131  SemaRef.Context.PseudoObjectTy,
12134  E->getLocation());
12135 }
12136 
12137 template<typename Derived>
12138 ExprResult
12140  // Transform the base expression.
12141  ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
12142  if (Base.isInvalid())
12143  return ExprError();
12144 
12145  // Transform the key expression.
12146  ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
12147  if (Key.isInvalid())
12148  return ExprError();
12149 
12150  // If nothing changed, just retain the existing expression.
12151  if (!getDerived().AlwaysRebuild() &&
12152  Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
12153  return E;
12154 
12155  return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
12156  Base.get(), Key.get(),
12157  E->getAtIndexMethodDecl(),
12158  E->setAtIndexMethodDecl());
12159 }
12160 
12161 template<typename Derived>
12162 ExprResult
12164  // Transform the base expression.
12165  ExprResult Base = getDerived().TransformExpr(E->getBase());
12166  if (Base.isInvalid())
12167  return ExprError();
12168 
12169  // If nothing changed, just retain the existing expression.
12170  if (!getDerived().AlwaysRebuild() &&
12171  Base.get() == E->getBase())
12172  return E;
12173 
12174  return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
12175  E->getOpLoc(),
12176  E->isArrow());
12177 }
12178 
12179 template<typename Derived>
12180 ExprResult
12182  bool ArgumentChanged = false;
12183  SmallVector<Expr*, 8> SubExprs;
12184  SubExprs.reserve(E->getNumSubExprs());
12185  if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
12186  SubExprs, &ArgumentChanged))
12187  return ExprError();
12188 
12189  if (!getDerived().AlwaysRebuild() &&
12190  !ArgumentChanged)
12191  return E;
12192 
12193  return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
12194  SubExprs,
12195  E->getRParenLoc());
12196 }
12197 
12198 template<typename Derived>
12199 ExprResult
12201  ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
12202  if (SrcExpr.isInvalid())
12203  return ExprError();
12204 
12205  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
12206  if (!Type)
12207  return ExprError();
12208 
12209  if (!getDerived().AlwaysRebuild() &&
12210  Type == E->getTypeSourceInfo() &&
12211  SrcExpr.get() == E->getSrcExpr())
12212  return E;
12213 
12214  return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
12215  SrcExpr.get(), Type,
12216  E->getRParenLoc());
12217 }
12218 
12219 template<typename Derived>
12220 ExprResult
12222  BlockDecl *oldBlock = E->getBlockDecl();
12223 
12224  SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
12225  BlockScopeInfo *blockScope = SemaRef.getCurBlock();
12226 
12227  blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
12228  blockScope->TheDecl->setBlockMissingReturnType(
12229  oldBlock->blockMissingReturnType());
12230 
12232  SmallVector<QualType, 4> paramTypes;
12233 
12234  const FunctionProtoType *exprFunctionType = E->getFunctionType();
12235 
12236  // Parameter substitution.
12237  Sema::ExtParameterInfoBuilder extParamInfos;
12238  if (getDerived().TransformFunctionTypeParams(
12239  E->getCaretLocation(), oldBlock->parameters(), nullptr,
12240  exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
12241  extParamInfos)) {
12242  getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
12243  return ExprError();
12244  }
12245 
12246  QualType exprResultType =
12247  getDerived().TransformType(exprFunctionType->getReturnType());
12248 
12249  auto epi = exprFunctionType->getExtProtoInfo();
12250  epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
12251 
12253  getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
12254  blockScope->FunctionType = functionType;
12255 
12256  // Set the parameters on the block decl.
12257  if (!params.empty())
12258  blockScope->TheDecl->setParams(params);
12259 
12260  if (!oldBlock->blockMissingReturnType()) {
12261  blockScope->HasImplicitReturnType = false;
12262  blockScope->ReturnType = exprResultType;
12263  }
12264 
12265  // Transform the body
12266  StmtResult body = getDerived().TransformStmt(E->getBody());
12267  if (body.isInvalid()) {
12268  getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
12269  return ExprError();
12270  }
12271 
12272 #ifndef NDEBUG
12273  // In builds with assertions, make sure that we captured everything we
12274  // captured before.
12275  if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
12276  for (const auto &I : oldBlock->captures()) {
12277  VarDecl *oldCapture = I.getVariable();
12278 
12279  // Ignore parameter packs.
12280  if (isa<ParmVarDecl>(oldCapture) &&
12281  cast<ParmVarDecl>(oldCapture)->isParameterPack())
12282  continue;
12283 
12284  VarDecl *newCapture =
12285  cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
12286  oldCapture));
12287  assert(blockScope->CaptureMap.count(newCapture));
12288  }
12289  assert(oldBlock->capturesCXXThis() == blockScope->isCXXThisCaptured());
12290  }
12291 #endif
12292 
12293  return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
12294  /*Scope=*/nullptr);
12295 }
12296 
12297 template<typename Derived>
12298 ExprResult
12300  llvm_unreachable("Cannot transform asType expressions yet");
12301 }
12302 
12303 template<typename Derived>
12304 ExprResult
12306  QualType RetTy = getDerived().TransformType(E->getType());
12307  bool ArgumentChanged = false;
12308  SmallVector<Expr*, 8> SubExprs;
12309  SubExprs.reserve(E->getNumSubExprs());
12310  if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
12311  SubExprs, &ArgumentChanged))
12312  return ExprError();
12313 
12314  if (!getDerived().AlwaysRebuild() &&
12315  !ArgumentChanged)
12316  return E;
12317 
12318  return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
12319  RetTy, E->getOp(), E->getRParenLoc());
12320 }
12321 
12322 //===----------------------------------------------------------------------===//
12323 // Type reconstruction
12324 //===----------------------------------------------------------------------===//
12325 
12326 template<typename Derived>
12328  SourceLocation Star) {
12329  return SemaRef.BuildPointerType(PointeeType, Star,
12330  getDerived().getBaseEntity());
12331 }
12332 
12333 template<typename Derived>
12335  SourceLocation Star) {
12336  return SemaRef.BuildBlockPointerType(PointeeType, Star,
12337  getDerived().getBaseEntity());
12338 }
12339 
12340 template<typename Derived>
12341 QualType
12343  bool WrittenAsLValue,
12344  SourceLocation Sigil) {
12345  return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
12346  Sigil, getDerived().getBaseEntity());
12347 }
12348 
12349 template<typename Derived>
12350 QualType
12352  QualType ClassType,
12353  SourceLocation Sigil) {
12354  return SemaRef.BuildMemberPointerType(PointeeType, ClassType, Sigil,
12355  getDerived().getBaseEntity());
12356 }
12357 
12358 template<typename Derived>
12360  const ObjCTypeParamDecl *Decl,
12361  SourceLocation ProtocolLAngleLoc,
12362  ArrayRef<ObjCProtocolDecl *> Protocols,
12363  ArrayRef<SourceLocation> ProtocolLocs,
12364  SourceLocation ProtocolRAngleLoc) {
12365  return SemaRef.BuildObjCTypeParamType(Decl,
12366  ProtocolLAngleLoc, Protocols,
12367  ProtocolLocs, ProtocolRAngleLoc,
12368  /*FailOnError=*/true);
12369 }
12370 
12371 template<typename Derived>
12373  QualType BaseType,
12374  SourceLocation Loc,
12375  SourceLocation TypeArgsLAngleLoc,
12376  ArrayRef<TypeSourceInfo *> TypeArgs,
12377  SourceLocation TypeArgsRAngleLoc,
12378  SourceLocation ProtocolLAngleLoc,
12379  ArrayRef<ObjCProtocolDecl *> Protocols,
12380  ArrayRef<SourceLocation> ProtocolLocs,
12381  SourceLocation ProtocolRAngleLoc) {
12382  return SemaRef.BuildObjCObjectType(BaseType, Loc, TypeArgsLAngleLoc,
12383  TypeArgs, TypeArgsRAngleLoc,
12384  ProtocolLAngleLoc, Protocols, ProtocolLocs,
12385  ProtocolRAngleLoc,
12386  /*FailOnError=*/true);
12387 }
12388 
12389 template<typename Derived>
12391  QualType PointeeType,
12392  SourceLocation Star) {
12393  return SemaRef.Context.getObjCObjectPointerType(PointeeType);
12394 }
12395 
12396 template<typename Derived>
12397 QualType
12400  const llvm::APInt *Size,
12401  Expr *SizeExpr,
12402  unsigned IndexTypeQuals,
12403  SourceRange BracketsRange) {
12404  if (SizeExpr || !Size)
12405  return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
12406  IndexTypeQuals, BracketsRange,
12407  getDerived().getBaseEntity());
12408 
12409  QualType Types[] = {
12410  SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
12411  SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
12412  SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
12413  };
12414  const unsigned NumTypes = llvm::array_lengthof(Types);
12415  QualType SizeType;
12416  for (unsigned I = 0; I != NumTypes; ++I)
12417  if (Size->getBitWidth() == SemaRef.Context.getIntWidth(Types[I])) {
12418  SizeType = Types[I];
12419  break;
12420  }
12421 
12422  // Note that we can return a VariableArrayType here in the case where
12423  // the element type was a dependent VariableArrayType.
12424  IntegerLiteral *ArraySize
12425  = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
12426  /*FIXME*/BracketsRange.getBegin());
12427  return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
12428  IndexTypeQuals, BracketsRange,
12429  getDerived().getBaseEntity());
12430 }
12431 
12432 template<typename Derived>
12433 QualType
12436  const llvm::APInt &Size,
12437  unsigned IndexTypeQuals,
12438  SourceRange BracketsRange) {
12439  return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, nullptr,
12440  IndexTypeQuals, BracketsRange);
12441 }
12442 
12443 template<typename Derived>
12444 QualType
12447  unsigned IndexTypeQuals,
12448  SourceRange BracketsRange) {
12449  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
12450  IndexTypeQuals, BracketsRange);
12451 }
12452 
12453 template<typename Derived>
12454 QualType
12457  Expr *SizeExpr,
12458  unsigned IndexTypeQuals,
12459  SourceRange BracketsRange) {
12460  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
12461  SizeExpr,
12462  IndexTypeQuals, BracketsRange);
12463 }
12464 
12465 template<typename Derived>
12466 QualType
12469  Expr *SizeExpr,
12470  unsigned IndexTypeQuals,
12471  SourceRange BracketsRange) {
12472  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
12473  SizeExpr,
12474  IndexTypeQuals, BracketsRange);
12475 }
12476 
12477 template <typename Derived>
12479  QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
12480  return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
12481  AttributeLoc);
12482 }
12483 
12484 template <typename Derived>
12485 QualType
12487  unsigned NumElements,
12488  VectorType::VectorKind VecKind) {
12489  // FIXME: semantic checking!
12490  return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
12491 }
12492 
12493 template <typename Derived>
12495  QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
12496  VectorType::VectorKind VecKind) {
12497  return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
12498 }
12499 
12500 template<typename Derived>
12502  unsigned NumElements,
12503  SourceLocation AttributeLoc) {
12504  llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
12505  NumElements, true);
12506  IntegerLiteral *VectorSize
12507  = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
12508  AttributeLoc);
12509  return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
12510 }
12511 
12512 template<typename Derived>
12513 QualType
12515  Expr *SizeExpr,
12516  SourceLocation AttributeLoc) {
12517  return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
12518 }
12519 
12520 template<typename Derived>
12522  QualType T,
12523  MutableArrayRef<QualType> ParamTypes,
12524  const FunctionProtoType::ExtProtoInfo &EPI) {
12525  return SemaRef.BuildFunctionType(T, ParamTypes,
12526  getDerived().getBaseLocation(),
12527  getDerived().getBaseEntity(),
12528  EPI);
12529 }
12530 
12531 template<typename Derived>
12533  return SemaRef.Context.getFunctionNoProtoType(T);
12534 }
12535 
12536 template<typename Derived>
12538  Decl *D) {
12539  assert(D && "no decl found");
12540  if (D->isInvalidDecl()) return QualType();
12541 
12542  // FIXME: Doesn't account for ObjCInterfaceDecl!
12543  TypeDecl *Ty;
12544  if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
12545  // A valid resolved using typename pack expansion decl can have multiple
12546  // UsingDecls, but they must each have exactly one type, and it must be
12547  // the same type in every case. But we must have at least one expansion!
12548  if (UPD->expansions().empty()) {
12549  getSema().Diag(Loc, diag::err_using_pack_expansion_empty)
12550  << UPD->isCXXClassMember() << UPD;
12551  return QualType();
12552  }
12553 
12554  // We might still have some unresolved types. Try to pick a resolved type
12555  // if we can. The final instantiation will check that the remaining
12556  // unresolved types instantiate to the type we pick.
12557  QualType FallbackT;
12558  QualType T;
12559  for (auto *E : UPD->expansions()) {
12560  QualType ThisT = RebuildUnresolvedUsingType(Loc, E);
12561  if (ThisT.isNull())
12562  continue;
12563  else if (ThisT->getAs<UnresolvedUsingType>())
12564  FallbackT = ThisT;
12565  else if (T.isNull())
12566  T = ThisT;
12567  else
12568  assert(getSema().Context.hasSameType(ThisT, T) &&
12569  "mismatched resolved types in using pack expansion");
12570  }
12571  return T.isNull() ? FallbackT : T;
12572  } else if (auto *Using = dyn_cast<UsingDecl>(D)) {
12573  assert(Using->hasTypename() &&
12574  "UnresolvedUsingTypenameDecl transformed to non-typename using");
12575 
12576  // A valid resolved using typename decl points to exactly one type decl.
12577  assert(++Using->shadow_begin() == Using->shadow_end());
12578  Ty = cast<TypeDecl>((*Using->shadow_begin())->getTargetDecl());
12579  } else {
12580  assert(isa<UnresolvedUsingTypenameDecl>(D) &&
12581  "UnresolvedUsingTypenameDecl transformed to non-using decl");
12582  Ty = cast<UnresolvedUsingTypenameDecl>(D);
12583  }
12584 
12585  return SemaRef.Context.getTypeDeclType(Ty);
12586 }
12587 
12588 template<typename Derived>
12590  SourceLocation Loc) {
12591  return SemaRef.BuildTypeofExprType(E, Loc);
12592 }
12593 
12594 template<typename Derived>
12596  return SemaRef.Context.getTypeOfType(Underlying);
12597 }
12598 
12599 template<typename Derived>
12601  SourceLocation Loc) {
12602  return SemaRef.BuildDecltypeType(E, Loc);
12603 }
12604 
12605 template<typename Derived>
12608  SourceLocation Loc) {
12609  return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
12610 }
12611 
12612 template<typename Derived>
12614  TemplateName Template,
12615  SourceLocation TemplateNameLoc,
12616  TemplateArgumentListInfo &TemplateArgs) {
12617  return SemaRef.CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
12618 }
12619 
12620 template<typename Derived>
12622  SourceLocation KWLoc) {
12623  return SemaRef.BuildAtomicType(ValueType, KWLoc);
12624 }
12625 
12626 template<typename Derived>
12628  SourceLocation KWLoc,
12629  bool isReadPipe) {
12630  return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
12631  : SemaRef.BuildWritePipeType(ValueType, KWLoc);
12632 }
12633 
12634 template<typename Derived>
12637  bool TemplateKW,
12638  TemplateDecl *Template) {
12639  return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
12640  Template);
12641 }
12642 
12643 template<typename Derived>
12646  SourceLocation TemplateKWLoc,
12647  const IdentifierInfo &Name,
12648  SourceLocation NameLoc,
12649  QualType ObjectType,
12650  NamedDecl *FirstQualifierInScope,
12651  bool AllowInjectedClassName) {
12653  TemplateName.setIdentifier(&Name, NameLoc);
12654  Sema::TemplateTy Template;
12655  getSema().ActOnDependentTemplateName(/*Scope=*/nullptr,
12656  SS, TemplateKWLoc, TemplateName,
12657  ParsedType::make(ObjectType),
12658  /*EnteringContext=*/false,
12659  Template, AllowInjectedClassName);
12660  return Template.get();
12661 }
12662 
12663 template<typename Derived>
12666  SourceLocation TemplateKWLoc,
12667  OverloadedOperatorKind Operator,
12668  SourceLocation NameLoc,
12669  QualType ObjectType,
12670  bool AllowInjectedClassName) {
12671  UnqualifiedId Name;
12672  // FIXME: Bogus location information.
12673  SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
12674  Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
12675  Sema::TemplateTy Template;
12676  getSema().ActOnDependentTemplateName(/*Scope=*/nullptr,
12677  SS, TemplateKWLoc, Name,
12678  ParsedType::make(ObjectType),
12679  /*EnteringContext=*/false,
12680  Template, AllowInjectedClassName);
12681  return Template.get();
12682 }
12683 
12684 template<typename Derived>
12685 ExprResult
12687  SourceLocation OpLoc,
12688  Expr *OrigCallee,
12689  Expr *First,
12690  Expr *Second) {
12691  Expr *Callee = OrigCallee->IgnoreParenCasts();
12692  bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
12693 
12694  if (First->getObjectKind() == OK_ObjCProperty) {
12697  return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc, Opc,
12698  First, Second);
12699  ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
12700  if (Result.isInvalid())
12701  return ExprError();
12702  First = Result.get();
12703  }
12704 
12705  if (Second && Second->getObjectKind() == OK_ObjCProperty) {
12706  ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
12707  if (Result.isInvalid())
12708  return ExprError();
12709  Second = Result.get();
12710  }
12711 
12712  // Determine whether this should be a builtin operation.
12713  if (Op == OO_Subscript) {
12714  if (!First->getType()->isOverloadableType() &&
12715  !Second->getType()->isOverloadableType())
12716  return getSema().CreateBuiltinArraySubscriptExpr(
12717  First, Callee->getBeginLoc(), Second, OpLoc);
12718  } else if (Op == OO_Arrow) {
12719  // -> is never a builtin operation.
12720  return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
12721  } else if (Second == nullptr || isPostIncDec) {
12722  if (!First->getType()->isOverloadableType() ||
12723  (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
12724  // The argument is not of overloadable type, or this is an expression
12725  // of the form &Class::member, so try to create a built-in unary
12726  // operation.
12727  UnaryOperatorKind Opc
12728  = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
12729 
12730  return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
12731  }
12732  } else {
12733  if (!First->getType()->isOverloadableType() &&
12734  !Second->getType()->isOverloadableType()) {
12735  // Neither of the arguments is an overloadable type, so try to
12736  // create a built-in binary operation.
12738  ExprResult Result
12739  = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
12740  if (Result.isInvalid())
12741  return ExprError();
12742 
12743  return Result;
12744  }
12745  }
12746 
12747  // Compute the transformed set of functions (and function templates) to be
12748  // used during overload resolution.
12749  UnresolvedSet<16> Functions;
12750  bool RequiresADL;
12751 
12752  if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
12753  Functions.append(ULE->decls_begin(), ULE->decls_end());
12754  // If the overload could not be resolved in the template definition
12755  // (because we had a dependent argument), ADL is performed as part of
12756  // template instantiation.
12757  RequiresADL = ULE->requiresADL();
12758  } else {
12759  // If we've resolved this to a particular non-member function, just call
12760  // that function. If we resolved it to a member function,
12761  // CreateOverloaded* will find that function for us.
12762  NamedDecl *ND = cast<DeclRefExpr>(Callee)->getDecl();
12763  if (!isa<CXXMethodDecl>(ND))
12764  Functions.addDecl(ND);
12765  RequiresADL = false;
12766  }
12767 
12768  // Add any functions found via argument-dependent lookup.
12769  Expr *Args[2] = { First, Second };
12770  unsigned NumArgs = 1 + (Second != nullptr);
12771 
12772  // Create the overloaded operator invocation for unary operators.
12773  if (NumArgs == 1 || isPostIncDec) {
12774  UnaryOperatorKind Opc
12775  = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
12776  return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
12777  RequiresADL);
12778  }
12779 
12780  if (Op == OO_Subscript) {
12781  SourceLocation LBrace;
12782  SourceLocation RBrace;
12783 
12784  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Callee)) {
12785  DeclarationNameLoc NameLoc = DRE->getNameInfo().getInfo();
12789  NameLoc.CXXOperatorName.EndOpNameLoc);
12790  } else {
12791  LBrace = Callee->getBeginLoc();
12792  RBrace = OpLoc;
12793  }
12794 
12795  return SemaRef.CreateOverloadedArraySubscriptExpr(LBrace, RBrace,
12796  First, Second);
12797  }
12798 
12799  // Create the overloaded operator invocation for binary operators.
12801  ExprResult Result = SemaRef.CreateOverloadedBinOp(
12802  OpLoc, Opc, Functions, Args[0], Args[1], RequiresADL);
12803  if (Result.isInvalid())
12804  return ExprError();
12805 
12806  return Result;
12807 }
12808 
12809 template<typename Derived>
12810 ExprResult
12812  SourceLocation OperatorLoc,
12813  bool isArrow,
12814  CXXScopeSpec &SS,
12815  TypeSourceInfo *ScopeType,
12816  SourceLocation CCLoc,
12817  SourceLocation TildeLoc,
12818  PseudoDestructorTypeStorage Destroyed) {
12819  QualType BaseType = Base->getType();
12820  if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
12821  (!isArrow && !BaseType->getAs<RecordType>()) ||
12822  (isArrow && BaseType->getAs<PointerType>() &&
12823  !BaseType->getAs<PointerType>()->getPointeeType()
12824  ->template getAs<RecordType>())){
12825  // This pseudo-destructor expression is still a pseudo-destructor.
12826  return SemaRef.BuildPseudoDestructorExpr(
12827  Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
12828  CCLoc, TildeLoc, Destroyed);
12829  }
12830 
12831  TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
12832  DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
12833  SemaRef.Context.getCanonicalType(DestroyedType->getType())));
12834  DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
12835  NameInfo.setNamedTypeInfo(DestroyedType);
12836 
12837  // The scope type is now known to be a valid nested name specifier
12838  // component. Tack it on to the end of the nested name specifier.
12839  if (ScopeType) {
12840  if (!ScopeType->getType()->getAs<TagType>()) {
12841  getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
12842  diag::err_expected_class_or_namespace)
12843  << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
12844  return ExprError();
12845  }
12846  SS.Extend(SemaRef.Context, SourceLocation(), ScopeType->getTypeLoc(),
12847  CCLoc);
12848  }
12849 
12850  SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
12851  return getSema().BuildMemberReferenceExpr(Base, BaseType,
12852  OperatorLoc, isArrow,
12853  SS, TemplateKWLoc,
12854  /*FIXME: FirstQualifier*/ nullptr,
12855  NameInfo,
12856  /*TemplateArgs*/ nullptr,
12857  /*S*/nullptr);
12858 }
12859 
12860 template<typename Derived>
12861 StmtResult
12863  SourceLocation Loc = S->getBeginLoc();
12864  CapturedDecl *CD = S->getCapturedDecl();
12865  unsigned NumParams = CD->getNumParams();
12866  unsigned ContextParamPos = CD->getContextParamPosition();
12868  for (unsigned I = 0; I < NumParams; ++I) {
12869  if (I != ContextParamPos) {
12870  Params.push_back(
12871  std::make_pair(
12872  CD->getParam(I)->getName(),
12873  getDerived().TransformType(CD->getParam(I)->getType())));
12874  } else {
12875  Params.push_back(std::make_pair(StringRef(), QualType()));
12876  }
12877  }
12878  getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
12879  S->getCapturedRegionKind(), Params);
12880  StmtResult Body;
12881  {
12882  Sema::CompoundScopeRAII CompoundScope(getSema());
12883  Body = getDerived().TransformStmt(S->getCapturedStmt());
12884  }
12885 
12886  if (Body.isInvalid()) {
12887  getSema().ActOnCapturedRegionError();
12888  return StmtError();
12889  }
12890 
12891  return getSema().ActOnCapturedRegionEnd(Body.get());
12892 }
12893 
12894 } // end namespace clang
12895 
12896 #endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
SourceLocation getRParenLoc() const
Definition: Stmt.h:2218
Expr * getInc()
Definition: Stmt.h:2270
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:577
const Expr * getSubExpr() const
Definition: Expr.h:890
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1518
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:78
TemporaryBase(TreeTransform &Self, SourceLocation Location, DeclarationName Entity)
The receiver is the instance of the superclass object.
Definition: ExprObjC.h:1061
Represents a single C99 designator.
Definition: Expr.h:4494
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:1215
SourceLocation getRBracLoc() const
Definition: Stmt.h:1334
const BlockDecl * getBlockDecl() const
Definition: Expr.h:5191
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3248
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:4735
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field)
Field is the non-static data member whose default initializer is used by this expression.
Definition: ExprCXX.h:1152
IdentifierInfo * getInputIdentifier(unsigned i) const
Definition: Stmt.h:2789
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1431
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:5129
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1583
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2208
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:923
SourceLocation getRParenLoc() const
Definition: Stmt.h:2696
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:596
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:2768
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:994
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:1174
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1771
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:2675
Represents a function declaration or definition.
Definition: Decl.h:1738
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4455
Expr * getArrayIndex(const Designator &D) const
Definition: Expr.cpp:3962
SourceLocation getForLoc() const
Definition: StmtCXX.h:194
SourceRange getExceptionSpecRange() const
Definition: TypeLoc.h:1382
Stmt * body_back()
Definition: Stmt.h:1279
helper_expr_const_range reduction_ops() const
Name lookup found a set of overloaded functions that met the criteria.
Definition: Lookup.h:64
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:227
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:2543
The receiver is an object instance.
Definition: ExprObjC.h:1055
Expr * getLHS() const
Definition: Expr.h:3627
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:2786
unsigned getNumInputs() const
Definition: Stmt.h:2591
Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var, Expr *Expr, Sema::ConditionKind Kind)
Transform the specified condition.
SourceLocation getOpLoc() const
Definition: ExprObjC.h:1473
SourceLocation getRParenLoc() const
Definition: Expr.h:2635
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:344
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: Expr.h:1207
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
Definition: Expr.cpp:2131
CompoundStmt * getBlock() const
Definition: Stmt.h:3010
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:2283
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; directives.
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:496
PtrTy get() const
Definition: Ownership.h:81
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2537
StmtResult RebuildCaseStmt(SourceLocation CaseLoc, Expr *LHS, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation ColonLoc)
Build a new case statement.
QualType getPointeeType() const
Definition: Type.h:2550
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:107
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
Definition: ExprCXX.h:1110
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
Definition: Type.h:4121
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2235
A (possibly-)qualified type.
Definition: Type.h:638
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:5395
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:1171
ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(type) expression.
QualType RebuildDependentSizedArrayType(QualType ElementType, ArrayType::ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new dependent-sized array type given the element type, size modifier, size 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:2773
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1278
Derived & getDerived()
Retrieves a reference to the derived class.
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:260
Expr * getCond() const
Definition: Expr.h:4022
QualType TransformType(QualType T)
Transforms the given type into another type.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2553
ObjCMethodDecl * getAtIndexMethodDecl() const
Definition: ExprObjC.h:854
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:3801
Selector getSelector() const
Definition: ExprObjC.cpp:312
QualType RebuildTemplateSpecializationType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &Args)
Build a new template specialization type.
SourceRange getSourceRange() const
Definition: ExprCXX.h:3743
SourceLocation getEllipsisLoc() const
Get the location of the ... in a case statement of the form LHS ... RHS.
Definition: Stmt.h:1469
SourceLocation getLParen() const
Get the location of the left parentheses &#39;(&#39;.
Definition: Expr.h:1868
const Expr * getSubExpr() const
Definition: ExprCXX.h:1037
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition: ExprCXX.cpp:1162
SourceLocation getCommaLoc()
Get location of &#39;,&#39;.
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:403
Expr * getCond()
Definition: Stmt.h:2112
TemplateParameterList * GLTemplateParameterList
If this is a generic lambda, and the template parameter list has been created (from the AutoTemplateP...
Definition: ScopeInfo.h:830
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
Definition: Expr.h:3880
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:2430
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
Definition: Sema.h:3055
CompoundStmt * getSubStmt()
Definition: Expr.h:3817
This represents &#39;atomic_default_mem_order&#39; clause in the &#39;#pragma omp requires&#39; directive.
Definition: OpenMPClause.h:870
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:3223
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2271
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:532
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:2880
Expr * getUnderlyingExpr() const
Definition: Type.h:4256
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:2272
static ConditionResult ConditionError()
Definition: Sema.h:9919
const TemplateArgumentLoc * operator->() const
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1374
SourceLocation getRParenLoc() const
Definition: StmtObjC.h:104
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
Definition: ExprCXX.h:1851
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:1047
OMPClause * RebuildOMPLastprivateClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;lastprivate&#39; clause.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition: Type.h:1370
bool isLeftFold() const
Does this produce a left-associated sequence of operators?
Definition: ExprCXX.h:4300
Represents a &#39;co_return&#39; statement in the C++ Coroutines TS.
Definition: StmtCXX.h:435
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:2540
This represents clause &#39;in_reduction&#39; in the &#39;#pragma omp task&#39; directives.
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2561
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
Definition: StmtObjC.h:224
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1568
void setExceptionSpecRange(SourceRange R)
Definition: TypeLoc.h:1388
ExprResult RebuildExpressionTrait(ExpressionTrait Trait, SourceLocation StartLoc, Expr *Queried, SourceLocation RParenLoc)
Build a new expression trait expression.
CXXCatchStmt * getHandler(unsigned i)
Definition: StmtCXX.h:104
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:1687
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:3012
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition: Expr.h:2152
SourceLocation getRParenLoc() const
Definition: Expr.h:3867
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:505
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3040
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2267
ObjCMethodDecl * setAtIndexMethodDecl() const
Definition: ExprObjC.h:858
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:650
QualType RebuildEnumType(EnumDecl *Enum)
Build a new Enum type.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1020
unsigned getNumOutputs() const
Definition: Stmt.h:2569
Microsoft&#39;s &#39;__super&#39; specifier, stored as a CXXRecordDecl* of the class it appeared in...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Definition: Decl.h:2094
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:5212
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:737
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1181
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:532
The template argument is an expression, and we&#39;ve not resolved it to one of the other forms yet...
Definition: TemplateBase.h:87
bool isRecordType() const
Definition: Type.h:6369
Expr * getBase() const
Definition: Expr.h:2767
const StringLiteral * getAsmString() const
Definition: Stmt.h:2701
OMPClause * RebuildOMPMapClause(ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;map&#39; clause.
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:2961
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition: Sema.h:1308
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:87
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:3659
Stmt * getHandlerBlock() const
Definition: StmtCXX.h:52
SourceLocation getBeginLoc() const
Returns starting location of directive kind.
Definition: StmtOpenMP.h:168
ObjCMethodDecl * getImplicitPropertySetter() const
Definition: ExprObjC.h:680
Decl * TransformDefinition(SourceLocation Loc, Decl *D)
Transform the definition of the given declaration.
OMPClause * RebuildOMPUseDevicePtrClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;use_device_ptr&#39; clause.
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:4858
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:2033
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition: TypeLoc.h:569
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2828
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:240
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
const Expr * getSubExpr() const
Definition: Expr.h:4109
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we&#39;re testing for, along with location information.
Definition: StmtCXX.h:277
Defines the C++ template declaration subclasses.
Opcode getOpcode() const
Definition: Expr.h:3322
StringRef P
CapturedStmt * getInnermostCapturedStmt()
Get innermost captured statement for the construct.
Definition: StmtOpenMP.h:226
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:4749
SourceLocation getIdentLoc() const
Definition: Stmt.h:1607
Represents an attribute applied to a statement.
Definition: Stmt.h:1633
QualType RebuildUnaryTransformType(QualType BaseType, UnaryTransformType::UTTKind UKind, SourceLocation Loc)
Build a new unary transform type.
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1844
const AstTypeMatcher< FunctionType > functionType
Matches FunctionType nodes.
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
Definition: Expr.h:2787
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
Definition: StmtCXX.h:273
ExprResult TransformInitializer(Expr *Init, bool NotCopyInit)
Transform the given initializer.
Expr * getLowerBound()
Get lower bound of array section.
Definition: ExprOpenMP.h:91
This represents &#39;priority&#39; clause in the &#39;#pragma omp ...&#39; directive.
The base class of the type hierarchy.
Definition: Type.h:1407
This represents &#39;#pragma omp target teams distribute&#39; combined directive.
Definition: StmtOpenMP.h:3796
Represents Objective-C&#39;s @throw statement.
Definition: StmtObjC.h:313
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called...
Definition: ExprCXX.h:1373
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
Definition: Decl.cpp:4265
const IdentifierInfo * getField() const
Definition: Designator.h:74
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
Definition: Expr.h:1195
QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc)
Build a new typeof(expr) type.
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2091
QualType RebuildConstantArrayType(QualType ElementType, ArrayType::ArraySizeModifier SizeMod, const llvm::APInt &Size, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new constant array type given the element type, size modifier, (known) size of the array...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2812
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Definition: TemplateBase.h:64
Represent a C++ namespace.
Definition: Decl.h:515
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:4486
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1262
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:1169
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:803
Wrapper for source info for typedefs.
Definition: TypeLoc.h:664
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition: Expr.h:395
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to...
Definition: Expr.h:3208
FPOptions getFPFeatures() const
Definition: Expr.h:3461
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2514
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1138
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:414
bool getIsCXXTry() const
Definition: Stmt.h:3048
SourceLocation getLParenLoc() const
Definition: Expr.h:3250
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:365
std::input_iterator_tag iterator_category
A container of type source information.
Definition: Decl.h:87
This represents &#39;update&#39; clause in the &#39;#pragma omp atomic&#39; directive.
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4311
Wrapper for void* pointer.
Definition: Ownership.h:51
QualType TransformTemplateSpecializationType(TypeLocBuilder &TLB, TemplateSpecializationTypeLoc TL, TemplateName Template)
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:308
SourceLocation getAttributeLoc() const
Definition: Type.h:3260
This represents &#39;#pragma omp parallel for&#39; directive.
Definition: StmtOpenMP.h:1552
MS property subscript expression.
Definition: ExprCXX.h:828
IdentKind getIdentKind() const
Definition: Expr.h:1806
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:2493
SourceLocation getGotoLoc() const
Definition: Stmt.h:2355
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:3906
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1895
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:3864
Wrapper for source info for pointers decayed from arrays and functions.
Definition: TypeLoc.h:1163
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:26
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:2484
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
Definition: Lookup.h:543
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4156
SourceLocation getAccessorLoc() const
Definition: Expr.h:5141
ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, SourceLocation OpLoc, Expr *Callee, Expr *First, Expr *Second)
Build a new overloaded operator call expression.
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:3952
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:227
SourceLocation getSecondScheduleModifierLoc() const
Get the second modifier location.
QualType getElementType() const
Definition: Type.h:2847
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
Definition: Type.h:4803
QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements, SourceLocation AttributeLoc)
Build a new extended vector type given the element type and number of elements.
SourceLocation getCoawaitLoc() const
Definition: StmtCXX.h:195
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:2180
Stmt * getExceptionHandler() const
Definition: StmtCXX.h:381
SourceLocation getEndLoc() const
Returns ending location of directive.
Definition: StmtOpenMP.h:170
DeclarationNameInfo TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
Transform the given declaration name.
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1792
Expr * getDeallocate() const
Definition: StmtCXX.h:391
An identifier, stored as an IdentifierInfo*.
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2463
Stmt * getSubStmt()
Definition: Stmt.h:1555
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: DeclSpec.cpp:125
SourceLocation getDependencyLoc() const
Get dependency type location.
void setRAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:575
This represents &#39;read&#39; clause in the &#39;#pragma omp atomic&#39; directive.
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2550
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:508
RAII object that enters a new expression evaluation context.
Definition: Sema.h:10853
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:813
ActionResult< Stmt * > StmtResult
Definition: Ownership.h:268
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:2285
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:1437
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1765
void removeObjCLifetime()
Definition: Type.h:332
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:2925
This represents &#39;num_threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:382
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1232
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. ...
ParmVarDecl * TransformFunctionTypeParam(ParmVarDecl *OldParm, int indexAdjustment, Optional< unsigned > NumExpansions, bool ExpectParameterPack)
Transforms a single function-type parameter.
bool isEnumeralType() const
Definition: Type.h:6373
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;.&#39; or &#39;->&#39; operator.
Definition: ExprCXX.h:2352
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Definition: TypeLoc.h:271
IdentifierInfo * getIdentifier() const
Definition: ExprCXX.h:2255
UnresolvedLookupExpr * getOperatorCoawaitLookup() const
Definition: ExprCXX.h:4482
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6748
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition: Type.h:6670
varlist_range varlists()
Definition: OpenMPClause.h:207
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:4907
Records and restores the FP_CONTRACT state on entry/exit of compound statements.
Definition: Sema.h:1209
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:2479
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:57
Extra information about a function prototype.
Definition: Type.h:3767
This represents &#39;defaultmap&#39; clause in the &#39;#pragma omp ...&#39; directive.
Stmt * getResultDecl() const
Definition: StmtCXX.h:397
ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1205
Represents a C++17 deduced template specialization type.
Definition: Type.h:4785
TypeSourceInfo * InventTypeSourceInfo(QualType T)
Fakes up a TypeSourceInfo for a type.
SourceLocation getColonLoc() const
Definition: Expr.h:3572
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:1465
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
SourceLocation getLeftLoc() const
Definition: ExprObjC.h:1363
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:999
RAII object used to temporarily allow the C++ &#39;this&#39; expression to be used, with the given qualifiers...
Definition: Sema.h:5116
A namespace, stored as a NamespaceDecl*.
SourceLocation getColonLoc() const
Return the location of &#39;:&#39;.
Definition: OpenMPClause.h:305
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:2744
reference front() const
Definition: DeclBase.h:1234
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:624
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:1972
bool isInvalidDecl() const
Definition: DeclBase.h:542
Stmt * getThen()
Definition: Stmt.h:1774
SourceLocation getIfLoc() const
Definition: Stmt.h:1846
void transformedLocalDecl(Decl *Old, Decl *New)
Note that a local declaration has been transformed by this transformer.
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1690
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:782
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:68
unsigned getContextParamPosition() const
Definition: Decl.h:4118
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:2051
TypeSourceInfo * getArgumentTypeInfo() const
Definition: Expr.h:2262
ExprResult RebuildAtomicExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, QualType RetTy, AtomicExpr::AtomicOp Op, SourceLocation RParenLoc)
Build a new atomic operation expression.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition: ExprCXX.h:2896
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:2098
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
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:1483
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1015
Expr * getExprOperand() const
Definition: ExprCXX.h:726
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3089
This represents &#39;reverse_offload&#39; clause in the &#39;#pragma omp requires&#39; directive. ...
Definition: OpenMPClause.h:807
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:2482
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:1676
Represents a parameter to a function.
Definition: Decl.h:1550
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:147
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4603
TemplateArgumentLocContainerIterator operator++(int)
SourceLocation getRParenLoc() const
Definition: Expr.h:5041
Defines the clang::Expr interface and subclasses for C++ expressions.
bool isUnset() const
Definition: Ownership.h:172
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:1952
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:507
The collection of all-type qualifiers we support.
Definition: Type.h:141
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1500
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1196
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition: TypeLoc.h:958
SourceLocation getBuiltinLoc() const
Definition: Expr.h:4029
This represents &#39;safelen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:447
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:670
PipeType - OpenCL20.
Definition: Type.h:6002
bool needsExtraLocalData() const
Definition: TypeLoc.h:576
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:326
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:720
ExprResult RebuildCXXNoexceptExpr(SourceRange Range, Expr *Arg)
Build a new noexcept expression.
Expr * getExprOperand() const
Definition: ExprCXX.h:933
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:3709
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:947
const Stmt * getSubStmt() const
Definition: StmtObjC.h:356
SourceLocation getAttributeLoc() const
Definition: Type.h:3145
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:270
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:57
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition: ExprCXX.h:303
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:1593
Represents a struct/union/class.
Definition: Decl.h:3593
A semantic tree transformation that allows one to transform one abstract syntax tree into another...
Definition: TreeTransform.h:96
Represents a C99 designated initializer expression.
Definition: Expr.h:4419
unsigned varlist_size() const
Definition: OpenMPClause.h:204
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:298
TypeSourceInfo * getEncodedTypeSourceInfo() const
Definition: ExprObjC.h:409
ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, ValueDecl *VD, const DeclarationNameInfo &NameInfo, TemplateArgumentListInfo *TemplateArgs)
Build a new expression that references a declaration.
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2363
SourceLocation getKeywordLoc() const
Definition: StmtCXX.h:455
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:2210
StmtResult TransformStmt(Stmt *S, bool DiscardedValue=false)
Transform the given statement.
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:4197
void setLocalRangeEnd(SourceLocation L)
Definition: TypeLoc.h:1358
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
Definition: Lookup.h:74
SourceLocation getTildeLoc() const
Retrieve the location of the &#39;~&#39;.
Definition: ExprCXX.h:2370
SourceLocation getRParenLoc() const
Definition: Expr.h:5524
Step
Definition: OpenMPClause.h:152
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:239
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:276
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3846
SourceLocation getColonLoc() const
Gets location of &#39;:&#39; symbol in clause.
bool TransformFunctionTypeParams(SourceLocation Loc, ArrayRef< ParmVarDecl *> Params, const QualType *ParamTypes, const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl *> *PVars, Sema::ExtParameterInfoBuilder &PInfos)
Transforms the parameters of a function type into the given vectors.
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:5538
SourceLocation getRParen() const
Get the location of the right parentheses &#39;)&#39;.
Definition: Expr.h:1872
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:330
A C++ nested-name-specifier augmented with source location information.
Expr * getInit() const
Retrieve the initializer value.
Definition: Expr.h:4653
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:423
ExprResult ExprEmpty()
Definition: Ownership.h:289
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3895
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1187
QualType RebuildDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc)
Build a new DependentAddressSpaceType or return the pointee type variable with the correct address sp...
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:3941
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:507
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1118
QualType BuildParenType(QualType T)
Build a paren type including T.
Definition: SemaType.cpp:1819
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:72
void setBuiltinLoc(SourceLocation Loc)
Definition: TypeLoc.h:553
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:1584
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:1841
bool isExplicitProperty() const
Definition: ExprObjC.h:668
bool isSpelledAsLValue() const
Definition: Type.h:2689
SourceLocation getAmpAmpLoc() const
Definition: Expr.h:3771
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
void setRBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1477
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:288
NameKind getNameKind() const
Determine what kind of name this is.
OpenMPLinearClauseKind
OpenMP attributes for &#39;linear&#39; clause.
Definition: OpenMPKinds.h:84
SourceLocation getEndLoc() const
Definition: Stmt.h:1166
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:13828
Represents a member of a struct/union/class.
Definition: Decl.h:2579
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:4904
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
This represents clause &#39;lastprivate&#39; in the &#39;#pragma omp ...&#39; directives.
The current expression is potentially evaluated at run time, which means that code may be generated t...
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:3615
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4713
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:539
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:977
VarDecl * getPromiseDecl() const
Definition: StmtCXX.h:370
ArrayRef< Expr * > getAllExprs() const
Definition: Stmt.h:2926
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1603
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:587
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:97
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1211
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:963
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition: Expr.h:2071
SourceLocation getLabelLoc() const
Definition: Expr.h:3773
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2006
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition: Expr.h:2834
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:4332
SourceLocation getOperatorLoc() const
Definition: Expr.h:2289
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:4057
bool isReferenceType() const
Definition: Type.h:6308
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:3253
SourceLocation getDefaultKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:656
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2002
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:971
This represents &#39;#pragma omp target simd&#39; directive.
Definition: StmtOpenMP.h:3384
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1003
bool isInvalid() const
Definition: Sema.h:9908
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3538
Wrapper for source info for unresolved typename using decls.
Definition: TypeLoc.h:686
qual_iterator qual_begin() const
Definition: Type.h:5439
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1370
QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc, VectorType::VectorKind)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub, bool IsThrownVariableInScope)
Build a new C++ throw expression.
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:9909
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:5116
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:805
LookupResultKind getResultKind() const
Definition: Lookup.h:310
OpenMPDirectiveKind getDirectiveKind() const
Definition: StmtOpenMP.h:244
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:481
OMPClause * RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;collapse&#39; clause.
Expr * getSubExpr()
Definition: Expr.h:3050
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:1885
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:1883
SourceLocation getQuestionLoc() const
Definition: Expr.h:3571
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:171
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:4014
ExprResult RebuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
Build a new Objective-C boxed expression.
This represents &#39;#pragma omp critical&#39; directive.
Definition: StmtOpenMP.h:1478
bool isAssignmentOp() const
Definition: Expr.h:3413
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
Definition: ExprCXX.h:1720
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Definition: Lookup.h:56
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:3030
StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @autoreleasepool statement.
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1784
IdentifierTable & Idents
Definition: ASTContext.h:566
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition: Type.h:6091
SourceLocation getCatchLoc() const
Definition: StmtCXX.h:49
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:110
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:507
Represents Objective-C&#39;s @catch statement.
Definition: StmtObjC.h:74
Expr * getLHS() const
Definition: ExprCXX.h:4291
DeclClass * getAsSingle() const
Definition: Lookup.h:496
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:109
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:2339
QualType RebuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo *> TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl *> Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build an Objective-C object type.
Describes an C or C++ initializer list.
Definition: Expr.h:4185
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:1564
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:669
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:3099
VarDecl * RebuildExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *Declarator, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Build a new C++ exception declaration.
bool isArrow() const
Definition: ExprObjC.h:551
OMPClause * RebuildOMPIsDevicePtrClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;is_device_ptr&#39; clause.
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:795
Expr * getKeyExpr() const
Definition: ExprObjC.h:851
This represents &#39;#pragma omp teams distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3588
BinaryOperatorKind
Expr * getArraySize()
Definition: ExprCXX.h:2040
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:934
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:4132
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2228
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:2237
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Definition: SemaLookup.cpp:469
void setAttr(const Attr *A)
Definition: TypeLoc.h:874
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:521
Represents the results of name lookup.
Definition: Lookup.h:47
PtrTy get() const
Definition: Ownership.h:174
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:2224
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:2210
friend bool operator!=(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
Expr * getBaseExpr() const
Definition: ExprObjC.h:848
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
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:1340
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2115
Expr * getOperand() const
Definition: ExprCXX.h:3739
const Expr * getThrowExpr() const
Definition: StmtObjC.h:325
Wrapper for source info for injected class names of class templates.
Definition: TypeLoc.h:675
< Capturing the *this object by copy
Definition: Lambda.h:37
bool isGlobalNew() const
Definition: ExprCXX.h:2074
unsigned getNumProtocols() const
Definition: TypeLoc.h:786
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:983
SourceLocation getSigilLoc() const
Definition: TypeLoc.h:1176
A convenient class for passing around template argument information.
Definition: TemplateBase.h:555
SourceLocation getLocation() const
Definition: ExprCXX.h:2259
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation Loc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:2944
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:1610
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4313
SourceLocation getLBracLoc() const
Definition: Stmt.h:1333
QualType RebuildRecordType(RecordDecl *Record)
Build a new class/struct/union type.
ExprResult TransformAddressOfOperand(Expr *E)
The operand of a unary address-of operator has special rules: it&#39;s allowed to refer to a non-static m...
SourceLocation getRParenLoc() const
Definition: StmtCXX.h:197
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:2090
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:1470
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:2760
Stmt * getBody()
Definition: Stmt.h:2271
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:1998
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:838
StmtResult StmtError()
Definition: Ownership.h:284
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:1831
QualType FunctionType
BlockType - The function type of the block, if one was given.
Definition: ScopeInfo.h:721
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: ExprCXX.h:3486
Represents a declaration of a type.
Definition: Decl.h:2874
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3287
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:831
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:1487
const Expr * getAssocExpr(unsigned i) const
Definition: Expr.h:5043
LangAS getAddressSpace() const
Definition: Type.h:352
Stmt * getInit()
Definition: Stmt.h:2250
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:436
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1362
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1796
SourceLocation getThrowLoc() const
Definition: ExprCXX.h:1040
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:2802
TemplateArgumentLocContainerIterator & operator++()
QualType RebuildVectorType(QualType ElementType, unsigned NumElements, VectorType::VectorKind VecKind)
Build a new vector type given the element type and number of elements.
const Type * getClass() const
Definition: Type.h:2790
CXXForRangeStmt - This represents C++0x [stmt.ranged]&#39;s ranged for statement, represented as &#39;for (ra...
Definition: StmtCXX.h:127
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3255
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:2874
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:2718
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:606
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Definition: Expr.cpp:2595
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:51
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the &#39;=&#39; that precedes the initializer value itself, if present.
Definition: Expr.h:4644
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:2087
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3454
Expr * getRHS() const
Definition: ExprCXX.h:4292
Expr * getSizeExpr() const
Definition: Type.h:2991
const CallExpr * getConfig() const
Definition: ExprCXX.h:240
bool isArrow() const
Definition: ExprCXX.h:812
Wrapper for source info for ObjC interfaces.
Definition: TypeLoc.h:1049
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:4034
CaseStmt - Represent a case statement.
Definition: Stmt.h:1394
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:2207
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5562
This represents &#39;final&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:330
This represents &#39;mergeable&#39; clause in the &#39;#pragma omp ...&#39; directive.
SourceLocation getCaretLocation() const
Definition: Expr.cpp:2137
Expr * getCond()
Definition: Stmt.h:2269
This represents &#39;#pragma omp teams&#39; directive.
Definition: StmtOpenMP.h:2661
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
void append(iterator I, iterator E)
StmtResult RebuildSEHFinallyStmt(SourceLocation Loc, Stmt *Block)
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:63
const Expr * getControllingExpr() const
Definition: Expr.h:5068
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:1158
Helper class for OffsetOfExpr.
Definition: Expr.h:2013
Expr * getOperand() const
Definition: ExprCXX.h:4480
This represents &#39;#pragma omp teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3518
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1217
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:2836
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:91
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:241
SourceLocation getBuiltinLoc() const
Definition: Expr.h:4120
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:988
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1649
CXXRecordDecl * getNamingClass()
Gets the &#39;naming class&#39; (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition: ExprCXX.h:2904
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value &#39;V&#39; and type &#39;type&#39;.
Definition: Expr.cpp:792
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
Definition: Expr.h:1133
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:167
SourceLocation getBeginLoc() const
Default argument expressions have no representation in the source, so they have an empty source range...
Definition: ExprCXX.h:1114
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:2985
SourceLocation getTryLoc() const
Definition: Stmt.h:3045
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:3284
This represents clause &#39;is_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1350
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4044
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
Definition: Stmt.cpp:902
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:1930
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition: Lookup.h:415
QualType RebuildReferenceType(QualType ReferentType, bool LValue, SourceLocation Sigil)
Build a new reference type given the type it references.
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:3063
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:1153
StmtClass
Definition: Stmt.h:68
const Stmt * getBody() const
Definition: Expr.cpp:2140
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition: ExprCXX.cpp:325
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1891
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
SourceLocation getProtocolRAngleLoc() const
Definition: TypeLoc.h:776
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Definition: DeclSpec.cpp:143
Stmt * getBody()
Definition: Stmt.h:1958
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2055
Expr * getSizeExpr() const
Definition: Type.h:3048
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition: Expr.cpp:1202
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1073
Stmt * getInit()
Definition: Stmt.h:1830
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1669
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2692
bool isTypeOperand() const
Definition: ExprCXX.h:916
Expr * getSizeExpr() const
Definition: Type.h:3258
Stmt * getReturnStmt() const
Definition: StmtCXX.h:398
QualType getElementType() const
Definition: Type.h:3144
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:1873
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
Definition: ExprCXX.h:3654
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:7357
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:3128
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:3418
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:976
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1857
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:543
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:223
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (&#39;)&#39;) that follows the argument list.
Definition: ExprCXX.h:3217
A helper class for building up ExtParameterInfos.
Definition: Sema.h:7725
QualType RebuildQualifiedType(QualType T, QualifiedTypeLoc TL)
Build a new qualified type given its unqualified type and type location.
TypeSourceInfo * getAllocatedTypeSourceInfo() const
Definition: ExprCXX.h:2012
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:1595
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: Expr.h:2792
Class that aids in the construction of nested-name-specifiers along with source-location information ...
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition: ExprCXX.h:2557
ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, SourceLocation LParenOrBraceLoc, MultiExprArg Args, SourceLocation RParenOrBraceLoc, bool ListInitialization)
Build a new object-construction expression.
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:1556
bool isArrayForm() const
Definition: ExprCXX.h:2197
Expr ** getSubExprs()
Retrieve the array of expressions.
Definition: Expr.h:3883
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
Definition: StmtObjC.h:206
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3650
Expr * getAddrSpaceExpr() const
Definition: Type.h:3099
helper_expr_const_range reduction_ops() const
This represents &#39;#pragma omp target parallel for simd&#39; directive.
Definition: StmtOpenMP.h:3316
llvm::Optional< bool > getKnownValue() const
Definition: Sema.h:9913
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:45
This represents &#39;dynamic_allocators&#39; clause in the &#39;#pragma omp requires&#39; directive.
Definition: OpenMPClause.h:838
StmtResult TransformSEHHandler(Stmt *Handler)
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3582
An error occurred.
Definition: Sema.h:4523
SourceLocation getBuiltinLoc() const
Definition: TypeLoc.h:549
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1610
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:278
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1364
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2286
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:946
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1241
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:653
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3687
SourceLocation getRBracket() const
Definition: ExprObjC.h:839
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:1897
NamedDecl * TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc)
Transform the given declaration, which was the first part of a nested-name-specifier in a member acce...
OMPClause * RebuildOMPToClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;to&#39; clause.
This represents &#39;threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
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:5500
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
Definition: StmtCXX.h:281
This represents &#39;#pragma omp taskgroup&#39; directive.
Definition: StmtOpenMP.h:1971
Expr * getSimdlen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:535
bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall, SmallVectorImpl< Expr *> &Outputs, bool *ArgChanged=nullptr)
Transform the given list of expressions.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Definition: ExprCXX.h:1334
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:3715
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:3477
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Definition: OpenMPClause.h:79
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:199
SourceLocation getNameLoc() const
Definition: TypeLoc.h:2018
ExprResult TransformParenDependentScopeDeclRefExpr(ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
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:2222
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:2818
SourceLocation getTryLoc() const
Definition: StmtCXX.h:91
bool isConstexpr() const
Definition: Stmt.h:1860
ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait, SourceLocation StartLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParenLoc)
Build a new array type trait expression.
QualType TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, Fn TransformExceptionSpec)
SourceLocation getRBracketLoc() const
Definition: ExprCXX.h:866
This represents clause &#39;task_reduction&#39; in the &#39;#pragma omp taskgroup&#39; directives.
SourceLocation getLocation() const
Definition: Expr.h:1122
QualType RebuildTypeOfType(QualType Underlying)
Build a new typeof(type) type.
void setSizeExpr(Expr *Size)
Definition: TypeLoc.h:1489
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.
Definition: Expr.h:904
ObjCTypeParamDecl * getDecl() const
Definition: Type.h:5507
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:4091
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2123
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param)
Definition: ExprCXX.h:1096
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.
OpenMPProcBindClauseKind getProcBindKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:723
SourceLocation getLabelLoc() const
Definition: Stmt.h:2322
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:3374
SourceLocation getThrowLoc() const LLVM_READONLY
Definition: StmtObjC.h:329
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
Definition: Expr.cpp:4189
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2099
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:2972
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:136
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:3026
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
Definition: ExprCXX.h:2394
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:190
SourceLocation getFinallyLoc() const
Definition: Stmt.h:3007
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:1881
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2095
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:1871
Retains information about a block that is currently being parsed.
Definition: ScopeInfo.h:711
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:3637
const Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
Definition: StmtOpenMP.h:196
CXXMethodDecl * CallOperator
The lambda&#39;s compiler-generated operator().
Definition: ScopeInfo.h:791
Expr * getCond() const
Definition: Expr.h:3616
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
Definition: Expr.cpp:1283
Type source information for an attributed type.
Definition: TypeLoc.h:849
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:973
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3858
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1597
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2071
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:4622
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:675
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
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:2777
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:637
ExprResult RebuildCoyieldExpr(SourceLocation CoyieldLoc, Expr *Result)
Build a new co_yield expression.
This represents one expression.
Definition: Expr.h:106
SourceLocation getLocalRangeEnd() const
Definition: TypeLoc.h:1354
SourceLocation getElseLoc() const
Definition: Stmt.h:1849
DeclStmt * getEndStmt()
Definition: StmtCXX.h:158
SourceLocation End
QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new pointer type given its pointee type.
ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool RequiresADL)
Build a new expression that references a declaration.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition: Type.h:5068
SourceLocation getCaptureDefaultLoc() const
Retrieve the location of this lambda&#39;s capture-default, if any.
Definition: ExprCXX.h:1725
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:2788
ArrayRef< StringRef > getClobbers() const
Definition: Stmt.h:2922
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:1493
SourceLocation getMapLoc() const LLVM_READONLY
Fetches location of clause mapping kind.
QualType RebuildFunctionNoProtoType(QualType ResultType)
Build a new unprototyped function type.
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3634
int Id
Definition: ASTDiff.cpp:191
This represents &#39;simdlen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:501
Expr * getNumTasks() const
Return safe iteration space distance.
SourceLocation getDefaultLoc() const
Definition: Stmt.h:1559
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr)
SourceLocation getScheduleKindLoc()
Get kind location.
QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc)
Build a new C++11 decltype type.
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:1435
SourceLocation getWhileLoc() const
Definition: Stmt.h:2164
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition: TypeLoc.h:320
SourceRange getBracketsRange() const
Definition: TypeLoc.h:1481
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:6811
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1581
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:5050
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:68
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:151
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:444
unsigned getNumParams() const
Definition: Decl.h:4089
const TypeSourceInfo * getAssocTypeSourceInfo(unsigned i) const
Definition: Expr.h:5053
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5177
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:87
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2706
VarDecl * getExceptionDecl() const
Definition: StmtCXX.h:50
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Definition: ExprCXX.h:2386
Expr * getCallee()
Definition: Expr.h:2514
OMPClause * RebuildOMPFromClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;from&#39; clause.
QualType TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, DependentTemplateSpecializationTypeLoc TL, TemplateName Template, CXXScopeSpec &SS)
unsigned getNumInits() const
Definition: Expr.h:4215
TemplateArgumentLocInventIterator & operator++()
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:3948
bool isIfNotExists() const
Determine whether this is an __if_exists statement.
Definition: StmtCXX.h:269
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:2349
Stmt * getBody()
Definition: Stmt.h:2124
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:2794
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:288
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:282
DeclContext * getDeclContext()
Definition: DeclBase.h:427
SourceLocation getLParenLoc() const
Definition: Expr.h:4964
Expr * getRHS()
Definition: Stmt.h:1495
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Definition: Type.h:5238
Represents Objective-C&#39;s @synchronized statement.
Definition: StmtObjC.h:262
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:429
Expr ** getArgs()
Retrieve the arguments to this message, not including the receiver.
Definition: ExprObjC.h:1333
SourceLocation Begin
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2176
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:2159
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:3844
SourceLocation getRBracketLoc() const
Definition: ExprOpenMP.h:112
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:65
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:5226
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
SourceLocation getAtTryLoc() const
Retrieve the location of the @ in the @try.
Definition: StmtObjC.h:193
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:2236
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
Definition: Expr.h:2532
IdentifierInfo & getAccessor() const
Definition: Expr.h:5138
Represents a C++ template name within the type system.
Definition: TemplateName.h:179
Represents the type decltype(expr) (C++11).
Definition: Type.h:4246
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:4021
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2553
ExprResult RebuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Build an empty C++1z fold-expression with the given operator.
A namespace alias, stored as a NamespaceAliasDecl*.
This represents &#39;ordered&#39; clause in the &#39;#pragma omp ...&#39; directive.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc, bool isReadPipe)
Build a new pipe type given its value type.
SourceRange getAngleBrackets() const LLVM_READONLY
Definition: ExprCXX.h:307
StmtResult RebuildGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new goto statement.
Kind getKind() const
Determine what kind of offsetof node this is.
Definition: Expr.h:2067
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1788
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:2815
bool isInvalid() const
QualType getType() const
Definition: Expr.h:128
SourceLocation getColonLoc() const
Get colon location.
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:3730
SourceLocation getLocalRangeBegin() const
Definition: TypeLoc.h:1346
SourceLocation getKeywordLoc() const
Retrieve the location of the __if_exists or __if_not_exists keyword.
Definition: StmtCXX.h:263
Wrapper for source info for enum types.
Definition: TypeLoc.h:724
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:1104
A unary type transform, which is a type constructed from another.
Definition: Type.h:4289
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:766
Expr * getPattern() const
Get the pattern, that is, the operand that contains an unexpanded pack.
Definition: ExprCXX.h:4303
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:251
SourceLocation getSwitchLoc() const
Definition: Stmt.h:2019
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2180
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:2317
const Stmt * getTryBody() const
Retrieve the @try body.
Definition: StmtObjC.h:197
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4266
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition: TypeLoc.h:746
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:2443
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:3737
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition: TypeLoc.h:1007
A boolean condition, from &#39;if&#39;, &#39;while&#39;, &#39;for&#39;, or &#39;do&#39;.
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:904
TemplateName RebuildTemplateName(CXXScopeSpec &SS, bool TemplateKW, TemplateDecl *Template)
Build a new template name given a nested name specifier, a flag indicating whether the "template" key...
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:2850
SourceLocation getDoLoc() const
Definition: Stmt.h:2214
SourceLocation getAtLoc() const
Definition: StmtObjC.h:365
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:675
ConditionKind
Definition: Sema.h:9921
bool isInvalid() const
Definition: Ownership.h:170
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition: Expr.cpp:1767
SourceLocation getRBracketLoc() const
Definition: Expr.h:2366
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:1896
bool isInstanceMethod() const
Definition: DeclObjC.h:422
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of &#39;F&#39;...
Definition: Expr.h:2879
Represents a GCC generic vector type.
Definition: Type.h:3168
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1188
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2849
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
Definition: Expr.h:4649
struct CXXOpName CXXOperatorName
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2615
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:13461
AtomicOp getOp() const
Definition: Expr.h:5497
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:759
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
UTTKind getUTTKind() const
Definition: Type.h:4317
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:3958
const OffsetOfNode & getComponent(unsigned Idx) const
Definition: Expr.h:2166
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:7744
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:2776
This represents &#39;collapse&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:555
This represents clause &#39;firstprivate&#39; in the &#39;#pragma omp ...&#39; directives.
QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc)
Build a new atomic type given its value type.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
SourceLocation getCommaLoc()
Get location of &#39;,&#39;.
The symbol exists.
Definition: Sema.h:4513
Expr * getCond()
Definition: Stmt.h:1762
ValueDecl * getDecl()
Definition: Expr.h:1114
SourceLocation getKWLoc() const
Definition: TypeLoc.h:1872
SourceLocation getLocation() const
Definition: Expr.h:1810
bool isUsable() const
Definition: Ownership.h:171
SourceLocation getRParenLoc() const
Definition: Expr.h:4123
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:1396
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:53
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:222
const Expr * getSubExpr() const
Definition: Expr.h:1860
ObjCBridgeCastKind getBridgeKind() const
Determine which kind of bridge is being performed via this cast.
Definition: ExprObjC.h:1602
const Expr * getSubExpr() const
Definition: ExprCXX.h:1240
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2011
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:3224
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition: ExprCXX.h:3909
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1200
OpenMPProcBindClauseKind
OpenMP attributes for &#39;proc_bind&#39; clause.
Definition: OpenMPKinds.h:51
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:703
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1279
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2347
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1411
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.
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:1517
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:2044
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:301
This represents &#39;#pragma omp parallel for simd&#39; directive.
Definition: StmtOpenMP.h:1632
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition: Expr.h:412
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition: Stmt.cpp:1135
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:2185
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:3394
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.
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:3212
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Definition: Type.h:4013
RecordDecl * getDecl() const
Definition: Type.h:4380
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3399
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Definition: ExprCXX.h:129
void setIsVariadic(bool value)
Definition: Decl.h:3934
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:76
void setTypeofLoc(SourceLocation Loc)
Definition: TypeLoc.h:1780
This represents &#39;unified_address&#39; clause in the &#39;#pragma omp requires&#39; directive. ...
Definition: OpenMPClause.h:745
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:2982
Expr * getArgument()
Definition: ExprCXX.h:2212
This represents &#39;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2404
Simple iterator that traverses the template arguments in a container that provides a getArgLoc() memb...
SourceLocation getLParenLoc()
Get location of &#39;(&#39;.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition: Expr.cpp:1897
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)
Wrapper for source info for arrays.
Definition: TypeLoc.h:1460
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
SourceLocation getColonLoc() const
Returns the location of &#39;:&#39;.
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.
OMPClause * TransformOMPClause(OMPClause *S)
Transform the given statement.
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:362
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:945
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1918
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:3914
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
Definition: ExprObjC.h:1329
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:2958
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:3058
Kind
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2192
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2635
This captures a statement into a function.
Definition: Stmt.h:3105
A field in a dependent type, known only by its name.
Definition: Expr.h:2022
Expr * getInit() const
Get the operand that doesn&#39;t contain a pack, for a binary fold.
Definition: ExprCXX.h:4306
QualType getCanonicalType() const
Definition: Type.h:6111
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1448
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2617
Token * getAsmToks()
Definition: Stmt.h:2881
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:157
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3743
Expr ** getPlacementArgs()
Definition: ExprCXX.h:2055
SourceLocation getLParenLoc()
Get location of &#39;(&#39;.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5299
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2107
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:1183
QualType RebuildObjCObjectPointerType(QualType PointeeType, SourceLocation Star)
Build a new Objective-C object pointer type given the pointee type.
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:5090
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:3899
const Attr * getAttr() const
The type attribute.
Definition: TypeLoc.h:871
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:2747
const ExtParameterInfo * ExtParameterInfos
Definition: Type.h:3774
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Definition: ExprCXX.h:1497
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: Expr.h:2823
unsigned getNumExprs() const
Return the number of expressions in this paren list.
Definition: Expr.h:4945
This represents &#39;#pragma omp single&#39; directive.
Definition: StmtOpenMP.h:1376
Encodes a location in the source.
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1274
body_range body()
Definition: Stmt.h:1274
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2551
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:1170
QualType getReturnType() const
Definition: Type.h:3613
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:2476
OpenMPDependClauseKind
OpenMP attributes for &#39;depend&#39; clause.
Definition: OpenMPKinds.h:76
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4396
SourceLocation getOperatorLoc() const
Definition: Expr.h:3319
StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new label statement.
const Stmt * getCatchBody() const
Definition: StmtObjC.h:90
LangAS getAddressSpace() const
Return the address space of this type.
Definition: Type.h:6188
unsigned getNumHandlers() const
Definition: StmtCXX.h:103
Expr * getSubExpr() const
Definition: Expr.h:1926
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3465
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3020
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:1175
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
Definition: Diagnostic.h:1290
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information...
Definition: ExprCXX.h:2338
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:33
A structure for storing an already-substituted template template parameter pack.
Definition: TemplateName.h:122
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition: ExprCXX.h:300
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1914
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:2154
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:342
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:772
Expr * getLHS()
Definition: Stmt.h:1483
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:484
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Definition: ExprCXX.h:481
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3064
MutableArrayRef< Expr * > MultiExprArg
Definition: Ownership.h:277
This represents &#39;schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:948
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:3808
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc)
Build the type that describes a C++ typename specifier, e.g., "typename T::type". ...
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, Optional< unsigned > Length=None, ArrayRef< TemplateArgument > PartialArgs=None)
Definition: ExprCXX.cpp:1504
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:171
SourceLocation getExceptLoc() const
Definition: Stmt.h:2970
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:364
OMPClause * RebuildOMPProcBindClause(OpenMPProcBindClauseKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;proc_bind&#39; clause.
Stmt * getElse()
Definition: Stmt.h:1783
QualType getElementType() const
Definition: Type.h:3203
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:1143
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
Represents the declaration of a label.
Definition: Decl.h:469
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:3245
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:975
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2494
SourceLocation getProcBindKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:726
ExprResult RebuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentKind IK)
Build a new predefined expression.
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Definition: StmtOpenMP.h:1536
SourceLocation getLBraceLoc() const
Definition: Stmt.h:2873
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2041
ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new address-of-label expression.
Expr * getCond()
Definition: Stmt.h:1946
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:109
SourceLocation getRParenLoc() const
Definition: Expr.h:3826
OpenMPLinearClauseKind Modifier
Modifier of &#39;linear&#39; clause.
Definition: OpenMPClause.h:102
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:404
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
C-style initialization with assignment.
Definition: Decl.h:818
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:1248
SourceLocation getAtLoc() const
Definition: ExprObjC.h:402
This represents &#39;#pragma omp taskwait&#39; directive.
Definition: StmtOpenMP.h:1927
QualType getAllocatedType() const
Definition: ExprCXX.h:2007
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1097
const ParmVarDecl * getParamDecl(unsigned i) const
Definition: Decl.h:2285
SourceLocation getLocation() const
Definition: Attr.h:94
QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new block pointer type given its pointee type.
Name lookup found an unresolvable value declaration and cannot yet complete.
Definition: Lookup.h:69
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
QualType RebuildUnresolvedUsingType(SourceLocation NameLoc, Decl *D)
Rebuild an unresolved typename type, given the decl that the UnresolvedUsingTypenameDecl was transfor...
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.
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:51
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:5909
QualType getEquivalentType() const
Definition: Type.h:4451
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:5433
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2253
bool isArray() const
Definition: ExprCXX.h:2038
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:89
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:474
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1236
bool hasRestrict() const
Definition: Type.h:268
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Definition: Expr.h:149
QualType getReceiverType() const
Retrieve the receiver type to which this message is being directed.
Definition: ExprObjC.cpp:319
SourceLocation getLParenLoc() const
Definition: Expr.h:3824
SourceLocation getGotoLoc() const
Definition: Stmt.h:2320
SourceLocation getAtFinallyLoc() const
Definition: StmtObjC.h:141
bool isObjCObjectPointerType() const
Definition: Type.h:6393
SourceLocation getNameModifierLoc() const
Return the location of directive name modifier.
Definition: OpenMPClause.h:314
const Attr * TransformAttr(const Attr *S)
Transform the given attribute.
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:2774
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:729
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2059
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3115
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition: Stmt.h:3206
SourceLocation getAtCatchLoc() const
Definition: StmtObjC.h:102
Expr ** getInits()
Retrieve the set of initializers.
Definition: Expr.h:4218
QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType, SourceLocation Sigil)
Build a new member pointer type given the pointee type and the class type it refers into...
This represents &#39;#pragma omp target&#39; directive.
Definition: StmtOpenMP.h:2288
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:447
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.
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:590
void setLBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1469
No entity found met the criteria.
Definition: Lookup.h:51
AutoTypeKeyword getKeyword() const
Definition: Type.h:4764
NestedNameSpecifierLoc TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr)
Transform the given nested-name-specifier with source-location information.
SourceLocation getEndLoc() const
Definition: Stmt.h:2875
Expr * getArrayRangeStart(const Designator &D) const
Definition: Expr.cpp:3967
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:1572
Expr * getSubExpr()
Definition: ExprObjC.h:135
The name is a dependent name, so the results will differ from one instantiation to the next...
Definition: Sema.h:4520
An expression trait intrinsic.
Definition: ExprCXX.h:2580
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:736
EnumDecl * getDecl() const
Definition: Type.h:4403
Expr ** getExprs()
Definition: Expr.h:4956
const ObjCMethodDecl * getMethodDecl() const
Definition: ExprObjC.h:1303
VarDecl * getConditionVariable()
Retrieve the variable declared in this "switch" statement, if any.
Definition: Stmt.cpp:965
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2099
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3801
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:7732
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1393
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:3040
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:117
bool isArgumentType() const
Definition: Expr.h:2258
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition: TypeLoc.h:162
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
Definition: Type.cpp:2552
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
Definition: ExprCXX.cpp:1473
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:5380
OMPClause * RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;hint&#39; clause.
SourceLocation getStarLoc() const
Definition: Stmt.h:2357
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:423
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:574
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:595
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2035
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2614
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3004
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
Definition: StmtCXX.h:241
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:215
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:2942
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1493
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:244
const Expr * getInitializer() const
Definition: Expr.h:2951
QualType getPointeeType() const
Definition: Type.h:3100
Represents a pack expansion of types.
Definition: Type.h:5355
Expr * getLHS() const
Definition: Expr.h:3327
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3504
SourceLocation getLocation() const LLVM_READONLY
Definition: ExprCXX.h:1499
Expr ** getElements()
Retrieve elements of array of literals.
Definition: ExprObjC.h:202
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:1366
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1560
Represents a C11 generic selection.
Definition: Expr.h:5010
QualType RebuildDependentSizedExtVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition: ExprCXX.h:3937
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:937
const Expr * getBase() const
Definition: Expr.h:5134
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1207
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3757
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1575
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2916
SourceLocation getTypeofLoc() const
Definition: TypeLoc.h:1776
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
Definition: ExprCXX.h:4078
Represents a template argument.
Definition: TemplateBase.h:51
ArrayRef< OpenMPMapModifierKind > getMapTypeModifiers() const LLVM_READONLY
Fetches ArrayRef of map-type-modifiers.
bool isDeduced() const
Definition: Type.h:4738
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:813
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
Definition: ExprCXX.h:2379
TypeSourceInfo * getClassTInfo() const
Definition: TypeLoc.h:1248
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:13799
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Definition: Expr.h:3714
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:367
TagTypeKind
The kind of a tag type.
Definition: Type.h:5031
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:1210
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1222
OpenMPScheduleClauseModifier
OpenMP modifiers for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:67
bool isTypeOperand() const
Definition: ExprCXX.h:709
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition: Decl.cpp:2535
bool isNull() const
Determine whether this template name is NULL.
unsigned getNumAssocs() const
Definition: Expr.h:5037
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:2556
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
Definition: Type.cpp:1723
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:7351
ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base, SourceLocation OperatorLoc, bool isArrow, CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage Destroyed)
Build a new pseudo-destructor expression.
ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E)
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: Expr.h:2846
Stmt * getReturnStmtOnAllocFailure() const
Definition: StmtCXX.h:399
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
Definition: Stmt.cpp:1021
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:499
not evaluated yet, for special member function
Expr * getAllocate() const
Definition: StmtCXX.h:388
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1758
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition: Expr.h:2867
UnaryOperatorKind
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1262
SourceLocation getLocation() const
Definition: ExprObjC.h:726
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2170
ArrayRef< Capture > captures() const
Definition: Decl.h:3985
IdentifierInfo * getOutputIdentifier(unsigned i) const
Definition: Stmt.h:2763
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:399
bool isSimple() const
Definition: Stmt.h:2553
QualType TransformTypeWithDeducedTST(QualType T)
Transform a type that is permitted to produce a DeducedTemplateSpecializationType.
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:105
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
bool isVariadic() const
Definition: Decl.h:3933
bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL, LookupResult &R)
Transform the set of declarations in an OverloadExpr.
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:474
MSPropertyDecl * getPropertyDecl() const
Definition: ExprCXX.h:811
const Stmt * getFinallyBody() const
Definition: StmtObjC.h:132
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:131
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:80
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:1669
bool isImplicit() const
Definition: ExprCXX.h:997
SourceRange getSourceRange(const SourceRange &Range)
Returns the SourceRange of a SourceRange.
Definition: FixIt.h:34
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:357
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1314
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:3450
Expr * getReturnValueInit() const
Definition: StmtCXX.h:394
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:512
Interesting information about a specific parameter that can&#39;t simply be reflected in parameter&#39;s type...
Definition: Type.h:3381
SourceLocation EllipsisLoc
The location of the ellipsis, if this is a pack expansion.
Definition: ExprObjC.h:247
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:3208
AccessSpecifier getAccess() const
Definition: DeclBase.h:462
A constant boolean condition from &#39;if constexpr&#39;.
static ExprResult Owned(Expr *E)
A runtime availability query.
Definition: ExprObjC.h:1636
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:740
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:404
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:1039
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2251
Stmt * getHandler() const
Definition: Stmt.h:3054
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4502
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3430
SourceLocation getLBraceLoc() const
Definition: Expr.h:4330
The name of a declaration.
StmtClass getStmtClass() const
Definition: Stmt.h:1029
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:559
VectorKind getVectorKind() const
Definition: Type.h:3213
Expr * getDefaultArg()
Definition: Decl.cpp:2573
SourceRange getIntroducerRange() const
Retrieve the source range covering the lambda introducer, which contains the explicit capture list su...
Definition: ExprCXX.h:1819
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Definition: Decl.h:346
Expr * getOperand() const
Retrieve the operand of the &#39;co_return&#39; statement.
Definition: StmtCXX.h:459
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:3772
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1353
OMPClause * RebuildOMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Num)
Build a new OpenMP &#39;ordered&#39; clause.
QualType RebuildFunctionProtoType(QualType T, MutableArrayRef< QualType > ParamTypes, const FunctionProtoType::ExtProtoInfo &EPI)
Build a new function type.
bool isImplicit() const
Definition: ExprCXX.h:4445
This represents &#39;unified_shared_memory&#39; clause in the &#39;#pragma omp requires&#39; directive.
Definition: OpenMPClause.h:776
This represents clause &#39;linear&#39; in the &#39;#pragma omp ...&#39; directives.
Represents an enum.
Definition: Decl.h:3326
const Expr * getSynchExpr() const
Definition: StmtObjC.h:290
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:374
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2756
bool hasObjCLifetime() const
Definition: Type.h:325
ExprResult RebuildCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc)
Build a new C++1z fold-expression.
void setSigilLoc(SourceLocation Loc)
Definition: TypeLoc.h:1180
bool isIfExists() const
Determine whether this is an __if_exists statement.
Definition: StmtCXX.h:266
Expr * get() const
Definition: Sema.h:3673
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition: TypeLoc.h:866
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:3297
NestedNameSpecifierLoc getQualifierLoc() const
Definition: ExprCXX.h:814
StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body)
Attach the body to a new case statement.
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
Definition: ExprCXX.h:3647
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it...
Definition: ExprCXX.cpp:1205
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2154
SourceLocation getBeginLoc() const
Returns the starting location of the clause.
Definition: OpenMPClause.h:67
A type that was preceded by the &#39;template&#39; keyword, stored as a Type*.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
Definition: TemplateBase.h:340
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4618
bool isNull() const
Determine whether this template argument has no value.
Definition: TemplateBase.h:238
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
SourceLocation getLParenLoc() const
Definition: ExprObjC.h:1599
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:716
Expr * getArrayRangeEnd(const Designator &D) const
Definition: Expr.cpp:3973
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
Definition: SemaDecl.cpp:1153
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:1947
Represents a __leave statement.
Definition: Stmt.h:3070
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:1939
QualType getModifiedType() const
Definition: Type.h:4450
unsigned getNumParams() const
Definition: TypeLoc.h:1402
LabelDecl * getLabel() const
Definition: Expr.h:3779
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2022
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:1473
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:3719
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:151
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:1886
SourceLocation getColonColonLoc() const
Retrieve the location of the &#39;::&#39; in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2367
Name lookup found a single declaration that met the criteria.
Definition: Lookup.h:60
ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
Build a new template-id expression.
OMPClause * RebuildOMPCopyprivateClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;copyprivate&#39; clause.
QualType RebuildIncompleteArrayType(QualType ElementType, ArrayType::ArraySizeModifier SizeMod, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new incomplete array type given the element type, size modifier, and index type qualifiers...
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:2221
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1184
Not an overloaded operator.
Definition: OperatorKinds.h:23
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition: ExprCXX.h:2994
SourceLocation getRParenLoc() const
Definition: StmtObjC.h:55
DeclarationNameInfo getNameInfo() const
Definition: Expr.h:1118
Represents the body of a coroutine.
Definition: StmtCXX.h:302
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4370
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, TypeSourceInfo *EncodedTypeInfo, SourceLocation RParenLoc)
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
unsigned getIndexTypeCVRQualifiers() const
Definition: Type.h:2857
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, Expr *SubExpr, TypeSourceInfo *TInfo, SourceLocation RParenLoc)
Build a new va_arg expression.
Expr * getBase() const
Definition: ExprObjC.h:1463
ExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build a new binary operator expression.
SourceLocation getBuiltinLoc() const
Definition: Expr.h:3864
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:2312
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
Definition: TypeLoc.h:953
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:650
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
Definition: OpenMPClause.h:311
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
Definition: ExprObjC.h:210
This file defines OpenMP AST classes for executable directives and clauses.
Represents Objective-C&#39;s collection statement.
Definition: StmtObjC.h:24
TypedefNameDecl * getTypedefNameDecl() const
Definition: TypeLoc.h:668
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1596
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:386
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition: ExprCXX.h:3912
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2216
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2232
OMPClause * RebuildOMPGrainsizeClause(Expr *Grainsize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;grainsize&#39; clause.
SourceLocation getLocation() const
Definition: ExprObjC.h:556
An implicit indirection through a C++ base class, when the field found is in a base class...
Definition: Expr.h:2025
const llvm::APInt & getSize() const
Definition: Type.h:2890
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1922
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:219
bool isFunctionType() const
Definition: Type.h:6292
SourceLocation getRParenLoc() const
Definition: Expr.h:4032
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4419
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:362
QualType RebuildVariableArrayType(QualType ElementType, ArrayType::ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new variable-length array type given the element type, size modifier, size expression...
std::iterator_traits< InputIterator >::difference_type difference_type
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:716
Stmt * getInit()
Definition: Stmt.h:1967
SourceLocation getColonLoc() const
Gets location of &#39;:&#39; symbol in clause.
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
Definition: DeclSpec.cpp:1332
SourceRange getDirectInitRange() const
Definition: ExprCXX.h:2157
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information...
Definition: ExprCXX.h:3405
OpenMPScheduleClauseKind
OpenMP attributes for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:59
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:790
Expr * getSizeExpr() const
Definition: TypeLoc.h:1485
Opcode getOpcode() const
Definition: Expr.h:1921
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1413
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:2673
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
decl_range decls()
Definition: Stmt.h:1186
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:4091
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:114
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:945
Wrapper for source info for record types.
Definition: TypeLoc.h:716
SourceLocation getLBracketLoc() const
Definition: TypeLoc.h:1465
Represents Objective-C&#39;s @finally statement.
Definition: StmtObjC.h:120
SourceLocation getDefaultLoc() const
Definition: Expr.h:5040
The template argument is a type.
Definition: TemplateBase.h:60
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1270
Holds information about the various types of exception specification.
Definition: Type.h:3741
StringRef getAsmString() const
Definition: Stmt.h:2884
OpenMPDefaultClauseKind
OpenMP attributes for &#39;default&#39; clause.
Definition: OpenMPKinds.h:43
ArrayRef< StringRef > getAllConstraints() const
Definition: Stmt.h:2918
SourceLocation getDistScheduleKindLoc()
Get kind location.
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
Definition: StmtOpenMP.h:193
ExprResult RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, UnresolvedLookupExpr *Lookup)
Build a new co_await expression.
const Expr * getBase() const
Definition: ExprObjC.h:547
The template argument is actually a parameter pack.
Definition: TemplateBase.h:91
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
Definition: ScopeInfo.h:635
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3391
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: Expr.h:2855
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
SourceLocation getColonLoc() const
Definition: Stmt.h:1375
This represents &#39;write&#39; clause in the &#39;#pragma omp atomic&#39; directive.
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1093
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:2601
bool isImplicit() const
Definition: StmtCXX.h:468
SourceLocation getRParenLoc() const
Definition: Stmt.h:2287
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:513
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:3746
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof...
Definition: ExprCXX.h:3932
ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, bool IsImplicit)
Build a new co_await expression.
DeclStmt * getRangeStmt()
Definition: StmtCXX.h:154
unsigned arg_size() const
Retrieve the number of arguments.
Definition: ExprCXX.h:3226
bool capturesCXXThis() const
Definition: Decl.h:3990
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:1011
UnqualTypeLoc getUnqualifiedLoc() const
Definition: TypeLoc.h:275
Expr * getRHS() const
Definition: Expr.h:4026
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:2733
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3169
SourceLocation getAsmLoc() const
Definition: Stmt.h:2550
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2304
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1137
Expr * getTarget()
Definition: Stmt.h:2359
VectorType::VectorKind getVectorKind() const
Definition: Type.h:3261
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:238
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:1556
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:3938
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3446
TypedefNameDecl * getDecl() const
Definition: Type.h:4167
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:13954
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getTypeArgsLAngleLoc() const
Definition: TypeLoc.h:933
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
Definition: TemplateBase.h:347
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:3749
void AddDesignator(Designator D)
AddDesignator - Add a designator to the end of this list.
Definition: Designator.h:187
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
An integral condition for a &#39;switch&#39; statement.
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition: Stmt.cpp:1265
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:235
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4425
bool isFreeIvar() const
Definition: ExprObjC.h:552
Expr * getCond()
Definition: Stmt.h:2203
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2220
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
Call-style initialization (C++98)
Definition: Decl.h:821
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Represents a type parameter type in Objective C.
Definition: Type.h:5464
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:47
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
Definition: Stmt.cpp:864
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:2682
SourceLocation getWhileLoc() const
Definition: Stmt.h:2216
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:267
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:6152
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2521
This represents &#39;nowait&#39; clause in the &#39;#pragma omp ...&#39; directive.
Represents a C++ struct/union/class.
Definition: DeclCXX.h:300
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:5264
ContinueStmt - This represents a continue.
Definition: Stmt.h:2384
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:869
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
Represents a loop initializing the elements of an array.
Definition: Expr.h:4803
const TemplateArgumentLoc * operator->() const
This represents &#39;num_tasks&#39; clause in the &#39;#pragma omp ...&#39; directive.
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:76
Stmt * getFallthroughHandler() const
Definition: StmtCXX.h:384
SourceLocation getColonLoc() const
Definition: StmtCXX.h:196
Represents a C array with an unspecified size.
Definition: Type.h:2926
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:3977
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:2973
QualType RebuildAutoType(QualType Deduced, AutoTypeKeyword Keyword)
Build a new C++11 auto type.
SourceLocation getAttrLoc() const
Definition: Stmt.h:1668
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3655
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:29
An index into an array.
Definition: Expr.h:2018
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1519
SourceLocation getRParenLoc() const
Definition: Expr.h:4965
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:254
OpenMPMapClauseKind
OpenMP mapping kind for &#39;map&#39; clause.
Definition: OpenMPKinds.h:92
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:6099
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:3628
Expr * getOperand() const
Definition: ExprCXX.h:4440
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1945
void setParam(unsigned i, ParmVarDecl *VD)
Definition: TypeLoc.h:1409
StmtResult RebuildSEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S)
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:5169
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:2063
SourceLocation getFirstScheduleModifierLoc() const
Get the first modifier location.
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1430
TryCaptureKind
Definition: Sema.h:4071
unsigned getNumProtocols() const
Definition: TypeLoc.h:979
helper_expr_const_range reduction_ops() const
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1101
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:4624
Location information for a TemplateArgument.
Definition: TemplateBase.h:393
SourceRange getParensRange() const
Definition: TypeLoc.h:1893
bool isCXXThisCaptured() const
Determine whether the C++ &#39;this&#39; is captured.
Definition: ScopeInfo.h:674
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1550
SourceLocation getAtSynchronizedLoc() const
Definition: StmtObjC.h:279
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:3812
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier &#39;::&#39;.
Definition: DeclSpec.cpp:97
CompoundStmt * getTryBlock()
Definition: StmtCXX.h:96
SourceLocation getCaseLoc() const
Definition: Stmt.h:1465
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:4308
The receiver is a class.
Definition: ExprObjC.h:1052
Represents Objective-C&#39;s @try ... @catch ... @finally statement.
Definition: StmtObjC.h:154
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:276
bool isGlobalDelete() const
Definition: ExprCXX.h:2196
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:2906
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_convertvector token.
Definition: Expr.h:3949
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
Definition: StmtObjC.h:203
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3382
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1566
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
Definition: ExprCXX.h:1848
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:2396
bool TransformTemplateArgument(const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output, bool Uneval=false)
Transform the given template argument.
SourceLocation getNameLoc() const
Definition: TypeLoc.h:517
SourceRange getTypeIdParens() const
Definition: ExprCXX.h:2069
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:3801
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1576
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:276
ExprResult ExprError()
Definition: Ownership.h:283
static Qualifiers fromCVRMask(unsigned CVR)
Definition: Type.h:234
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:1687
bool blockMissingReturnType() const
Definition: Decl.h:3993
bool TransformExceptionSpec(SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, SmallVectorImpl< QualType > &Exceptions, bool &Changed)
Expr * getLHS() const
Definition: Expr.h:4024
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition: ExprCXX.cpp:1158
Stmt * getBody() const
Retrieve the body of the coroutine as written.
Definition: StmtCXX.h:363
unsigned getNumTypeArgs() const
Definition: TypeLoc.h:949
ExprResult RebuildImplicitValueInitExpr(QualType T)
Build a new value-initialized expression.
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:270
unsigned getNumElements() const
Definition: Type.h:3204
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:2776
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:1246
Designation - Represent a full designation, which is a sequence of designators.
Definition: Designator.h:181
Expr * getHint() const
Returns number of threads.
static OpaquePtr make(QualType P)
Definition: Ownership.h:61
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:82
bool isObjectReceiver() const
Definition: ExprObjC.h:738
The top declaration context.
Definition: Decl.h:108
unsigned getNumComponents() const
Definition: Expr.h:2176
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2346
bool isReadOnly() const
Definition: Type.h:6035
ExprResult RebuildStmtExpr(SourceLocation LParenLoc, Stmt *SubStmt, SourceLocation RParenLoc)
Build a new GNU statement expression.
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1102
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2079
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:257
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1041
Represents an extended address space qualifier where the input address space value is dependent...
Definition: Type.h:3086
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4841
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:3944
Expr * getRHS() const
Definition: Expr.h:3329
QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL)
Transforms a reference type.
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.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition: ExprCXX.h:2756
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
bool isPointerType() const
Definition: Type.h:6296
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:967
Iterator adaptor that invents template argument location information for each of the template argumen...
BreakStmt - This represents a break.
Definition: Stmt.h:2410
Expr * getChunkSize()
Get chunk size.
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:94
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:539
Expr * getOperand() const
Definition: ExprCXX.h:4515
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:1666
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: ExprCXX.h:3438
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition: Expr.cpp:2761
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:426
Stmt * getSubStmt()
Definition: Stmt.h:1614
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
attr::Kind getAttrKind() const
Definition: TypeLoc.h:854
SourceLocation getBridgeKeywordLoc() const
The location of the bridge keyword.
Definition: ExprObjC.h:1610
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1...
Definition: ExprCXX.h:1345
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3912
DeclStmt * getLoopVarStmt()
Definition: StmtCXX.h:161
QualType getType() const
Definition: Decl.h:648
Wrapper for source info for builtin types.
Definition: TypeLoc.h:544
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:114
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1105
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition: ExprCXX.h:1410
Wrapper for template type parameters.
Definition: TypeLoc.h:732
static Designator getArray(Expr *Index, SourceLocation LBracketLoc)
Definition: Designator.h:136
const Expr * getBase() const
Definition: ExprObjC.h:719
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:324
This represents &#39;#pragma omp taskyield&#39; directive.
Definition: StmtOpenMP.h:1839
This represents a decl that may have a name.
Definition: Decl.h:249
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
Definition: DeclSpec.h:1023
TemplateName TransformTemplateName(CXXScopeSpec &SS, TemplateName Name, SourceLocation NameLoc, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr, bool AllowInjectedClassName=false)
Transform the given template name.
This represents &#39;#pragma omp distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3179
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:562
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: Expr.h:2807
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:478
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2117
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
Definition: TypeLoc.h:76
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2971
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2619
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1700
Represents a C++ namespace alias.
Definition: DeclCXX.h:3020
StmtResult RebuildCoreturnStmt(SourceLocation CoreturnLoc, Expr *Result, bool IsImplicit)
Build a new co_return statement.
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1600
Sema & getSema() const
Retrieves a reference to the semantic analysis object used for this tree transform.
SourceLocation getBuiltinLoc() const
Definition: Expr.h:5523
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2063
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:887
No keyword precedes the qualified type name.
Definition: Type.h:5071
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1552
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, MultiStmtArg Statements, SourceLocation RBraceLoc, bool IsStmtExpr)
Build a new compound statement.
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:1824
SourceLocation getAttributeLoc() const
Definition: Type.h:3101
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:281
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition: Expr.h:3695
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3047
TypeSourceInfo * getWrittenTypeInfo() const
Definition: Expr.h:4117
DeclStmt * getBeginStmt()
Definition: StmtCXX.h:155
QualType getElementType() const
Definition: Type.h:3259
void setBlockMissingReturnType(bool val=true)
Definition: Decl.h:3997
const ExtParameterInfo * getExtParameterInfosOrNull() const
Return a pointer to the beginning of the array of extra parameter information, if present...
Definition: Type.h:4072
SourceLocation getRightLoc() const
Definition: ExprObjC.h:1364
static Designator getArrayRange(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Definition: Designator.h:146
attr::Kind getKind() const
Definition: Attr.h:87
The receiver is a superclass.
Definition: ExprObjC.h:1058
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:302
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition: Lookup.h:513
SourceLocation getGenericLoc() const
Definition: Expr.h:5039
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
Definition: ExprObjC.cpp:290
The global specifier &#39;::&#39;. There is no stored value.
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:288
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Definition: Decl.cpp:3055
Wrapper for source info for pointers.
Definition: TypeLoc.h:1202
SourceLocation getBegin() const
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
Definition: Expr.h:3941
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4309
SourceLocation ColonLoc
Location of &#39;:&#39;.
Definition: OpenMPClause.h:108
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
Definition: Expr.h:2156
ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocatedType, TypeSourceInfo *AllocatedTypeInfo, Expr *ArraySize, SourceRange DirectInitRange, Expr *Initializer)
Build a new C++ "new" expression.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition: Decl.h:730
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:3915
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1215
QualType RebuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl *> Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Represents Objective-C&#39;s @autoreleasepool Statement.
Definition: StmtObjC.h:345
llvm::Optional< NullabilityKind > getImmediateNullability() const
Definition: Type.cpp:3823
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:4381
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2872
CompoundStmt * getTryBlock() const
Definition: Stmt.h:3050
Stmt * getSubStmt()
Definition: Stmt.h:1673
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:3773
QualType getBaseType() const
Definition: ExprCXX.h:3624
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4342
QualType RebuildDeducedTemplateSpecializationType(TemplateName Template, QualType Deduced)
By default, builds a new DeducedTemplateSpecializationType with the given deduced type...
Expr * getBaseExpr() const
Definition: ExprCXX.h:810
QualType RebuildTypedefType(TypedefNameDecl *Typedef)
Build a new typedef type.
The symbol does not exist.
Definition: Sema.h:4516
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:4893
CompoundStmt * getBlock() const
Definition: Stmt.h:2977
static StmtResult Owned(Stmt *S)
SourceLocation getReturnLoc() const
Definition: Stmt.h:2499
Stmt * getFinalSuspendStmt() const
Definition: StmtCXX.h:377
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1943
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition: Stmt.cpp:1280
This represents &#39;#pragma omp target parallel for&#39; directive.
Definition: StmtOpenMP.h:2581
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:44
SourceLocation getLocation() const
Definition: DeclBase.h:418
This represents clause &#39;use_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
SourceLocation getTypeArgsRAngleLoc() const
Definition: TypeLoc.h:941
QualType getPointeeType() const
Definition: Type.h:2776
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:98
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2469
Expr * getLength()
Get length of array section.
Definition: ExprOpenMP.h:99
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:1845
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3425
const IdentifierInfo * getIdentifier() const
Definition: Type.h:5291
StmtResult RebuildGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, SourceLocation RParenLoc)
Build a new inline asm statement.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
Definition: Decl.cpp:1738
ConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1382
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:1235
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
Definition: ExprOpenMP.h:82
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
Definition: Type.h:1058
A RAII object to temporarily push a declaration context.
Definition: Sema.h:728
Stmt * getSubStmt()
Definition: Stmt.h:1513
StmtResult RebuildObjCAtTryStmt(SourceLocation AtLoc, Stmt *TryBody, MultiStmtArg CatchStmts, Stmt *Finally)
Build a new Objective-C @try statement.
This represents &#39;#pragma omp taskloop&#39; directive.
Definition: StmtOpenMP.h:2841