clang  6.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 /// \brief 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 /// overridding 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  /// \brief 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  /// \brief 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  /// \brief Initializes a new tree transformer.
124  TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { }
125 
126  /// \brief Retrieves a reference to the derived class.
127  Derived &getDerived() { return static_cast<Derived&>(*this); }
128 
129  /// \brief 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  /// \brief Retrieves a reference to the semantic analysis object used for
138  /// this tree transform.
139  Sema &getSema() const { return SemaRef; }
140 
141  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief "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  /// \brief "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  /// \brief Note to the derived class when a function parameter pack is
281  /// being expanded.
283 
284  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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);
332 
333  /// \brief 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  /// \brief 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 /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief 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  /// \brief Fakes up a TemplateArgumentLoc for a given TemplateArgument.
582  void InventTemplateArgumentLoc(const TemplateArgument &Arg,
583  TemplateArgumentLoc &ArgLoc);
584 
585  /// \brief 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  unsigned 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  /// \brief 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  /// \brief 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  /// \brief Build a new qualified type given its unqualified type and type
688  /// qualifiers.
689  ///
690  /// By default, this routine adds type qualifiers only to types that can
691  /// have qualifiers, and silently suppresses those qualifiers that are not
692  /// permitted. Subclasses may override this routine to provide different
693  /// behavior.
694  QualType RebuildQualifiedType(QualType T, SourceLocation Loc,
695  Qualifiers Quals);
696 
697  /// \brief Build a new pointer type given its pointee type.
698  ///
699  /// By default, performs semantic analysis when building the pointer type.
700  /// Subclasses may override this routine to provide different behavior.
701  QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil);
702 
703  /// \brief Build a new block pointer type given its pointee type.
704  ///
705  /// By default, performs semantic analysis when building the block pointer
706  /// type. Subclasses may override this routine to provide different behavior.
707  QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil);
708 
709  /// \brief Build a new reference type given the type it references.
710  ///
711  /// By default, performs semantic analysis when building the
712  /// reference type. Subclasses may override this routine to provide
713  /// different behavior.
714  ///
715  /// \param LValue whether the type was written with an lvalue sigil
716  /// or an rvalue sigil.
717  QualType RebuildReferenceType(QualType ReferentType,
718  bool LValue,
719  SourceLocation Sigil);
720 
721  /// \brief Build a new member pointer type given the pointee type and the
722  /// class type it refers into.
723  ///
724  /// By default, performs semantic analysis when building the member pointer
725  /// type. Subclasses may override this routine to provide different behavior.
726  QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType,
727  SourceLocation Sigil);
728 
729  QualType RebuildObjCTypeParamType(const ObjCTypeParamDecl *Decl,
730  SourceLocation ProtocolLAngleLoc,
731  ArrayRef<ObjCProtocolDecl *> Protocols,
732  ArrayRef<SourceLocation> ProtocolLocs,
733  SourceLocation ProtocolRAngleLoc);
734 
735  /// \brief Build an Objective-C object type.
736  ///
737  /// By default, performs semantic analysis when building the object type.
738  /// Subclasses may override this routine to provide different behavior.
739  QualType RebuildObjCObjectType(QualType BaseType,
740  SourceLocation Loc,
741  SourceLocation TypeArgsLAngleLoc,
742  ArrayRef<TypeSourceInfo *> TypeArgs,
743  SourceLocation TypeArgsRAngleLoc,
744  SourceLocation ProtocolLAngleLoc,
745  ArrayRef<ObjCProtocolDecl *> Protocols,
746  ArrayRef<SourceLocation> ProtocolLocs,
747  SourceLocation ProtocolRAngleLoc);
748 
749  /// \brief Build a new Objective-C object pointer type given the pointee type.
750  ///
751  /// By default, directly builds the pointer type, with no additional semantic
752  /// analysis.
753  QualType RebuildObjCObjectPointerType(QualType PointeeType,
754  SourceLocation Star);
755 
756  /// \brief Build a new array type given the element type, size
757  /// modifier, size of the array (if known), size expression, and index type
758  /// qualifiers.
759  ///
760  /// By default, performs semantic analysis when building the array type.
761  /// Subclasses may override this routine to provide different behavior.
762  /// Also by default, all of the other Rebuild*Array
763  QualType RebuildArrayType(QualType ElementType,
765  const llvm::APInt *Size,
766  Expr *SizeExpr,
767  unsigned IndexTypeQuals,
768  SourceRange BracketsRange);
769 
770  /// \brief Build a new constant array type given the element type, size
771  /// modifier, (known) size of the array, and index type qualifiers.
772  ///
773  /// By default, performs semantic analysis when building the array type.
774  /// Subclasses may override this routine to provide different behavior.
775  QualType RebuildConstantArrayType(QualType ElementType,
777  const llvm::APInt &Size,
778  unsigned IndexTypeQuals,
779  SourceRange BracketsRange);
780 
781  /// \brief Build a new incomplete array type given the element type, size
782  /// modifier, and index type qualifiers.
783  ///
784  /// By default, performs semantic analysis when building the array type.
785  /// Subclasses may override this routine to provide different behavior.
786  QualType RebuildIncompleteArrayType(QualType ElementType,
788  unsigned IndexTypeQuals,
789  SourceRange BracketsRange);
790 
791  /// \brief Build a new variable-length array type given the element type,
792  /// size modifier, size expression, and index type qualifiers.
793  ///
794  /// By default, performs semantic analysis when building the array type.
795  /// Subclasses may override this routine to provide different behavior.
796  QualType RebuildVariableArrayType(QualType ElementType,
798  Expr *SizeExpr,
799  unsigned IndexTypeQuals,
800  SourceRange BracketsRange);
801 
802  /// \brief Build a new dependent-sized array type given the element type,
803  /// size modifier, size expression, and index type qualifiers.
804  ///
805  /// By default, performs semantic analysis when building the array type.
806  /// Subclasses may override this routine to provide different behavior.
807  QualType RebuildDependentSizedArrayType(QualType ElementType,
809  Expr *SizeExpr,
810  unsigned IndexTypeQuals,
811  SourceRange BracketsRange);
812 
813  /// \brief Build a new vector type given the element type and
814  /// number of elements.
815  ///
816  /// By default, performs semantic analysis when building the vector type.
817  /// Subclasses may override this routine to provide different behavior.
818  QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
819  VectorType::VectorKind VecKind);
820 
821  /// \brief Build a new extended vector type given the element type and
822  /// number of elements.
823  ///
824  /// By default, performs semantic analysis when building the vector type.
825  /// Subclasses may override this routine to provide different behavior.
826  QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
827  SourceLocation AttributeLoc);
828 
829  /// \brief Build a new potentially dependently-sized extended vector type
830  /// given the element type and number of elements.
831  ///
832  /// By default, performs semantic analysis when building the vector type.
833  /// Subclasses may override this routine to provide different behavior.
834  QualType RebuildDependentSizedExtVectorType(QualType ElementType,
835  Expr *SizeExpr,
836  SourceLocation AttributeLoc);
837 
838  /// \brief Build a new DependentAddressSpaceType or return the pointee
839  /// type variable with the correct address space (retrieved from
840  /// AddrSpaceExpr) applied to it. The former will be returned in cases
841  /// where the address space remains dependent.
842  ///
843  /// By default, performs semantic analysis when building the type with address
844  /// space applied. Subclasses may override this routine to provide different
845  /// behavior.
846  QualType RebuildDependentAddressSpaceType(QualType PointeeType,
847  Expr *AddrSpaceExpr,
848  SourceLocation AttributeLoc);
849 
850  /// \brief Build a new function type.
851  ///
852  /// By default, performs semantic analysis when building the function type.
853  /// Subclasses may override this routine to provide different behavior.
854  QualType RebuildFunctionProtoType(QualType T,
855  MutableArrayRef<QualType> ParamTypes,
856  const FunctionProtoType::ExtProtoInfo &EPI);
857 
858  /// \brief Build a new unprototyped function type.
859  QualType RebuildFunctionNoProtoType(QualType ResultType);
860 
861  /// \brief Rebuild an unresolved typename type, given the decl that
862  /// the UnresolvedUsingTypenameDecl was transformed to.
863  QualType RebuildUnresolvedUsingType(SourceLocation NameLoc, Decl *D);
864 
865  /// \brief Build a new typedef type.
867  return SemaRef.Context.getTypeDeclType(Typedef);
868  }
869 
870  /// \brief Build a new class/struct/union type.
872  return SemaRef.Context.getTypeDeclType(Record);
873  }
874 
875  /// \brief Build a new Enum type.
877  return SemaRef.Context.getTypeDeclType(Enum);
878  }
879 
880  /// \brief Build a new typeof(expr) type.
881  ///
882  /// By default, performs semantic analysis when building the typeof type.
883  /// Subclasses may override this routine to provide different behavior.
884  QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc);
885 
886  /// \brief Build a new typeof(type) type.
887  ///
888  /// By default, builds a new TypeOfType with the given underlying type.
889  QualType RebuildTypeOfType(QualType Underlying);
890 
891  /// \brief Build a new unary transform type.
892  QualType RebuildUnaryTransformType(QualType BaseType,
894  SourceLocation Loc);
895 
896  /// \brief Build a new C++11 decltype type.
897  ///
898  /// By default, performs semantic analysis when building the decltype type.
899  /// Subclasses may override this routine to provide different behavior.
900  QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc);
901 
902  /// \brief Build a new C++11 auto type.
903  ///
904  /// By default, builds a new AutoType with the given deduced type.
906  // Note, IsDependent is always false here: we implicitly convert an 'auto'
907  // which has been deduced to a dependent type into an undeduced 'auto', so
908  // that we'll retry deduction after the transformation.
909  return SemaRef.Context.getAutoType(Deduced, Keyword,
910  /*IsDependent*/ false);
911  }
912 
913  /// By default, builds a new DeducedTemplateSpecializationType with the given
914  /// deduced type.
916  QualType Deduced) {
918  Template, Deduced, /*IsDependent*/ false);
919  }
920 
921  /// \brief Build a new template specialization type.
922  ///
923  /// By default, performs semantic analysis when building the template
924  /// specialization type. Subclasses may override this routine to provide
925  /// different behavior.
926  QualType RebuildTemplateSpecializationType(TemplateName Template,
927  SourceLocation TemplateLoc,
929 
930  /// \brief Build a new parenthesized type.
931  ///
932  /// By default, builds a new ParenType type from the inner type.
933  /// Subclasses may override this routine to provide different behavior.
935  return SemaRef.BuildParenType(InnerType);
936  }
937 
938  /// \brief Build a new qualified name type.
939  ///
940  /// By default, builds a new ElaboratedType type from the keyword,
941  /// the nested-name-specifier and the named type.
942  /// Subclasses may override this routine to provide different behavior.
944  ElaboratedTypeKeyword Keyword,
945  NestedNameSpecifierLoc QualifierLoc,
946  QualType Named) {
947  return SemaRef.Context.getElaboratedType(Keyword,
948  QualifierLoc.getNestedNameSpecifier(),
949  Named);
950  }
951 
952  /// \brief Build a new typename type that refers to a template-id.
953  ///
954  /// By default, builds a new DependentNameType type from the
955  /// nested-name-specifier and the given type. Subclasses may override
956  /// this routine to provide different behavior.
958  ElaboratedTypeKeyword Keyword,
959  NestedNameSpecifierLoc QualifierLoc,
960  const IdentifierInfo *Name,
961  SourceLocation NameLoc,
963  bool AllowInjectedClassName) {
964  // Rebuild the template name.
965  // TODO: avoid TemplateName abstraction
966  CXXScopeSpec SS;
967  SS.Adopt(QualifierLoc);
968  TemplateName InstName
969  = getDerived().RebuildTemplateName(SS, *Name, NameLoc, QualType(),
970  nullptr, AllowInjectedClassName);
971 
972  if (InstName.isNull())
973  return QualType();
974 
975  // If it's still dependent, make a dependent specialization.
976  if (InstName.getAsDependentTemplateName())
977  return SemaRef.Context.getDependentTemplateSpecializationType(Keyword,
978  QualifierLoc.getNestedNameSpecifier(),
979  Name,
980  Args);
981 
982  // Otherwise, make an elaborated type wrapping a non-dependent
983  // specialization.
984  QualType T =
985  getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args);
986  if (T.isNull()) return QualType();
987 
988  if (Keyword == ETK_None && QualifierLoc.getNestedNameSpecifier() == nullptr)
989  return T;
990 
991  return SemaRef.Context.getElaboratedType(Keyword,
992  QualifierLoc.getNestedNameSpecifier(),
993  T);
994  }
995 
996  /// \brief Build a new typename type that refers to an identifier.
997  ///
998  /// By default, performs semantic analysis when building the typename type
999  /// (or elaborated type). Subclasses may override this routine to provide
1000  /// different behavior.
1002  SourceLocation KeywordLoc,
1003  NestedNameSpecifierLoc QualifierLoc,
1004  const IdentifierInfo *Id,
1005  SourceLocation IdLoc,
1006  bool DeducedTSTContext) {
1007  CXXScopeSpec SS;
1008  SS.Adopt(QualifierLoc);
1009 
1010  if (QualifierLoc.getNestedNameSpecifier()->isDependent()) {
1011  // If the name is still dependent, just build a new dependent name type.
1012  if (!SemaRef.computeDeclContext(SS))
1013  return SemaRef.Context.getDependentNameType(Keyword,
1014  QualifierLoc.getNestedNameSpecifier(),
1015  Id);
1016  }
1017 
1018  if (Keyword == ETK_None || Keyword == ETK_Typename) {
1019  QualType T = SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1020  *Id, IdLoc);
1021  // If a dependent name resolves to a deduced template specialization type,
1022  // check that we're in one of the syntactic contexts permitting it.
1023  if (!DeducedTSTContext) {
1024  if (auto *Deduced = dyn_cast_or_null<DeducedTemplateSpecializationType>(
1025  T.isNull() ? nullptr : T->getContainedDeducedType())) {
1026  SemaRef.Diag(IdLoc, diag::err_dependent_deduced_tst)
1027  << (int)SemaRef.getTemplateNameKindForDiagnostics(
1028  Deduced->getTemplateName())
1029  << QualType(QualifierLoc.getNestedNameSpecifier()->getAsType(), 0);
1030  if (auto *TD = Deduced->getTemplateName().getAsTemplateDecl())
1031  SemaRef.Diag(TD->getLocation(), diag::note_template_decl_here);
1032  return QualType();
1033  }
1034  }
1035  return T;
1036  }
1037 
1039 
1040  // We had a dependent elaborated-type-specifier that has been transformed
1041  // into a non-dependent elaborated-type-specifier. Find the tag we're
1042  // referring to.
1043  LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
1044  DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1045  if (!DC)
1046  return QualType();
1047 
1048  if (SemaRef.RequireCompleteDeclContext(SS, DC))
1049  return QualType();
1050 
1051  TagDecl *Tag = nullptr;
1052  SemaRef.LookupQualifiedName(Result, DC);
1053  switch (Result.getResultKind()) {
1056  break;
1057 
1058  case LookupResult::Found:
1059  Tag = Result.getAsSingle<TagDecl>();
1060  break;
1061 
1064  llvm_unreachable("Tag lookup cannot find non-tags");
1065 
1067  // Let the LookupResult structure handle ambiguities.
1068  return QualType();
1069  }
1070 
1071  if (!Tag) {
1072  // Check where the name exists but isn't a tag type and use that to emit
1073  // better diagnostics.
1074  LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
1075  SemaRef.LookupQualifiedName(Result, DC);
1076  switch (Result.getResultKind()) {
1077  case LookupResult::Found:
1080  NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1081  Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1082  SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << SomeDecl
1083  << NTK << Kind;
1084  SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1085  break;
1086  }
1087  default:
1088  SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1089  << Kind << Id << DC << QualifierLoc.getSourceRange();
1090  break;
1091  }
1092  return QualType();
1093  }
1094 
1095  if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1096  IdLoc, Id)) {
1097  SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1098  SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1099  return QualType();
1100  }
1101 
1102  // Build the elaborated-type-specifier type.
1103  QualType T = SemaRef.Context.getTypeDeclType(Tag);
1104  return SemaRef.Context.getElaboratedType(Keyword,
1105  QualifierLoc.getNestedNameSpecifier(),
1106  T);
1107  }
1108 
1109  /// \brief Build a new pack expansion type.
1110  ///
1111  /// By default, builds a new PackExpansionType type from the given pattern.
1112  /// Subclasses may override this routine to provide different behavior.
1114  SourceRange PatternRange,
1115  SourceLocation EllipsisLoc,
1116  Optional<unsigned> NumExpansions) {
1117  return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1118  NumExpansions);
1119  }
1120 
1121  /// \brief Build a new atomic type given its value type.
1122  ///
1123  /// By default, performs semantic analysis when building the atomic type.
1124  /// Subclasses may override this routine to provide different behavior.
1125  QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc);
1126 
1127  /// \brief Build a new pipe type given its value type.
1128  QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc,
1129  bool isReadPipe);
1130 
1131  /// \brief Build a new template name given a nested name specifier, a flag
1132  /// indicating whether the "template" keyword was provided, and the template
1133  /// that the template name refers to.
1134  ///
1135  /// By default, builds the new template name directly. Subclasses may override
1136  /// this routine to provide different behavior.
1137  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1138  bool TemplateKW,
1139  TemplateDecl *Template);
1140 
1141  /// \brief Build a new template name given a nested name specifier and the
1142  /// name that is referred to as a template.
1143  ///
1144  /// By default, performs semantic analysis to determine whether the name can
1145  /// be resolved to a specific template, then builds the appropriate kind of
1146  /// template name. Subclasses may override this routine to provide different
1147  /// behavior.
1148  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1149  const IdentifierInfo &Name,
1150  SourceLocation NameLoc,
1151  QualType ObjectType,
1152  NamedDecl *FirstQualifierInScope,
1153  bool AllowInjectedClassName);
1154 
1155  /// \brief Build a new template name given a nested name specifier and the
1156  /// overloaded operator name that is referred to as a template.
1157  ///
1158  /// By default, performs semantic analysis to determine whether the name can
1159  /// be resolved to a specific template, then builds the appropriate kind of
1160  /// template name. Subclasses may override this routine to provide different
1161  /// behavior.
1162  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1163  OverloadedOperatorKind Operator,
1164  SourceLocation NameLoc,
1165  QualType ObjectType,
1166  bool AllowInjectedClassName);
1167 
1168  /// \brief Build a new template name given a template template parameter pack
1169  /// and the
1170  ///
1171  /// By default, performs semantic analysis to determine whether the name can
1172  /// be resolved to a specific template, then builds the appropriate kind of
1173  /// template name. Subclasses may override this routine to provide different
1174  /// behavior.
1176  const TemplateArgument &ArgPack) {
1177  return getSema().Context.getSubstTemplateTemplateParmPack(Param, ArgPack);
1178  }
1179 
1180  /// \brief Build a new compound statement.
1181  ///
1182  /// By default, performs semantic analysis to build the new statement.
1183  /// Subclasses may override this routine to provide different behavior.
1185  MultiStmtArg Statements,
1186  SourceLocation RBraceLoc,
1187  bool IsStmtExpr) {
1188  return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1189  IsStmtExpr);
1190  }
1191 
1192  /// \brief Build a new case statement.
1193  ///
1194  /// By default, performs semantic analysis to build the new statement.
1195  /// Subclasses may override this routine to provide different behavior.
1197  Expr *LHS,
1198  SourceLocation EllipsisLoc,
1199  Expr *RHS,
1201  return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1202  ColonLoc);
1203  }
1204 
1205  /// \brief Attach the body to a new case statement.
1206  ///
1207  /// By default, performs semantic analysis to build the new statement.
1208  /// Subclasses may override this routine to provide different behavior.
1210  getSema().ActOnCaseStmtBody(S, Body);
1211  return S;
1212  }
1213 
1214  /// \brief Build a new default statement.
1215  ///
1216  /// By default, performs semantic analysis to build the new statement.
1217  /// Subclasses may override this routine to provide different behavior.
1220  Stmt *SubStmt) {
1221  return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1222  /*CurScope=*/nullptr);
1223  }
1224 
1225  /// \brief Build a new label statement.
1226  ///
1227  /// By default, performs semantic analysis to build the new statement.
1228  /// Subclasses may override this routine to provide different behavior.
1230  SourceLocation ColonLoc, Stmt *SubStmt) {
1231  return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1232  }
1233 
1234  /// \brief Build a new label statement.
1235  ///
1236  /// By default, performs semantic analysis to build the new statement.
1237  /// Subclasses may override this routine to provide different behavior.
1239  ArrayRef<const Attr*> Attrs,
1240  Stmt *SubStmt) {
1241  return SemaRef.ActOnAttributedStmt(AttrLoc, Attrs, SubStmt);
1242  }
1243 
1244  /// \brief Build a new "if" statement.
1245  ///
1246  /// By default, performs semantic analysis to build the new statement.
1247  /// Subclasses may override this routine to provide different behavior.
1248  StmtResult RebuildIfStmt(SourceLocation IfLoc, bool IsConstexpr,
1249  Sema::ConditionResult Cond, Stmt *Init, Stmt *Then,
1250  SourceLocation ElseLoc, Stmt *Else) {
1251  return getSema().ActOnIfStmt(IfLoc, IsConstexpr, Init, Cond, Then,
1252  ElseLoc, Else);
1253  }
1254 
1255  /// \brief Start building a new switch statement.
1256  ///
1257  /// By default, performs semantic analysis to build the new statement.
1258  /// Subclasses may override this routine to provide different behavior.
1260  Sema::ConditionResult Cond) {
1261  return getSema().ActOnStartOfSwitchStmt(SwitchLoc, Init, Cond);
1262  }
1263 
1264  /// \brief Attach the body to the switch statement.
1265  ///
1266  /// By default, performs semantic analysis to build the new statement.
1267  /// Subclasses may override this routine to provide different behavior.
1269  Stmt *Switch, Stmt *Body) {
1270  return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1271  }
1272 
1273  /// \brief Build a new while statement.
1274  ///
1275  /// By default, performs semantic analysis to build the new statement.
1276  /// Subclasses may override this routine to provide different behavior.
1278  Sema::ConditionResult Cond, Stmt *Body) {
1279  return getSema().ActOnWhileStmt(WhileLoc, Cond, Body);
1280  }
1281 
1282  /// \brief Build a new do-while statement.
1283  ///
1284  /// By default, performs semantic analysis to build the new statement.
1285  /// Subclasses may override this routine to provide different behavior.
1287  SourceLocation WhileLoc, SourceLocation LParenLoc,
1288  Expr *Cond, SourceLocation RParenLoc) {
1289  return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1290  Cond, RParenLoc);
1291  }
1292 
1293  /// \brief Build a new for statement.
1294  ///
1295  /// By default, performs semantic analysis to build the new statement.
1296  /// Subclasses may override this routine to provide different behavior.
1298  Stmt *Init, Sema::ConditionResult Cond,
1299  Sema::FullExprArg Inc, SourceLocation RParenLoc,
1300  Stmt *Body) {
1301  return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1302  Inc, RParenLoc, Body);
1303  }
1304 
1305  /// \brief Build a new goto statement.
1306  ///
1307  /// By default, performs semantic analysis to build the new statement.
1308  /// Subclasses may override this routine to provide different behavior.
1310  LabelDecl *Label) {
1311  return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1312  }
1313 
1314  /// \brief Build a new indirect goto statement.
1315  ///
1316  /// By default, performs semantic analysis to build the new statement.
1317  /// Subclasses may override this routine to provide different behavior.
1319  SourceLocation StarLoc,
1320  Expr *Target) {
1321  return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1322  }
1323 
1324  /// \brief Build a new return statement.
1325  ///
1326  /// By default, performs semantic analysis to build the new statement.
1327  /// Subclasses may override this routine to provide different behavior.
1329  return getSema().BuildReturnStmt(ReturnLoc, Result);
1330  }
1331 
1332  /// \brief Build a new declaration statement.
1333  ///
1334  /// By default, performs semantic analysis to build the new statement.
1335  /// Subclasses may override this routine to provide different behavior.
1337  SourceLocation StartLoc, SourceLocation EndLoc) {
1338  Sema::DeclGroupPtrTy DG = getSema().BuildDeclaratorGroup(Decls);
1339  return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1340  }
1341 
1342  /// \brief Build a new inline asm statement.
1343  ///
1344  /// By default, performs semantic analysis to build the new statement.
1345  /// Subclasses may override this routine to provide different behavior.
1347  bool IsVolatile, unsigned NumOutputs,
1348  unsigned NumInputs, IdentifierInfo **Names,
1349  MultiExprArg Constraints, MultiExprArg Exprs,
1350  Expr *AsmString, MultiExprArg Clobbers,
1351  SourceLocation RParenLoc) {
1352  return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1353  NumInputs, Names, Constraints, Exprs,
1354  AsmString, Clobbers, RParenLoc);
1355  }
1356 
1357  /// \brief Build a new MS style inline asm statement.
1358  ///
1359  /// By default, performs semantic analysis to build the new statement.
1360  /// Subclasses may override this routine to provide different behavior.
1362  ArrayRef<Token> AsmToks,
1363  StringRef AsmString,
1364  unsigned NumOutputs, unsigned NumInputs,
1365  ArrayRef<StringRef> Constraints,
1366  ArrayRef<StringRef> Clobbers,
1367  ArrayRef<Expr*> Exprs,
1368  SourceLocation EndLoc) {
1369  return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1370  NumOutputs, NumInputs,
1371  Constraints, Clobbers, Exprs, EndLoc);
1372  }
1373 
1374  /// \brief Build a new co_return statement.
1375  ///
1376  /// By default, performs semantic analysis to build the new statement.
1377  /// Subclasses may override this routine to provide different behavior.
1379  bool IsImplicit) {
1380  return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1381  }
1382 
1383  /// \brief Build a new co_await expression.
1384  ///
1385  /// By default, performs semantic analysis to build the new expression.
1386  /// Subclasses may override this routine to provide different behavior.
1388  bool IsImplicit) {
1389  return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Result, IsImplicit);
1390  }
1391 
1392  /// \brief Build a new co_await expression.
1393  ///
1394  /// By default, performs semantic analysis to build the new expression.
1395  /// Subclasses may override this routine to provide different behavior.
1397  Expr *Result,
1398  UnresolvedLookupExpr *Lookup) {
1399  return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1400  }
1401 
1402  /// \brief Build a new co_yield expression.
1403  ///
1404  /// By default, performs semantic analysis to build the new expression.
1405  /// Subclasses may override this routine to provide different behavior.
1407  return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1408  }
1409 
1411  return getSema().BuildCoroutineBodyStmt(Args);
1412  }
1413 
1414  /// \brief Build a new Objective-C \@try statement.
1415  ///
1416  /// By default, performs semantic analysis to build the new statement.
1417  /// Subclasses may override this routine to provide different behavior.
1419  Stmt *TryBody,
1420  MultiStmtArg CatchStmts,
1421  Stmt *Finally) {
1422  return getSema().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1423  Finally);
1424  }
1425 
1426  /// \brief Rebuild an Objective-C exception declaration.
1427  ///
1428  /// By default, performs semantic analysis to build the new declaration.
1429  /// Subclasses may override this routine to provide different behavior.
1431  TypeSourceInfo *TInfo, QualType T) {
1432  return getSema().BuildObjCExceptionDecl(TInfo, T,
1433  ExceptionDecl->getInnerLocStart(),
1434  ExceptionDecl->getLocation(),
1435  ExceptionDecl->getIdentifier());
1436  }
1437 
1438  /// \brief Build a new Objective-C \@catch statement.
1439  ///
1440  /// By default, performs semantic analysis to build the new statement.
1441  /// Subclasses may override this routine to provide different behavior.
1443  SourceLocation RParenLoc,
1444  VarDecl *Var,
1445  Stmt *Body) {
1446  return getSema().ActOnObjCAtCatchStmt(AtLoc, RParenLoc,
1447  Var, Body);
1448  }
1449 
1450  /// \brief Build a new Objective-C \@finally statement.
1451  ///
1452  /// By default, performs semantic analysis to build the new statement.
1453  /// Subclasses may override this routine to provide different behavior.
1455  Stmt *Body) {
1456  return getSema().ActOnObjCAtFinallyStmt(AtLoc, Body);
1457  }
1458 
1459  /// \brief Build a new Objective-C \@throw statement.
1460  ///
1461  /// By default, performs semantic analysis to build the new statement.
1462  /// Subclasses may override this routine to provide different behavior.
1464  Expr *Operand) {
1465  return getSema().BuildObjCAtThrowStmt(AtLoc, Operand);
1466  }
1467 
1468  /// \brief Build a new OpenMP executable directive.
1469  ///
1470  /// By default, performs semantic analysis to build the new statement.
1471  /// Subclasses may override this routine to provide different behavior.
1473  DeclarationNameInfo DirName,
1474  OpenMPDirectiveKind CancelRegion,
1475  ArrayRef<OMPClause *> Clauses,
1476  Stmt *AStmt, SourceLocation StartLoc,
1477  SourceLocation EndLoc) {
1478  return getSema().ActOnOpenMPExecutableDirective(
1479  Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1480  }
1481 
1482  /// \brief Build a new OpenMP 'if' clause.
1483  ///
1484  /// By default, performs semantic analysis to build the new OpenMP clause.
1485  /// Subclasses may override this routine to provide different behavior.
1487  Expr *Condition, SourceLocation StartLoc,
1488  SourceLocation LParenLoc,
1489  SourceLocation NameModifierLoc,
1491  SourceLocation EndLoc) {
1492  return getSema().ActOnOpenMPIfClause(NameModifier, Condition, StartLoc,
1493  LParenLoc, NameModifierLoc, ColonLoc,
1494  EndLoc);
1495  }
1496 
1497  /// \brief Build a new OpenMP 'final' clause.
1498  ///
1499  /// By default, performs semantic analysis to build the new OpenMP clause.
1500  /// Subclasses may override this routine to provide different behavior.
1502  SourceLocation LParenLoc,
1503  SourceLocation EndLoc) {
1504  return getSema().ActOnOpenMPFinalClause(Condition, StartLoc, LParenLoc,
1505  EndLoc);
1506  }
1507 
1508  /// \brief Build a new OpenMP 'num_threads' clause.
1509  ///
1510  /// By default, performs semantic analysis to build the new OpenMP clause.
1511  /// Subclasses may override this routine to provide different behavior.
1513  SourceLocation StartLoc,
1514  SourceLocation LParenLoc,
1515  SourceLocation EndLoc) {
1516  return getSema().ActOnOpenMPNumThreadsClause(NumThreads, StartLoc,
1517  LParenLoc, EndLoc);
1518  }
1519 
1520  /// \brief Build a new OpenMP 'safelen' clause.
1521  ///
1522  /// By default, performs semantic analysis to build the new OpenMP clause.
1523  /// Subclasses may override this routine to provide different behavior.
1525  SourceLocation LParenLoc,
1526  SourceLocation EndLoc) {
1527  return getSema().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc, EndLoc);
1528  }
1529 
1530  /// \brief Build a new OpenMP 'simdlen' clause.
1531  ///
1532  /// By default, performs semantic analysis to build the new OpenMP clause.
1533  /// Subclasses may override this routine to provide different behavior.
1535  SourceLocation LParenLoc,
1536  SourceLocation EndLoc) {
1537  return getSema().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc, EndLoc);
1538  }
1539 
1540  /// \brief Build a new OpenMP 'collapse' clause.
1541  ///
1542  /// By default, performs semantic analysis to build the new OpenMP clause.
1543  /// Subclasses may override this routine to provide different behavior.
1545  SourceLocation LParenLoc,
1546  SourceLocation EndLoc) {
1547  return getSema().ActOnOpenMPCollapseClause(Num, StartLoc, LParenLoc,
1548  EndLoc);
1549  }
1550 
1551  /// \brief Build a new OpenMP 'default' clause.
1552  ///
1553  /// By default, performs semantic analysis to build the new OpenMP clause.
1554  /// Subclasses may override this routine to provide different behavior.
1556  SourceLocation KindKwLoc,
1557  SourceLocation StartLoc,
1558  SourceLocation LParenLoc,
1559  SourceLocation EndLoc) {
1560  return getSema().ActOnOpenMPDefaultClause(Kind, KindKwLoc,
1561  StartLoc, LParenLoc, EndLoc);
1562  }
1563 
1564  /// \brief Build a new OpenMP 'proc_bind' clause.
1565  ///
1566  /// By default, performs semantic analysis to build the new OpenMP clause.
1567  /// Subclasses may override this routine to provide different behavior.
1569  SourceLocation KindKwLoc,
1570  SourceLocation StartLoc,
1571  SourceLocation LParenLoc,
1572  SourceLocation EndLoc) {
1573  return getSema().ActOnOpenMPProcBindClause(Kind, KindKwLoc,
1574  StartLoc, LParenLoc, EndLoc);
1575  }
1576 
1577  /// \brief Build a new OpenMP 'schedule' clause.
1578  ///
1579  /// By default, performs semantic analysis to build the new OpenMP clause.
1580  /// Subclasses may override this routine to provide different behavior.
1583  OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1584  SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1585  SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1586  return getSema().ActOnOpenMPScheduleClause(
1587  M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1588  CommaLoc, EndLoc);
1589  }
1590 
1591  /// \brief Build a new OpenMP 'ordered' clause.
1592  ///
1593  /// By default, performs semantic analysis to build the new OpenMP clause.
1594  /// Subclasses may override this routine to provide different behavior.
1596  SourceLocation EndLoc,
1597  SourceLocation LParenLoc, Expr *Num) {
1598  return getSema().ActOnOpenMPOrderedClause(StartLoc, EndLoc, LParenLoc, Num);
1599  }
1600 
1601  /// \brief Build a new OpenMP 'private' clause.
1602  ///
1603  /// By default, performs semantic analysis to build the new OpenMP clause.
1604  /// Subclasses may override this routine to provide different behavior.
1606  SourceLocation StartLoc,
1607  SourceLocation LParenLoc,
1608  SourceLocation EndLoc) {
1609  return getSema().ActOnOpenMPPrivateClause(VarList, StartLoc, LParenLoc,
1610  EndLoc);
1611  }
1612 
1613  /// \brief Build a new OpenMP 'firstprivate' clause.
1614  ///
1615  /// By default, performs semantic analysis to build the new OpenMP clause.
1616  /// Subclasses may override this routine to provide different behavior.
1618  SourceLocation StartLoc,
1619  SourceLocation LParenLoc,
1620  SourceLocation EndLoc) {
1621  return getSema().ActOnOpenMPFirstprivateClause(VarList, StartLoc, LParenLoc,
1622  EndLoc);
1623  }
1624 
1625  /// \brief Build a new OpenMP 'lastprivate' clause.
1626  ///
1627  /// By default, performs semantic analysis to build the new OpenMP clause.
1628  /// Subclasses may override this routine to provide different behavior.
1630  SourceLocation StartLoc,
1631  SourceLocation LParenLoc,
1632  SourceLocation EndLoc) {
1633  return getSema().ActOnOpenMPLastprivateClause(VarList, StartLoc, LParenLoc,
1634  EndLoc);
1635  }
1636 
1637  /// \brief Build a new OpenMP 'shared' clause.
1638  ///
1639  /// By default, performs semantic analysis to build the new OpenMP clause.
1640  /// Subclasses may override this routine to provide different behavior.
1642  SourceLocation StartLoc,
1643  SourceLocation LParenLoc,
1644  SourceLocation EndLoc) {
1645  return getSema().ActOnOpenMPSharedClause(VarList, StartLoc, LParenLoc,
1646  EndLoc);
1647  }
1648 
1649  /// \brief Build a new OpenMP 'reduction' clause.
1650  ///
1651  /// By default, performs semantic analysis to build the new statement.
1652  /// Subclasses may override this routine to provide different behavior.
1654  SourceLocation StartLoc,
1655  SourceLocation LParenLoc,
1657  SourceLocation EndLoc,
1658  CXXScopeSpec &ReductionIdScopeSpec,
1659  const DeclarationNameInfo &ReductionId,
1660  ArrayRef<Expr *> UnresolvedReductions) {
1661  return getSema().ActOnOpenMPReductionClause(
1662  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1663  ReductionId, UnresolvedReductions);
1664  }
1665 
1666  /// Build a new OpenMP 'task_reduction' clause.
1667  ///
1668  /// By default, performs semantic analysis to build the new statement.
1669  /// Subclasses may override this routine to provide different behavior.
1671  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1673  CXXScopeSpec &ReductionIdScopeSpec,
1674  const DeclarationNameInfo &ReductionId,
1675  ArrayRef<Expr *> UnresolvedReductions) {
1676  return getSema().ActOnOpenMPTaskReductionClause(
1677  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1678  ReductionId, UnresolvedReductions);
1679  }
1680 
1681  /// Build a new OpenMP 'in_reduction' clause.
1682  ///
1683  /// By default, performs semantic analysis to build the new statement.
1684  /// Subclasses may override this routine to provide different behavior.
1685  OMPClause *
1688  SourceLocation EndLoc,
1689  CXXScopeSpec &ReductionIdScopeSpec,
1690  const DeclarationNameInfo &ReductionId,
1691  ArrayRef<Expr *> UnresolvedReductions) {
1692  return getSema().ActOnOpenMPInReductionClause(
1693  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1694  ReductionId, UnresolvedReductions);
1695  }
1696 
1697  /// \brief Build a new OpenMP 'linear' clause.
1698  ///
1699  /// By default, performs semantic analysis to build the new OpenMP clause.
1700  /// Subclasses may override this routine to provide different behavior.
1702  SourceLocation StartLoc,
1703  SourceLocation LParenLoc,
1707  SourceLocation EndLoc) {
1708  return getSema().ActOnOpenMPLinearClause(VarList, Step, StartLoc, LParenLoc,
1709  Modifier, ModifierLoc, ColonLoc,
1710  EndLoc);
1711  }
1712 
1713  /// \brief Build a new OpenMP 'aligned' clause.
1714  ///
1715  /// By default, performs semantic analysis to build the new OpenMP clause.
1716  /// Subclasses may override this routine to provide different behavior.
1718  SourceLocation StartLoc,
1719  SourceLocation LParenLoc,
1721  SourceLocation EndLoc) {
1722  return getSema().ActOnOpenMPAlignedClause(VarList, Alignment, StartLoc,
1723  LParenLoc, ColonLoc, EndLoc);
1724  }
1725 
1726  /// \brief Build a new OpenMP 'copyin' clause.
1727  ///
1728  /// By default, performs semantic analysis to build the new OpenMP clause.
1729  /// Subclasses may override this routine to provide different behavior.
1731  SourceLocation StartLoc,
1732  SourceLocation LParenLoc,
1733  SourceLocation EndLoc) {
1734  return getSema().ActOnOpenMPCopyinClause(VarList, StartLoc, LParenLoc,
1735  EndLoc);
1736  }
1737 
1738  /// \brief Build a new OpenMP 'copyprivate' clause.
1739  ///
1740  /// By default, performs semantic analysis to build the new OpenMP clause.
1741  /// Subclasses may override this routine to provide different behavior.
1743  SourceLocation StartLoc,
1744  SourceLocation LParenLoc,
1745  SourceLocation EndLoc) {
1746  return getSema().ActOnOpenMPCopyprivateClause(VarList, StartLoc, LParenLoc,
1747  EndLoc);
1748  }
1749 
1750  /// \brief Build a new OpenMP 'flush' pseudo clause.
1751  ///
1752  /// By default, performs semantic analysis to build the new OpenMP clause.
1753  /// Subclasses may override this routine to provide different behavior.
1755  SourceLocation StartLoc,
1756  SourceLocation LParenLoc,
1757  SourceLocation EndLoc) {
1758  return getSema().ActOnOpenMPFlushClause(VarList, StartLoc, LParenLoc,
1759  EndLoc);
1760  }
1761 
1762  /// \brief Build a new OpenMP 'depend' pseudo clause.
1763  ///
1764  /// By default, performs semantic analysis to build the new OpenMP clause.
1765  /// Subclasses may override this routine to provide different behavior.
1766  OMPClause *
1769  SourceLocation StartLoc, SourceLocation LParenLoc,
1770  SourceLocation EndLoc) {
1771  return getSema().ActOnOpenMPDependClause(DepKind, DepLoc, ColonLoc, VarList,
1772  StartLoc, LParenLoc, EndLoc);
1773  }
1774 
1775  /// \brief Build a new OpenMP 'device' clause.
1776  ///
1777  /// By default, performs semantic analysis to build the new statement.
1778  /// Subclasses may override this routine to provide different behavior.
1780  SourceLocation LParenLoc,
1781  SourceLocation EndLoc) {
1782  return getSema().ActOnOpenMPDeviceClause(Device, StartLoc, LParenLoc,
1783  EndLoc);
1784  }
1785 
1786  /// \brief Build a new OpenMP 'map' clause.
1787  ///
1788  /// By default, performs semantic analysis to build the new OpenMP clause.
1789  /// Subclasses may override this routine to provide different behavior.
1790  OMPClause *
1792  OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
1794  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1795  SourceLocation LParenLoc, SourceLocation EndLoc) {
1796  return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType,
1797  IsMapTypeImplicit, MapLoc, ColonLoc,
1798  VarList, StartLoc, LParenLoc, EndLoc);
1799  }
1800 
1801  /// \brief Build a new OpenMP 'num_teams' clause.
1802  ///
1803  /// By default, performs semantic analysis to build the new statement.
1804  /// Subclasses may override this routine to provide different behavior.
1806  SourceLocation LParenLoc,
1807  SourceLocation EndLoc) {
1808  return getSema().ActOnOpenMPNumTeamsClause(NumTeams, StartLoc, LParenLoc,
1809  EndLoc);
1810  }
1811 
1812  /// \brief Build a new OpenMP 'thread_limit' clause.
1813  ///
1814  /// By default, performs semantic analysis to build the new statement.
1815  /// Subclasses may override this routine to provide different behavior.
1817  SourceLocation StartLoc,
1818  SourceLocation LParenLoc,
1819  SourceLocation EndLoc) {
1820  return getSema().ActOnOpenMPThreadLimitClause(ThreadLimit, StartLoc,
1821  LParenLoc, EndLoc);
1822  }
1823 
1824  /// \brief Build a new OpenMP 'priority' clause.
1825  ///
1826  /// By default, performs semantic analysis to build the new statement.
1827  /// Subclasses may override this routine to provide different behavior.
1829  SourceLocation LParenLoc,
1830  SourceLocation EndLoc) {
1831  return getSema().ActOnOpenMPPriorityClause(Priority, StartLoc, LParenLoc,
1832  EndLoc);
1833  }
1834 
1835  /// \brief Build a new OpenMP 'grainsize' clause.
1836  ///
1837  /// By default, performs semantic analysis to build the new statement.
1838  /// Subclasses may override this routine to provide different behavior.
1840  SourceLocation LParenLoc,
1841  SourceLocation EndLoc) {
1842  return getSema().ActOnOpenMPGrainsizeClause(Grainsize, StartLoc, LParenLoc,
1843  EndLoc);
1844  }
1845 
1846  /// \brief Build a new OpenMP 'num_tasks' clause.
1847  ///
1848  /// By default, performs semantic analysis to build the new statement.
1849  /// Subclasses may override this routine to provide different behavior.
1851  SourceLocation LParenLoc,
1852  SourceLocation EndLoc) {
1853  return getSema().ActOnOpenMPNumTasksClause(NumTasks, StartLoc, LParenLoc,
1854  EndLoc);
1855  }
1856 
1857  /// \brief Build a new OpenMP 'hint' clause.
1858  ///
1859  /// By default, performs semantic analysis to build the new statement.
1860  /// Subclasses may override this routine to provide different behavior.
1862  SourceLocation LParenLoc,
1863  SourceLocation EndLoc) {
1864  return getSema().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc, EndLoc);
1865  }
1866 
1867  /// \brief Build a new OpenMP 'dist_schedule' clause.
1868  ///
1869  /// By default, performs semantic analysis to build the new OpenMP clause.
1870  /// Subclasses may override this routine to provide different behavior.
1871  OMPClause *
1873  Expr *ChunkSize, SourceLocation StartLoc,
1874  SourceLocation LParenLoc, SourceLocation KindLoc,
1875  SourceLocation CommaLoc, SourceLocation EndLoc) {
1876  return getSema().ActOnOpenMPDistScheduleClause(
1877  Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
1878  }
1879 
1880  /// \brief Build a new OpenMP 'to' clause.
1881  ///
1882  /// By default, performs semantic analysis to build the new statement.
1883  /// Subclasses may override this routine to provide different behavior.
1885  SourceLocation StartLoc,
1886  SourceLocation LParenLoc,
1887  SourceLocation EndLoc) {
1888  return getSema().ActOnOpenMPToClause(VarList, StartLoc, LParenLoc, EndLoc);
1889  }
1890 
1891  /// \brief Build a new OpenMP 'from' clause.
1892  ///
1893  /// By default, performs semantic analysis to build the new statement.
1894  /// Subclasses may override this routine to provide different behavior.
1896  SourceLocation StartLoc,
1897  SourceLocation LParenLoc,
1898  SourceLocation EndLoc) {
1899  return getSema().ActOnOpenMPFromClause(VarList, StartLoc, LParenLoc,
1900  EndLoc);
1901  }
1902 
1903  /// Build a new OpenMP 'use_device_ptr' clause.
1904  ///
1905  /// By default, performs semantic analysis to build the new OpenMP clause.
1906  /// Subclasses may override this routine to provide different behavior.
1908  SourceLocation StartLoc,
1909  SourceLocation LParenLoc,
1910  SourceLocation EndLoc) {
1911  return getSema().ActOnOpenMPUseDevicePtrClause(VarList, StartLoc, LParenLoc,
1912  EndLoc);
1913  }
1914 
1915  /// Build a new OpenMP 'is_device_ptr' clause.
1916  ///
1917  /// By default, performs semantic analysis to build the new OpenMP clause.
1918  /// Subclasses may override this routine to provide different behavior.
1920  SourceLocation StartLoc,
1921  SourceLocation LParenLoc,
1922  SourceLocation EndLoc) {
1923  return getSema().ActOnOpenMPIsDevicePtrClause(VarList, StartLoc, LParenLoc,
1924  EndLoc);
1925  }
1926 
1927  /// \brief Rebuild the operand to an Objective-C \@synchronized statement.
1928  ///
1929  /// By default, performs semantic analysis to build the new statement.
1930  /// Subclasses may override this routine to provide different behavior.
1932  Expr *object) {
1933  return getSema().ActOnObjCAtSynchronizedOperand(atLoc, object);
1934  }
1935 
1936  /// \brief Build a new Objective-C \@synchronized statement.
1937  ///
1938  /// By default, performs semantic analysis to build the new statement.
1939  /// Subclasses may override this routine to provide different behavior.
1941  Expr *Object, Stmt *Body) {
1942  return getSema().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
1943  }
1944 
1945  /// \brief Build a new Objective-C \@autoreleasepool statement.
1946  ///
1947  /// By default, performs semantic analysis to build the new statement.
1948  /// Subclasses may override this routine to provide different behavior.
1950  Stmt *Body) {
1951  return getSema().ActOnObjCAutoreleasePoolStmt(AtLoc, Body);
1952  }
1953 
1954  /// \brief Build a new Objective-C fast enumeration statement.
1955  ///
1956  /// By default, performs semantic analysis to build the new statement.
1957  /// Subclasses may override this routine to provide different behavior.
1959  Stmt *Element,
1960  Expr *Collection,
1961  SourceLocation RParenLoc,
1962  Stmt *Body) {
1963  StmtResult ForEachStmt = getSema().ActOnObjCForCollectionStmt(ForLoc,
1964  Element,
1965  Collection,
1966  RParenLoc);
1967  if (ForEachStmt.isInvalid())
1968  return StmtError();
1969 
1970  return getSema().FinishObjCForCollectionStmt(ForEachStmt.get(), Body);
1971  }
1972 
1973  /// \brief Build a new C++ exception declaration.
1974  ///
1975  /// By default, performs semantic analysis to build the new decaration.
1976  /// Subclasses may override this routine to provide different behavior.
1979  SourceLocation StartLoc,
1980  SourceLocation IdLoc,
1981  IdentifierInfo *Id) {
1982  VarDecl *Var = getSema().BuildExceptionDeclaration(nullptr, Declarator,
1983  StartLoc, IdLoc, Id);
1984  if (Var)
1985  getSema().CurContext->addDecl(Var);
1986  return Var;
1987  }
1988 
1989  /// \brief Build a new C++ catch statement.
1990  ///
1991  /// By default, performs semantic analysis to build the new statement.
1992  /// Subclasses may override this routine to provide different behavior.
1994  VarDecl *ExceptionDecl,
1995  Stmt *Handler) {
1996  return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
1997  Handler));
1998  }
1999 
2000  /// \brief Build a new C++ try statement.
2001  ///
2002  /// By default, performs semantic analysis to build the new statement.
2003  /// Subclasses may override this routine to provide different behavior.
2005  ArrayRef<Stmt *> Handlers) {
2006  return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2007  }
2008 
2009  /// \brief Build a new C++0x range-based for statement.
2010  ///
2011  /// By default, performs semantic analysis to build the new statement.
2012  /// Subclasses may override this routine to provide different behavior.
2014  SourceLocation CoawaitLoc,
2016  Stmt *Range, Stmt *Begin, Stmt *End,
2017  Expr *Cond, Expr *Inc,
2018  Stmt *LoopVar,
2019  SourceLocation RParenLoc) {
2020  // If we've just learned that the range is actually an Objective-C
2021  // collection, treat this as an Objective-C fast enumeration loop.
2022  if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2023  if (RangeStmt->isSingleDecl()) {
2024  if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2025  if (RangeVar->isInvalidDecl())
2026  return StmtError();
2027 
2028  Expr *RangeExpr = RangeVar->getInit();
2029  if (!RangeExpr->isTypeDependent() &&
2030  RangeExpr->getType()->isObjCObjectPointerType())
2031  return getSema().ActOnObjCForCollectionStmt(ForLoc, LoopVar, RangeExpr,
2032  RParenLoc);
2033  }
2034  }
2035  }
2036 
2037  return getSema().BuildCXXForRangeStmt(ForLoc, CoawaitLoc, ColonLoc,
2038  Range, Begin, End,
2039  Cond, Inc, LoopVar, RParenLoc,
2041  }
2042 
2043  /// \brief Build a new C++0x range-based for statement.
2044  ///
2045  /// By default, performs semantic analysis to build the new statement.
2046  /// Subclasses may override this routine to provide different behavior.
2048  bool IsIfExists,
2049  NestedNameSpecifierLoc QualifierLoc,
2050  DeclarationNameInfo NameInfo,
2051  Stmt *Nested) {
2052  return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2053  QualifierLoc, NameInfo, Nested);
2054  }
2055 
2056  /// \brief Attach body to a C++0x range-based for statement.
2057  ///
2058  /// By default, performs semantic analysis to finish the new statement.
2059  /// Subclasses may override this routine to provide different behavior.
2061  return getSema().FinishCXXForRangeStmt(ForRange, Body);
2062  }
2063 
2065  Stmt *TryBlock, Stmt *Handler) {
2066  return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2067  }
2068 
2070  Stmt *Block) {
2071  return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2072  }
2073 
2075  return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2076  }
2077 
2078  /// \brief Build a new predefined expression.
2079  ///
2080  /// By default, performs semantic analysis to build the new expression.
2081  /// Subclasses may override this routine to provide different behavior.
2084  return getSema().BuildPredefinedExpr(Loc, IT);
2085  }
2086 
2087  /// \brief Build a new expression that references a declaration.
2088  ///
2089  /// By default, performs semantic analysis to build the new expression.
2090  /// Subclasses may override this routine to provide different behavior.
2092  LookupResult &R,
2093  bool RequiresADL) {
2094  return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2095  }
2096 
2097 
2098  /// \brief Build a new expression that references a declaration.
2099  ///
2100  /// By default, performs semantic analysis to build the new expression.
2101  /// Subclasses may override this routine to provide different behavior.
2103  ValueDecl *VD,
2104  const DeclarationNameInfo &NameInfo,
2105  TemplateArgumentListInfo *TemplateArgs) {
2106  CXXScopeSpec SS;
2107  SS.Adopt(QualifierLoc);
2108 
2109  // FIXME: loses template args.
2110 
2111  return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD);
2112  }
2113 
2114  /// \brief Build a new expression in parentheses.
2115  ///
2116  /// By default, performs semantic analysis to build the new expression.
2117  /// Subclasses may override this routine to provide different behavior.
2119  SourceLocation RParen) {
2120  return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2121  }
2122 
2123  /// \brief Build a new pseudo-destructor expression.
2124  ///
2125  /// By default, performs semantic analysis to build the new expression.
2126  /// Subclasses may override this routine to provide different behavior.
2127  ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base,
2128  SourceLocation OperatorLoc,
2129  bool isArrow,
2130  CXXScopeSpec &SS,
2131  TypeSourceInfo *ScopeType,
2132  SourceLocation CCLoc,
2133  SourceLocation TildeLoc,
2134  PseudoDestructorTypeStorage Destroyed);
2135 
2136  /// \brief Build a new unary operator expression.
2137  ///
2138  /// By default, performs semantic analysis to build the new expression.
2139  /// Subclasses may override this routine to provide different behavior.
2141  UnaryOperatorKind Opc,
2142  Expr *SubExpr) {
2143  return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2144  }
2145 
2146  /// \brief Build a new builtin offsetof expression.
2147  ///
2148  /// By default, performs semantic analysis to build the new expression.
2149  /// Subclasses may override this routine to provide different behavior.
2153  SourceLocation RParenLoc) {
2154  return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2155  RParenLoc);
2156  }
2157 
2158  /// \brief Build a new sizeof, alignof or vec_step expression with a
2159  /// type argument.
2160  ///
2161  /// By default, performs semantic analysis to build the new expression.
2162  /// Subclasses may override this routine to provide different behavior.
2164  SourceLocation OpLoc,
2165  UnaryExprOrTypeTrait ExprKind,
2166  SourceRange R) {
2167  return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2168  }
2169 
2170  /// \brief Build a new sizeof, alignof or vec step expression with an
2171  /// expression argument.
2172  ///
2173  /// By default, performs semantic analysis to build the new expression.
2174  /// Subclasses may override this routine to provide different behavior.
2176  UnaryExprOrTypeTrait ExprKind,
2177  SourceRange R) {
2178  ExprResult Result
2179  = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2180  if (Result.isInvalid())
2181  return ExprError();
2182 
2183  return Result;
2184  }
2185 
2186  /// \brief Build a new array subscript expression.
2187  ///
2188  /// By default, performs semantic analysis to build the new expression.
2189  /// Subclasses may override this routine to provide different behavior.
2191  SourceLocation LBracketLoc,
2192  Expr *RHS,
2193  SourceLocation RBracketLoc) {
2194  return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2195  LBracketLoc, RHS,
2196  RBracketLoc);
2197  }
2198 
2199  /// \brief Build a new array section expression.
2200  ///
2201  /// By default, performs semantic analysis to build the new expression.
2202  /// Subclasses may override this routine to provide different behavior.
2204  Expr *LowerBound,
2205  SourceLocation ColonLoc, Expr *Length,
2206  SourceLocation RBracketLoc) {
2207  return getSema().ActOnOMPArraySectionExpr(Base, LBracketLoc, LowerBound,
2208  ColonLoc, Length, RBracketLoc);
2209  }
2210 
2211  /// \brief Build a new call expression.
2212  ///
2213  /// By default, performs semantic analysis to build the new expression.
2214  /// Subclasses may override this routine to provide different behavior.
2216  MultiExprArg Args,
2217  SourceLocation RParenLoc,
2218  Expr *ExecConfig = nullptr) {
2219  return getSema().ActOnCallExpr(/*Scope=*/nullptr, Callee, LParenLoc,
2220  Args, RParenLoc, ExecConfig);
2221  }
2222 
2223  /// \brief Build a new member access expression.
2224  ///
2225  /// By default, performs semantic analysis to build the new expression.
2226  /// Subclasses may override this routine to provide different behavior.
2228  bool isArrow,
2229  NestedNameSpecifierLoc QualifierLoc,
2230  SourceLocation TemplateKWLoc,
2231  const DeclarationNameInfo &MemberNameInfo,
2232  ValueDecl *Member,
2233  NamedDecl *FoundDecl,
2234  const TemplateArgumentListInfo *ExplicitTemplateArgs,
2235  NamedDecl *FirstQualifierInScope) {
2236  ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base,
2237  isArrow);
2238  if (!Member->getDeclName()) {
2239  // We have a reference to an unnamed field. This is always the
2240  // base of an anonymous struct/union member access, i.e. the
2241  // field is always of record type.
2242  assert(!QualifierLoc && "Can't have an unnamed field with a qualifier!");
2243  assert(Member->getType()->isRecordType() &&
2244  "unnamed member not of record type?");
2245 
2246  BaseResult =
2247  getSema().PerformObjectMemberConversion(BaseResult.get(),
2248  QualifierLoc.getNestedNameSpecifier(),
2249  FoundDecl, Member);
2250  if (BaseResult.isInvalid())
2251  return ExprError();
2252  Base = BaseResult.get();
2253  ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind();
2254  MemberExpr *ME = new (getSema().Context)
2255  MemberExpr(Base, isArrow, OpLoc, Member, MemberNameInfo,
2256  cast<FieldDecl>(Member)->getType(), VK, OK_Ordinary);
2257  return ME;
2258  }
2259 
2260  CXXScopeSpec SS;
2261  SS.Adopt(QualifierLoc);
2262 
2263  Base = BaseResult.get();
2264  QualType BaseType = Base->getType();
2265 
2266  if (isArrow && !BaseType->isPointerType())
2267  return ExprError();
2268 
2269  // FIXME: this involves duplicating earlier analysis in a lot of
2270  // cases; we should avoid this when possible.
2271  LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
2272  R.addDecl(FoundDecl);
2273  R.resolveKind();
2274 
2275  return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
2276  SS, TemplateKWLoc,
2277  FirstQualifierInScope,
2278  R, ExplicitTemplateArgs,
2279  /*S*/nullptr);
2280  }
2281 
2282  /// \brief Build a new binary operator expression.
2283  ///
2284  /// By default, performs semantic analysis to build the new expression.
2285  /// Subclasses may override this routine to provide different behavior.
2287  BinaryOperatorKind Opc,
2288  Expr *LHS, Expr *RHS) {
2289  return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS);
2290  }
2291 
2292  /// \brief Build a new conditional operator expression.
2293  ///
2294  /// By default, performs semantic analysis to build the new expression.
2295  /// Subclasses may override this routine to provide different behavior.
2297  SourceLocation QuestionLoc,
2298  Expr *LHS,
2300  Expr *RHS) {
2301  return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
2302  LHS, RHS);
2303  }
2304 
2305  /// \brief Build a new C-style cast expression.
2306  ///
2307  /// By default, performs semantic analysis to build the new expression.
2308  /// Subclasses may override this routine to provide different behavior.
2310  TypeSourceInfo *TInfo,
2311  SourceLocation RParenLoc,
2312  Expr *SubExpr) {
2313  return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
2314  SubExpr);
2315  }
2316 
2317  /// \brief Build a new compound literal expression.
2318  ///
2319  /// By default, performs semantic analysis to build the new expression.
2320  /// Subclasses may override this routine to provide different behavior.
2322  TypeSourceInfo *TInfo,
2323  SourceLocation RParenLoc,
2324  Expr *Init) {
2325  return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
2326  Init);
2327  }
2328 
2329  /// \brief Build a new extended vector element access expression.
2330  ///
2331  /// By default, performs semantic analysis to build the new expression.
2332  /// Subclasses may override this routine to provide different behavior.
2334  SourceLocation OpLoc,
2335  SourceLocation AccessorLoc,
2336  IdentifierInfo &Accessor) {
2337 
2338  CXXScopeSpec SS;
2339  DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
2340  return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
2341  OpLoc, /*IsArrow*/ false,
2342  SS, SourceLocation(),
2343  /*FirstQualifierInScope*/ nullptr,
2344  NameInfo,
2345  /* TemplateArgs */ nullptr,
2346  /*S*/ nullptr);
2347  }
2348 
2349  /// \brief Build a new initializer list expression.
2350  ///
2351  /// By default, performs semantic analysis to build the new expression.
2352  /// Subclasses may override this routine to provide different behavior.
2355  SourceLocation RBraceLoc,
2356  QualType ResultTy) {
2357  ExprResult Result
2358  = SemaRef.ActOnInitList(LBraceLoc, Inits, RBraceLoc);
2359  if (Result.isInvalid() || ResultTy->isDependentType())
2360  return Result;
2361 
2362  // Patch in the result type we were given, which may have been computed
2363  // when the initial InitListExpr was built.
2364  InitListExpr *ILE = cast<InitListExpr>((Expr *)Result.get());
2365  ILE->setType(ResultTy);
2366  return Result;
2367  }
2368 
2369  /// \brief Build a new designated initializer expression.
2370  ///
2371  /// By default, performs semantic analysis to build the new expression.
2372  /// Subclasses may override this routine to provide different behavior.
2374  MultiExprArg ArrayExprs,
2375  SourceLocation EqualOrColonLoc,
2376  bool GNUSyntax,
2377  Expr *Init) {
2378  ExprResult Result
2379  = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
2380  Init);
2381  if (Result.isInvalid())
2382  return ExprError();
2383 
2384  return Result;
2385  }
2386 
2387  /// \brief Build a new value-initialized expression.
2388  ///
2389  /// By default, builds the implicit value initialization without performing
2390  /// any semantic analysis. Subclasses may override this routine to provide
2391  /// different behavior.
2393  return new (SemaRef.Context) ImplicitValueInitExpr(T);
2394  }
2395 
2396  /// \brief Build a new \c va_arg expression.
2397  ///
2398  /// By default, performs semantic analysis to build the new expression.
2399  /// Subclasses may override this routine to provide different behavior.
2401  Expr *SubExpr, TypeSourceInfo *TInfo,
2402  SourceLocation RParenLoc) {
2403  return getSema().BuildVAArgExpr(BuiltinLoc,
2404  SubExpr, TInfo,
2405  RParenLoc);
2406  }
2407 
2408  /// \brief Build a new expression list in parentheses.
2409  ///
2410  /// By default, performs semantic analysis to build the new expression.
2411  /// Subclasses may override this routine to provide different behavior.
2413  MultiExprArg SubExprs,
2414  SourceLocation RParenLoc) {
2415  return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
2416  }
2417 
2418  /// \brief Build a new address-of-label expression.
2419  ///
2420  /// By default, performs semantic analysis, using the name of the label
2421  /// rather than attempting to map the label statement itself.
2422  /// Subclasses may override this routine to provide different behavior.
2424  SourceLocation LabelLoc, LabelDecl *Label) {
2425  return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
2426  }
2427 
2428  /// \brief Build a new GNU statement expression.
2429  ///
2430  /// By default, performs semantic analysis to build the new expression.
2431  /// Subclasses may override this routine to provide different behavior.
2433  Stmt *SubStmt,
2434  SourceLocation RParenLoc) {
2435  return getSema().ActOnStmtExpr(LParenLoc, SubStmt, RParenLoc);
2436  }
2437 
2438  /// \brief Build a new __builtin_choose_expr expression.
2439  ///
2440  /// By default, performs semantic analysis to build the new expression.
2441  /// Subclasses may override this routine to provide different behavior.
2443  Expr *Cond, Expr *LHS, Expr *RHS,
2444  SourceLocation RParenLoc) {
2445  return SemaRef.ActOnChooseExpr(BuiltinLoc,
2446  Cond, LHS, RHS,
2447  RParenLoc);
2448  }
2449 
2450  /// \brief Build a new generic selection expression.
2451  ///
2452  /// By default, performs semantic analysis to build the new expression.
2453  /// Subclasses may override this routine to provide different behavior.
2455  SourceLocation DefaultLoc,
2456  SourceLocation RParenLoc,
2457  Expr *ControllingExpr,
2459  ArrayRef<Expr *> Exprs) {
2460  return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
2461  ControllingExpr, Types, Exprs);
2462  }
2463 
2464  /// \brief Build a new overloaded operator call expression.
2465  ///
2466  /// By default, performs semantic analysis to build the new expression.
2467  /// The semantic analysis provides the behavior of template instantiation,
2468  /// copying with transformations that turn what looks like an overloaded
2469  /// operator call into a use of a builtin operator, performing
2470  /// argument-dependent lookup, etc. Subclasses may override this routine to
2471  /// provide different behavior.
2472  ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
2473  SourceLocation OpLoc,
2474  Expr *Callee,
2475  Expr *First,
2476  Expr *Second);
2477 
2478  /// \brief Build a new C++ "named" cast expression, such as static_cast or
2479  /// reinterpret_cast.
2480  ///
2481  /// By default, this routine dispatches to one of the more-specific routines
2482  /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
2483  /// Subclasses may override this routine to provide different behavior.
2485  Stmt::StmtClass Class,
2486  SourceLocation LAngleLoc,
2487  TypeSourceInfo *TInfo,
2488  SourceLocation RAngleLoc,
2489  SourceLocation LParenLoc,
2490  Expr *SubExpr,
2491  SourceLocation RParenLoc) {
2492  switch (Class) {
2493  case Stmt::CXXStaticCastExprClass:
2494  return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
2495  RAngleLoc, LParenLoc,
2496  SubExpr, RParenLoc);
2497 
2498  case Stmt::CXXDynamicCastExprClass:
2499  return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
2500  RAngleLoc, LParenLoc,
2501  SubExpr, RParenLoc);
2502 
2503  case Stmt::CXXReinterpretCastExprClass:
2504  return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
2505  RAngleLoc, LParenLoc,
2506  SubExpr,
2507  RParenLoc);
2508 
2509  case Stmt::CXXConstCastExprClass:
2510  return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
2511  RAngleLoc, LParenLoc,
2512  SubExpr, RParenLoc);
2513 
2514  default:
2515  llvm_unreachable("Invalid C++ named cast");
2516  }
2517  }
2518 
2519  /// \brief Build a new C++ static_cast expression.
2520  ///
2521  /// By default, performs semantic analysis to build the new expression.
2522  /// Subclasses may override this routine to provide different behavior.
2524  SourceLocation LAngleLoc,
2525  TypeSourceInfo *TInfo,
2526  SourceLocation RAngleLoc,
2527  SourceLocation LParenLoc,
2528  Expr *SubExpr,
2529  SourceLocation RParenLoc) {
2530  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
2531  TInfo, SubExpr,
2532  SourceRange(LAngleLoc, RAngleLoc),
2533  SourceRange(LParenLoc, RParenLoc));
2534  }
2535 
2536  /// \brief Build a new C++ dynamic_cast expression.
2537  ///
2538  /// By default, performs semantic analysis to build the new expression.
2539  /// Subclasses may override this routine to provide different behavior.
2541  SourceLocation LAngleLoc,
2542  TypeSourceInfo *TInfo,
2543  SourceLocation RAngleLoc,
2544  SourceLocation LParenLoc,
2545  Expr *SubExpr,
2546  SourceLocation RParenLoc) {
2547  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
2548  TInfo, SubExpr,
2549  SourceRange(LAngleLoc, RAngleLoc),
2550  SourceRange(LParenLoc, RParenLoc));
2551  }
2552 
2553  /// \brief Build a new C++ reinterpret_cast expression.
2554  ///
2555  /// By default, performs semantic analysis to build the new expression.
2556  /// Subclasses may override this routine to provide different behavior.
2558  SourceLocation LAngleLoc,
2559  TypeSourceInfo *TInfo,
2560  SourceLocation RAngleLoc,
2561  SourceLocation LParenLoc,
2562  Expr *SubExpr,
2563  SourceLocation RParenLoc) {
2564  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
2565  TInfo, SubExpr,
2566  SourceRange(LAngleLoc, RAngleLoc),
2567  SourceRange(LParenLoc, RParenLoc));
2568  }
2569 
2570  /// \brief Build a new C++ const_cast expression.
2571  ///
2572  /// By default, performs semantic analysis to build the new expression.
2573  /// Subclasses may override this routine to provide different behavior.
2575  SourceLocation LAngleLoc,
2576  TypeSourceInfo *TInfo,
2577  SourceLocation RAngleLoc,
2578  SourceLocation LParenLoc,
2579  Expr *SubExpr,
2580  SourceLocation RParenLoc) {
2581  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
2582  TInfo, SubExpr,
2583  SourceRange(LAngleLoc, RAngleLoc),
2584  SourceRange(LParenLoc, RParenLoc));
2585  }
2586 
2587  /// \brief Build a new C++ functional-style cast expression.
2588  ///
2589  /// By default, performs semantic analysis to build the new expression.
2590  /// Subclasses may override this routine to provide different behavior.
2592  SourceLocation LParenLoc,
2593  Expr *Sub,
2594  SourceLocation RParenLoc) {
2595  return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
2596  MultiExprArg(&Sub, 1),
2597  RParenLoc);
2598  }
2599 
2600  /// \brief Build a new C++ typeid(type) expression.
2601  ///
2602  /// By default, performs semantic analysis to build the new expression.
2603  /// Subclasses may override this routine to provide different behavior.
2605  SourceLocation TypeidLoc,
2606  TypeSourceInfo *Operand,
2607  SourceLocation RParenLoc) {
2608  return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
2609  RParenLoc);
2610  }
2611 
2612 
2613  /// \brief Build a new C++ typeid(expr) expression.
2614  ///
2615  /// By default, performs semantic analysis to build the new expression.
2616  /// Subclasses may override this routine to provide different behavior.
2618  SourceLocation TypeidLoc,
2619  Expr *Operand,
2620  SourceLocation RParenLoc) {
2621  return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
2622  RParenLoc);
2623  }
2624 
2625  /// \brief Build a new C++ __uuidof(type) expression.
2626  ///
2627  /// By default, performs semantic analysis to build the new expression.
2628  /// Subclasses may override this routine to provide different behavior.
2630  SourceLocation TypeidLoc,
2631  TypeSourceInfo *Operand,
2632  SourceLocation RParenLoc) {
2633  return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand,
2634  RParenLoc);
2635  }
2636 
2637  /// \brief Build a new C++ __uuidof(expr) expression.
2638  ///
2639  /// By default, performs semantic analysis to build the new expression.
2640  /// Subclasses may override this routine to provide different behavior.
2642  SourceLocation TypeidLoc,
2643  Expr *Operand,
2644  SourceLocation RParenLoc) {
2645  return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand,
2646  RParenLoc);
2647  }
2648 
2649  /// \brief Build a new C++ "this" expression.
2650  ///
2651  /// By default, builds a new "this" expression without performing any
2652  /// semantic analysis. Subclasses may override this routine to provide
2653  /// different behavior.
2655  QualType ThisType,
2656  bool isImplicit) {
2657  getSema().CheckCXXThisCapture(ThisLoc);
2658  return new (getSema().Context) CXXThisExpr(ThisLoc, ThisType, isImplicit);
2659  }
2660 
2661  /// \brief Build a new C++ throw expression.
2662  ///
2663  /// By default, performs semantic analysis to build the new expression.
2664  /// Subclasses may override this routine to provide different behavior.
2666  bool IsThrownVariableInScope) {
2667  return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
2668  }
2669 
2670  /// \brief Build a new C++ default-argument expression.
2671  ///
2672  /// By default, builds a new default-argument expression, which does not
2673  /// require any semantic analysis. Subclasses may override this routine to
2674  /// provide different behavior.
2676  ParmVarDecl *Param) {
2677  return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param);
2678  }
2679 
2680  /// \brief Build a new C++11 default-initialization expression.
2681  ///
2682  /// By default, builds a new default field initialization expression, which
2683  /// does not require any semantic analysis. Subclasses may override this
2684  /// routine to provide different behavior.
2686  FieldDecl *Field) {
2687  return CXXDefaultInitExpr::Create(getSema().Context, Loc, Field);
2688  }
2689 
2690  /// \brief Build a new C++ zero-initialization expression.
2691  ///
2692  /// By default, performs semantic analysis to build the new expression.
2693  /// Subclasses may override this routine to provide different behavior.
2695  SourceLocation LParenLoc,
2696  SourceLocation RParenLoc) {
2697  return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc,
2698  None, RParenLoc);
2699  }
2700 
2701  /// \brief Build a new C++ "new" expression.
2702  ///
2703  /// By default, performs semantic analysis to build the new expression.
2704  /// Subclasses may override this routine to provide different behavior.
2706  bool UseGlobal,
2707  SourceLocation PlacementLParen,
2708  MultiExprArg PlacementArgs,
2709  SourceLocation PlacementRParen,
2710  SourceRange TypeIdParens,
2711  QualType AllocatedType,
2712  TypeSourceInfo *AllocatedTypeInfo,
2713  Expr *ArraySize,
2714  SourceRange DirectInitRange,
2715  Expr *Initializer) {
2716  return getSema().BuildCXXNew(StartLoc, UseGlobal,
2717  PlacementLParen,
2718  PlacementArgs,
2719  PlacementRParen,
2720  TypeIdParens,
2721  AllocatedType,
2722  AllocatedTypeInfo,
2723  ArraySize,
2724  DirectInitRange,
2725  Initializer);
2726  }
2727 
2728  /// \brief Build a new C++ "delete" expression.
2729  ///
2730  /// By default, performs semantic analysis to build the new expression.
2731  /// Subclasses may override this routine to provide different behavior.
2733  bool IsGlobalDelete,
2734  bool IsArrayForm,
2735  Expr *Operand) {
2736  return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
2737  Operand);
2738  }
2739 
2740  /// \brief Build a new type trait expression.
2741  ///
2742  /// By default, performs semantic analysis to build the new expression.
2743  /// Subclasses may override this routine to provide different behavior.
2745  SourceLocation StartLoc,
2747  SourceLocation RParenLoc) {
2748  return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
2749  }
2750 
2751  /// \brief Build a new array type trait expression.
2752  ///
2753  /// By default, performs semantic analysis to build the new expression.
2754  /// Subclasses may override this routine to provide different behavior.
2756  SourceLocation StartLoc,
2757  TypeSourceInfo *TSInfo,
2758  Expr *DimExpr,
2759  SourceLocation RParenLoc) {
2760  return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
2761  }
2762 
2763  /// \brief Build a new expression trait expression.
2764  ///
2765  /// By default, performs semantic analysis to build the new expression.
2766  /// Subclasses may override this routine to provide different behavior.
2768  SourceLocation StartLoc,
2769  Expr *Queried,
2770  SourceLocation RParenLoc) {
2771  return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
2772  }
2773 
2774  /// \brief Build a new (previously unresolved) declaration reference
2775  /// expression.
2776  ///
2777  /// By default, performs semantic analysis to build the new expression.
2778  /// Subclasses may override this routine to provide different behavior.
2780  NestedNameSpecifierLoc QualifierLoc,
2781  SourceLocation TemplateKWLoc,
2782  const DeclarationNameInfo &NameInfo,
2783  const TemplateArgumentListInfo *TemplateArgs,
2784  bool IsAddressOfOperand,
2785  TypeSourceInfo **RecoveryTSI) {
2786  CXXScopeSpec SS;
2787  SS.Adopt(QualifierLoc);
2788 
2789  if (TemplateArgs || TemplateKWLoc.isValid())
2790  return getSema().BuildQualifiedTemplateIdExpr(SS, TemplateKWLoc, NameInfo,
2791  TemplateArgs);
2792 
2793  return getSema().BuildQualifiedDeclarationNameExpr(
2794  SS, NameInfo, IsAddressOfOperand, /*S*/nullptr, RecoveryTSI);
2795  }
2796 
2797  /// \brief Build a new template-id expression.
2798  ///
2799  /// By default, performs semantic analysis to build the new expression.
2800  /// Subclasses may override this routine to provide different behavior.
2802  SourceLocation TemplateKWLoc,
2803  LookupResult &R,
2804  bool RequiresADL,
2805  const TemplateArgumentListInfo *TemplateArgs) {
2806  return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
2807  TemplateArgs);
2808  }
2809 
2810  /// \brief Build a new object-construction expression.
2811  ///
2812  /// By default, performs semantic analysis to build the new expression.
2813  /// Subclasses may override this routine to provide different behavior.
2815  SourceLocation Loc,
2816  CXXConstructorDecl *Constructor,
2817  bool IsElidable,
2818  MultiExprArg Args,
2819  bool HadMultipleCandidates,
2820  bool ListInitialization,
2821  bool StdInitListInitialization,
2822  bool RequiresZeroInit,
2823  CXXConstructExpr::ConstructionKind ConstructKind,
2824  SourceRange ParenRange) {
2825  SmallVector<Expr*, 8> ConvertedArgs;
2826  if (getSema().CompleteConstructorCall(Constructor, Args, Loc,
2827  ConvertedArgs))
2828  return ExprError();
2829 
2830  return getSema().BuildCXXConstructExpr(Loc, T, Constructor,
2831  IsElidable,
2832  ConvertedArgs,
2833  HadMultipleCandidates,
2834  ListInitialization,
2835  StdInitListInitialization,
2836  RequiresZeroInit, ConstructKind,
2837  ParenRange);
2838  }
2839 
2840  /// \brief Build a new implicit construction via inherited constructor
2841  /// expression.
2843  CXXConstructorDecl *Constructor,
2844  bool ConstructsVBase,
2845  bool InheritedFromVBase) {
2846  return new (getSema().Context) CXXInheritedCtorInitExpr(
2847  Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
2848  }
2849 
2850  /// \brief Build a new object-construction expression.
2851  ///
2852  /// By default, performs semantic analysis to build the new expression.
2853  /// Subclasses may override this routine to provide different behavior.
2855  SourceLocation LParenLoc,
2856  MultiExprArg Args,
2857  SourceLocation RParenLoc) {
2858  return getSema().BuildCXXTypeConstructExpr(TSInfo,
2859  LParenLoc,
2860  Args,
2861  RParenLoc);
2862  }
2863 
2864  /// \brief Build a new object-construction expression.
2865  ///
2866  /// By default, performs semantic analysis to build the new expression.
2867  /// Subclasses may override this routine to provide different behavior.
2869  SourceLocation LParenLoc,
2870  MultiExprArg Args,
2871  SourceLocation RParenLoc) {
2872  return getSema().BuildCXXTypeConstructExpr(TSInfo,
2873  LParenLoc,
2874  Args,
2875  RParenLoc);
2876  }
2877 
2878  /// \brief Build a new member reference expression.
2879  ///
2880  /// By default, performs semantic analysis to build the new expression.
2881  /// Subclasses may override this routine to provide different behavior.
2883  QualType BaseType,
2884  bool IsArrow,
2885  SourceLocation OperatorLoc,
2886  NestedNameSpecifierLoc QualifierLoc,
2887  SourceLocation TemplateKWLoc,
2888  NamedDecl *FirstQualifierInScope,
2889  const DeclarationNameInfo &MemberNameInfo,
2890  const TemplateArgumentListInfo *TemplateArgs) {
2891  CXXScopeSpec SS;
2892  SS.Adopt(QualifierLoc);
2893 
2894  return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
2895  OperatorLoc, IsArrow,
2896  SS, TemplateKWLoc,
2897  FirstQualifierInScope,
2898  MemberNameInfo,
2899  TemplateArgs, /*S*/nullptr);
2900  }
2901 
2902  /// \brief Build a new member reference expression.
2903  ///
2904  /// By default, performs semantic analysis to build the new expression.
2905  /// Subclasses may override this routine to provide different behavior.
2907  SourceLocation OperatorLoc,
2908  bool IsArrow,
2909  NestedNameSpecifierLoc QualifierLoc,
2910  SourceLocation TemplateKWLoc,
2911  NamedDecl *FirstQualifierInScope,
2912  LookupResult &R,
2913  const TemplateArgumentListInfo *TemplateArgs) {
2914  CXXScopeSpec SS;
2915  SS.Adopt(QualifierLoc);
2916 
2917  return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
2918  OperatorLoc, IsArrow,
2919  SS, TemplateKWLoc,
2920  FirstQualifierInScope,
2921  R, TemplateArgs, /*S*/nullptr);
2922  }
2923 
2924  /// \brief Build a new noexcept expression.
2925  ///
2926  /// By default, performs semantic analysis to build the new expression.
2927  /// Subclasses may override this routine to provide different behavior.
2929  return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
2930  }
2931 
2932  /// \brief Build a new expression to compute the length of a parameter pack.
2934  NamedDecl *Pack,
2935  SourceLocation PackLoc,
2936  SourceLocation RParenLoc,
2937  Optional<unsigned> Length,
2938  ArrayRef<TemplateArgument> PartialArgs) {
2939  return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
2940  RParenLoc, Length, PartialArgs);
2941  }
2942 
2943  /// \brief Build a new Objective-C boxed expression.
2944  ///
2945  /// By default, performs semantic analysis to build the new expression.
2946  /// Subclasses may override this routine to provide different behavior.
2948  return getSema().BuildObjCBoxedExpr(SR, ValueExpr);
2949  }
2950 
2951  /// \brief Build a new Objective-C array literal.
2952  ///
2953  /// By default, performs semantic analysis to build the new expression.
2954  /// Subclasses may override this routine to provide different behavior.
2956  Expr **Elements, unsigned NumElements) {
2957  return getSema().BuildObjCArrayLiteral(Range,
2958  MultiExprArg(Elements, NumElements));
2959  }
2960 
2962  Expr *Base, Expr *Key,
2963  ObjCMethodDecl *getterMethod,
2964  ObjCMethodDecl *setterMethod) {
2965  return getSema().BuildObjCSubscriptExpression(RB, Base, Key,
2966  getterMethod, setterMethod);
2967  }
2968 
2969  /// \brief Build a new Objective-C dictionary literal.
2970  ///
2971  /// By default, performs semantic analysis to build the new expression.
2972  /// Subclasses may override this routine to provide different behavior.
2975  return getSema().BuildObjCDictionaryLiteral(Range, Elements);
2976  }
2977 
2978  /// \brief Build a new Objective-C \@encode expression.
2979  ///
2980  /// By default, performs semantic analysis to build the new expression.
2981  /// Subclasses may override this routine to provide different behavior.
2983  TypeSourceInfo *EncodeTypeInfo,
2984  SourceLocation RParenLoc) {
2985  return SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo, RParenLoc);
2986  }
2987 
2988  /// \brief Build a new Objective-C class message.
2990  Selector Sel,
2991  ArrayRef<SourceLocation> SelectorLocs,
2992  ObjCMethodDecl *Method,
2993  SourceLocation LBracLoc,
2994  MultiExprArg Args,
2995  SourceLocation RBracLoc) {
2996  return SemaRef.BuildClassMessage(ReceiverTypeInfo,
2997  ReceiverTypeInfo->getType(),
2998  /*SuperLoc=*/SourceLocation(),
2999  Sel, Method, LBracLoc, SelectorLocs,
3000  RBracLoc, Args);
3001  }
3002 
3003  /// \brief Build a new Objective-C instance message.
3005  Selector Sel,
3006  ArrayRef<SourceLocation> SelectorLocs,
3007  ObjCMethodDecl *Method,
3008  SourceLocation LBracLoc,
3009  MultiExprArg Args,
3010  SourceLocation RBracLoc) {
3011  return SemaRef.BuildInstanceMessage(Receiver,
3012  Receiver->getType(),
3013  /*SuperLoc=*/SourceLocation(),
3014  Sel, Method, LBracLoc, SelectorLocs,
3015  RBracLoc, Args);
3016  }
3017 
3018  /// \brief Build a new Objective-C instance/class message to 'super'.
3020  Selector Sel,
3021  ArrayRef<SourceLocation> SelectorLocs,
3022  QualType SuperType,
3023  ObjCMethodDecl *Method,
3024  SourceLocation LBracLoc,
3025  MultiExprArg Args,
3026  SourceLocation RBracLoc) {
3027  return Method->isInstanceMethod() ? SemaRef.BuildInstanceMessage(nullptr,
3028  SuperType,
3029  SuperLoc,
3030  Sel, Method, LBracLoc, SelectorLocs,
3031  RBracLoc, Args)
3032  : SemaRef.BuildClassMessage(nullptr,
3033  SuperType,
3034  SuperLoc,
3035  Sel, Method, LBracLoc, SelectorLocs,
3036  RBracLoc, Args);
3037 
3038 
3039  }
3040 
3041  /// \brief Build a new Objective-C ivar reference expression.
3042  ///
3043  /// By default, performs semantic analysis to build the new expression.
3044  /// Subclasses may override this routine to provide different behavior.
3046  SourceLocation IvarLoc,
3047  bool IsArrow, bool IsFreeIvar) {
3048  CXXScopeSpec SS;
3049  DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3050  ExprResult Result = getSema().BuildMemberReferenceExpr(
3051  BaseArg, BaseArg->getType(),
3052  /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3053  /*FirstQualifierInScope=*/nullptr, NameInfo,
3054  /*TemplateArgs=*/nullptr,
3055  /*S=*/nullptr);
3056  if (IsFreeIvar && Result.isUsable())
3057  cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3058  return Result;
3059  }
3060 
3061  /// \brief Build a new Objective-C property reference expression.
3062  ///
3063  /// By default, performs semantic analysis to build the new expression.
3064  /// Subclasses may override this routine to provide different behavior.
3066  ObjCPropertyDecl *Property,
3067  SourceLocation PropertyLoc) {
3068  CXXScopeSpec SS;
3069  DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3070  return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3071  /*FIXME:*/PropertyLoc,
3072  /*IsArrow=*/false,
3073  SS, SourceLocation(),
3074  /*FirstQualifierInScope=*/nullptr,
3075  NameInfo,
3076  /*TemplateArgs=*/nullptr,
3077  /*S=*/nullptr);
3078  }
3079 
3080  /// \brief Build a new Objective-C property reference expression.
3081  ///
3082  /// By default, performs semantic analysis to build the new expression.
3083  /// Subclasses may override this routine to provide different behavior.
3085  ObjCMethodDecl *Getter,
3086  ObjCMethodDecl *Setter,
3087  SourceLocation PropertyLoc) {
3088  // Since these expressions can only be value-dependent, we do not
3089  // need to perform semantic analysis again.
3090  return Owned(
3091  new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3093  PropertyLoc, Base));
3094  }
3095 
3096  /// \brief Build a new Objective-C "isa" expression.
3097  ///
3098  /// By default, performs semantic analysis to build the new expression.
3099  /// Subclasses may override this routine to provide different behavior.
3101  SourceLocation OpLoc, bool IsArrow) {
3102  CXXScopeSpec SS;
3103  DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
3104  return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3105  OpLoc, IsArrow,
3106  SS, SourceLocation(),
3107  /*FirstQualifierInScope=*/nullptr,
3108  NameInfo,
3109  /*TemplateArgs=*/nullptr,
3110  /*S=*/nullptr);
3111  }
3112 
3113  /// \brief Build a new shuffle vector expression.
3114  ///
3115  /// By default, performs semantic analysis to build the new expression.
3116  /// Subclasses may override this routine to provide different behavior.
3118  MultiExprArg SubExprs,
3119  SourceLocation RParenLoc) {
3120  // Find the declaration for __builtin_shufflevector
3121  const IdentifierInfo &Name
3122  = SemaRef.Context.Idents.get("__builtin_shufflevector");
3124  DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
3125  assert(!Lookup.empty() && "No __builtin_shufflevector?");
3126 
3127  // Build a reference to the __builtin_shufflevector builtin
3128  FunctionDecl *Builtin = cast<FunctionDecl>(Lookup.front());
3129  Expr *Callee = new (SemaRef.Context) DeclRefExpr(Builtin, false,
3130  SemaRef.Context.BuiltinFnTy,
3131  VK_RValue, BuiltinLoc);
3132  QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
3133  Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
3134  CK_BuiltinFnToFnPtr).get();
3135 
3136  // Build the CallExpr
3137  ExprResult TheCall = new (SemaRef.Context) CallExpr(
3138  SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
3139  Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc);
3140 
3141  // Type-check the __builtin_shufflevector expression.
3142  return SemaRef.SemaBuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
3143  }
3144 
3145  /// \brief Build a new convert vector expression.
3147  Expr *SrcExpr, TypeSourceInfo *DstTInfo,
3148  SourceLocation RParenLoc) {
3149  return SemaRef.SemaConvertVectorExpr(SrcExpr, DstTInfo,
3150  BuiltinLoc, RParenLoc);
3151  }
3152 
3153  /// \brief Build a new template argument pack expansion.
3154  ///
3155  /// By default, performs semantic analysis to build a new pack expansion
3156  /// for a template argument. Subclasses may override this routine to provide
3157  /// different behavior.
3159  SourceLocation EllipsisLoc,
3160  Optional<unsigned> NumExpansions) {
3161  switch (Pattern.getArgument().getKind()) {
3163  ExprResult Result
3164  = getSema().CheckPackExpansion(Pattern.getSourceExpression(),
3165  EllipsisLoc, NumExpansions);
3166  if (Result.isInvalid())
3167  return TemplateArgumentLoc();
3168 
3169  return TemplateArgumentLoc(Result.get(), Result.get());
3170  }
3171 
3174  Pattern.getArgument().getAsTemplate(),
3175  NumExpansions),
3176  Pattern.getTemplateQualifierLoc(),
3177  Pattern.getTemplateNameLoc(),
3178  EllipsisLoc);
3179 
3186  llvm_unreachable("Pack expansion pattern has no parameter packs");
3187 
3189  if (TypeSourceInfo *Expansion
3190  = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
3191  EllipsisLoc,
3192  NumExpansions))
3193  return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
3194  Expansion);
3195  break;
3196  }
3197 
3198  return TemplateArgumentLoc();
3199  }
3200 
3201  /// \brief Build a new expression pack expansion.
3202  ///
3203  /// By default, performs semantic analysis to build a new pack expansion
3204  /// for an expression. Subclasses may override this routine to provide
3205  /// different behavior.
3207  Optional<unsigned> NumExpansions) {
3208  return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
3209  }
3210 
3211  /// \brief Build a new C++1z fold-expression.
3212  ///
3213  /// By default, performs semantic analysis in order to build a new fold
3214  /// expression.
3216  BinaryOperatorKind Operator,
3217  SourceLocation EllipsisLoc, Expr *RHS,
3218  SourceLocation RParenLoc) {
3219  return getSema().BuildCXXFoldExpr(LParenLoc, LHS, Operator, EllipsisLoc,
3220  RHS, RParenLoc);
3221  }
3222 
3223  /// \brief Build an empty C++1z fold-expression with the given operator.
3224  ///
3225  /// By default, produces the fallback value for the fold-expression, or
3226  /// produce an error if there is no fallback value.
3228  BinaryOperatorKind Operator) {
3229  return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
3230  }
3231 
3232  /// \brief Build a new atomic operation expression.
3233  ///
3234  /// By default, performs semantic analysis to build the new expression.
3235  /// Subclasses may override this routine to provide different behavior.
3237  MultiExprArg SubExprs,
3238  QualType RetTy,
3240  SourceLocation RParenLoc) {
3241  // Just create the expression; there is not any interesting semantic
3242  // analysis here because we can't actually build an AtomicExpr until
3243  // we are sure it is semantically sound.
3244  return new (SemaRef.Context) AtomicExpr(BuiltinLoc, SubExprs, RetTy, Op,
3245  RParenLoc);
3246  }
3247 
3248 private:
3249  TypeLoc TransformTypeInObjectScope(TypeLoc TL,
3250  QualType ObjectType,
3251  NamedDecl *FirstQualifierInScope,
3252  CXXScopeSpec &SS);
3253 
3254  TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
3255  QualType ObjectType,
3256  NamedDecl *FirstQualifierInScope,
3257  CXXScopeSpec &SS);
3258 
3259  TypeSourceInfo *TransformTSIInObjectScope(TypeLoc TL, QualType ObjectType,
3260  NamedDecl *FirstQualifierInScope,
3261  CXXScopeSpec &SS);
3262 
3263  QualType TransformDependentNameType(TypeLocBuilder &TLB,
3265  bool DeducibleTSTContext);
3266 };
3267 
3268 template<typename Derived>
3270  if (!S)
3271  return S;
3272 
3273  switch (S->getStmtClass()) {
3274  case Stmt::NoStmtClass: break;
3275 
3276  // Transform individual statement nodes
3277 #define STMT(Node, Parent) \
3278  case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
3279 #define ABSTRACT_STMT(Node)
3280 #define EXPR(Node, Parent)
3281 #include "clang/AST/StmtNodes.inc"
3282 
3283  // Transform expressions by calling TransformExpr.
3284 #define STMT(Node, Parent)
3285 #define ABSTRACT_STMT(Stmt)
3286 #define EXPR(Node, Parent) case Stmt::Node##Class:
3287 #include "clang/AST/StmtNodes.inc"
3288  {
3289  ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
3290  if (E.isInvalid())
3291  return StmtError();
3292 
3293  return getSema().ActOnExprStmt(E);
3294  }
3295  }
3296 
3297  return S;
3298 }
3299 
3300 template<typename Derived>
3302  if (!S)
3303  return S;
3304 
3305  switch (S->getClauseKind()) {
3306  default: break;
3307  // Transform individual clause nodes
3308 #define OPENMP_CLAUSE(Name, Class) \
3309  case OMPC_ ## Name : \
3310  return getDerived().Transform ## Class(cast<Class>(S));
3311 #include "clang/Basic/OpenMPKinds.def"
3312  }
3313 
3314  return S;
3315 }
3316 
3317 
3318 template<typename Derived>
3320  if (!E)
3321  return E;
3322 
3323  switch (E->getStmtClass()) {
3324  case Stmt::NoStmtClass: break;
3325 #define STMT(Node, Parent) case Stmt::Node##Class: break;
3326 #define ABSTRACT_STMT(Stmt)
3327 #define EXPR(Node, Parent) \
3328  case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
3329 #include "clang/AST/StmtNodes.inc"
3330  }
3331 
3332  return E;
3333 }
3334 
3335 template<typename Derived>
3337  bool NotCopyInit) {
3338  // Initializers are instantiated like expressions, except that various outer
3339  // layers are stripped.
3340  if (!Init)
3341  return Init;
3342 
3343  if (ExprWithCleanups *ExprTemp = dyn_cast<ExprWithCleanups>(Init))
3344  Init = ExprTemp->getSubExpr();
3345 
3346  if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init))
3347  Init = AIL->getCommonExpr();
3348 
3349  if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
3350  Init = MTE->GetTemporaryExpr();
3351 
3352  while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
3353  Init = Binder->getSubExpr();
3354 
3355  if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
3356  Init = ICE->getSubExprAsWritten();
3357 
3358  if (CXXStdInitializerListExpr *ILE =
3359  dyn_cast<CXXStdInitializerListExpr>(Init))
3360  return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
3361 
3362  // If this is copy-initialization, we only need to reconstruct
3363  // InitListExprs. Other forms of copy-initialization will be a no-op if
3364  // the initializer is already the right type.
3365  CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
3366  if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
3367  return getDerived().TransformExpr(Init);
3368 
3369  // Revert value-initialization back to empty parens.
3370  if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
3371  SourceRange Parens = VIE->getSourceRange();
3372  return getDerived().RebuildParenListExpr(Parens.getBegin(), None,
3373  Parens.getEnd());
3374  }
3375 
3376  // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
3377  if (isa<ImplicitValueInitExpr>(Init))
3378  return getDerived().RebuildParenListExpr(SourceLocation(), None,
3379  SourceLocation());
3380 
3381  // Revert initialization by constructor back to a parenthesized or braced list
3382  // of expressions. Any other form of initializer can just be reused directly.
3383  if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
3384  return getDerived().TransformExpr(Init);
3385 
3386  // If the initialization implicitly converted an initializer list to a
3387  // std::initializer_list object, unwrap the std::initializer_list too.
3388  if (Construct && Construct->isStdInitListInitialization())
3389  return TransformInitializer(Construct->getArg(0), NotCopyInit);
3390 
3391  SmallVector<Expr*, 8> NewArgs;
3392  bool ArgChanged = false;
3393  if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
3394  /*IsCall*/true, NewArgs, &ArgChanged))
3395  return ExprError();
3396 
3397  // If this was list initialization, revert to list form.
3398  if (Construct->isListInitialization())
3399  return getDerived().RebuildInitList(Construct->getLocStart(), NewArgs,
3400  Construct->getLocEnd(),
3401  Construct->getType());
3402 
3403  // Build a ParenListExpr to represent anything else.
3404  SourceRange Parens = Construct->getParenOrBraceRange();
3405  if (Parens.isInvalid()) {
3406  // This was a variable declaration's initialization for which no initializer
3407  // was specified.
3408  assert(NewArgs.empty() &&
3409  "no parens or braces but have direct init with arguments?");
3410  return ExprEmpty();
3411  }
3412  return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
3413  Parens.getEnd());
3414 }
3415 
3416 template<typename Derived>
3418  unsigned NumInputs,
3419  bool IsCall,
3420  SmallVectorImpl<Expr *> &Outputs,
3421  bool *ArgChanged) {
3422  for (unsigned I = 0; I != NumInputs; ++I) {
3423  // If requested, drop call arguments that need to be dropped.
3424  if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
3425  if (ArgChanged)
3426  *ArgChanged = true;
3427 
3428  break;
3429  }
3430 
3431  if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
3432  Expr *Pattern = Expansion->getPattern();
3433 
3435  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
3436  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
3437 
3438  // Determine whether the set of unexpanded parameter packs can and should
3439  // be expanded.
3440  bool Expand = true;
3441  bool RetainExpansion = false;
3442  Optional<unsigned> OrigNumExpansions = Expansion->getNumExpansions();
3443  Optional<unsigned> NumExpansions = OrigNumExpansions;
3444  if (getDerived().TryExpandParameterPacks(Expansion->getEllipsisLoc(),
3445  Pattern->getSourceRange(),
3446  Unexpanded,
3447  Expand, RetainExpansion,
3448  NumExpansions))
3449  return true;
3450 
3451  if (!Expand) {
3452  // The transform has determined that we should perform a simple
3453  // transformation on the pack expansion, producing another pack
3454  // expansion.
3455  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
3456  ExprResult OutPattern = getDerived().TransformExpr(Pattern);
3457  if (OutPattern.isInvalid())
3458  return true;
3459 
3460  ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
3461  Expansion->getEllipsisLoc(),
3462  NumExpansions);
3463  if (Out.isInvalid())
3464  return true;
3465 
3466  if (ArgChanged)
3467  *ArgChanged = true;
3468  Outputs.push_back(Out.get());
3469  continue;
3470  }
3471 
3472  // Record right away that the argument was changed. This needs
3473  // to happen even if the array expands to nothing.
3474  if (ArgChanged) *ArgChanged = true;
3475 
3476  // The transform has determined that we should perform an elementwise
3477  // expansion of the pattern. Do so.
3478  for (unsigned I = 0; I != *NumExpansions; ++I) {
3479  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
3480  ExprResult Out = getDerived().TransformExpr(Pattern);
3481  if (Out.isInvalid())
3482  return true;
3483 
3484  if (Out.get()->containsUnexpandedParameterPack()) {
3485  Out = getDerived().RebuildPackExpansion(
3486  Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
3487  if (Out.isInvalid())
3488  return true;
3489  }
3490 
3491  Outputs.push_back(Out.get());
3492  }
3493 
3494  // If we're supposed to retain a pack expansion, do so by temporarily
3495  // forgetting the partially-substituted parameter pack.
3496  if (RetainExpansion) {
3497  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
3498 
3499  ExprResult Out = getDerived().TransformExpr(Pattern);
3500  if (Out.isInvalid())
3501  return true;
3502 
3503  Out = getDerived().RebuildPackExpansion(
3504  Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
3505  if (Out.isInvalid())
3506  return true;
3507 
3508  Outputs.push_back(Out.get());
3509  }
3510 
3511  continue;
3512  }
3513 
3514  ExprResult Result =
3515  IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
3516  : getDerived().TransformExpr(Inputs[I]);
3517  if (Result.isInvalid())
3518  return true;
3519 
3520  if (Result.get() != Inputs[I] && ArgChanged)
3521  *ArgChanged = true;
3522 
3523  Outputs.push_back(Result.get());
3524  }
3525 
3526  return false;
3527 }
3528 
3529 template <typename Derived>
3532  if (Var) {
3533  VarDecl *ConditionVar = cast_or_null<VarDecl>(
3534  getDerived().TransformDefinition(Var->getLocation(), Var));
3535 
3536  if (!ConditionVar)
3537  return Sema::ConditionError();
3538 
3539  return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
3540  }
3541 
3542  if (Expr) {
3543  ExprResult CondExpr = getDerived().TransformExpr(Expr);
3544 
3545  if (CondExpr.isInvalid())
3546  return Sema::ConditionError();
3547 
3548  return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind);
3549  }
3550 
3551  return Sema::ConditionResult();
3552 }
3553 
3554 template<typename Derived>
3558  QualType ObjectType,
3559  NamedDecl *FirstQualifierInScope) {
3561  for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
3562  Qualifier = Qualifier.getPrefix())
3563  Qualifiers.push_back(Qualifier);
3564 
3565  CXXScopeSpec SS;
3566  while (!Qualifiers.empty()) {
3567  NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
3569 
3570  switch (QNNS->getKind()) {
3573  Q.getLocalBeginLoc(), Q.getLocalEndLoc(), ObjectType);
3574  if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo, false,
3575  SS, FirstQualifierInScope, false))
3576  return NestedNameSpecifierLoc();
3577  }
3578  break;
3579 
3581  NamespaceDecl *NS
3582  = cast_or_null<NamespaceDecl>(
3583  getDerived().TransformDecl(
3584  Q.getLocalBeginLoc(),
3585  QNNS->getAsNamespace()));
3586  SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
3587  break;
3588  }
3589 
3591  NamespaceAliasDecl *Alias
3592  = cast_or_null<NamespaceAliasDecl>(
3593  getDerived().TransformDecl(Q.getLocalBeginLoc(),
3594  QNNS->getAsNamespaceAlias()));
3595  SS.Extend(SemaRef.Context, Alias, Q.getLocalBeginLoc(),
3596  Q.getLocalEndLoc());
3597  break;
3598  }
3599 
3601  // There is no meaningful transformation that one could perform on the
3602  // global scope.
3603  SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
3604  break;
3605 
3607  CXXRecordDecl *RD =
3608  cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
3609  SourceLocation(), QNNS->getAsRecordDecl()));
3610  SS.MakeSuper(SemaRef.Context, RD, Q.getBeginLoc(), Q.getEndLoc());
3611  break;
3612  }
3613 
3616  TypeLoc TL = TransformTypeInObjectScope(Q.getTypeLoc(), ObjectType,
3617  FirstQualifierInScope, SS);
3618 
3619  if (!TL)
3620  return NestedNameSpecifierLoc();
3621 
3622  if (TL.getType()->isDependentType() || TL.getType()->isRecordType() ||
3623  (SemaRef.getLangOpts().CPlusPlus11 &&
3624  TL.getType()->isEnumeralType())) {
3625  assert(!TL.getType().hasLocalQualifiers() &&
3626  "Can't get cv-qualifiers here");
3627  if (TL.getType()->isEnumeralType())
3628  SemaRef.Diag(TL.getBeginLoc(),
3629  diag::warn_cxx98_compat_enum_nested_name_spec);
3630  SS.Extend(SemaRef.Context, /*FIXME:*/SourceLocation(), TL,
3631  Q.getLocalEndLoc());
3632  break;
3633  }
3634  // If the nested-name-specifier is an invalid type def, don't emit an
3635  // error because a previous error should have already been emitted.
3636  TypedefTypeLoc TTL = TL.getAs<TypedefTypeLoc>();
3637  if (!TTL || !TTL.getTypedefNameDecl()->isInvalidDecl()) {
3638  SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
3639  << TL.getType() << SS.getRange();
3640  }
3641  return NestedNameSpecifierLoc();
3642  }
3643  }
3644 
3645  // The qualifier-in-scope and object type only apply to the leftmost entity.
3646  FirstQualifierInScope = nullptr;
3647  ObjectType = QualType();
3648  }
3649 
3650  // Don't rebuild the nested-name-specifier if we don't have to.
3651  if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
3652  !getDerived().AlwaysRebuild())
3653  return NNS;
3654 
3655  // If we can re-use the source-location data from the original
3656  // nested-name-specifier, do so.
3657  if (SS.location_size() == NNS.getDataLength() &&
3658  memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
3659  return NestedNameSpecifierLoc(SS.getScopeRep(), NNS.getOpaqueData());
3660 
3661  // Allocate new nested-name-specifier location information.
3662  return SS.getWithLocInContext(SemaRef.Context);
3663 }
3664 
3665 template<typename Derived>
3669  DeclarationName Name = NameInfo.getName();
3670  if (!Name)
3671  return DeclarationNameInfo();
3672 
3673  switch (Name.getNameKind()) {
3681  return NameInfo;
3682 
3684  TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
3685  TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
3686  getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
3687  if (!NewTemplate)
3688  return DeclarationNameInfo();
3689 
3690  DeclarationNameInfo NewNameInfo(NameInfo);
3691  NewNameInfo.setName(
3692  SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
3693  return NewNameInfo;
3694  }
3695 
3699  TypeSourceInfo *NewTInfo;
3700  CanQualType NewCanTy;
3701  if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
3702  NewTInfo = getDerived().TransformType(OldTInfo);
3703  if (!NewTInfo)
3704  return DeclarationNameInfo();
3705  NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
3706  }
3707  else {
3708  NewTInfo = nullptr;
3709  TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
3710  QualType NewT = getDerived().TransformType(Name.getCXXNameType());
3711  if (NewT.isNull())
3712  return DeclarationNameInfo();
3713  NewCanTy = SemaRef.Context.getCanonicalType(NewT);
3714  }
3715 
3716  DeclarationName NewName
3717  = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
3718  NewCanTy);
3719  DeclarationNameInfo NewNameInfo(NameInfo);
3720  NewNameInfo.setName(NewName);
3721  NewNameInfo.setNamedTypeInfo(NewTInfo);
3722  return NewNameInfo;
3723  }
3724  }
3725 
3726  llvm_unreachable("Unknown name kind.");
3727 }
3728 
3729 template<typename Derived>
3732  TemplateName Name,
3733  SourceLocation NameLoc,
3734  QualType ObjectType,
3735  NamedDecl *FirstQualifierInScope,
3736  bool AllowInjectedClassName) {
3738  TemplateDecl *Template = QTN->getTemplateDecl();
3739  assert(Template && "qualified template name must refer to a template");
3740 
3741  TemplateDecl *TransTemplate
3742  = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
3743  Template));
3744  if (!TransTemplate)
3745  return TemplateName();
3746 
3747  if (!getDerived().AlwaysRebuild() &&
3748  SS.getScopeRep() == QTN->getQualifier() &&
3749  TransTemplate == Template)
3750  return Name;
3751 
3752  return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
3753  TransTemplate);
3754  }
3755 
3757  if (SS.getScopeRep()) {
3758  // These apply to the scope specifier, not the template.
3759  ObjectType = QualType();
3760  FirstQualifierInScope = nullptr;
3761  }
3762 
3763  if (!getDerived().AlwaysRebuild() &&
3764  SS.getScopeRep() == DTN->getQualifier() &&
3765  ObjectType.isNull())
3766  return Name;
3767 
3768  if (DTN->isIdentifier()) {
3769  return getDerived().RebuildTemplateName(SS,
3770  *DTN->getIdentifier(),
3771  NameLoc,
3772  ObjectType,
3773  FirstQualifierInScope,
3774  AllowInjectedClassName);
3775  }
3776 
3777  return getDerived().RebuildTemplateName(SS, DTN->getOperator(), NameLoc,
3778  ObjectType, AllowInjectedClassName);
3779  }
3780 
3781  if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
3782  TemplateDecl *TransTemplate
3783  = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
3784  Template));
3785  if (!TransTemplate)
3786  return TemplateName();
3787 
3788  if (!getDerived().AlwaysRebuild() &&
3789  TransTemplate == Template)
3790  return Name;
3791 
3792  return TemplateName(TransTemplate);
3793  }
3794 
3797  TemplateTemplateParmDecl *TransParam
3798  = cast_or_null<TemplateTemplateParmDecl>(
3799  getDerived().TransformDecl(NameLoc, SubstPack->getParameterPack()));
3800  if (!TransParam)
3801  return TemplateName();
3802 
3803  if (!getDerived().AlwaysRebuild() &&
3804  TransParam == SubstPack->getParameterPack())
3805  return Name;
3806 
3807  return getDerived().RebuildTemplateName(TransParam,
3808  SubstPack->getArgumentPack());
3809  }
3810 
3811  // These should be getting filtered out before they reach the AST.
3812  llvm_unreachable("overloaded function decl survived to here");
3813 }
3814 
3815 template<typename Derived>
3817  const TemplateArgument &Arg,
3818  TemplateArgumentLoc &Output) {
3819  SourceLocation Loc = getDerived().getBaseLocation();
3820  switch (Arg.getKind()) {
3822  llvm_unreachable("null template argument in TreeTransform");
3823  break;
3824 
3826  Output = TemplateArgumentLoc(Arg,
3827  SemaRef.Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc));
3828 
3829  break;
3830 
3835  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
3836  Builder.MakeTrivial(SemaRef.Context, DTN->getQualifier(), Loc);
3837  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
3838  Builder.MakeTrivial(SemaRef.Context, QTN->getQualifier(), Loc);
3839 
3840  if (Arg.getKind() == TemplateArgument::Template)
3841  Output = TemplateArgumentLoc(Arg,
3842  Builder.getWithLocInContext(SemaRef.Context),
3843  Loc);
3844  else
3845  Output = TemplateArgumentLoc(Arg,
3846  Builder.getWithLocInContext(SemaRef.Context),
3847  Loc, Loc);
3848 
3849  break;
3850  }
3851 
3853  Output = TemplateArgumentLoc(Arg, Arg.getAsExpr());
3854  break;
3855 
3861  break;
3862  }
3863 }
3864 
3865 template<typename Derived>
3867  const TemplateArgumentLoc &Input,
3868  TemplateArgumentLoc &Output, bool Uneval) {
3869  const TemplateArgument &Arg = Input.getArgument();
3870  switch (Arg.getKind()) {
3876  llvm_unreachable("Unexpected TemplateArgument");
3877 
3878  case TemplateArgument::Type: {
3879  TypeSourceInfo *DI = Input.getTypeSourceInfo();
3880  if (!DI)
3881  DI = InventTypeSourceInfo(Input.getArgument().getAsType());
3882 
3883  DI = getDerived().TransformType(DI);
3884  if (!DI) return true;
3885 
3886  Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
3887  return false;
3888  }
3889 
3891  NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
3892  if (QualifierLoc) {
3893  QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
3894  if (!QualifierLoc)
3895  return true;
3896  }
3897 
3898  CXXScopeSpec SS;
3899  SS.Adopt(QualifierLoc);
3900  TemplateName Template
3901  = getDerived().TransformTemplateName(SS, Arg.getAsTemplate(),
3902  Input.getTemplateNameLoc());
3903  if (Template.isNull())
3904  return true;
3905 
3906  Output = TemplateArgumentLoc(TemplateArgument(Template), QualifierLoc,
3907  Input.getTemplateNameLoc());
3908  return false;
3909  }
3910 
3912  llvm_unreachable("Caller should expand pack expansions");
3913 
3915  // Template argument expressions are constant expressions.
3917  getSema(), Uneval
3920 
3921  Expr *InputExpr = Input.getSourceExpression();
3922  if (!InputExpr) InputExpr = Input.getArgument().getAsExpr();
3923 
3924  ExprResult E = getDerived().TransformExpr(InputExpr);
3925  E = SemaRef.ActOnConstantExpression(E);
3926  if (E.isInvalid()) return true;
3927  Output = TemplateArgumentLoc(TemplateArgument(E.get()), E.get());
3928  return false;
3929  }
3930  }
3931 
3932  // Work around bogus GCC warning
3933  return true;
3934 }
3935 
3936 /// \brief Iterator adaptor that invents template argument location information
3937 /// for each of the template arguments in its underlying iterator.
3938 template<typename Derived, typename InputIterator>
3940  TreeTransform<Derived> &Self;
3941  InputIterator Iter;
3942 
3943 public:
3946  typedef typename std::iterator_traits<InputIterator>::difference_type
3948  typedef std::input_iterator_tag iterator_category;
3949 
3950  class pointer {
3951  TemplateArgumentLoc Arg;
3952 
3953  public:
3954  explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
3955 
3956  const TemplateArgumentLoc *operator->() const { return &Arg; }
3957  };
3958 
3960 
3962  InputIterator Iter)
3963  : Self(Self), Iter(Iter) { }
3964 
3966  ++Iter;
3967  return *this;
3968  }
3969 
3972  ++(*this);
3973  return Old;
3974  }
3975 
3976  reference operator*() const {
3977  TemplateArgumentLoc Result;
3978  Self.InventTemplateArgumentLoc(*Iter, Result);
3979  return Result;
3980  }
3981 
3982  pointer operator->() const { return pointer(**this); }
3983 
3986  return X.Iter == Y.Iter;
3987  }
3988 
3991  return X.Iter != Y.Iter;
3992  }
3993 };
3994 
3995 template<typename Derived>
3996 template<typename InputIterator>
3998  InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
3999  bool Uneval) {
4000  for (; First != Last; ++First) {
4001  TemplateArgumentLoc Out;
4002  TemplateArgumentLoc In = *First;
4003 
4004  if (In.getArgument().getKind() == TemplateArgument::Pack) {
4005  // Unpack argument packs, which we translate them into separate
4006  // arguments.
4007  // FIXME: We could do much better if we could guarantee that the
4008  // TemplateArgumentLocInfo for the pack expansion would be usable for
4009  // all of the template arguments in the argument pack.
4010  typedef TemplateArgumentLocInventIterator<Derived,
4012  PackLocIterator;
4013  if (TransformTemplateArguments(PackLocIterator(*this,
4014  In.getArgument().pack_begin()),
4015  PackLocIterator(*this,
4016  In.getArgument().pack_end()),
4017  Outputs, Uneval))
4018  return true;
4019 
4020  continue;
4021  }
4022 
4023  if (In.getArgument().isPackExpansion()) {
4024  // We have a pack expansion, for which we will be substituting into
4025  // the pattern.
4026  SourceLocation Ellipsis;
4027  Optional<unsigned> OrigNumExpansions;
4028  TemplateArgumentLoc Pattern
4029  = getSema().getTemplateArgumentPackExpansionPattern(
4030  In, Ellipsis, OrigNumExpansions);
4031 
4033  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4034  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4035 
4036  // Determine whether the set of unexpanded parameter packs can and should
4037  // be expanded.
4038  bool Expand = true;
4039  bool RetainExpansion = false;
4040  Optional<unsigned> NumExpansions = OrigNumExpansions;
4041  if (getDerived().TryExpandParameterPacks(Ellipsis,
4042  Pattern.getSourceRange(),
4043  Unexpanded,
4044  Expand,
4045  RetainExpansion,
4046  NumExpansions))
4047  return true;
4048 
4049  if (!Expand) {
4050  // The transform has determined that we should perform a simple
4051  // transformation on the pack expansion, producing another pack
4052  // expansion.
4053  TemplateArgumentLoc OutPattern;
4054  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
4055  if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
4056  return true;
4057 
4058  Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis,
4059  NumExpansions);
4060  if (Out.getArgument().isNull())
4061  return true;
4062 
4063  Outputs.addArgument(Out);
4064  continue;
4065  }
4066 
4067  // The transform has determined that we should perform an elementwise
4068  // expansion of the pattern. Do so.
4069  for (unsigned I = 0; I != *NumExpansions; ++I) {
4070  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
4071 
4072  if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4073  return true;
4074 
4076  Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4077  OrigNumExpansions);
4078  if (Out.getArgument().isNull())
4079  return true;
4080  }
4081 
4082  Outputs.addArgument(Out);
4083  }
4084 
4085  // If we're supposed to retain a pack expansion, do so by temporarily
4086  // forgetting the partially-substituted parameter pack.
4087  if (RetainExpansion) {
4088  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4089 
4090  if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4091  return true;
4092 
4093  Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4094  OrigNumExpansions);
4095  if (Out.getArgument().isNull())
4096  return true;
4097 
4098  Outputs.addArgument(Out);
4099  }
4100 
4101  continue;
4102  }
4103 
4104  // The simple case:
4105  if (getDerived().TransformTemplateArgument(In, Out, Uneval))
4106  return true;
4107 
4108  Outputs.addArgument(Out);
4109  }
4110 
4111  return false;
4112 
4113 }
4114 
4115 //===----------------------------------------------------------------------===//
4116 // Type transformation
4117 //===----------------------------------------------------------------------===//
4118 
4119 template<typename Derived>
4121  if (getDerived().AlreadyTransformed(T))
4122  return T;
4123 
4124  // Temporary workaround. All of these transformations should
4125  // eventually turn into transformations on TypeLocs.
4126  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
4127  getDerived().getBaseLocation());
4128 
4129  TypeSourceInfo *NewDI = getDerived().TransformType(DI);
4130 
4131  if (!NewDI)
4132  return QualType();
4133 
4134  return NewDI->getType();
4135 }
4136 
4137 template<typename Derived>
4139  // Refine the base location to the type's location.
4140  TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
4141  getDerived().getBaseEntity());
4142  if (getDerived().AlreadyTransformed(DI->getType()))
4143  return DI;
4144 
4145  TypeLocBuilder TLB;
4146 
4147  TypeLoc TL = DI->getTypeLoc();
4148  TLB.reserve(TL.getFullDataSize());
4149 
4150  QualType Result = getDerived().TransformType(TLB, TL);
4151  if (Result.isNull())
4152  return nullptr;
4153 
4154  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4155 }
4156 
4157 template<typename Derived>
4158 QualType
4160  switch (T.getTypeLocClass()) {
4161 #define ABSTRACT_TYPELOC(CLASS, PARENT)
4162 #define TYPELOC(CLASS, PARENT) \
4163  case TypeLoc::CLASS: \
4164  return getDerived().Transform##CLASS##Type(TLB, \
4165  T.castAs<CLASS##TypeLoc>());
4166 #include "clang/AST/TypeLocNodes.def"
4167  }
4168 
4169  llvm_unreachable("unhandled type loc!");
4170 }
4171 
4172 template<typename Derived>
4174  if (!isa<DependentNameType>(T))
4175  return TransformType(T);
4176 
4177  if (getDerived().AlreadyTransformed(T))
4178  return T;
4179  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
4180  getDerived().getBaseLocation());
4181  TypeSourceInfo *NewDI = getDerived().TransformTypeWithDeducedTST(DI);
4182  return NewDI ? NewDI->getType() : QualType();
4183 }
4184 
4185 template<typename Derived>
4188  if (!isa<DependentNameType>(DI->getType()))
4189  return TransformType(DI);
4190 
4191  // Refine the base location to the type's location.
4192  TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
4193  getDerived().getBaseEntity());
4194  if (getDerived().AlreadyTransformed(DI->getType()))
4195  return DI;
4196 
4197  TypeLocBuilder TLB;
4198 
4199  TypeLoc TL = DI->getTypeLoc();
4200  TLB.reserve(TL.getFullDataSize());
4201 
4202  auto QTL = TL.getAs<QualifiedTypeLoc>();
4203  if (QTL)
4204  TL = QTL.getUnqualifiedLoc();
4205 
4206  auto DNTL = TL.castAs<DependentNameTypeLoc>();
4207 
4208  QualType Result = getDerived().TransformDependentNameType(
4209  TLB, DNTL, /*DeducedTSTContext*/true);
4210  if (Result.isNull())
4211  return nullptr;
4212 
4213  if (QTL) {
4214  Result = getDerived().RebuildQualifiedType(
4215  Result, QTL.getBeginLoc(), QTL.getType().getLocalQualifiers());
4216  TLB.TypeWasModifiedSafely(Result);
4217  }
4218 
4219  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4220 }
4221 
4222 template<typename Derived>
4223 QualType
4225  QualifiedTypeLoc T) {
4226  Qualifiers Quals = T.getType().getLocalQualifiers();
4227 
4228  QualType Result = getDerived().TransformType(TLB, T.getUnqualifiedLoc());
4229  if (Result.isNull())
4230  return QualType();
4231 
4232  Result = getDerived().RebuildQualifiedType(Result, T.getBeginLoc(), Quals);
4233 
4234  // RebuildQualifiedType might have updated the type, but not in a way
4235  // that invalidates the TypeLoc. (There's no location information for
4236  // qualifiers.)
4237  TLB.TypeWasModifiedSafely(Result);
4238 
4239  return Result;
4240 }
4241 
4242 template<typename Derived>
4244  SourceLocation Loc,
4245  Qualifiers Quals) {
4246  // C++ [dcl.fct]p7:
4247  // [When] adding cv-qualifications on top of the function type [...] the
4248  // cv-qualifiers are ignored.
4249  // C++ [dcl.ref]p1:
4250  // when the cv-qualifiers are introduced through the use of a typedef-name
4251  // or decltype-specifier [...] the cv-qualifiers are ignored.
4252  // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
4253  // applied to a reference type.
4254  // FIXME: This removes all qualifiers, not just cv-qualifiers!
4255  if (T->isFunctionType() || T->isReferenceType())
4256  return T;
4257 
4258  // Suppress Objective-C lifetime qualifiers if they don't make sense for the
4259  // resulting type.
4260  if (Quals.hasObjCLifetime()) {
4261  if (!T->isObjCLifetimeType() && !T->isDependentType())
4262  Quals.removeObjCLifetime();
4263  else if (T.getObjCLifetime()) {
4264  // Objective-C ARC:
4265  // A lifetime qualifier applied to a substituted template parameter
4266  // overrides the lifetime qualifier from the template argument.
4267  const AutoType *AutoTy;
4268  if (const SubstTemplateTypeParmType *SubstTypeParam
4269  = dyn_cast<SubstTemplateTypeParmType>(T)) {
4270  QualType Replacement = SubstTypeParam->getReplacementType();
4271  Qualifiers Qs = Replacement.getQualifiers();
4272  Qs.removeObjCLifetime();
4273  Replacement = SemaRef.Context.getQualifiedType(
4274  Replacement.getUnqualifiedType(), Qs);
4275  T = SemaRef.Context.getSubstTemplateTypeParmType(
4276  SubstTypeParam->getReplacedParameter(), Replacement);
4277  } else if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
4278  // 'auto' types behave the same way as template parameters.
4279  QualType Deduced = AutoTy->getDeducedType();
4280  Qualifiers Qs = Deduced.getQualifiers();
4281  Qs.removeObjCLifetime();
4282  Deduced =
4283  SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
4284  T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
4285  AutoTy->isDependentType());
4286  } else {
4287  // Otherwise, complain about the addition of a qualifier to an
4288  // already-qualified type.
4289  // FIXME: Why is this check not in Sema::BuildQualifiedType?
4290  SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
4291  Quals.removeObjCLifetime();
4292  }
4293  }
4294  }
4295 
4296  return SemaRef.BuildQualifiedType(T, Loc, Quals);
4297 }
4298 
4299 template<typename Derived>
4300 TypeLoc
4302  QualType ObjectType,
4303  NamedDecl *UnqualLookup,
4304  CXXScopeSpec &SS) {
4305  if (getDerived().AlreadyTransformed(TL.getType()))
4306  return TL;
4307 
4308  TypeSourceInfo *TSI =
4309  TransformTSIInObjectScope(TL, ObjectType, UnqualLookup, SS);
4310  if (TSI)
4311  return TSI->getTypeLoc();
4312  return TypeLoc();
4313 }
4314 
4315 template<typename Derived>
4318  QualType ObjectType,
4319  NamedDecl *UnqualLookup,
4320  CXXScopeSpec &SS) {
4321  if (getDerived().AlreadyTransformed(TSInfo->getType()))
4322  return TSInfo;
4323 
4324  return TransformTSIInObjectScope(TSInfo->getTypeLoc(), ObjectType,
4325  UnqualLookup, SS);
4326 }
4327 
4328 template <typename Derived>
4330  TypeLoc TL, QualType ObjectType, NamedDecl *UnqualLookup,
4331  CXXScopeSpec &SS) {
4332  QualType T = TL.getType();
4333  assert(!getDerived().AlreadyTransformed(T));
4334 
4335  TypeLocBuilder TLB;
4336  QualType Result;
4337 
4338  if (isa<TemplateSpecializationType>(T)) {
4341 
4342  TemplateName Template = getDerived().TransformTemplateName(
4343  SS, SpecTL.getTypePtr()->getTemplateName(), SpecTL.getTemplateNameLoc(),
4344  ObjectType, UnqualLookup, /*AllowInjectedClassName*/true);
4345  if (Template.isNull())
4346  return nullptr;
4347 
4348  Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL,
4349  Template);
4350  } else if (isa<DependentTemplateSpecializationType>(T)) {
4353 
4354  TemplateName Template
4355  = getDerived().RebuildTemplateName(SS,
4356  *SpecTL.getTypePtr()->getIdentifier(),
4357  SpecTL.getTemplateNameLoc(),
4358  ObjectType, UnqualLookup,
4359  /*AllowInjectedClassName*/true);
4360  if (Template.isNull())
4361  return nullptr;
4362 
4363  Result = getDerived().TransformDependentTemplateSpecializationType(TLB,
4364  SpecTL,
4365  Template,
4366  SS);
4367  } else {
4368  // Nothing special needs to be done for these.
4369  Result = getDerived().TransformType(TLB, TL);
4370  }
4371 
4372  if (Result.isNull())
4373  return nullptr;
4374 
4375  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4376 }
4377 
4378 template <class TyLoc> static inline
4380  TyLoc NewT = TLB.push<TyLoc>(T.getType());
4381  NewT.setNameLoc(T.getNameLoc());
4382  return T.getType();
4383 }
4384 
4385 template<typename Derived>
4387  BuiltinTypeLoc T) {
4388  BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
4389  NewT.setBuiltinLoc(T.getBuiltinLoc());
4390  if (T.needsExtraLocalData())
4392  return T.getType();
4393 }
4394 
4395 template<typename Derived>
4397  ComplexTypeLoc T) {
4398  // FIXME: recurse?
4399  return TransformTypeSpecType(TLB, T);
4400 }
4401 
4402 template <typename Derived>
4404  AdjustedTypeLoc TL) {
4405  // Adjustments applied during transformation are handled elsewhere.
4406  return getDerived().TransformType(TLB, TL.getOriginalLoc());
4407 }
4408 
4409 template<typename Derived>
4411  DecayedTypeLoc TL) {
4412  QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
4413  if (OriginalType.isNull())
4414  return QualType();
4415 
4416  QualType Result = TL.getType();
4417  if (getDerived().AlwaysRebuild() ||
4418  OriginalType != TL.getOriginalLoc().getType())
4419  Result = SemaRef.Context.getDecayedType(OriginalType);
4420  TLB.push<DecayedTypeLoc>(Result);
4421  // Nothing to set for DecayedTypeLoc.
4422  return Result;
4423 }
4424 
4425 template<typename Derived>
4427  PointerTypeLoc TL) {
4428  QualType PointeeType
4429  = getDerived().TransformType(TLB, TL.getPointeeLoc());
4430  if (PointeeType.isNull())
4431  return QualType();
4432 
4433  QualType Result = TL.getType();
4434  if (PointeeType->getAs<ObjCObjectType>()) {
4435  // A dependent pointer type 'T *' has is being transformed such
4436  // that an Objective-C class type is being replaced for 'T'. The
4437  // resulting pointer type is an ObjCObjectPointerType, not a
4438  // PointerType.
4439  Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
4440 
4442  NewT.setStarLoc(TL.getStarLoc());
4443  return Result;
4444  }
4445 
4446  if (getDerived().AlwaysRebuild() ||
4447  PointeeType != TL.getPointeeLoc().getType()) {
4448  Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
4449  if (Result.isNull())
4450  return QualType();
4451  }
4452 
4453  // Objective-C ARC can add lifetime qualifiers to the type that we're
4454  // pointing to.
4455  TLB.TypeWasModifiedSafely(Result->getPointeeType());
4456 
4457  PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
4458  NewT.setSigilLoc(TL.getSigilLoc());
4459  return Result;
4460 }
4461 
4462 template<typename Derived>
4463 QualType
4465  BlockPointerTypeLoc TL) {
4466  QualType PointeeType
4467  = getDerived().TransformType(TLB, TL.getPointeeLoc());
4468  if (PointeeType.isNull())
4469  return QualType();
4470 
4471  QualType Result = TL.getType();
4472  if (getDerived().AlwaysRebuild() ||
4473  PointeeType != TL.getPointeeLoc().getType()) {
4474  Result = getDerived().RebuildBlockPointerType(PointeeType,
4475  TL.getSigilLoc());
4476  if (Result.isNull())
4477  return QualType();
4478  }
4479 
4480  BlockPointerTypeLoc NewT = TLB.push<BlockPointerTypeLoc>(Result);
4481  NewT.setSigilLoc(TL.getSigilLoc());
4482  return Result;
4483 }
4484 
4485 /// Transforms a reference type. Note that somewhat paradoxically we
4486 /// don't care whether the type itself is an l-value type or an r-value
4487 /// type; we only care if the type was *written* as an l-value type
4488 /// or an r-value type.
4489 template<typename Derived>
4490 QualType
4492  ReferenceTypeLoc TL) {
4493  const ReferenceType *T = TL.getTypePtr();
4494 
4495  // Note that this works with the pointee-as-written.
4496  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
4497  if (PointeeType.isNull())
4498  return QualType();
4499 
4500  QualType Result = TL.getType();
4501  if (getDerived().AlwaysRebuild() ||
4502  PointeeType != T->getPointeeTypeAsWritten()) {
4503  Result = getDerived().RebuildReferenceType(PointeeType,
4504  T->isSpelledAsLValue(),
4505  TL.getSigilLoc());
4506  if (Result.isNull())
4507  return QualType();
4508  }
4509 
4510  // Objective-C ARC can add lifetime qualifiers to the type that we're
4511  // referring to.
4514 
4515  // r-value references can be rebuilt as l-value references.
4516  ReferenceTypeLoc NewTL;
4517  if (isa<LValueReferenceType>(Result))
4518  NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
4519  else
4520  NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
4521  NewTL.setSigilLoc(TL.getSigilLoc());
4522 
4523  return Result;
4524 }
4525 
4526 template<typename Derived>
4527 QualType
4530  return TransformReferenceType(TLB, TL);
4531 }
4532 
4533 template<typename Derived>
4534 QualType
4537  return TransformReferenceType(TLB, TL);
4538 }
4539 
4540 template<typename Derived>
4541 QualType
4543  MemberPointerTypeLoc TL) {
4544  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
4545  if (PointeeType.isNull())
4546  return QualType();
4547 
4548  TypeSourceInfo* OldClsTInfo = TL.getClassTInfo();
4549  TypeSourceInfo *NewClsTInfo = nullptr;
4550  if (OldClsTInfo) {
4551  NewClsTInfo = getDerived().TransformType(OldClsTInfo);
4552  if (!NewClsTInfo)
4553  return QualType();
4554  }
4555 
4556  const MemberPointerType *T = TL.getTypePtr();
4557  QualType OldClsType = QualType(T->getClass(), 0);
4558  QualType NewClsType;
4559  if (NewClsTInfo)
4560  NewClsType = NewClsTInfo->getType();
4561  else {
4562  NewClsType = getDerived().TransformType(OldClsType);
4563  if (NewClsType.isNull())
4564  return QualType();
4565  }
4566 
4567  QualType Result = TL.getType();
4568  if (getDerived().AlwaysRebuild() ||
4569  PointeeType != T->getPointeeType() ||
4570  NewClsType != OldClsType) {
4571  Result = getDerived().RebuildMemberPointerType(PointeeType, NewClsType,
4572  TL.getStarLoc());
4573  if (Result.isNull())
4574  return QualType();
4575  }
4576 
4577  // If we had to adjust the pointee type when building a member pointer, make
4578  // sure to push TypeLoc info for it.
4579  const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
4580  if (MPT && PointeeType != MPT->getPointeeType()) {
4581  assert(isa<AdjustedType>(MPT->getPointeeType()));
4582  TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
4583  }
4584 
4585  MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(Result);
4586  NewTL.setSigilLoc(TL.getSigilLoc());
4587  NewTL.setClassTInfo(NewClsTInfo);
4588 
4589  return Result;
4590 }
4591 
4592 template<typename Derived>
4593 QualType
4595  ConstantArrayTypeLoc TL) {
4596  const ConstantArrayType *T = TL.getTypePtr();
4597  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4598  if (ElementType.isNull())
4599  return QualType();
4600 
4601  QualType Result = TL.getType();
4602  if (getDerived().AlwaysRebuild() ||
4603  ElementType != T->getElementType()) {
4604  Result = getDerived().RebuildConstantArrayType(ElementType,
4605  T->getSizeModifier(),
4606  T->getSize(),
4608  TL.getBracketsRange());
4609  if (Result.isNull())
4610  return QualType();
4611  }
4612 
4613  // We might have either a ConstantArrayType or a VariableArrayType now:
4614  // a ConstantArrayType is allowed to have an element type which is a
4615  // VariableArrayType if the type is dependent. Fortunately, all array
4616  // types have the same location layout.
4617  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4618  NewTL.setLBracketLoc(TL.getLBracketLoc());
4619  NewTL.setRBracketLoc(TL.getRBracketLoc());
4620 
4621  Expr *Size = TL.getSizeExpr();
4622  if (Size) {
4625  Size = getDerived().TransformExpr(Size).template getAs<Expr>();
4626  Size = SemaRef.ActOnConstantExpression(Size).get();
4627  }
4628  NewTL.setSizeExpr(Size);
4629 
4630  return Result;
4631 }
4632 
4633 template<typename Derived>
4635  TypeLocBuilder &TLB,
4637  const IncompleteArrayType *T = TL.getTypePtr();
4638  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4639  if (ElementType.isNull())
4640  return QualType();
4641 
4642  QualType Result = TL.getType();
4643  if (getDerived().AlwaysRebuild() ||
4644  ElementType != T->getElementType()) {
4645  Result = getDerived().RebuildIncompleteArrayType(ElementType,
4646  T->getSizeModifier(),
4648  TL.getBracketsRange());
4649  if (Result.isNull())
4650  return QualType();
4651  }
4652 
4653  IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(Result);
4654  NewTL.setLBracketLoc(TL.getLBracketLoc());
4655  NewTL.setRBracketLoc(TL.getRBracketLoc());
4656  NewTL.setSizeExpr(nullptr);
4657 
4658  return Result;
4659 }
4660 
4661 template<typename Derived>
4662 QualType
4664  VariableArrayTypeLoc TL) {
4665  const VariableArrayType *T = TL.getTypePtr();
4666  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4667  if (ElementType.isNull())
4668  return QualType();
4669 
4670  ExprResult SizeResult;
4671  {
4674  SizeResult = getDerived().TransformExpr(T->getSizeExpr());
4675  }
4676  if (SizeResult.isInvalid())
4677  return QualType();
4678  SizeResult = SemaRef.ActOnFinishFullExpr(SizeResult.get());
4679  if (SizeResult.isInvalid())
4680  return QualType();
4681 
4682  Expr *Size = SizeResult.get();
4683 
4684  QualType Result = TL.getType();
4685  if (getDerived().AlwaysRebuild() ||
4686  ElementType != T->getElementType() ||
4687  Size != T->getSizeExpr()) {
4688  Result = getDerived().RebuildVariableArrayType(ElementType,
4689  T->getSizeModifier(),
4690  Size,
4692  TL.getBracketsRange());
4693  if (Result.isNull())
4694  return QualType();
4695  }
4696 
4697  // We might have constant size array now, but fortunately it has the same
4698  // location layout.
4699  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4700  NewTL.setLBracketLoc(TL.getLBracketLoc());
4701  NewTL.setRBracketLoc(TL.getRBracketLoc());
4702  NewTL.setSizeExpr(Size);
4703 
4704  return Result;
4705 }
4706 
4707 template<typename Derived>
4708 QualType
4711  const DependentSizedArrayType *T = TL.getTypePtr();
4712  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4713  if (ElementType.isNull())
4714  return QualType();
4715 
4716  // Array bounds are constant expressions.
4719 
4720  // Prefer the expression from the TypeLoc; the other may have been uniqued.
4721  Expr *origSize = TL.getSizeExpr();
4722  if (!origSize) origSize = T->getSizeExpr();
4723 
4724  ExprResult sizeResult
4725  = getDerived().TransformExpr(origSize);
4726  sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
4727  if (sizeResult.isInvalid())
4728  return QualType();
4729 
4730  Expr *size = sizeResult.get();
4731 
4732  QualType Result = TL.getType();
4733  if (getDerived().AlwaysRebuild() ||
4734  ElementType != T->getElementType() ||
4735  size != origSize) {
4736  Result = getDerived().RebuildDependentSizedArrayType(ElementType,
4737  T->getSizeModifier(),
4738  size,
4740  TL.getBracketsRange());
4741  if (Result.isNull())
4742  return QualType();
4743  }
4744 
4745  // We might have any sort of array type now, but fortunately they
4746  // all have the same location layout.
4747  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4748  NewTL.setLBracketLoc(TL.getLBracketLoc());
4749  NewTL.setRBracketLoc(TL.getRBracketLoc());
4750  NewTL.setSizeExpr(size);
4751 
4752  return Result;
4753 }
4754 
4755 template<typename Derived>
4757  TypeLocBuilder &TLB,
4759  const DependentSizedExtVectorType *T = TL.getTypePtr();
4760 
4761  // FIXME: ext vector locs should be nested
4762  QualType ElementType = getDerived().TransformType(T->getElementType());
4763  if (ElementType.isNull())
4764  return QualType();
4765 
4766  // Vector sizes are constant expressions.
4769 
4770  ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
4771  Size = SemaRef.ActOnConstantExpression(Size);
4772  if (Size.isInvalid())
4773  return QualType();
4774 
4775  QualType Result = TL.getType();
4776  if (getDerived().AlwaysRebuild() ||
4777  ElementType != T->getElementType() ||
4778  Size.get() != T->getSizeExpr()) {
4779  Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
4780  Size.get(),
4781  T->getAttributeLoc());
4782  if (Result.isNull())
4783  return QualType();
4784  }
4785 
4786  // Result might be dependent or not.
4787  if (isa<DependentSizedExtVectorType>(Result)) {
4789  = TLB.push<DependentSizedExtVectorTypeLoc>(Result);
4790  NewTL.setNameLoc(TL.getNameLoc());
4791  } else {
4792  ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
4793  NewTL.setNameLoc(TL.getNameLoc());
4794  }
4795 
4796  return Result;
4797 }
4798 
4799 template <typename Derived>
4802  const DependentAddressSpaceType *T = TL.getTypePtr();
4803 
4804  QualType pointeeType = getDerived().TransformType(T->getPointeeType());
4805 
4806  if (pointeeType.isNull())
4807  return QualType();
4808 
4809  // Address spaces are constant expressions.
4812 
4813  ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
4814  AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
4815  if (AddrSpace.isInvalid())
4816  return QualType();
4817 
4818  QualType Result = TL.getType();
4819  if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
4820  AddrSpace.get() != T->getAddrSpaceExpr()) {
4821  Result = getDerived().RebuildDependentAddressSpaceType(
4822  pointeeType, AddrSpace.get(), T->getAttributeLoc());
4823  if (Result.isNull())
4824  return QualType();
4825  }
4826 
4827  // Result might be dependent or not.
4828  if (isa<DependentAddressSpaceType>(Result)) {
4830  TLB.push<DependentAddressSpaceTypeLoc>(Result);
4831 
4834  NewTL.setAttrNameLoc(TL.getAttrNameLoc());
4835 
4836  } else {
4837  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(
4838  Result, getDerived().getBaseLocation());
4839  TransformType(TLB, DI->getTypeLoc());
4840  }
4841 
4842  return Result;
4843 }
4844 
4845 template <typename Derived>
4847  VectorTypeLoc TL) {
4848  const VectorType *T = TL.getTypePtr();
4849  QualType ElementType = getDerived().TransformType(T->getElementType());
4850  if (ElementType.isNull())
4851  return QualType();
4852 
4853  QualType Result = TL.getType();
4854  if (getDerived().AlwaysRebuild() ||
4855  ElementType != T->getElementType()) {
4856  Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
4857  T->getVectorKind());
4858  if (Result.isNull())
4859  return QualType();
4860  }
4861 
4862  VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
4863  NewTL.setNameLoc(TL.getNameLoc());
4864 
4865  return Result;
4866 }
4867 
4868 template<typename Derived>
4870  ExtVectorTypeLoc TL) {
4871  const VectorType *T = TL.getTypePtr();
4872  QualType ElementType = getDerived().TransformType(T->getElementType());
4873  if (ElementType.isNull())
4874  return QualType();
4875 
4876  QualType Result = TL.getType();
4877  if (getDerived().AlwaysRebuild() ||
4878  ElementType != T->getElementType()) {
4879  Result = getDerived().RebuildExtVectorType(ElementType,
4880  T->getNumElements(),
4881  /*FIXME*/ SourceLocation());
4882  if (Result.isNull())
4883  return QualType();
4884  }
4885 
4886  ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
4887  NewTL.setNameLoc(TL.getNameLoc());
4888 
4889  return Result;
4890 }
4891 
4892 template <typename Derived>
4894  ParmVarDecl *OldParm, int indexAdjustment, Optional<unsigned> NumExpansions,
4895  bool ExpectParameterPack) {
4896  TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
4897  TypeSourceInfo *NewDI = nullptr;
4898 
4899  if (NumExpansions && isa<PackExpansionType>(OldDI->getType())) {
4900  // If we're substituting into a pack expansion type and we know the
4901  // length we want to expand to, just substitute for the pattern.
4902  TypeLoc OldTL = OldDI->getTypeLoc();
4903  PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
4904 
4905  TypeLocBuilder TLB;
4906  TypeLoc NewTL = OldDI->getTypeLoc();
4907  TLB.reserve(NewTL.getFullDataSize());
4908 
4909  QualType Result = getDerived().TransformType(TLB,
4910  OldExpansionTL.getPatternLoc());
4911  if (Result.isNull())
4912  return nullptr;
4913 
4914  Result = RebuildPackExpansionType(Result,
4915  OldExpansionTL.getPatternLoc().getSourceRange(),
4916  OldExpansionTL.getEllipsisLoc(),
4917  NumExpansions);
4918  if (Result.isNull())
4919  return nullptr;
4920 
4921  PackExpansionTypeLoc NewExpansionTL
4922  = TLB.push<PackExpansionTypeLoc>(Result);
4923  NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
4924  NewDI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
4925  } else
4926  NewDI = getDerived().TransformType(OldDI);
4927  if (!NewDI)
4928  return nullptr;
4929 
4930  if (NewDI == OldDI && indexAdjustment == 0)
4931  return OldParm;
4932 
4933  ParmVarDecl *newParm = ParmVarDecl::Create(SemaRef.Context,
4934  OldParm->getDeclContext(),
4935  OldParm->getInnerLocStart(),
4936  OldParm->getLocation(),
4937  OldParm->getIdentifier(),
4938  NewDI->getType(),
4939  NewDI,
4940  OldParm->getStorageClass(),
4941  /* DefArg */ nullptr);
4942  newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
4943  OldParm->getFunctionScopeIndex() + indexAdjustment);
4944  return newParm;
4945 }
4946 
4947 template <typename Derived>
4950  const QualType *ParamTypes,
4951  const FunctionProtoType::ExtParameterInfo *ParamInfos,
4952  SmallVectorImpl<QualType> &OutParamTypes,
4955  int indexAdjustment = 0;
4956 
4957  unsigned NumParams = Params.size();
4958  for (unsigned i = 0; i != NumParams; ++i) {
4959  if (ParmVarDecl *OldParm = Params[i]) {
4960  assert(OldParm->getFunctionScopeIndex() == i);
4961 
4962  Optional<unsigned> NumExpansions;
4963  ParmVarDecl *NewParm = nullptr;
4964  if (OldParm->isParameterPack()) {
4965  // We have a function parameter pack that may need to be expanded.
4967 
4968  // Find the parameter packs that could be expanded.
4969  TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
4970  PackExpansionTypeLoc ExpansionTL = TL.castAs<PackExpansionTypeLoc>();
4971  TypeLoc Pattern = ExpansionTL.getPatternLoc();
4972  SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
4973  assert(Unexpanded.size() > 0 && "Could not find parameter packs!");
4974 
4975  // Determine whether we should expand the parameter packs.
4976  bool ShouldExpand = false;
4977  bool RetainExpansion = false;
4978  Optional<unsigned> OrigNumExpansions =
4979  ExpansionTL.getTypePtr()->getNumExpansions();
4980  NumExpansions = OrigNumExpansions;
4981  if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
4982  Pattern.getSourceRange(),
4983  Unexpanded,
4984  ShouldExpand,
4985  RetainExpansion,
4986  NumExpansions)) {
4987  return true;
4988  }
4989 
4990  if (ShouldExpand) {
4991  // Expand the function parameter pack into multiple, separate
4992  // parameters.
4993  getDerived().ExpandingFunctionParameterPack(OldParm);
4994  for (unsigned I = 0; I != *NumExpansions; ++I) {
4995  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
4996  ParmVarDecl *NewParm
4997  = getDerived().TransformFunctionTypeParam(OldParm,
4998  indexAdjustment++,
4999  OrigNumExpansions,
5000  /*ExpectParameterPack=*/false);
5001  if (!NewParm)
5002  return true;
5003 
5004  if (ParamInfos)
5005  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5006  OutParamTypes.push_back(NewParm->getType());
5007  if (PVars)
5008  PVars->push_back(NewParm);
5009  }
5010 
5011  // If we're supposed to retain a pack expansion, do so by temporarily
5012  // forgetting the partially-substituted parameter pack.
5013  if (RetainExpansion) {
5014  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5015  ParmVarDecl *NewParm
5016  = getDerived().TransformFunctionTypeParam(OldParm,
5017  indexAdjustment++,
5018  OrigNumExpansions,
5019  /*ExpectParameterPack=*/false);
5020  if (!NewParm)
5021  return true;
5022 
5023  if (ParamInfos)
5024  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5025  OutParamTypes.push_back(NewParm->getType());
5026  if (PVars)
5027  PVars->push_back(NewParm);
5028  }
5029 
5030  // The next parameter should have the same adjustment as the
5031  // last thing we pushed, but we post-incremented indexAdjustment
5032  // on every push. Also, if we push nothing, the adjustment should
5033  // go down by one.
5034  indexAdjustment--;
5035 
5036  // We're done with the pack expansion.
5037  continue;
5038  }
5039 
5040  // We'll substitute the parameter now without expanding the pack
5041  // expansion.
5042  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5043  NewParm = getDerived().TransformFunctionTypeParam(OldParm,
5044  indexAdjustment,
5045  NumExpansions,
5046  /*ExpectParameterPack=*/true);
5047  } else {
5048  NewParm = getDerived().TransformFunctionTypeParam(
5049  OldParm, indexAdjustment, None, /*ExpectParameterPack=*/ false);
5050  }
5051 
5052  if (!NewParm)
5053  return true;
5054 
5055  if (ParamInfos)
5056  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5057  OutParamTypes.push_back(NewParm->getType());
5058  if (PVars)
5059  PVars->push_back(NewParm);
5060  continue;
5061  }
5062 
5063  // Deal with the possibility that we don't have a parameter
5064  // declaration for this parameter.
5065  QualType OldType = ParamTypes[i];
5066  bool IsPackExpansion = false;
5067  Optional<unsigned> NumExpansions;
5068  QualType NewType;
5069  if (const PackExpansionType *Expansion
5070  = dyn_cast<PackExpansionType>(OldType)) {
5071  // We have a function parameter pack that may need to be expanded.
5072  QualType Pattern = Expansion->getPattern();
5074  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5075 
5076  // Determine whether we should expand the parameter packs.
5077  bool ShouldExpand = false;
5078  bool RetainExpansion = false;
5079  if (getDerived().TryExpandParameterPacks(Loc, SourceRange(),
5080  Unexpanded,
5081  ShouldExpand,
5082  RetainExpansion,
5083  NumExpansions)) {
5084  return true;
5085  }
5086 
5087  if (ShouldExpand) {
5088  // Expand the function parameter pack into multiple, separate
5089  // parameters.
5090  for (unsigned I = 0; I != *NumExpansions; ++I) {
5091  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
5092  QualType NewType = getDerived().TransformType(Pattern);
5093  if (NewType.isNull())
5094  return true;
5095 
5096  if (NewType->containsUnexpandedParameterPack()) {
5097  NewType =
5098  getSema().getASTContext().getPackExpansionType(NewType, None);
5099 
5100  if (NewType.isNull())
5101  return true;
5102  }
5103 
5104  if (ParamInfos)
5105  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5106  OutParamTypes.push_back(NewType);
5107  if (PVars)
5108  PVars->push_back(nullptr);
5109  }
5110 
5111  // We're done with the pack expansion.
5112  continue;
5113  }
5114 
5115  // If we're supposed to retain a pack expansion, do so by temporarily
5116  // forgetting the partially-substituted parameter pack.
5117  if (RetainExpansion) {
5118  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5119  QualType NewType = getDerived().TransformType(Pattern);
5120  if (NewType.isNull())
5121  return true;
5122 
5123  if (ParamInfos)
5124  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5125  OutParamTypes.push_back(NewType);
5126  if (PVars)
5127  PVars->push_back(nullptr);
5128  }
5129 
5130  // We'll substitute the parameter now without expanding the pack
5131  // expansion.
5132  OldType = Expansion->getPattern();
5133  IsPackExpansion = true;
5134  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5135  NewType = getDerived().TransformType(OldType);
5136  } else {
5137  NewType = getDerived().TransformType(OldType);
5138  }
5139 
5140  if (NewType.isNull())
5141  return true;
5142 
5143  if (IsPackExpansion)
5144  NewType = getSema().Context.getPackExpansionType(NewType,
5145  NumExpansions);
5146 
5147  if (ParamInfos)
5148  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5149  OutParamTypes.push_back(NewType);
5150  if (PVars)
5151  PVars->push_back(nullptr);
5152  }
5153 
5154 #ifndef NDEBUG
5155  if (PVars) {
5156  for (unsigned i = 0, e = PVars->size(); i != e; ++i)
5157  if (ParmVarDecl *parm = (*PVars)[i])
5158  assert(parm->getFunctionScopeIndex() == i);
5159  }
5160 #endif
5161 
5162  return false;
5163 }
5164 
5165 template<typename Derived>
5166 QualType
5168  FunctionProtoTypeLoc TL) {
5169  SmallVector<QualType, 4> ExceptionStorage;
5170  TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
5171  return getDerived().TransformFunctionProtoType(
5172  TLB, TL, nullptr, 0,
5173  [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
5174  return This->TransformExceptionSpec(TL.getBeginLoc(), ESI,
5175  ExceptionStorage, Changed);
5176  });
5177 }
5178 
5179 template<typename Derived> template<typename Fn>
5181  TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
5182  unsigned ThisTypeQuals, Fn TransformExceptionSpec) {
5183 
5184  // Transform the parameters and return type.
5185  //
5186  // We are required to instantiate the params and return type in source order.
5187  // When the function has a trailing return type, we instantiate the
5188  // parameters before the return type, since the return type can then refer
5189  // to the parameters themselves (via decltype, sizeof, etc.).
5190  //
5191  SmallVector<QualType, 4> ParamTypes;
5192  SmallVector<ParmVarDecl*, 4> ParamDecls;
5193  Sema::ExtParameterInfoBuilder ExtParamInfos;
5194  const FunctionProtoType *T = TL.getTypePtr();
5195 
5196  QualType ResultType;
5197 
5198  if (T->hasTrailingReturn()) {
5199  if (getDerived().TransformFunctionTypeParams(
5200  TL.getBeginLoc(), TL.getParams(),
5201  TL.getTypePtr()->param_type_begin(),
5203  ParamTypes, &ParamDecls, ExtParamInfos))
5204  return QualType();
5205 
5206  {
5207  // C++11 [expr.prim.general]p3:
5208  // If a declaration declares a member function or member function
5209  // template of a class X, the expression this is a prvalue of type
5210  // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
5211  // and the end of the function-definition, member-declarator, or
5212  // declarator.
5213  Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, ThisTypeQuals);
5214 
5215  ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5216  if (ResultType.isNull())
5217  return QualType();
5218  }
5219  }
5220  else {
5221  ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5222  if (ResultType.isNull())
5223  return QualType();
5224 
5225  if (getDerived().TransformFunctionTypeParams(
5226  TL.getBeginLoc(), TL.getParams(),
5227  TL.getTypePtr()->param_type_begin(),
5229  ParamTypes, &ParamDecls, ExtParamInfos))
5230  return QualType();
5231  }
5232 
5234 
5235  bool EPIChanged = false;
5236  if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
5237  return QualType();
5238 
5239  // Handle extended parameter information.
5240  if (auto NewExtParamInfos =
5241  ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
5242  if (!EPI.ExtParameterInfos ||
5243  llvm::makeArrayRef(EPI.ExtParameterInfos, TL.getNumParams())
5244  != llvm::makeArrayRef(NewExtParamInfos, ParamTypes.size())) {
5245  EPIChanged = true;
5246  }
5247  EPI.ExtParameterInfos = NewExtParamInfos;
5248  } else if (EPI.ExtParameterInfos) {
5249  EPIChanged = true;
5250  EPI.ExtParameterInfos = nullptr;
5251  }
5252 
5253  QualType Result = TL.getType();
5254  if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
5255  T->getParamTypes() != llvm::makeArrayRef(ParamTypes) || EPIChanged) {
5256  Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
5257  if (Result.isNull())
5258  return QualType();
5259  }
5260 
5261  FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result);
5263  NewTL.setLParenLoc(TL.getLParenLoc());
5264  NewTL.setRParenLoc(TL.getRParenLoc());
5266  NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
5267  for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
5268  NewTL.setParam(i, ParamDecls[i]);
5269 
5270  return Result;
5271 }
5272 
5273 template<typename Derived>
5276  SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
5277  assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
5278 
5279  // Instantiate a dynamic noexcept expression, if any.
5280  if (ESI.Type == EST_ComputedNoexcept) {
5283  ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
5284  if (NoexceptExpr.isInvalid())
5285  return true;
5286 
5287  // FIXME: This is bogus, a noexcept expression is not a condition.
5288  NoexceptExpr = getSema().CheckBooleanCondition(Loc, NoexceptExpr.get());
5289  if (NoexceptExpr.isInvalid())
5290  return true;
5291 
5292  if (!NoexceptExpr.get()->isValueDependent()) {
5293  NoexceptExpr = getSema().VerifyIntegerConstantExpression(
5294  NoexceptExpr.get(), nullptr,
5295  diag::err_noexcept_needs_constant_expression,
5296  /*AllowFold*/false);
5297  if (NoexceptExpr.isInvalid())
5298  return true;
5299  }
5300 
5301  if (ESI.NoexceptExpr != NoexceptExpr.get())
5302  Changed = true;
5303  ESI.NoexceptExpr = NoexceptExpr.get();
5304  }
5305 
5306  if (ESI.Type != EST_Dynamic)
5307  return false;
5308 
5309  // Instantiate a dynamic exception specification's type.
5310  for (QualType T : ESI.Exceptions) {
5311  if (const PackExpansionType *PackExpansion =
5312  T->getAs<PackExpansionType>()) {
5313  Changed = true;
5314 
5315  // We have a pack expansion. Instantiate it.
5317  SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
5318  Unexpanded);
5319  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5320 
5321  // Determine whether the set of unexpanded parameter packs can and
5322  // should
5323  // be expanded.
5324  bool Expand = false;
5325  bool RetainExpansion = false;
5326  Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
5327  // FIXME: Track the location of the ellipsis (and track source location
5328  // information for the types in the exception specification in general).
5329  if (getDerived().TryExpandParameterPacks(
5330  Loc, SourceRange(), Unexpanded, Expand,
5331  RetainExpansion, NumExpansions))
5332  return true;
5333 
5334  if (!Expand) {
5335  // We can't expand this pack expansion into separate arguments yet;
5336  // just substitute into the pattern and create a new pack expansion
5337  // type.
5338  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5339  QualType U = getDerived().TransformType(PackExpansion->getPattern());
5340  if (U.isNull())
5341  return true;
5342 
5343  U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
5344  Exceptions.push_back(U);
5345  continue;
5346  }
5347 
5348  // Substitute into the pack expansion pattern for each slice of the
5349  // pack.
5350  for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
5351  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
5352 
5353  QualType U = getDerived().TransformType(PackExpansion->getPattern());
5354  if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
5355  return true;
5356 
5357  Exceptions.push_back(U);
5358  }
5359  } else {
5360  QualType U = getDerived().TransformType(T);
5361  if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
5362  return true;
5363  if (T != U)
5364  Changed = true;
5365 
5366  Exceptions.push_back(U);
5367  }
5368  }
5369 
5370  ESI.Exceptions = Exceptions;
5371  if (ESI.Exceptions.empty())
5372  ESI.Type = EST_DynamicNone;
5373  return false;
5374 }
5375 
5376 template<typename Derived>
5378  TypeLocBuilder &TLB,
5380  const FunctionNoProtoType *T = TL.getTypePtr();
5381  QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5382  if (ResultType.isNull())
5383  return QualType();
5384 
5385  QualType Result = TL.getType();
5386  if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
5387  Result = getDerived().RebuildFunctionNoProtoType(ResultType);
5388 
5389  FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result);
5391  NewTL.setLParenLoc(TL.getLParenLoc());
5392  NewTL.setRParenLoc(TL.getRParenLoc());
5393  NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
5394 
5395  return Result;
5396 }
5397 
5398 template<typename Derived> QualType
5401  const UnresolvedUsingType *T = TL.getTypePtr();
5402  Decl *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
5403  if (!D)
5404  return QualType();
5405 
5406  QualType Result = TL.getType();
5407  if (getDerived().AlwaysRebuild() || D != T->getDecl()) {
5408  Result = getDerived().RebuildUnresolvedUsingType(TL.getNameLoc(), D);
5409  if (Result.isNull())
5410  return QualType();
5411  }
5412 
5413  // We might get an arbitrary type spec type back. We should at
5414  // least always get a type spec type, though.
5415  TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(Result);
5416  NewTL.setNameLoc(TL.getNameLoc());
5417 
5418  return Result;
5419 }
5420 
5421 template<typename Derived>
5423  TypedefTypeLoc TL) {
5424  const TypedefType *T = TL.getTypePtr();
5425  TypedefNameDecl *Typedef
5426  = cast_or_null<TypedefNameDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5427  T->getDecl()));
5428  if (!Typedef)
5429  return QualType();
5430 
5431  QualType Result = TL.getType();
5432  if (getDerived().AlwaysRebuild() ||
5433  Typedef != T->getDecl()) {
5434  Result = getDerived().RebuildTypedefType(Typedef);
5435  if (Result.isNull())
5436  return QualType();
5437  }
5438 
5439  TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(Result);
5440  NewTL.setNameLoc(TL.getNameLoc());
5441 
5442  return Result;
5443 }
5444 
5445 template<typename Derived>
5447  TypeOfExprTypeLoc TL) {
5448  // typeof expressions are not potentially evaluated contexts
5452 
5453  ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
5454  if (E.isInvalid())
5455  return QualType();
5456 
5457  E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
5458  if (E.isInvalid())
5459  return QualType();
5460 
5461  QualType Result = TL.getType();
5462  if (getDerived().AlwaysRebuild() ||
5463  E.get() != TL.getUnderlyingExpr()) {
5464  Result = getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc());
5465  if (Result.isNull())
5466  return QualType();
5467  }
5468  else E.get();
5469 
5470  TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
5471  NewTL.setTypeofLoc(TL.getTypeofLoc());
5472  NewTL.setLParenLoc(TL.getLParenLoc());
5473  NewTL.setRParenLoc(TL.getRParenLoc());
5474 
5475  return Result;
5476 }
5477 
5478 template<typename Derived>
5480  TypeOfTypeLoc TL) {
5481  TypeSourceInfo* Old_Under_TI = TL.getUnderlyingTInfo();
5482  TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
5483  if (!New_Under_TI)
5484  return QualType();
5485 
5486  QualType Result = TL.getType();
5487  if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
5488  Result = getDerived().RebuildTypeOfType(New_Under_TI->getType());
5489  if (Result.isNull())
5490  return QualType();
5491  }
5492 
5493  TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
5494  NewTL.setTypeofLoc(TL.getTypeofLoc());
5495  NewTL.setLParenLoc(TL.getLParenLoc());
5496  NewTL.setRParenLoc(TL.getRParenLoc());
5497  NewTL.setUnderlyingTInfo(New_Under_TI);
5498 
5499  return Result;
5500 }
5501 
5502 template<typename Derived>
5504  DecltypeTypeLoc TL) {
5505  const DecltypeType *T = TL.getTypePtr();
5506 
5507  // decltype expressions are not potentially evaluated contexts
5510  /*IsDecltype=*/true);
5511 
5512  ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
5513  if (E.isInvalid())
5514  return QualType();
5515 
5516  E = getSema().ActOnDecltypeExpression(E.get());
5517  if (E.isInvalid())
5518  return QualType();
5519 
5520  QualType Result = TL.getType();
5521  if (getDerived().AlwaysRebuild() ||
5522  E.get() != T->getUnderlyingExpr()) {
5523  Result = getDerived().RebuildDecltypeType(E.get(), TL.getNameLoc());
5524  if (Result.isNull())
5525  return QualType();
5526  }
5527  else E.get();
5528 
5529  DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
5530  NewTL.setNameLoc(TL.getNameLoc());
5531 
5532  return Result;
5533 }
5534 
5535 template<typename Derived>
5537  TypeLocBuilder &TLB,
5538  UnaryTransformTypeLoc TL) {
5539  QualType Result = TL.getType();
5540  if (Result->isDependentType()) {
5541  const UnaryTransformType *T = TL.getTypePtr();
5542  QualType NewBase =
5543  getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
5544  Result = getDerived().RebuildUnaryTransformType(NewBase,
5545  T->getUTTKind(),
5546  TL.getKWLoc());
5547  if (Result.isNull())
5548  return QualType();
5549  }
5550 
5551  UnaryTransformTypeLoc NewTL = TLB.push<UnaryTransformTypeLoc>(Result);
5552  NewTL.setKWLoc(TL.getKWLoc());
5553  NewTL.setParensRange(TL.getParensRange());
5555  return Result;
5556 }
5557 
5558 template<typename Derived>
5560  AutoTypeLoc TL) {
5561  const AutoType *T = TL.getTypePtr();
5562  QualType OldDeduced = T->getDeducedType();
5563  QualType NewDeduced;
5564  if (!OldDeduced.isNull()) {
5565  NewDeduced = getDerived().TransformType(OldDeduced);
5566  if (NewDeduced.isNull())
5567  return QualType();
5568  }
5569 
5570  QualType Result = TL.getType();
5571  if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
5572  T->isDependentType()) {
5573  Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword());
5574  if (Result.isNull())
5575  return QualType();
5576  }
5577 
5578  AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
5579  NewTL.setNameLoc(TL.getNameLoc());
5580 
5581  return Result;
5582 }
5583 
5584 template<typename Derived>
5588 
5589  CXXScopeSpec SS;
5590  TemplateName TemplateName = getDerived().TransformTemplateName(
5591  SS, T->getTemplateName(), TL.getTemplateNameLoc());
5592  if (TemplateName.isNull())
5593  return QualType();
5594 
5595  QualType OldDeduced = T->getDeducedType();
5596  QualType NewDeduced;
5597  if (!OldDeduced.isNull()) {
5598  NewDeduced = getDerived().TransformType(OldDeduced);
5599  if (NewDeduced.isNull())
5600  return QualType();
5601  }
5602 
5603  QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
5604  TemplateName, NewDeduced);
5605  if (Result.isNull())
5606  return QualType();
5607 
5611 
5612  return Result;
5613 }
5614 
5615 template<typename Derived>
5617  RecordTypeLoc TL) {
5618  const RecordType *T = TL.getTypePtr();
5619  RecordDecl *Record
5620  = cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5621  T->getDecl()));
5622  if (!Record)
5623  return QualType();
5624 
5625  QualType Result = TL.getType();
5626  if (getDerived().AlwaysRebuild() ||
5627  Record != T->getDecl()) {
5628  Result = getDerived().RebuildRecordType(Record);
5629  if (Result.isNull())
5630  return QualType();
5631  }
5632 
5633  RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(Result);
5634  NewTL.setNameLoc(TL.getNameLoc());
5635 
5636  return Result;
5637 }
5638 
5639 template<typename Derived>
5641  EnumTypeLoc TL) {
5642  const EnumType *T = TL.getTypePtr();
5643  EnumDecl *Enum
5644  = cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5645  T->getDecl()));
5646  if (!Enum)
5647  return QualType();
5648 
5649  QualType Result = TL.getType();
5650  if (getDerived().AlwaysRebuild() ||
5651  Enum != T->getDecl()) {
5652  Result = getDerived().RebuildEnumType(Enum);
5653  if (Result.isNull())
5654  return QualType();
5655  }
5656 
5657  EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(Result);
5658  NewTL.setNameLoc(TL.getNameLoc());
5659 
5660  return Result;
5661 }
5662 
5663 template<typename Derived>
5665  TypeLocBuilder &TLB,
5667  Decl *D = getDerived().TransformDecl(TL.getNameLoc(),
5668  TL.getTypePtr()->getDecl());
5669  if (!D) return QualType();
5670 
5671  QualType T = SemaRef.Context.getTypeDeclType(cast<TypeDecl>(D));
5672  TLB.pushTypeSpec(T).setNameLoc(TL.getNameLoc());
5673  return T;
5674 }
5675 
5676 template<typename Derived>
5678  TypeLocBuilder &TLB,
5680  return TransformTypeSpecType(TLB, TL);
5681 }
5682 
5683 template<typename Derived>
5685  TypeLocBuilder &TLB,
5687  const SubstTemplateTypeParmType *T = TL.getTypePtr();
5688 
5689  // Substitute into the replacement type, which itself might involve something
5690  // that needs to be transformed. This only tends to occur with default
5691  // template arguments of template template parameters.
5692  TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
5693  QualType Replacement = getDerived().TransformType(T->getReplacementType());
5694  if (Replacement.isNull())
5695  return QualType();
5696 
5697  // Always canonicalize the replacement type.
5698  Replacement = SemaRef.Context.getCanonicalType(Replacement);
5699  QualType Result
5700  = SemaRef.Context.getSubstTemplateTypeParmType(T->getReplacedParameter(),
5701  Replacement);
5702 
5703  // Propagate type-source information.
5705  = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
5706  NewTL.setNameLoc(TL.getNameLoc());
5707  return Result;
5708 
5709 }
5710 
5711 template<typename Derived>
5713  TypeLocBuilder &TLB,
5715  return TransformTypeSpecType(TLB, TL);
5716 }
5717 
5718 template<typename Derived>
5720  TypeLocBuilder &TLB,
5722  const TemplateSpecializationType *T = TL.getTypePtr();
5723 
5724  // The nested-name-specifier never matters in a TemplateSpecializationType,
5725  // because we can't have a dependent nested-name-specifier anyway.
5726  CXXScopeSpec SS;
5727  TemplateName Template
5728  = getDerived().TransformTemplateName(SS, T->getTemplateName(),
5729  TL.getTemplateNameLoc());
5730  if (Template.isNull())
5731  return QualType();
5732 
5733  return getDerived().TransformTemplateSpecializationType(TLB, TL, Template);
5734 }
5735 
5736 template<typename Derived>
5738  AtomicTypeLoc TL) {
5739  QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
5740  if (ValueType.isNull())
5741  return QualType();
5742 
5743  QualType Result = TL.getType();
5744  if (getDerived().AlwaysRebuild() ||
5745  ValueType != TL.getValueLoc().getType()) {
5746  Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
5747  if (Result.isNull())
5748  return QualType();
5749  }
5750 
5751  AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
5752  NewTL.setKWLoc(TL.getKWLoc());
5753  NewTL.setLParenLoc(TL.getLParenLoc());
5754  NewTL.setRParenLoc(TL.getRParenLoc());
5755 
5756  return Result;
5757 }
5758 
5759 template <typename Derived>
5761  PipeTypeLoc TL) {
5762  QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
5763  if (ValueType.isNull())
5764  return QualType();
5765 
5766  QualType Result = TL.getType();
5767  if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
5768  const PipeType *PT = Result->getAs<PipeType>();
5769  bool isReadPipe = PT->isReadOnly();
5770  Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
5771  if (Result.isNull())
5772  return QualType();
5773  }
5774 
5775  PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
5776  NewTL.setKWLoc(TL.getKWLoc());
5777 
5778  return Result;
5779 }
5780 
5781  /// \brief Simple iterator that traverses the template arguments in a
5782  /// container that provides a \c getArgLoc() member function.
5783  ///
5784  /// This iterator is intended to be used with the iterator form of
5785  /// \c TreeTransform<Derived>::TransformTemplateArguments().
5786  template<typename ArgLocContainer>
5788  ArgLocContainer *Container;
5789  unsigned Index;
5790 
5791  public:
5794  typedef int difference_type;
5795  typedef std::input_iterator_tag iterator_category;
5796 
5797  class pointer {
5798  TemplateArgumentLoc Arg;
5799 
5800  public:
5801  explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5802 
5804  return &Arg;
5805  }
5806  };
5807 
5808 
5810 
5811  TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
5812  unsigned Index)
5813  : Container(&Container), Index(Index) { }
5814 
5816  ++Index;
5817  return *this;
5818  }
5819 
5822  ++(*this);
5823  return Old;
5824  }
5825 
5827  return Container->getArgLoc(Index);
5828  }
5829 
5831  return pointer(Container->getArgLoc(Index));
5832  }
5833 
5836  return X.Container == Y.Container && X.Index == Y.Index;
5837  }
5838 
5841  return !(X == Y);
5842  }
5843  };
5844 
5845 
5846 template <typename Derived>
5848  TypeLocBuilder &TLB,
5850  TemplateName Template) {
5851  TemplateArgumentListInfo NewTemplateArgs;
5852  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
5853  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
5855  ArgIterator;
5856  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
5857  ArgIterator(TL, TL.getNumArgs()),
5858  NewTemplateArgs))
5859  return QualType();
5860 
5861  // FIXME: maybe don't rebuild if all the template arguments are the same.
5862 
5863  QualType Result =
5864  getDerived().RebuildTemplateSpecializationType(Template,
5865  TL.getTemplateNameLoc(),
5866  NewTemplateArgs);
5867 
5868  if (!Result.isNull()) {
5869  // Specializations of template template parameters are represented as
5870  // TemplateSpecializationTypes, and substitution of type alias templates
5871  // within a dependent context can transform them into
5872  // DependentTemplateSpecializationTypes.
5873  if (isa<DependentTemplateSpecializationType>(Result)) {
5880  NewTL.setLAngleLoc(TL.getLAngleLoc());
5881  NewTL.setRAngleLoc(TL.getRAngleLoc());
5882  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
5883  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
5884  return Result;
5885  }
5886 
5888  = TLB.push<TemplateSpecializationTypeLoc>(Result);
5891  NewTL.setLAngleLoc(TL.getLAngleLoc());
5892  NewTL.setRAngleLoc(TL.getRAngleLoc());
5893  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
5894  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
5895  }
5896 
5897  return Result;
5898 }
5899 
5900 template <typename Derived>
5902  TypeLocBuilder &TLB,
5904  TemplateName Template,
5905  CXXScopeSpec &SS) {
5906  TemplateArgumentListInfo NewTemplateArgs;
5907  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
5908  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
5911  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
5912  ArgIterator(TL, TL.getNumArgs()),
5913  NewTemplateArgs))
5914  return QualType();
5915 
5916  // FIXME: maybe don't rebuild if all the template arguments are the same.
5917 
5918  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
5919  QualType Result
5920  = getSema().Context.getDependentTemplateSpecializationType(
5921  TL.getTypePtr()->getKeyword(),
5922  DTN->getQualifier(),
5923  DTN->getIdentifier(),
5924  NewTemplateArgs);
5925 
5929  NewTL.setQualifierLoc(SS.getWithLocInContext(SemaRef.Context));
5932  NewTL.setLAngleLoc(TL.getLAngleLoc());
5933  NewTL.setRAngleLoc(TL.getRAngleLoc());
5934  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
5935  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
5936  return Result;
5937  }
5938 
5939  QualType Result
5940  = getDerived().RebuildTemplateSpecializationType(Template,
5941  TL.getTemplateNameLoc(),
5942  NewTemplateArgs);
5943 
5944  if (!Result.isNull()) {
5945  /// FIXME: Wrap this in an elaborated-type-specifier?
5947  = TLB.push<TemplateSpecializationTypeLoc>(Result);
5950  NewTL.setLAngleLoc(TL.getLAngleLoc());
5951  NewTL.setRAngleLoc(TL.getRAngleLoc());
5952  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
5953  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
5954  }
5955 
5956  return Result;
5957 }
5958 
5959 template<typename Derived>
5960 QualType
5962  ElaboratedTypeLoc TL) {
5963  const ElaboratedType *T = TL.getTypePtr();
5964 
5965  NestedNameSpecifierLoc QualifierLoc;
5966  // NOTE: the qualifier in an ElaboratedType is optional.
5967  if (TL.getQualifierLoc()) {
5968  QualifierLoc
5969  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
5970  if (!QualifierLoc)
5971  return QualType();
5972  }
5973 
5974  QualType NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc());
5975  if (NamedT.isNull())
5976  return QualType();
5977 
5978  // C++0x [dcl.type.elab]p2:
5979  // If the identifier resolves to a typedef-name or the simple-template-id
5980  // resolves to an alias template specialization, the
5981  // elaborated-type-specifier is ill-formed.
5982  if (T->getKeyword() != ETK_None && T->getKeyword() != ETK_Typename) {
5983  if (const TemplateSpecializationType *TST =
5984  NamedT->getAs<TemplateSpecializationType>()) {
5985  TemplateName Template = TST->getTemplateName();
5986  if (TypeAliasTemplateDecl *TAT = dyn_cast_or_null<TypeAliasTemplateDecl>(
5987  Template.getAsTemplateDecl())) {
5988  SemaRef.Diag(TL.getNamedTypeLoc().getBeginLoc(),
5989  diag::err_tag_reference_non_tag)
5990  << TAT << Sema::NTK_TypeAliasTemplate
5992  SemaRef.Diag(TAT->getLocation(), diag::note_declared_at);
5993  }
5994  }
5995  }
5996 
5997  QualType Result = TL.getType();
5998  if (getDerived().AlwaysRebuild() ||
5999  QualifierLoc != TL.getQualifierLoc() ||
6000  NamedT != T->getNamedType()) {
6001  Result = getDerived().RebuildElaboratedType(TL.getElaboratedKeywordLoc(),
6002  T->getKeyword(),
6003  QualifierLoc, NamedT);
6004  if (Result.isNull())
6005  return QualType();
6006  }
6007 
6008  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6010  NewTL.setQualifierLoc(QualifierLoc);
6011  return Result;
6012 }
6013 
6014 template<typename Derived>
6016  TypeLocBuilder &TLB,
6017  AttributedTypeLoc TL) {
6018  const AttributedType *oldType = TL.getTypePtr();
6019  QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
6020  if (modifiedType.isNull())
6021  return QualType();
6022 
6023  QualType result = TL.getType();
6024 
6025  // FIXME: dependent operand expressions?
6026  if (getDerived().AlwaysRebuild() ||
6027  modifiedType != oldType->getModifiedType()) {
6028  // TODO: this is really lame; we should really be rebuilding the
6029  // equivalent type from first principles.
6030  QualType equivalentType
6031  = getDerived().TransformType(oldType->getEquivalentType());
6032  if (equivalentType.isNull())
6033  return QualType();
6034 
6035  // Check whether we can add nullability; it is only represented as
6036  // type sugar, and therefore cannot be diagnosed in any other way.
6037  if (auto nullability = oldType->getImmediateNullability()) {
6038  if (!modifiedType->canHaveNullability()) {
6039  SemaRef.Diag(TL.getAttrNameLoc(), diag::err_nullability_nonpointer)
6040  << DiagNullabilityKind(*nullability, false) << modifiedType;
6041  return QualType();
6042  }
6043  }
6044 
6045  result = SemaRef.Context.getAttributedType(oldType->getAttrKind(),
6046  modifiedType,
6047  equivalentType);
6048  }
6049 
6050  AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
6051  newTL.setAttrNameLoc(TL.getAttrNameLoc());
6052  if (TL.hasAttrOperand())
6054  if (TL.hasAttrExprOperand())
6056  else if (TL.hasAttrEnumOperand())
6058 
6059  return result;
6060 }
6061 
6062 template<typename Derived>
6063 QualType
6065  ParenTypeLoc TL) {
6066  QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
6067  if (Inner.isNull())
6068  return QualType();
6069 
6070  QualType Result = TL.getType();
6071  if (getDerived().AlwaysRebuild() ||
6072  Inner != TL.getInnerLoc().getType()) {
6073  Result = getDerived().RebuildParenType(Inner);
6074  if (Result.isNull())
6075  return QualType();
6076  }
6077 
6078  ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
6079  NewTL.setLParenLoc(TL.getLParenLoc());
6080  NewTL.setRParenLoc(TL.getRParenLoc());
6081  return Result;
6082 }
6083 
6084 template<typename Derived>
6087  return TransformDependentNameType(TLB, TL, false);
6088 }
6089 
6090 template<typename Derived>
6092  TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext) {
6093  const DependentNameType *T = TL.getTypePtr();
6094 
6095  NestedNameSpecifierLoc QualifierLoc
6096  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6097  if (!QualifierLoc)
6098  return QualType();
6099 
6100  QualType Result
6101  = getDerived().RebuildDependentNameType(T->getKeyword(),
6103  QualifierLoc,
6104  T->getIdentifier(),
6105  TL.getNameLoc(),
6106  DeducedTSTContext);
6107  if (Result.isNull())
6108  return QualType();
6109 
6110  if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) {
6111  QualType NamedT = ElabT->getNamedType();
6112  TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc());
6113 
6114  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6116  NewTL.setQualifierLoc(QualifierLoc);
6117  } else {
6118  DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
6120  NewTL.setQualifierLoc(QualifierLoc);
6121  NewTL.setNameLoc(TL.getNameLoc());
6122  }
6123  return Result;
6124 }
6125 
6126 template<typename Derived>
6130  NestedNameSpecifierLoc QualifierLoc;
6131  if (TL.getQualifierLoc()) {
6132  QualifierLoc
6133  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6134  if (!QualifierLoc)
6135  return QualType();
6136  }
6137 
6138  return getDerived()
6139  .TransformDependentTemplateSpecializationType(TLB, TL, QualifierLoc);
6140 }
6141 
6142 template<typename Derived>
6146  NestedNameSpecifierLoc QualifierLoc) {
6148 
6149  TemplateArgumentListInfo NewTemplateArgs;
6150  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
6151  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
6152 
6155  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
6156  ArgIterator(TL, TL.getNumArgs()),
6157  NewTemplateArgs))
6158  return QualType();
6159 
6160  QualType Result = getDerived().RebuildDependentTemplateSpecializationType(
6161  T->getKeyword(), QualifierLoc, T->getIdentifier(),
6162  TL.getTemplateNameLoc(), NewTemplateArgs,
6163  /*AllowInjectedClassName*/ false);
6164  if (Result.isNull())
6165  return QualType();
6166 
6167  if (const ElaboratedType *ElabT = dyn_cast<ElaboratedType>(Result)) {
6168  QualType NamedT = ElabT->getNamedType();
6169 
6170  // Copy information relevant to the template specialization.
6172  = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
6174  NamedTL.setTemplateNameLoc(TL.getTemplateNameLoc());
6175  NamedTL.setLAngleLoc(TL.getLAngleLoc());
6176  NamedTL.setRAngleLoc(TL.getRAngleLoc());
6177  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6178  NamedTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6179 
6180  // Copy information relevant to the elaborated type.
6181  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6183  NewTL.setQualifierLoc(QualifierLoc);
6184  } else if (isa<DependentTemplateSpecializationType>(Result)) {
6188  SpecTL.setQualifierLoc(QualifierLoc);
6191  SpecTL.setLAngleLoc(TL.getLAngleLoc());
6192  SpecTL.setRAngleLoc(TL.getRAngleLoc());
6193  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6194  SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6195  } else {
6197  = TLB.push<TemplateSpecializationTypeLoc>(Result);
6200  SpecTL.setLAngleLoc(TL.getLAngleLoc());
6201  SpecTL.setRAngleLoc(TL.getRAngleLoc());
6202  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6203  SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6204  }
6205  return Result;
6206 }
6207 
6208 template<typename Derived>
6210  PackExpansionTypeLoc TL) {
6211  QualType Pattern
6212  = getDerived().TransformType(TLB, TL.getPatternLoc());
6213  if (Pattern.isNull())
6214  return QualType();
6215 
6216  QualType Result = TL.getType();
6217  if (getDerived().AlwaysRebuild() ||
6218  Pattern != TL.getPatternLoc().getType()) {
6219  Result = getDerived().RebuildPackExpansionType(Pattern,
6221  TL.getEllipsisLoc(),
6222  TL.getTypePtr()->getNumExpansions());
6223  if (Result.isNull())
6224  return QualType();
6225  }
6226 
6227  PackExpansionTypeLoc NewT = TLB.push<PackExpansionTypeLoc>(Result);
6228  NewT.setEllipsisLoc(TL.getEllipsisLoc());
6229  return Result;
6230 }
6231 
6232 template<typename Derived>
6233 QualType
6235  ObjCInterfaceTypeLoc TL) {
6236  // ObjCInterfaceType is never dependent.
6237  TLB.pushFullCopy(TL);
6238  return TL.getType();
6239 }
6240 
6241 template<typename Derived>
6242 QualType
6244  ObjCTypeParamTypeLoc TL) {
6245  const ObjCTypeParamType *T = TL.getTypePtr();
6246  ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
6247  getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
6248  if (!OTP)
6249  return QualType();
6250 
6251  QualType Result = TL.getType();
6252  if (getDerived().AlwaysRebuild() ||
6253  OTP != T->getDecl()) {
6254  Result = getDerived().RebuildObjCTypeParamType(OTP,
6255  TL.getProtocolLAngleLoc(),
6256  llvm::makeArrayRef(TL.getTypePtr()->qual_begin(),
6257  TL.getNumProtocols()),
6258  TL.getProtocolLocs(),
6259  TL.getProtocolRAngleLoc());
6260  if (Result.isNull())
6261  return QualType();
6262  }
6263 
6264  ObjCTypeParamTypeLoc NewTL = TLB.push<ObjCTypeParamTypeLoc>(Result);
6265  if (TL.getNumProtocols()) {
6267  for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
6268  NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
6270  }
6271  return Result;
6272 }
6273 
6274 template<typename Derived>
6275 QualType
6277  ObjCObjectTypeLoc TL) {
6278  // Transform base type.
6279  QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
6280  if (BaseType.isNull())
6281  return QualType();
6282 
6283  bool AnyChanged = BaseType != TL.getBaseLoc().getType();
6284 
6285  // Transform type arguments.
6286  SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
6287  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
6288  TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
6289  TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
6290  QualType TypeArg = TypeArgInfo->getType();
6291  if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
6292  AnyChanged = true;
6293 
6294  // We have a pack expansion. Instantiate it.
6295  const auto *PackExpansion = PackExpansionLoc.getType()
6298  SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6299  Unexpanded);
6300  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6301 
6302  // Determine whether the set of unexpanded parameter packs can
6303  // and should be expanded.
6304  TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
6305  bool Expand = false;
6306  bool RetainExpansion = false;
6307  Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
6308  if (getDerived().TryExpandParameterPacks(
6309  PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
6310  Unexpanded, Expand, RetainExpansion, NumExpansions))
6311  return QualType();
6312 
6313  if (!Expand) {
6314  // We can't expand this pack expansion into separate arguments yet;
6315  // just substitute into the pattern and create a new pack expansion
6316  // type.
6317  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6318 
6319  TypeLocBuilder TypeArgBuilder;
6320  TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
6321  QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
6322  PatternLoc);
6323  if (NewPatternType.isNull())
6324  return QualType();
6325 
6326  QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
6327  NewPatternType, NumExpansions);
6328  auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
6329  NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
6330  NewTypeArgInfos.push_back(
6331  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
6332  continue;
6333  }
6334 
6335  // Substitute into the pack expansion pattern for each slice of the
6336  // pack.
6337  for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6338  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
6339 
6340  TypeLocBuilder TypeArgBuilder;
6341  TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
6342 
6343  QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
6344  PatternLoc);
6345  if (NewTypeArg.isNull())
6346  return QualType();
6347 
6348  NewTypeArgInfos.push_back(
6349  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
6350  }
6351 
6352  continue;
6353  }
6354 
6355  TypeLocBuilder TypeArgBuilder;
6356  TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
6357  QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
6358  if (NewTypeArg.isNull())
6359  return QualType();
6360 
6361  // If nothing changed, just keep the old TypeSourceInfo.
6362  if (NewTypeArg == TypeArg) {
6363  NewTypeArgInfos.push_back(TypeArgInfo);
6364  continue;
6365  }
6366 
6367  NewTypeArgInfos.push_back(
6368  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
6369  AnyChanged = true;
6370  }
6371 
6372  QualType Result = TL.getType();
6373  if (getDerived().AlwaysRebuild() || AnyChanged) {
6374  // Rebuild the type.
6375  Result = getDerived().RebuildObjCObjectType(
6376  BaseType,
6377  TL.getLocStart(),
6378  TL.getTypeArgsLAngleLoc(),
6379  NewTypeArgInfos,
6380  TL.getTypeArgsRAngleLoc(),
6381  TL.getProtocolLAngleLoc(),
6382  llvm::makeArrayRef(TL.getTypePtr()->qual_begin(),
6383  TL.getNumProtocols()),
6384  TL.getProtocolLocs(),
6385  TL.getProtocolRAngleLoc());
6386 
6387  if (Result.isNull())
6388  return QualType();
6389  }
6390 
6391  ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
6392  NewT.setHasBaseTypeAsWritten(true);
6394  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
6395  NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
6398  for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
6399  NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
6401  return Result;
6402 }
6403 
6404 template<typename Derived>
6405 QualType
6408  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
6409  if (PointeeType.isNull())
6410  return QualType();
6411 
6412  QualType Result = TL.getType();
6413  if (getDerived().AlwaysRebuild() ||
6414  PointeeType != TL.getPointeeLoc().getType()) {
6415  Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
6416  TL.getStarLoc());
6417  if (Result.isNull())
6418  return QualType();
6419  }
6420 
6422  NewT.setStarLoc(TL.getStarLoc());
6423  return Result;
6424 }
6425 
6426 //===----------------------------------------------------------------------===//
6427 // Statement transformation
6428 //===----------------------------------------------------------------------===//
6429 template<typename Derived>
6430 StmtResult
6432  return S;
6433 }
6434 
6435 template<typename Derived>
6436 StmtResult
6438  return getDerived().TransformCompoundStmt(S, false);
6439 }
6440 
6441 template<typename Derived>
6442 StmtResult
6444  bool IsStmtExpr) {
6445  Sema::CompoundScopeRAII CompoundScope(getSema());
6446 
6447  bool SubStmtInvalid = false;
6448  bool SubStmtChanged = false;
6449  SmallVector<Stmt*, 8> Statements;
6450  for (auto *B : S->body()) {
6451  StmtResult Result = getDerived().TransformStmt(B);
6452  if (Result.isInvalid()) {
6453  // Immediately fail if this was a DeclStmt, since it's very
6454  // likely that this will cause problems for future statements.
6455  if (isa<DeclStmt>(B))
6456  return StmtError();
6457 
6458  // Otherwise, just keep processing substatements and fail later.
6459  SubStmtInvalid = true;
6460  continue;
6461  }
6462 
6463  SubStmtChanged = SubStmtChanged || Result.get() != B;
6464  Statements.push_back(Result.getAs<Stmt>());
6465  }
6466 
6467  if (SubStmtInvalid)
6468  return StmtError();
6469 
6470  if (!getDerived().AlwaysRebuild() &&
6471  !SubStmtChanged)
6472  return S;
6473 
6474  return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
6475  Statements,
6476  S->getRBracLoc(),
6477  IsStmtExpr);
6478 }
6479 
6480 template<typename Derived>
6481 StmtResult
6483  ExprResult LHS, RHS;
6484  {
6487 
6488  // Transform the left-hand case value.
6489  LHS = getDerived().TransformExpr(S->getLHS());
6490  LHS = SemaRef.ActOnConstantExpression(LHS);
6491  if (LHS.isInvalid())
6492  return StmtError();
6493 
6494  // Transform the right-hand case value (for the GNU case-range extension).
6495  RHS = getDerived().TransformExpr(S->getRHS());
6496  RHS = SemaRef.ActOnConstantExpression(RHS);
6497  if (RHS.isInvalid())
6498  return StmtError();
6499  }
6500 
6501  // Build the case statement.
6502  // Case statements are always rebuilt so that they will attached to their
6503  // transformed switch statement.
6504  StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
6505  LHS.get(),
6506  S->getEllipsisLoc(),
6507  RHS.get(),
6508  S->getColonLoc());
6509  if (Case.isInvalid())
6510  return StmtError();
6511 
6512  // Transform the statement following the case
6513  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6514  if (SubStmt.isInvalid())
6515  return StmtError();
6516 
6517  // Attach the body to the case statement
6518  return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
6519 }
6520 
6521 template<typename Derived>
6522 StmtResult
6524  // Transform the statement following the default case
6525  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6526  if (SubStmt.isInvalid())
6527  return StmtError();
6528 
6529  // Default statements are always rebuilt
6530  return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
6531  SubStmt.get());
6532 }
6533 
6534 template<typename Derived>
6535 StmtResult
6537  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6538  if (SubStmt.isInvalid())
6539  return StmtError();
6540 
6541  Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
6542  S->getDecl());
6543  if (!LD)
6544  return StmtError();
6545 
6546 
6547  // FIXME: Pass the real colon location in.
6548  return getDerived().RebuildLabelStmt(S->getIdentLoc(),
6549  cast<LabelDecl>(LD), SourceLocation(),
6550  SubStmt.get());
6551 }
6552 
6553 template <typename Derived>
6555  if (!R)
6556  return R;
6557 
6558  switch (R->getKind()) {
6559 // Transform attributes with a pragma spelling by calling TransformXXXAttr.
6560 #define ATTR(X)
6561 #define PRAGMA_SPELLING_ATTR(X) \
6562  case attr::X: \
6563  return getDerived().Transform##X##Attr(cast<X##Attr>(R));
6564 #include "clang/Basic/AttrList.inc"
6565  default:
6566  return R;
6567  }
6568 }
6569 
6570 template <typename Derived>
6572  bool AttrsChanged = false;
6574 
6575  // Visit attributes and keep track if any are transformed.
6576  for (const auto *I : S->getAttrs()) {
6577  const Attr *R = getDerived().TransformAttr(I);
6578  AttrsChanged |= (I != R);
6579  Attrs.push_back(R);
6580  }
6581 
6582  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6583  if (SubStmt.isInvalid())
6584  return StmtError();
6585 
6586  if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
6587  return S;
6588 
6589  return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
6590  SubStmt.get());
6591 }
6592 
6593 template<typename Derived>
6594 StmtResult
6596  // Transform the initialization statement
6597  StmtResult Init = getDerived().TransformStmt(S->getInit());
6598  if (Init.isInvalid())
6599  return StmtError();
6600 
6601  // Transform the condition
6602  Sema::ConditionResult Cond = getDerived().TransformCondition(
6603  S->getIfLoc(), S->getConditionVariable(), S->getCond(),
6606  if (Cond.isInvalid())
6607  return StmtError();
6608 
6609  // If this is a constexpr if, determine which arm we should instantiate.
6610  llvm::Optional<bool> ConstexprConditionValue;
6611  if (S->isConstexpr())
6612  ConstexprConditionValue = Cond.getKnownValue();
6613 
6614  // Transform the "then" branch.
6615  StmtResult Then;
6616  if (!ConstexprConditionValue || *ConstexprConditionValue) {
6617  Then = getDerived().TransformStmt(S->getThen());
6618  if (Then.isInvalid())
6619  return StmtError();
6620  } else {
6621  Then = new (getSema().Context) NullStmt(S->getThen()->getLocStart());
6622  }
6623 
6624  // Transform the "else" branch.
6625  StmtResult Else;
6626  if (!ConstexprConditionValue || !*ConstexprConditionValue) {
6627  Else = getDerived().TransformStmt(S->getElse());
6628  if (Else.isInvalid())
6629  return StmtError();
6630  }
6631 
6632  if (!getDerived().AlwaysRebuild() &&
6633  Init.get() == S->getInit() &&
6634  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
6635  Then.get() == S->getThen() &&
6636  Else.get() == S->getElse())
6637  return S;
6638 
6639  return getDerived().RebuildIfStmt(S->getIfLoc(), S->isConstexpr(), Cond,
6640  Init.get(), Then.get(), S->getElseLoc(),
6641  Else.get());
6642 }
6643 
6644 template<typename Derived>
6645 StmtResult
6647  // Transform the initialization statement
6648  StmtResult Init = getDerived().TransformStmt(S->getInit());
6649  if (Init.isInvalid())
6650  return StmtError();
6651 
6652  // Transform the condition.
6653  Sema::ConditionResult Cond = getDerived().TransformCondition(
6654  S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
6656  if (Cond.isInvalid())
6657  return StmtError();
6658 
6659  // Rebuild the switch statement.
6660  StmtResult Switch
6661  = getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond);
6662  if (Switch.isInvalid())
6663  return StmtError();
6664 
6665  // Transform the body of the switch statement.
6666  StmtResult Body = getDerived().TransformStmt(S->getBody());
6667  if (Body.isInvalid())
6668  return StmtError();
6669 
6670  // Complete the switch statement.
6671  return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
6672  Body.get());
6673 }
6674 
6675 template<typename Derived>
6676 StmtResult
6678  // Transform the condition
6679  Sema::ConditionResult Cond = getDerived().TransformCondition(
6680  S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
6682  if (Cond.isInvalid())
6683  return StmtError();
6684 
6685  // Transform the body
6686  StmtResult Body = getDerived().TransformStmt(S->getBody());
6687  if (Body.isInvalid())
6688  return StmtError();
6689 
6690  if (!getDerived().AlwaysRebuild() &&
6691  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
6692  Body.get() == S->getBody())
6693  return Owned(S);
6694 
6695  return getDerived().RebuildWhileStmt(S->getWhileLoc(), Cond, Body.get());
6696 }
6697 
6698 template<typename Derived>
6699 StmtResult
6701  // Transform the body
6702  StmtResult Body = getDerived().TransformStmt(S->getBody());
6703  if (Body.isInvalid())
6704  return StmtError();
6705 
6706  // Transform the condition
6707  ExprResult Cond = getDerived().TransformExpr(S->getCond());
6708  if (Cond.isInvalid())
6709  return StmtError();
6710 
6711  if (!getDerived().AlwaysRebuild() &&
6712  Cond.get() == S->getCond() &&
6713  Body.get() == S->getBody())
6714  return S;
6715 
6716  return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
6717  /*FIXME:*/S->getWhileLoc(), Cond.get(),
6718  S->getRParenLoc());
6719 }
6720 
6721 template<typename Derived>
6722 StmtResult
6724  // Transform the initialization statement
6725  StmtResult Init = getDerived().TransformStmt(S->getInit());
6726  if (Init.isInvalid())
6727  return StmtError();
6728 
6729  // In OpenMP loop region loop control variable must be captured and be
6730  // private. Perform analysis of first part (if any).
6731  if (getSema().getLangOpts().OpenMP && Init.isUsable())
6732  getSema().ActOnOpenMPLoopInitialization(S->getForLoc(), Init.get());
6733 
6734  // Transform the condition
6735  Sema::ConditionResult Cond = getDerived().TransformCondition(
6736  S->getForLoc(), S->getConditionVariable(), S->getCond(),
6738  if (Cond.isInvalid())
6739  return StmtError();
6740 
6741  // Transform the increment
6742  ExprResult Inc = getDerived().TransformExpr(S->getInc());
6743  if (Inc.isInvalid())
6744  return StmtError();
6745 
6746  Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
6747  if (S->getInc() && !FullInc.get())
6748  return StmtError();
6749 
6750  // Transform the body
6751  StmtResult Body = getDerived().TransformStmt(S->getBody());
6752  if (Body.isInvalid())
6753  return StmtError();
6754 
6755  if (!getDerived().AlwaysRebuild() &&
6756  Init.get() == S->getInit() &&
6757  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
6758  Inc.get() == S->getInc() &&
6759  Body.get() == S->getBody())
6760  return S;
6761 
6762  return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
6763  Init.get(), Cond, FullInc,
6764  S->getRParenLoc(), Body.get());
6765 }
6766 
6767 template<typename Derived>
6768 StmtResult
6770  Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
6771  S->getLabel());
6772  if (!LD)
6773  return StmtError();
6774 
6775  // Goto statements must always be rebuilt, to resolve the label.
6776  return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
6777  cast<LabelDecl>(LD));
6778 }
6779 
6780 template<typename Derived>
6781 StmtResult
6783  ExprResult Target = getDerived().TransformExpr(S->getTarget());
6784  if (Target.isInvalid())
6785  return StmtError();
6786  Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
6787 
6788  if (!getDerived().AlwaysRebuild() &&
6789  Target.get() == S->getTarget())
6790  return S;
6791 
6792  return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
6793  Target.get());
6794 }
6795 
6796 template<typename Derived>
6797 StmtResult
6799  return S;
6800 }
6801 
6802 template<typename Derived>
6803 StmtResult
6805  return S;
6806 }
6807 
6808 template<typename Derived>
6809 StmtResult
6811  ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
6812  /*NotCopyInit*/false);
6813  if (Result.isInvalid())
6814  return StmtError();
6815 
6816  // FIXME: We always rebuild the return statement because there is no way
6817  // to tell whether the return type of the function has changed.
6818  return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
6819 }
6820 
6821 template<typename Derived>
6822 StmtResult
6824  bool DeclChanged = false;
6825  SmallVector<Decl *, 4> Decls;
6826  for (auto *D : S->decls()) {
6827  Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
6828  if (!Transformed)
6829  return StmtError();
6830 
6831  if (Transformed != D)
6832  DeclChanged = true;
6833 
6834  Decls.push_back(Transformed);
6835  }
6836 
6837  if (!getDerived().AlwaysRebuild() && !DeclChanged)
6838  return S;
6839 
6840  return getDerived().RebuildDeclStmt(Decls, S->getStartLoc(), S->getEndLoc());
6841 }
6842 
6843 template<typename Derived>
6844 StmtResult
6846 
6847  SmallVector<Expr*, 8> Constraints;
6848  SmallVector<Expr*, 8> Exprs;
6850 
6851  ExprResult AsmString;
6852  SmallVector<Expr*, 8> Clobbers;
6853 
6854  bool ExprsChanged = false;
6855 
6856  // Go through the outputs.
6857  for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
6858  Names.push_back(S->getOutputIdentifier(I));
6859 
6860  // No need to transform the constraint literal.
6861  Constraints.push_back(S->getOutputConstraintLiteral(I));
6862 
6863  // Transform the output expr.
6864  Expr *OutputExpr = S->getOutputExpr(I);
6865  ExprResult Result = getDerived().TransformExpr(OutputExpr);
6866  if (Result.isInvalid())
6867  return StmtError();
6868 
6869  ExprsChanged |= Result.get() != OutputExpr;
6870 
6871  Exprs.push_back(Result.get());
6872  }
6873 
6874  // Go through the inputs.
6875  for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
6876  Names.push_back(S->getInputIdentifier(I));
6877 
6878  // No need to transform the constraint literal.
6879  Constraints.push_back(S->getInputConstraintLiteral(I));
6880 
6881  // Transform the input expr.
6882  Expr *InputExpr = S->getInputExpr(I);
6883  ExprResult Result = getDerived().TransformExpr(InputExpr);
6884  if (Result.isInvalid())
6885  return StmtError();
6886 
6887  ExprsChanged |= Result.get() != InputExpr;
6888 
6889  Exprs.push_back(Result.get());
6890  }
6891 
6892  if (!getDerived().AlwaysRebuild() && !ExprsChanged)
6893  return S;
6894 
6895  // Go through the clobbers.
6896  for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I)
6897  Clobbers.push_back(S->getClobberStringLiteral(I));
6898 
6899  // No need to transform the asm string literal.
6900  AsmString = S->getAsmString();
6901  return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
6902  S->isVolatile(), S->getNumOutputs(),
6903  S->getNumInputs(), Names.data(),
6904  Constraints, Exprs, AsmString.get(),
6905  Clobbers, S->getRParenLoc());
6906 }
6907 
6908 template<typename Derived>
6909 StmtResult
6911  ArrayRef<Token> AsmToks =
6912  llvm::makeArrayRef(S->getAsmToks(), S->getNumAsmToks());
6913 
6914  bool HadError = false, HadChange = false;
6915 
6916  ArrayRef<Expr*> SrcExprs = S->getAllExprs();
6917  SmallVector<Expr*, 8> TransformedExprs;
6918  TransformedExprs.reserve(SrcExprs.size());
6919  for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
6920  ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
6921  if (!Result.isUsable()) {
6922  HadError = true;
6923  } else {
6924  HadChange |= (Result.get() != SrcExprs[i]);
6925  TransformedExprs.push_back(Result.get());
6926  }
6927  }
6928 
6929  if (HadError) return StmtError();
6930  if (!HadChange && !getDerived().AlwaysRebuild())
6931  return Owned(S);
6932 
6933  return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
6934  AsmToks, S->getAsmString(),
6935  S->getNumOutputs(), S->getNumInputs(),
6936  S->getAllConstraints(), S->getClobbers(),
6937  TransformedExprs, S->getEndLoc());
6938 }
6939 
6940 // C++ Coroutines TS
6941 
6942 template<typename Derived>
6943 StmtResult
6945  auto *ScopeInfo = SemaRef.getCurFunction();
6946  auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
6947  assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
6948  ScopeInfo->NeedsCoroutineSuspends &&
6949  ScopeInfo->CoroutineSuspends.first == nullptr &&
6950  ScopeInfo->CoroutineSuspends.second == nullptr &&
6951  "expected clean scope info");
6952 
6953  // Set that we have (possibly-invalid) suspend points before we do anything
6954  // that may fail.
6955  ScopeInfo->setNeedsCoroutineSuspends(false);
6956 
6957  // The new CoroutinePromise object needs to be built and put into the current
6958  // FunctionScopeInfo before any transformations or rebuilding occurs.
6959  auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
6960  if (!Promise)
6961  return StmtError();
6962  getDerived().transformedLocalDecl(S->getPromiseDecl(), Promise);
6963  ScopeInfo->CoroutinePromise = Promise;
6964 
6965  // Transform the implicit coroutine statements we built during the initial
6966  // parse.
6967  StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
6968  if (InitSuspend.isInvalid())
6969  return StmtError();
6970  StmtResult FinalSuspend =
6971  getDerived().TransformStmt(S->getFinalSuspendStmt());
6972  if (FinalSuspend.isInvalid())
6973  return StmtError();
6974  ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
6975  assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
6976 
6977  StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
6978  if (BodyRes.isInvalid())
6979  return StmtError();
6980 
6981  CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
6982  if (Builder.isInvalid())
6983  return StmtError();
6984 
6985  Expr *ReturnObject = S->getReturnValueInit();
6986  assert(ReturnObject && "the return object is expected to be valid");
6987  ExprResult Res = getDerived().TransformInitializer(ReturnObject,
6988  /*NoCopyInit*/ false);
6989  if (Res.isInvalid())
6990  return StmtError();
6991  Builder.ReturnValue = Res.get();
6992 
6993  if (S->hasDependentPromiseType()) {
6994  assert(!Promise->getType()->isDependentType() &&
6995  "the promise type must no longer be dependent");
6996  assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
6997  !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
6998  "these nodes should not have been built yet");
6999  if (!Builder.buildDependentStatements())
7000  return StmtError();
7001  } else {
7002  if (auto *OnFallthrough = S->getFallthroughHandler()) {
7003  StmtResult Res = getDerived().TransformStmt(OnFallthrough);
7004  if (Res.isInvalid())
7005  return StmtError();
7006  Builder.OnFallthrough = Res.get();
7007  }
7008 
7009  if (auto *OnException = S->getExceptionHandler()) {
7010  StmtResult Res = getDerived().TransformStmt(OnException);
7011  if (Res.isInvalid())
7012  return StmtError();
7013  Builder.OnException = Res.get();
7014  }
7015 
7016  if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
7017  StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
7018  if (Res.isInvalid())
7019  return StmtError();
7020  Builder.ReturnStmtOnAllocFailure = Res.get();
7021  }
7022 
7023  // Transform any additional statements we may have already built
7024  assert(S->getAllocate() && S->getDeallocate() &&
7025  "allocation and deallocation calls must already be built");
7026  ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
7027  if (AllocRes.isInvalid())
7028  return StmtError();
7029  Builder.Allocate = AllocRes.get();
7030 
7031  ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
7032  if (DeallocRes.isInvalid())
7033  return StmtError();
7034  Builder.Deallocate = DeallocRes.get();
7035 
7036  assert(S->getResultDecl() && "ResultDecl must already be built");
7037  StmtResult ResultDecl = getDerived().TransformStmt(S->getResultDecl());
7038  if (ResultDecl.isInvalid())
7039  return StmtError();
7040  Builder.ResultDecl = ResultDecl.get();
7041 
7042  if (auto *ReturnStmt = S->getReturnStmt()) {
7043  StmtResult Res = getDerived().TransformStmt(ReturnStmt);
7044  if (Res.isInvalid())
7045  return StmtError();
7046  Builder.ReturnStmt = Res.get();
7047  }
7048  }
7049  if (!Builder.buildParameterMoves())
7050  return StmtError();
7051 
7052  return getDerived().RebuildCoroutineBodyStmt(Builder);
7053 }
7054 
7055 template<typename Derived>
7056 StmtResult
7058  ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
7059  /*NotCopyInit*/false);
7060  if (Result.isInvalid())
7061  return StmtError();
7062 
7063  // Always rebuild; we don't know if this needs to be injected into a new
7064  // context or if the promise type has changed.
7065  return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
7066  S->isImplicit());
7067 }
7068 
7069 template<typename Derived>
7070 ExprResult
7072  ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
7073  /*NotCopyInit*/false);
7074  if (Result.isInvalid())
7075  return ExprError();
7076 
7077  // Always rebuild; we don't know if this needs to be injected into a new
7078  // context or if the promise type has changed.
7079  return getDerived().RebuildCoawaitExpr(E->getKeywordLoc(), Result.get(),
7080  E->isImplicit());
7081 }
7082 
7083 template <typename Derived>
7084 ExprResult
7086  ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
7087  /*NotCopyInit*/ false);
7088  if (OperandResult.isInvalid())
7089  return ExprError();
7090 
7091  ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
7093 
7094  if (LookupResult.isInvalid())
7095  return ExprError();
7096 
7097  // Always rebuild; we don't know if this needs to be injected into a new
7098  // context or if the promise type has changed.
7099  return getDerived().RebuildDependentCoawaitExpr(
7100  E->getKeywordLoc(), OperandResult.get(),
7101  cast<UnresolvedLookupExpr>(LookupResult.get()));
7102 }
7103 
7104 template<typename Derived>
7105 ExprResult
7107  ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
7108  /*NotCopyInit*/false);
7109  if (Result.isInvalid())
7110  return ExprError();
7111 
7112  // Always rebuild; we don't know if this needs to be injected into a new
7113  // context or if the promise type has changed.
7114  return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
7115 }
7116 
7117 // Objective-C Statements.
7118 
7119 template<typename Derived>
7120 StmtResult
7122  // Transform the body of the @try.
7123  StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
7124  if (TryBody.isInvalid())
7125  return StmtError();
7126 
7127  // Transform the @catch statements (if present).
7128  bool AnyCatchChanged = false;
7129  SmallVector<Stmt*, 8> CatchStmts;
7130  for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
7131  StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
7132  if (Catch.isInvalid())
7133  return StmtError();
7134  if (Catch.get() != S->getCatchStmt(I))
7135  AnyCatchChanged = true;
7136  CatchStmts.push_back(Catch.get());
7137  }
7138 
7139  // Transform the @finally statement (if present).
7140  StmtResult Finally;
7141  if (S->getFinallyStmt()) {
7142  Finally = getDerived().TransformStmt(S->getFinallyStmt());
7143  if (Finally.isInvalid())
7144  return StmtError();
7145  }
7146 
7147  // If nothing changed, just retain this statement.
7148  if (!getDerived().AlwaysRebuild() &&
7149  TryBody.get() == S->getTryBody() &&
7150  !AnyCatchChanged &&
7151  Finally.get() == S->getFinallyStmt())
7152  return S;
7153 
7154  // Build a new statement.
7155  return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
7156  CatchStmts, Finally.get());
7157 }
7158 
7159 template<typename Derived>
7160 StmtResult
7162  // Transform the @catch parameter, if there is one.
7163  VarDecl *Var = nullptr;
7164  if (VarDecl *FromVar = S->getCatchParamDecl()) {
7165  TypeSourceInfo *TSInfo = nullptr;
7166  if (FromVar->getTypeSourceInfo()) {
7167  TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
7168  if (!TSInfo)
7169  return StmtError();
7170  }
7171 
7172  QualType T;
7173  if (TSInfo)
7174  T = TSInfo->getType();
7175  else {
7176  T = getDerived().TransformType(FromVar->getType());
7177  if (T.isNull())
7178  return StmtError();
7179  }
7180 
7181  Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
7182  if (!Var)
7183  return StmtError();
7184  }
7185 
7186  StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
7187  if (Body.isInvalid())
7188  return StmtError();
7189 
7190  return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
7191  S->getRParenLoc(),
7192  Var, Body.get());
7193 }
7194 
7195 template<typename Derived>
7196 StmtResult
7198  // Transform the body.
7199  StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
7200  if (Body.isInvalid())
7201  return StmtError();
7202 
7203  // If nothing changed, just retain this statement.
7204  if (!getDerived().AlwaysRebuild() &&
7205  Body.get() == S->getFinallyBody())
7206  return S;
7207 
7208  // Build a new statement.
7209  return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
7210  Body.get());
7211 }
7212 
7213 template<typename Derived>
7214 StmtResult
7216  ExprResult Operand;
7217  if (S->getThrowExpr()) {
7218  Operand = getDerived().TransformExpr(S->getThrowExpr());
7219  if (Operand.isInvalid())
7220  return StmtError();
7221  }
7222 
7223  if (!getDerived().AlwaysRebuild() &&
7224  Operand.get() == S->getThrowExpr())
7225  return S;
7226 
7227  return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
7228 }
7229 
7230 template<typename Derived>
7231 StmtResult
7234  // Transform the object we are locking.
7235  ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
7236  if (Object.isInvalid())
7237  return StmtError();
7238  Object =
7239  getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
7240  Object.get());
7241  if (Object.isInvalid())
7242  return StmtError();
7243 
7244  // Transform the body.
7245  StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
7246  if (Body.isInvalid())
7247  return StmtError();
7248 
7249  // If nothing change, just retain the current statement.
7250  if (!getDerived().AlwaysRebuild() &&
7251  Object.get() == S->getSynchExpr() &&
7252  Body.get() == S->getSynchBody())
7253  return S;
7254 
7255  // Build a new statement.
7256  return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
7257  Object.get(), Body.get());
7258 }
7259 
7260 template<typename Derived>
7261 StmtResult
7264  // Transform the body.
7265  StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
7266  if (Body.isInvalid())
7267  return StmtError();
7268 
7269  // If nothing changed, just retain this statement.
7270  if (!getDerived().AlwaysRebuild() &&
7271  Body.get() == S->getSubStmt())
7272  return S;
7273 
7274  // Build a new statement.
7275  return getDerived().RebuildObjCAutoreleasePoolStmt(
7276  S->getAtLoc(), Body.get());
7277 }
7278 
7279 template<typename Derived>
7280 StmtResult
7282  ObjCForCollectionStmt *S) {
7283  // Transform the element statement.
7284  StmtResult Element = getDerived().TransformStmt(S->getElement());
7285  if (Element.isInvalid())
7286  return StmtError();
7287 
7288  // Transform the collection expression.
7289  ExprResult Collection = getDerived().TransformExpr(S->getCollection());
7290  if (Collection.isInvalid())
7291  return StmtError();
7292 
7293  // Transform the body.
7294  StmtResult Body = getDerived().TransformStmt(S->getBody());
7295  if (Body.isInvalid())
7296  return StmtError();
7297 
7298  // If nothing changed, just retain this statement.
7299  if (!getDerived().AlwaysRebuild() &&
7300  Element.get() == S->getElement() &&
7301  Collection.get() == S->getCollection() &&
7302  Body.get() == S->getBody())
7303  return S;
7304 
7305  // Build a new statement.
7306  return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
7307  Element.get(),
7308  Collection.get(),
7309  S->getRParenLoc(),
7310  Body.get());
7311 }
7312 
7313 template <typename Derived>
7315  // Transform the exception declaration, if any.
7316  VarDecl *Var = nullptr;
7317  if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
7318  TypeSourceInfo *T =
7319  getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
7320  if (!T)
7321  return StmtError();
7322 
7323  Var = getDerived().RebuildExceptionDecl(
7324  ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
7325  ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
7326  if (!Var || Var->isInvalidDecl())
7327  return StmtError();
7328  }
7329 
7330  // Transform the actual exception handler.
7331  StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
7332  if (Handler.isInvalid())
7333  return StmtError();
7334 
7335  if (!getDerived().AlwaysRebuild() && !Var &&
7336  Handler.get() == S->getHandlerBlock())
7337  return S;
7338 
7339  return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
7340 }
7341 
7342 template <typename Derived>
7344  // Transform the try block itself.
7345  StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
7346  if (TryBlock.isInvalid())
7347  return StmtError();
7348 
7349  // Transform the handlers.
7350  bool HandlerChanged = false;
7351  SmallVector<Stmt *, 8> Handlers;
7352  for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
7353  StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
7354  if (Handler.isInvalid())
7355  return StmtError();
7356 
7357  HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
7358  Handlers.push_back(Handler.getAs<Stmt>());
7359  }
7360 
7361  if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
7362  !HandlerChanged)
7363  return S;
7364 
7365  return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
7366  Handlers);
7367 }
7368 
7369 template<typename Derived>
7370 StmtResult
7372  StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
7373  if (Range.isInvalid())
7374  return StmtError();
7375 
7376  StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
7377  if (Begin.isInvalid())
7378  return StmtError();
7379  StmtResult End = getDerived().TransformStmt(S->getEndStmt());
7380  if (End.isInvalid())
7381  return StmtError();
7382 
7383  ExprResult Cond = getDerived().TransformExpr(S->getCond());
7384  if (Cond.isInvalid())
7385  return StmtError();
7386  if (Cond.get())
7387  Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
7388  if (Cond.isInvalid())
7389  return StmtError();
7390  if (Cond.get())
7391  Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
7392 
7393  ExprResult Inc = getDerived().TransformExpr(S->getInc());
7394  if (Inc.isInvalid())
7395  return StmtError();
7396  if (Inc.get())
7397  Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
7398 
7399  StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
7400  if (LoopVar.isInvalid())
7401  return StmtError();
7402 
7403  StmtResult NewStmt = S;
7404  if (getDerived().AlwaysRebuild() ||
7405  Range.get() != S->getRangeStmt() ||
7406  Begin.get() != S->getBeginStmt() ||
7407  End.get() != S->getEndStmt() ||
7408  Cond.get() != S->getCond() ||
7409  Inc.get() != S->getInc() ||
7410  LoopVar.get() != S->getLoopVarStmt()) {
7411  NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(),
7412  S->getCoawaitLoc(),
7413  S->getColonLoc(), Range.get(),
7414  Begin.get(), End.get(),
7415  Cond.get(),
7416  Inc.get(), LoopVar.get(),
7417  S->getRParenLoc());
7418  if (NewStmt.isInvalid())
7419  return StmtError();
7420  }
7421 
7422  StmtResult Body = getDerived().TransformStmt(S->getBody());
7423  if (Body.isInvalid())
7424  return StmtError();
7425 
7426  // Body has changed but we didn't rebuild the for-range statement. Rebuild
7427  // it now so we have a new statement to attach the body to.
7428  if (Body.get() != S->getBody() && NewStmt.get() == S) {
7429  NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(),
7430  S->getCoawaitLoc(),
7431  S->getColonLoc(), Range.get(),
7432  Begin.get(), End.get(),
7433  Cond.get(),
7434  Inc.get(), LoopVar.get(),
7435  S->getRParenLoc());
7436  if (NewStmt.isInvalid())
7437  return StmtError();
7438  }
7439 
7440  if (NewStmt.get() == S)
7441  return S;
7442 
7443  return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
7444 }
7445 
7446 template<typename Derived>
7447 StmtResult
7449  MSDependentExistsStmt *S) {
7450  // Transform the nested-name-specifier, if any.
7451  NestedNameSpecifierLoc QualifierLoc;
7452  if (S->getQualifierLoc()) {
7453  QualifierLoc
7454  = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
7455  if (!QualifierLoc)
7456  return StmtError();
7457  }
7458 
7459  // Transform the declaration name.
7460  DeclarationNameInfo NameInfo = S->getNameInfo();
7461  if (NameInfo.getName()) {
7462  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
7463  if (!NameInfo.getName())
7464  return StmtError();
7465  }
7466 
7467  // Check whether anything changed.
7468  if (!getDerived().AlwaysRebuild() &&
7469  QualifierLoc == S->getQualifierLoc() &&
7470  NameInfo.getName() == S->getNameInfo().getName())
7471  return S;
7472 
7473  // Determine whether this name exists, if we can.
7474  CXXScopeSpec SS;
7475  SS.Adopt(QualifierLoc);
7476  bool Dependent = false;
7477  switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
7478  case Sema::IER_Exists:
7479  if (S->isIfExists())
7480  break;
7481 
7482  return new (getSema().Context) NullStmt(S->getKeywordLoc());
7483 
7485  if (S->isIfNotExists())
7486  break;
7487 
7488  return new (getSema().Context) NullStmt(S->getKeywordLoc());
7489 
7490  case Sema::IER_Dependent:
7491  Dependent = true;
7492  break;
7493 
7494  case Sema::IER_Error:
7495  return StmtError();
7496  }
7497 
7498  // We need to continue with the instantiation, so do so now.
7499  StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
7500  if (SubStmt.isInvalid())
7501  return StmtError();
7502 
7503  // If we have resolved the name, just transform to the substatement.
7504  if (!Dependent)
7505  return SubStmt;
7506 
7507  // The name is still dependent, so build a dependent expression again.
7508  return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
7509  S->isIfExists(),
7510  QualifierLoc,
7511  NameInfo,
7512  SubStmt.get());
7513 }
7514 
7515 template<typename Derived>
7516 ExprResult
7518  NestedNameSpecifierLoc QualifierLoc;
7519  if (E->getQualifierLoc()) {
7520  QualifierLoc
7521  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
7522  if (!QualifierLoc)
7523  return ExprError();
7524  }
7525 
7526  MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
7527  getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
7528  if (!PD)
7529  return ExprError();
7530 
7531  ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
7532  if (Base.isInvalid())
7533  return ExprError();
7534 
7535  return new (SemaRef.getASTContext())
7536  MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
7537  SemaRef.getASTContext().PseudoObjectTy, VK_LValue,
7538  QualifierLoc, E->getMemberLoc());
7539 }
7540 
7541 template <typename Derived>
7544  auto BaseRes = getDerived().TransformExpr(E->getBase());
7545  if (BaseRes.isInvalid())
7546  return ExprError();
7547  auto IdxRes = getDerived().TransformExpr(E->getIdx());
7548  if (IdxRes.isInvalid())
7549  return ExprError();
7550 
7551  if (!getDerived().AlwaysRebuild() &&
7552  BaseRes.get() == E->getBase() &&
7553  IdxRes.get() == E->getIdx())
7554  return E;
7555 
7556  return getDerived().RebuildArraySubscriptExpr(
7557  BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
7558 }
7559 
7560 template <typename Derived>
7562  StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
7563  if (TryBlock.isInvalid())
7564  return StmtError();
7565 
7566  StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
7567  if (Handler.isInvalid())
7568  return StmtError();
7569 
7570  if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
7571  Handler.get() == S->getHandler())
7572  return S;
7573 
7574  return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
7575  TryBlock.get(), Handler.get());
7576 }
7577 
7578 template <typename Derived>
7580  StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
7581  if (Block.isInvalid())
7582  return StmtError();
7583 
7584  return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
7585 }
7586 
7587 template <typename Derived>
7589  ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
7590  if (FilterExpr.isInvalid())
7591  return StmtError();
7592 
7593  StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
7594  if (Block.isInvalid())
7595  return StmtError();
7596 
7597  return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
7598  Block.get());
7599 }
7600 
7601 template <typename Derived>
7603  if (isa<SEHFinallyStmt>(Handler))
7604  return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
7605  else
7606  return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
7607 }
7608 
7609 template<typename Derived>
7610 StmtResult
7612  return S;
7613 }
7614 
7615 //===----------------------------------------------------------------------===//
7616 // OpenMP directive transformation
7617 //===----------------------------------------------------------------------===//
7618 template <typename Derived>
7621 
7622  // Transform the clauses
7624  ArrayRef<OMPClause *> Clauses = D->clauses();
7625  TClauses.reserve(Clauses.size());
7626  for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
7627  I != E; ++I) {
7628  if (*I) {
7629  getDerived().getSema().StartOpenMPClause((*I)->getClauseKind());
7630  OMPClause *Clause = getDerived().TransformOMPClause(*I);
7631  getDerived().getSema().EndOpenMPClause();
7632  if (Clause)
7633  TClauses.push_back(Clause);
7634  } else {
7635  TClauses.push_back(nullptr);
7636  }
7637  }
7638  StmtResult AssociatedStmt;
7639  if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
7640  getDerived().getSema().ActOnOpenMPRegionStart(D->getDirectiveKind(),
7641  /*CurScope=*/nullptr);
7642  StmtResult Body;
7643  {
7644  Sema::CompoundScopeRAII CompoundScope(getSema());
7645  int ThisCaptureLevel =
7647  Stmt *CS = D->getAssociatedStmt();
7648  while (--ThisCaptureLevel >= 0)
7649  CS = cast<CapturedStmt>(CS)->getCapturedStmt();
7650  Body = getDerived().TransformStmt(CS);
7651  }
7652  AssociatedStmt =
7653  getDerived().getSema().ActOnOpenMPRegionEnd(Body, TClauses);
7654  if (AssociatedStmt.isInvalid()) {
7655  return StmtError();
7656  }
7657  }
7658  if (TClauses.size() != Clauses.size()) {
7659  return StmtError();
7660  }
7661 
7662  // Transform directive name for 'omp critical' directive.
7663  DeclarationNameInfo DirName;
7664  if (D->getDirectiveKind() == OMPD_critical) {
7665  DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
7666  DirName = getDerived().TransformDeclarationNameInfo(DirName);
7667  }
7668  OpenMPDirectiveKind CancelRegion = OMPD_unknown;
7669  if (D->getDirectiveKind() == OMPD_cancellation_point) {
7670  CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
7671  } else if (D->getDirectiveKind() == OMPD_cancel) {
7672  CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
7673  }
7674 
7675  return getDerived().RebuildOMPExecutableDirective(
7676  D->getDirectiveKind(), DirName, CancelRegion, TClauses,
7677  AssociatedStmt.get(), D->getLocStart(), D->getLocEnd());
7678 }
7679 
7680 template <typename Derived>
7681 StmtResult
7683  DeclarationNameInfo DirName;
7684  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel, DirName, nullptr,
7685  D->getLocStart());
7686  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7687  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7688  return Res;
7689 }
7690 
7691 template <typename Derived>
7692 StmtResult
7694  DeclarationNameInfo DirName;
7695  getDerived().getSema().StartOpenMPDSABlock(OMPD_simd, DirName, nullptr,
7696  D->getLocStart());
7697  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7698  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7699  return Res;
7700 }
7701 
7702 template <typename Derived>
7703 StmtResult
7705  DeclarationNameInfo DirName;
7706  getDerived().getSema().StartOpenMPDSABlock(OMPD_for, DirName, nullptr,
7707  D->getLocStart());
7708  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7709  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7710  return Res;
7711 }
7712 
7713 template <typename Derived>
7714 StmtResult
7716  DeclarationNameInfo DirName;
7717  getDerived().getSema().StartOpenMPDSABlock(OMPD_for_simd, DirName, nullptr,
7718  D->getLocStart());
7719  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7720  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7721  return Res;
7722 }
7723 
7724 template <typename Derived>
7725 StmtResult
7727  DeclarationNameInfo DirName;
7728  getDerived().getSema().StartOpenMPDSABlock(OMPD_sections, DirName, nullptr,
7729  D->getLocStart());
7730  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7731  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7732  return Res;
7733 }
7734 
7735 template <typename Derived>
7736 StmtResult
7738  DeclarationNameInfo DirName;
7739  getDerived().getSema().StartOpenMPDSABlock(OMPD_section, DirName, nullptr,
7740  D->getLocStart());
7741  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7742  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7743  return Res;
7744 }
7745 
7746 template <typename Derived>
7747 StmtResult
7749  DeclarationNameInfo DirName;
7750  getDerived().getSema().StartOpenMPDSABlock(OMPD_single, DirName, nullptr,
7751  D->getLocStart());
7752  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7753  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7754  return Res;
7755 }
7756 
7757 template <typename Derived>
7758 StmtResult
7760  DeclarationNameInfo DirName;
7761  getDerived().getSema().StartOpenMPDSABlock(OMPD_master, DirName, nullptr,
7762  D->getLocStart());
7763  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7764  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7765  return Res;
7766 }
7767 
7768 template <typename Derived>
7769 StmtResult
7771  getDerived().getSema().StartOpenMPDSABlock(
7772  OMPD_critical, D->getDirectiveName(), nullptr, D->getLocStart());
7773  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7774  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7775  return Res;
7776 }
7777 
7778 template <typename Derived>
7781  DeclarationNameInfo DirName;
7782  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_for, DirName,
7783  nullptr, D->getLocStart());
7784  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7785  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7786  return Res;
7787 }
7788 
7789 template <typename Derived>
7792  DeclarationNameInfo DirName;
7793  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_for_simd, DirName,
7794  nullptr, D->getLocStart());
7795  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7796  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7797  return Res;
7798 }
7799 
7800 template <typename Derived>
7803  DeclarationNameInfo DirName;
7804  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_sections, DirName,
7805  nullptr, D->getLocStart());
7806  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7807  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7808  return Res;
7809 }
7810 
7811 template <typename Derived>
7812 StmtResult
7814  DeclarationNameInfo DirName;
7815  getDerived().getSema().StartOpenMPDSABlock(OMPD_task, DirName, nullptr,
7816  D->getLocStart());
7817  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7818  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7819  return Res;
7820 }
7821 
7822 template <typename Derived>
7824  OMPTaskyieldDirective *D) {
7825  DeclarationNameInfo DirName;
7826  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskyield, DirName, nullptr,
7827  D->getLocStart());
7828  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7829  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7830  return Res;
7831 }
7832 
7833 template <typename Derived>
7834 StmtResult
7836  DeclarationNameInfo DirName;
7837  getDerived().getSema().StartOpenMPDSABlock(OMPD_barrier, DirName, nullptr,
7838  D->getLocStart());
7839  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7840  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7841  return Res;
7842 }
7843 
7844 template <typename Derived>
7845 StmtResult
7847  DeclarationNameInfo DirName;
7848  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskwait, DirName, nullptr,
7849  D->getLocStart());
7850  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7851  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7852  return Res;
7853 }
7854 
7855 template <typename Derived>
7857  OMPTaskgroupDirective *D) {
7858  DeclarationNameInfo DirName;
7859  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskgroup, DirName, nullptr,
7860  D->getLocStart());
7861  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7862  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7863  return Res;
7864 }
7865 
7866 template <typename Derived>
7867 StmtResult
7869  DeclarationNameInfo DirName;
7870  getDerived().getSema().StartOpenMPDSABlock(OMPD_flush, DirName, nullptr,
7871  D->getLocStart());
7872  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7873  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7874  return Res;
7875 }
7876 
7877 template <typename Derived>
7878 StmtResult
7880  DeclarationNameInfo DirName;
7881  getDerived().getSema().StartOpenMPDSABlock(OMPD_ordered, DirName, nullptr,
7882  D->getLocStart());
7883  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7884  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7885  return Res;
7886 }
7887 
7888 template <typename Derived>
7889 StmtResult
7891  DeclarationNameInfo DirName;
7892  getDerived().getSema().StartOpenMPDSABlock(OMPD_atomic, DirName, nullptr,
7893  D->getLocStart());
7894  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7895  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7896  return Res;
7897 }
7898 
7899 template <typename Derived>
7900 StmtResult
7902  DeclarationNameInfo DirName;
7903  getDerived().getSema().StartOpenMPDSABlock(OMPD_target, DirName, nullptr,
7904  D->getLocStart());
7905  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7906  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7907  return Res;
7908 }
7909 
7910 template <typename Derived>
7913  DeclarationNameInfo DirName;
7914  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_data, DirName, nullptr,
7915  D->getLocStart());
7916  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7917  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7918  return Res;
7919 }
7920 
7921 template <typename Derived>
7924  DeclarationNameInfo DirName;
7925  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_enter_data, DirName,
7926  nullptr, D->getLocStart());
7927  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7928  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7929  return Res;
7930 }
7931 
7932 template <typename Derived>
7935  DeclarationNameInfo DirName;
7936  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_exit_data, DirName,
7937  nullptr, D->getLocStart());
7938  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7939  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7940  return Res;
7941 }
7942 
7943 template <typename Derived>
7946  DeclarationNameInfo DirName;
7947  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel, DirName,
7948  nullptr, D->getLocStart());
7949  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7950  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7951  return Res;
7952 }
7953 
7954 template <typename Derived>
7957  DeclarationNameInfo DirName;
7958  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel_for, DirName,
7959  nullptr, D->getLocStart());
7960  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7961  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7962  return Res;
7963 }
7964 
7965 template <typename Derived>
7968  DeclarationNameInfo DirName;
7969  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_update, DirName,
7970  nullptr, D->getLocStart());
7971  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7972  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7973  return Res;
7974 }
7975 
7976 template <typename Derived>
7977 StmtResult
7979  DeclarationNameInfo DirName;
7980  getDerived().getSema().StartOpenMPDSABlock(OMPD_teams, DirName, nullptr,
7981  D->getLocStart());
7982  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7983  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7984  return Res;
7985 }
7986 
7987 template <typename Derived>
7990  DeclarationNameInfo DirName;
7991  getDerived().getSema().StartOpenMPDSABlock(OMPD_cancellation_point, DirName,
7992  nullptr, D->getLocStart());
7993  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7994  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7995  return Res;
7996 }
7997 
7998 template <typename Derived>
7999 StmtResult
8001  DeclarationNameInfo DirName;
8002  getDerived().getSema().StartOpenMPDSABlock(OMPD_cancel, DirName, nullptr,
8003  D->getLocStart());
8004  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8005  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8006  return Res;
8007 }
8008 
8009 template <typename Derived>
8010 StmtResult
8012  DeclarationNameInfo DirName;
8013  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop, DirName, nullptr,
8014  D->getLocStart());
8015  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8016  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8017  return Res;
8018 }
8019 
8020 template <typename Derived>
8023  DeclarationNameInfo DirName;
8024  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop_simd, DirName,
8025  nullptr, D->getLocStart());
8026  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8027  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8028  return Res;
8029 }
8030 
8031 template <typename Derived>
8034  DeclarationNameInfo DirName;
8035  getDerived().getSema().StartOpenMPDSABlock(OMPD_distribute, DirName, nullptr,
8036  D->getLocStart());
8037  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8038  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8039  return Res;
8040 }
8041 
8042 template <typename Derived>
8045  DeclarationNameInfo DirName;
8046  getDerived().getSema().StartOpenMPDSABlock(
8047  OMPD_distribute_parallel_for, DirName, nullptr, D->getLocStart());
8048  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8049  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8050  return Res;
8051 }
8052 
8053 template <typename Derived>
8054 StmtResult
8057  DeclarationNameInfo DirName;
8058  getDerived().getSema().StartOpenMPDSABlock(
8059  OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getLocStart());
8060  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8061  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8062  return Res;
8063 }
8064 
8065 template <typename Derived>
8068  DeclarationNameInfo DirName;
8069  getDerived().getSema().StartOpenMPDSABlock(OMPD_distribute_simd, DirName,
8070  nullptr, D->getLocStart());
8071  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8072  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8073  return Res;
8074 }
8075 
8076 template <typename Derived>
8079  DeclarationNameInfo DirName;
8080  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel_for_simd,
8081  DirName, nullptr,
8082  D->getLocStart());
8083  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8084  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8085  return Res;
8086 }
8087 
8088 template <typename Derived>
8091  DeclarationNameInfo DirName;
8092  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_simd, DirName, nullptr,
8093  D->getLocStart());
8094  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8095  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8096  return Res;
8097 }
8098 
8099 template <typename Derived>
8102  DeclarationNameInfo DirName;
8103  getDerived().getSema().StartOpenMPDSABlock(OMPD_teams_distribute, DirName,
8104  nullptr, D->getLocStart());
8105  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8106  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8107  return Res;
8108 }
8109 
8110 template <typename Derived>
8113  DeclarationNameInfo DirName;
8114  getDerived().getSema().StartOpenMPDSABlock(
8115  OMPD_teams_distribute_simd, DirName, nullptr, D->getLocStart());
8116  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8117  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8118  return Res;
8119 }
8120 
8121 template <typename Derived>
8124  DeclarationNameInfo DirName;
8125  getDerived().getSema().StartOpenMPDSABlock(
8126  OMPD_teams_distribute_parallel_for_simd, DirName, nullptr, D->getLocStart());
8127  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8128  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8129  return Res;
8130 }
8131 
8132 template <typename Derived>
8135  DeclarationNameInfo DirName;
8136  getDerived().getSema().StartOpenMPDSABlock(OMPD_teams_distribute_parallel_for,
8137  DirName, nullptr, D->getLocStart());
8138  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8139  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8140  return Res;
8141 }
8142 
8143 template <typename Derived>
8146  DeclarationNameInfo DirName;
8147  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_teams, DirName,
8148  nullptr, D->getLocStart());
8149  auto Res = getDerived().TransformOMPExecutableDirective(D);
8150  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8151  return Res;
8152 }
8153 
8154 template <typename Derived>
8157  DeclarationNameInfo DirName;
8158  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_teams_distribute,
8159  DirName, nullptr, D->getLocStart());
8160  auto Res = getDerived().TransformOMPExecutableDirective(D);
8161  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8162  return Res;
8163 }
8164 
8165 template <typename Derived>
8166 StmtResult
8169  DeclarationNameInfo DirName;
8170  getDerived().getSema().StartOpenMPDSABlock(
8171  OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
8172  D->getLocStart());
8173  auto Res = getDerived().TransformOMPExecutableDirective(D);
8174  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8175  return Res;
8176 }
8177 
8178 template <typename Derived>
8182  DeclarationNameInfo DirName;
8183  getDerived().getSema().StartOpenMPDSABlock(
8184  OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
8185  D->getLocStart());
8186  auto Res = getDerived().TransformOMPExecutableDirective(D);
8187  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8188  return Res;
8189 }
8190 
8191 template <typename Derived>
8192 StmtResult
8195  DeclarationNameInfo DirName;
8196  getDerived().getSema().StartOpenMPDSABlock(
8197  OMPD_target_teams_distribute_simd, DirName, nullptr, D->getLocStart());
8198  auto Res = getDerived().TransformOMPExecutableDirective(D);
8199  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8200  return Res;
8201 }
8202 
8203 
8204 //===----------------------------------------------------------------------===//
8205 // OpenMP clause transformation
8206 //===----------------------------------------------------------------------===//
8207 template <typename Derived>
8209  ExprResult Cond = getDerived().TransformExpr(C->getCondition());
8210  if (Cond.isInvalid())
8211  return nullptr;
8212  return getDerived().RebuildOMPIfClause(
8213  C->getNameModifier(), Cond.get(), C->getLocStart(), C->getLParenLoc(),
8214  C->getNameModifierLoc(), C->getColonLoc(), C->getLocEnd());
8215 }
8216 
8217 template <typename Derived>
8219  ExprResult Cond = getDerived().TransformExpr(C->getCondition());
8220  if (Cond.isInvalid())
8221  return nullptr;
8222  return getDerived().RebuildOMPFinalClause(Cond.get(), C->getLocStart(),
8223  C->getLParenLoc(), C->getLocEnd());
8224 }
8225 
8226 template <typename Derived>
8227 OMPClause *
8229  ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
8230  if (NumThreads.isInvalid())
8231  return nullptr;
8232  return getDerived().RebuildOMPNumThreadsClause(
8233  NumThreads.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8234 }
8235 
8236 template <typename Derived>
8237 OMPClause *
8239  ExprResult E = getDerived().TransformExpr(C->getSafelen());
8240  if (E.isInvalid())
8241  return nullptr;
8242  return getDerived().RebuildOMPSafelenClause(
8243  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8244 }
8245 
8246 template <typename Derived>
8247 OMPClause *
8249  ExprResult E = getDerived().TransformExpr(C->getSimdlen());
8250  if (E.isInvalid())
8251  return nullptr;
8252  return getDerived().RebuildOMPSimdlenClause(
8253  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8254 }
8255 
8256 template <typename Derived>
8257 OMPClause *
8259  ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
8260  if (E.isInvalid())
8261  return nullptr;
8262  return getDerived().RebuildOMPCollapseClause(
8263  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8264 }
8265 
8266 template <typename Derived>
8267 OMPClause *
8269  return getDerived().RebuildOMPDefaultClause(
8271  C->getLParenLoc(), C->getLocEnd());
8272 }
8273 
8274 template <typename Derived>
8275 OMPClause *
8277  return getDerived().RebuildOMPProcBindClause(
8279  C->getLParenLoc(), C->getLocEnd());
8280 }
8281 
8282 template <typename Derived>
8283 OMPClause *
8285  ExprResult E = getDerived().TransformExpr(C->getChunkSize());
8286  if (E.isInvalid())
8287  return nullptr;
8288  return getDerived().RebuildOMPScheduleClause(
8290  C->getScheduleKind(), E.get(), C->getLocStart(), C->getLParenLoc(),
8292  C->getScheduleKindLoc(), C->getCommaLoc(), C->getLocEnd());
8293 }
8294 
8295 template <typename Derived>
8296 OMPClause *
8298  ExprResult E;
8299  if (auto *Num = C->getNumForLoops()) {
8300  E = getDerived().TransformExpr(Num);
8301  if (E.isInvalid())
8302  return nullptr;
8303  }
8304  return getDerived().RebuildOMPOrderedClause(C->getLocStart(), C->getLocEnd(),
8305  C->getLParenLoc(), E.get());
8306 }
8307 
8308 template <typename Derived>
8309 OMPClause *
8311  // No need to rebuild this clause, no template-dependent parameters.
8312  return C;
8313 }
8314 
8315 template <typename Derived>
8316 OMPClause *
8318  // No need to rebuild this clause, no template-dependent parameters.
8319  return C;
8320 }
8321 
8322 template <typename Derived>
8323 OMPClause *
8325  // No need to rebuild this clause, no template-dependent parameters.
8326  return C;
8327 }
8328 
8329 template <typename Derived>
8331  // No need to rebuild this clause, no template-dependent parameters.
8332  return C;
8333 }
8334 
8335 template <typename Derived>
8337  // No need to rebuild this clause, no template-dependent parameters.
8338  return C;
8339 }
8340 
8341 template <typename Derived>
8342 OMPClause *
8344  // No need to rebuild this clause, no template-dependent parameters.
8345  return C;
8346 }
8347 
8348 template <typename Derived>
8349 OMPClause *
8351  // No need to rebuild this clause, no template-dependent parameters.
8352  return C;
8353 }
8354 
8355 template <typename Derived>
8356 OMPClause *
8358  // No need to rebuild this clause, no template-dependent parameters.
8359  return C;
8360 }
8361 
8362 template <typename Derived>
8363 OMPClause *
8365  // No need to rebuild this clause, no template-dependent parameters.
8366  return C;
8367 }
8368 
8369 template <typename Derived>
8371  // No need to rebuild this clause, no template-dependent parameters.
8372  return C;
8373 }
8374 
8375 template <typename Derived>
8376 OMPClause *
8378  // No need to rebuild this clause, no template-dependent parameters.
8379  return C;
8380 }
8381 
8382 template <typename Derived>
8383 OMPClause *
8386  Vars.reserve(C->varlist_size());
8387  for (auto *VE : C->varlists()) {
8388  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8389  if (EVar.isInvalid())
8390  return nullptr;
8391  Vars.push_back(EVar.get());
8392  }
8393  return getDerived().RebuildOMPPrivateClause(
8394  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8395 }
8396 
8397 template <typename Derived>
8399  OMPFirstprivateClause *C) {
8401  Vars.reserve(C->varlist_size());
8402  for (auto *VE : C->varlists()) {
8403  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8404  if (EVar.isInvalid())
8405  return nullptr;
8406  Vars.push_back(EVar.get());
8407  }
8408  return getDerived().RebuildOMPFirstprivateClause(
8409  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8410 }
8411 
8412 template <typename Derived>
8413 OMPClause *
8416  Vars.reserve(C->varlist_size());
8417  for (auto *VE : C->varlists()) {
8418  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8419  if (EVar.isInvalid())
8420  return nullptr;
8421  Vars.push_back(EVar.get());
8422  }
8423  return getDerived().RebuildOMPLastprivateClause(
8424  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8425 }
8426 
8427 template <typename Derived>
8428 OMPClause *
8431  Vars.reserve(C->varlist_size());
8432  for (auto *VE : C->varlists()) {
8433  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8434  if (EVar.isInvalid())
8435  return nullptr;
8436  Vars.push_back(EVar.get());
8437  }
8438  return getDerived().RebuildOMPSharedClause(Vars, C->getLocStart(),
8439  C->getLParenLoc(), C->getLocEnd());
8440 }
8441 
8442 template <typename Derived>
8443 OMPClause *
8446  Vars.reserve(C->varlist_size());
8447  for (auto *VE : C->varlists()) {
8448  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8449  if (EVar.isInvalid())
8450  return nullptr;
8451  Vars.push_back(EVar.get());
8452  }
8453  CXXScopeSpec ReductionIdScopeSpec;
8454  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8455 
8456  DeclarationNameInfo NameInfo = C->getNameInfo();
8457  if (NameInfo.getName()) {
8458  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8459  if (!NameInfo.getName())
8460  return nullptr;
8461  }
8462  // Build a list of all UDR decls with the same names ranged by the Scopes.
8463  // The Scope boundary is a duplication of the previous decl.
8464  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8465  for (auto *E : C->reduction_ops()) {
8466  // Transform all the decls.
8467  if (E) {
8468  auto *ULE = cast<UnresolvedLookupExpr>(E);
8469  UnresolvedSet<8> Decls;
8470  for (auto *D : ULE->decls()) {
8471  NamedDecl *InstD =
8472  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8473  Decls.addDecl(InstD, InstD->getAccess());
8474  }
8475  UnresolvedReductions.push_back(
8477  SemaRef.Context, /*NamingClass=*/nullptr,
8478  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context),
8479  NameInfo, /*ADL=*/true, ULE->isOverloaded(),
8480  Decls.begin(), Decls.end()));
8481  } else
8482  UnresolvedReductions.push_back(nullptr);
8483  }
8484  return getDerived().RebuildOMPReductionClause(
8485  Vars, C->getLocStart(), C->getLParenLoc(), C->getColonLoc(),
8486  C->getLocEnd(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8487 }
8488 
8489 template <typename Derived>
8493  Vars.reserve(C->varlist_size());
8494  for (auto *VE : C->varlists()) {
8495  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8496  if (EVar.isInvalid())
8497  return nullptr;
8498  Vars.push_back(EVar.get());
8499  }
8500  CXXScopeSpec ReductionIdScopeSpec;
8501  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8502 
8503  DeclarationNameInfo NameInfo = C->getNameInfo();
8504  if (NameInfo.getName()) {
8505  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8506  if (!NameInfo.getName())
8507  return nullptr;
8508  }
8509  // Build a list of all UDR decls with the same names ranged by the Scopes.
8510  // The Scope boundary is a duplication of the previous decl.
8511  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8512  for (auto *E : C->reduction_ops()) {
8513  // Transform all the decls.
8514  if (E) {
8515  auto *ULE = cast<UnresolvedLookupExpr>(E);
8516  UnresolvedSet<8> Decls;
8517  for (auto *D : ULE->decls()) {
8518  NamedDecl *InstD =
8519  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8520  Decls.addDecl(InstD, InstD->getAccess());
8521  }
8522  UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
8523  SemaRef.Context, /*NamingClass=*/nullptr,
8524  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
8525  /*ADL=*/true, ULE->isOverloaded(), Decls.begin(), Decls.end()));
8526  } else
8527  UnresolvedReductions.push_back(nullptr);
8528  }
8529  return getDerived().RebuildOMPTaskReductionClause(
8530  Vars, C->getLocStart(), C->getLParenLoc(), C->getColonLoc(),
8531  C->getLocEnd(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8532 }
8533 
8534 template <typename Derived>
8535 OMPClause *
8538  Vars.reserve(C->varlist_size());
8539  for (auto *VE : C->varlists()) {
8540  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8541  if (EVar.isInvalid())
8542  return nullptr;
8543  Vars.push_back(EVar.get());
8544  }
8545  CXXScopeSpec ReductionIdScopeSpec;
8546  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8547 
8548  DeclarationNameInfo NameInfo = C->getNameInfo();
8549  if (NameInfo.getName()) {
8550  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8551  if (!NameInfo.getName())
8552  return nullptr;
8553  }
8554  // Build a list of all UDR decls with the same names ranged by the Scopes.
8555  // The Scope boundary is a duplication of the previous decl.
8556  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8557  for (auto *E : C->reduction_ops()) {
8558  // Transform all the decls.
8559  if (E) {
8560  auto *ULE = cast<UnresolvedLookupExpr>(E);
8561  UnresolvedSet<8> Decls;
8562  for (auto *D : ULE->decls()) {
8563  NamedDecl *InstD =
8564  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8565  Decls.addDecl(InstD, InstD->getAccess());
8566  }
8567  UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
8568  SemaRef.Context, /*NamingClass=*/nullptr,
8569  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
8570  /*ADL=*/true, ULE->isOverloaded(), Decls.begin(), Decls.end()));
8571  } else
8572  UnresolvedReductions.push_back(nullptr);
8573  }
8574  return getDerived().RebuildOMPInReductionClause(
8575  Vars, C->getLocStart(), C->getLParenLoc(), C->getColonLoc(),
8576  C->getLocEnd(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8577 }
8578 
8579 template <typename Derived>
8580 OMPClause *
8583  Vars.reserve(C->varlist_size());
8584  for (auto *VE : C->varlists()) {
8585  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8586  if (EVar.isInvalid())
8587  return nullptr;
8588  Vars.push_back(EVar.get());
8589  }
8590  ExprResult Step = getDerived().TransformExpr(C->getStep());
8591  if (Step.isInvalid())
8592  return nullptr;
8593  return getDerived().RebuildOMPLinearClause(
8594  Vars, Step.get(), C->getLocStart(), C->getLParenLoc(), C->getModifier(),
8595  C->getModifierLoc(), C->getColonLoc(), C->getLocEnd());
8596 }
8597 
8598 template <typename Derived>
8599 OMPClause *
8602  Vars.reserve(C->varlist_size());
8603  for (auto *VE : C->varlists()) {
8604  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8605  if (EVar.isInvalid())
8606  return nullptr;
8607  Vars.push_back(EVar.get());
8608  }
8609  ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
8610  if (Alignment.isInvalid())
8611  return nullptr;
8612  return getDerived().RebuildOMPAlignedClause(
8613  Vars, Alignment.get(), C->getLocStart(), C->getLParenLoc(),
8614  C->getColonLoc(), C->getLocEnd());
8615 }
8616 
8617 template <typename Derived>
8618 OMPClause *
8621  Vars.reserve(C->varlist_size());
8622  for (auto *VE : C->varlists()) {
8623  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8624  if (EVar.isInvalid())
8625  return nullptr;
8626  Vars.push_back(EVar.get());
8627  }
8628  return getDerived().RebuildOMPCopyinClause(Vars, C->getLocStart(),
8629  C->getLParenLoc(), C->getLocEnd());
8630 }
8631 
8632 template <typename Derived>
8633 OMPClause *
8636  Vars.reserve(C->varlist_size());
8637  for (auto *VE : C->varlists()) {
8638  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8639  if (EVar.isInvalid())
8640  return nullptr;
8641  Vars.push_back(EVar.get());
8642  }
8643  return getDerived().RebuildOMPCopyprivateClause(
8644  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8645 }
8646 
8647 template <typename Derived>
8650  Vars.reserve(C->varlist_size());
8651  for (auto *VE : C->varlists()) {
8652  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8653  if (EVar.isInvalid())
8654  return nullptr;
8655  Vars.push_back(EVar.get());
8656  }
8657  return getDerived().RebuildOMPFlushClause(Vars, C->getLocStart(),
8658  C->getLParenLoc(), C->getLocEnd());
8659 }
8660 
8661 template <typename Derived>
8662 OMPClause *
8665  Vars.reserve(C->varlist_size());
8666  for (auto *VE : C->varlists()) {
8667  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8668  if (EVar.isInvalid())
8669  return nullptr;
8670  Vars.push_back(EVar.get());
8671  }
8672  return getDerived().RebuildOMPDependClause(
8673  C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(), Vars,
8674  C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8675 }
8676 
8677 template <typename Derived>
8678 OMPClause *
8680  ExprResult E = getDerived().TransformExpr(C->getDevice());
8681  if (E.isInvalid())
8682  return nullptr;
8683  return getDerived().RebuildOMPDeviceClause(
8684  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8685 }
8686 
8687 template <typename Derived>
8690  Vars.reserve(C->varlist_size());
8691  for (auto *VE : C->varlists()) {
8692  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8693  if (EVar.isInvalid())
8694  return nullptr;
8695  Vars.push_back(EVar.get());
8696  }
8697  return getDerived().RebuildOMPMapClause(
8699  C->getMapLoc(), C->getColonLoc(), Vars, C->getLocStart(),
8700  C->getLParenLoc(), C->getLocEnd());
8701 }
8702 
8703 template <typename Derived>
8704 OMPClause *
8706  ExprResult E = getDerived().TransformExpr(C->getNumTeams());
8707  if (E.isInvalid())
8708  return nullptr;
8709  return getDerived().RebuildOMPNumTeamsClause(
8710  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8711 }
8712 
8713 template <typename Derived>
8714 OMPClause *
8716  ExprResult E = getDerived().TransformExpr(C->getThreadLimit());
8717  if (E.isInvalid())
8718  return nullptr;
8719  return getDerived().RebuildOMPThreadLimitClause(
8720  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8721 }
8722 
8723 template <typename Derived>
8724 OMPClause *
8726  ExprResult E = getDerived().TransformExpr(C->getPriority());
8727  if (E.isInvalid())
8728  return nullptr;
8729  return getDerived().RebuildOMPPriorityClause(
8730  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8731 }
8732 
8733 template <typename Derived>
8734 OMPClause *
8736  ExprResult E = getDerived().TransformExpr(C->getGrainsize());
8737  if (E.isInvalid())
8738  return nullptr;
8739  return getDerived().RebuildOMPGrainsizeClause(
8740  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8741 }
8742 
8743 template <typename Derived>
8744 OMPClause *
8746  ExprResult E = getDerived().TransformExpr(C->getNumTasks());
8747  if (E.isInvalid())
8748  return nullptr;
8749  return getDerived().RebuildOMPNumTasksClause(
8750  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8751 }
8752 
8753 template <typename Derived>
8755  ExprResult E = getDerived().TransformExpr(C->getHint());
8756  if (E.isInvalid())
8757  return nullptr;
8758  return getDerived().RebuildOMPHintClause(E.get(), C->getLocStart(),
8759  C->getLParenLoc(), C->getLocEnd());
8760 }
8761 
8762 template <typename Derived>
8764  OMPDistScheduleClause *C) {
8765  ExprResult E = getDerived().TransformExpr(C->getChunkSize());
8766  if (E.isInvalid())
8767  return nullptr;
8768  return getDerived().RebuildOMPDistScheduleClause(
8769  C->getDistScheduleKind(), E.get(), C->getLocStart(), C->getLParenLoc(),
8770  C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getLocEnd());
8771 }
8772 
8773 template <typename Derived>
8774 OMPClause *
8776  return C;
8777 }
8778 
8779 template <typename Derived>
8782  Vars.reserve(C->varlist_size());
8783  for (auto *VE : C->varlists()) {
8784  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8785  if (EVar.isInvalid())
8786  return 0;
8787  Vars.push_back(EVar.get());
8788  }
8789  return getDerived().RebuildOMPToClause(Vars, C->getLocStart(),
8790  C->getLParenLoc(), C->getLocEnd());
8791 }
8792 
8793 template <typename Derived>
8796  Vars.reserve(C->varlist_size());
8797  for (auto *VE : C->varlists()) {
8798  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8799  if (EVar.isInvalid())
8800  return 0;
8801  Vars.push_back(EVar.get());
8802  }
8803  return getDerived().RebuildOMPFromClause(Vars, C->getLocStart(),
8804  C->getLParenLoc(), C->getLocEnd());
8805 }
8806 
8807 template <typename Derived>
8809  OMPUseDevicePtrClause *C) {
8811  Vars.reserve(C->varlist_size());
8812  for (auto *VE : C->varlists()) {
8813  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8814  if (EVar.isInvalid())
8815  return nullptr;
8816  Vars.push_back(EVar.get());
8817  }
8818  return getDerived().RebuildOMPUseDevicePtrClause(
8819  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8820 }
8821 
8822 template <typename Derived>
8823 OMPClause *
8826  Vars.reserve(C->varlist_size());
8827  for (auto *VE : C->varlists()) {
8828  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8829  if (EVar.isInvalid())
8830  return nullptr;
8831  Vars.push_back(EVar.get());
8832  }
8833  return getDerived().RebuildOMPIsDevicePtrClause(
8834  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8835 }
8836 
8837 //===----------------------------------------------------------------------===//
8838 // Expression transformation
8839 //===----------------------------------------------------------------------===//
8840 template<typename Derived>
8841 ExprResult
8843  if (!E->isTypeDependent())
8844  return E;
8845 
8846  return getDerived().RebuildPredefinedExpr(E->getLocation(),
8847  E->getIdentType());
8848 }
8849 
8850 template<typename Derived>
8851 ExprResult
8853  NestedNameSpecifierLoc QualifierLoc;
8854  if (E->getQualifierLoc()) {
8855  QualifierLoc
8856  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
8857  if (!QualifierLoc)
8858  return ExprError();
8859  }
8860 
8861  ValueDecl *ND
8862  = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
8863  E->getDecl()));
8864  if (!ND)
8865  return ExprError();
8866 
8867  DeclarationNameInfo NameInfo = E->getNameInfo();
8868  if (NameInfo.getName()) {
8869  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8870  if (!NameInfo.getName())
8871  return ExprError();
8872  }
8873 
8874  if (!getDerived().AlwaysRebuild() &&
8875  QualifierLoc == E->getQualifierLoc() &&
8876  ND == E->getDecl() &&
8877  NameInfo.getName() == E->getDecl()->getDeclName() &&
8878  !E->hasExplicitTemplateArgs()) {
8879 
8880  // Mark it referenced in the new context regardless.
8881  // FIXME: this is a bit instantiation-specific.
8882  SemaRef.MarkDeclRefReferenced(E);
8883 
8884  return E;
8885  }
8886 
8887  TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
8888  if (E->hasExplicitTemplateArgs()) {
8889  TemplateArgs = &TransArgs;
8890  TransArgs.setLAngleLoc(E->getLAngleLoc());
8891  TransArgs.setRAngleLoc(E->getRAngleLoc());
8892  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
8893  E->getNumTemplateArgs(),
8894  TransArgs))
8895  return ExprError();
8896  }
8897 
8898  return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
8899  TemplateArgs);
8900 }
8901 
8902 template<typename Derived>
8903 ExprResult
8905  return E;
8906 }
8907 
8908 template<typename Derived>
8909 ExprResult
8911  return E;
8912 }
8913 
8914 template<typename Derived>
8915 ExprResult
8917  return E;
8918 }
8919 
8920 template<typename Derived>
8921 ExprResult
8923  return E;
8924 }
8925 
8926 template<typename Derived>
8927 ExprResult
8929  return E;
8930 }
8931 
8932 template<typename Derived>
8933 ExprResult
8935  if (FunctionDecl *FD = E->getDirectCallee())
8936  SemaRef.MarkFunctionReferenced(E->getLocStart(), FD);
8937  return SemaRef.MaybeBindToTemporary(E);
8938 }
8939 
8940 template<typename Derived>
8941 ExprResult
8943  ExprResult ControllingExpr =
8944  getDerived().TransformExpr(E->getControllingExpr());
8945  if (ControllingExpr.isInvalid())
8946  return ExprError();
8947 
8948  SmallVector<Expr *, 4> AssocExprs;
8950  for (unsigned i = 0; i != E->getNumAssocs(); ++i) {
8952  if (TS) {
8953  TypeSourceInfo *AssocType = getDerived().TransformType(TS);
8954  if (!AssocType)
8955  return ExprError();
8956  AssocTypes.push_back(AssocType);
8957  } else {
8958  AssocTypes.push_back(nullptr);
8959  }
8960 
8961  ExprResult AssocExpr = getDerived().TransformExpr(E->getAssocExpr(i));
8962  if (AssocExpr.isInvalid())
8963  return ExprError();
8964  AssocExprs.push_back(AssocExpr.get());
8965  }
8966 
8967  return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
8968  E->getDefaultLoc(),
8969  E->getRParenLoc(),
8970  ControllingExpr.get(),
8971  AssocTypes,
8972  AssocExprs);
8973 }
8974 
8975 template<typename Derived>
8976 ExprResult
8978  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
8979  if (SubExpr.isInvalid())
8980  return ExprError();
8981 
8982  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
8983  return E;
8984 
8985  return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
8986  E->getRParen());
8987 }
8988 
8989 /// \brief The operand of a unary address-of operator has special rules: it's
8990 /// allowed to refer to a non-static member of a class even if there's no 'this'
8991 /// object available.
8992 template<typename Derived>
8993 ExprResult
8995  if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
8996  return getDerived().TransformDependentScopeDeclRefExpr(DRE, true, nullptr);
8997  else
8998  return getDerived().TransformExpr(E);
8999 }
9000 
9001 template<typename Derived>
9002 ExprResult
9004  ExprResult SubExpr;
9005  if (E->getOpcode() == UO_AddrOf)
9006  SubExpr = TransformAddressOfOperand(E->getSubExpr());
9007  else
9008  SubExpr = TransformExpr(E->getSubExpr());
9009  if (SubExpr.isInvalid())
9010  return ExprError();
9011 
9012  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
9013  return E;
9014 
9015  return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
9016  E->getOpcode(),
9017  SubExpr.get());
9018 }
9019 
9020 template<typename Derived>
9021 ExprResult
9023  // Transform the type.
9024  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
9025  if (!Type)
9026  return ExprError();
9027 
9028  // Transform all of the components into components similar to what the
9029  // parser uses.
9030  // FIXME: It would be slightly more efficient in the non-dependent case to
9031  // just map FieldDecls, rather than requiring the rebuilder to look for
9032  // the fields again. However, __builtin_offsetof is rare enough in
9033  // template code that we don't care.
9034  bool ExprChanged = false;
9035  typedef Sema::OffsetOfComponent Component;
9036  SmallVector<Component, 4> Components;
9037  for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
9038  const OffsetOfNode &ON = E->getComponent(I);
9039  Component Comp;
9040  Comp.isBrackets = true;
9041  Comp.LocStart = ON.getSourceRange().getBegin();
9042  Comp.LocEnd = ON.getSourceRange().getEnd();
9043  switch (ON.getKind()) {
9044  case OffsetOfNode::Array: {
9045  Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
9046  ExprResult Index = getDerived().TransformExpr(FromIndex);
9047  if (Index.isInvalid())
9048  return ExprError();
9049 
9050  ExprChanged = ExprChanged || Index.get() != FromIndex;
9051  Comp.isBrackets = true;
9052  Comp.U.E = Index.get();
9053  break;
9054  }
9055 
9056  case OffsetOfNode::Field:
9058  Comp.isBrackets = false;
9059  Comp.U.IdentInfo = ON.getFieldName();
9060  if (!Comp.U.IdentInfo)
9061  continue;
9062 
9063  break;
9064 
9065  case OffsetOfNode::Base:
9066  // Will be recomputed during the rebuild.
9067  continue;
9068  }
9069 
9070  Components.push_back(Comp);
9071  }
9072 
9073  // If nothing changed, retain the existing expression.
9074  if (!getDerived().AlwaysRebuild() &&
9075  Type == E->getTypeSourceInfo() &&
9076  !ExprChanged)
9077  return E;
9078 
9079  // Build a new offsetof expression.
9080  return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
9081  Components, E->getRParenLoc());
9082 }
9083 
9084 template<typename Derived>
9085 ExprResult
9087  assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
9088  "opaque value expression requires transformation");
9089  return E;
9090 }
9091 
9092 template<typename Derived>
9093 ExprResult
9095  return E;
9096 }
9097 
9098 template<typename Derived>
9099 ExprResult
9101  // Rebuild the syntactic form. The original syntactic form has
9102  // opaque-value expressions in it, so strip those away and rebuild
9103  // the result. This is a really awful way of doing this, but the
9104  // better solution (rebuilding the semantic expressions and
9105  // rebinding OVEs as necessary) doesn't work; we'd need
9106  // TreeTransform to not strip away implicit conversions.
9107  Expr *newSyntacticForm = SemaRef.recreateSyntacticForm(E);
9108  ExprResult result = getDerived().TransformExpr(newSyntacticForm);
9109  if (result.isInvalid()) return ExprError();
9110 
9111  // If that gives us a pseudo-object result back, the pseudo-object
9112  // expression must have been an lvalue-to-rvalue conversion which we
9113  // should reapply.
9114  if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
9115  result = SemaRef.checkPseudoObjectRValue(result.get());
9116 
9117  return result;
9118 }
9119 
9120 template<typename Derived>
9121 ExprResult
9124  if (E->isArgumentType()) {
9125  TypeSourceInfo *OldT = E->getArgumentTypeInfo();
9126 
9127  TypeSourceInfo *NewT = getDerived().TransformType(OldT);
9128  if (!NewT)
9129  return ExprError();
9130 
9131  if (!getDerived().AlwaysRebuild() && OldT == NewT)
9132  return E;
9133 
9134  return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
9135  E->getKind(),
9136  E->getSourceRange());
9137  }
9138 
9139  // C++0x [expr.sizeof]p1:
9140  // The operand is either an expression, which is an unevaluated operand
9141  // [...]
9145 
9146  // Try to recover if we have something like sizeof(T::X) where X is a type.
9147  // Notably, there must be *exactly* one set of parens if X is a type.
9148  TypeSourceInfo *RecoveryTSI = nullptr;
9149  ExprResult SubExpr;
9150  auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
9151  if (auto *DRE =
9152  PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
9153  SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
9154  PE, DRE, false, &RecoveryTSI);
9155  else
9156  SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
9157 
9158  if (RecoveryTSI) {
9159  return getDerived().RebuildUnaryExprOrTypeTrait(
9160  RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
9161  } else if (SubExpr.isInvalid())
9162  return ExprError();
9163 
9164  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
9165  return E;
9166 
9167  return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
9168  E->getOperatorLoc(),
9169  E->getKind(),
9170  E->getSourceRange());
9171 }
9172 
9173 template<typename Derived>
9174 ExprResult
9176  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9177  if (LHS.isInvalid())
9178  return ExprError();
9179 
9180  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9181  if (RHS.isInvalid())
9182  return ExprError();
9183 
9184 
9185  if (!getDerived().AlwaysRebuild() &&
9186  LHS.get() == E->getLHS() &&
9187  RHS.get() == E->getRHS())
9188  return E;
9189 
9190  return getDerived().RebuildArraySubscriptExpr(LHS.get(),
9191  /*FIXME:*/E->getLHS()->getLocStart(),
9192  RHS.get(),
9193  E->getRBracketLoc());
9194 }
9195 
9196 template <typename Derived>
9197 ExprResult
9199  ExprResult Base = getDerived().TransformExpr(E->getBase());
9200  if (Base.isInvalid())
9201  return ExprError();
9202 
9203  ExprResult LowerBound;
9204  if (E->getLowerBound()) {
9205  LowerBound = getDerived().TransformExpr(E->getLowerBound());
9206  if (LowerBound.isInvalid())
9207  return ExprError();
9208  }
9209 
9210  ExprResult Length;
9211  if (E->getLength()) {
9212  Length = getDerived().TransformExpr(E->getLength());
9213  if (Length.isInvalid())
9214  return ExprError();
9215  }
9216 
9217  if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
9218  LowerBound.get() == E->getLowerBound() && Length.get() == E->getLength())
9219  return E;
9220 
9221  return getDerived().RebuildOMPArraySectionExpr(
9222  Base.get(), E->getBase()->getLocEnd(), LowerBound.get(), E->getColonLoc(),
9223  Length.get(), E->getRBracketLoc());
9224 }
9225 
9226 template<typename Derived>
9227 ExprResult
9229  // Transform the callee.
9230  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
9231  if (Callee.isInvalid())
9232  return ExprError();
9233 
9234  // Transform arguments.
9235  bool ArgChanged = false;
9236  SmallVector<Expr*, 8> Args;
9237  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
9238  &ArgChanged))
9239  return ExprError();
9240 
9241  if (!getDerived().AlwaysRebuild() &&
9242  Callee.get() == E->getCallee() &&
9243  !ArgChanged)
9244  return SemaRef.MaybeBindToTemporary(E);
9245 
9246  // FIXME: Wrong source location information for the '('.
9247  SourceLocation FakeLParenLoc
9248  = ((Expr *)Callee.get())->getSourceRange().getBegin();
9249  return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
9250  Args,
9251  E->getRParenLoc());
9252 }
9253 
9254 template<typename Derived>
9255 ExprResult
9257  ExprResult Base = getDerived().TransformExpr(E->getBase());
9258  if (Base.isInvalid())
9259  return ExprError();
9260 
9261  NestedNameSpecifierLoc QualifierLoc;
9262  if (E->hasQualifier()) {
9263  QualifierLoc
9264  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9265 
9266  if (!QualifierLoc)
9267  return ExprError();
9268  }
9269  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
9270 
9271  ValueDecl *Member
9272  = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
9273  E->getMemberDecl()));
9274  if (!Member)
9275  return ExprError();
9276 
9277  NamedDecl *FoundDecl = E->getFoundDecl();
9278  if (FoundDecl == E->getMemberDecl()) {
9279  FoundDecl = Member;
9280  } else {
9281  FoundDecl = cast_or_null<NamedDecl>(
9282  getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
9283  if (!FoundDecl)
9284  return ExprError();
9285  }
9286 
9287  if (!getDerived().AlwaysRebuild() &&
9288  Base.get() == E->getBase() &&
9289  QualifierLoc == E->getQualifierLoc() &&
9290  Member == E->getMemberDecl() &&
9291  FoundDecl == E->getFoundDecl() &&
9292  !E->hasExplicitTemplateArgs()) {
9293 
9294  // Mark it referenced in the new context regardless.
9295  // FIXME: this is a bit instantiation-specific.
9296  SemaRef.MarkMemberReferenced(E);
9297 
9298  return E;
9299  }
9300 
9301  TemplateArgumentListInfo TransArgs;
9302  if (E->hasExplicitTemplateArgs()) {
9303  TransArgs.setLAngleLoc(E->getLAngleLoc());
9304  TransArgs.setRAngleLoc(E->getRAngleLoc());
9305  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
9306  E->getNumTemplateArgs(),
9307  TransArgs))
9308  return ExprError();
9309  }
9310 
9311  // FIXME: Bogus source location for the operator
9312  SourceLocation FakeOperatorLoc =
9313  SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
9314 
9315  // FIXME: to do this check properly, we will need to preserve the
9316  // first-qualifier-in-scope here, just in case we had a dependent
9317  // base (and therefore couldn't do the check) and a
9318  // nested-name-qualifier (and therefore could do the lookup).
9319  NamedDecl *FirstQualifierInScope = nullptr;
9320  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
9321  if (MemberNameInfo.getName()) {
9322  MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
9323  if (!MemberNameInfo.getName())
9324  return ExprError();
9325  }
9326 
9327  return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
9328  E->isArrow(),
9329  QualifierLoc,
9330  TemplateKWLoc,
9331  MemberNameInfo,
9332  Member,
9333  FoundDecl,
9335  ? &TransArgs : nullptr),
9336  FirstQualifierInScope);
9337 }
9338 
9339 template<typename Derived>
9340 ExprResult
9342  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9343  if (LHS.isInvalid())
9344  return ExprError();
9345 
9346  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9347  if (RHS.isInvalid())
9348  return ExprError();
9349 
9350  if (!getDerived().AlwaysRebuild() &&
9351  LHS.get() == E->getLHS() &&
9352  RHS.get() == E->getRHS())
9353  return E;
9354 
9355  Sema::FPContractStateRAII FPContractState(getSema());
9356  getSema().FPFeatures = E->getFPFeatures();
9357 
9358  return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
9359  LHS.get(), RHS.get());
9360 }
9361 
9362 template<typename Derived>
9363 ExprResult
9366  return getDerived().TransformBinaryOperator(E);
9367 }
9368 
9369 template<typename Derived>
9372  // Just rebuild the common and RHS expressions and see whether we
9373  // get any changes.
9374 
9375  ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
9376  if (commonExpr.isInvalid())
9377  return ExprError();
9378 
9379  ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
9380  if (rhs.isInvalid())
9381  return ExprError();
9382 
9383  if (!getDerived().AlwaysRebuild() &&
9384  commonExpr.get() == e->getCommon() &&
9385  rhs.get() == e->getFalseExpr())
9386  return e;
9387 
9388  return getDerived().RebuildConditionalOperator(commonExpr.get(),
9389  e->getQuestionLoc(),
9390  nullptr,
9391  e->getColonLoc(),
9392  rhs.get());
9393 }
9394 
9395 template<typename Derived>
9396 ExprResult
9398  ExprResult Cond = getDerived().TransformExpr(E->getCond());
9399  if (Cond.isInvalid())
9400  return ExprError();
9401 
9402  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9403  if (LHS.isInvalid())
9404  return ExprError();
9405 
9406  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9407  if (RHS.isInvalid())
9408  return ExprError();
9409 
9410  if (!getDerived().AlwaysRebuild() &&
9411  Cond.get() == E->getCond() &&
9412  LHS.get() == E->getLHS() &&
9413  RHS.get() == E->getRHS())
9414  return E;
9415 
9416  return getDerived().RebuildConditionalOperator(Cond.get(),
9417  E->getQuestionLoc(),
9418  LHS.get(),
9419  E->getColonLoc(),
9420  RHS.get());
9421 }
9422 
9423 template<typename Derived>
9424 ExprResult
9426  // Implicit casts are eliminated during transformation, since they
9427  // will be recomputed by semantic analysis after transformation.
9428  return getDerived().TransformExpr(E->getSubExprAsWritten());
9429 }
9430 
9431 template<typename Derived>
9432 ExprResult
9434  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
9435  if (!Type)
9436  return ExprError();
9437 
9438  ExprResult SubExpr
9439  = getDerived().TransformExpr(E->getSubExprAsWritten());
9440  if (SubExpr.isInvalid())
9441  return ExprError();
9442 
9443  if (!getDerived().AlwaysRebuild() &&
9444  Type == E->getTypeInfoAsWritten() &&
9445  SubExpr.get() == E->getSubExpr())
9446  return E;
9447 
9448  return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
9449  Type,
9450  E->getRParenLoc(),
9451  SubExpr.get());
9452 }
9453 
9454 template<typename Derived>
9455 ExprResult
9457  TypeSourceInfo *OldT = E->getTypeSourceInfo();
9458  TypeSourceInfo *NewT = getDerived().TransformType(OldT);
9459  if (!NewT)
9460  return ExprError();
9461 
9462  ExprResult Init = getDerived().TransformExpr(E->getInitializer());
9463  if (Init.isInvalid())
9464  return ExprError();
9465 
9466  if (!getDerived().AlwaysRebuild() &&
9467  OldT == NewT &&
9468  Init.get() == E->getInitializer())
9469  return SemaRef.MaybeBindToTemporary(E);
9470 
9471  // Note: the expression type doesn't necessarily match the
9472  // type-as-written, but that's okay, because it should always be
9473  // derivable from the initializer.
9474 
9475  return getDerived().RebuildCompoundLiteralExpr(E->getLParenLoc(), NewT,
9476  /*FIXME:*/E->getInitializer()->getLocEnd(),
9477  Init.get());
9478 }
9479 
9480 template<typename Derived>
9481 ExprResult
9483  ExprResult Base = getDerived().TransformExpr(E->getBase());
9484  if (Base.isInvalid())
9485  return ExprError();
9486 
9487  if (!getDerived().AlwaysRebuild() &&
9488  Base.get() == E->getBase())
9489  return E;
9490 
9491  // FIXME: Bad source location
9492  SourceLocation FakeOperatorLoc =
9493  SemaRef.getLocForEndOfToken(E->getBase()->getLocEnd());
9494  return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc,
9495  E->getAccessorLoc(),
9496  E->getAccessor());
9497 }
9498 
9499 template<typename Derived>
9500 ExprResult
9502  if (InitListExpr *Syntactic = E->getSyntacticForm())
9503  E = Syntactic;
9504 
9505  bool InitChanged = false;
9506 
9508  if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
9509  Inits, &InitChanged))
9510  return ExprError();
9511 
9512  if (!getDerived().AlwaysRebuild() && !InitChanged) {
9513  // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
9514  // in some cases. We can't reuse it in general, because the syntactic and
9515  // semantic forms are linked, and we can't know that semantic form will
9516  // match even if the syntactic form does.
9517  }
9518 
9519  return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
9520  E->getRBraceLoc(), E->getType());
9521 }
9522 
9523 template<typename Derived>
9524 ExprResult
9526  Designation Desig;
9527 
9528  // transform the initializer value
9529  ExprResult Init = getDerived().TransformExpr(E->getInit());
9530  if (Init.isInvalid())
9531  return ExprError();
9532 
9533  // transform the designators.
9534  SmallVector<Expr*, 4> ArrayExprs;
9535  bool ExprChanged = false;
9536  for (const DesignatedInitExpr::Designator &D : E->designators()) {
9537  if (D.isFieldDesignator()) {
9538  Desig.AddDesignator(Designator::getField(D.getFieldName(),
9539  D.getDotLoc(),
9540  D.getFieldLoc()));
9541  if (D.getField()) {
9542  FieldDecl *Field = cast_or_null<FieldDecl>(
9543  getDerived().TransformDecl(D.getFieldLoc(), D.getField()));
9544  if (Field != D.getField())
9545  // Rebuild the expression when the transformed FieldDecl is
9546  // different to the already assigned FieldDecl.
9547  ExprChanged = true;
9548  } else {
9549  // Ensure that the designator expression is rebuilt when there isn't
9550  // a resolved FieldDecl in the designator as we don't want to assign
9551  // a FieldDecl to a pattern designator that will be instantiated again.
9552  ExprChanged = true;
9553  }
9554  continue;
9555  }
9556 
9557  if (D.isArrayDesignator()) {
9558  ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
9559  if (Index.isInvalid())
9560  return ExprError();
9561 
9562  Desig.AddDesignator(
9563  Designator::getArray(Index.get(), D.getLBracketLoc()));
9564 
9565  ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D);
9566  ArrayExprs.push_back(Index.get());
9567  continue;
9568  }
9569 
9570  assert(D.isArrayRangeDesignator() && "New kind of designator?");
9571  ExprResult Start
9572  = getDerived().TransformExpr(E->getArrayRangeStart(D));
9573  if (Start.isInvalid())
9574  return ExprError();
9575 
9576  ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
9577  if (End.isInvalid())
9578  return ExprError();
9579 
9580  Desig.AddDesignator(Designator::getArrayRange(Start.get(),
9581  End.get(),
9582  D.getLBracketLoc(),
9583  D.getEllipsisLoc()));
9584 
9585  ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
9586  End.get() != E->getArrayRangeEnd(D);
9587 
9588  ArrayExprs.push_back(Start.get());
9589  ArrayExprs.push_back(End.get());
9590  }
9591 
9592  if (!getDerived().AlwaysRebuild() &&
9593  Init.get() == E->getInit() &&
9594  !ExprChanged)
9595  return E;
9596 
9597  return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
9598  E->getEqualOrColonLoc(),
9599  E->usesGNUSyntax(), Init.get());
9600 }
9601 
9602 // Seems that if TransformInitListExpr() only works on the syntactic form of an
9603 // InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
9604 template<typename Derived>
9605 ExprResult
9608  llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
9609  "initializer");
9610  return ExprError();
9611 }
9612 
9613 template<typename Derived>
9614 ExprResult
9616  NoInitExpr *E) {
9617  llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
9618  return ExprError();
9619 }
9620 
9621 template<typename Derived>
9622 ExprResult
9624  llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
9625  return ExprError();
9626 }
9627 
9628 template<typename Derived>
9629 ExprResult
9631  llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
9632  return ExprError();
9633 }
9634 
9635 template<typename Derived>
9636 ExprResult
9638  ImplicitValueInitExpr *E) {
9639  TemporaryBase Rebase(*this, E->getLocStart(), DeclarationName());
9640 
9641  // FIXME: Will we ever have proper type location here? Will we actually
9642  // need to transform the type?
9643  QualType T = getDerived().TransformType(E->getType());
9644  if (T.isNull())
9645  return ExprError();
9646 
9647  if (!getDerived().AlwaysRebuild() &&
9648  T == E->getType())
9649  return E;
9650 
9651  return getDerived().RebuildImplicitValueInitExpr(T);
9652 }
9653 
9654 template<typename Derived>
9655 ExprResult
9657  TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
9658  if (!TInfo)
9659  return ExprError();
9660 
9661  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
9662  if (SubExpr.isInvalid())
9663  return ExprError();
9664 
9665  if (!getDerived().AlwaysRebuild() &&
9666  TInfo == E->getWrittenTypeInfo() &&
9667  SubExpr.get() == E->getSubExpr())
9668  return E;
9669 
9670  return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
9671  TInfo, E->getRParenLoc());
9672 }
9673 
9674 template<typename Derived>
9675 ExprResult
9677  bool ArgumentChanged = false;
9679  if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
9680  &ArgumentChanged))
9681  return ExprError();
9682 
9683  return getDerived().RebuildParenListExpr(E->getLParenLoc(),
9684  Inits,
9685  E->getRParenLoc());
9686 }
9687 
9688 /// \brief Transform an address-of-label expression.
9689 ///
9690 /// By default, the transformation of an address-of-label expression always
9691 /// rebuilds the expression, so that the label identifier can be resolved to
9692 /// the corresponding label statement by semantic analysis.
9693 template<typename Derived>
9694 ExprResult
9696  Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
9697  E->getLabel());
9698  if (!LD)
9699  return ExprError();
9700 
9701  return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
9702  cast<LabelDecl>(LD));
9703 }
9704 
9705 template<typename Derived>
9706 ExprResult
9708  SemaRef.ActOnStartStmtExpr();
9709  StmtResult SubStmt
9710  = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
9711  if (SubStmt.isInvalid()) {
9712  SemaRef.ActOnStmtExprError();
9713  return ExprError();
9714  }
9715 
9716  if (!getDerived().AlwaysRebuild() &&
9717  SubStmt.get() == E->getSubStmt()) {
9718  // Calling this an 'error' is unintuitive, but it does the right thing.
9719  SemaRef.ActOnStmtExprError();
9720  return SemaRef.MaybeBindToTemporary(E);
9721  }
9722 
9723  return getDerived().RebuildStmtExpr(E->getLParenLoc(),
9724  SubStmt.get(),
9725  E->getRParenLoc());
9726 }
9727 
9728 template<typename Derived>
9729 ExprResult
9731  ExprResult Cond = getDerived().TransformExpr(E->getCond());
9732  if (Cond.isInvalid())
9733  return ExprError();
9734 
9735  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9736  if (LHS.isInvalid())
9737  return ExprError();
9738 
9739  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9740  if (RHS.isInvalid())
9741  return ExprError();
9742 
9743  if (!getDerived().AlwaysRebuild() &&
9744  Cond.get() == E->getCond() &&
9745  LHS.get() == E->getLHS() &&
9746  RHS.get() == E->getRHS())
9747  return E;
9748 
9749  return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
9750  Cond.get(), LHS.get(), RHS.get(),
9751  E->getRParenLoc());
9752 }
9753 
9754 template<typename Derived>
9755 ExprResult
9757  return E;
9758 }
9759 
9760 template<typename Derived>
9761 ExprResult
9763  switch (E->getOperator()) {
9764  case OO_New:
9765  case OO_Delete:
9766  case OO_Array_New:
9767  case OO_Array_Delete:
9768  llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
9769 
9770  case OO_Call: {
9771  // This is a call to an object's operator().
9772  assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
9773 
9774  // Transform the object itself.
9775  ExprResult Object = getDerived().TransformExpr(E->getArg(0));
9776  if (Object.isInvalid())
9777  return ExprError();
9778 
9779  // FIXME: Poor location information
9780  SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(
9781  static_cast<Expr *>(Object.get())->getLocEnd());
9782 
9783  // Transform the call arguments.
9784  SmallVector<Expr*, 8> Args;
9785  if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
9786  Args))
9787  return ExprError();
9788 
9789  return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc,
9790  Args,
9791  E->getLocEnd());
9792  }
9793 
9794 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
9795  case OO_##Name:
9796 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
9797 #include "clang/Basic/OperatorKinds.def"
9798  case OO_Subscript:
9799  // Handled below.
9800  break;
9801 
9802  case OO_Conditional:
9803  llvm_unreachable("conditional operator is not actually overloadable");
9804 
9805  case OO_None:
9807  llvm_unreachable("not an overloaded operator?");
9808  }
9809 
9810  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
9811  if (Callee.isInvalid())
9812  return ExprError();
9813 
9814  ExprResult First;
9815  if (E->getOperator() == OO_Amp)
9816  First = getDerived().TransformAddressOfOperand(E->getArg(0));
9817  else
9818  First = getDerived().TransformExpr(E->getArg(0));
9819  if (First.isInvalid())
9820  return ExprError();
9821 
9822  ExprResult Second;
9823  if (E->getNumArgs() == 2) {
9824  Second = getDerived().TransformExpr(E->getArg(1));
9825  if (Second.isInvalid())
9826  return ExprError();
9827  }
9828 
9829  if (!getDerived().AlwaysRebuild() &&
9830  Callee.get() == E->getCallee() &&
9831  First.get() == E->getArg(0) &&
9832  (E->getNumArgs() != 2 || Second.get() == E->getArg(1)))
9833  return SemaRef.MaybeBindToTemporary(E);
9834 
9835  Sema::FPContractStateRAII FPContractState(getSema());
9836  getSema().FPFeatures = E->getFPFeatures();
9837 
9838  return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(),
9839  E->getOperatorLoc(),
9840  Callee.get(),
9841  First.get(),
9842  Second.get());
9843 }
9844 
9845 template<typename Derived>
9846 ExprResult
9848  return getDerived().TransformCallExpr(E);
9849 }
9850 
9851 template<typename Derived>
9852 ExprResult
9854  // Transform the callee.
9855  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
9856  if (Callee.isInvalid())
9857  return ExprError();
9858 
9859  // Transform exec config.
9860  ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
9861  if (EC.isInvalid())
9862  return ExprError();
9863 
9864  // Transform arguments.
9865  bool ArgChanged = false;
9866  SmallVector<Expr*, 8> Args;
9867  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
9868  &ArgChanged))
9869  return ExprError();
9870 
9871  if (!getDerived().AlwaysRebuild() &&
9872  Callee.get() == E->getCallee() &&
9873  !ArgChanged)
9874  return SemaRef.MaybeBindToTemporary(E);
9875 
9876  // FIXME: Wrong source location information for the '('.
9877  SourceLocation FakeLParenLoc
9878  = ((Expr *)Callee.get())->getSourceRange().getBegin();
9879  return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
9880  Args,
9881  E->getRParenLoc(), EC.get());
9882 }
9883 
9884 template<typename Derived>
9885 ExprResult
9887  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
9888  if (!Type)
9889  return ExprError();
9890 
9891  ExprResult SubExpr
9892  = getDerived().TransformExpr(E->getSubExprAsWritten());
9893  if (SubExpr.isInvalid())
9894  return ExprError();
9895 
9896  if (!getDerived().AlwaysRebuild() &&
9897  Type == E->getTypeInfoAsWritten() &&
9898  SubExpr.get() == E->getSubExpr())
9899  return E;
9900  return getDerived().RebuildCXXNamedCastExpr(
9902  Type, E->getAngleBrackets().getEnd(),
9903  // FIXME. this should be '(' location
9904  E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
9905 }
9906 
9907 template<typename Derived>
9908 ExprResult
9910  return getDerived().TransformCXXNamedCastExpr(E);
9911 }
9912 
9913 template<typename Derived>
9914 ExprResult
9916  return getDerived().TransformCXXNamedCastExpr(E);
9917 }
9918 
9919 template<typename Derived>
9920 ExprResult
9923  return getDerived().TransformCXXNamedCastExpr(E);
9924 }
9925 
9926 template<typename Derived>
9927 ExprResult
9929  return getDerived().TransformCXXNamedCastExpr(E);
9930 }
9931 
9932 template<typename Derived>
9933 ExprResult
9935  CXXFunctionalCastExpr *E) {
9936  TypeSourceInfo *Type =
9937  getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
9938  if (!Type)
9939  return ExprError();
9940 
9941  ExprResult SubExpr
9942  = getDerived().TransformExpr(E->getSubExprAsWritten());
9943  if (SubExpr.isInvalid())
9944  return ExprError();
9945 
9946  if (!getDerived().AlwaysRebuild() &&
9947  Type == E->getTypeInfoAsWritten() &&
9948  SubExpr.get() == E->getSubExpr())
9949  return E;
9950 
9951  return getDerived().RebuildCXXFunctionalCastExpr(Type,
9952  E->getLParenLoc(),
9953  SubExpr.get(),
9954  E->getRParenLoc());
9955 }
9956 
9957 template<typename Derived>
9958 ExprResult
9960  if (E->isTypeOperand()) {
9961  TypeSourceInfo *TInfo
9962  = getDerived().TransformType(E->getTypeOperandSourceInfo());
9963  if (!TInfo)
9964  return ExprError();
9965 
9966  if (!getDerived().AlwaysRebuild() &&
9967  TInfo == E->getTypeOperandSourceInfo())
9968  return E;
9969 
9970  return getDerived().RebuildCXXTypeidExpr(E->getType(),
9971  E->getLocStart(),
9972  TInfo,
9973  E->getLocEnd());
9974  }
9975 
9976  // We don't know whether the subexpression is potentially evaluated until
9977  // after we perform semantic analysis. We speculatively assume it is
9978  // unevaluated; it will get fixed later if the subexpression is in fact
9979  // potentially evaluated.
9983 
9984  ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
9985  if (SubExpr.isInvalid())
9986  return ExprError();
9987 
9988  if (!getDerived().AlwaysRebuild() &&
9989  SubExpr.get() == E->getExprOperand())
9990  return E;
9991 
9992  return getDerived().RebuildCXXTypeidExpr(E->getType(),
9993  E->getLocStart(),
9994  SubExpr.get(),
9995  E->getLocEnd());
9996 }
9997 
9998 template<typename Derived>
9999 ExprResult
10001  if (E->isTypeOperand()) {
10002  TypeSourceInfo *TInfo
10003  = getDerived().TransformType(E->getTypeOperandSourceInfo());
10004  if (!TInfo)
10005  return ExprError();
10006 
10007  if (!getDerived().AlwaysRebuild() &&
10008  TInfo == E->getTypeOperandSourceInfo())
10009  return E;
10010 
10011  return getDerived().RebuildCXXUuidofExpr(E->getType(),
10012  E->getLocStart(),
10013  TInfo,
10014  E->getLocEnd());
10015  }
10016 
10019 
10020  ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
10021  if (SubExpr.isInvalid())
10022  return ExprError();
10023 
10024  if (!getDerived().AlwaysRebuild() &&
10025  SubExpr.get() == E->getExprOperand())
10026  return E;
10027 
10028  return getDerived().RebuildCXXUuidofExpr(E->getType(),
10029  E->getLocStart(),
10030  SubExpr.get(),
10031  E->getLocEnd());
10032 }
10033 
10034 template<typename Derived>
10035 ExprResult
10037  return E;
10038 }
10039 
10040 template<typename Derived>
10041 ExprResult
10043  CXXNullPtrLiteralExpr *E) {
10044  return E;
10045 }
10046 
10047 template<typename Derived>
10048 ExprResult
10050  QualType T = getSema().getCurrentThisType();
10051 
10052  if (!getDerived().AlwaysRebuild() && T == E->getType()) {
10053  // Make sure that we capture 'this'.
10054  getSema().CheckCXXThisCapture(E->getLocStart());
10055  return E;
10056  }
10057 
10058  return getDerived().RebuildCXXThisExpr(E->getLocStart(), T, E->isImplicit());
10059 }
10060 
10061 template<typename Derived>
10062 ExprResult
10064  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
10065  if (SubExpr.isInvalid())
10066  return ExprError();
10067 
10068  if (!getDerived().AlwaysRebuild() &&
10069  SubExpr.get() == E->getSubExpr())
10070  return E;
10071 
10072  return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
10074 }
10075 
10076 template<typename Derived>
10077 ExprResult
10079  ParmVarDecl *Param
10080  = cast_or_null<ParmVarDecl>(getDerived().TransformDecl(E->getLocStart(),
10081  E->getParam()));
10082  if (!Param)
10083  return ExprError();
10084 
10085  if (!getDerived().AlwaysRebuild() &&
10086  Param == E->getParam())
10087  return E;
10088 
10089  return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param);
10090 }
10091 
10092 template<typename Derived>
10093 ExprResult
10095  FieldDecl *Field
10096  = cast_or_null<FieldDecl>(getDerived().TransformDecl(E->getLocStart(),
10097  E->getField()));
10098  if (!Field)
10099  return ExprError();
10100 
10101  if (!getDerived().AlwaysRebuild() && Field == E->getField())
10102  return E;
10103 
10104  return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
10105 }
10106 
10107 template<typename Derived>
10108 ExprResult
10111  TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
10112  if (!T)
10113  return ExprError();
10114 
10115  if (!getDerived().AlwaysRebuild() &&
10116  T == E->getTypeSourceInfo())
10117  return E;
10118 
10119  return getDerived().RebuildCXXScalarValueInitExpr(T,
10120  /*FIXME:*/T->getTypeLoc().getEndLoc(),
10121  E->getRParenLoc());
10122 }
10123 
10124 template<typename Derived>
10125 ExprResult
10127  // Transform the type that we're allocating
10128  TypeSourceInfo *AllocTypeInfo =
10129  getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
10130  if (!AllocTypeInfo)
10131  return ExprError();
10132 
10133  // Transform the size of the array we're allocating (if any).
10134  ExprResult ArraySize = getDerived().TransformExpr(E->getArraySize());
10135  if (ArraySize.isInvalid())
10136  return ExprError();
10137 
10138  // Transform the placement arguments (if any).
10139  bool ArgumentChanged = false;
10140  SmallVector<Expr*, 8> PlacementArgs;
10141  if (getDerived().TransformExprs(E->getPlacementArgs(),
10142  E->getNumPlacementArgs(), true,
10143  PlacementArgs, &ArgumentChanged))
10144  return ExprError();
10145 
10146  // Transform the initializer (if any).
10147  Expr *OldInit = E->getInitializer();
10148  ExprResult NewInit;
10149  if (OldInit)
10150  NewInit = getDerived().TransformInitializer(OldInit, true);
10151  if (NewInit.isInvalid())
10152  return ExprError();
10153 
10154  // Transform new operator and delete operator.
10155  FunctionDecl *OperatorNew = nullptr;
10156  if (E->getOperatorNew()) {
10157  OperatorNew = cast_or_null<FunctionDecl>(
10158  getDerived().TransformDecl(E->getLocStart(),
10159  E->getOperatorNew()));
10160  if (!OperatorNew)
10161  return ExprError();
10162  }
10163 
10164  FunctionDecl *OperatorDelete = nullptr;
10165  if (E->getOperatorDelete()) {
10166  OperatorDelete = cast_or_null<FunctionDecl>(
10167  getDerived().TransformDecl(E->getLocStart(),
10168  E->getOperatorDelete()));
10169  if (!OperatorDelete)
10170  return ExprError();
10171  }
10172 
10173  if (!getDerived().AlwaysRebuild() &&
10174  AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
10175  ArraySize.get() == E->getArraySize() &&
10176  NewInit.get() == OldInit &&
10177  OperatorNew == E->getOperatorNew() &&
10178  OperatorDelete == E->getOperatorDelete() &&
10179  !ArgumentChanged) {
10180  // Mark any declarations we need as referenced.
10181  // FIXME: instantiation-specific.
10182  if (OperatorNew)
10183  SemaRef.MarkFunctionReferenced(E->getLocStart(), OperatorNew);
10184  if (OperatorDelete)
10185  SemaRef.MarkFunctionReferenced(E->getLocStart(), OperatorDelete);
10186 
10187  if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
10188  QualType ElementType
10189  = SemaRef.Context.getBaseElementType(E->getAllocatedType());
10190  if (const RecordType *RecordT = ElementType->getAs<RecordType>()) {
10191  CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordT->getDecl());
10192  if (CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(Record)) {
10193  SemaRef.MarkFunctionReferenced(E->getLocStart(), Destructor);
10194  }
10195  }
10196  }
10197 
10198  return E;
10199  }
10200 
10201  QualType AllocType = AllocTypeInfo->getType();
10202  if (!ArraySize.get()) {
10203  // If no array size was specified, but the new expression was
10204  // instantiated with an array type (e.g., "new T" where T is
10205  // instantiated with "int[4]"), extract the outer bound from the
10206  // array type as our array size. We do this with constant and
10207  // dependently-sized array types.
10208  const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
10209  if (!ArrayT) {
10210  // Do nothing
10211  } else if (const ConstantArrayType *ConsArrayT
10212  = dyn_cast<ConstantArrayType>(ArrayT)) {
10213  ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
10214  SemaRef.Context.getSizeType(),
10215  /*FIXME:*/ E->getLocStart());
10216  AllocType = ConsArrayT->getElementType();
10217  } else if (const DependentSizedArrayType *DepArrayT
10218  = dyn_cast<DependentSizedArrayType>(ArrayT)) {
10219  if (DepArrayT->getSizeExpr()) {
10220  ArraySize = DepArrayT->getSizeExpr();
10221  AllocType = DepArrayT->getElementType();
10222  }
10223  }
10224  }
10225 
10226  return getDerived().RebuildCXXNewExpr(E->getLocStart(),
10227  E->isGlobalNew(),
10228  /*FIXME:*/E->getLocStart(),
10229  PlacementArgs,
10230  /*FIXME:*/E->getLocStart(),
10231  E->getTypeIdParens(),
10232  AllocType,
10233  AllocTypeInfo,
10234  ArraySize.get(),
10235  E->getDirectInitRange(),
10236  NewInit.get());
10237 }
10238 
10239 template<typename Derived>
10240 ExprResult
10242  ExprResult Operand = getDerived().TransformExpr(E->getArgument());
10243  if (Operand.isInvalid())
10244  return ExprError();
10245 
10246  // Transform the delete operator, if known.
10247  FunctionDecl *OperatorDelete = nullptr;
10248  if (E->getOperatorDelete()) {
10249  OperatorDelete = cast_or_null<FunctionDecl>(
10250  getDerived().TransformDecl(E->getLocStart(),
10251  E->getOperatorDelete()));
10252  if (!OperatorDelete)
10253  return ExprError();
10254  }
10255 
10256  if (!getDerived().AlwaysRebuild() &&
10257  Operand.get() == E->getArgument() &&
10258  OperatorDelete == E->getOperatorDelete()) {
10259  // Mark any declarations we need as referenced.
10260  // FIXME: instantiation-specific.
10261  if (OperatorDelete)
10262  SemaRef.MarkFunctionReferenced(E->getLocStart(), OperatorDelete);
10263 
10264  if (!E->getArgument()->isTypeDependent()) {
10265  QualType Destroyed = SemaRef.Context.getBaseElementType(
10266  E->getDestroyedType());
10267  if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
10268  CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
10269  SemaRef.MarkFunctionReferenced(E->getLocStart(),
10270  SemaRef.LookupDestructor(Record));
10271  }
10272  }
10273 
10274  return E;
10275  }
10276 
10277  return getDerived().RebuildCXXDeleteExpr(E->getLocStart(),
10278  E->isGlobalDelete(),
10279  E->isArrayForm(),
10280  Operand.get());
10281 }
10282 
10283 template<typename Derived>
10284 ExprResult
10287  ExprResult Base = getDerived().TransformExpr(E->getBase());
10288  if (Base.isInvalid())
10289  return ExprError();
10290 
10291  ParsedType ObjectTypePtr;
10292  bool MayBePseudoDestructor = false;
10293  Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
10294  E->getOperatorLoc(),
10295  E->isArrow()? tok::arrow : tok::period,
10296  ObjectTypePtr,
10297  MayBePseudoDestructor);
10298  if (Base.isInvalid())
10299  return ExprError();
10300 
10301  QualType ObjectType = ObjectTypePtr.get();
10302  NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
10303  if (QualifierLoc) {
10304  QualifierLoc
10305  = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
10306  if (!QualifierLoc)
10307  return ExprError();
10308  }
10309  CXXScopeSpec SS;
10310  SS.Adopt(QualifierLoc);
10311 
10312  PseudoDestructorTypeStorage Destroyed;
10313  if (E->getDestroyedTypeInfo()) {
10314  TypeSourceInfo *DestroyedTypeInfo
10315  = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(),
10316  ObjectType, nullptr, SS);
10317  if (!DestroyedTypeInfo)
10318  return ExprError();
10319  Destroyed = DestroyedTypeInfo;
10320  } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
10321  // We aren't likely to be able to resolve the identifier down to a type
10322  // now anyway, so just retain the identifier.
10324  E->getDestroyedTypeLoc());
10325  } else {
10326  // Look for a destructor known with the given name.
10327  ParsedType T = SemaRef.getDestructorName(E->getTildeLoc(),
10329  E->getDestroyedTypeLoc(),
10330  /*Scope=*/nullptr,
10331  SS, ObjectTypePtr,
10332  false);
10333  if (!T)
10334  return ExprError();
10335 
10336  Destroyed
10337  = SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.GetTypeFromParser(T),
10338  E->getDestroyedTypeLoc());
10339  }
10340 
10341  TypeSourceInfo *ScopeTypeInfo = nullptr;
10342  if (E->getScopeTypeInfo()) {
10343  CXXScopeSpec EmptySS;
10344  ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
10345  E->getScopeTypeInfo(), ObjectType, nullptr, EmptySS);
10346  if (!ScopeTypeInfo)
10347  return ExprError();
10348  }
10349 
10350  return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
10351  E->getOperatorLoc(),
10352  E->isArrow(),
10353  SS,
10354  ScopeTypeInfo,
10355  E->getColonColonLoc(),
10356  E->getTildeLoc(),
10357  Destroyed);
10358 }
10359 
10360 template <typename Derived>
10362  bool RequiresADL,
10363  LookupResult &R) {
10364  // Transform all the decls.
10365  bool AllEmptyPacks = true;
10366  for (auto *OldD : Old->decls()) {
10367  Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
10368  if (!InstD) {
10369  // Silently ignore these if a UsingShadowDecl instantiated to nothing.
10370  // This can happen because of dependent hiding.
10371  if (isa<UsingShadowDecl>(OldD))
10372  continue;
10373  else {
10374  R.clear();
10375  return true;
10376  }
10377  }
10378 
10379  // Expand using pack declarations.
10380  NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
10381  ArrayRef<NamedDecl*> Decls = SingleDecl;
10382  if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
10383  Decls = UPD->expansions();
10384 
10385  // Expand using declarations.
10386  for (auto *D : Decls) {
10387  if (auto *UD = dyn_cast<UsingDecl>(D)) {
10388  for (auto *SD : UD->shadows())
10389  R.addDecl(SD);
10390  } else {
10391  R.addDecl(D);
10392  }
10393  }
10394 
10395  AllEmptyPacks &= Decls.empty();
10396  };
10397 
10398  // C++ [temp.res]/8.4.2:
10399  // The program is ill-formed, no diagnostic required, if [...] lookup for
10400  // a name in the template definition found a using-declaration, but the
10401  // lookup in the corresponding scope in the instantiation odoes not find
10402  // any declarations because the using-declaration was a pack expansion and
10403  // the corresponding pack is empty
10404  if (AllEmptyPacks && !RequiresADL) {
10405  getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
10406  << isa<UnresolvedMemberExpr>(Old) << Old->getNameInfo().getName();
10407  return true;
10408  }
10409 
10410  // Resolve a kind, but don't do any further analysis. If it's
10411  // ambiguous, the callee needs to deal with it.
10412  R.resolveKind();
10413  return false;
10414 }
10415 
10416 template<typename Derived>
10417 ExprResult
10419  UnresolvedLookupExpr *Old) {
10420  LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
10422 
10423  // Transform the declaration set.
10424  if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
10425  return ExprError();
10426 
10427  // Rebuild the nested-name qualifier, if present.
10428  CXXScopeSpec SS;
10429  if (Old->getQualifierLoc()) {
10430  NestedNameSpecifierLoc QualifierLoc
10431  = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
10432  if (!QualifierLoc)
10433  return ExprError();
10434 
10435  SS.Adopt(QualifierLoc);
10436  }
10437 
10438  if (Old->getNamingClass()) {
10439  CXXRecordDecl *NamingClass
10440  = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
10441  Old->getNameLoc(),
10442  Old->getNamingClass()));
10443  if (!NamingClass) {
10444  R.clear();
10445  return ExprError();
10446  }
10447 
10448  R.setNamingClass(NamingClass);
10449  }
10450 
10451  SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
10452 
10453  // If we have neither explicit template arguments, nor the template keyword,
10454  // it's a normal declaration name or member reference.
10455  if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid()) {
10456  NamedDecl *D = R.getAsSingle<NamedDecl>();
10457  // In a C++11 unevaluated context, an UnresolvedLookupExpr might refer to an
10458  // instance member. In other contexts, BuildPossibleImplicitMemberExpr will
10459  // give a good diagnostic.
10460  if (D && D->isCXXInstanceMember()) {
10461  return SemaRef.BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, R,
10462  /*TemplateArgs=*/nullptr,
10463  /*Scope=*/nullptr);
10464  }
10465 
10466  return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
10467  }
10468 
10469  // If we have template arguments, rebuild them, then rebuild the
10470  // templateid expression.
10471  TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
10472  if (Old->hasExplicitTemplateArgs() &&
10473  getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
10474  Old->getNumTemplateArgs(),
10475  TransArgs)) {
10476  R.clear();
10477  return ExprError();
10478  }
10479 
10480  return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
10481  Old->requiresADL(), &TransArgs);
10482 }
10483 
10484 template<typename Derived>
10485 ExprResult
10487  bool ArgChanged = false;
10489  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
10490  TypeSourceInfo *From = E->getArg(I);
10491  TypeLoc FromTL = From->getTypeLoc();
10492  if (!FromTL.getAs<PackExpansionTypeLoc>()) {
10493  TypeLocBuilder TLB;
10494  TLB.reserve(FromTL.getFullDataSize());
10495  QualType To = getDerived().TransformType(TLB, FromTL);
10496  if (To.isNull())
10497  return ExprError();
10498 
10499  if (To == From->getType())
10500  Args.push_back(From);
10501  else {
10502  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10503  ArgChanged = true;
10504  }
10505  continue;
10506  }
10507 
10508  ArgChanged = true;
10509 
10510  // We have a pack expansion. Instantiate it.
10511  PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
10512  TypeLoc PatternTL = ExpansionTL.getPatternLoc();
10514  SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
10515 
10516  // Determine whether the set of unexpanded parameter packs can and should
10517  // be expanded.
10518  bool Expand = true;
10519  bool RetainExpansion = false;
10520  Optional<unsigned> OrigNumExpansions =
10521  ExpansionTL.getTypePtr()->getNumExpansions();
10522  Optional<unsigned> NumExpansions = OrigNumExpansions;
10523  if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
10524  PatternTL.getSourceRange(),
10525  Unexpanded,
10526  Expand, RetainExpansion,
10527  NumExpansions))
10528  return ExprError();
10529 
10530  if (!Expand) {
10531  // The transform has determined that we should perform a simple
10532  // transformation on the pack expansion, producing another pack
10533  // expansion.
10534  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
10535 
10536  TypeLocBuilder TLB;
10537  TLB.reserve(From->getTypeLoc().getFullDataSize());
10538 
10539  QualType To = getDerived().TransformType(TLB, PatternTL);
10540  if (To.isNull())
10541  return ExprError();
10542 
10543  To = getDerived().RebuildPackExpansionType(To,
10544  PatternTL.getSourceRange(),
10545  ExpansionTL.getEllipsisLoc(),
10546  NumExpansions);
10547  if (To.isNull())
10548  return ExprError();
10549 
10550  PackExpansionTypeLoc ToExpansionTL
10551  = TLB.push<PackExpansionTypeLoc>(To);
10552  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
10553  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10554  continue;
10555  }
10556 
10557  // Expand the pack expansion by substituting for each argument in the
10558  // pack(s).
10559  for (unsigned I = 0; I != *NumExpansions; ++I) {
10560  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I);
10561  TypeLocBuilder TLB;
10562  TLB.reserve(PatternTL.getFullDataSize());
10563  QualType To = getDerived().TransformType(TLB, PatternTL);
10564  if (To.isNull())
10565  return ExprError();
10566 
10567  if (To->containsUnexpandedParameterPack()) {
10568  To = getDerived().RebuildPackExpansionType(To,
10569  PatternTL.getSourceRange(),
10570  ExpansionTL.getEllipsisLoc(),
10571  NumExpansions);
10572  if (To.isNull())
10573  return ExprError();
10574 
10575  PackExpansionTypeLoc ToExpansionTL
10576  = TLB.push<PackExpansionTypeLoc>(To);
10577  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
10578  }
10579 
10580  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10581  }
10582 
10583  if (!RetainExpansion)
10584  continue;
10585 
10586  // If we're supposed to retain a pack expansion, do so by temporarily
10587  // forgetting the partially-substituted parameter pack.
10588  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
10589 
10590  TypeLocBuilder TLB;
10591  TLB.reserve(From->getTypeLoc().getFullDataSize());
10592 
10593  QualType To = getDerived().TransformType(TLB, PatternTL);
10594  if (To.isNull())
10595  return ExprError();
10596 
10597  To = getDerived().RebuildPackExpansionType(To,
10598  PatternTL.getSourceRange(),
10599  ExpansionTL.getEllipsisLoc(),
10600  NumExpansions);
10601  if (To.isNull())
10602  return ExprError();
10603 
10604  PackExpansionTypeLoc ToExpansionTL
10605  = TLB.push<PackExpansionTypeLoc>(To);
10606  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
10607  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10608  }
10609 
10610  if (!getDerived().AlwaysRebuild() && !ArgChanged)
10611  return E;
10612 
10613  return getDerived().RebuildTypeTrait(E->getTrait(),
10614  E->getLocStart(),
10615  Args,
10616  E->getLocEnd());
10617 }
10618 
10619 template<typename Derived>
10620 ExprResult
10622  TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
10623  if (!T)
10624  return ExprError();
10625 
10626  if (!getDerived().AlwaysRebuild() &&
10627  T == E->getQueriedTypeSourceInfo())
10628  return E;
10629 
10630  ExprResult SubExpr;
10631  {
10634  SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
10635  if (SubExpr.isInvalid())
10636  return ExprError();
10637 
10638  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getDimensionExpression())
10639  return E;
10640  }
10641 
10642  return getDerived().RebuildArrayTypeTrait(E->getTrait(),
10643  E->getLocStart(),
10644  T,
10645  SubExpr.get(),
10646  E->getLocEnd());
10647 }
10648 
10649 template<typename Derived>
10650 ExprResult
10652  ExprResult SubExpr;
10653  {
10656  SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
10657  if (SubExpr.isInvalid())
10658  return ExprError();
10659 
10660  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
10661  return E;
10662  }
10663 
10664  return getDerived().RebuildExpressionTrait(
10665  E->getTrait(), E->getLocStart(), SubExpr.get(), E->getLocEnd());
10666 }
10667 
10668 template <typename Derived>
10670  ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
10671  TypeSourceInfo **RecoveryTSI) {
10672  ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
10673  DRE, AddrTaken, RecoveryTSI);
10674 
10675  // Propagate both errors and recovered types, which return ExprEmpty.
10676  if (!NewDRE.isUsable())
10677  return NewDRE;
10678 
10679  // We got an expr, wrap it up in parens.
10680  if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
10681  return PE;
10682  return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
10683  PE->getRParen());
10684 }
10685 
10686 template <typename Derived>
10689  return TransformDependentScopeDeclRefExpr(E, /*IsAddressOfOperand=*/false,
10690  nullptr);
10691 }
10692 
10693 template<typename Derived>
10694 ExprResult
10697  bool IsAddressOfOperand,
10698  TypeSourceInfo **RecoveryTSI) {
10699  assert(E->getQualifierLoc());
10700  NestedNameSpecifierLoc QualifierLoc
10701  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
10702  if (!QualifierLoc)
10703  return ExprError();
10704  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
10705 
10706  // TODO: If this is a conversion-function-id, verify that the
10707  // destination type name (if present) resolves the same way after
10708  // instantiation as it did in the local scope.
10709 
10710  DeclarationNameInfo NameInfo
10711  = getDerived().TransformDeclarationNameInfo(E->getNameInfo());
10712  if (!NameInfo.getName())
10713  return ExprError();
10714 
10715  if (!E->hasExplicitTemplateArgs()) {
10716  if (!getDerived().AlwaysRebuild() &&
10717  QualifierLoc == E->getQualifierLoc() &&
10718  // Note: it is sufficient to compare the Name component of NameInfo:
10719  // if name has not changed, DNLoc has not changed either.
10720  NameInfo.getName() == E->getDeclName())
10721  return E;
10722 
10723  return getDerived().RebuildDependentScopeDeclRefExpr(
10724  QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
10725  IsAddressOfOperand, RecoveryTSI);
10726  }
10727 
10728  TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
10729  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
10730  E->getNumTemplateArgs(),
10731  TransArgs))
10732  return ExprError();
10733 
10734  return getDerived().RebuildDependentScopeDeclRefExpr(
10735  QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
10736  RecoveryTSI);
10737 }
10738 
10739 template<typename Derived>
10740 ExprResult
10742  // CXXConstructExprs other than for list-initialization and
10743  // CXXTemporaryObjectExpr are always implicit, so when we have
10744  // a 1-argument construction we just transform that argument.
10745  if ((E->getNumArgs() == 1 ||
10746  (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
10747  (!getDerived().DropCallArgument(E->getArg(0))) &&
10748  !E->isListInitialization())
10749  return getDerived().TransformExpr(E->getArg(0));
10750 
10751  TemporaryBase Rebase(*this, /*FIXME*/E->getLocStart(), DeclarationName());
10752 
10753  QualType T = getDerived().TransformType(E->getType());
10754  if (T.isNull())
10755  return ExprError();
10756 
10757  CXXConstructorDecl *Constructor
10758  = cast_or_null<CXXConstructorDecl>(
10759  getDerived().TransformDecl(E->getLocStart(),
10760  E->getConstructor()));
10761  if (!Constructor)
10762  return ExprError();
10763 
10764  bool ArgumentChanged = false;
10765  SmallVector<Expr*, 8> Args;
10766  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
10767  &ArgumentChanged))
10768  return ExprError();
10769 
10770  if (!getDerived().AlwaysRebuild() &&
10771  T == E->getType() &&
10772  Constructor == E->getConstructor() &&
10773  !ArgumentChanged) {
10774  // Mark the constructor as referenced.
10775  // FIXME: Instantiation-specific
10776  SemaRef.MarkFunctionReferenced(E->getLocStart(), Constructor);
10777  return E;
10778  }
10779 
10780  return getDerived().RebuildCXXConstructExpr(T, /*FIXME:*/E->getLocStart(),
10781  Constructor,
10782  E->isElidable(), Args,
10783  E->hadMultipleCandidates(),
10784  E->isListInitialization(),
10787  E->getConstructionKind(),
10788  E->getParenOrBraceRange());
10789 }
10790 
10791 template<typename Derived>
10794  QualType T = getDerived().TransformType(E->getType());
10795  if (T.isNull())
10796  return ExprError();
10797 
10798  CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
10799  getDerived().TransformDecl(E->getLocStart(), E->getConstructor()));
10800  if (!Constructor)
10801  return ExprError();
10802 
10803  if (!getDerived().AlwaysRebuild() &&
10804  T == E->getType() &&
10805  Constructor == E->getConstructor()) {
10806  // Mark the constructor as referenced.
10807  // FIXME: Instantiation-specific
10808  SemaRef.MarkFunctionReferenced(E->getLocStart(), Constructor);
10809  return E;
10810  }
10811 
10812  return getDerived().RebuildCXXInheritedCtorInitExpr(
10813  T, E->getLocation(), Constructor,
10814  E->constructsVBase(), E->inheritedFromVBase());
10815 }
10816 
10817 /// \brief Transform a C++ temporary-binding expression.
10818 ///
10819 /// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
10820 /// transform the subexpression and return that.
10821 template<typename Derived>
10822 ExprResult
10824  return getDerived().TransformExpr(E->getSubExpr());
10825 }
10826 
10827 /// \brief Transform a C++ expression that contains cleanups that should
10828 /// be run after the expression is evaluated.
10829 ///
10830 /// Since ExprWithCleanups nodes are implicitly generated, we
10831 /// just transform the subexpression and return that.
10832 template<typename Derived>
10833 ExprResult
10835  return getDerived().TransformExpr(E->getSubExpr());
10836 }
10837 
10838 template<typename Derived>
10839 ExprResult
10842  TypeSourceInfo *T =
10843  getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
10844  if (!T)
10845  return ExprError();
10846 
10847  CXXConstructorDecl *Constructor
10848  = cast_or_null<CXXConstructorDecl>(
10849  getDerived().TransformDecl(E->getLocStart(),
10850  E->getConstructor()));
10851  if (!Constructor)
10852  return ExprError();
10853 
10854  bool ArgumentChanged = false;
10855  SmallVector<Expr*, 8> Args;
10856  Args.reserve(E->getNumArgs());
10857  if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
10858  &ArgumentChanged))
10859  return ExprError();
10860 
10861  if (!getDerived().AlwaysRebuild() &&
10862  T == E->getTypeSourceInfo() &&
10863  Constructor == E->getConstructor() &&
10864  !ArgumentChanged) {
10865  // FIXME: Instantiation-specific
10866  SemaRef.MarkFunctionReferenced(E->getLocStart(), Constructor);
10867  return SemaRef.MaybeBindToTemporary(E);
10868  }
10869 
10870  // FIXME: Pass in E->isListInitialization().
10871  return getDerived().RebuildCXXTemporaryObjectExpr(T,
10872  /*FIXME:*/T->getTypeLoc().getEndLoc(),
10873  Args,
10874  E->getLocEnd());
10875 }
10876 
10877 template<typename Derived>
10878 ExprResult
10880  // Transform any init-capture expressions before entering the scope of the
10881  // lambda body, because they are not semantically within that scope.
10882  typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
10883  SmallVector<InitCaptureInfoTy, 8> InitCaptureExprsAndTypes;
10884  InitCaptureExprsAndTypes.resize(E->explicit_capture_end() -
10885  E->explicit_capture_begin());
10887  CEnd = E->capture_end();
10888  C != CEnd; ++C) {
10889  if (!E->isInitCapture(C))
10890  continue;
10893  ExprResult NewExprInitResult = getDerived().TransformInitializer(
10894  C->getCapturedVar()->getInit(),
10895  C->getCapturedVar()->getInitStyle() == VarDecl::CallInit);
10896 
10897  if (NewExprInitResult.isInvalid())
10898  return ExprError();
10899  Expr *NewExprInit = NewExprInitResult.get();
10900 
10901  VarDecl *OldVD = C->getCapturedVar();
10902  QualType NewInitCaptureType =
10903  getSema().buildLambdaInitCaptureInitialization(
10904  C->getLocation(), OldVD->getType()->isReferenceType(),
10905  OldVD->getIdentifier(),
10906  C->getCapturedVar()->getInitStyle() != VarDecl::CInit, NewExprInit);
10907  NewExprInitResult = NewExprInit;
10908  InitCaptureExprsAndTypes[C - E->capture_begin()] =
10909  std::make_pair(NewExprInitResult, NewInitCaptureType);
10910  }
10911 
10912  // Transform the template parameters, and add them to the current
10913  // instantiation scope. The null case is handled correctly.
10914  auto TPL = getDerived().TransformTemplateParameterList(
10916 
10917  // Transform the type of the original lambda's call operator.
10918  // The transformation MUST be done in the CurrentInstantiationScope since
10919  // it introduces a mapping of the original to the newly created
10920  // transformed parameters.
10921  TypeSourceInfo *NewCallOpTSI = nullptr;
10922  {
10923  TypeSourceInfo *OldCallOpTSI = E->getCallOperator()->getTypeSourceInfo();
10924  FunctionProtoTypeLoc OldCallOpFPTL =
10925  OldCallOpTSI->getTypeLoc().getAs<FunctionProtoTypeLoc>();
10926 
10927  TypeLocBuilder NewCallOpTLBuilder;
10928  SmallVector<QualType, 4> ExceptionStorage;
10929  TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
10930  QualType NewCallOpType = TransformFunctionProtoType(
10931  NewCallOpTLBuilder, OldCallOpFPTL, nullptr, 0,
10932  [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
10933  return This->TransformExceptionSpec(OldCallOpFPTL.getBeginLoc(), ESI,
10934  ExceptionStorage, Changed);
10935  });
10936  if (NewCallOpType.isNull())
10937  return ExprError();
10938  NewCallOpTSI = NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context,
10939  NewCallOpType);
10940  }
10941 
10942  LambdaScopeInfo *LSI = getSema().PushLambdaScope();
10943  Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
10944  LSI->GLTemplateParameterList = TPL;
10945 
10946  // Create the local class that will describe the lambda.
10947  CXXRecordDecl *Class
10948  = getSema().createLambdaClosureType(E->getIntroducerRange(),
10949  NewCallOpTSI,
10950  /*KnownDependent=*/false,
10951  E->getCaptureDefault());
10952  getDerived().transformedLocalDecl(E->getLambdaClass(), Class);
10953 
10954  // Build the call operator.
10955  CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition(
10956  Class, E->getIntroducerRange(), NewCallOpTSI,
10957  E->getCallOperator()->getLocEnd(),
10958  NewCallOpTSI->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams(),
10959  E->getCallOperator()->isConstexpr());
10960 
10961  LSI->CallOperator = NewCallOperator;
10962 
10963  for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
10964  I != NumParams; ++I) {
10965  auto *P = NewCallOperator->getParamDecl(I);
10966  if (P->hasUninstantiatedDefaultArg()) {
10968  getSema(),
10970  ExprResult R = getDerived().TransformExpr(
10972  P->setDefaultArg(R.get());
10973  }
10974  }
10975 
10976  getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
10977  getDerived().transformedLocalDecl(E->getCallOperator(), NewCallOperator);
10978 
10979  // Introduce the context of the call operator.
10980  Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
10981  /*NewThisContext*/false);
10982 
10983  // Enter the scope of the lambda.
10984  getSema().buildLambdaScope(LSI, NewCallOperator,
10985  E->getIntroducerRange(),
10986  E->getCaptureDefault(),
10987  E->getCaptureDefaultLoc(),
10988  E->hasExplicitParameters(),
10989  E->hasExplicitResultType(),
10990  E->isMutable());
10991 
10992  bool Invalid = false;
10993 
10994  // Transform captures.
10995  bool FinishedExplicitCaptures = false;
10997  CEnd = E->capture_end();
10998  C != CEnd; ++C) {
10999  // When we hit the first implicit capture, tell Sema that we've finished
11000  // the list of explicit captures.
11001  if (!FinishedExplicitCaptures && C->isImplicit()) {
11002  getSema().finishLambdaExplicitCaptures(LSI);
11003  FinishedExplicitCaptures = true;
11004  }
11005 
11006  // Capturing 'this' is trivial.
11007  if (C->capturesThis()) {
11008  getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
11009  /*BuildAndDiagnose*/ true, nullptr,
11010  C->getCaptureKind() == LCK_StarThis);
11011  continue;
11012  }
11013  // Captured expression will be recaptured during captured variables
11014  // rebuilding.
11015  if (C->capturesVLAType())
11016  continue;
11017 
11018  // Rebuild init-captures, including the implied field declaration.
11019  if (E->isInitCapture(C)) {
11020  InitCaptureInfoTy InitExprTypePair =
11021  InitCaptureExprsAndTypes[C - E->capture_begin()];
11022  ExprResult Init = InitExprTypePair.first;
11023  QualType InitQualType = InitExprTypePair.second;
11024  if (Init.isInvalid() || InitQualType.isNull()) {
11025  Invalid = true;
11026  continue;
11027  }
11028  VarDecl *OldVD = C->getCapturedVar();
11029  VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
11030  OldVD->getLocation(), InitExprTypePair.second, OldVD->getIdentifier(),
11031  OldVD->getInitStyle(), Init.get());
11032  if (!NewVD)
11033  Invalid = true;
11034  else {
11035  getDerived().transformedLocalDecl(OldVD, NewVD);
11036  }
11037  getSema().buildInitCaptureField(LSI, NewVD);
11038  continue;
11039  }
11040 
11041  assert(C->capturesVariable() && "unexpected kind of lambda capture");
11042 
11043  // Determine the capture kind for Sema.
11045  = C->isImplicit()? Sema::TryCapture_Implicit
11046  : C->getCaptureKind() == LCK_ByCopy
11049  SourceLocation EllipsisLoc;
11050  if (C->isPackExpansion()) {
11051  UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
11052  bool ShouldExpand = false;
11053  bool RetainExpansion = false;
11054  Optional<unsigned> NumExpansions;
11055  if (getDerived().TryExpandParameterPacks(C->getEllipsisLoc(),
11056  C->getLocation(),
11057  Unexpanded,
11058  ShouldExpand, RetainExpansion,
11059  NumExpansions)) {
11060  Invalid = true;
11061  continue;
11062  }
11063 
11064  if (ShouldExpand) {
11065  // The transform has determined that we should perform an expansion;
11066  // transform and capture each of the arguments.
11067  // expansion of the pattern. Do so.
11068  VarDecl *Pack = C->getCapturedVar();
11069  for (unsigned I = 0; I != *NumExpansions; ++I) {
11070  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
11071  VarDecl *CapturedVar
11072  = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(),
11073  Pack));
11074  if (!CapturedVar) {
11075  Invalid = true;
11076  continue;
11077  }
11078 
11079  // Capture the transformed variable.
11080  getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
11081  }
11082 
11083  // FIXME: Retain a pack expansion if RetainExpansion is true.
11084 
11085  continue;
11086  }
11087 
11088  EllipsisLoc = C->getEllipsisLoc();
11089  }
11090 
11091  // Transform the captured variable.
11092  VarDecl *CapturedVar
11093  = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(),
11094  C->getCapturedVar()));
11095  if (!CapturedVar || CapturedVar->isInvalidDecl()) {
11096  Invalid = true;
11097  continue;
11098  }
11099 
11100  // Capture the transformed variable.
11101  getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
11102  EllipsisLoc);
11103  }
11104  if (!FinishedExplicitCaptures)
11105  getSema().finishLambdaExplicitCaptures(LSI);
11106 
11107  // Enter a new evaluation context to insulate the lambda from any
11108  // cleanups from the enclosing full-expression.
11109  getSema().PushExpressionEvaluationContext(
11111 
11112  // Instantiate the body of the lambda expression.
11113  StmtResult Body =
11114  Invalid ? StmtError() : getDerived().TransformStmt(E->getBody());
11115 
11116  // ActOnLambda* will pop the function scope for us.
11117  FuncScopeCleanup.disable();
11118 
11119  if (Body.isInvalid()) {
11120  SavedContext.pop();
11121  getSema().ActOnLambdaError(E->getLocStart(), /*CurScope=*/nullptr,
11122  /*IsInstantiation=*/true);
11123  return ExprError();
11124  }
11125 
11126  // Copy the LSI before ActOnFinishFunctionBody removes it.
11127  // FIXME: This is dumb. Store the lambda information somewhere that outlives
11128  // the call operator.
11129  auto LSICopy = *LSI;
11130  getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
11131  /*IsInstantiation*/ true);
11132  SavedContext.pop();
11133 
11134  return getSema().BuildLambdaExpr(E->getLocStart(), Body.get()->getLocEnd(),
11135  &LSICopy);
11136 }
11137 
11138 template<typename Derived>
11139 ExprResult
11142  TypeSourceInfo *T =
11143  getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
11144  if (!T)
11145  return ExprError();
11146 
11147  bool ArgumentChanged = false;
11148  SmallVector<Expr*, 8> Args;
11149  Args.reserve(E->arg_size());
11150  if (getDerived().TransformExprs(E->arg_begin(), E->arg_size(), true, Args,
11151  &ArgumentChanged))
11152  return ExprError();
11153 
11154  if (!getDerived().AlwaysRebuild() &&
11155  T == E->getTypeSourceInfo() &&
11156  !ArgumentChanged)
11157  return E;
11158 
11159  // FIXME: we're faking the locations of the commas
11160  return getDerived().RebuildCXXUnresolvedConstructExpr(T,
11161  E->getLParenLoc(),
11162  Args,
11163  E->getRParenLoc());
11164 }
11165 
11166 template<typename Derived>
11167 ExprResult
11170  // Transform the base of the expression.
11171  ExprResult Base((Expr*) nullptr);
11172  Expr *OldBase;
11173  QualType BaseType;
11174  QualType ObjectType;
11175  if (!E->isImplicitAccess()) {
11176  OldBase = E->getBase();
11177  Base = getDerived().TransformExpr(OldBase);
11178  if (Base.isInvalid())
11179  return ExprError();
11180 
11181  // Start the member reference and compute the object's type.
11182  ParsedType ObjectTy;
11183  bool MayBePseudoDestructor = false;
11184  Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
11185  E->getOperatorLoc(),
11186  E->isArrow()? tok::arrow : tok::period,
11187  ObjectTy,
11188  MayBePseudoDestructor);
11189  if (Base.isInvalid())
11190  return ExprError();
11191 
11192  ObjectType = ObjectTy.get();
11193  BaseType = ((Expr*) Base.get())->getType();
11194  } else {
11195  OldBase = nullptr;
11196  BaseType = getDerived().TransformType(E->getBaseType());
11197  ObjectType = BaseType->getAs<PointerType>()->getPointeeType();
11198  }
11199 
11200  // Transform the first part of the nested-name-specifier that qualifies
11201  // the member name.
11202  NamedDecl *FirstQualifierInScope
11203  = getDerived().TransformFirstQualifierInScope(
11205  E->getQualifierLoc().getBeginLoc());
11206 
11207  NestedNameSpecifierLoc QualifierLoc;
11208  if (E->getQualifier()) {
11209  QualifierLoc
11210  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
11211  ObjectType,
11212  FirstQualifierInScope);
11213  if (!QualifierLoc)
11214  return ExprError();
11215  }
11216 
11217  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
11218 
11219  // TODO: If this is a conversion-function-id, verify that the
11220  // destination type name (if present) resolves the same way after
11221  // instantiation as it did in the local scope.
11222 
11223  DeclarationNameInfo NameInfo
11224  = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
11225  if (!NameInfo.getName())
11226  return ExprError();
11227 
11228  if (!E->hasExplicitTemplateArgs()) {
11229  // This is a reference to a member without an explicitly-specified
11230  // template argument list. Optimize for this common case.
11231  if (!getDerived().AlwaysRebuild() &&
11232  Base.get() == OldBase &&
11233  BaseType == E->getBaseType() &&
11234  QualifierLoc == E->getQualifierLoc() &&
11235  NameInfo.getName() == E->getMember() &&
11236  FirstQualifierInScope == E->getFirstQualifierFoundInScope())
11237  return E;
11238 
11239  return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
11240  BaseType,
11241  E->isArrow(),
11242  E->getOperatorLoc(),
11243  QualifierLoc,
11244  TemplateKWLoc,
11245  FirstQualifierInScope,
11246  NameInfo,
11247  /*TemplateArgs*/nullptr);
11248  }
11249 
11250  TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
11251  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
11252  E->getNumTemplateArgs(),
11253  TransArgs))
11254  return ExprError();
11255 
11256  return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
11257  BaseType,
11258  E->isArrow(),
11259  E->getOperatorLoc(),
11260  QualifierLoc,
11261  TemplateKWLoc,
11262  FirstQualifierInScope,
11263  NameInfo,
11264  &TransArgs);
11265 }
11266 
11267 template<typename Derived>
11268 ExprResult
11270  // Transform the base of the expression.
11271  ExprResult Base((Expr*) nullptr);
11272  QualType BaseType;
11273  if (!Old->isImplicitAccess()) {
11274  Base = getDerived().TransformExpr(Old->getBase());
11275  if (Base.isInvalid())
11276  return ExprError();
11277  Base = getSema().PerformMemberExprBaseConversion(Base.get(),
11278  Old->isArrow());
11279  if (Base.isInvalid())
11280  return ExprError();
11281  BaseType = Base.get()->getType();
11282  } else {
11283  BaseType = getDerived().TransformType(Old->getBaseType());
11284  }
11285 
11286  NestedNameSpecifierLoc QualifierLoc;
11287  if (Old->getQualifierLoc()) {
11288  QualifierLoc
11289  = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
11290  if (!QualifierLoc)
11291  return ExprError();
11292  }
11293 
11294  SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
11295 
11296  LookupResult R(SemaRef, Old->getMemberNameInfo(),
11298 
11299  // Transform the declaration set.
11300  if (TransformOverloadExprDecls(Old, /*RequiresADL*/false, R))
11301  return ExprError();
11302 
11303  // Determine the naming class.
11304  if (Old->getNamingClass()) {
11305  CXXRecordDecl *NamingClass
11306  = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
11307  Old->getMemberLoc(),
11308  Old->getNamingClass()));
11309  if (!NamingClass)
11310  return ExprError();
11311 
11312  R.setNamingClass(NamingClass);
11313  }
11314 
11315  TemplateArgumentListInfo TransArgs;
11316  if (Old->hasExplicitTemplateArgs()) {
11317  TransArgs.setLAngleLoc(Old->getLAngleLoc());
11318  TransArgs.setRAngleLoc(Old->getRAngleLoc());
11319  if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
11320  Old->getNumTemplateArgs(),
11321  TransArgs))
11322  return ExprError();
11323  }
11324 
11325  // FIXME: to do this check properly, we will need to preserve the
11326  // first-qualifier-in-scope here, just in case we had a dependent
11327  // base (and therefore couldn't do the check) and a
11328  // nested-name-qualifier (and therefore could do the lookup).
11329  NamedDecl *FirstQualifierInScope = nullptr;
11330 
11331  return getDerived().RebuildUnresolvedMemberExpr(Base.get(),
11332  BaseType,
11333  Old->getOperatorLoc(),
11334  Old->isArrow(),
11335  QualifierLoc,
11336  TemplateKWLoc,
11337  FirstQualifierInScope,
11338  R,
11339  (Old->hasExplicitTemplateArgs()
11340  ? &TransArgs : nullptr));
11341 }
11342 
11343 template<typename Derived>
11344 ExprResult
11348  ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
11349  if (SubExpr.isInvalid())
11350  return ExprError();
11351 
11352  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
11353  return E;
11354 
11355  return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
11356 }
11357 
11358 template<typename Derived>
11359 ExprResult
11361  ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
11362  if (Pattern.isInvalid())
11363  return ExprError();
11364 
11365  if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
11366  return E;
11367 
11368  return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
11369  E->getNumExpansions());
11370 }
11371 
11372 template<typename Derived>
11373 ExprResult
11375  // If E is not value-dependent, then nothing will change when we transform it.
11376  // Note: This is an instantiation-centric view.
11377  if (!E->isValueDependent())
11378  return E;
11379 
11382 
11383  ArrayRef<TemplateArgument> PackArgs;
11384  TemplateArgument ArgStorage;
11385 
11386  // Find the argument list to transform.
11387  if (E->isPartiallySubstituted()) {
11388  PackArgs = E->getPartialArguments();
11389  } else if (E->isValueDependent()) {
11390  UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
11391  bool ShouldExpand = false;
11392  bool RetainExpansion = false;
11393  Optional<unsigned> NumExpansions;
11394  if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(),
11395  Unexpanded,
11396  ShouldExpand, RetainExpansion,
11397  NumExpansions))
11398  return ExprError();
11399 
11400  // If we need to expand the pack, build a template argument from it and
11401  // expand that.
11402  if (ShouldExpand) {
11403  auto *Pack = E->getPack();
11404  if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
11405  ArgStorage = getSema().Context.getPackExpansionType(
11406  getSema().Context.getTypeDeclType(TTPD), None);
11407  } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
11408  ArgStorage = TemplateArgument(TemplateName(TTPD), None);
11409  } else {
11410  auto *VD = cast<ValueDecl>(Pack);
11411  ExprResult DRE = getSema().BuildDeclRefExpr(VD, VD->getType(),
11412  VK_RValue, E->getPackLoc());
11413  if (DRE.isInvalid())
11414  return ExprError();
11415  ArgStorage = new (getSema().Context) PackExpansionExpr(
11416  getSema().Context.DependentTy, DRE.get(), E->getPackLoc(), None);
11417  }
11418  PackArgs = ArgStorage;
11419  }
11420  }
11421 
11422  // If we're not expanding the pack, just transform the decl.
11423  if (!PackArgs.size()) {
11424  auto *Pack = cast_or_null<NamedDecl>(
11425  getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
11426  if (!Pack)
11427  return ExprError();
11428  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), Pack,
11429  E->getPackLoc(),
11430  E->getRParenLoc(), None, None);
11431  }
11432 
11433  // Try to compute the result without performing a partial substitution.
11434  Optional<unsigned> Result = 0;
11435  for (const TemplateArgument &Arg : PackArgs) {
11436  if (!Arg.isPackExpansion()) {
11437  Result = *Result + 1;
11438  continue;
11439  }
11440 
11441  TemplateArgumentLoc ArgLoc;
11442  InventTemplateArgumentLoc(Arg, ArgLoc);
11443 
11444  // Find the pattern of the pack expansion.
11445  SourceLocation Ellipsis;
11446  Optional<unsigned> OrigNumExpansions;
11447  TemplateArgumentLoc Pattern =
11448  getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
11449  OrigNumExpansions);
11450 
11451  // Substitute under the pack expansion. Do not expand the pack (yet).
11452  TemplateArgumentLoc OutPattern;
11453  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
11454  if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
11455  /*Uneval*/ true))
11456  return true;
11457 
11458  // See if we can determine the number of arguments from the result.
11459  Optional<unsigned> NumExpansions =
11460  getSema().getFullyPackExpandedSize(OutPattern.getArgument());
11461  if (!NumExpansions) {
11462  // No: we must be in an alias template expansion, and we're going to need
11463  // to actually expand the packs.
11464  Result = None;
11465  break;
11466  }
11467 
11468  Result = *Result + *NumExpansions;
11469  }
11470 
11471  // Common case: we could determine the number of expansions without
11472  // substituting.
11473  if (Result)
11474  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
11475  E->getPackLoc(),
11476  E->getRParenLoc(), *Result, None);
11477 
11478  TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
11479  E->getPackLoc());
11480  {
11481  TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
11483  Derived, const TemplateArgument*> PackLocIterator;
11484  if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
11485  PackLocIterator(*this, PackArgs.end()),
11486  TransformedPackArgs, /*Uneval*/true))
11487  return ExprError();
11488  }
11489 
11490  // Check whether we managed to fully-expand the pack.
11491  // FIXME: Is it possible for us to do so and not hit the early exit path?
11493  bool PartialSubstitution = false;
11494  for (auto &Loc : TransformedPackArgs.arguments()) {
11495  Args.push_back(Loc.getArgument());
11496  if (Loc.getArgument().isPackExpansion())
11497  PartialSubstitution = true;
11498  }
11499 
11500  if (PartialSubstitution)
11501  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
11502  E->getPackLoc(),
11503  E->getRParenLoc(), None, Args);
11504 
11505  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
11506  E->getPackLoc(), E->getRParenLoc(),
11507  Args.size(), None);
11508 }
11509 
11510 template<typename Derived>
11511 ExprResult
11514  // Default behavior is to do nothing with this transformation.
11515  return E;
11516 }
11517 
11518 template<typename Derived>
11519 ExprResult
11522  // Default behavior is to do nothing with this transformation.
11523  return E;
11524 }
11525 
11526 template<typename Derived>
11527 ExprResult
11529  // Default behavior is to do nothing with this transformation.
11530  return E;
11531 }
11532 
11533 template<typename Derived>
11534 ExprResult
11537  return getDerived().TransformExpr(E->GetTemporaryExpr());
11538 }
11539 
11540 template<typename Derived>
11541 ExprResult
11543  Expr *Pattern = E->getPattern();
11544 
11546  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
11547  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
11548 
11549  // Determine whether the set of unexpanded parameter packs can and should
11550  // be expanded.
11551  bool Expand = true;
11552  bool RetainExpansion = false;
11553  Optional<unsigned> NumExpansions;
11554  if (getDerived().TryExpandParameterPacks(E->getEllipsisLoc(),
11555  Pattern->getSourceRange(),
11556  Unexpanded,
11557  Expand, RetainExpansion,
11558  NumExpansions))
11559  return true;
11560 
11561  if (!Expand) {
11562  // Do not expand any packs here, just transform and rebuild a fold
11563  // expression.
11564  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
11565 
11566  ExprResult LHS =
11567  E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
11568  if (LHS.isInvalid())
11569  return true;
11570 
11571  ExprResult RHS =
11572  E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
11573  if (RHS.isInvalid())
11574  return true;
11575 
11576  if (!getDerived().AlwaysRebuild() &&
11577  LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
11578  return E;
11579 
11580  return getDerived().RebuildCXXFoldExpr(
11581  E->getLocStart(), LHS.get(), E->getOperator(), E->getEllipsisLoc(),
11582  RHS.get(), E->getLocEnd());
11583  }
11584 
11585  // The transform has determined that we should perform an elementwise
11586  // expansion of the pattern. Do so.
11587  ExprResult Result = getDerived().TransformExpr(E->getInit());
11588  if (Result.isInvalid())
11589  return true;
11590  bool LeftFold = E->isLeftFold();
11591 
11592  // If we're retaining an expansion for a right fold, it is the innermost
11593  // component and takes the init (if any).
11594  if (!LeftFold && RetainExpansion) {
11595  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
11596 
11597  ExprResult Out = getDerived().TransformExpr(Pattern);
11598  if (Out.isInvalid())
11599  return true;
11600 
11601  Result = getDerived().RebuildCXXFoldExpr(
11602  E->getLocStart(), Out.get(), E->getOperator(), E->getEllipsisLoc(),
11603  Result.get(), E->getLocEnd());
11604  if (Result.isInvalid())
11605  return true;
11606  }
11607 
11608  for (unsigned I = 0; I != *NumExpansions; ++I) {
11610  getSema(), LeftFold ? I : *NumExpansions - I - 1);
11611  ExprResult Out = getDerived().TransformExpr(Pattern);
11612  if (Out.isInvalid())
11613  return true;
11614 
11615  if (Out.get()->containsUnexpandedParameterPack()) {
11616  // We still have a pack; retain a pack expansion for this slice.
11617  Result = getDerived().RebuildCXXFoldExpr(
11618  E->getLocStart(),
11619  LeftFold ? Result.get() : Out.get(),
11620  E->getOperator(), E->getEllipsisLoc(),
11621  LeftFold ? Out.get() : Result.get(),
11622  E->getLocEnd());
11623  } else if (Result.isUsable()) {
11624  // We've got down to a single element; build a binary operator.
11625  Result = getDerived().RebuildBinaryOperator(
11626  E->getEllipsisLoc(), E->getOperator(),
11627  LeftFold ? Result.get() : Out.get(),
11628  LeftFold ? Out.get() : Result.get());
11629  } else
11630  Result = Out;
11631 
11632  if (Result.isInvalid())
11633  return true;
11634  }
11635 
11636  // If we're retaining an expansion for a left fold, it is the outermost
11637  // component and takes the complete expansion so far as its init (if any).
11638  if (LeftFold && RetainExpansion) {
11639  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
11640 
11641  ExprResult Out = getDerived().TransformExpr(Pattern);
11642  if (Out.isInvalid())
11643  return true;
11644 
11645  Result = getDerived().RebuildCXXFoldExpr(
11646  E->getLocStart(), Result.get(),
11647  E->getOperator(), E->getEllipsisLoc(),
11648  Out.get(), E->getLocEnd());
11649  if (Result.isInvalid())
11650  return true;
11651  }
11652 
11653  // If we had no init and an empty pack, and we're not retaining an expansion,
11654  // then produce a fallback value or error.
11655  if (Result.isUnset())
11656  return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
11657  E->getOperator());
11658 
11659  return Result;
11660 }
11661 
11662 template<typename Derived>
11663 ExprResult
11666  return getDerived().TransformExpr(E->getSubExpr());
11667 }
11668 
11669 template<typename Derived>
11670 ExprResult
11672  return SemaRef.MaybeBindToTemporary(E);
11673 }
11674 
11675 template<typename Derived>
11676 ExprResult
11678  return E;
11679 }
11680 
11681 template<typename Derived>
11682 ExprResult
11684  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
11685  if (SubExpr.isInvalid())
11686  return ExprError();
11687 
11688  if (!getDerived().AlwaysRebuild() &&
11689  SubExpr.get() == E->getSubExpr())
11690  return E;
11691 
11692  return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
11693 }
11694 
11695 template<typename Derived>
11696 ExprResult
11698  // Transform each of the elements.
11699  SmallVector<Expr *, 8> Elements;
11700  bool ArgChanged = false;
11701  if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
11702  /*IsCall=*/false, Elements, &ArgChanged))
11703  return ExprError();
11704 
11705  if (!getDerived().AlwaysRebuild() && !ArgChanged)
11706  return SemaRef.MaybeBindToTemporary(E);
11707 
11708  return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
11709  Elements.data(),
11710  Elements.size());
11711 }
11712 
11713 template<typename Derived>
11714 ExprResult
11716  ObjCDictionaryLiteral *E) {
11717  // Transform each of the elements.
11719  bool ArgChanged = false;
11720  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
11721  ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
11722 
11723  if (OrigElement.isPackExpansion()) {
11724  // This key/value element is a pack expansion.
11726  getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
11727  getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
11728  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
11729 
11730  // Determine whether the set of unexpanded parameter packs can
11731  // and should be expanded.
11732  bool Expand = true;
11733  bool RetainExpansion = false;
11734  Optional<unsigned> OrigNumExpansions = OrigElement.NumExpansions;
11735  Optional<unsigned> NumExpansions = OrigNumExpansions;
11736  SourceRange PatternRange(OrigElement.Key->getLocStart(),
11737  OrigElement.Value->getLocEnd());
11738  if (getDerived().TryExpandParameterPacks(OrigElement.EllipsisLoc,
11739  PatternRange,
11740  Unexpanded,
11741  Expand, RetainExpansion,
11742  NumExpansions))
11743  return ExprError();
11744 
11745  if (!Expand) {
11746  // The transform has determined that we should perform a simple
11747  // transformation on the pack expansion, producing another pack
11748  // expansion.
11749  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
11750  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
11751  if (Key.isInvalid())
11752  return ExprError();
11753 
11754  if (Key.get() != OrigElement.Key)
11755  ArgChanged = true;
11756 
11757  ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
11758  if (Value.isInvalid())
11759  return ExprError();
11760 
11761  if (Value.get() != OrigElement.Value)
11762  ArgChanged = true;
11763 
11764  ObjCDictionaryElement Expansion = {
11765  Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
11766  };
11767  Elements.push_back(Expansion);
11768  continue;
11769  }
11770 
11771  // Record right away that the argument was changed. This needs
11772  // to happen even if the array expands to nothing.
11773  ArgChanged = true;
11774 
11775  // The transform has determined that we should perform an elementwise
11776  // expansion of the pattern. Do so.
11777  for (unsigned I = 0; I != *NumExpansions; ++I) {
11778  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
11779  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
11780  if (Key.isInvalid())
11781  return ExprError();
11782 
11783  ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
11784  if (Value.isInvalid())
11785  return ExprError();
11786 
11787  ObjCDictionaryElement Element = {
11788  Key.get(), Value.get(), SourceLocation(), NumExpansions
11789  };
11790 
11791  // If any unexpanded parameter packs remain, we still have a
11792  // pack expansion.
11793  // FIXME: Can this really happen?
11794  if (Key.get()->containsUnexpandedParameterPack() ||
11795  Value.get()->containsUnexpandedParameterPack())
11796  Element.EllipsisLoc = OrigElement.EllipsisLoc;
11797 
11798  Elements.push_back(Element);
11799  }
11800 
11801  // FIXME: Retain a pack expansion if RetainExpansion is true.
11802 
11803  // We've finished with this pack expansion.
11804  continue;
11805  }
11806 
11807  // Transform and check key.
11808  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
11809  if (Key.isInvalid())
11810  return ExprError();
11811 
11812  if (Key.get() != OrigElement.Key)
11813  ArgChanged = true;
11814 
11815  // Transform and check value.
11817  = getDerived().TransformExpr(OrigElement.Value);
11818  if (Value.isInvalid())
11819  return ExprError();
11820 
11821  if (Value.get() != OrigElement.Value)
11822  ArgChanged = true;
11823 
11824  ObjCDictionaryElement Element = {
11825  Key.get(), Value.get(), SourceLocation(), None
11826  };
11827  Elements.push_back(Element);
11828  }
11829 
11830  if (!getDerived().AlwaysRebuild() && !ArgChanged)
11831  return SemaRef.MaybeBindToTemporary(E);
11832 
11833  return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
11834  Elements);
11835 }
11836 
11837 template<typename Derived>
11838 ExprResult
11840  TypeSourceInfo *EncodedTypeInfo
11841  = getDerived().TransformType(E->getEncodedTypeSourceInfo());
11842  if (!EncodedTypeInfo)
11843  return ExprError();
11844 
11845  if (!getDerived().AlwaysRebuild() &&
11846  EncodedTypeInfo == E->getEncodedTypeSourceInfo())
11847  return E;
11848 
11849  return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
11850  EncodedTypeInfo,
11851  E->getRParenLoc());
11852 }
11853 
11854 template<typename Derived>
11857  // This is a kind of implicit conversion, and it needs to get dropped
11858  // and recomputed for the same general reasons that ImplicitCastExprs
11859  // do, as well a more specific one: this expression is only valid when
11860  // it appears *immediately* as an argument expression.
11861  return getDerived().TransformExpr(E->getSubExpr());
11862 }
11863 
11864 template<typename Derived>
11867  TypeSourceInfo *TSInfo
11868  = getDerived().TransformType(E->getTypeInfoAsWritten());
11869  if (!TSInfo)
11870  return ExprError();
11871 
11872  ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
11873  if (Result.isInvalid())
11874  return ExprError();
11875 
11876  if (!getDerived().AlwaysRebuild() &&
11877  TSInfo == E->getTypeInfoAsWritten() &&
11878  Result.get() == E->getSubExpr())
11879  return E;
11880 
11881  return SemaRef.BuildObjCBridgedCast(E->getLParenLoc(), E->getBridgeKind(),
11882  E->getBridgeKeywordLoc(), TSInfo,
11883  Result.get());
11884 }
11885 
11886 template <typename Derived>
11889  return E;
11890 }
11891 
11892 template<typename Derived>
11893 ExprResult
11895  // Transform arguments.
11896  bool ArgChanged = false;
11897  SmallVector<Expr*, 8> Args;
11898  Args.reserve(E->getNumArgs());
11899  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
11900  &ArgChanged))
11901  return ExprError();
11902 
11904  // Class message: transform the receiver type.
11905  TypeSourceInfo *ReceiverTypeInfo
11906  = getDerived().TransformType(E->getClassReceiverTypeInfo());
11907  if (!ReceiverTypeInfo)
11908  return ExprError();
11909 
11910  // If nothing changed, just retain the existing message send.
11911  if (!getDerived().AlwaysRebuild() &&
11912  ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
11913  return SemaRef.MaybeBindToTemporary(E);
11914 
11915  // Build a new class message send.
11917  E->getSelectorLocs(SelLocs);
11918  return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
11919  E->getSelector(),
11920  SelLocs,
11921  E->getMethodDecl(),
11922  E->getLeftLoc(),
11923  Args,
11924  E->getRightLoc());
11925  }
11926  else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
11928  if (!E->getMethodDecl())
11929  return ExprError();
11930 
11931  // Build a new class message send to 'super'.
11933  E->getSelectorLocs(SelLocs);
11934  return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
11935  E->getSelector(),
11936  SelLocs,
11937  E->getReceiverType(),
11938  E->getMethodDecl(),
11939  E->getLeftLoc(),
11940  Args,
11941  E->getRightLoc());
11942  }
11943 
11944  // Instance message: transform the receiver
11945  assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
11946  "Only class and instance messages may be instantiated");
11947  ExprResult Receiver
11948  = getDerived().TransformExpr(E->getInstanceReceiver());
11949  if (Receiver.isInvalid())
11950  return ExprError();
11951 
11952  // If nothing changed, just retain the existing message send.
11953  if (!getDerived().AlwaysRebuild() &&
11954  Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
11955  return SemaRef.MaybeBindToTemporary(E);
11956 
11957  // Build a new instance message send.
11959  E->getSelectorLocs(SelLocs);
11960  return getDerived().RebuildObjCMessageExpr(Receiver.get(),
11961  E->getSelector(),
11962  SelLocs,
11963  E->getMethodDecl(),
11964  E->getLeftLoc(),
11965  Args,
11966  E->getRightLoc());
11967 }
11968 
11969 template<typename Derived>
11970 ExprResult
11972  return E;
11973 }
11974 
11975 template<typename Derived>
11976 ExprResult
11978  return E;
11979 }
11980 
11981 template<typename Derived>
11982 ExprResult
11984  // Transform the base expression.
11985  ExprResult Base = getDerived().TransformExpr(E->getBase());
11986  if (Base.isInvalid())
11987  return ExprError();
11988 
11989  // We don't need to transform the ivar; it will never change.
11990 
11991  // If nothing changed, just retain the existing expression.
11992  if (!getDerived().AlwaysRebuild() &&
11993  Base.get() == E->getBase())
11994  return E;
11995 
11996  return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
11997  E->getLocation(),
11998  E->isArrow(), E->isFreeIvar());
11999 }
12000 
12001 template<typename Derived>
12002 ExprResult
12004  // 'super' and types never change. Property never changes. Just
12005  // retain the existing expression.
12006  if (!E->isObjectReceiver())
12007  return E;
12008 
12009  // Transform the base expression.
12010  ExprResult Base = getDerived().TransformExpr(E->getBase());
12011  if (Base.isInvalid())
12012  return ExprError();
12013 
12014  // We don't need to transform the property; it will never change.
12015 
12016  // If nothing changed, just retain the existing expression.
12017  if (!getDerived().AlwaysRebuild() &&
12018  Base.get() == E->getBase())
12019  return E;
12020 
12021  if (E->isExplicitProperty())
12022  return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
12023  E->getExplicitProperty(),
12024  E->getLocation());
12025 
12026  return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
12027  SemaRef.Context.PseudoObjectTy,
12030  E->getLocation());
12031 }
12032 
12033 template<typename Derived>
12034 ExprResult
12036  // Transform the base expression.
12037  ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
12038  if (Base.isInvalid())
12039  return ExprError();
12040 
12041  // Transform the key expression.
12042  ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
12043  if (Key.isInvalid())
12044  return ExprError();
12045 
12046  // If nothing changed, just retain the existing expression.
12047  if (!getDerived().AlwaysRebuild() &&
12048  Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
12049  return E;
12050 
12051  return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
12052  Base.get(), Key.get(),
12053  E->getAtIndexMethodDecl(),
12054  E->setAtIndexMethodDecl());
12055 }
12056 
12057 template<typename Derived>
12058 ExprResult
12060  // Transform the base expression.
12061  ExprResult Base = getDerived().TransformExpr(E->getBase());
12062  if (Base.isInvalid())
12063  return ExprError();
12064 
12065  // If nothing changed, just retain the existing expression.
12066  if (!getDerived().AlwaysRebuild() &&
12067  Base.get() == E->getBase())
12068  return E;
12069 
12070  return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
12071  E->getOpLoc(),
12072  E->isArrow());
12073 }
12074 
12075 template<typename Derived>
12076 ExprResult
12078  bool ArgumentChanged = false;
12079  SmallVector<Expr*, 8> SubExprs;
12080  SubExprs.reserve(E->getNumSubExprs());
12081  if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
12082  SubExprs, &ArgumentChanged))
12083  return ExprError();
12084 
12085  if (!getDerived().AlwaysRebuild() &&
12086  !ArgumentChanged)
12087  return E;
12088 
12089  return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
12090  SubExprs,
12091  E->getRParenLoc());
12092 }
12093 
12094 template<typename Derived>
12095 ExprResult
12097  ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
12098  if (SrcExpr.isInvalid())
12099  return ExprError();
12100 
12101  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
12102  if (!Type)
12103  return ExprError();
12104 
12105  if (!getDerived().AlwaysRebuild() &&
12106  Type == E->getTypeSourceInfo() &&
12107  SrcExpr.get() == E->getSrcExpr())
12108  return E;
12109 
12110  return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
12111  SrcExpr.get(), Type,
12112  E->getRParenLoc());
12113 }
12114 
12115 template<typename Derived>
12116 ExprResult
12118  BlockDecl *oldBlock = E->getBlockDecl();
12119 
12120  SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
12121  BlockScopeInfo *blockScope = SemaRef.getCurBlock();
12122 
12123  blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
12124  blockScope->TheDecl->setBlockMissingReturnType(
12125  oldBlock->blockMissingReturnType());
12126 
12128  SmallVector<QualType, 4> paramTypes;
12129 
12130  const FunctionProtoType *exprFunctionType = E->getFunctionType();
12131 
12132  // Parameter substitution.
12133  Sema::ExtParameterInfoBuilder extParamInfos;
12134  if (getDerived().TransformFunctionTypeParams(
12135  E->getCaretLocation(), oldBlock->parameters(), nullptr,
12136  exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
12137  extParamInfos)) {
12138  getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
12139  return ExprError();
12140  }
12141 
12142  QualType exprResultType =
12143  getDerived().TransformType(exprFunctionType->getReturnType());
12144 
12145  auto epi = exprFunctionType->getExtProtoInfo();
12146  epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
12147 
12149  getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
12150  blockScope->FunctionType = functionType;
12151 
12152  // Set the parameters on the block decl.
12153  if (!params.empty())
12154  blockScope->TheDecl->setParams(params);
12155 
12156  if (!oldBlock->blockMissingReturnType()) {
12157  blockScope->HasImplicitReturnType = false;
12158  blockScope->ReturnType = exprResultType;
12159  }
12160 
12161  // Transform the body
12162  StmtResult body = getDerived().TransformStmt(E->getBody());
12163  if (body.isInvalid()) {
12164  getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
12165  return ExprError();
12166  }
12167 
12168 #ifndef NDEBUG
12169  // In builds with assertions, make sure that we captured everything we
12170  // captured before.
12171  if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
12172  for (const auto &I : oldBlock->captures()) {
12173  VarDecl *oldCapture = I.getVariable();
12174 
12175  // Ignore parameter packs.
12176  if (isa<ParmVarDecl>(oldCapture) &&
12177  cast<ParmVarDecl>(oldCapture)->isParameterPack())
12178  continue;
12179 
12180  VarDecl *newCapture =
12181  cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
12182  oldCapture));
12183  assert(blockScope->CaptureMap.count(newCapture));
12184  }
12185  assert(oldBlock->capturesCXXThis() == blockScope->isCXXThisCaptured());
12186  }
12187 #endif
12188 
12189  return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
12190  /*Scope=*/nullptr);
12191 }
12192 
12193 template<typename Derived>
12194 ExprResult
12196  llvm_unreachable("Cannot transform asType expressions yet");
12197 }
12198 
12199 template<typename Derived>
12200 ExprResult
12202  QualType RetTy = getDerived().TransformType(E->getType());
12203  bool ArgumentChanged = false;
12204  SmallVector<Expr*, 8> SubExprs;
12205  SubExprs.reserve(E->getNumSubExprs());
12206  if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
12207  SubExprs, &ArgumentChanged))
12208  return ExprError();
12209 
12210  if (!getDerived().AlwaysRebuild() &&
12211  !ArgumentChanged)
12212  return E;
12213 
12214  return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
12215  RetTy, E->getOp(), E->getRParenLoc());
12216 }
12217 
12218 //===----------------------------------------------------------------------===//
12219 // Type reconstruction
12220 //===----------------------------------------------------------------------===//
12221 
12222 template<typename Derived>
12224  SourceLocation Star) {
12225  return SemaRef.BuildPointerType(PointeeType, Star,
12226  getDerived().getBaseEntity());
12227 }
12228 
12229 template<typename Derived>
12231  SourceLocation Star) {
12232  return SemaRef.BuildBlockPointerType(PointeeType, Star,
12233  getDerived().getBaseEntity());
12234 }
12235 
12236 template<typename Derived>
12237 QualType
12239  bool WrittenAsLValue,
12240  SourceLocation Sigil) {
12241  return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
12242  Sigil, getDerived().getBaseEntity());
12243 }
12244 
12245 template<typename Derived>
12246 QualType
12248  QualType ClassType,
12249  SourceLocation Sigil) {
12250  return SemaRef.BuildMemberPointerType(PointeeType, ClassType, Sigil,
12251  getDerived().getBaseEntity());
12252 }
12253 
12254 template<typename Derived>
12256  const ObjCTypeParamDecl *Decl,
12257  SourceLocation ProtocolLAngleLoc,
12258  ArrayRef<ObjCProtocolDecl *> Protocols,
12259  ArrayRef<SourceLocation> ProtocolLocs,
12260  SourceLocation ProtocolRAngleLoc) {
12261  return SemaRef.BuildObjCTypeParamType(Decl,
12262  ProtocolLAngleLoc, Protocols,
12263  ProtocolLocs, ProtocolRAngleLoc,
12264  /*FailOnError=*/true);
12265 }
12266 
12267 template<typename Derived>
12269  QualType BaseType,
12270  SourceLocation Loc,
12271  SourceLocation TypeArgsLAngleLoc,
12272  ArrayRef<TypeSourceInfo *> TypeArgs,
12273  SourceLocation TypeArgsRAngleLoc,
12274  SourceLocation ProtocolLAngleLoc,
12275  ArrayRef<ObjCProtocolDecl *> Protocols,
12276  ArrayRef<SourceLocation> ProtocolLocs,
12277  SourceLocation ProtocolRAngleLoc) {
12278  return SemaRef.BuildObjCObjectType(BaseType, Loc, TypeArgsLAngleLoc,
12279  TypeArgs, TypeArgsRAngleLoc,
12280  ProtocolLAngleLoc, Protocols, ProtocolLocs,
12281  ProtocolRAngleLoc,
12282  /*FailOnError=*/true);
12283 }
12284 
12285 template<typename Derived>
12287  QualType PointeeType,
12288  SourceLocation Star) {
12289  return SemaRef.Context.getObjCObjectPointerType(PointeeType);
12290 }
12291 
12292 template<typename Derived>
12293 QualType
12296  const llvm::APInt *Size,
12297  Expr *SizeExpr,
12298  unsigned IndexTypeQuals,
12299  SourceRange BracketsRange) {
12300  if (SizeExpr || !Size)
12301  return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
12302  IndexTypeQuals, BracketsRange,
12303  getDerived().getBaseEntity());
12304 
12305  QualType Types[] = {
12306  SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
12307  SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
12308  SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
12309  };
12310  const unsigned NumTypes = llvm::array_lengthof(Types);
12311  QualType SizeType;
12312  for (unsigned I = 0; I != NumTypes; ++I)
12313  if (Size->getBitWidth() == SemaRef.Context.getIntWidth(Types[I])) {
12314  SizeType = Types[I];
12315  break;
12316  }
12317 
12318  // Note that we can return a VariableArrayType here in the case where
12319  // the element type was a dependent VariableArrayType.
12320  IntegerLiteral *ArraySize
12321  = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
12322  /*FIXME*/BracketsRange.getBegin());
12323  return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
12324  IndexTypeQuals, BracketsRange,
12325  getDerived().getBaseEntity());
12326 }
12327 
12328 template<typename Derived>
12329 QualType
12332  const llvm::APInt &Size,
12333  unsigned IndexTypeQuals,
12334  SourceRange BracketsRange) {
12335  return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, nullptr,
12336  IndexTypeQuals, BracketsRange);
12337 }
12338 
12339 template<typename Derived>
12340 QualType
12343  unsigned IndexTypeQuals,
12344  SourceRange BracketsRange) {
12345  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
12346  IndexTypeQuals, BracketsRange);
12347 }
12348 
12349 template<typename Derived>
12350 QualType
12353  Expr *SizeExpr,
12354  unsigned IndexTypeQuals,
12355  SourceRange BracketsRange) {
12356  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
12357  SizeExpr,
12358  IndexTypeQuals, BracketsRange);
12359 }
12360 
12361 template<typename Derived>
12362 QualType
12365  Expr *SizeExpr,
12366  unsigned IndexTypeQuals,
12367  SourceRange BracketsRange) {
12368  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
12369  SizeExpr,
12370  IndexTypeQuals, BracketsRange);
12371 }
12372 
12373 template <typename Derived>
12375  QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
12376  return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
12377  AttributeLoc);
12378 }
12379 
12380 template <typename Derived>
12381 QualType
12383  unsigned NumElements,
12384  VectorType::VectorKind VecKind) {
12385  // FIXME: semantic checking!
12386  return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
12387 }
12388 
12389 template<typename Derived>
12391  unsigned NumElements,
12392  SourceLocation AttributeLoc) {
12393  llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
12394  NumElements, true);
12395  IntegerLiteral *VectorSize
12396  = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
12397  AttributeLoc);
12398  return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
12399 }
12400 
12401 template<typename Derived>
12402 QualType
12404  Expr *SizeExpr,
12405  SourceLocation AttributeLoc) {
12406  return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
12407 }
12408 
12409 template<typename Derived>
12411  QualType T,
12412  MutableArrayRef<QualType> ParamTypes,
12413  const FunctionProtoType::ExtProtoInfo &EPI) {
12414  return SemaRef.BuildFunctionType(T, ParamTypes,
12415  getDerived().getBaseLocation(),
12416  getDerived().getBaseEntity(),
12417  EPI);
12418 }
12419 
12420 template<typename Derived>
12422  return SemaRef.Context.getFunctionNoProtoType(T);
12423 }
12424 
12425 template<typename Derived>
12427  Decl *D) {
12428  assert(D && "no decl found");
12429  if (D->isInvalidDecl()) return QualType();
12430 
12431  // FIXME: Doesn't account for ObjCInterfaceDecl!
12432  TypeDecl *Ty;
12433  if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
12434  // A valid resolved using typename pack expansion decl can have multiple
12435  // UsingDecls, but they must each have exactly one type, and it must be
12436  // the same type in every case. But we must have at least one expansion!
12437  if (UPD->expansions().empty()) {
12438  getSema().Diag(Loc, diag::err_using_pack_expansion_empty)
12439  << UPD->isCXXClassMember() << UPD;
12440  return QualType();
12441  }
12442 
12443  // We might still have some unresolved types. Try to pick a resolved type
12444  // if we can. The final instantiation will check that the remaining
12445  // unresolved types instantiate to the type we pick.
12446  QualType FallbackT;
12447  QualType T;
12448  for (auto *E : UPD->expansions()) {
12449  QualType ThisT = RebuildUnresolvedUsingType(Loc, E);
12450  if (ThisT.isNull())
12451  continue;
12452  else if (ThisT->getAs<UnresolvedUsingType>())
12453  FallbackT = ThisT;
12454  else if (T.isNull())
12455  T = ThisT;
12456  else
12457  assert(getSema().Context.hasSameType(ThisT, T) &&
12458  "mismatched resolved types in using pack expansion");
12459  }
12460  return T.isNull() ? FallbackT : T;
12461  } else if (auto *Using = dyn_cast<UsingDecl>(D)) {
12462  assert(Using->hasTypename() &&
12463  "UnresolvedUsingTypenameDecl transformed to non-typename using");
12464 
12465  // A valid resolved using typename decl points to exactly one type decl.
12466  assert(++Using->shadow_begin() == Using->shadow_end());
12467  Ty = cast<TypeDecl>((*Using->shadow_begin())->getTargetDecl());
12468  } else {
12469  assert(isa<UnresolvedUsingTypenameDecl>(D) &&
12470  "UnresolvedUsingTypenameDecl transformed to non-using decl");
12471  Ty = cast<UnresolvedUsingTypenameDecl>(D);
12472  }
12473 
12474  return SemaRef.Context.getTypeDeclType(Ty);
12475 }
12476 
12477 template<typename Derived>
12479  SourceLocation Loc) {
12480  return SemaRef.BuildTypeofExprType(E, Loc);
12481 }
12482 
12483 template<typename Derived>
12485  return SemaRef.Context.getTypeOfType(Underlying);
12486 }
12487 
12488 template<typename Derived>
12490  SourceLocation Loc) {
12491  return SemaRef.BuildDecltypeType(E, Loc);
12492 }
12493 
12494 template<typename Derived>
12497  SourceLocation Loc) {
12498  return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
12499 }
12500 
12501 template<typename Derived>
12503  TemplateName Template,
12504  SourceLocation TemplateNameLoc,
12505  TemplateArgumentListInfo &TemplateArgs) {
12506  return SemaRef.CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
12507 }
12508 
12509 template<typename Derived>
12511  SourceLocation KWLoc) {
12512  return SemaRef.BuildAtomicType(ValueType, KWLoc);
12513 }
12514 
12515 template<typename Derived>
12517  SourceLocation KWLoc,
12518  bool isReadPipe) {
12519  return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
12520  : SemaRef.BuildWritePipeType(ValueType, KWLoc);
12521 }
12522 
12523 template<typename Derived>
12526  bool TemplateKW,
12527  TemplateDecl *Template) {
12528  return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
12529  Template);
12530 }
12531 
12532 template<typename Derived>
12535  const IdentifierInfo &Name,
12536  SourceLocation NameLoc,
12537  QualType ObjectType,
12538  NamedDecl *FirstQualifierInScope,
12539  bool AllowInjectedClassName) {
12541  TemplateName.setIdentifier(&Name, NameLoc);
12542  Sema::TemplateTy Template;
12543  SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
12544  getSema().ActOnDependentTemplateName(/*Scope=*/nullptr,
12545  SS, TemplateKWLoc, TemplateName,
12546  ParsedType::make(ObjectType),
12547  /*EnteringContext=*/false,
12548  Template, AllowInjectedClassName);
12549  return Template.get();
12550 }
12551 
12552 template<typename Derived>
12555  OverloadedOperatorKind Operator,
12556  SourceLocation NameLoc,
12557  QualType ObjectType,
12558  bool AllowInjectedClassName) {
12559  UnqualifiedId Name;
12560  // FIXME: Bogus location information.
12561  SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
12562  Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
12563  SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
12564  Sema::TemplateTy Template;
12565  getSema().ActOnDependentTemplateName(/*Scope=*/nullptr,
12566  SS, TemplateKWLoc, Name,
12567  ParsedType::make(ObjectType),
12568  /*EnteringContext=*/false,
12569  Template, AllowInjectedClassName);
12570  return Template.get();
12571 }
12572 
12573 template<typename Derived>
12574 ExprResult
12576  SourceLocation OpLoc,
12577  Expr *OrigCallee,
12578  Expr *First,
12579  Expr *Second) {
12580  Expr *Callee = OrigCallee->IgnoreParenCasts();
12581  bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
12582 
12583  if (First->getObjectKind() == OK_ObjCProperty) {
12586  return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc, Opc,
12587  First, Second);
12588  ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
12589  if (Result.isInvalid())
12590  return ExprError();
12591  First = Result.get();
12592  }
12593 
12594  if (Second && Second->getObjectKind() == OK_ObjCProperty) {
12595  ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
12596  if (Result.isInvalid())
12597  return ExprError();
12598  Second = Result.get();
12599  }
12600 
12601  // Determine whether this should be a builtin operation.
12602  if (Op == OO_Subscript) {
12603  if (!First->getType()->isOverloadableType() &&
12604  !Second->getType()->isOverloadableType())
12605  return getSema().CreateBuiltinArraySubscriptExpr(First,
12606  Callee->getLocStart(),
12607  Second, OpLoc);
12608  } else if (Op == OO_Arrow) {
12609  // -> is never a builtin operation.
12610  return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
12611  } else if (Second == nullptr || isPostIncDec) {
12612  if (!First->getType()->isOverloadableType()) {
12613  // The argument is not of overloadable type, so try to create a
12614  // built-in unary operation.
12615  UnaryOperatorKind Opc
12616  = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
12617 
12618  return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
12619  }
12620  } else {
12621  if (!First->getType()->isOverloadableType() &&
12622  !Second->getType()->isOverloadableType()) {
12623  // Neither of the arguments is an overloadable type, so try to
12624  // create a built-in binary operation.
12626  ExprResult Result
12627  = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
12628  if (Result.isInvalid())
12629  return ExprError();
12630 
12631  return Result;
12632  }
12633  }
12634 
12635  // Compute the transformed set of functions (and function templates) to be
12636  // used during overload resolution.
12637  UnresolvedSet<16> Functions;
12638  bool RequiresADL;
12639 
12640  if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
12641  Functions.append(ULE->decls_begin(), ULE->decls_end());
12642  // If the overload could not be resolved in the template definition
12643  // (because we had a dependent argument), ADL is performed as part of
12644  // template instantiation.
12645  RequiresADL = ULE->requiresADL();
12646  } else {
12647  // If we've resolved this to a particular non-member function, just call
12648  // that function. If we resolved it to a member function,
12649  // CreateOverloaded* will find that function for us.
12650  NamedDecl *ND = cast<DeclRefExpr>(Callee)->getDecl();
12651  if (!isa<CXXMethodDecl>(ND))
12652  Functions.addDecl(ND);
12653  RequiresADL = false;
12654  }
12655 
12656  // Add any functions found via argument-dependent lookup.
12657  Expr *Args[2] = { First, Second };
12658  unsigned NumArgs = 1 + (Second != nullptr);
12659 
12660  // Create the overloaded operator invocation for unary operators.
12661  if (NumArgs == 1 || isPostIncDec) {
12662  UnaryOperatorKind Opc
12663  = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
12664  return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
12665  RequiresADL);
12666  }
12667 
12668  if (Op == OO_Subscript) {
12669  SourceLocation LBrace;
12670  SourceLocation RBrace;
12671 
12672  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Callee)) {
12673  DeclarationNameLoc NameLoc = DRE->getNameInfo().getInfo();
12677  NameLoc.CXXOperatorName.EndOpNameLoc);
12678  } else {
12679  LBrace = Callee->getLocStart();
12680  RBrace = OpLoc;
12681  }
12682 
12683  return SemaRef.CreateOverloadedArraySubscriptExpr(LBrace, RBrace,
12684  First, Second);
12685  }
12686 
12687  // Create the overloaded operator invocation for binary operators.
12689  ExprResult Result = SemaRef.CreateOverloadedBinOp(
12690  OpLoc, Opc, Functions, Args[0], Args[1], RequiresADL);
12691  if (Result.isInvalid())
12692  return ExprError();
12693 
12694  return Result;
12695 }
12696 
12697 template<typename Derived>
12698 ExprResult
12700  SourceLocation OperatorLoc,
12701  bool isArrow,
12702  CXXScopeSpec &SS,
12703  TypeSourceInfo *ScopeType,
12704  SourceLocation CCLoc,
12705  SourceLocation TildeLoc,
12706  PseudoDestructorTypeStorage Destroyed) {
12707  QualType BaseType = Base->getType();
12708  if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
12709  (!isArrow && !BaseType->getAs<RecordType>()) ||
12710  (isArrow && BaseType->getAs<PointerType>() &&
12711  !BaseType->getAs<PointerType>()->getPointeeType()
12712  ->template getAs<RecordType>())){
12713  // This pseudo-destructor expression is still a pseudo-destructor.
12714  return SemaRef.BuildPseudoDestructorExpr(
12715  Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
12716  CCLoc, TildeLoc, Destroyed);
12717  }
12718 
12719  TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
12720  DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
12721  SemaRef.Context.getCanonicalType(DestroyedType->getType())));
12722  DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
12723  NameInfo.setNamedTypeInfo(DestroyedType);
12724 
12725  // The scope type is now known to be a valid nested name specifier
12726  // component. Tack it on to the end of the nested name specifier.
12727  if (ScopeType) {
12728  if (!ScopeType->getType()->getAs<TagType>()) {
12729  getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
12730  diag::err_expected_class_or_namespace)
12731  << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
12732  return ExprError();
12733  }
12734  SS.Extend(SemaRef.Context, SourceLocation(), ScopeType->getTypeLoc(),
12735  CCLoc);
12736  }
12737 
12738  SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
12739  return getSema().BuildMemberReferenceExpr(Base, BaseType,
12740  OperatorLoc, isArrow,
12741  SS, TemplateKWLoc,
12742  /*FIXME: FirstQualifier*/ nullptr,
12743  NameInfo,
12744  /*TemplateArgs*/ nullptr,
12745  /*S*/nullptr);
12746 }
12747 
12748 template<typename Derived>
12749 StmtResult
12751  SourceLocation Loc = S->getLocStart();
12752  CapturedDecl *CD = S->getCapturedDecl();
12753  unsigned NumParams = CD->getNumParams();
12754  unsigned ContextParamPos = CD->getContextParamPosition();
12756  for (unsigned I = 0; I < NumParams; ++I) {
12757  if (I != ContextParamPos) {
12758  Params.push_back(
12759  std::make_pair(
12760  CD->getParam(I)->getName(),
12761  getDerived().TransformType(CD->getParam(I)->getType())));
12762  } else {
12763  Params.push_back(std::make_pair(StringRef(), QualType()));
12764  }
12765  }
12766  getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
12767  S->getCapturedRegionKind(), Params);
12768  StmtResult Body;
12769  {
12770  Sema::CompoundScopeRAII CompoundScope(getSema());
12771  Body = getDerived().TransformStmt(S->getCapturedStmt());
12772  }
12773 
12774  if (Body.isInvalid()) {
12775  getSema().ActOnCapturedRegionError();
12776  return StmtError();
12777  }
12778 
12779  return getSema().ActOnCapturedRegionEnd(Body.get());
12780 }
12781 
12782 } // end namespace clang
12783 
12784 #endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
SourceLocation getRParenLoc() const
Definition: Stmt.h:1188
Expr * getInc()
Definition: Stmt.h:1241
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:577
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1517
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:1060
Represents a single C99 designator.
Definition: Expr.h:4181
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:1140
SourceLocation getStartLoc() const
Definition: Stmt.h:511
CXXRecordDecl * getNamingClass() const
Retrieve the naming class of this lookup.
Definition: ExprCXX.cpp:1282
SourceLocation getRBracLoc() const
Definition: Stmt.h:684
const BlockDecl * getBlockDecl() const
Definition: Expr.h:4865
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3194
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:4387
IdentifierInfo * getInputIdentifier(unsigned i) const
Definition: Stmt.h:1738
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1377
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:4784
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1546
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2270
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:892
SourceLocation getRParenLoc() const
Definition: Stmt.h:1641
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:565
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:2678
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:977
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1717
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:1620
An instance of this class is created to represent a function declaration or definition.
Definition: Decl.h:1697
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4340
Expr * getArrayIndex(const Designator &D) const
Definition: Expr.cpp:3799
SourceLocation getForLoc() const
Definition: StmtCXX.h:193
SourceRange getExceptionSpecRange() const
Definition: TypeLoc.h:1451
helper_expr_const_range reduction_ops() const
Name lookup found a set of overloaded functions that met the criteria.
Definition: Lookup.h:49
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:223
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:2269
The receiver is an object instance.
Definition: ExprObjC.h:1054
Expr * getLHS() const
Definition: Expr.h:3314
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:2694
const Stmt * getElse() const
Definition: Stmt.h:973
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:3623
unsigned getNumInputs() const
Definition: Stmt.h:1536
Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var, Expr *Expr, Sema::ConditionKind Kind)
Transform the specified condition.
SourceLocation getOpLoc() const
Definition: ExprObjC.h:1472
SourceLocation getRParenLoc() const
Definition: Expr.h:2345
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:1131
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
Definition: Expr.cpp:2005
CompoundStmt * getBlock() const
Definition: Stmt.h:1962
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:1254
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; directives.
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:497
ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
Build a new object-construction expression.
PtrTy get() const
Definition: Ownership.h:74
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2283
StmtResult RebuildCaseStmt(SourceLocation CaseLoc, Expr *LHS, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation ColonLoc)
Build a new case statement.
QualType getPointeeType() const
Definition: Type.h:2296
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:1086
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
Definition: Type.h:3727
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2146
A (possibly-)qualified type.
Definition: Type.h:653
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:5292
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:2483
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1347
Derived & getDerived()
Retrieves a reference to the derived class.
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:239
Expr * getCond() const
Definition: Expr.h:3709
QualType TransformType(QualType T)
Transforms the given type into another type.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2278
ObjCMethodDecl * getAtIndexMethodDecl() const
Definition: ExprObjC.h:853
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:3758
Selector getSelector() const
Definition: ExprObjC.cpp:312
QualType RebuildTemplateSpecializationType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &Args)
Build a new template specialization type.
SourceLocation getEllipsisLoc() const
Definition: Stmt.h:759
SourceLocation getLParen() const
Get the location of the left parentheses &#39;(&#39;.
Definition: Expr.h:1689
const Expr * getSubExpr() const
Definition: ExprCXX.h:1007
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition: ExprCXX.cpp:965
SourceLocation getCommaLoc()
Get location of &#39;,&#39;.
Definition: OpenMPClause.h:900
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:404
Expr * getCond()
Definition: Stmt.h:1131
TemplateParameterList * GLTemplateParameterList
If this is a generic lambda, and the template parameter list has been created (from the AutoTemplateP...
Definition: ScopeInfo.h:784
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:3567
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:2339
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
Definition: Sema.h:2994
CompoundStmt * getSubStmt()
Definition: Expr.h:3504
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2333
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:526
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:1829
Expr * getUnderlyingExpr() const
Definition: Type.h:3862
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:2334
static ConditionResult ConditionError()
Definition: Sema.h:9746
ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
Build a new object-construction expression.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition: ExprCXX.h:2781
const TemplateArgumentLoc * operator->() const
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1443
SourceLocation getRParenLoc() const
Definition: StmtObjC.h:104
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
Definition: ExprCXX.h:1782
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:1017
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:1314
bool isLeftFold() const
Does this produce a left-associated sequence of operators?
Definition: ExprCXX.h:4179
Represents a &#39;co_return&#39; statement in the C++ Coroutines TS.
Definition: StmtCXX.h:432
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:2266
This represents clause &#39;in_reduction&#39; in the &#39;#pragma omp task&#39; directives.
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2474
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
Definition: StmtObjC.h:224
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2402
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1637
void setExceptionSpecRange(SourceRange R)
Definition: TypeLoc.h:1457
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:933
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:2925
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition: Expr.h:1961
SourceLocation getRParenLoc() const
Definition: Expr.h:3554
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:456
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:2951
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2329
ObjCMethodDecl * setAtIndexMethodDecl() const
Definition: ExprObjC.h:857
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:609
QualType RebuildEnumType(EnumDecl *Enum)
Build a new Enum type.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1009
unsigned getNumOutputs() const
Definition: Stmt.h:1514
ActionResult< Expr * > ExprResult
Definition: Ownership.h:251
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:2042
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:4849
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:915
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1127
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:6015
Expr * getBase() const
Definition: Expr.h:2477
const StringLiteral * getAsmString() const
Definition: Stmt.h:1646
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:2673
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition: Sema.h:1270
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
This represents &#39;grainsize&#39; clause in the &#39;#pragma omp ...&#39; directive.
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1150
TemplateParameterList * TransformTemplateParameterList(TemplateParameterList *TPL)
This represents &#39;#pragma omp teams distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3605
Stmt * getHandlerBlock() const
Definition: StmtCXX.h:52
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2056
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:4545
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:1942
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition: TypeLoc.h:570
void setType(QualType t)
Definition: Expr.h:129
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2736
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:3796
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we&#39;re testing for, along with location information.
Definition: StmtCXX.h:276
Defines the C++ template declaration subclasses.
Opcode getOpcode() const
Definition: Expr.h:3026
StringRef P
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:4401
SourceLocation getIdentLoc() const
Definition: Stmt.h:858
Represents an attribute applied to a statement.
Definition: Stmt.h:881
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:1665
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:2497
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
Definition: StmtCXX.h:272
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:1351
This represents &#39;#pragma omp target teams distribute&#39; combined directive.
Definition: StmtOpenMP.h:3742
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:1329
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
Definition: Decl.cpp:4071
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:1119
QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc)
Build a new typeof(expr) type.
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2153
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:2558
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
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:505
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:4371
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1239
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:802
Wrapper for source info for typedefs.
Definition: TypeLoc.h:665
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:2906
FPOptions getFPFeatures() const
Definition: Expr.h:3157
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2423
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1207
bool getIsCXXTry() const
Definition: Stmt.h:2001
SourceLocation getLParenLoc() const
Definition: Expr.h:2948
SourceLocation getLocStart() const LLVM_READONLY
Definition: Expr.h:4594
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:365
std::input_iterator_tag iterator_category
A container of type source information.
Definition: Decl.h:86
This represents &#39;update&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Wrapper for void* pointer.
Definition: Ownership.h:45
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
This represents &#39;#pragma omp parallel for&#39; directive.
Definition: StmtOpenMP.h:1498
MS property subscript expression.
Definition: ExprCXX.h:797
OMPClause * RebuildOMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;priority&#39; clause.
SourceLocation getGotoLoc() const
Definition: Stmt.h:1328
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:3786
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclBase.h:412
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1825
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:3810
ExprResult RebuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentType IT)
Build a new predefined expression.
Wrapper for source info for pointers decayed from arrays and functions.
Definition: TypeLoc.h:1232
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:2397
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.cpp:784
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4035
SourceLocation getAccessorLoc() const
Definition: Expr.h:4815
ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, SourceLocation OpLoc, Expr *Callee, Expr *First, Expr *Second)
Build a new overloaded operator call expression.
Expr * getAlignment()
Returns alignment.
static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind)
Return the number of captured regions created for an OpenMP directive.
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.
Definition: OpenMPClause.h:960
SourceLocation getRParenLoc() const
getRParenLoc - Return the location of final right parenthesis.
Definition: Expr.h:3639
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:227
SourceLocation getSecondScheduleModifierLoc() const
Get the second modifier location.
Definition: OpenMPClause.h:895
QualType getElementType() const
Definition: Type.h:2593
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "while" statement, if any.
Definition: Stmt.cpp:900
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
Definition: Type.h:4455
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:194
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:1989
Stmt * getExceptionHandler() const
Definition: StmtCXX.h:378
DeclarationNameInfo TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
Transform the given declaration name.
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1854
Expr * getDeallocate() const
Definition: StmtCXX.h:388
An identifier, stored as an IdentifierInfo*.
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2409
Stmt * getSubStmt()
Definition: Stmt.h:814
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:566
This represents &#39;read&#39; clause in the &#39;#pragma omp atomic&#39; directive.
RAII object that enters a new expression evaluation context.
Definition: Sema.h:10640
OMPClause * RebuildOMPDeviceClause(Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;device&#39; clause.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:806
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:1256
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:1436
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1752
void removeObjCLifetime()
Definition: Type.h:347
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:2637
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:1301
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:6019
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;.&#39; or &#39;->&#39; operator.
Definition: ExprCXX.h:2263
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Definition: TypeLoc.h:272
IdentifierInfo * getIdentifier() const
Definition: ExprCXX.h:2166
UnresolvedLookupExpr * getOperatorCoawaitLookup() const
Definition: ExprCXX.h:4367
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6305
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition: Type.h:6245
varlist_range varlists()
Definition: OpenMPClause.h:207
Records and restores the FP_CONTRACT state on entry/exit of compound statements.
Definition: Sema.h:1171
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:2388
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:3387
This represents &#39;defaultmap&#39; clause in the &#39;#pragma omp ...&#39; directive.
Stmt * getResultDecl() const
Definition: StmtCXX.h:394
ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1274
Represents a C++17 deduced template specialization type.
Definition: Type.h:4437
TypeSourceInfo * InventTypeSourceInfo(QualType T)
Fakes up a TypeSourceInfo for a type.
SourceLocation getColonLoc() const
Definition: Expr.h:3259
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:1464
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
SourceLocation getLeftLoc() const
Definition: ExprObjC.h:1362
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:1068
RAII object used to temporarily allow the C++ &#39;this&#39; expression to be used, with the given qualifiers...
Definition: Sema.h:5040
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:2655
reference front() const
Definition: DeclBase.h:1230
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:594
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2034
bool isInvalidDecl() const
Definition: DeclBase.h:546
SourceLocation getIfLoc() const
Definition: Stmt.h:980
void transformedLocalDecl(Decl *Old, Decl *New)
Note that a local declaration has been transformed by this transformer.
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1759
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:783
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:68
unsigned getContextParamPosition() const
Definition: Decl.h:3940
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:1956
TypeSourceInfo * getArgumentTypeInfo() const
Definition: Expr.h:2071
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:2809
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:1907
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:1435
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:985
Expr * getExprOperand() const
Definition: ExprCXX.h:695
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3000
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:2391
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:1745
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1513
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:147
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4256
TemplateArgumentLocContainerIterator operator++(int)
SourceLocation getRParenLoc() const
Definition: Expr.h:4715
Defines the clang::Expr interface and subclasses for C++ expressions.
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "switch" statement, if any.
Definition: Stmt.cpp:866
bool isUnset() const
Definition: Ownership.h:160
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2014
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:508
The collection of all-type qualifiers we support.
Definition: Type.h:152
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:999
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition: TypeLoc.h:1027
SourceLocation getBuiltinLoc() const
Definition: Expr.h:3716
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:5648
bool needsExtraLocalData() const
Definition: TypeLoc.h:577
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:302
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:902
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:3616
const Stmt * getSubStmt() const
Definition: StmtObjC.h:356
SourceLocation getAttributeLoc() const
Definition: Type.h:2891
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Definition: Decl.h:265
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:56
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition: ExprCXX.h:279
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:842
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3488
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:4106
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
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:291
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:2274
SourceLocation getKeywordLoc() const
Definition: StmtCXX.h:452
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
SourceLocation getColonLoc() const
Definition: Stmt.h:820
One of these records is kept for each identifier that is lexed.
Stmt * getBody()
Definition: Stmt.h:1179
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:4076
void setLocalRangeEnd(SourceLocation L)
Definition: TypeLoc.h:1427
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
Definition: Lookup.h:59
SourceLocation getTildeLoc() const
Retrieve the location of the &#39;~&#39;.
Definition: ExprCXX.h:2281
SourceLocation getRParenLoc() const
Definition: Expr.h:5194
Step
Definition: OpenMPClause.h:141
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:239
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:255
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3533
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:5184
SourceLocation getRParen() const
Get the location of the right parentheses &#39;)&#39;.
Definition: Expr.h:1693
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:4340
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:422
ExprResult ExprEmpty()
Definition: Ownership.h:273
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3496
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1182
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:3844
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:501
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1187
QualType BuildParenType(QualType T)
Build a paren type including T.
Definition: SemaType.cpp:1752
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:554
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:1653
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:1903
bool isExplicitProperty() const
Definition: ExprObjC.h:668
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2463
bool isSpelledAsLValue() const
Definition: Type.h:2435
SourceLocation getAmpAmpLoc() const
Definition: Expr.h:3458
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
void setRBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1546
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
OpenMPLinearClauseKind
OpenMP attributes for &#39;linear&#39; clause.
Definition: OpenMPKinds.h:84
SourceLocation getEndLoc() const
Definition: Stmt.h:513
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:12914
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2467
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:4563
void setBlockMissingReturnType(bool val)
Definition: Decl.h:3828
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:3507
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4400
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:897
VarDecl * getPromiseDecl() const
Definition: StmtCXX.h:367
ArrayRef< Expr * > getAllExprs() const
Definition: Stmt.h:1875
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
Definition: ExprCXX.h:2652
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1566
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:587
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:96
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1014
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:1032
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition: Expr.h:1880
const Expr * getRetValue() const
Definition: Stmt.cpp:928
SourceLocation getLabelLoc() const
Definition: Expr.h:3460
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2068
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition: Expr.h:2542
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:4019
SourceLocation getOperatorLoc() const
Definition: Expr.h:2098
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:3744
bool isReferenceType() const
Definition: Type.h:5954
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:2951
SourceLocation getDefaultKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:656
Interesting information about a specific parameter that can&#39;t simply be reflected in parameter&#39;s type...
Definition: Type.h:3289
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2064
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:1040
This represents &#39;#pragma omp target simd&#39; directive.
Definition: StmtOpenMP.h:3330
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:926
bool isInvalid() const
Definition: Sema.h:9735
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3439
Wrapper for source info for unresolved typename using decls.
Definition: TypeLoc.h:687
qual_iterator qual_begin() const
Definition: Type.h:5085
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1439
ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub, bool IsThrownVariableInScope)
Build a new C++ throw expression.
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:9736
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:4790
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:806
LookupResultKind getResultKind() const
Definition: Lookup.h:324
OpenMPDirectiveKind getDirectiveKind() const
Definition: StmtOpenMP.h:225
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:2761
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:4190
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:1947
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:1829
SourceLocation getQuestionLoc() const
Definition: Expr.h:3258
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
Fetches the full source range of the argument.
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:3894
Expr * getAttrExprOperand() const
The attribute&#39;s expression operand, if it has one.
Definition: TypeLoc.h:907
ExprResult RebuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
Build a new Objective-C boxed expression.
This represents &#39;#pragma omp critical&#39; directive.
Definition: StmtOpenMP.h:1424
bool isAssignmentOp() const
Definition: Expr.h:3111
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
Definition: Diagnostic.h:1202
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
Definition: ExprCXX.h:1651
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Definition: Lookup.h:41
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:2941
StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @autoreleasepool statement.
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1846
IdentifierTable & Idents
Definition: ASTContext.h:537
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition: Type.h:5737
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:107
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:504
Represents Objective-C&#39;s @catch statement.
Definition: StmtObjC.h:74
Expr * getLHS() const
Definition: ExprCXX.h:4170
DeclClass * getAsSingle() const
Definition: Lookup.h:510
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:100
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:1312
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:3872
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:1633
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:638
This represents &#39;#pragma omp distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3045
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:796
Expr * getKeyExpr() const
Definition: ExprObjC.h:850
This represents &#39;#pragma omp teams distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3534
BinaryOperatorKind
Expr * getArraySize()
Definition: ExprCXX.h:1949
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:910
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:3738
SourceLocation getLocEnd() const
Returns ending location of directive.
Definition: StmtOpenMP.h:170
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2290
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:1207
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Definition: SemaLookup.cpp:471
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:522
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:705
Represents the results of name lookup.
Definition: Lookup.h:32
PtrTy get() const
Definition: Ownership.h:162
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:2286
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:2123
friend bool operator!=(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
Expr * getBaseExpr() const
Definition: ExprObjC.h:847
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:1308
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2177
Expr * getOperand() const
Definition: ExprCXX.h:3619
const Expr * getThrowExpr() const
Definition: StmtObjC.h:325
Wrapper for source info for injected class names of class templates.
Definition: TypeLoc.h:676
< Capturing the *this object by copy
Definition: Lambda.h:37
bool isGlobalNew() const
Definition: ExprCXX.h:1974
unsigned getNumProtocols() const
Definition: TypeLoc.h:787
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:1052
SourceLocation getSigilLoc() const
Definition: TypeLoc.h:1245
A convenient class for passing around template argument information.
Definition: TemplateBase.h:546
ExprResult RebuildInitList(SourceLocation LBraceLoc, MultiExprArg Inits, SourceLocation RBraceLoc, QualType ResultTy)
Build a new initializer list expression.
SourceLocation getLocation() const
Definition: ExprCXX.h:2170
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation Loc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:2809
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:859
SourceLocation getLBracLoc() const
Definition: Stmt.h:683
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 getLocStart() const
Returns the starting location of the clause.
Definition: OpenMPClause.h:67
SourceLocation getRParenLoc() const
Definition: StmtCXX.h:196
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:1987
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Definition: Expr.h:405
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:1469
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:2671
Stmt * getBody()
Definition: Stmt.h:1242
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2060
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:839
StmtResult StmtError()
Definition: Ownership.h:268
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:1633
QualType FunctionType
BlockType - The function type of the block, if one was given.
Definition: ScopeInfo.h:680
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: ExprCXX.h:3387
TypeDecl - Represents a declaration of a type.
Definition: Decl.h:2760
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:2985
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:832
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:1439
const Expr * getAssocExpr(unsigned i) const
Definition: Expr.h:4717
Stmt * getInit()
Definition: Stmt.h:1221
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:420
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1431
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1858
SourceLocation getThrowLoc() const
Definition: ExprCXX.h:1010
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1751
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:2536
CXXForRangeStmt - This represents C++0x [stmt.ranged]&#39;s ranged for statement, represented as &#39;for (ra...
Definition: StmtCXX.h:128
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3159
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:2582
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:2664
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:2465
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:4331
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:2149
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3356
Expr * getRHS() const
Definition: ExprCXX.h:4171
Expr * getSizeExpr() const
Definition: Type.h:2737
const CallExpr * getConfig() const
Definition: ExprCXX.h:216
bool isArrow() const
Definition: ExprCXX.h:781
Wrapper for source info for ObjC interfaces.
Definition: TypeLoc.h:1118
FPOptions getFPFeatures() const
Definition: ExprCXX.h:147
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:3641
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:2157
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5232
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:2011
Expr * getCond()
Definition: Stmt.h:1240
This represents &#39;#pragma omp teams&#39; directive.
Definition: StmtOpenMP.h:2607
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:4742
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:1137
Helper class for OffsetOfExpr.
Definition: Expr.h:1822
Expr * getOperand() const
Definition: ExprCXX.h:4365
This represents &#39;#pragma omp teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3464
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1196
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:1785
StmtResult RebuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, 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.
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:90
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:241
SourceLocation getBuiltinLoc() const
Definition: Expr.h:3807
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:1057
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:964
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1580
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:748
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
Definition: Expr.h:1060
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
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:2899
An ordinary object is located at an address in memory.
Definition: Specifiers.h:123
SourceLocation getTryLoc() const
Definition: Stmt.h:1998
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3202
This represents clause &#39;is_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1419
This represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3866
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
Definition: Stmt.cpp:838
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:1748
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition: Lookup.h:429
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:3002
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:956
StmtClass
Definition: Stmt.h:68
const Stmt * getBody() const
Definition: Expr.cpp:2014
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1821
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
SourceLocation getProtocolRAngleLoc() const
Definition: TypeLoc.h:777
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Definition: DeclSpec.cpp:143
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2117
Expr * getSizeExpr() const
Definition: Type.h:2794
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition: Expr.cpp:1125
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1042
Stmt * getInit()
Definition: Stmt.h:966
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1738
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2438
bool isTypeOperand() const
Definition: ExprCXX.h:885
Stmt * getReturnStmt() const
Definition: StmtCXX.h:395
QualType getElementType() const
Definition: Type.h:2890
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:1935
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:3542
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:7230
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:2874
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:3322
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:945
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:3138
A helper class for building up ExtParameterInfos.
Definition: Sema.h:7594
TypeSourceInfo * getAllocatedTypeSourceInfo() const
Definition: ExprCXX.h:1921
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:1536
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: Expr.h:2502
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:2470
SourceLocation getLocStart() const
Returns starting location of directive kind.
Definition: StmtOpenMP.h:168
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:1625
bool isArrayForm() const
Definition: ExprCXX.h:2112
Expr ** getSubExprs()
Retrieve the array of expressions.
Definition: Expr.h:3570
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:3233
Expr * getAddrSpaceExpr() const
Definition: Type.h:2845
helper_expr_const_range reduction_ops() const
This represents &#39;#pragma omp target parallel for simd&#39; directive.
Definition: StmtOpenMP.h:3262
llvm::Optional< bool > getKnownValue() const
Definition: Sema.h:9740
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:45
StmtResult TransformSEHHandler(Stmt *Handler)
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3269
An error occurred.
Definition: Sema.h:4462
SourceLocation getBuiltinLoc() const
Definition: TypeLoc.h:550
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1549
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:274
OMPClause * RebuildOMPMapClause(OpenMPMapClauseKind MapTypeModifier, 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.
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1324
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2197
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:595
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:653
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3268
SourceLocation getRBracket() const
Definition: ExprObjC.h:838
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:1959
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:5170
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
Definition: StmtCXX.h:280
This represents &#39;#pragma omp taskgroup&#39; directive.
Definition: StmtOpenMP.h:1917
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:1302
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:3673
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:3378
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:2080
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.cpp:290
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:2031
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:2564
SourceLocation getTryLoc() const
Definition: StmtCXX.h:91
bool isConstexpr() const
Definition: Stmt.h:985
ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait, SourceLocation StartLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParenLoc)
Build a new array type trait expression.
SourceLocation getRBracketLoc() const
Definition: ExprCXX.h:835
This represents clause &#39;task_reduction&#39; in the &#39;#pragma omp taskgroup&#39; directives.
SourceLocation getLocation() const
Definition: Expr.h:1049
QualType RebuildTypeOfType(QualType Underlying)
Build a new typeof(type) type.
void setSizeExpr(Expr *Size)
Definition: TypeLoc.h:1558
SourceRange getRange() const
Definition: DeclSpec.h:68
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
ObjCTypeParamDecl * getDecl() const
Definition: Type.h:5153
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:3778
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2185
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param)
Definition: ExprCXX.h:1067
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:1295
OMPClause * RebuildOMPNumThreadsClause(Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;num_threads&#39; clause.
SourceLocation getThrowLoc() const LLVM_READONLY
Definition: StmtObjC.h:329
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:900
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
Definition: Expr.cpp:4005
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:4194
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2161
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:2918
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:133
void setAttrExprOperand(Expr *e)
Definition: TypeLoc.h:911
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:2772
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
Definition: ExprCXX.h:2305
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:190
SourceLocation getFinallyLoc() const
Definition: Stmt.h:1959
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:1943
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2157
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:1802
Retains information about a block that is currently being parsed.
Definition: ScopeInfo.h:670
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:3527
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:745
Expr * getCond() const
Definition: Expr.h:3303
Type source information for an attributed type.
Definition: TypeLoc.h:859
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:916
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3695
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1560
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2133
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:4309
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:2487
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:627
ExprResult RebuildCoyieldExpr(SourceLocation CoyieldLoc, Expr *Result)
Build a new co_yield expression.
Expr - This represents one expression.
Definition: Expr.h:106
SourceLocation getLocalRangeEnd() const
Definition: TypeLoc.h:1423
SourceLocation getElseLoc() const
Definition: Stmt.h:982
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.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:104
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition: Type.h:4723
SourceLocation getCaptureDefaultLoc() const
Retrieve the location of this lambda&#39;s capture-default, if any.
Definition: ExprCXX.h:1656
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:2696
ArrayRef< StringRef > getClobbers() const
Definition: Stmt.h:1871
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:1391
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:3524
int Id
Definition: ASTDiff.cpp:191
QualType TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext, unsigned ThisTypeQuals, Fn TransformExceptionSpec)
const FunctionProtoType * T
This represents &#39;simdlen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:501
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.cpp:780
Expr * getNumTasks() const
Return safe iteration space distance.
SourceLocation getDefaultLoc() const
Definition: Stmt.h:818
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr)
SourceLocation getScheduleKindLoc()
Get kind location.
Definition: OpenMPClause.h:887
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:1242
SourceLocation getWhileLoc() const
Definition: Stmt.h:1138
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition: TypeLoc.h:321
SourceRange getBracketsRange() const
Definition: TypeLoc.h:1550
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:6368
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1530
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:4705
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:68
const Stmt * getThen() const
Definition: Stmt.h:971
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:140
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:420
unsigned getNumParams() const
Definition: Decl.h:3911
const TypeSourceInfo * getAssocTypeSourceInfo(unsigned i) const
Definition: Expr.h:4727
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4851
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:86
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2620
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:2297
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:3902
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Definition: ExprCXX.cpp:1189
TemplateArgumentLocInventIterator & operator++()
const Expr * getCallee() const
Definition: Expr.h:2249
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:3894
bool isIfNotExists() const
Determine whether this is an __if_exists statement.
Definition: StmtCXX.h:268
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:2260
Stmt * getBody()
Definition: Stmt.h:1134
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:2702
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:425
SourceLocation getLParenLoc() const
Definition: Expr.h:4636
QualType RebuildDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo *Name, SourceLocation NameLoc, TemplateArgumentListInfo &Args, bool AllowInjectedClassName)
Build a new typename type that refers to a template-id.
Expr * getRHS()
Definition: Stmt.h:765
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Definition: Type.h:4875
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:1332
SourceLocation Begin
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2238
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:1968
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:3724
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:4896
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:2298
IdentifierInfo & getAccessor() const
Definition: Expr.h:4812
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
Represents the type decltype(expr) (C++11).
Definition: Type.h:3852
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3967
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2466
ExprResult RebuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Build an empty C++1z fold-expression with the given operator.
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1788
A namespace alias, stored as a NamespaceAliasDecl*.
This represents &#39;ordered&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:925
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.
StmtResult TransformStmt(Stmt *S)
Transform the given statement.
SourceRange getAngleBrackets() const LLVM_READONLY
Definition: ExprCXX.h:283
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:1876
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1850
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:2525
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:3688
SourceLocation getLocalRangeBegin() const
Definition: TypeLoc.h:1415
SourceLocation getKeywordLoc() const
Retrieve the location of the __if_exists or __if_not_exists keyword.
Definition: StmtCXX.h:262
Wrapper for source info for enum types.
Definition: TypeLoc.h:725
This represents &#39;#pragma omp for&#39; directive.
Definition: StmtOpenMP.h:1050
A unary type transform, which is a type constructed from another.
Definition: Type.h:3895
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:767
Expr * getPattern() const
Get the pattern, that is, the operand that contains an unexpanded pack.
Definition: ExprCXX.h:4182
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:1062
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2242
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:1290
const Stmt * getTryBody() const
Retrieve the @try body.
Definition: StmtObjC.h:197
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4145
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition: TypeLoc.h:747
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:1417
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:3683
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition: TypeLoc.h:1076
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:903
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:1799
SourceLocation getDoLoc() const
Definition: Stmt.h:1183
SourceLocation getAtLoc() const
Definition: StmtObjC.h:363
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:675
ConditionKind
Definition: Sema.h:9748
bool isInvalid() const
Definition: Ownership.h:158
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition: Expr.cpp:1659
SourceLocation getRBracketLoc() const
Definition: Expr.h:2183
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:1717
bool isInstanceMethod() const
Definition: DeclObjC.h:452
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of &#39;F&#39;...
Definition: Expr.h:2587
Represents a GCC generic vector type.
Definition: Type.h:2914
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1187
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2595
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
Definition: Expr.h:4336
struct CXXOpName CXXOperatorName
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:12762
AtomicOp getOp() const
Definition: Expr.h:5167
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:728
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
UTTKind getUTTKind() const
Definition: Type.h:3923
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:3838
const OffsetOfNode & getComponent(unsigned Idx) const
Definition: Expr.h:1975
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:7613
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:2722
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:4452
ValueDecl * getDecl()
Definition: Expr.h:1041
SourceLocation getKWLoc() const
Definition: TypeLoc.h:1934
SourceLocation getLocation() const
Definition: Expr.h:1217
bool isUsable() const
Definition: Ownership.h:159
SourceLocation getRParenLoc() const
Definition: Expr.h:3810
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:1347
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:178
const Expr * getSubExpr() const
Definition: Expr.h:1681
ObjCBridgeCastKind getBridgeKind() const
Determine which kind of bridge is being performed via this cast.
Definition: ExprObjC.h:1599
const Expr * getSubExpr() const
Definition: ExprCXX.h:1219
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2073
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:2922
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition: ExprCXX.h:3789
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1003
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:719
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1271
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2154
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1480
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:1463
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:1990
This represents &#39;#pragma omp parallel for simd&#39; directive.
Definition: StmtOpenMP.h:1578
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:970
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:1158
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:3299
bool hasAttrExprOperand() const
Definition: TypeLoc.h:868
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:3133
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
bool hasTrailingReturn() const
Definition: Type.h:3625
RecordDecl * getDecl() const
Definition: Type.h:3986
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3303
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Definition: ExprCXX.h:126
void setIsVariadic(bool value)
Definition: Decl.h:3770
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:76
void setTypeofLoc(SourceLocation Loc)
Definition: TypeLoc.h:1842
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:2896
Expr * getArgument()
Definition: ExprCXX.h:2125
This represents &#39;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2350
Simple iterator that traverses the template arguments in a container that provides a getArgLoc() memb...
SourceLocation getLParenLoc()
Get location of &#39;(&#39;.
Definition: OpenMPClause.h:884
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition: Expr.cpp:1771
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:1529
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:338
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:868
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:936
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1980
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:3601
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
Definition: ExprObjC.h:1328
VarDecl * RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TInfo, QualType T)
Rebuild an Objective-C exception declaration.
CanQualType BuiltinFnTy
Definition: ASTContext.h:1014
SourceLocation getLParenLoc() const
Definition: Expr.h:2670
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:2997
Kind
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2254
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2548
This captures a statement into a function.
Definition: Stmt.h:2058
A field in a dependent type, known only by its name.
Definition: Expr.h:1831
Expr * getInit() const
Get the operand that doesn&#39;t contain a pack, for a binary fold.
Definition: ExprCXX.h:4185
QualType getCanonicalType() const
Definition: Type.h:5757
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1400
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2530
Token * getAsmToks()
Definition: Stmt.h:1830
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:144
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3365
Expr ** getPlacementArgs()
Definition: ExprCXX.h:1958
SourceLocation getLParenLoc()
Get location of &#39;(&#39;.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:4969
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2169
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:1108
QualType RebuildObjCObjectPointerType(QualType PointeeType, SourceLocation Star)
Build a new Objective-C object pointer type given the pointee type.
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:4745
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:3500
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2527
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:2658
const ExtParameterInfo * ExtParameterInfos
Definition: Type.h:3394
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Definition: ExprCXX.h:1449
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: Expr.h:2532
unsigned getNumExprs() const
Definition: Expr.h:4618
This represents &#39;#pragma omp single&#39; directive.
Definition: StmtOpenMP.h:1322
Encodes a location in the source.
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1343
body_range body()
Definition: Stmt.h:626
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:973
QualType getReturnType() const
Definition: Type.h:3201
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.
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:706
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:4002
SourceLocation getOperatorLoc() const
Definition: Expr.h:3023
StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new label statement.
const Stmt * getCatchBody() const
Definition: StmtObjC.h:90
unsigned getNumHandlers() const
Definition: StmtCXX.h:103
Expr * getSubExpr() const
Definition: Expr.h:1744
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3366
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:2932
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:1101
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information...
Definition: ExprCXX.h:2249
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:121
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition: ExprCXX.h:276
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1842
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:342
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:773
Expr * getLHS()
Definition: Stmt.h:764
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:481
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Definition: ExprCXX.h:457
DeclarationName getName() const
getName - Returns the embedded declaration name.
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:915
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2944
This represents &#39;schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:744
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:3688
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:1313
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:164
SourceLocation getExceptLoc() const
Definition: Stmt.h:1921
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.
QualType getElementType() const
Definition: Type.h:2949
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:487
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:459
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
This represents clause &#39;shared&#39; in the &#39;#pragma omp ...&#39; directives.
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1044
SourceLocation getProcBindKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:726
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Definition: StmtOpenMP.h:1482
SourceLocation getLBraceLoc() const
Definition: Stmt.h:1822
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2134
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1964
ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new address-of-label expression.
QualType RebuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Quals)
Build a new qualified type given its unqualified type and type qualifiers.
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:3513
OpenMPLinearClauseKind Modifier
Modifier of &#39;linear&#39; clause.
Definition: OpenMPClause.h:91
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:811
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:1247
SourceLocation getAtLoc() const
Definition: ExprObjC.h:402
This represents &#39;#pragma omp taskwait&#39; directive.
Definition: StmtOpenMP.h:1873
QualType getAllocatedType() const
Definition: ExprCXX.h:1916
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1166
const ParmVarDecl * getParamDecl(unsigned i) const
Definition: Decl.h:2190
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:54
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:5691
QualType getEquivalentType() const
Definition: Type.h:4104
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:5103
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2062
bool isArray() const
Definition: ExprCXX.h:1947
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:1305
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:3511
SourceLocation getGotoLoc() const
Definition: Stmt.h:1293
SourceLocation getAtFinallyLoc() const
Definition: StmtObjC.h:141
bool isObjCObjectPointerType() const
Definition: Type.h:6039
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:1723
static CXXDefaultInitExpr * Create(const ASTContext &C, SourceLocation Loc, FieldDecl *Field)
Field is the non-static data member whose default initializer is used by this expression.
Definition: ExprCXX.h:1131
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:746
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2403
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2121
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:2822
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition: Stmt.h:2159
OpenMPMapClauseKind getMapTypeModifier() const LLVM_READONLY
Fetches the map type modifier for the clause.
SourceLocation getAtCatchLoc() const
Definition: StmtObjC.h:102
Expr ** getInits()
Retrieve the set of initializers.
Definition: Expr.h:3905
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:2234
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:431
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:1538
No entity found met the criteria.
Definition: Lookup.h:36
AutoTypeKeyword getKeyword() const
Definition: Type.h:4416
NestedNameSpecifierLoc TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr)
Transform the given nested-name-specifier with source-location information.
IdentType getIdentType() const
Definition: Expr.h:1215
SourceLocation getEndLoc() const
Definition: Stmt.h:1824
Expr * getArrayRangeStart(const Designator &D) const
Definition: Expr.cpp:3804
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:1641
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:4459
An expression trait intrinsic.
Definition: ExprCXX.h:2493
EnumDecl * getDecl() const
Definition: Type.h:4009
Expr ** getExprs()
Definition: Expr.h:4630
const ObjCMethodDecl * getMethodDecl() const
Definition: ExprObjC.h:1302
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2045
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3488
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:7601
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1462
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:2986
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:2067
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition: TypeLoc.h:163
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
Definition: Type.cpp:2477
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:5025
OMPClause * RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;hint&#39; clause.
SourceLocation getStarLoc() const
Definition: Stmt.h:1330
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:423
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:565
MutableArrayRef< Expr * > MultiExprArg
Definition: Ownership.h:261
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:586
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:1944
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:2918
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
Definition: StmtCXX.h:240
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:216
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:2854
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1562
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:244
const Expr * getInitializer() const
Definition: Expr.h:2663
QualType getPointeeType() const
Definition: Type.h:2846
Represents a pack expansion of types.
Definition: Type.h:4994
Expr * getLHS() const
Definition: Expr.h:3029
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3191
SourceLocation getLocation() const LLVM_READONLY
Definition: ExprCXX.h:1451
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:1435
SourceLocation getLocEnd() const
Returns the ending location of the clause.
Definition: OpenMPClause.h:70
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1629
Represents a C11 generic selection.
Definition: Expr.h:4684
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:3817
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1006
const Expr * getBase() const
Definition: Expr.h:4808
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1206
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3444
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1572
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2802
SourceLocation getTypeofLoc() const
Definition: TypeLoc.h:1838
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
Definition: ExprCXX.h:3957
Represents a template argument.
Definition: TemplateBase.h:51
bool isDeduced() const
Definition: Type.h:4390
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:782
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
Definition: ExprCXX.h:2290
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "if" statement, if any.
Definition: Stmt.cpp:803
TypeSourceInfo * getClassTInfo() const
Definition: TypeLoc.h:1317
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:12885
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Definition: Expr.h:3401
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:366
TagTypeKind
The kind of a tag type.
Definition: Type.h:4686
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:556
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1025
OpenMPScheduleClauseModifier
OpenMP modifiers for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:67
bool isTypeOperand() const
Definition: ExprCXX.h:678
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition: Decl.cpp:2455
bool isNull() const
Determine whether this template name is NULL.
unsigned getNumAssocs() const
Definition: Expr.h:4711
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:1501
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
Definition: Type.cpp:1686
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:7224
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:2554
Stmt * getReturnStmtOnAllocFailure() const
Definition: StmtCXX.h:396
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:493
not evaluated yet, for special member function
Expr * getAllocate() const
Definition: StmtCXX.h:385
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1188
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition: Expr.h:2575
UnaryOperatorKind
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1256
SourceLocation getLocation() const
Definition: ExprObjC.h:726
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2071
ArrayRef< Capture > captures() const
Definition: Decl.h:3821
IdentifierInfo * getOutputIdentifier(unsigned i) const
Definition: Stmt.h:1710
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:1498
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:106
SourceLocation ModifierLoc
Location of linear modifier if any.
Definition: OpenMPClause.h:94
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
bool isVariadic() const
Definition: Decl.h:3769
bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL, LookupResult &R)
Transform the set of declarations in an OverloadExpr.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
Definition: Expr.cpp:1216
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:466
MSPropertyDecl * getPropertyDecl() const
Definition: ExprCXX.h:780
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:130
SourceLocation getLocStart() const LLVM_READONLY
Definition: TypeLoc.h:154
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:80
bool isImplicit() const
Definition: ExprCXX.h:967
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:354
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1260
ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, SourceLocation LParenLoc, Expr *Sub, SourceLocation RParenLoc)
Build a new C++ functional-style cast expression.
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:3396
Expr * getReturnValueInit() const
Definition: StmtCXX.h:391
Expr * getSourceExpression() const
Definition: TemplateBase.h:506
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:3129
AccessSpecifier getAccess() const
Definition: DeclBase.h:460
A constant boolean condition from &#39;if constexpr&#39;.
static ExprResult Owned(Expr *E)
A runtime availability query.
Definition: ExprObjC.h:1633
TemplateArgumentLocContainerIterator(ArgLocContainer &Container, unsigned Index)
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
Definition: Type.h:756
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:380
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:985
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2162
Stmt * getHandler() const
Definition: Stmt.h:2007
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4387
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3334
SourceLocation getLBraceLoc() const
Definition: Expr.h:4017
DeclarationName - The name of a declaration.
StmtClass getStmtClass() const
Definition: Stmt.h:378
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:576
VectorKind getVectorKind() const
Definition: Type.h:2959
Expr * getDefaultArg()
Definition: Decl.cpp:2493
SourceRange getIntroducerRange() const
Retrieve the source range covering the lambda introducer, which contains the explicit capture list su...
Definition: ExprCXX.h:1750
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Definition: Decl.h:337
Expr * getOperand() const
Retrieve the operand of the &#39;co_return&#39; statement.
Definition: StmtCXX.h:456
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:3652
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1317
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:4330
This represents clause &#39;linear&#39; in the &#39;#pragma omp ...&#39; directives.
EnumDecl - Represents an enum.
Definition: Decl.h:3239
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:371
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2502
bool hasObjCLifetime() const
Definition: Type.h:340
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:1249
bool isIfExists() const
Determine whether this is an __if_exists statement.
Definition: StmtCXX.h:265
Expr * get() const
Definition: Sema.h:3632
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition: TypeLoc.h:890
NestedNameSpecifierLoc getQualifierLoc() const
Definition: ExprCXX.h:783
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:3534
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:1008
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2100
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:4271
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:1596
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:685
Expr * getArrayRangeEnd(const Designator &D) const
Definition: Expr.cpp:3810
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
Definition: SemaDecl.cpp:1156
const Stmt * getBody() const
Definition: Stmt.h:1050
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2009
Represents a __leave statement.
Definition: Stmt.h:2023
CXXRecordDecl * getNamingClass() const
Gets the &#39;naming class&#39; (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition: ExprCXX.h:2817
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2001
QualType getModifiedType() const
Definition: Type.h:4103
unsigned getNumParams() const
Definition: TypeLoc.h:1471
LabelDecl * getLabel() const
Definition: Expr.h:3466
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2084
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:1542
bool hasAttrEnumOperand() const
Definition: TypeLoc.h:873
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3600
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:150
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:1011
SourceLocation getColonColonLoc() const
Retrieve the location of the &#39;::&#39; in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2278
Name lookup found a single declaration that met the criteria.
Definition: Lookup.h:45
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...
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1253
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:2908
SourceLocation getRParenLoc() const
Definition: StmtObjC.h:55
DeclarationNameInfo getNameInfo() const
Definition: Expr.h:1045
void setAttrEnumOperandLoc(SourceLocation loc)
Definition: TypeLoc.h:923
Represents the body of a coroutine.
Definition: StmtCXX.h:299
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:3976
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, TypeSourceInfo *EncodedTypeInfo, SourceLocation RParenLoc)
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
unsigned getIndexTypeCVRQualifiers() const
Definition: Type.h:2603
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, Expr *SubExpr, TypeSourceInfo *TInfo, SourceLocation RParenLoc)
Build a new va_arg expression.
Expr * getBase() const
Definition: ExprObjC.h:1462
ExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build a new binary operator expression.
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2528
SourceLocation getBuiltinLoc() const
Definition: Expr.h:3551
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:2121
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
Definition: TypeLoc.h:1022
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:669
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1665
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:386
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition: ExprCXX.h:3792
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2278
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2294
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:1834
const llvm::APInt & getSize() const
Definition: Type.h:2636
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1984
Kind getAttrKind() const
Definition: Type.h:4099
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:203
bool isFunctionType() const
Definition: Type.h:5938
SourceLocation getRParenLoc() const
Definition: Expr.h:3719
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4304
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:707
Stmt * getInit()
Definition: Stmt.h:1046
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:1281
SourceRange getDirectInitRange() const
Definition: ExprCXX.h:2050
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information...
Definition: ExprCXX.h:3309
OpenMPScheduleClauseKind
OpenMP attributes for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:59
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:791
Expr * getSizeExpr() const
Definition: TypeLoc.h:1554
Opcode getOpcode() const
Definition: Expr.h:1741
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1365
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:2419
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
decl_range decls()
Definition: Stmt.h:534
ActionResult< Stmt * > StmtResult
Definition: Ownership.h:252
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:3913
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:113
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1014
Wrapper for source info for record types.
Definition: TypeLoc.h:717
SourceLocation getLocStart() const LLVM_READONLY
Default argument expressions have no representation in the source, so they have an empty source range...
Definition: ExprCXX.h:1090
SourceLocation getLBracketLoc() const
Definition: TypeLoc.h:1534
Represents Objective-C&#39;s @finally statement.
Definition: StmtObjC.h:120
SourceLocation getDefaultLoc() const
Definition: Expr.h:4714
The template argument is a type.
Definition: TemplateBase.h:60
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1339
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:2250
StringRef getAsmString() const
Definition: Stmt.h:1833
OpenMPDefaultClauseKind
OpenMP attributes for &#39;default&#39; clause.
Definition: OpenMPKinds.h:43
ArrayRef< StringRef > getAllConstraints() const
Definition: Stmt.h:1867
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
SourceLocation getLocStart() const
Definition: ExprCXX.h:507
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
Definition: ScopeInfo.h:594
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3296
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: Expr.h:2563
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
This represents &#39;write&#39; clause in the &#39;#pragma omp atomic&#39; directive.
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1162
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)
const Expr * Replacement
Definition: AttributeList.h:59
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
unsigned getNumClobbers() const
Definition: Stmt.h:1546
bool isImplicit() const
Definition: StmtCXX.h:465
SourceLocation getRParenLoc() const
Definition: Stmt.h:1258
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:513
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:3368
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof...
Definition: ExprCXX.h:3812
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:3147
bool capturesCXXThis() const
Definition: Decl.h:3826
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:1080
UnqualTypeLoc getUnqualifiedLoc() const
Definition: TypeLoc.h:276
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2464
Expr * getRHS() const
Definition: Expr.h:3713
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:2644
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3087
SourceLocation getAsmLoc() const
Definition: Stmt.h:1495
GotoStmt - This represents a direct goto.
Definition: Stmt.h:1278
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1113
Expr * getTarget()
Definition: Stmt.h:1332
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:239
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:3625
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3349
TypedefNameDecl * getDecl() const
Definition: Type.h:3773
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:13010
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getTypeArgsLAngleLoc() const
Definition: TypeLoc.h:1002
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 EST_ComputedNoexcept.
Definition: Type.h:3371
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;.
Definition: OpenMPClause.h:957
An integral condition for a &#39;switch&#39; statement.
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition: Stmt.cpp:1100
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:4031
bool isFreeIvar() const
Definition: ExprObjC.h:552
Expr * getCond()
Definition: Stmt.h:1176
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2282
Call-style initialization (C++98)
Definition: Decl.h:814
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Represents a type parameter type in Objective C.
Definition: Type.h:5110
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
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
Definition: OpenMPClause.h:879
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:989
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2387
SourceLocation getWhileLoc() const
Definition: Stmt.h:1185
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...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:5798
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2467
This represents &#39;nowait&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:975
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
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:4901
ContinueStmt - This represents a continue.
Definition: Stmt.h:1355
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:838
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
Definition: OpenMPClause.h:874
Represents a loop initializing the elements of an array.
Definition: Expr.h:4490
const TemplateArgumentLoc * operator->() const
This represents &#39;num_tasks&#39; clause in the &#39;#pragma omp ...&#39; directive.
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1452
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:76
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.cpp:453
Stmt * getFallthroughHandler() const
Definition: StmtCXX.h:381
SourceLocation getColonLoc() const
Definition: StmtCXX.h:195
Represents a C array with an unspecified size.
Definition: Type.h:2672
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:3664
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:1924
QualType RebuildAutoType(QualType Deduced, AutoTypeKeyword Keyword)
Build a new C++11 auto type.
SourceLocation getAttrLoc() const
Definition: Stmt.h:914
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3342
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:29
An index into an array.
Definition: Expr.h:1827
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1471
SourceLocation getRParenLoc() const
Definition: Expr.h:4637
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
Definition: OpenMPClause.h:871
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:5745
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:3315
Expr * getOperand() const
Definition: ExprCXX.h:4325
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1964
void setParam(unsigned i, ParmVarDecl *VD)
Definition: TypeLoc.h:1478
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition: TypeLoc.h:932
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:4813
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:1102
SourceLocation getFirstScheduleModifierLoc() const
Get the first modifier location.
Definition: OpenMPClause.h:890
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1382
TryCaptureKind
Definition: Sema.h:4010
unsigned getNumProtocols() const
Definition: TypeLoc.h:1048
helper_expr_const_range reduction_ops() const
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1170
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Definition: Type.h:4277
Location information for a TemplateArgument.
Definition: TemplateBase.h:393
SourceRange getParensRange() const
Definition: TypeLoc.h:1955
bool isCXXThisCaptured() const
Determine whether the C++ &#39;this&#39; is captured.
Definition: ScopeInfo.h:633
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1502
SourceLocation getAtSynchronizedLoc() const
Definition: StmtObjC.h:279
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:136
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:3692
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:757
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
bool hasAttrOperand() const
Definition: TypeLoc.h:878
SourceLocation getEllipsisLoc() const
Definition: ExprCXX.h:4187
The receiver is a class.
Definition: ExprObjC.h:1051
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:265
bool isGlobalDelete() const
Definition: ExprCXX.h:2111
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:2852
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_convertvector token.
Definition: Expr.h:3636
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:3287
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1509
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
Definition: ExprCXX.h:1779
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:2209
bool TransformTemplateArgument(const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output, bool Uneval=false)
Transform the given template argument.
SourceLocation getNameLoc() const
Definition: TypeLoc.h:518
SourceRange getTypeIdParens() const
Definition: ExprCXX.h:1972
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:3681
bool HasImplicitReturnType
Whether the target type of return statements in this context is deduced (e.g.
Definition: ScopeInfo.h:605
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1645
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:270
ExprResult ExprError()
Definition: Ownership.h:267
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:1756
bool blockMissingReturnType() const
Definition: Decl.h:3827
bool TransformExceptionSpec(SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, SmallVectorImpl< QualType > &Exceptions, bool &Changed)
Expr * getLHS() const
Definition: Expr.h:3711
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition: ExprCXX.cpp:961
Stmt * getBody() const
Retrieve the body of the coroutine as written.
Definition: StmtCXX.h:360
unsigned getNumTypeArgs() const
Definition: TypeLoc.h:1018
ExprResult RebuildImplicitValueInitExpr(QualType T)
Build a new value-initialized expression.
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:246
unsigned getNumElements() const
Definition: Type.h:2950
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:2685
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:1192
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:54
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:82
bool isObjectReceiver() const
Definition: ExprObjC.h:738
TranslationUnitDecl - The top declaration context.
Definition: Decl.h:107
unsigned getNumComponents() const
Definition: Expr.h:1985
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2292
bool isReadOnly() const
Definition: Type.h:5681
ExprResult RebuildStmtExpr(SourceLocation LParenLoc, Stmt *SubStmt, SourceLocation RParenLoc)
Build a new GNU statement expression.
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1073
ExprResult RebuildConvertVectorExpr(SourceLocation BuiltinLoc, Expr *SrcExpr, TypeSourceInfo *DstTInfo, SourceLocation RParenLoc)
Build a new convert vector expression.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:1858
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:956
Represents an extended address space qualifier where the input address space value is dependent...
Definition: Type.h:2832
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4493
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:3780
Expr * getRHS() const
Definition: Expr.h:3031
QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL)
Transforms a reference type.
ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc, QualType ThisType, bool isImplicit)
Build a new C++ "this" expression.
SourceLocation getColonLoc() const
Definition: Stmt.h:761
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:2667
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
bool isPointerType() const
Definition: Type.h:5942
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1036
Iterator adaptor that invents template argument location information for each of the template argumen...
BreakStmt - This represents a break.
Definition: Stmt.h:1381
Expr * getChunkSize()
Get chunk size.
Definition: OpenMPClause.h:903
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:94
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:532
Expr * getOperand() const
Definition: ExprCXX.h:4400
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:1735
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: ExprCXX.h:3342
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition: Expr.cpp:2620
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:426
Stmt * getSubStmt()
Definition: Stmt.h:862
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
SourceLocation getBridgeKeywordLoc() const
The location of the bridge keyword.
Definition: ExprObjC.h:1607
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1...
Definition: ExprCXX.h:1313
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3835
DeclStmt * getLoopVarStmt()
Definition: StmtCXX.h:161
QualType getType() const
Definition: Decl.h:638
Wrapper for source info for builtin types.
Definition: TypeLoc.h:545
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:111
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1174
unsigned getNumArgs() const
Definition: ExprCXX.h:1362
Wrapper for template type parameters.
Definition: TypeLoc.h:733
static Designator getArray(Expr *Index, SourceLocation LBracketLoc)
Definition: Designator.h:136
const Expr * getBase() const
Definition: ExprObjC.h:719
const Expr * getCond() const
Definition: Stmt.h:969
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:316
This represents &#39;#pragma omp taskyield&#39; directive.
Definition: StmtOpenMP.h:1785
NamedDecl - This represents a decl with a name.
Definition: Decl.h:245
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
Definition: DeclSpec.h:999
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:3125
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:530
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: Expr.h:2518
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:1926
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
Definition: TypeLoc.h:75
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2717
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2532
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1646
Represents a C++ namespace alias.
Definition: DeclCXX.h:2947
StmtResult RebuildCoreturnStmt(SourceLocation CoreturnLoc, Expr *Result, bool IsImplicit)
Build a new co_return statement.
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1669
Sema & getSema() const
Retrieves a reference to the semantic analysis object used for this tree transform.
SourceLocation getBuiltinLoc() const
Definition: Expr.h:5193
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2125
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:856
No keyword precedes the qualified type name.
Definition: Type.h:4726
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1504
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, MultiStmtArg Statements, SourceLocation RBraceLoc, bool IsStmtExpr)
Build a new compound statement.
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:1886
SourceLocation getAttributeLoc() const
Definition: Type.h:2847
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:3382
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:2958
TypeSourceInfo * getWrittenTypeInfo() const
Definition: Expr.h:3804
DeclStmt * getBeginStmt()
Definition: StmtCXX.h:155
const ExtParameterInfo * getExtParameterInfosOrNull() const
Return a pointer to the beginning of the array of extra parameter information, if present...
Definition: Type.h:3678
SourceLocation getRightLoc() const
Definition: ExprObjC.h:1363
const Expr * getCond() const
Definition: Stmt.h:1049
static Designator getArrayRange(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Definition: Designator.h:146
attr::Kind getKind() const
Definition: Attr.h:84
The receiver is a superclass.
Definition: ExprObjC.h:1057
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:527
SourceLocation getGenericLoc() const
Definition: Expr.h:4713
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
Definition: ExprObjC.cpp:290
SourceLocation getAttrEnumOperandLoc() const
The location of the attribute&#39;s enumerated operand, if it has one.
Definition: TypeLoc.h:919
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:2910
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.cpp:277
Wrapper for source info for pointers.
Definition: TypeLoc.h:1271
SourceLocation getBegin() const
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
Definition: Expr.h:3628
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4188
SourceLocation ColonLoc
Location of &#39;:&#39;.
Definition: OpenMPClause.h:97
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
Definition: Expr.h:1965
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
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
Definition: Decl.h:722
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:3795
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1284
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:3725
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:4264
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2618
CompoundStmt * getTryBlock() const
Definition: Stmt.h:2003
Stmt * getSubStmt()
Definition: Stmt.h:919
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:3393
QualType getBaseType() const
Definition: ExprCXX.h:3516
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4029
QualType RebuildDeducedTemplateSpecializationType(TemplateName Template, QualType Deduced)
By default, builds a new DeducedTemplateSpecializationType with the given deduced type...
Expr * getBaseExpr() const
Definition: ExprCXX.h:779
QualType RebuildTypedefType(TypedefNameDecl *Typedef)
Build a new typedef type.
The symbol does not exist.
Definition: Sema.h:4455
void clear()
Clears out any current state.
Definition: Lookup.h:557
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:4580
CompoundStmt * getBlock() const
Definition: Stmt.h:1928
static StmtResult Owned(Stmt *S)
SourceLocation getReturnLoc() const
Definition: Stmt.h:1436
Stmt * getFinalSuspendStmt() const
Definition: StmtCXX.h:374
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2005
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition: Stmt.cpp:1115
This represents &#39;#pragma omp target parallel for&#39; directive.
Definition: StmtOpenMP.h:2527
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:43
SourceLocation getLocation() const
Definition: DeclBase.h:416
This represents clause &#39;use_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
SourceLocation getTypeArgsRAngleLoc() const
Definition: TypeLoc.h:1010
QualType getPointeeType() const
Definition: Type.h:2522
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:97
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2378
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:1907
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3328
const IdentifierInfo * getIdentifier() const
Definition: Type.h:4932
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:1689
ConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1336
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:1234
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:1070
A RAII object to temporarily push a declaration context.
Definition: Sema.h:705
Stmt * getSubStmt()
Definition: Stmt.h:766
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:2787